From 51c5b6906f9571f17a9905d7f1111baa1f2dc126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Tue, 16 Oct 2012 12:26:39 +0000 Subject: Fixed Facebook channel change. git-svn-id: http://svn.miranda-ng.org/main/trunk@1955 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/client.h | 4 ++-- protocols/FacebookRM/src/communication.cpp | 34 ++++++------------------------ protocols/FacebookRM/src/constants.h | 3 +-- 3 files changed, 9 insertions(+), 32 deletions(-) (limited to 'protocols') diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index d11cf0ab55..6b0f320ba7 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -36,7 +36,7 @@ public: { username_ = password_ = \ post_form_id_ = dtsg_ = \ - chat_sequence_num_ = chat_channel_host_ = chat_channel_partition_ = chat_channel_jslogger_ = \ + chat_sequence_num_ = chat_channel_host_ = chat_channel_partition_ = \ logout_hash_ = ""; msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = 0; @@ -67,8 +67,8 @@ public: std::string post_form_id_; std::string dtsg_; std::string logout_hash_; + std::string chat_channel_; std::string chat_channel_host_; - std::string chat_channel_jslogger_; std::string chat_channel_partition_; std::string chat_sequence_num_; std::string chat_reconnect_reason_; diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 7aa116d653..19478d165a 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -303,9 +303,6 @@ std::string facebook_client::choose_server( int request_type, std::string* data, case FACEBOOK_REQUEST_MESSAGES_RECEIVE: { std::string server = FACEBOOK_SERVER_CHAT; - if (!this->chat_channel_jslogger_.empty()) - server = FACEBOOK_SERVER_CHAT2; - utils::text::replace_first( &server, "%s", "0" ); utils::text::replace_first( &server, "%s", this->chat_channel_host_ ); return server; @@ -446,16 +443,10 @@ std::string facebook_client::choose_action( int request_type, std::string* data, case FACEBOOK_REQUEST_MESSAGES_RECEIVE: { - std::string action = "/x/%s/0/true/p_%s=%s"; - if (!this->chat_channel_jslogger_.empty()) { - action = "/pull?clientid=&channel=p_%s&seq=%s&cb=&state=active"; - //utils::text::replace_first( &action, "%s", dtsg_ ); - } else { - utils::text::replace_first( &action, "%s", utils::time::unix_timestamp()); - } - - utils::text::replace_first( &action, "%s", self_.user_id ); - utils::text::replace_first( &action, "%s", chat_sequence_num_.empty() ? "0" : chat_sequence_num_ ); + std::string action = "/pull?channel=" + (this->chat_channel_.empty() ? "p_" + self_.user_id : this->chat_channel_); + action += "&seq=" + (this->chat_sequence_num_.empty() ? "0" : this->chat_sequence_num_); + action += "&partition=" + (this->chat_channel_partition_.empty() ? "0" : this->chat_channel_partition_); + action += "&clientid=&cb=&idle=0&state=active"; return action; } @@ -888,8 +879,8 @@ bool facebook_client::reconnect( ) { case HTTP_CODE_OK: { - this->chat_channel_jslogger_ = utils::text::source_get_value( &resp.data, 2, "\"jslogger_suffix\":\"", "\"" ); - parent->Log(" Got self channel jslogger: %s", this->chat_channel_jslogger_.c_str()); + this->chat_channel_ = utils::text::source_get_value( &resp.data, 2, "\"user_channel\":\"", "\"" ); + parent->Log(" Got self channel: %s", this->chat_channel_.c_str()); this->chat_channel_partition_ = utils::text::source_get_value2( &resp.data, "\"partition\":", ",}" ); parent->Log(" Got self channel partition: %s", this->chat_channel_partition_.c_str()); @@ -900,13 +891,6 @@ bool facebook_client::reconnect( ) this->chat_sequence_num_ = utils::text::source_get_value2( &resp.data, "\"seq\":", ",}" ); parent->Log(" Got self sequence number: %s", this->chat_sequence_num_.c_str()); - if (this->chat_channel_jslogger_.empty()) { - if (!atoi(this->chat_channel_host_.substr(0, this->chat_channel_host_.find(".")).c_str())) { - this->chat_channel_jslogger_ = "SOMETHING"; - parent->Log(" Got no jslogger, changed."); - } - } - return handle_success( "reconnect" ); } @@ -1069,12 +1053,6 @@ bool facebook_client::channel( ) case HTTP_CODE_FAKE_DISCONNECTED: case HTTP_CODE_FAKE_ERROR: default: - // Testing workaround for channel change - if (!this->chat_channel_jslogger_.empty()) - this->chat_channel_jslogger_ = "_"; - else - this->chat_channel_jslogger_.clear(); - return handle_error( "channel" ); } } diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h index 30f65b9df3..48a911f93b 100644 --- a/protocols/FacebookRM/src/constants.h +++ b/protocols/FacebookRM/src/constants.h @@ -38,8 +38,7 @@ along with this program. If not, see . // Connection #define FACEBOOK_SERVER_REGULAR "www.facebook.com" #define FACEBOOK_SERVER_MOBILE "m.facebook.com" -#define FACEBOOK_SERVER_CHAT "%s.%s.facebook.com" -#define FACEBOOK_SERVER_CHAT2 "%s-%s.facebook.com" +#define FACEBOOK_SERVER_CHAT "%s-%s.facebook.com" #define FACEBOOK_SERVER_LOGIN "login.facebook.com" #define FACEBOOK_SERVER_APPS "apps.facebook.com" -- cgit v1.2.3