From c9e610c405ec66764de279ff797ffa48964936be Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Tue, 25 Aug 2015 12:58:13 +0000 Subject: SkypeWeb: Contacts receiving git-svn-id: http://svn.miranda-ng.org/main/trunk@15028 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_messages.cpp | 64 ++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_messages.cpp') diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index b8483e7b46..45fe0177d3 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -28,7 +28,6 @@ int CSkypeProto::OnReceiveMessage(MCONTACT hContact, const char *szContent, cons recv.lParam = emoteOffset; recv.pCustomData = (void*)mir_strdup(szMessageId); recv.cbCustomDataSize = (DWORD)mir_strlen(szMessageId); - if (isRead) recv.flags |= PREF_CREATEREAD; @@ -234,8 +233,11 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node) { AddDbEvent(SKYPE_DB_EVENT_TYPE_URIOBJ, hContact, timestamp, DBEF_UTF, strContent.c_str(), szMessageId); } + else if (strMessageType == "RichText/Contacts") + { + ProcessContactRecv(hContact, timestamp, strContent.c_str(), szMessageId); + } //else if (messageType == "Event/SkypeVideoMessage") {} - //else if (messageType.c_str() == "RichText/Contacts") {} //else if (messageType.c_str() == "RichText/Location") {} else { @@ -263,3 +265,61 @@ void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent) if(db_get_dw(hContact, m_szModuleName, "LastMsgTime", 0) > (timestamp - 300)) PushRequest(new MarkMessageReadRequest(username, timestamp, timestamp, false, li)); } + + +void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const char *szContent, const char *szMessageId) +{ + HXML xmlNode = xmlParseString(mir_utf8decodeT(szContent), 0, _T("contacts")); + if (xmlNode) + { + int nCount = 0; + PROTOSEARCHRESULT **psr; + for (int i = 0; i < xmlGetChildCount(xmlNode); i++) nCount++; + + if (psr = (PROTOSEARCHRESULT**)mir_calloc(sizeof(PROTOSEARCHRESULT*) * nCount)) + { + nCount = 0; + for (int i = 0; i < xmlGetChildCount(xmlNode); i++) + { + HXML xmlContact = xmlGetNthChild(xmlNode, _T("c"), i); + if (xmlContact != NULL) + { + const TCHAR *tszContactId = xmlGetAttrValue(xmlContact, L"s"); + //const TCHAR *tszContactName = xmlGetAttrValue(xmlContact, L"f"); + + psr[nCount] = (PROTOSEARCHRESULT*)mir_calloc(sizeof(PROTOSEARCHRESULT)); + psr[nCount]->cbSize = sizeof(psr); + psr[nCount]->flags = PSR_TCHAR; + psr[nCount]->id.t = mir_tstrdup(tszContactId); + //psr[nCount]->nick.t = mir_tstrdup(tszContactName == NULL ? L"" : tszContactName); + nCount++; + } + } + if (nCount) + { + PROTORECVEVENT pre = { 0 }; + pre.timestamp = (DWORD)timestamp; + pre.szMessage = (char*)psr; + + PBYTE b = (PBYTE)mir_calloc(sizeof(DWORD) + mir_strlen(szMessageId) + 1); + PBYTE pCur = b; + *((PDWORD)pCur) = nCount; + pCur += sizeof(DWORD); + + mir_strcpy((char*)pCur, szMessageId); + + pre.lParam = (LPARAM)b; + + ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre); + for (nCount = 0; nCount < *((PDWORD)b); nCount++) + { + mir_free(psr[nCount]->id.t); + mir_free(psr[nCount]->nick.t); + mir_free(psr[nCount]); + } + mir_free(b); + } + mir_free(psr); + } + } +} \ No newline at end of file -- cgit v1.2.3