summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2016-12-11 22:03:39 +0100
committerRobert Pösel <robyer@seznam.cz>2016-12-11 22:03:39 +0100
commit459a25ab00ba1a75cc8fd41656e98f95c1a45e9d (patch)
tree767a6234b0a6dc286800584789c1135172950fe9 /protocols
parentc2c418eafb367c365b8e347e8598b2d859cdea39 (diff)
Facebook: Option to load all contacts at login (not only friends)
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/res/facebook.rc4
-rw-r--r--protocols/FacebookRM/src/constants.h1
-rw-r--r--protocols/FacebookRM/src/db.h1
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp2
-rw-r--r--protocols/FacebookRM/src/json.cpp4
-rw-r--r--protocols/FacebookRM/src/json.h2
-rw-r--r--protocols/FacebookRM/src/process.cpp8
-rw-r--r--protocols/FacebookRM/src/resource.h1
8 files changed, 16 insertions, 7 deletions
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc
index f918e1efd6..02fb085371 100644
--- a/protocols/FacebookRM/res/facebook.rc
+++ b/protocols/FacebookRM/res/facebook.rc
@@ -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,74
+ GROUPBOX "Contacts",IDC_STATIC,7,77,291,88
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,
@@ -129,6 +129,8 @@ BEGIN
CONTROL "Use bigger avatars",IDC_BIGGER_AVATARS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,120,271,10
CONTROL "Prefer real names instead of nicknames",IDC_NAME_AS_NICK,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,134,271,10
+ CONTROL "At login load also contacts you recently chat with",IDC_LOAD_ALL_CONTACTS,
+ "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,148,271,10
END
IDD_OPTIONS_EVENTS DIALOGEX 0, 0, 305, 227
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index 5bcc095479..a55ab619d7 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -98,6 +98,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEFAULT_JOIN_EXISTING_CHATS 1
#define DEFAULT_NOTIFICATIONS_CHATROOM 0
#define DEFAULT_NAME_AS_NICK 1
+#define DEFAULT_LOAD_ALL_CONTACTS 0
#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 1f6bcfb234..483284c89f 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -73,6 +73,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_JOIN_EXISTING_CHATS "JoinExistingChats"
#define FACEBOOK_KEY_NOTIFICATIONS_CHATROOM "NotificationsChatroom"
#define FACEBOOK_KEY_NAME_AS_NICK "NameAsNick"
+#define FACEBOOK_KEY_LOAD_ALL_CONTACTS "LoadAllContacts"
// 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 cb9aee5a4b..6d7e11473c 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -371,6 +371,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
LoadDBCheckState(proto, hwnd, IDC_SET_IGNORE_STATUS, FACEBOOK_KEY_DISABLE_STATUS_NOTIFY, DEFAULT_DISABLE_STATUS_NOTIFY);
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);
} return TRUE;
@@ -417,6 +418,7 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
StoreDBCheckState(proto, hwnd, IDC_SET_IGNORE_STATUS, FACEBOOK_KEY_DISABLE_STATUS_NOTIFY);
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);
return TRUE;
}
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 95e9a793ab..c584bce416 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -164,7 +164,7 @@ int facebook_json_parser::parse_chat_participant_names(std::string *data, std::m
return EXIT_SUCCESS;
}
-int facebook_json_parser::parse_friends(std::string *data, std::map< std::string, facebook_user* >* friends)
+int facebook_json_parser::parse_friends(std::string *data, std::map< std::string, facebook_user* >* friends, bool loadAllContacts)
{
std::string jsonData = data->substr(9);
@@ -181,7 +181,7 @@ int facebook_json_parser::parse_friends(std::string *data, std::map< std::string
parseUser(*it, fbu);
// Facebook now sends also other types of contacts, which we do not want here
- if (fbu->type != CONTACT_FRIEND) {
+ if (!loadAllContacts && fbu->type != CONTACT_FRIEND) {
delete fbu;
continue;
}
diff --git a/protocols/FacebookRM/src/json.h b/protocols/FacebookRM/src/json.h
index d81ce2caf8..f57672925e 100644
--- a/protocols/FacebookRM/src/json.h
+++ b/protocols/FacebookRM/src/json.h
@@ -30,7 +30,7 @@ class facebook_json_parser
{
public:
FacebookProto* proto;
- int parse_friends(std::string*, std::map< std::string, facebook_user* >*);
+ int parse_friends(std::string*, std::map< std::string, facebook_user* >*, bool);
int parse_notifications(std::string*, std::map< std::string, facebook_notification* >*);
int parse_messages(std::string*, std::vector< facebook_message >*, std::map< std::string, facebook_notification* >*);
int parse_unread_threads(std::string*, std::vector< std::string >*);
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index cde67b04dd..b0ed92b683 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -59,8 +59,10 @@ void FacebookProto::ProcessFriendList(void*)
try {
std::map<std::string, facebook_user*> friends;
+ bool loadAllContacts = getBool(FACEBOOK_KEY_LOAD_ALL_CONTACTS, DEFAULT_LOAD_ALL_CONTACTS);
+
facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_friends(&resp.data, &friends);
+ p->parse_friends(&resp.data, &friends, loadAllContacts);
delete p;
// Check and update old contacts
@@ -117,8 +119,8 @@ void FacebookProto::ProcessFriendList(void*)
// TODO: remove that popup and use "Contact added you" event?
}
- // Wasn't contact removed from "server-list" someday?
- if (getDword(hContact, FACEBOOK_KEY_DELETED, 0)) {
+ // Wasn't contact removed from "server-list" someday? And is it friend now? (as we can get also non-friends from this request now)?
+ if (fbu->type == CONTACT_FRIEND && getDword(hContact, FACEBOOK_KEY_DELETED, 0)) {
delSetting(hContact, FACEBOOK_KEY_DELETED);
// Notify it, if user wants to be notified
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index 886c607041..ec3d76d425 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -37,6 +37,7 @@
#define IDC_BIGGER_AVATARS 1030
#define IDC_NAME_AS_NICK 1031
#define IDC_MAP_STATUSES 1032
+#define IDC_LOAD_ALL_CONTACTS 1033
#define IDC_CUSTOM_SMILEYS 1034
#define IDC_LOAD_PAGES 1036
#define IDC_KEEP_UNREAD 1037