From a46fe1de288c25b360f008d84fd744f608878ce3 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Wed, 6 Jul 2016 19:08:21 +0000 Subject: SkypeWeb: fixed search git-svn-id: http://svn.miranda-ng.org/main/trunk@17070 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/requests/search.h | 10 ++++++++-- protocols/SkypeWeb/src/skype_messages.cpp | 3 +-- protocols/SkypeWeb/src/skype_profile.cpp | 2 +- protocols/SkypeWeb/src/skype_search.cpp | 15 ++++++++------- 4 files changed, 18 insertions(+), 12 deletions(-) (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/requests/search.h b/protocols/SkypeWeb/src/requests/search.h index 7549006e58..e8aad493b3 100644 --- a/protocols/SkypeWeb/src/requests/search.h +++ b/protocols/SkypeWeb/src/requests/search.h @@ -22,10 +22,16 @@ class GetSearchRequest : public HttpRequest { public: GetSearchRequest(const char *string, LoginInfo &li) : - HttpRequest(REQUEST_GET, "api.skype.com/search/users/any") + HttpRequest(REQUEST_GET, "skypegraph.skype.com/search/v1.1/namesearch/swx/") { + + wchar_t locale[LOCALE_NAME_MAX_LENGTH] = { 0 }; + LCIDToLocaleName(Langpack_GetDefaultLocale(), locale, _countof(locale), 0); + Url - << CHAR_VALUE("keyWord", string); + << CHAR_VALUE("requestid", "skype.com-1.48.78-00000000-0000-0000-0000-000000000000") + << CHAR_VALUE("locale", T2Utf(locale)) + << CHAR_VALUE("searchstring", string); Headers << CHAR_VALUE("Accept", "application/json") << CHAR_VALUE("X-Skypetoken", li.api.szToken); diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index b9c2257093..898bc1f11a 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -85,8 +85,7 @@ void CSkypeProto::OnMessageSent(const NETLIBHTTPREQUEST *response, void *arg) if (response->pData != NULL) { JSONNode jRoot = JSONNode::parse(response->pData); - auto it = m_mpOutMessages.find(hMessage); - if (it == m_mpOutMessages.end()) + if (m_mpOutMessages.find(hMessage) == m_mpOutMessages.end()) { m_mpOutMessages[hMessage] = std::stoull(jRoot["OriginalArrivalTime"].as_string()) / 1000; } diff --git a/protocols/SkypeWeb/src/skype_profile.cpp b/protocols/SkypeWeb/src/skype_profile.cpp index 37c9f72f37..1d59c06cf0 100644 --- a/protocols/SkypeWeb/src/skype_profile.cpp +++ b/protocols/SkypeWeb/src/skype_profile.cpp @@ -266,7 +266,7 @@ void CSkypeProto::UpdateProfileDisplayName(const JSONNode &root, MCONTACT hConta ptrT firstname(getTStringA(hContact, "FirstName")); ptrT lastname(getTStringA(hContact, "LastName")); if (firstname) { - CMString nick = firstname; + CMString nick(firstname); if (lastname) nick.AppendFormat(_T(" %s"), lastname); setTString(hContact, "Nick", nick); diff --git a/protocols/SkypeWeb/src/skype_search.cpp b/protocols/SkypeWeb/src/skype_search.cpp index f989be13db..7c7637abdc 100644 --- a/protocols/SkypeWeb/src/skype_search.cpp +++ b/protocols/SkypeWeb/src/skype_search.cpp @@ -53,17 +53,18 @@ void CSkypeProto::OnSearch(const NETLIBHTTPREQUEST *response) return; } - const JSONNode &items = root.as_array(); - for (size_t i = 0; i < items.size(); i++) + const JSONNode &items = root["results"].as_array(); + for (auto it = items.begin(); it != items.end(); ++it) { - const JSONNode &item = items[i]; - const JSONNode &ContactCards = item["ContactCards"]; - const JSONNode &Skype = ContactCards["Skype"]; + const JSONNode &item = (*it)["nodeProfileData"]; + + std::string skypeId = item["skypeId"].as_string(); + std::string name = item["name"].as_string(); PROTOSEARCHRESULT psr = { sizeof(psr) }; psr.flags = PSR_UTF8; - psr.id.a = mir_strdup(Skype["SkypeName"].as_string().c_str()); - psr.nick.a = mir_strdup(Skype["DisplayName"].as_string().c_str()); + psr.id.a = const_cast(skypeId.c_str()); + psr.nick.a = const_cast(name.c_str()); ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr); } -- cgit v1.2.3