diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-04-21 14:50:37 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-04-21 14:50:37 +0000 |
commit | 1506353f98b6f2862ae0d701b837b4378ed0b620 (patch) | |
tree | 401fa67535f18b742957d0f8f5915b36590725e8 /protocols/FacebookRM | |
parent | 4a1eb5200ee36228ded5cd9a005c7d19d2bba142 (diff) |
Facebook: Support receiving typing notifications for chatrooms
git-svn-id: http://svn.miranda-ng.org/main/trunk@9009 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index ff9f4d7fec..cd9d6f286a 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -614,6 +614,44 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)60);
else
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
+ } else if (t == "ttyp") {
+ // multi chat typing notification
+
+ JSONNODE *from_ = json_get(it, "from");
+ JSONNODE *thread_ = json_get(it, "thread");
+ JSONNODE *st_ = json_get(it, "st");
+
+ if (from_ == NULL || thread_ == NULL || st_ == NULL)
+ continue;
+
+ std::tstring tid = json_as_string(thread_);
+ std::string from_id = json_as_pstring(from_);
+
+ std::map<std::tstring, facebook_chatroom>::iterator chatroom = proto->facy.chat_rooms.find(tid);
+ if (chatroom != proto->facy.chat_rooms.end()) {
+ std::map<std::string, std::string>::const_iterator participant = chatroom->second.participants.find(from_id);
+ if (participant == chatroom->second.participants.end()) {
+ // TODO: load name of this participant
+ std::string name = from_id;
+ proto->AddChatContact(tid.c_str(), from_id.c_str(), name.c_str());
+ }
+
+ participant = chatroom->second.participants.find(from_id);
+ if (participant != chatroom->second.participants.end()) {
+ MCONTACT hChatContact = proto->ChatIDToHContact(tid);
+ ptrT name(mir_utf8decodeT(participant->second.c_str()));
+
+ TCHAR tstr[200];
+
+ if (json_as_int(st_) == 1)
+ mir_sntprintf(tstr, SIZEOF(tstr), TranslateT("%s is typing a message..."), name);
+ else
+ mir_sntprintf(tstr, SIZEOF(tstr), _T(""));
+
+ // TODO: support proper MS_PROTO_CONTACTISTYPING service for chatrooms (when it will be implemented)
+ CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hChatContact, (LPARAM)tstr);
+ }
+ }
} else if (t == "privacy_changed") {
// settings changed
|