From 26890d819c469ffc7a01352d828eeaf659f82be8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Mon, 23 Jan 2017 01:07:41 +0100 Subject: Facebook: Add option to make Pages always invisible (enabled by default) FB Pages are not online or offline, they just are. And this options helps users to find them in their contact list easily. --- protocols/FacebookRM/res/facebook.rc | 8 +++++--- protocols/FacebookRM/src/constants.h | 1 + protocols/FacebookRM/src/db.h | 1 + protocols/FacebookRM/src/dialogs.cpp | 2 ++ protocols/FacebookRM/src/process.cpp | 6 ++++++ protocols/FacebookRM/src/proto.cpp | 5 +++++ protocols/FacebookRM/src/resource.h | 1 + 7 files changed, 21 insertions(+), 3 deletions(-) diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc index ae0b3f4c89..7dba9ded72 100644 --- a/protocols/FacebookRM/res/facebook.rc +++ b/protocols/FacebookRM/res/facebook.rc @@ -109,7 +109,7 @@ BEGIN PUSHBUTTON "Cancel",IDCANCEL,110,94,44,15 END -IDD_OPTIONS DIALOGEX 0, 0, 305, 190 +IDD_OPTIONS DIALOGEX 0, 0, 305, 195 STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD EXSTYLE WS_EX_CONTROLPARENT FONT 8, "MS Shell Dlg", 0, 0, 0x1 @@ -121,7 +121,7 @@ BEGIN EDITTEXT IDC_PW,84,34,123,13,ES_PASSWORD | ES_AUTOHSCROLL CONTROL "Create a new Facebook account",IDC_NEWACCOUNTLINK, "Hyperlink",WS_TABSTOP,84,53,189,10 - GROUPBOX "Contacts",IDC_STATIC,7,77,291,88 + GROUPBOX "Contacts",IDC_STATIC,7,77,291,103 LTEXT "Default group:",IDC_STATIC,17,91,61,8,0,WS_EX_RIGHT EDITTEXT IDC_GROUP,84,89,123,13,ES_AUTOHSCROLL CONTROL "Automatically set 'Ignore status change' flag",IDC_SET_IGNORE_STATUS, @@ -131,6 +131,8 @@ BEGIN "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,134,271,10 CONTROL "Load also Messenger contacts at login (not only Facebook friends)",IDC_LOAD_ALL_CONTACTS, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,148,271,10 + CONTROL "Use invisible status for Facebook Pages (instead of offline)",IDC_PAGES_ALWAYS_ONLINE, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,163,271,10 END IDD_OPTIONS_EVENTS DIALOGEX 0, 0, 305, 227 @@ -277,7 +279,7 @@ BEGIN VERTGUIDE, 288 VERTGUIDE, 298 TOPMARGIN, 7 - BOTTOMMARGIN, 183 + BOTTOMMARGIN, 188 END IDD_OPTIONS_EVENTS, DIALOG diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h index 76b883ffe3..6b8bf70949 100644 --- a/protocols/FacebookRM/src/constants.h +++ b/protocols/FacebookRM/src/constants.h @@ -99,6 +99,7 @@ along with this program. If not, see . #define DEFAULT_NOTIFICATIONS_CHATROOM 0 #define DEFAULT_NAME_AS_NICK 1 #define DEFAULT_LOAD_ALL_CONTACTS 0 +#define DEFAULT_PAGES_ALWAYS_ONLINE 1 #define DEFAULT_EVENT_NOTIFICATIONS_ENABLE 1 #define DEFAULT_EVENT_FEEDS_ENABLE 0 diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h index 8679d1234b..85c3678d62 100644 --- a/protocols/FacebookRM/src/db.h +++ b/protocols/FacebookRM/src/db.h @@ -74,6 +74,7 @@ along with this program. If not, see . #define FACEBOOK_KEY_NOTIFICATIONS_CHATROOM "NotificationsChatroom" #define FACEBOOK_KEY_NAME_AS_NICK "NameAsNick" #define FACEBOOK_KEY_LOAD_ALL_CONTACTS "LoadAllContacts" +#define FACEBOOK_KEY_PAGES_ALWAYS_ONLINE "PagesAlwaysOnline" // Account DB keys - notifications #define FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE "EventNotificationsEnable" diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp index 8bbdcd7cbb..14c99e50cc 100644 --- a/protocols/FacebookRM/src/dialogs.cpp +++ b/protocols/FacebookRM/src/dialogs.cpp @@ -372,6 +372,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp LoadDBCheckState(proto, hwnd, IDC_BIGGER_AVATARS, FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS); LoadDBCheckState(proto, hwnd, IDC_NAME_AS_NICK, FACEBOOK_KEY_NAME_AS_NICK, DEFAULT_NAME_AS_NICK); LoadDBCheckState(proto, hwnd, IDC_LOAD_ALL_CONTACTS, FACEBOOK_KEY_LOAD_ALL_CONTACTS, DEFAULT_LOAD_ALL_CONTACTS); + LoadDBCheckState(proto, hwnd, IDC_PAGES_ALWAYS_ONLINE, FACEBOOK_KEY_PAGES_ALWAYS_ONLINE, DEFAULT_PAGES_ALWAYS_ONLINE); } return TRUE; @@ -419,6 +420,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp StoreDBCheckState(proto, hwnd, IDC_BIGGER_AVATARS, FACEBOOK_KEY_BIG_AVATARS); StoreDBCheckState(proto, hwnd, IDC_NAME_AS_NICK, FACEBOOK_KEY_NAME_AS_NICK); StoreDBCheckState(proto, hwnd, IDC_LOAD_ALL_CONTACTS, FACEBOOK_KEY_LOAD_ALL_CONTACTS); + StoreDBCheckState(proto, hwnd, IDC_PAGES_ALWAYS_ONLINE, FACEBOOK_KEY_PAGES_ALWAYS_ONLINE); return TRUE; } diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 33a451204e..0f4a4e736e 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -60,6 +60,7 @@ void FacebookProto::ProcessFriendList(void*) std::map friends; bool loadAllContacts = getBool(FACEBOOK_KEY_LOAD_ALL_CONTACTS, DEFAULT_LOAD_ALL_CONTACTS); + bool pagesAlwaysOnline = getBool(FACEBOOK_KEY_PAGES_ALWAYS_ONLINE, DEFAULT_PAGES_ALWAYS_ONLINE); facebook_json_parser* p = new facebook_json_parser(this); p->parse_friends(&resp.data, &friends, loadAllContacts); @@ -77,6 +78,11 @@ void FacebookProto::ProcessFriendList(void*) setDword(hContact, FACEBOOK_KEY_DELETED, deletedTS); } + // If this contact is page, set it as invisible (if enabled in options) + if (pagesAlwaysOnline && getByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, CONTACT_NONE) == CONTACT_PAGE) { + setWord(hContact, "Status", ID_STATUS_ONLINE); + } + facebook_user *fbu; ptrA id(getStringA(hContact, FACEBOOK_KEY_ID)); if (id != NULL) { diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 0cb9fc7a37..8c63120cb4 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -375,6 +375,11 @@ int FacebookProto::GetInfo(MCONTACT hContact, int) } } + // If this contact is page, set it as invisible (if enabled in options) + if (getBool(FACEBOOK_KEY_PAGES_ALWAYS_ONLINE, DEFAULT_PAGES_ALWAYS_ONLINE) && fbu.type == CONTACT_PAGE) { + setWord(hContact, "Status", ID_STATUS_ONLINE); + } + CheckAvatarChange(hContact, fbu.image_url); return 1; diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h index ec3d76d425..e5f5cccf9c 100644 --- a/protocols/FacebookRM/src/resource.h +++ b/protocols/FacebookRM/src/resource.h @@ -39,6 +39,7 @@ #define IDC_MAP_STATUSES 1032 #define IDC_LOAD_ALL_CONTACTS 1033 #define IDC_CUSTOM_SMILEYS 1034 +#define IDC_PAGES_ALWAYS_ONLINE 1035 #define IDC_LOAD_PAGES 1036 #define IDC_KEEP_UNREAD 1037 #define IDC_MESSAGES_ON_OPEN 1039 -- cgit v1.2.3