diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-09-07 11:42:55 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-09-07 11:42:55 +0000 |
commit | 36fda94bceb22984f08944e1a89d420a90cd6299 (patch) | |
tree | 953fe688c9aaf87b17c72b6dc66b3c33bb927688 /protocols | |
parent | 064b323a22f939a04f54eb3cdcd165cdcca431c9 (diff) |
Facebook: Various fixes
- Fix getting own name and avatar
- Improve login error messages
- Fix turning off chat on logout and improve logout procedure
- Improve some options text
- Remove "DisableLogout" hidden option
- Some code cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@10387 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/docs/facebook - readme.txt | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/res/facebook.rc | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/communication.cpp | 40 | ||||
-rw-r--r-- | protocols/FacebookRM/src/connection.cpp | 33 | ||||
-rw-r--r-- | protocols/FacebookRM/src/db.h | 41 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.cpp | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/version.h | 2 |
8 files changed, 65 insertions, 58 deletions
diff --git a/protocols/FacebookRM/docs/facebook - readme.txt b/protocols/FacebookRM/docs/facebook - readme.txt index bb813ddea2..e252ed8a8c 100644 --- a/protocols/FacebookRM/docs/facebook - readme.txt +++ b/protocols/FacebookRM/docs/facebook - readme.txt @@ -25,7 +25,6 @@ Info: Hidden settings
--------------------------------
"TimeoutsLimit" (Byte) - Errors limit (default 3) after which fb disconnects
-"DisableLogout" (Byte) - 1 = Disable logout procedure, 0 = default
"PollRate" (Byte) - Waiting time between buddy list and newsfeed parsing.
"Locale" (String) - Get facebook errors in specific language, "en_US", "cs_CZ", etc.
"UseLocalTimestampUnread" (Byte) - 1 = Use local timestamp for offline (unread) messages
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc index 9d1fbd0ec9..6456390d9c 100644 --- a/protocols/FacebookRM/res/facebook.rc +++ b/protocols/FacebookRM/res/facebook.rc @@ -150,9 +150,9 @@ BEGIN CONTROL "Post Miranda statuses to Wall",IDC_SET_STATUS,"Button",BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,13,44,281,10
CONTROL "Use secure connection also for channel requests",IDC_SECURE_CHANNEL,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,32,33,262,10
- CONTROL "Also disconnect chat when going to offline",IDC_DISCONNECT_CHAT,
+ CONTROL "Turn off chat on Facebook when going to offline in Miranda",IDC_DISCONNECT_CHAT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,55,281,10
- CONTROL "Map non-standard statuses to Invisible (instead of Online)",IDC_MAP_STATUSES,
+ CONTROL "Map unsupported statuses to Invisible (instead of Online)",IDC_MAP_STATUSES,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,67,281,10
CONTROL "Allow posting statuses to my pages (may slow down login)",IDC_LOAD_PAGES,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,79,281,10
diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 6020de8ba7..932fbbcdec 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -937,9 +937,6 @@ bool facebook_client::login(const char *username, const char *password) bool facebook_client::logout() { - if (parent->getByte(FACEBOOK_KEY_DISABLE_LOGOUT, 0)) - return true; - handle_entry("logout"); std::string data = "fb_dtsg=" + (!this->dtsg_.empty() ? this->dtsg_ : "0"); @@ -947,12 +944,7 @@ bool facebook_client::logout() http::response resp = flap(REQUEST_LOGOUT, &data); - if (hFcbCon) - Netlib_CloseHandle(hFcbCon); - hFcbCon = NULL; - - // Process result - username_ = password_ = self_.user_id = ""; + this->username_ = this->password_ = this->self_.user_id = ""; switch (resp.code) { @@ -983,8 +975,11 @@ bool facebook_client::home() this->dtsg_ = utils::url::encode(utils::text::source_get_value(&resp.data, 3, "name=\"fb_dtsg\"", "value=\"", "\"")); parent->debugLogA(" Got self dtsg: %s", this->dtsg_.c_str()); - if (this->dtsg_.empty()) - return false; + if (this->dtsg_.empty()) { + parent->debugLogA("!!!!! Empty dtsg. Source code:\n%s", resp.data.c_str()); + client_notify(TranslateT("Could not load communication token. You should report this and wait for plugin update.")); + return handle_error("home", FORCE_QUIT); + } resp = flap(REQUEST_HOME); @@ -992,12 +987,12 @@ bool facebook_client::home() { case HTTP_CODE_OK: { - // Get real name (for mobile FB version since 27.8.2014) - this->self_.real_name = utils::text::source_get_value(&resp.data, 5, "id=\"root", "</a>", "<div", ">", "<img"); + // Get real name + this->self_.real_name = utils::text::source_get_value(&resp.data, 4, "id=\"root", "<strong", ">", "</strong>"); // Try to get name again, if we've got some some weird version of Facebook if (this->self_.real_name.empty()) - this->self_.real_name = utils::text::source_get_value(&resp.data, 4, "id=\"root", "<strong", ">", "</strong>"); + this->self_.real_name = utils::text::source_get_value(&resp.data, 5, "id=\"root", "</a>", "<div", ">", "</div>"); // Get and strip optional nickname std::string::size_type pos = this->self_.real_name.find("<span class=\"alternate_name\">"); @@ -1009,19 +1004,11 @@ bool facebook_client::home() } this->self_.real_name = utils::text::remove_html(this->self_.real_name); - parent->debugLogA(" Got self real name: %s", this->self_.real_name.c_str()); - - if (this->self_.real_name.empty()) { - client_notify(TranslateT("Something happened to Facebook. Maybe there was some major update so you should wait for an update.")); - return handle_error("home", FORCE_QUIT); - } - - // Save name and nickname parent->SaveName(NULL, &this->self_); // Get avatar - this->self_.image_url = utils::text::source_get_value(&resp.data, 4, "id=\"root", "class=\"l\"", "<img src=\"", "\""); + this->self_.image_url = utils::text::source_get_value(&resp.data, 3, "id=\"root", "<img src=\"", "\""); parent->debugLogA(" Got self avatar: %s", this->self_.image_url.c_str()); parent->CheckAvatarChange(NULL, this->self_.image_url); @@ -1029,6 +1016,11 @@ bool facebook_client::home() this->logout_hash_ = utils::text::source_get_value2(&resp.data, "/logout.php?h=", "&\""); parent->debugLogA(" Got self logout hash: %s", this->logout_hash_.c_str()); + if (this->self_.real_name.empty() || this->self_.image_url.empty() || this->logout_hash_.empty()) { + parent->debugLogA("!!!!! Empty nick/avatar/hash. Source code:\n%s", resp.data.c_str()); + client_notify(TranslateT("Could not load all required data. Plugin may still work correctly, but you should report this and wait for plugin update.")); + } + return handle_success("home"); } case HTTP_CODE_FOUND: @@ -1048,7 +1040,7 @@ bool facebook_client::chat_state(bool online) std::string data = (online ? "visibility=1" : "visibility=0"); data += "&window_id=0"; data += "&fb_dtsg=" + (!dtsg_.empty() ? dtsg_ : "0"); - data += "&phstamp=0&__user=" + self_.user_id; + data += "&__user=" + self_.user_id; http::response resp = flap(REQUEST_VISIBILITY, &data); if (!resp.error_title.empty()) diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index fbc4819308..3372d671d2 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -33,23 +33,27 @@ void FacebookProto::ChangeStatus(void*) if (new_status == ID_STATUS_OFFLINE) { // Logout debugLogA("##### Beginning SignOff process"); + m_signingOut = true; - m_iStatus = facy.self_.status_id = ID_STATUS_OFFLINE; SetEvent(update_loop_lock_); - Netlib_Shutdown(facy.hMsgCon); - - OnLeaveChat(NULL, NULL); - SetAllContactStatuses(ID_STATUS_OFFLINE); - ToggleStatusMenuItems(false); - delSetting("LogonTS"); - ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); + // Shutdown and close channel handle + Netlib_Shutdown(facy.hMsgCon); + if (facy.hMsgCon) + Netlib_CloseHandle(facy.hMsgCon); + facy.hMsgCon = NULL; + // Turn off chat on Facebook if (getByte(FACEBOOK_KEY_DISCONNECT_CHAT, DEFAULT_DISCONNECT_CHAT)) facy.chat_state(false); facy.logout(); + OnLeaveChat(NULL, NULL); + SetAllContactStatuses(ID_STATUS_OFFLINE); + ToggleStatusMenuItems(false); + delSetting("LogonTS"); + facy.clear_cookies(); facy.clear_notifications(); facy.clear_chatrooms(); @@ -59,10 +63,15 @@ void FacebookProto::ChangeStatus(void*) facy.pages.clear(); facy.typers.clear(); - if (facy.hMsgCon) - Netlib_CloseHandle(facy.hMsgCon); - facy.hMsgCon = NULL; + // Close connection handle + if (facy.hFcbCon) + Netlib_CloseHandle(facy.hFcbCon); + facy.hFcbCon = NULL; + + m_iStatus = facy.self_.status_id = ID_STATUS_OFFLINE; + ProtoBroadcastAck(0, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus); + m_signingOut = false; debugLogA("##### SignOff complete"); return; @@ -208,7 +217,7 @@ void FacebookProto::MessageLoop(void *) while (facy.channel()) { - if (isOffline()) + if (isOffline() || m_signingOut) break; debugLogA("***** FacebookProto::MessageLoop[%d] refreshing...", tim); } diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h index 9802f09c9e..341cb06be2 100644 --- a/protocols/FacebookRM/src/db.h +++ b/protocols/FacebookRM/src/db.h @@ -22,7 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #pragma once
-// DB keys
+// Contact DB keys
#define FACEBOOK_KEY_LOGIN "Email"
#define FACEBOOK_KEY_ID "ID"
#define FACEBOOK_KEY_TID "ThreadID"
@@ -36,6 +36,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_KEY_AVATAR "Avatar"
#define FACEBOOK_KEY_DELETED "Deleted"
#define FACEBOOK_KEY_CONTACT_TYPE "ContactType"
+#define FACEBOOK_KEY_MESSAGE_ID "LastMessageId"
+#define FACEBOOK_KEY_MESSAGE_READ "MessageRead"
+
+// Contact and account DB keys
+#define FACEBOOK_KEY_KEEP_UNREAD "KeepUnread" // (byte) 1 = don't mark messages as read on server (works globally or per contact)
+
+// Account DB keys
#define FACEBOOK_KEY_DEF_GROUP "DefaultGroup"
#define FACEBOOK_KEY_FORCE_HTTPS "ForceHTTPS"
#define FACEBOOK_KEY_FORCE_HTTPS_CHANNEL "ForceHTTPSChannel"
@@ -46,33 +53,31 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_KEY_DISCONNECT_CHAT "DisconnectChatEnable"
#define FACEBOOK_KEY_MAP_STATUSES "MapStatuses"
#define FACEBOOK_KEY_CUSTOM_SMILEYS "CustomSmileys"
-#define FACEBOOK_KEY_MESSAGE_ID "LastMessageId"
#define FACEBOOK_KEY_SERVER_TYPE "ServerType"
#define FACEBOOK_KEY_LOCAL_TIMESTAMP "UseLocalTimestamp"
#define FACEBOOK_KEY_PRIVACY_TYPE "PrivacyType"
#define FACEBOOK_KEY_PLACE "Place"
#define FACEBOOK_KEY_LAST_WALL "LastWall"
#define FACEBOOK_KEY_LOAD_PAGES "LoadPages"
-#define FACEBOOK_KEY_KEEP_UNREAD "KeepUnread" // (byte) 1 = don't mark messages as read on server (works globally or per contact)
#define FACEBOOK_KEY_INBOX_ONLY "InboxOnly"
#define FACEBOOK_KEY_FILTER_ADS "FilterAds"
#define FACEBOOK_KEY_MESSAGES_ON_OPEN "MessagesOnOpen"
#define FACEBOOK_KEY_MESSAGES_ON_OPEN_COUNT "MessagesOnOpenCount"
#define FACEBOOK_KEY_HIDE_CHATS "HideChats"
-#define FACEBOOK_KEY_MESSAGE_READ "MessageRead"
-#define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN]
-#define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN]
-#define FACEBOOK_KEY_DISABLE_LOGOUT "DisableLogout" // [HIDDEN]
-#define FACEBOOK_KEY_LOCALE "Locale" // [HIDDEN] - en_US, cs_CZ, etc.
-#define FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD "UseLocalTimestampUnread" // [HIDDEN] - 1 = use local timestamp for offline messages
-#define FACEBOOK_KEY_NASEEMS_SPAM_MODE "NaseemsSpamMode" // [HIDDEN] - 1 = don't load messages sent from other instances (e.g., browser) - known as "Naseem's spam mode"
-#define FACEBOOK_KEY_NAME_AS_NICK "NameAsNick" // [HIDDEN] - 0 = don't use real name as nickname, use nickname if possible
-#define FACEBOOK_KEY_OPEN_URL_BROWSER "OpenUrlBrowser" // [HIDDEN] - (unicode) = absolute path to browser to open url links with
-#define FACEBOOK_KEY_ENABLE_CHAT "EnableChat" // [HIDDEN] - 0 = don't use multi user chat at all (default is 1)
+// Account DB keys - notifications
+#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable"
+#define FACEBOOK_KEY_EVENT_FEEDS_ENABLE "EventFeedsEnable"
+#define FACEBOOK_KEY_EVENT_OTHER_ENABLE "EventOtherEnable"
+#define FACEBOOK_KEY_EVENT_CLIENT_ENABLE "EventClientEnable"
+#define FACEBOOK_KEY_FEED_TYPE "EventFeedsType"
-#define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable"
-#define FACEBOOK_KEY_EVENT_FEEDS_ENABLE "EventFeedsEnable"
-#define FACEBOOK_KEY_EVENT_OTHER_ENABLE "EventOtherEnable"
-#define FACEBOOK_KEY_EVENT_CLIENT_ENABLE "EventClientEnable"
-#define FACEBOOK_KEY_FEED_TYPE "EventFeedsType"
+// Hidden account DB keys (can't be changed through GUI)
+#define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN] - (byte)
+#define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN] - (byte)
+#define FACEBOOK_KEY_LOCALE "Locale" // [HIDDEN] - (string) en_US, cs_CZ, etc.
+#define FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD "UseLocalTimestampUnread" // [HIDDEN] - (byte) 1 = use local timestamp for offline messages
+#define FACEBOOK_KEY_NASEEMS_SPAM_MODE "NaseemsSpamMode" // [HIDDEN] - (byte) 1 = don't load messages sent from other instances (e.g., browser) - known as "Naseem's spam mode"
+#define FACEBOOK_KEY_NAME_AS_NICK "NameAsNick" // [HIDDEN] - (byte) 0 = don't use real name as nickname, use nickname if possible
+#define FACEBOOK_KEY_OPEN_URL_BROWSER "OpenUrlBrowser" // [HIDDEN] - (unicode) = absolute path to browser to open url links with
+#define FACEBOOK_KEY_ENABLE_CHAT "EnableChat" // [HIDDEN] - (byte) 0 = don't use multi user chat at all (default is 1)
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index b81f436cfa..18fb6fc93a 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -36,6 +36,7 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) : facy.fcb_conn_lock_ = CreateMutex(NULL, FALSE, NULL); m_invisible = false; + m_signingOut = false; m_enableChat = getBool(FACEBOOK_KEY_ENABLE_CHAT, true); CreateProtoService(PS_CREATEACCMGRUI, &FacebookProto::SvcCreateAccMgrUI); diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index 1b87bc10de..4ad3a3642c 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -53,6 +53,7 @@ public: bool m_invisible; bool m_enableChat; + bool m_signingOut; // DB utils missing in proto_interface diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 4376a641b8..1efaf598d8 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 9
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
|