From ab48390f184da37486fe37237f2c11e51fe7859d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Fri, 31 Jan 2014 11:36:42 +0000 Subject: Facebook: Ability to receive only inbox messages (hidden option) git-svn-id: http://svn.miranda-ng.org/main/trunk@7970 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/process.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'protocols/FacebookRM/src/process.cpp') diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index e7528bda30..777ce172db 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -265,10 +265,11 @@ void FacebookProto::ProcessUnreadMessages(void*) { facy.handle_entry("ProcessUnreadMessages"); - bool loadOther = true; // TODO: db setting? or use everytime? + // receive messages from all folders by default, use hidden setting to receive only inbox messages + bool inboxOnly = getBool(FACEBOOK_KEY_INBOX_ONLY, 0); std::string data = "folders[0]=inbox"; - if (loadOther) + if (!inboxOnly) data += "&folders[1]=other"; data += "&client=mercury"; data += "__user=" + facy.self_.user_id; @@ -284,7 +285,7 @@ void FacebookProto::ProcessUnreadMessages(void*) std::vector threads; facebook_json_parser* p = new facebook_json_parser(this); - p->parse_unread_threads(&resp.data, &threads); + p->parse_unread_threads(&resp.data, &threads, inboxOnly); delete p; ForkThread(&FacebookProto::ProcessUnreadMessage, new std::vector(threads)); @@ -319,6 +320,9 @@ void FacebookProto::ProcessUnreadMessage(void *p) // don't use local_timestamp for unread messages by default, use hidden setting to enable it bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0); + // receive messages from all folders by default, use hidden setting to receive only inbox messages + bool inboxOnly = getBool(FACEBOOK_KEY_INBOX_ONLY, 0); + http::response resp; while (!threads.empty()) { @@ -351,7 +355,7 @@ void FacebookProto::ProcessUnreadMessage(void *p) std::map chatrooms; facebook_json_parser* p = new facebook_json_parser(this); - p->parse_thread_messages(&resp.data, &messages, &chatrooms, true, limit); + p->parse_thread_messages(&resp.data, &messages, &chatrooms, true, inboxOnly, limit); delete p; for (std::map::iterator it = chatrooms.begin(); it != chatrooms.end(); ) { @@ -456,6 +460,9 @@ void FacebookProto::ProcessMessages(void* data) std::string* resp = (std::string*)data; + // receive messages from all folders by default, use hidden setting to receive only inbox messages + bool inboxOnly = getBool(FACEBOOK_KEY_INBOX_ONLY, 0); + if (isOffline()) goto exit; @@ -467,7 +474,7 @@ void FacebookProto::ProcessMessages(void* data) std::vector< facebook_notification* > notifications; facebook_json_parser* p = new facebook_json_parser(this); - p->parse_messages(data, &messages, ¬ifications); + p->parse_messages(data, &messages, ¬ifications, inboxOnly); delete p; bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP, 0); -- cgit v1.2.3