diff options
author | George Hazan <ghazan@miranda.im> | 2019-02-14 18:43:34 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-02-14 18:43:34 +0300 |
commit | 4fd7e4b563949b0f82d4e5fc81727af2de38da31 (patch) | |
tree | a49dad04003b4d2350acd4f783e44ae431782cf9 | |
parent | aa5b93489cf1185018e00a48033ac8a844dca533 (diff) |
grrm, one missing HXML
-rw-r--r-- | protocols/SkypeWeb/src/skype_messages.cpp | 80 |
1 files changed, 38 insertions, 42 deletions
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 0c6744c35f..67c289321e 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -237,54 +237,50 @@ void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent) PushRequest(new MarkMessageReadRequest(Contacts[hContact], timestamp, timestamp, false, li));
}
-
void CSkypeProto::ProcessContactRecv(MCONTACT hContact, time_t timestamp, const char *szContent, const char *szMessageId)
{
- HXML xmlNode = xmlParseString(mir_utf8decodeW(szContent), nullptr, L"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, L"c", i);
- if (xmlContact != nullptr) {
- const wchar_t *tszContactId = xmlGetAttrValue(xmlContact, L"s");
- //const wchar_t *tszContactName = xmlGetAttrValue(xmlContact, L"f");
-
- psr[nCount] = (PROTOSEARCHRESULT*)mir_calloc(sizeof(PROTOSEARCHRESULT));
- psr[nCount]->cbSize = sizeof(psr);
- psr[nCount]->flags = PSR_UNICODE;
- psr[nCount]->id.w = mir_wstrdup(tszContactId);
- //psr[nCount]->nick.w = mir_wstrdup(tszContactName == NULL ? L"" : tszContactName);
- nCount++;
- }
- }
- if (nCount) {
- PROTORECVEVENT pre = { 0 };
- pre.timestamp = (DWORD)timestamp;
- pre.szMessage = (char*)psr;
+ TiXmlDocument doc;
+ if (0 != doc.Parse(szContent))
+ return;
+
+ auto *xmlNode = doc.FirstChildElement("contacts");
+ if (xmlNode == nullptr)
+ return;
+
+ int nCount = 0;
+ for (auto *it : TiXmlEnum(xmlNode))
+ nCount++;
+
+ PROTOSEARCHRESULT **psr = (PROTOSEARCHRESULT**)mir_calloc(sizeof(PROTOSEARCHRESULT*) * nCount);
+
+ nCount = 0;
+ for (auto *xmlContact : TiXmlFilter(xmlNode, "c")) {
+ psr[nCount] = (PROTOSEARCHRESULT*)mir_calloc(sizeof(PROTOSEARCHRESULT));
+ psr[nCount]->cbSize = sizeof(psr);
+ psr[nCount]->id.a = mir_strdup(xmlContact->Attribute("s"));
+ nCount++;
+ }
- PBYTE b = (PBYTE)mir_calloc(sizeof(DWORD) + mir_strlen(szMessageId) + 1);
- PBYTE pCur = b;
- *((PDWORD)pCur) = nCount;
- pCur += sizeof(DWORD);
+ if (nCount) {
+ PROTORECVEVENT pre = {};
+ pre.timestamp = (DWORD)timestamp;
+ pre.szMessage = (char*)psr;
- mir_strcpy((char*)pCur, szMessageId);
+ PBYTE b = (PBYTE)mir_calloc(sizeof(DWORD) + mir_strlen(szMessageId) + 1);
+ PBYTE pCur = b;
+ *((PDWORD)pCur) = nCount;
+ pCur += sizeof(DWORD);
- pre.lParam = (LPARAM)b;
+ mir_strcpy((char*)pCur, szMessageId);
- ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
- for (DWORD i = 0; i < *((PDWORD)b); i++) {
- mir_free(psr[i]->id.w);
- mir_free(psr[i]);
- }
- mir_free(b);
- }
- mir_free(psr);
+ pre.lParam = (LPARAM)b;
+
+ ProtoChainRecv(hContact, PSR_CONTACTS, 0, (LPARAM)&pre);
+ for (DWORD i = 0; i < *((PDWORD)b); i++) {
+ mir_free(psr[i]->id.a);
+ mir_free(psr[i]);
}
+ mir_free(b);
}
+ mir_free(psr);
}
|