summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/client.h3
-rw-r--r--protocols/FacebookRM/src/communication.cpp24
-rw-r--r--protocols/FacebookRM/src/connection.cpp6
-rw-r--r--protocols/FacebookRM/src/contacts.cpp5
-rw-r--r--protocols/FacebookRM/src/entities.h4
-rw-r--r--protocols/FacebookRM/src/json.cpp293
-rw-r--r--protocols/FacebookRM/src/json.h1
-rw-r--r--protocols/FacebookRM/src/process.cpp133
-rw-r--r--protocols/FacebookRM/src/proto.cpp17
-rw-r--r--protocols/FacebookRM/src/proto.h2
-rw-r--r--protocols/FacebookRM/src/theme.cpp6
-rw-r--r--protocols/FacebookRM/src/version.h4
12 files changed, 200 insertions, 298 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index a6b0ddd4ac..f065893af7 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -39,7 +39,7 @@ public:
{
msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = random_ = chat_msgs_recv_ = chat_req_ = 0;
- buddies_lock_ = send_message_lock_ = notifications_lock_ = cookies_lock_ = NULL;
+ send_message_lock_ = notifications_lock_ = cookies_lock_ = NULL;
hMsgCon = NULL;
hFcbCon = NULL;
fcb_conn_lock_ = NULL;
@@ -184,7 +184,6 @@ public:
// Updates handling
List::List<facebook_user> buddies;
- HANDLE buddies_lock_;
HANDLE send_message_lock_;
HANDLE notifications_lock_;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp
index 8e77b71316..c847279530 100644
--- a/protocols/FacebookRM/src/communication.cpp
+++ b/protocols/FacebookRM/src/communication.cpp
@@ -1273,6 +1273,8 @@ bool facebook_client::channel()
}
std::string type = utils::text::source_get_value(&resp.data, 2, "\"t\":\"", "\"");
+ parent->debugLogA("Pull response type = %s", type.c_str());
+
if (type == "continue" || type == "heartbeat") {
// Everything is OK, no new message received
}
@@ -1284,21 +1286,19 @@ bool facebook_client::channel()
this->chat_sticky_num_ = utils::text::source_get_value2(&resp.data, "\"sticky\":\"", "\"");
parent->debugLogA(" Got self sticky number: %s", this->chat_sticky_num_.c_str());
}
- else if (type == "fullReload" || type == "refresh") {
- // Requested reload of page or relogin (due to some settings change, removing this session, etc.)
- parent->debugLogA("!!! Requested %s", type.c_str());
+ if (type == "refresh") {
+ // Requested relogin (due to some settings change, removing this session, etc.)
+ parent->debugLogA("!!! Requested refresh");
this->chat_sequence_num_ = utils::text::source_get_value2(&resp.data, "\"seq\":", ",}");
parent->debugLogA(" Got self sequence number: %s", this->chat_sequence_num_.c_str());
- if (type == "refresh") {
- this->chat_reconnect_reason_ = utils::text::source_get_value2(&resp.data, "\"reason\":", ",}");
- parent->debugLogA(" Got reconnect reason: %s", this->chat_reconnect_reason_.c_str());
+ this->chat_reconnect_reason_ = utils::text::source_get_value2(&resp.data, "\"reason\":", ",}");
+ parent->debugLogA(" Got reconnect reason: %s", this->chat_reconnect_reason_.c_str());
- return this->reconnect();
- }
- }
- else if (!type.empty()) {
+ return this->reconnect();
+ }
+ else if (!type.empty()) { // for "msg", "fullReload" and maybe also other types
// Something has been received, throw to new thread to process
std::string* response_data = new std::string(resp.data);
parent->ForkThread(&FacebookProto::ProcessMessages, response_data);
@@ -1311,6 +1311,10 @@ bool facebook_client::channel()
// Update msgs_recv number for every "msg" type we receive (during fullRefresh/reload responses it stays the same)
this->chat_msgs_recv_++;
}
+ else if (type == "fullReload") {
+ // At fullReload we force our seq number to received value (there may have been some error or something)
+ this->chat_sequence_num_ = seq;
+ }
// Check if it's different from our old one (which means we should increment our old one)
if (seq != this->chat_sequence_num_) {
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp
index 4a34435549..06222249fc 100644
--- a/protocols/FacebookRM/src/connection.cpp
+++ b/protocols/FacebookRM/src/connection.cpp
@@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
void FacebookProto::ChangeStatus(void*)
{
ScopedLock s(signon_lock_);
- ScopedLock b(facy.buddies_lock_);
int new_status = m_iDesiredStatus;
int old_status = m_iStatus;
@@ -64,7 +63,6 @@ void FacebookProto::ChangeStatus(void*)
facy.clear_notifications();
facy.clear_chatrooms();
facy.clear_readers();
- facy.buddies.clear();
facy.messages_ignore.clear();
facy.messages_timestamp.clear();
facy.pages.clear();
@@ -168,8 +166,6 @@ void FacebookProto::ChangeStatus(void*)
facy.chat_state(!m_invisible);
- ForkThread(&FacebookProto::ProcessBuddyList, NULL);
-
m_iStatus = facy.self_.status_id = new_status;
ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
@@ -216,8 +212,6 @@ void FacebookProto::UpdateLoop(void *)
for (int i = -1; !isOffline(); i = (i + 1) % 50)
{
if (i != -1) {
- ProcessBuddyList(NULL);
-
if (getByte(FACEBOOK_KEY_EVENT_FEEDS_ENABLE, DEFAULT_EVENT_FEEDS_ENABLE))
ProcessFeeds(NULL);
}
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 167933f061..70bb6aca5a 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -489,9 +489,10 @@ void FacebookProto::DeleteContactFromServer(void *data)
if (resp.data.find("\"payload\":null", 0) != std::string::npos)
{
- facebook_user* fbu = facy.buddies.find(id);
+ // FIXME: Remember that we deleted this contact, so we won't accidentally add him at status change
+ /* facebook_user* fbu = facy.buddies.find(id);
if (fbu != NULL)
- fbu->deleted = true;
+ fbu->deleted = true; */
MCONTACT hContact = ContactIDToHContact(id);
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h
index 88be2bd21e..8cd50f590b 100644
--- a/protocols/FacebookRM/src/entities.h
+++ b/protocols/FacebookRM/src/entities.h
@@ -40,6 +40,8 @@ struct facebook_user
bool deleted;
bool idle;
+ bool updated;
+
ClientType client;
facebook_user()
@@ -47,7 +49,7 @@ struct facebook_user
this->handle = NULL;
this->status_id = ID_STATUS_OFFLINE;
this->gender = this->last_active = 0;
- this->deleted = this->idle = false;
+ this->deleted = this->idle = this->updated = false;
this->client = CLIENT_WEB;
}
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 901b28ada6..7b5ac5dd04 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -22,100 +22,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-int facebook_json_parser::parse_buddy_list(std::string *data, List::List< facebook_user >* buddy_list)
-{
- facebook_user* current = NULL;
- std::string jsonData = data->substr(9);
-
- JSONNode root = JSONNode::parse(jsonData.c_str());
- if (!root)
- return EXIT_FAILURE;
-
- const JSONNode &list = root["payload"].at("buddy_list");
- if (!list)
- return EXIT_FAILURE;
-
- // Set all contacts in map to offline (and reset client)
- for (List::Item< facebook_user >* i = buddy_list->begin(); i != NULL; i = i->next) {
- i->data->status_id = ID_STATUS_OFFLINE;
- if (i->data->client == 0)
- i->data->client = CLIENT_WEB;
- }
-
- // Load last active times
- const JSONNode &lastActive = list["last_active_times"];
- for (auto it = lastActive.begin(); it != lastActive.end(); ++it) {
- const char *id = (*it).name();
-
- current = buddy_list->find(id);
- if (current == NULL) {
- buddy_list->insert(std::make_pair(id, new facebook_user()));
- current = buddy_list->find(id);
- current->user_id = id;
- }
-
- current->last_active = (*it).as_int();
- }
-
- // Find mobile friends
- const JSONNode &mobileFriends = list["mobile_friends"];
- for (auto it = mobileFriends.begin(); it != mobileFriends.end(); ++it) {
- std::string id = (*it).as_string();
-
- current = buddy_list->find(id);
- if (current == NULL) {
- buddy_list->insert(std::make_pair(id, new facebook_user()));
- current = buddy_list->find(id);
- current->user_id = id;
- }
-
- current->status_id = ID_STATUS_OFFLINE;
- current->client = CLIENT_MOBILE;
- }
-
- time_t now = ::time(NULL);
-
- // Find now available contacts
- const JSONNode &nowAvailable = list["nowAvailableList"];
- for (auto it = nowAvailable.begin(); it != nowAvailable.end(); ++it) {
- const char *id = (*it).name();
-
- current = buddy_list->find(id);
- if (current == NULL) {
- buddy_list->insert(std::make_pair(id, new facebook_user()));
- current = buddy_list->find(id);
- current->user_id = id;
- }
-
- current->status_id = (current->client == CLIENT_MOBILE || current->client == CLIENT_MESSENGER) ? ID_STATUS_ONTHEPHONE : ID_STATUS_ONLINE;
-
- // Set contacts that were last active more than 1 minute ago as away
- if (current->status_id == ID_STATUS_ONLINE && current->last_active > 0 && (now - current->last_active) > 60) {
- current->status_id = ID_STATUS_AWAY;
- }
- }
-
- // Get aditional informations about contacts (if available)
- const JSONNode &userInfos = list["userInfos"];
- for (auto it = userInfos.begin(); it != userInfos.end(); ++it) {
- const char *id = (*it).name();
-
- current = buddy_list->find(id);
- if (current == NULL)
- continue;
-
- std::string name = (*it)["name"].as_string();
- if (!name.empty())
- current->real_name = utils::text::slashu_to_utf8(name);
-
- std::string thumbSrc = (*it)["thumbSrc"].as_string();
- if (!thumbSrc.empty())
- current->image_url = utils::text::slashu_to_utf8(thumbSrc);
- }
-
- return EXIT_SUCCESS;
-}
-
void parseUser(const JSONNode &it, facebook_user *fbu)
{
fbu->user_id = it.name();
@@ -758,54 +664,191 @@ int facebook_json_parser::parse_messages(std::string *pData, std::vector<faceboo
proto->SetStatus(isVisible ? ID_STATUS_ONLINE : ID_STATUS_INVISIBLE);
}
}
+ else if (t == "chatproxy-presence") {
+ const JSONNode &buddyList = (*it)["buddyList"];
+ if (!buddyList)
+ continue;
+
+ for (auto itNodes = buddyList.begin(); itNodes != buddyList.end(); ++itNodes) {
+ std::string id = (*itNodes).name();
+
+ MCONTACT hContact = proto->ContactIDToHContact(id);
+ if (!hContact) {
+ // FIXME: What to do, when we don't have this contact? What does it mean?
+ // fbu->handle = AddToContactList(fbu, CONTACT_FRIEND); // add this contact as friend?
+ continue;
+ }
+
+ // TODO: Check for friends existence/inexistence? Here we should get all friends (but we're already doing friendslist request, so we should have fresh data already)
+
+ const JSONNode &p_ = (*itNodes)["p"]; // possible values: 0, 2 (something more?) (might not be present)
+ const JSONNode &lat_ = (*itNodes)["lat"]; // timestamp of last activity (could be 0) (is always present)
+ const JSONNode &vc_ = (*itNodes)["vc"]; // possible values: 0, 8, 10 (something more?) (might not be present)
+
+ int status = ID_STATUS_DND; // DND to easily spot some problem, as we expect it will always be p==0 or p==2 below
+
+ // Probably means presence: 0 = away, 2 = online, when not present then that probably means don't change that status
+ if (p_) {
+ int p = p_.as_int();
+
+ if (p == 0)
+ status = ID_STATUS_AWAY;
+ else if (p == 2)
+ status = ID_STATUS_ONLINE;
+
+ if (proto->getWord(hContact, "Status", 0) != status)
+ proto->setWord(hContact, "Status", status);
+ }
+
+ // Last active time
+ if (lat_) {
+ time_t last_active = utils::time::from_string(lat_.as_string());
+
+ if (proto->getDword(hContact, "LastActiveTS", 0) != last_active) {
+ if (last_active > 0)
+ proto->setDword(hContact, "LastActiveTS", last_active);
+ else
+ proto->delSetting(hContact, "LastActiveTS");
+ }
+ }
+
+ // Probably means client: guess 0 = web, 8 = messenger, 10 = something else?
+ if (vc_) {
+ int vc = vc_.as_int();
+ TCHAR *client;
+
+ if (vc == 0) {
+ client = _T(FACEBOOK_CLIENT_WEB);
+ }
+ else if (vc == 8) {
+ client = _T(FACEBOOK_CLIENT_MESSENGER); // I was online on Miranda, but when looked at myself at messenger.com I had icon of Messenger.
+ }
+ else if (vc == 10) {
+ client = _T(FACEBOOK_CLIENT_MOBILE);
+ }
+ else {
+ client = _T(FACEBOOK_CLIENT_OTHER);
+ }
+
+ ptrT oldClient(proto->getTStringA(hContact, "MirVer"));
+ if (!oldClient || mir_tstrcmp(oldClient, client))
+ proto->setTString(hContact, "MirVer", client);
+ }
+ }
+ }
else if (t == "buddylist_overlay") {
- // additional info about user status (used client)
+ // TODO: This is now supported also via /ajax/mercury/tabs_presence.php request (probably)
+ // additional info about user status (status, used client)
const JSONNode &overlay = (*it)["overlay"];
if (!overlay)
continue;
for (auto itNodes = overlay.begin(); itNodes != overlay.end(); ++itNodes) {
- std::string id = (*itNodes).as_string();
+ std::string id = (*itNodes).name();
- const JSONNode &p_ = (*itNodes)["p"];
- if (!p_)
+ MCONTACT hContact = proto->ContactIDToHContact(id);
+ if (!hContact) {
+ // FIXME: What to do, when we don't have this contact? What does it mean?
+ // fbu->handle = AddToContactList(fbu, CONTACT_FRIEND); // add this contact as friend?
continue;
+ }
- // TODO: This is now supported also via /ajax/mercury/tabs_presence.php request
- const JSONNode &p = (*it)["p"];
- if (p) {
- facebook_user* current = proto->facy.buddies.find(id); // HACKISH-WAY to get buddies...
- if (current == NULL)
- continue;
+ // TODO: Check for friends existence/inexistence?
- std::string status = p["status"].as_string(); // this seems to be "active" or "invisible" or null
- std::string webStatus = p["webStatus"].as_string(); // "active", "idle" or "offline"
- std::string fbAppStatus = p["fbAppStatus"].as_string(); // "offline" or "active" or "invisible" or null
- std::string messengerStatus = p["messengerStatus"].as_string(); // "offline" or "active" or "invisible" or null
- std::string otherStatus = p["otherStatus"].as_string(); // "offline" or "active" or "invisible" or null - this seems to be "active" when webStatus is "idle" or "active" only
+ /* if (getByte(fbu->handle, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND) {
+ setByte(fbu->handle, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_FRIEND);
+ // TODO: remove that popup and use "Contact added you" event?
+ }
- // this may never happen
- if (status != "active")
- current->status_id = ID_STATUS_OFFLINE;
+ // Wasn't contact removed from "server-list" someday?
+ if (getDword(fbu->handle, FACEBOOK_KEY_DELETED, 0)) {
+ delSetting(fbu->handle, FACEBOOK_KEY_DELETED);
- bool b;
+ std::string url = FACEBOOK_URL_PROFILE + fbu->user_id;
+ std::string contactname = getContactName(this, fbu->handle, !fbu->real_name.empty() ? fbu->real_name.c_str() : fbu->user_id.c_str());
- // "webStatus" and "otherStatus" are marked as "WEB" on FB website
- if ((b = (webStatus == "active")) || otherStatus == "active") {
- current->status_id = ID_STATUS_ONLINE;
- current->client = b ? CLIENT_WEB : CLIENT_OTHER;
- }
+ ptrT szTitle(mir_utf8decodeT(contactname.c_str()));
+ NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), fbu->handle, FACEBOOK_EVENT_FRIENDSHIP, &url);
+ } */
+
+
+ /* ptrT client(getTStringA(fbu->handle, "MirVer"));
+ if (!client || mir_tstrcmp(client, fbu->getMirVer()))
+ setTString(fbu->handle, "MirVer", fbu->getMirVer());
+ */
+
+ const JSONNode &a_ = (*itNodes)["a"]; // possible values: 0, 2 (something more?)
+ const JSONNode &la_ = (*itNodes)["la"]; // timestamp of last activity (could be 0)
+ const JSONNode &s_ = (*itNodes)["s"]; // possible values: push (something more?)
+ const JSONNode &vc_ = (*itNodes)["vc"]; // possible values: 0, 8, 10 (something more?)
+
+ // Friller account has also these:
+ // const JSONNode &ol_ = (*itNodes)["ol"]; // possible values: -1 (when goes to offline), 0 (when goes back online) (something more?)
+ // const JSONNode &p_ = (*itNodes)["p"]; // class with fbAppStatus, messengerStatus, otherStatus, status, webStatus
+
+ int status = ID_STATUS_FREECHAT; // FREECHAT to easily spot some problem, as we expect it will always be p==0 or p==2 below
+
+ if (a_) {
+ int a = a_.as_int();
+
+ if (a == 0)
+ status = ID_STATUS_OFFLINE;
+ else if (a == 2)
+ status = ID_STATUS_ONLINE;
+ }
- // "fbAppStatus" and "messengerStatus" are marked as "MOBILE" on FB website
- if ((b = (fbAppStatus == "active")) || messengerStatus == "active") {
- current->status_id = ID_STATUS_ONTHEPHONE;
- current->client = b ? CLIENT_APP : CLIENT_MESSENGER;
+ if (proto->getWord(hContact, "Status", 0) != status)
+ proto->setWord(hContact, "Status", status);
+
+
+ if (la_ && status != ID_STATUS_ONLINE) {
+ time_t last_active = utils::time::from_string(la_.as_string());
+
+ // we should set IdleTS only when contact is IDLE, or OFFLINE
+ if (proto->getDword(hContact, "IdleTS", 0) != last_active) {
+ if (/*(fbu->idle || status == ID_STATUS_OFFLINE) &&*/ last_active > 0)
+ proto->setDword(hContact, "IdleTS", last_active);
+ else
+ proto->delSetting(hContact, "IdleTS");
}
- // this is not marked anyhow on website (yet?)
- current->idle = webStatus == "idle" || otherStatus == "idle" || fbAppStatus == "idle" || messengerStatus == "idle";
+ /*if (proto->getDword(hContact, "LastActiveTS", 0) != last_active) {
+ if (last_active > 0)
+ proto->setDword(hContact, "LastActiveTS", last_active);
+ else
+ proto->delSetting(hContact, "LastActiveTS");
+ }*/
+ }
+ else {
+ proto->delSetting(hContact, "IdleTS");
+ }
+
+ if (s_) {
+ // what to do with this?
+ }
+ // Probably means client: guess 0 = web, 8 = messenger, 10 = something else?
+ if (vc_) {
+ int vc = vc_.as_int();
+ TCHAR *client = _T(FACEBOOK_CLIENT_WEB);
+
+ /*if (vc == 0) {
+ // means active some time ago? (on messenger or also on web)
+ client = _T(FACEBOOK_CLIENT_WEB);
+ }
+ else if (vc == 8) {
+ client = _T(FACEBOOK_CLIENT_MESSENGER); // I was online on Miranda, but when looked at myself at messenger.com I had icon of Messenger.
+ }
+ else if (vc == 10) {
+ // means actually active on messenger
+ client = _T(FACEBOOK_CLIENT_MOBILE);
+ }
+ else {
+ client = _T(FACEBOOK_CLIENT_OTHER);
+ }*/
- // TODO: save that info to DB
+ ptrT oldClient(proto->getTStringA(hContact, "MirVer"));
+ if (!oldClient || mir_tstrcmp(oldClient, client))
+ proto->setTString(hContact, "MirVer", client);
}
}
} else if (t == "ticker_update:home") {
diff --git a/protocols/FacebookRM/src/json.h b/protocols/FacebookRM/src/json.h
index b900487e36..b392fb247e 100644
--- a/protocols/FacebookRM/src/json.h
+++ b/protocols/FacebookRM/src/json.h
@@ -30,7 +30,6 @@ class facebook_json_parser
{
public:
FacebookProto* proto;
- int parse_buddy_list(std::string*, List::List< facebook_user >*);
int parse_friends(std::string*, std::map< std::string, facebook_user* >*);
int parse_notifications(std::string*, std::map< std::string, facebook_notification* >*);
int parse_messages(std::string*, std::vector< facebook_message >*, std::map< std::string, facebook_notification* >*);
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index d9d52b0b38..313c365dc8 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -38,129 +38,8 @@ std::string getContactName(FacebookProto *proto, MCONTACT hContact, const char *
return name;
}
-void FacebookProto::ProcessBuddyList(void*)
-{
- ScopedLock s(facy.buddies_lock_);
-
- if (isOffline())
- return;
-
- facy.handle_entry("ProcessBuddyList");
-
- std::string data = "user=" + facy.self_.user_id;
-
- data += "&cached_user_info_ids=";
- int counter = 0;
- for (List::Item< facebook_user >* i = facy.buddies.begin(); i != NULL; i = i->next, counter++) {
- data += i->data->user_id + "%2C";
- }
-
- if (getByte(FACEBOOK_KEY_FETCH_MOBILE, 0) == 1)
- data += "&fetch_mobile=true";
- // data += "&additional_buddies[0]=" + some_user_id; // FIXME: I'm not sure what this is for
- // data += "&additional_buddies[1]=" + some_user_id;
- data += "&get_now_available_list=true";
-
- data += "&__user=" + facy.self_.user_id;
- data += "&__dyn=" + facy.__dyn();
- data += "&__req=" + facy.__req();
- data += "&fb_dtsg=" + facy.dtsg_;
- data += "&ttstamp=" + facy.ttstamp_;
- data += "&__rev=" + facy.__rev();
-
- // Get buddy list
- http::response resp = facy.flap(REQUEST_BUDDY_LIST, &data); // NOTE: Request revised 1.9.2015
-
- if (resp.code != HTTP_CODE_OK) {
- facy.handle_error("buddy_list");
- return;
- }
-
- debugLogA("*** Starting processing buddy list");
-
- CODE_BLOCK_TRY
-
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_buddy_list(&resp.data, &facy.buddies);
- delete p;
-
- for (List::Item< facebook_user >* i = facy.buddies.begin(); i != NULL;)
- {
- facebook_user* fbu = i->data;
-
- if (!fbu->deleted) {
- if (!fbu->handle) // just been added
- fbu->handle = AddToContactList(fbu, CONTACT_FRIEND);
-
- ptrT client(getTStringA(fbu->handle, "MirVer"));
- if (!client || mir_tstrcmp(client, fbu->getMirVer()))
- setTString(fbu->handle, "MirVer", fbu->getMirVer());
-
- if (getDword(fbu->handle, "IdleTS", 0) != fbu->last_active) {
- if ((fbu->idle || fbu->status_id == ID_STATUS_OFFLINE) && fbu->last_active > 0)
- setDword(fbu->handle, "IdleTS", fbu->last_active);
- else
- delSetting(fbu->handle, "IdleTS");
- }
- }
-
- if (fbu->status_id == ID_STATUS_OFFLINE || fbu->deleted) {
- if (fbu->handle)
- setWord(fbu->handle, "Status", ID_STATUS_OFFLINE);
-
- std::string to_delete(i->key);
- i = i->next;
- facy.buddies.erase(to_delete);
- } else {
- i = i->next;
-
- if (!fbu->handle) // just been added
- fbu->handle = AddToContactList(fbu, CONTACT_FRIEND);
-
- if (getWord(fbu->handle, "Status", 0) != (int)fbu->status_id)
- setWord(fbu->handle, "Status", fbu->status_id);
-
- if (getDword(fbu->handle, "LastActiveTS", 0) != fbu->last_active) {
- if (fbu->last_active > 0)
- setDword(fbu->handle, "LastActiveTS", fbu->last_active);
- else
- delSetting(fbu->handle, "LastActiveTS");
- }
-
- if (getByte(fbu->handle, FACEBOOK_KEY_CONTACT_TYPE, 0) != CONTACT_FRIEND) {
- setByte(fbu->handle, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_FRIEND);
- // TODO: remove that popup and use "Contact added you" event?
- }
-
- // Wasn't contact removed from "server-list" someday?
- if (getDword(fbu->handle, FACEBOOK_KEY_DELETED, 0)) {
- delSetting(fbu->handle, FACEBOOK_KEY_DELETED);
-
- std::string url = FACEBOOK_URL_PROFILE + fbu->user_id;
- std::string contactname = getContactName(this, fbu->handle, !fbu->real_name.empty() ? fbu->real_name.c_str() : fbu->user_id.c_str());
-
- ptrT szTitle(mir_utf8decodeT(contactname.c_str()));
- NotifyEvent(szTitle, TranslateT("Contact is back on server-list."), fbu->handle, FACEBOOK_EVENT_FRIENDSHIP, &url);
- }
-
- // Check avatar change
- CheckAvatarChange(fbu->handle, fbu->image_url);
- }
- }
-
- debugLogA("*** Buddy list processed");
-
- CODE_BLOCK_CATCH
-
- debugLogA("*** Error processing buddy list: %s", e.what());
-
- CODE_BLOCK_END
-}
-
void FacebookProto::ProcessFriendList(void*)
{
- ScopedLock s(facy.buddies_lock_);
-
if (isOffline())
return;
@@ -1017,15 +896,15 @@ void FacebookProto::ProcessMessages(void* data)
std::vector<facebook_message> messages;
- facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_messages(resp, &messages, &facy.notifications);
- delete p;
+ facebook_json_parser* p = new facebook_json_parser(this);
+ p->parse_messages(resp, &messages, &facy.notifications);
+ delete p;
- ReceiveMessages(messages);
+ ReceiveMessages(messages);
- ShowNotifications();
+ ShowNotifications();
- debugLogA("*** Messages processed");
+ debugLogA("*** Messages processed");
CODE_BLOCK_CATCH
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 85f25595a4..79d2f30893 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -32,7 +32,6 @@ FacebookProto::FacebookProto(const char* proto_name, const TCHAR* username) :
avatar_lock_ = CreateMutex(NULL, FALSE, NULL);
log_lock_ = CreateMutex(NULL, FALSE, NULL);
update_loop_lock_ = CreateEvent(NULL, FALSE, FALSE, NULL);
- facy.buddies_lock_ = CreateMutex(NULL, FALSE, NULL);
facy.send_message_lock_ = CreateMutex(NULL, FALSE, NULL);
facy.fcb_conn_lock_ = CreateMutex(NULL, FALSE, NULL);
facy.notifications_lock_ = CreateMutex(NULL, FALSE, NULL);
@@ -121,7 +120,6 @@ FacebookProto::~FacebookProto()
WaitForSingleObject(signon_lock_, IGNORE);
WaitForSingleObject(avatar_lock_, IGNORE);
WaitForSingleObject(log_lock_, IGNORE);
- WaitForSingleObject(facy.buddies_lock_, IGNORE);
WaitForSingleObject(facy.send_message_lock_, IGNORE);
WaitForSingleObject(facy.notifications_lock_, IGNORE);
WaitForSingleObject(facy.cookies_lock_, IGNORE);
@@ -130,7 +128,6 @@ FacebookProto::~FacebookProto()
CloseHandle(avatar_lock_);
CloseHandle(log_lock_);
CloseHandle(update_loop_lock_);
- CloseHandle(facy.buddies_lock_);
CloseHandle(facy.send_message_lock_);
CloseHandle(facy.fcb_conn_lock_);
CloseHandle(facy.notifications_lock_);
@@ -646,15 +643,6 @@ INT_PTR FacebookProto::CheckFriendRequests(WPARAM, LPARAM)
return 0;
}
-INT_PTR FacebookProto::RefreshBuddyList(WPARAM, LPARAM)
-{
- if (!isOffline()) {
- facy.client_notify(TranslateT("Refreshing buddy list..."));
- ForkThread(&FacebookProto::ProcessBuddyList, NULL);
- }
- return 0;
-}
-
INT_PTR FacebookProto::VisitProfile(WPARAM wParam, LPARAM)
{
@@ -778,11 +766,12 @@ INT_PTR FacebookProto::CancelFriendship(WPARAM wParam, LPARAM lParam)
std::string *val = new std::string(id);
- if (deleting) {
+ // FIXME: Remember that we deleted this contact, so we won't accidentally add him at status change
+ /*if (deleting) {
facebook_user *fbu = facy.buddies.find(*val);
if (fbu != NULL)
fbu->handle = NULL;
- }
+ }*/
ForkThread(&FacebookProto::DeleteContactFromServer, val);
}
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index ad88a916cd..e7e3fa851c 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -125,7 +125,6 @@ public:
INT_PTR __cdecl OnCancelFriendshipRequest(WPARAM, LPARAM);
INT_PTR __cdecl CheckNewsfeeds(WPARAM, LPARAM);
INT_PTR __cdecl CheckFriendRequests(WPARAM, LPARAM);
- INT_PTR __cdecl RefreshBuddyList(WPARAM, LPARAM);
INT_PTR __cdecl GetNotificationsCount(WPARAM, LPARAM);
INT_PTR __cdecl OnJoinChat(WPARAM,LPARAM);
@@ -161,7 +160,6 @@ public:
void __cdecl UpdateLoop(void*);
// Processing threads
- void __cdecl ProcessBuddyList(void*);
void __cdecl ProcessFriendList(void*);
void __cdecl ProcessMessages(void*);
void __cdecl ProcessUnreadMessages(void*);
diff --git a/protocols/FacebookRM/src/theme.cpp b/protocols/FacebookRM/src/theme.cpp
index 1b1e747f49..42d1b6d8e8 100644
--- a/protocols/FacebookRM/src/theme.cpp
+++ b/protocols/FacebookRM/src/theme.cpp
@@ -246,12 +246,6 @@ void FacebookProto::InitMenu()
mi.hIcolibItem = Skin_GetIconHandle(SKINICON_OTHER_HELP);
mi.root = m_hMenuServicesRoot = Menu_AddProtoMenuItem(&mi, m_szModuleName);
- mi.pszService = "/RefreshBuddyList";
- CreateProtoService(mi.pszService, &FacebookProto::RefreshBuddyList);
- mi.name.a = LPGEN("Refresh Buddy List");
- mi.hIcolibItem = GetIconHandle("friendship");
- Menu_AddProtoMenuItem(&mi, m_szModuleName);
-
mi.pszService = "/CheckFriendRequests";
CreateProtoService(mi.pszService, &FacebookProto::CheckFriendRequests);
mi.name.a = LPGEN("Check Friends Requests");
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h
index 13b9e6d7fc..71ef6c5de1 100644
--- a/protocols/FacebookRM/src/version.h
+++ b/protocols/FacebookRM/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 2
-#define __RELEASE_NUM 13
-#define __BUILD_NUM 1
+#define __RELEASE_NUM 14
+#define __BUILD_NUM 0
#include <stdver.h>