diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-11-20 11:49:22 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-11-20 11:49:22 +0000 |
commit | a75ba12d58c579bd1a193c01d452db6cb295ae7a (patch) | |
tree | 2a59001be2b9bf64b28651ea0765c0d319078959 /protocols/FacebookRM/src/json.cpp | |
parent | bf644e855744c674eedf7951ba1f85fd629a1066 (diff) |
Facebook: Refactor whole groupchat with notifications
This fix crash on right-click to notification popup and problem with not working notifications count in statusbar
git-svn-id: http://svn.miranda-ng.org/main/trunk@11028 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/json.cpp')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index e6654517c2..8c0de1bd22 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -250,6 +250,9 @@ int facebook_json_parser::parse_notifications(void *data, std::map< std::string, // check if we should use use local_timestamp for unread messages and use it for notifications time too bool local_timestamp = proto->getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0); + // Create notifications chatroom (if it doesn't exists), because we will be writing to it new notifications here + proto->PrepareNotificationsChatRoom(); + for (unsigned int i = 0; i < json_size(list); i++) { JSONNODE *it = json_at(list, i); const char *id = json_name(it); @@ -272,7 +275,11 @@ int facebook_json_parser::parse_notifications(void *data, std::map< std::string, notification->seen = (json_as_int(unread) == 0); notification->time = local_timestamp ? ::time(NULL) : utils::time::fix_timestamp(json_as_float(time)); - if (notifications->find(notification->id) == notifications->end()) + // Write notification to chatroom + proto->UpdateNotificationsChatRoom(notification); + + // If it's unseen, remember it, otherwise forget it + if (notifications->find(notification->id) == notifications->end() && !notification->seen) notifications->insert(std::make_pair(notification->id, notification)); else delete notification; @@ -572,6 +579,9 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa // check if we should use use local_timestamp for unread messages and use it for notifications time too bool local_timestamp = proto->getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP_UNREAD, 0); + // Create notifications chatroom (if it doesn't exists), because we will be writing to it new notifications here + proto->PrepareNotificationsChatRoom(); + for (unsigned int j = 0; j < json_size(nodes); j++) { JSONNODE *itNodes = json_at(nodes, j); @@ -605,7 +615,11 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa if (pos != std::string::npos) notification->id = notification->id.substr(pos+1); - if (notifications->find(notification->id) == notifications->end()) + // Write notification to chatroom + proto->UpdateNotificationsChatRoom(notification); + + // If it's unseen, remember it, otherwise forget it (here it will always be unseen) + if (notifications->find(notification->id) == notifications->end() && !notification->seen) notifications->insert(std::make_pair(notification->id, notification)); else delete notification; @@ -769,6 +783,8 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa } } } else if (t == "notifications_read" || t == "notifications_seen") { + ScopedLock s(proto->facy.notifications_lock_); + JSONNODE *alerts = json_get(it, "alert_ids"); for (unsigned int j = 0; j < json_size(alerts); j++) { |