diff options
-rw-r--r-- | protocols/FacebookRM/src/client.h | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 17 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 32 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 40 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 67 |
5 files changed, 91 insertions, 68 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 7f95567e12..6110943167 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -39,8 +39,6 @@ public: {
msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = random_ = chat_msgs_recv_ = chat_req_ = 0;
- is_typing_ = false;
-
buddies_lock_ = send_message_lock_ = notifications_lock_ = cookies_lock_ = NULL;
hMsgCon = NULL;
hFcbCon = NULL;
@@ -81,7 +79,6 @@ public: std::string chat_conn_num_;
std::string chat_clientid_;
std::string chat_traceid_;
- bool is_typing_;
time_t last_feeds_update_;
time_t last_notification_time_;
volatile unsigned int msgid_;
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 5009d93bca..d6ffff32bb 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -296,21 +296,10 @@ std::string facebook_client::choose_action(RequestType request_type, std::string return "/ajax/chat/buddy_list.php?__a=1"; case REQUEST_USER_INFO: - { - std::string action = "/ajax/chat/user_info.php?__a=1&viewer=%s&__user=%s"; - utils::text::replace_all(&action, "%s", self_.user_id); - if (get_data != NULL) { - action += "&" + (*get_data); - } - return action; - } + return "/ajax/chat/user_info.php?__a=1"; case REQUEST_USER_INFO_ALL: - { - std::string action = "/ajax/chat/user_info_all.php?__a=1&viewer=%s&__user=%s"; - utils::text::replace_all(&action, "%s", self_.user_id); - return action; - } + return "/ajax/chat/user_info_all.php?__a=1&viewer=" + self_.user_id; case REQUEST_USER_INFO_MOBILE: { @@ -432,7 +421,7 @@ std::string facebook_client::choose_action(RequestType request_type, std::string return "/ajax/mercury/thread_info.php?__a=1"; case REQUEST_THREAD_SYNC: - return "/ajax/mercury/thread_sync.php"; + return "/ajax/mercury/thread_sync.php?__a=1"; case REQUEST_MESSAGES_RECEIVE: case REQUEST_ACTIVE_PING: diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 0b94c31701..1d8153b335 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -175,12 +175,16 @@ std::string FacebookProto::ThreadIDToContactID(const std::string &thread_id) std::string data = "client=mercury"; data += "&__user=" + facy.self_.user_id; + data += "&__dyn=" + facy.__dyn(); + data += "&__req=" + facy.__req(); data += "&fb_dtsg=" + facy.dtsg_; - data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp_; + data += "&ttstamp=" + facy.ttstamp_; + data += "&__rev=" + facy.__rev(); + data += "&threads[thread_ids][0]=" + utils::url::encode(thread_id); std::string user_id; - http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); + http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 1.9.2015 if (resp.code == HTTP_CODE_OK) { CODE_BLOCK_TRY @@ -210,18 +214,25 @@ void FacebookProto::LoadContactInfo(facebook_user* fbu) return; // TODO: support for more friends at once - std::string get_query = "&ids[0]=" + utils::url::encode(fbu->user_id); + std::string data = "ids[0]=" + utils::url::encode(fbu->user_id); + + 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(); - http::response resp = facy.flap(REQUEST_USER_INFO, NULL, &get_query); + http::response resp = facy.flap(REQUEST_USER_INFO, &data); // NOTE: Request revised 1.9.2015 if (resp.code == HTTP_CODE_OK) { CODE_BLOCK_TRY facebook_json_parser* p = new facebook_json_parser(this); - p->parse_user_info(&resp.data, fbu); - delete p; + p->parse_user_info(&resp.data, fbu); + delete p; - debugLogA("*** Contact thread info processed"); + debugLogA("*** Contact thread info processed"); CODE_BLOCK_CATCH @@ -266,15 +277,18 @@ void FacebookProto::LoadChatInfo(facebook_chatroom *fbc) std::string data = "client=mercury"; data += "&__user=" + facy.self_.user_id; + data += "&__dyn=" + facy.__dyn(); + data += "&__req=" + facy.__req(); data += "&fb_dtsg=" + facy.dtsg_; - data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp_; + data += "&ttstamp=" + facy.ttstamp_; + data += "&__rev=" + facy.__rev(); std::string thread_id = utils::url::encode(fbc->thread_id); // request info about thread data += "&threads[thread_ids][0]=" + thread_id; - http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); + http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 1.9.2015 if (resp.code != HTTP_CODE_OK) { facy.handle_error("LoadChatInfo"); diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 6d89c31b98..697d093c3e 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -89,12 +89,16 @@ void FacebookProto::SendChatMsgWorker(void *p) tid = tid_; } else { - std::string post_data = "threads[thread_ids][0]=" + utils::url::encode(data->chat_id); - post_data += "&fb_dtsg=" + facy.dtsg_; + std::string post_data = "client=mercury"; post_data += "&__user=" + facy.self_.user_id; + post_data += "&__dyn=" + facy.__dyn(); + post_data += "&__req=" + facy.__req(); + post_data += "&fb_dtsg=" + facy.dtsg_; post_data += "&ttstamp=" + facy.ttstamp_; + post_data += "&__rev=" + facy.__rev(); + post_data += "&threads[thread_ids][0]=" + utils::url::encode(data->chat_id); - http::response resp = facy.flap(REQUEST_THREAD_INFO, &post_data); + http::response resp = facy.flap(REQUEST_THREAD_INFO, &post_data); // NOTE: Request revised 1.9.2015 tid = utils::text::source_get_value(&resp.data, 2, "\"thread_id\":\"", "\""); if (!tid.empty() && tid.compare("null")) @@ -143,31 +147,25 @@ void FacebookProto::SendTypingWorker(void *p) return; } - // TODO RM: maybe better send typing optimalization - facy.is_typing_ = (typing->status == PROTOTYPE_SELFTYPING_ON); - SleepEx(2000, true); - - if (!facy.is_typing_ == (typing->status == PROTOTYPE_SELFTYPING_ON)) { - delete typing; - return; - } - const char *value = (isChatRoom(typing->hContact) ? FACEBOOK_KEY_TID : FACEBOOK_KEY_ID); ptrA id(getStringA(typing->hContact, value)); if (id != NULL) { - std::string data = "&source=mercury-chat"; - data += (typing->status == PROTOTYPE_SELFTYPING_ON ? "&typ=1" : "&typ=0"); + bool isChat = isChatRoom(typing->hContact); + std::string idEncoded = utils::url::encode(std::string(id)); - data += "&to="; - if (isChatRoom(typing->hContact)) - data += "&thread="; - data += utils::url::encode(std::string(id)); + std::string data = (typing->status == PROTOTYPE_SELFTYPING_ON ? "typ=1" : "typ=0"); + data += "&to=" + (isChat ? "" : idEncoded); + data += "&source=mercury-chat"; + data += "&thread=" + idEncoded; + data += "&__user=" + facy.self_.user_id; + data += "&__dyn=" + facy.__dyn(); + data += "&__req=" + facy.__req(); data += "&fb_dtsg=" + facy.dtsg_; - data += "&lsd=&__user=" + facy.self_.user_id; - data += "&ttstamp=" + facy.ttstramp_; + data += "&ttsamp=" + facy.ttstamp_; + data += "&__rev=" + facy.__rev(); - http::response resp = facy.flap(REQUEST_TYPING_SEND, &data); + http::response resp = facy.flap(REQUEST_TYPING_SEND, &data); // NOTE: Request revised 1.9.2015 } delete typing; diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 96aa8d1949..5bc32be1ff 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -49,19 +49,28 @@ void FacebookProto::ProcessBuddyList(void*) facy.handle_entry("ProcessBuddyList"); - // Prepare update data - std::string post_data = "user=" + facy.self_.user_id + "&fetch_mobile=true&fb_dtsg=" + facy.dtsg_ + "&__user=" + facy.self_.user_id + "&cached_user_info_ids="; + 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++) - { - post_data += i->data->user_id + "%2C"; + for (List::Item< facebook_user >* i = facy.buddies.begin(); i != NULL; i = i->next, counter++) { + data += i->data->user_id + "%2C"; } - post_data += "&ttstamp=" + facy.ttstamp_; + 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, &post_data); + 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"); @@ -158,8 +167,15 @@ void FacebookProto::ProcessFriendList(void*) facy.handle_entry("load_friends"); - // Get buddy list - http::response resp = facy.flap(REQUEST_USER_INFO_ALL); + // Get friends list + std::string 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(); + + http::response resp = facy.flap(REQUEST_USER_INFO_ALL, &data); // NOTE: Request revised 1.9.2015 if (resp.code != HTTP_CODE_OK) { facy.handle_error("load_friends"); @@ -299,7 +315,7 @@ void FacebookProto::ProcessUnreadMessages(void*) if (!inboxOnly) data += "&folders[1]=other"; data += "&client=mercury"; - data += "__user=" + facy.self_.user_id; + data += "&__user=" + facy.self_.user_id; data += "&fb_dtsg=" + facy.dtsg_; data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp_; @@ -355,11 +371,14 @@ void FacebookProto::ProcessUnreadMessage(void *pParam) // TODO: First load info about amount of unread messages, then load exactly this amount for each thread - while (!threads->empty()) { + while (!threads->empty()) { std::string data = "client=mercury"; data += "&__user=" + facy.self_.user_id; + data += "&__dyn=" + facy.__dyn(); + data += "&__req=" + facy.__req(); data += "&fb_dtsg=" + facy.dtsg_; - data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp_; + data += "&ttstamp=" + facy.ttstamp_; + data += "&__rev=" + facy.__rev(); for (std::vector<std::string>::size_type i = 0; i < threads->size(); i++) { std::string thread_id = utils::url::encode(threads->at(i)); @@ -375,7 +394,7 @@ void FacebookProto::ProcessUnreadMessage(void *pParam) data += "]=" + thread_id; } - resp = facy.flap(REQUEST_THREAD_INFO, &data); + resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 1.9.2015 if (resp.code == HTTP_CODE_OK) { @@ -459,8 +478,11 @@ void FacebookProto::LoadLastMessages(void *pParam) std::string data = "client=mercury"; data += "&__user=" + facy.self_.user_id; + data += "&__dyn=" + facy.__dyn(); + data += "&__req=" + facy.__req(); data += "&fb_dtsg=" + facy.dtsg_; - data += "&__a=1&__dyn=&__req=&ttstamp=" + facy.ttstamp_; + data += "&ttstamp=" + facy.ttstamp_; + data += "&__rev=" + facy.__rev(); bool isChat = isChatRoom(hContact); @@ -487,7 +509,7 @@ void FacebookProto::LoadLastMessages(void *pParam) // request info about thread data += "&threads[" + type + "][0]=" + id; - http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); + http::response resp = facy.flap(REQUEST_THREAD_INFO, &data); // NOTE: Request revised 1.9.2015 if (resp.code != HTTP_CODE_OK || resp.data.empty()) { facy.handle_error("LoadLastMessages"); @@ -579,18 +601,21 @@ void FacebookProto::SyncThreads(void*) // Get milli timestamp string for Facebook std::string time = utils::conversion::to_string((void*)×tamp, UTILS_CONV_TIME_T) + "000"; - std::string data = "client=mercury"; - data += "&last_action_timestamp=" + time; - data += "&__user=" + facy.self_.user_id; - data += "&fb_dtsg=" + facy.dtsg_; + std::string data = "last_action_timestamp=" + time; data += "&folders[0]=inbox"; if (!inboxOnly) data += "&folders[1]=other"; - data += "&__req=7&__a=1&__dyn=&__req=&__rev=&ttstamp=" + facy.ttstamp_; + data += "&client=mercury_sync"; + 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(); debugLogA(" Facebook's milli timestamp for sync: %s", time.c_str()); - http::response resp = facy.flap(REQUEST_THREAD_SYNC, &data); + http::response resp = facy.flap(REQUEST_THREAD_SYNC, &data); // NOTE: Request revised 1.9.2015 if (resp.code != HTTP_CODE_OK || resp.data.empty()) { facy.handle_error("LoadLastMessages"); |