summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/chat.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-11-20 11:49:22 +0000
committerRobert Pösel <robyer@seznam.cz>2014-11-20 11:49:22 +0000
commita75ba12d58c579bd1a193c01d452db6cb295ae7a (patch)
tree2a59001be2b9bf64b28651ea0765c0d319078959 /protocols/FacebookRM/src/chat.cpp
parentbf644e855744c674eedf7951ba1f85fd629a1066 (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/chat.cpp')
-rw-r--r--protocols/FacebookRM/src/chat.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/protocols/FacebookRM/src/chat.cpp b/protocols/FacebookRM/src/chat.cpp
index 684abe0671..d7d725917a 100644
--- a/protocols/FacebookRM/src/chat.cpp
+++ b/protocols/FacebookRM/src/chat.cpp
@@ -385,10 +385,51 @@ int FacebookProto::OnGCMenuHook(WPARAM, LPARAM lParam)
return 0;
}
-bool FacebookProto::isSpecialChatRoom(MCONTACT hContact) {
+bool FacebookProto::IsSpecialChatRoom(MCONTACT hContact) {
if (!isChatRoom(hContact))
return false;
ptrT idT(getTStringA(hContact, "ChatRoomID"));
return idT && !_tcscmp(idT, _T(FACEBOOK_NOTIFICATIONS_CHATROOM));
+}
+
+void FacebookProto::PrepareNotificationsChatRoom() {
+ if (!getBool(FACEBOOK_KEY_NOTIFICATIONS_CHATROOM, DEFAULT_NOTIFICATIONS_CHATROOM))
+ return;
+
+ // Prepare notifications chatroom if not exists
+ TCHAR *gidT = _T(FACEBOOK_NOTIFICATIONS_CHATROOM);
+
+ MCONTACT hNotificationsChatRoom = ChatIDToHContact(gidT);
+ if (hNotificationsChatRoom == NULL || getDword(hNotificationsChatRoom, "Status", ID_STATUS_OFFLINE) != ID_STATUS_ONLINE) {
+ TCHAR nameT[200];
+ mir_sntprintf(nameT, SIZEOF(nameT), _T("%s: %s"), m_tszUserName, TranslateT("Notifications"));
+
+ // Create the group chat session
+ GCSESSION gcw = { sizeof(gcw) };
+ gcw.iType = GCW_PRIVMESS;
+ gcw.ptszID = gidT;
+ gcw.pszModule = m_szModuleName;
+ gcw.ptszName = nameT;
+ CallServiceSync(MS_GC_NEWSESSION, 0, (LPARAM)&gcw);
+
+ // Send setting events
+ GCDEST gcd = { m_szModuleName, gidT, GC_EVENT_CONTROL };
+ GCEVENT gce = { sizeof(gce), &gcd };
+ gce.time = ::time(NULL);
+
+ CallServiceSync(MS_GC_EVENT, WINDOW_HIDDEN, reinterpret_cast<LPARAM>(&gce));
+ CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, reinterpret_cast<LPARAM>(&gce));
+ }
+}
+
+void FacebookProto::UpdateNotificationsChatRoom(facebook_notification *notification) {
+ if (!getBool(FACEBOOK_KEY_NOTIFICATIONS_CHATROOM, DEFAULT_NOTIFICATIONS_CHATROOM))
+ return;
+
+ char *name = _T2A(TranslateT("Notification"), CP_UTF8);
+
+ std::stringstream text;
+ text << notification->text << "\n\n" << notification->link;
+ UpdateChat(_T(FACEBOOK_NOTIFICATIONS_CHATROOM), name /*notification->second->user_id.c_str()*/, name, text.str().c_str(), notification->time, notification->seen);
} \ No newline at end of file