From 66e780c034b6a297f7ace52e2d3414153da2b110 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Wed, 8 Apr 2015 19:05:29 +0000 Subject: SkypeWeb: ConversationUpdate support. git-svn-id: http://svn.miranda-ng.org/main/trunk@12680 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_poll_processing.cpp | 51 +++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/protocols/SkypeWeb/src/skype_poll_processing.cpp b/protocols/SkypeWeb/src/skype_poll_processing.cpp index 8cf980e324..e55a080fb8 100644 --- a/protocols/SkypeWeb/src/skype_poll_processing.cpp +++ b/protocols/SkypeWeb/src/skype_poll_processing.cpp @@ -148,7 +148,56 @@ void CSkypeProto::ProcessNewMessageRes(JSONNODE *node) void CSkypeProto::ProcessConversationUpdateRes(JSONNODE *node) { - return; + debugLogA("CSkypeProto::ProcessNewMessageRes"); + JSONNODE *lastmsg = json_get(node, "lastMessage"); + + ptrA clientMsgId(mir_t2a(ptrT(json_as_string(json_get(lastmsg, "clientmessageid"))))); + ptrA skypeEditedId(mir_t2a(ptrT(json_as_string(json_get(lastmsg, "skypeeditedid"))))); + ptrA messageType(mir_t2a(ptrT(json_as_string(json_get(lastmsg, "messagetype"))))); + ptrA from(mir_t2a(ptrT(json_as_string(json_get(lastmsg, "from"))))); + ptrA content(mir_t2a(ptrT(json_as_string(json_get(lastmsg, "content"))))); + ptrT composeTime(json_as_string(json_get(lastmsg, "composetime"))); + ptrA conversationLink(mir_t2a(ptrT(json_as_string(json_get(lastmsg, "conversationLink"))))); + ptrA type(mir_t2a(ptrT(json_as_string(json_get(node, "type"))))); + time_t timestamp = IsoToUnixTime(composeTime); + + if (strstr(conversationLink, "/8:")) + { + if (!mir_strcmpi(type, "Message")) + { + ptrA skypename(ContactUrlToName(from)); + MCONTACT hContact = GetContact(skypename); + + if (hContact == NULL && !IsMe(skypename)) + AddContact(skypename, true); + + if (!mir_strcmpi(messageType, "Control/Typing")) + { + CallService(MS_PROTO_CONTACTISTYPING, hContact, 5); + } + else if (!mir_strcmpi(messageType, "Control/ClearTyping")) + { + CallService(MS_PROTO_CONTACTISTYPING, hContact, 0); + } + else if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText")) + { + int emoteOffset = json_as_int(json_get(node, "skypeemoteoffset")); + if (IsMe(skypename)) + { + hContact = GetContact(ptrA(ContactUrlToName(conversationLink))); + int hMessage = atoi(clientMsgId); + ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)hMessage, 0); + AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_SENT, clientMsgId, &content[emoteOffset], emoteOffset); + return; + } + OnReceiveMessage(clientMsgId, from, timestamp, content, emoteOffset); + } + else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage")) + { + return; //not supported + } + } + } } void CSkypeProto::ProcessThreadUpdateRes(JSONNODE *node) -- cgit v1.2.3