From a1d2e31a7e40c3daf9b61b545aea09f3dcc40260 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Fri, 10 Apr 2015 09:41:12 +0000 Subject: skype search 2nd attempt git-svn-id: http://svn.miranda-ng.org/main/trunk@12723 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_search.cpp | 41 ++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) (limited to 'protocols') diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp index e8ed4c3b5d..8709ab5515 100644 --- a/protocols/SkypeWeb/src/skype_search.cpp +++ b/protocols/SkypeWeb/src/skype_search.cpp @@ -36,27 +36,42 @@ void CSkypeProto::SearchBasicThread(void* id) void CSkypeProto::OnSearch(const NETLIBHTTPREQUEST *response) { - if (response == NULL) + if (response == NULL) { + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); return; + } - JSONROOT root(response->pData); - if (root == NULL) + debugLogA("CSkypeProto::OnSearch %d", response->resultCode); + if (response->resultCode != 200) { + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); return; + } - /*PROTOSEARCHBYNAME *pParam = (PROTOSEARCHBYNAME *)pReq->pUserInfo; - debugLogA("CSkypeProto::OnSearch %d", reply->resultCode); - if (reply->resultCode != 200) { - if (pParam) { - mir_free(pParam->pszFirstName); - mir_free(pParam->pszLastName); - mir_free(pParam->pszNick); - delete pParam; - } + JSONROOT root(response->pData); + if (root == NULL) { ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); return; } - JSONROOT pRoot; + JSONNODE *items = json_as_array(root), *item, *node; + for (size_t i = 0; i < json_size(items); i++) + { + JSONNODE *item = json_at(items, i); + JSONNODE *ContactCards = json_get(item, "ContactCards"); + JSONNODE *Skype = json_get(ContactCards, "Skype"); + + TCHAR *sDisplayName = json_as_string(json_get(Skype, "DisplayName")); + TCHAR *sSkypeName = json_as_string(json_get(Skype, "SkypeName")); + + PROTOSEARCHRESULT psr = { sizeof(psr) }; + psr.flags = PSR_TCHAR; + psr.id = mir_wstrdup(sSkypeName); + psr.nick = mir_wstrdup(sDisplayName); + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr); + } + ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); + + /*JSONROOT pRoot; JSONNODE *pResponse = CheckJsonResponse(pReq, reply, pRoot); if (pResponse == NULL) { if (pParam) { -- cgit v1.2.3