diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-07-20 07:46:19 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-07-20 07:46:19 +0000 |
commit | 42c1d344fd105bcc25ae35e5a82d16a978b302c4 (patch) | |
tree | 818f9107867a2ccc49cb0596aac0707e11a7b014 /protocols | |
parent | 471448968040658dbade77474b06248983a807bc (diff) |
Facebook: Don't do any requests when protocol is offline
git-svn-id: http://svn.miranda-ng.org/main/trunk@9875 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 9 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 38 | ||||
-rw-r--r-- | protocols/FacebookRM/src/http.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 25 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 5 |
5 files changed, 73 insertions, 5 deletions
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index f3e0c19c85..b2eea131b5 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -29,6 +29,13 @@ void facebook_client::client_notify(TCHAR* message) http::response facebook_client::flap(RequestType request_type, std::string* request_data, std::string* request_get_data, int method) { + http::response resp; + + if (parent->isOffline) { + resp.code = HTTP_CODE_FAKE_OFFLINE; + return resp; + } + NETLIBHTTPREQUEST nlhr = {sizeof(NETLIBHTTPREQUEST)}; nlhr.requestType = !method ? choose_method(request_type) : method; @@ -85,8 +92,6 @@ http::response facebook_client::flap(RequestType request_type, std::string* requ mir_free(nlhr.headers[3].szValue); mir_free(nlhr.headers); - http::response resp; - switch (request_type) { case REQUEST_LOGIN: diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index ec84cbabb4..5ad0b8a4d3 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -122,7 +122,9 @@ std::string FacebookProto::ThreadIDToContactID(std::string thread_id) } } - // We don't have any contact with thish thread_id cached, we must ask server + // We don't have any contact with this thread_id cached, we must ask server + if (isOffline()) + return ""; std::string data = "client=mercury"; data += "&__user=" + facy.self_.user_id; @@ -153,6 +155,9 @@ std::string FacebookProto::ThreadIDToContactID(std::string thread_id) void FacebookProto::LoadContactInfo(facebook_user* fbu) { + if (isOffline()) + return; + // TODO: support for more friends at once std::string get_query = "&ids[0]=" + utils::url::encode(fbu->user_id); @@ -195,6 +200,9 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc) // TODO: load unknown contact's names from server if (it->second.empty()) it->second = it->first; + + //if (isOffline()) + // return; } } } @@ -202,6 +210,9 @@ void FacebookProto::LoadParticipantsNames(facebook_chatroom *fbc) void FacebookProto::LoadChatInfo(facebook_chatroom *fbc) { + if (isOffline()) + return; + std::string data = "client=mercury"; data += "&__user=" + facy.self_.user_id; data += "&fb_dtsg=" + (!facy.dtsg_.empty() ? facy.dtsg_ : "0"); @@ -348,6 +359,11 @@ void FacebookProto::DeleteContactFromServer(void *data) if (data == NULL) return; + if (isOffline()) { + delete (std::string*)data; + return; + } + std::string id = (*(std::string*)data); delete data; @@ -392,6 +408,11 @@ void FacebookProto::AddContactToServer(void *data) if (data == NULL) return; + if (isOffline()) { + delete (std::string*)data; + return; + } + std::string id = (*(std::string*)data); delete data; @@ -426,6 +447,11 @@ void FacebookProto::ApproveContactToServer(void *data) if (data == NULL) return; + if (isOffline()) { + delete (MCONTACT*)data; + return; + } + MCONTACT hContact = *(MCONTACT*)data; delete data; @@ -449,6 +475,11 @@ void FacebookProto::CancelFriendsRequest(void *data) if (data == NULL) return; + if (isOffline()) { + delete (MCONTACT*)data; + return; + } + MCONTACT hContact = *(MCONTACT*)data; delete data; @@ -480,6 +511,11 @@ void FacebookProto::SendPokeWorker(void *p) if (p == NULL) return; + if (isOffline()) { + delete (std::string*)p; + return; + } + std::string id = (*(std::string*)p); delete p; diff --git a/protocols/FacebookRM/src/http.h b/protocols/FacebookRM/src/http.h index 507658bff9..4ae80cbec2 100644 --- a/protocols/FacebookRM/src/http.h +++ b/protocols/FacebookRM/src/http.h @@ -81,6 +81,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define HTTP_CODE_FAKE_DISCONNECTED 0
#define HTTP_CODE_FAKE_ERROR 1
+#define HTTP_CODE_FAKE_OFFLINE 2
namespace http
{
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 7dce1b8b14..7d783a66c7 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -284,6 +284,9 @@ void FacebookProto::ProcessFriendList(void*) void FacebookProto::ProcessUnreadMessages(void*) { + if (isOffline()) + return; + facy.handle_entry("ProcessUnreadMessages"); // receive messages from all folders by default, use hidden setting to receive only inbox messages @@ -330,6 +333,11 @@ void FacebookProto::ProcessUnreadMessage(void *p) if (p == NULL) return; + if (isOffline()) { + delete (std::vector<std::string>*)p; + return; + } + facy.handle_entry("ProcessUnreadMessage"); std::vector<std::string> threads = *(std::vector<std::string>*)p; @@ -434,6 +442,11 @@ void FacebookProto::LoadLastMessages(void *p) if (p == NULL) return; + if (isOffline()) { + delete (MCONTACT*)p; + return; + } + facy.handle_entry("LoadLastMessages"); MCONTACT hContact = *(MCONTACT*)p; @@ -725,6 +738,11 @@ void FacebookProto::ProcessMessages(void* data) if (data == NULL) return; + if (isOffline()) { + delete (std::string*)data; + return; + } + std::string* resp = (std::string*)data; // receive messages from all folders by default, use hidden setting to receive only inbox messages @@ -813,6 +831,9 @@ void FacebookProto::ProcessNotifications(void*) void FacebookProto::ProcessFriendRequests(void*) { + if (isOffline()) + return; + facy.handle_entry("friendRequests"); // Get notifications @@ -1076,9 +1097,9 @@ void FacebookProto::ProcessFeeds(void* data) facy.handle_success("feeds"); } -void FacebookProto::ProcessPages(void *data) +void FacebookProto::ProcessPages(void*) { - if (!getByte(FACEBOOK_KEY_LOAD_PAGES, DEFAULT_LOAD_PAGES)) + if (isOffline() || !getByte(FACEBOOK_KEY_LOAD_PAGES, DEFAULT_LOAD_PAGES)) return; facy.handle_entry("load_pages"); diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 800ca39d8e..c28f2cec31 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -811,6 +811,11 @@ void FacebookProto::ReadNotificationWorker(void *p) if (p == NULL) return; + if (isOffline()) { + delete (std::string*)p; + return; + } + std::string *id = static_cast<std::string*>(p); std::string data = "seen=0&asyncSignal=&__dyn=&__req=a&alert_ids%5B0%5D=" + utils::url::encode(*id); |