From e6b307560c6d58d8c1e7b960c2d41d759947b2e2 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 8 Aug 2024 13:11:59 +0300 Subject: SkypeWeb: fix for contact's info format v.2 --- protocols/SkypeWeb/src/skype_contacts.cpp | 45 ++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 3797ff66fd..733bbc631a 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -146,8 +146,6 @@ void CSkypeProto::LoadContactList(MHttpResponse *response, AsyncHttpRequest*) auto &root = reply.data(); for (auto &item : root["contacts"]) { - const JSONNode &name = item["name"]; - CMStringA szSkypeId = item["person_id"].as_mstring(); if (!IsPossibleUserType(szSkypeId)) continue; @@ -170,33 +168,48 @@ void CSkypeProto::LoadContactList(MHttpResponse *response, AsyncHttpRequest*) delSetting(hContact, "IsBlocked"); ptrW wszGroup(Clist_GetGroup(hContact)); - if (wszGroup == nullptr) { - if (wstrCListGroup) { - Clist_GroupCreate(0, wstrCListGroup); - Clist_SetGroup(hContact, wstrCListGroup); + if (wszGroup == nullptr && wstrCListGroup) { + Clist_GroupCreate(0, wstrCListGroup); + Clist_SetGroup(hContact, wstrCListGroup); + } + + auto &profile = item["profile"]; + SetString(hContact, "Homepage", profile["website"]); + + auto wstr = profile["birthday"].as_mstring(); + if (!wstr.IsEmpty() ) { + int nYear, nMonth, nDay; + if (swscanf(wstr, L"%d-%d-%d", &nYear, &nMonth, &nDay) == 3) { + setWord(hContact, "BirthYear", nYear); + setByte(hContact, "BirthMonth", nMonth); + setByte(hContact, "BirthDay", nDay); } } + wstr = profile["gender"].as_mstring(); + if (wstr == "male") + setByte(hContact, "Gender", 'M'); + else if (wstr == "female") + setByte(hContact, "Gender", 'F'); + + auto &name = profile["name"]; SetString(hContact, "FirstName", name["first"]); SetString(hContact, "LastName", name["surname"]); - if (item["mood"]) + if (profile["mood"]) db_set_ws(hContact, "CList", "StatusMsg", RemoveHtml(item["mood"].as_mstring())); - SetAvatarUrl(hContact, item["avatar_url"].as_mstring()); + SetAvatarUrl(hContact, profile["avatar_url"].as_mstring()); ReloadAvatarInfo(hContact); - for (auto &phone : item["phones"]) { + for (auto &phone : profile["phones"]) { CMStringW number = phone["number"].as_mstring(); - switch (phone["type"].as_int()) { - case 0: - setWString(hContact, "Phone", number); - break; - case 2: + auto wszType = phone["type"].as_mstring(); + if (wszType == L"mobile") setWString(hContact, "Cellular", number); - break; - } + else if (wszType == L"phone") + setWString(hContact, "Phone", number); } } -- cgit v1.2.3