From 0d8ae90913bd0b53c6af709928e7f5e5a3fc9b50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Fri, 17 May 2013 18:00:05 +0000 Subject: Facebook: Added few options items - use local time, send seen when marking read, select server to open urls. git-svn-id: http://svn.miranda-ng.org/main/trunk@4703 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/res/facebook.rc | 12 +++++++++--- protocols/FacebookRM/src/client.h | 1 + protocols/FacebookRM/src/communication.cpp | 8 ++++++++ protocols/FacebookRM/src/constants.h | 12 ++++++++++-- protocols/FacebookRM/src/db.h | 6 +++--- protocols/FacebookRM/src/dialogs.cpp | 11 +++++++++++ protocols/FacebookRM/src/messages.cpp | 26 +++++++++++++------------- protocols/FacebookRM/src/proto.cpp | 10 +--------- protocols/FacebookRM/src/resource.h | 5 ++++- protocols/FacebookRM/src/version.h | 2 +- 10 files changed, 61 insertions(+), 32 deletions(-) (limited to 'protocols/FacebookRM') diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc index 12ceaf1738..3cf23fd4c8 100644 --- a/protocols/FacebookRM/res/facebook.rc +++ b/protocols/FacebookRM/res/facebook.rc @@ -158,7 +158,7 @@ STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - GROUPBOX "Advanced Settings",IDC_STATIC,7,7,291,104 + GROUPBOX "Advanced Settings",IDC_STATIC,7,7,291,148 CONTROL "Force secure (HTTPS) connection",IDC_SECURE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,32,267,10 CONTROL "Post Miranda statuses to Wall",IDC_SET_STATUS,"Button",BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,17,56,267,10 CONTROL "Enable logging for debugging purposes",IDC_LOGGING, @@ -171,6 +171,12 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,81,267,10 CONTROL "Enable support for Custom smileys (EXPERIMENTAL + BUGGY!)",IDC_CUSTOM_SMILEYS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,95,267,10 + CONTROL "Use local time for received messages",IDC_USE_LOCAL_TIME, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,108,267,10 + CONTROL "Send ""Seen"" info when marking messages as read",IDC_SEND_SEEN, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,122,267,10 + COMBOBOX IDC_URL_SERVER,156,135,96,59,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP + LTEXT "Use this server for opening links:",IDC_STATIC,17,137,135,8 END @@ -242,8 +248,8 @@ BEGIN RIGHTMARGIN, 298 VERTGUIDE, 17 VERTGUIDE, 32 - VERTGUIDE, 119 - VERTGUIDE, 122 + VERTGUIDE, 152 + VERTGUIDE, 156 VERTGUIDE, 284 TOPMARGIN, 7 BOTTOMMARGIN, 203 diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index 214e5a81ce..9a531825d5 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -93,6 +93,7 @@ public: std::map< std::string, std::string > cookies; std::string get_newsfeed_type(); + std::string get_server_type(); char* load_cookies(); void store_headers(http::response* resp, NETLIBHTTPHEADER* headers, int headers_count); diff --git a/protocols/FacebookRM/src/communication.cpp b/protocols/FacebookRM/src/communication.cpp index 2cf3f4cdf7..c216eeccc9 100644 --- a/protocols/FacebookRM/src/communication.cpp +++ b/protocols/FacebookRM/src/communication.cpp @@ -547,6 +547,14 @@ std::string facebook_client::get_newsfeed_type() return feed_types[feed_type].id; } +std::string facebook_client::get_server_type() +{ + BYTE server_type = db_get_b(NULL, parent->m_szModuleName, FACEBOOK_KEY_SERVER_TYPE, 0); + if (server_type < 0 || server_type >= SIZEOF(server_types)) + server_type = 0; + return server_types[server_type].id; +} + char* facebook_client::load_cookies() { ScopedLock s(cookies_lock_); diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h index 647576a4a9..82d6015931 100644 --- a/protocols/FacebookRM/src/constants.h +++ b/protocols/FacebookRM/src/constants.h @@ -121,8 +121,7 @@ along with this program. If not, see . #define FACEBOOK_CONTACT_APPROVE 4 // contact that is asking us for approval of friendship // News Feed types -static const struct -{ +static const struct { const char *name; const char *id; } feed_types[] = { @@ -132,4 +131,13 @@ static const struct { LPGEN("Photos"), "app_2305272732_2392950137" }, { LPGEN("Links"), "app_2309869772" }, { LPGEN("Apps and Games"), "appsandgames" }, +}; + +static const struct { + const char *id; + const char *name; +} server_types[] = { + { "www.facebook.com", LPGEN("Classic website") }, + { "m.facebook.com", LPGEN("Mobile website") }, + { "touch.facebook.com", LPGEN("Smartphone website") }, }; \ No newline at end of file diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h index a25fb0c20a..ab249b213d 100644 --- a/protocols/FacebookRM/src/db.h +++ b/protocols/FacebookRM/src/db.h @@ -62,15 +62,15 @@ along with this program. If not, see . #define FACEBOOK_KEY_LOAD_MOBILE "LoadMobile" #define FACEBOOK_KEY_CUSTOM_SMILEYS "CustomSmileys" #define FACEBOOK_KEY_MESSAGE_ID "LastMessageId" +#define FACEBOOK_KEY_SERVER_TYPE "ServerType" +#define FACEBOOK_KEY_MARK_READ "MarkRead" +#define FACEBOOK_KEY_LOCAL_TIMESTAMP "UseLocalTimestamp" #define FACEBOOK_KEY_POLL_RATE "PollRate" // [HIDDEN] #define FACEBOOK_KEY_TIMEOUTS_LIMIT "TimeoutsLimit" // [HIDDEN] #define FACEBOOK_KEY_DISABLE_LOGOUT "DisableLogout" // [HIDDEN] #define FACEBOOK_KEY_VALIDATE_RESPONSE "ValidateResponse" // [HIDDEN] - 0 = standard, 1 = always, 2 = never -#define FACEBOOK_KEY_LOCAL_TIMESTAMP "UseLocalTimestamp" // [HIDDEN] - 0 = use facebook timestamps for messages, 1 = use local timestamps -#define FACEBOOK_KEY_MARK_READ "MarkRead" // [HIDDEN] - 0 = marking messages as read without "Seen" info, 1 = with "Seen" info #define FACEBOOK_KEY_LOCALE "Locale" // [HIDDEN] - en_US, cs_CZ, etc. -#define FACEBOOK_KEY_SERVER "Server" // [HIDDEN] - for rewrite links to open: m.facebook.com, touch.facebook.com, etc. #define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable" #define FACEBOOK_KEY_EVENT_FEEDS_ENABLE "EventFeedsEnable" diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index 4f4ee0a581..830bea22bb 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -295,6 +295,10 @@ INT_PTR CALLBACK FBOptionsAdvancedProc(HWND hwnd, UINT message, WPARAM wparam, L proto = reinterpret_cast(lparam); SetWindowLongPtr(hwnd,GWLP_USERDATA,lparam); + for(size_t i=0; i(Translate(server_types[i].name))); + SendDlgItemMessage(hwnd, IDC_URL_SERVER, CB_SETCURSEL, db_get_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_SERVER_TYPE, 0), 0); + LoadDBCheckState(proto, hwnd, IDC_SECURE, FACEBOOK_KEY_FORCE_HTTPS, DEFAULT_FORCE_HTTPS); LoadDBCheckState(proto, hwnd, IDC_SECURE_CHANNEL, FACEBOOK_KEY_FORCE_HTTPS_CHANNEL, DEFAULT_FORCE_HTTPS_CHANNEL); LoadDBCheckState(proto, hwnd, IDC_DISCONNECT_CHAT, FACEBOOK_KEY_DISCONNECT_CHAT, DEFAULT_DISCONNECT_CHAT); @@ -302,6 +306,9 @@ INT_PTR CALLBACK FBOptionsAdvancedProc(HWND hwnd, UINT message, WPARAM wparam, L LoadDBCheckState(proto, hwnd, IDC_LOGGING, FACEBOOK_KEY_LOGGING_ENABLE, DEFAULT_LOGGING_ENABLE); LoadDBCheckState(proto, hwnd, IDC_MAP_STATUSES, FACEBOOK_KEY_MAP_STATUSES, DEFAULT_MAP_STATUSES); LoadDBCheckState(proto, hwnd, IDC_CUSTOM_SMILEYS, FACEBOOK_KEY_CUSTOM_SMILEYS, DEFAULT_CUSTOM_SMILEYS); + + LoadDBCheckState(proto, hwnd, IDC_USE_LOCAL_TIME, FACEBOOK_KEY_LOCAL_TIMESTAMP, 0); + LoadDBCheckState(proto, hwnd, IDC_SEND_SEEN, FACEBOOK_KEY_MARK_READ, 1); EnableWindow(GetDlgItem(hwnd, IDC_SECURE_CHANNEL), IsDlgButtonChecked(hwnd, IDC_SECURE)); @@ -324,12 +331,16 @@ INT_PTR CALLBACK FBOptionsAdvancedProc(HWND hwnd, UINT message, WPARAM wparam, L case WM_NOTIFY: if (reinterpret_cast(lparam)->code == PSN_APPLY) { + db_set_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_SERVER_TYPE, SendDlgItemMessage(hwnd, IDC_URL_SERVER, CB_GETCURSEL, 0, 0)); + StoreDBCheckState(proto, hwnd, IDC_SECURE, FACEBOOK_KEY_FORCE_HTTPS); StoreDBCheckState(proto, hwnd, IDC_LOGGING, FACEBOOK_KEY_LOGGING_ENABLE); StoreDBCheckState(proto, hwnd, IDC_SECURE_CHANNEL, FACEBOOK_KEY_FORCE_HTTPS_CHANNEL); StoreDBCheckState(proto, hwnd, IDC_DISCONNECT_CHAT, FACEBOOK_KEY_DISCONNECT_CHAT); StoreDBCheckState(proto, hwnd, IDC_MAP_STATUSES, FACEBOOK_KEY_MAP_STATUSES); StoreDBCheckState(proto, hwnd, IDC_CUSTOM_SMILEYS, FACEBOOK_KEY_CUSTOM_SMILEYS); + StoreDBCheckState(proto, hwnd, IDC_USE_LOCAL_TIME, FACEBOOK_KEY_LOCAL_TIMESTAMP); + StoreDBCheckState(proto, hwnd, IDC_SEND_SEEN, FACEBOOK_KEY_MARK_READ); BOOL setStatus = IsDlgButtonChecked(hwnd, IDC_SET_STATUS); BOOL setStatusOld = db_get_b(NULL, proto->m_szModuleName, FACEBOOK_KEY_SET_MIRANDA_STATUS, DEFAULT_SET_MIRANDA_STATUS); diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index bb3808c225..e7d2c7c081 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -172,19 +172,19 @@ void FacebookProto::ReadMessageWorker(void *p) HANDLE hContact = static_cast(p); - if (!db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_MARK_READ, 0)) { - // old variant - no seen info updated - ptrA id( db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_ID)); - if (id == NULL) return; - - std::string data = "action=chatMarkRead"; - data += "&other_user=" + std::string(id); - data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0"); - data += "&lsd=&__user=" + facy.self_.user_id; + // first mark message read + ptrA id( db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_ID)); + if (id == NULL) return; + + std::string data = "action=chatMarkRead"; + data += "&other_user=" + std::string(id); + data += "&fb_dtsg=" + (facy.dtsg_.length() ? facy.dtsg_ : "0"); + data += "&lsd=&__user=" + facy.self_.user_id; - http::response resp = facy.flap(FACEBOOK_REQUEST_ASYNC, &data); - } else { - // new variant - with seen info + facy.flap(FACEBOOK_REQUEST_ASYNC, &data); + + // then send seen info, if enabled + if (db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_MARK_READ, 1)) { ptrA mid( db_get_sa(hContact, m_szModuleName, FACEBOOK_KEY_MESSAGE_ID)); if (mid == NULL) return; @@ -193,7 +193,7 @@ void FacebookProto::ReadMessageWorker(void *p) data += "&__user=" + facy.self_.user_id; data += "&__a=1&__dyn=&__req=j&phstamp=0"; - http::response resp = facy.flap(FACEBOOK_REQUEST_MARK_READ, &data); + facy.flap(FACEBOOK_REQUEST_MARK_READ, &data); } } diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 87edd10ce4..ab040021e1 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -622,15 +622,7 @@ void FacebookProto::OpenUrl(std::string url) // Make absolute url bool useHttps = db_get_b(NULL, m_szModuleName, FACEBOOK_KEY_FORCE_HTTPS, 1) > 0; - std::string newUrl = (useHttps ? HTTP_PROTO_SECURE : HTTP_PROTO_REGULAR); - - ptrA server = db_get_sa(NULL, m_szModuleName, FACEBOOK_KEY_SERVER); - if (server != NULL) - newUrl += server; - else - newUrl += FACEBOOK_SERVER_REGULAR; - - url = newUrl + url; + url = (useHttps ? HTTP_PROTO_SECURE : HTTP_PROTO_REGULAR) + facy.get_server_type() + url; } ptrT data = mir_utf8decodeT(url.c_str()); diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h index a888e45a8d..64b151822d 100644 --- a/protocols/FacebookRM/src/resource.h +++ b/protocols/FacebookRM/src/resource.h @@ -29,6 +29,8 @@ #define IDC_MAP_STATUSES 1032 #define IDC_LOAD_MOBILE 1033 #define IDC_CUSTOM_SMILEYS 1034 +#define IDC_USE_LOCAL_TIME 1035 +#define IDC_SEND_SEEN 1036 #define IDC_NOTIFICATIONS_ENABLE 1041 #define IDC_FEEDS_ENABLE 1042 #define IDC_OTHER_ENABLE 1043 @@ -57,6 +59,7 @@ #define IDC_PREVIEW 1099 #define IDC_SET_STATUS 1126 #define IDC_FEED_TYPE 1201 +#define IDC_URL_SERVER 1202 // Next default values for new objects // @@ -64,7 +67,7 @@ #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 129 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1202 +#define _APS_NEXT_CONTROL_VALUE 1203 #define _APS_NEXT_SYMED_VALUE 131 #endif #endif diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 9c4795d83e..29a5fcbeaa 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -17,4 +17,4 @@ #define __AUTHOR "Michal Zelinka, Robert P\xf6" "sel" #define __AUTHOREMAIL "robyer@seznam.cz" #define __AUTHORWEB "http://miranda-ng.org/" -#define __COPYRIGHT "(c) 2009-11 Michal Zelinka, 2011-13 Robert P\xf6" "sel" +#define __COPYRIGHT "© 2009-11 Michal Zelinka, 2011-13 Robert P\xf6" "sel" -- cgit v1.2.3