diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-04-05 09:03:20 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-04-05 09:03:20 +0000 |
commit | 5e8e5ed54e602e0de3d328098ff828cba441b2a0 (patch) | |
tree | 178212b37c358cb3f6d5b1c1f2ca195b49aa24d5 /protocols/FacebookRM/src/process.cpp | |
parent | 7e7e977e3dd74fe09c62d7b345bbbbecf33602a4 (diff) |
Facebook: Correct implementation of managing number of unread notifications
git-svn-id: http://svn.miranda-ng.org/main/trunk@8858 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/process.cpp')
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 45 |
1 files changed, 18 insertions, 27 deletions
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp index 0fd44897ce..c8a3fc7d6b 100644 --- a/protocols/FacebookRM/src/process.cpp +++ b/protocols/FacebookRM/src/process.cpp @@ -497,7 +497,6 @@ void FacebookProto::ReceiveMessages(std::vector<facebook_message*> messages, boo messages.clear();
}
-// TODO: combine processmessages and processunreadmessages? (behavior of showing messages to user should be the same)
void FacebookProto::ProcessMessages(void* data)
{
if (data == NULL)
@@ -516,24 +515,16 @@ void FacebookProto::ProcessMessages(void* data) CODE_BLOCK_TRY
std::vector< facebook_message* > messages;
- std::vector< facebook_notification* > notifications;
facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_messages(data, &messages, ¬ifications, inboxOnly);
+ p->parse_messages(data, &messages, &facy.notifications, inboxOnly);
delete p;
bool local_timestamp = getBool(FACEBOOK_KEY_LOCAL_TIMESTAMP, 0);
ReceiveMessages(messages, local_timestamp);
- for(std::vector<facebook_notification*>::size_type i=0; i<notifications.size(); i++)
- {
- debugLogA(" Got notification: %s", notifications[i]->text.c_str());
- ptrT szText( mir_utf8decodeT(notifications[i]->text.c_str()));
- NotifyEvent(m_tszUserName, szText, ContactIDToHContact(notifications[i]->user_id), FACEBOOK_EVENT_NOTIFICATION, ¬ifications[i]->link, ¬ifications[i]->id);
- delete notifications[i];
- }
- notifications.clear();
+ ShowNotifications();
debugLogA("***** Messages processed");
@@ -547,6 +538,20 @@ exit: delete resp;
}
+void FacebookProto::ShowNotifications() {
+ if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
+ return;
+
+ for (std::map<std::string, facebook_notification*>::iterator it = facy.notifications.begin(); it != facy.notifications.end(); ++it) {
+ if (it->second != NULL && !it->second->seen) {
+ debugLogA(" Got notification: %s", it->second->text.c_str());
+ ptrT szText(mir_utf8decodeT(it->second->text.c_str()));
+ it->second->hWndPopup = NotifyEvent(m_tszUserName, szText, ContactIDToHContact(it->second->user_id), FACEBOOK_EVENT_NOTIFICATION, &it->second->link, &it->second->id);
+ it->second->seen = true;
+ }
+ }
+}
+
void FacebookProto::ProcessNotifications(void*)
{
if (isOffline())
@@ -568,25 +573,11 @@ void FacebookProto::ProcessNotifications(void*) CODE_BLOCK_TRY
- std::vector< facebook_notification* > notifications;
-
facebook_json_parser* p = new facebook_json_parser(this);
- p->parse_notifications(&(resp.data), ¬ifications);
+ p->parse_notifications(&(resp.data), &facy.notifications);
delete p;
- facy.notifications_count_ = notifications.size();
-
- if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
- return;
-
- for(std::vector<facebook_notification*>::size_type i=0; i<notifications.size(); i++)
- {
- debugLogA(" Got notification: %s", notifications[i]->text.c_str());
- ptrT szText( mir_utf8decodeT(notifications[i]->text.c_str()));
- NotifyEvent(m_tszUserName, szText, ContactIDToHContact(notifications[i]->user_id), FACEBOOK_EVENT_NOTIFICATION, ¬ifications[i]->link, ¬ifications[i]->id);
- delete notifications[i];
- }
- notifications.clear();
+ ShowNotifications();
debugLogA("***** Notifications processed");
|