summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/client.h3
-rw-r--r--protocols/FacebookRM/src/json.cpp11
-rw-r--r--protocols/FacebookRM/src/process.cpp8
-rw-r--r--protocols/FacebookRM/src/proto.cpp9
-rw-r--r--protocols/FacebookRM/src/proto.h1
5 files changed, 26 insertions, 6 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h
index 8184e34513..c2980556c0 100644
--- a/protocols/FacebookRM/src/client.h
+++ b/protocols/FacebookRM/src/client.h
@@ -41,7 +41,7 @@ public:
chat_sequence_num_ = chat_channel_host_ = chat_channel_partition_ = \
dtsg_ = logout_hash_ = chat_sticky_num_ = chat_conn_num_ = chat_clientid_ = "";
- msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = 0;
+ msgid_ = error_count_ = last_feeds_update_ = last_notification_time_ = notifications_count_ = 0;
https_ = is_idle_ = invisible_ = is_typing_ = false;
@@ -82,6 +82,7 @@ public:
bool https_;
time_t last_feeds_update_;
unsigned __int64 last_notification_time_;
+ int notifications_count_;
int msgid_;
////////////////////////////////////////////////////////////
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index 34b23a1fc9..dc824d0cbf 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -599,13 +599,20 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa
messages->push_back(message);
}
}
+ } else if (t == "notifications_read") {
+ JSONNODE *alerts = json_get(it, "alert_ids");
+ proto->facy.notifications_count_ -= json_size(alerts);
+
+ if (proto->facy.notifications_count_ < 0)
+ proto->facy.notifications_count_ = 0;
} else if (t == "notification_json") {
// event notification
+ JSONNODE *nodes = json_get(it, "nodes");
+ proto->facy.notifications_count_ += json_size(nodes);
if (!proto->getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
continue;
-
- JSONNODE *nodes = json_get(it, "nodes");
+
for (unsigned int j = 0; j < json_size(nodes); j++) {
JSONNODE *itNodes = json_at(nodes, j);
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index c06143bc69..0fd44897ce 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -552,9 +552,6 @@ void FacebookProto::ProcessNotifications(void*)
if (isOffline())
return;
- if (!getByte(FACEBOOK_KEY_EVENT_NOTIFICATIONS_ENABLE, DEFAULT_EVENT_NOTIFICATIONS_ENABLE))
- return;
-
facy.handle_entry("notifications");
// Get notifications
@@ -577,6 +574,11 @@ void FacebookProto::ProcessNotifications(void*)
p->parse_notifications(&(resp.data), &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());
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index 9afdbe0e96..ceb54aa774 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -40,6 +40,7 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
CreateProtoService(PS_GETMYAVATART, &FacebookProto::GetMyAvatar);
CreateProtoService(PS_GETAVATARINFOT, &FacebookProto::GetAvatarInfo);
CreateProtoService(PS_GETAVATARCAPS, &FacebookProto::GetAvatarCaps);
+ CreateProtoService(PS_GETUNREADEMAILCOUNT, &FacebookProto::GetNotificationsCount);
CreateProtoService(PS_JOINCHAT, &FacebookProto::OnJoinChat);
CreateProtoService(PS_LEAVECHAT, &FacebookProto::OnLeaveChat);
@@ -380,6 +381,14 @@ int FacebookProto::OnIdleChanged(WPARAM wParam, LPARAM lParam)
return 0;
}
+INT_PTR FacebookProto::GetNotificationsCount(WPARAM wParam, LPARAM lParam)
+{
+ if (isOffline())
+ return 0;
+
+ return facy.notifications_count_;
+}
+
//////////////////////////////////////////////////////////////////////////////
int FacebookProto::OnEvent(PROTOEVENTTYPE event, WPARAM wParam, LPARAM lParam)
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index 414e016bf0..49c9102367 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -125,6 +125,7 @@ public:
INT_PTR __cdecl CheckNewsfeeds(WPARAM, LPARAM);
INT_PTR __cdecl CheckFriendRequests(WPARAM, LPARAM);
INT_PTR __cdecl RefreshBuddyList(WPARAM, LPARAM);
+ INT_PTR __cdecl GetNotificationsCount(WPARAM, LPARAM);
INT_PTR __cdecl OnJoinChat(WPARAM,LPARAM);
INT_PTR __cdecl OnLeaveChat(WPARAM,LPARAM);