From bc4739cfef31ece629fdd1cf3e1d67f1ddd3d996 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 10 Apr 2015 16:17:44 +0000 Subject: Skype: messagging refactoring git-svn-id: http://svn.miranda-ng.org/main/trunk@12748 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_chatrooms.cpp | 47 ++++++++++++++++ protocols/SkypeWeb/src/skype_poll_processing.cpp | 68 +++--------------------- protocols/SkypeWeb/src/skype_proto.h | 2 + 3 files changed, 56 insertions(+), 61 deletions(-) (limited to 'protocols') diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index ba6781e958..6662f9c786 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -76,4 +76,51 @@ void CSkypeProto::SetChatStatus(MCONTACT hContact, int iStatus) GCEVENT gce = { sizeof(gce), &gcd }; CallServiceSync(MS_GC_EVENT, true ? SESSION_INITDONE : WINDOW_HIDDEN, (LPARAM)&gce); CallServiceSync(MS_GC_EVENT, SESSION_ONLINE, (LPARAM)&gce); +} + +/* CHAT EVENT */ + +void CSkypeProto::OnChatEvent(JSONNODE *node) +{ + ptrA clientMsgId(mir_t2a(ptrT(json_as_string(json_get(node, "clientmessageid"))))); + ptrA skypeEditedId(mir_t2a(ptrT(json_as_string(json_get(node, "skypeeditedid"))))); + + ptrA from(mir_t2a(ptrT(json_as_string(json_get(node, "from"))))); + + ptrT composeTime(json_as_string(json_get(node, "composetime"))); + time_t timestamp = IsoToUnixTime(composeTime); + + ptrA content(mir_t2a(ptrT(json_as_string(json_get(node, "content"))))); + int emoteOffset = json_as_int(json_get(node, "skypeemoteoffset")); + + ptrA conversationLink(mir_t2a(ptrT(json_as_string(json_get(node, "conversationLink"))))); + ptrA chatname(ChatUrlToName(conversationLink)); + + ptrA topic(mir_t2a(ptrT(json_as_string(json_get(node, "threadtopic"))))); + + MCONTACT chatContact = AddChatRoom(chatname); + //SetChatStatus(chatContact, ID_STATUS_ONLINE); + + ptrA messageType(mir_t2a(ptrT(json_as_string(json_get(node, "messagetype"))))); + if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText")) + { + + } + else if (!mir_strcmpi(messageType, "ThreadActivity/AddMember")) + { + + } + else if (!mir_strcmpi(messageType, "ThreadActivity/DeleteMember")) + { + + } + else if (!mir_strcmpi(messageType, "ThreadActivity/TopicUpdate")) + { + + } + else if (!mir_strcmpi(messageType, "ThreadActivity/RoleUpdate")) + { + + } + return; //chats not supported } \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_poll_processing.cpp b/protocols/SkypeWeb/src/skype_poll_processing.cpp index 7d59ab5a0e..dd220f77dd 100644 --- a/protocols/SkypeWeb/src/skype_poll_processing.cpp +++ b/protocols/SkypeWeb/src/skype_poll_processing.cpp @@ -100,70 +100,16 @@ void CSkypeProto::ProcessNewMessageRes(JSONNODE *node) ptrA conversationLink(mir_t2a(ptrT(json_as_string(json_get(node, "conversationLink"))))); time_t timestamp = IsoToUnixTime(composeTime); int emoteOffset = json_as_int(json_get(node, "skypeemoteoffset")); - if (strstr(conversationLink, "/19:")) - { - ptrA chatname(ChatUrlToName(conversationLink)); - ptrA topic(mir_t2a(ptrT(json_as_string(json_get(node, "threadtopic"))))); - MCONTACT chatContact = AddChatRoom(chatname); - SetChatStatus(chatContact, ID_STATUS_ONLINE); - if (!mir_strcmpi(messageType, "Text") || !mir_strcmpi(messageType, "RichText")) - { - } - else if (!mir_strcmpi(messageType, "ThreadActivity/AddMember")) - { - - } - else if (!mir_strcmpi(messageType, "ThreadActivity/DeleteMember")) - { - - } - else if (!mir_strcmpi(messageType, "ThreadActivity/TopicUpdate")) - { - - } - else if (!mir_strcmpi(messageType, "ThreadActivity/RoleUpdate")) - { + if (strstr(conversationLink, "/8:")) + OnPrivateMessageEvent(node); + else if (strstr(conversationLink, "/19:")) + OnChatEvent(node); - } - return; //chats not supported - } - else if (strstr(conversationLink, "/8:")) + /*else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage")) { - OnPrivateMessageEvent(node); - ptrA skypename(ContactUrlToName(from)); - - if (IsMe(skypename)) - { - MCONTACT hContact = FindContact(ptrA(ContactUrlToName(conversationLink))); - int hMessage = atoi(clientMsgId); - ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_SUCCESS, (HANDLE)hMessage, 0); - debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId); - AddMessageToDb(hContact, timestamp, DBEF_UTF | DBEF_SENT, clientMsgId, &content[emoteOffset], emoteOffset); - } - else - { - MCONTACT hContact = 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")) - { - - if (IsMe(skypename)) - { - - } - debugLogA(__FUNCTION__" timestamp = %d clientmsgid = %s", timestamp, clientMsgId); - OnReceiveMessage(clientMsgId, from, timestamp, content, emoteOffset); - } - } - /*else if (!mir_strcmpi(messageType, "Event/SkypeVideoMessage")) - { - return; //not supported - }*/ - } + return; //not supported + }*/ } void CSkypeProto::ProcessConversationUpdateRes(JSONNODE *node) diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 74b9868ec4..a5c8383fc6 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -236,6 +236,8 @@ private: MCONTACT AddChatRoom(const char *chatname); void SetChatStatus(MCONTACT hContact, int iStatus); + void OnChatEvent(JSONNODE *node); + //polling void ParsePollData(JSONNODE *data); void __cdecl PollingThread(void*); -- cgit v1.2.3