summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2024-06-09 19:58:36 +0300
committerGeorge Hazan <george.hazan@gmail.com>2024-06-09 19:58:36 +0300
commitbccb5a28410bd899280048ff8267c5aa98e5a2fa (patch)
treec80f9c1bb009642dac8f6a10409e0993ea1adc08
parentca075a2786664d1cf635ea04236237fd95e46607 (diff)
code cleaning
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp10
-rw-r--r--protocols/SkypeWeb/src/skype_profile.cpp119
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h13
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp9
4 files changed, 26 insertions, 125 deletions
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index c16ccaa97a..e2b2539423 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -134,7 +134,7 @@ void CSkypeProto::LoadContactsAuth(MHttpResponse *response, AsyncHttpRequest*)
dbei.timestamp = time(0);
dbei.cbBlob = blob.size();
dbei.pBlob = blob;
- ProtoChainRecv(hContact, PSR_AUTH, 0, dbei);
+ ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&dbei);
}
}
@@ -154,8 +154,6 @@ void CSkypeProto::LoadContactList(MHttpResponse *response, AsyncHttpRequest*)
const JSONNode &name = item["name"];
std::string skypeId = item["person_id"].as_string();
- CMStringW first_name = name["first"].as_mstring();
- CMStringW last_name = name["surname"].as_mstring();
CMStringW avatar_url = item["avatar_url"].as_mstring();
std::string type = item["type"].as_string();
@@ -187,10 +185,8 @@ void CSkypeProto::LoadContactList(MHttpResponse *response, AsyncHttpRequest*)
setString(hContact, "Type", type.c_str());
- if (first_name)
- setWString(hContact, "FirstName", first_name);
- if (last_name)
- setWString(hContact, "LastName", last_name);
+ SetString(hContact, "FirstName", name["first"]);
+ SetString(hContact, "LastName", name["surname"]);
if (item["mood"])
db_set_ws(hContact, "CList", "StatusMsg", RemoveHtml(item["mood"].as_mstring()));
diff --git a/protocols/SkypeWeb/src/skype_profile.cpp b/protocols/SkypeWeb/src/skype_profile.cpp
index 963e60db68..ee010b9444 100644
--- a/protocols/SkypeWeb/src/skype_profile.cpp
+++ b/protocols/SkypeWeb/src/skype_profile.cpp
@@ -208,24 +208,6 @@ void CSkypeProto::InitLanguages()
result[L"zu"] = L"Zulu";
}
-void CSkypeProto::UpdateProfileFirstName(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW firstname = root["firstname"].as_mstring();
- if (!firstname.IsEmpty() && firstname != "null")
- setWString(hContact, "FirstName", firstname);
- else
- delSetting(hContact, "FirstName");
-}
-
-void CSkypeProto::UpdateProfileLastName(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW lastname = root["lastname"].as_mstring();
- if (!lastname.IsEmpty() && lastname != "null")
- setWString(hContact, "LastName", lastname);
- else
- delSetting(hContact, "LastName");
-}
-
void CSkypeProto::UpdateProfileDisplayName(const JSONNode &root, MCONTACT hContact)
{
ptrW firstname(getWStringA(hContact, "FirstName"));
@@ -239,13 +221,8 @@ void CSkypeProto::UpdateProfileDisplayName(const JSONNode &root, MCONTACT hConta
else if (lastname)
setWString(hContact, "Nick", lastname);
else {
-
const JSONNode &node = root["displayname"];
- CMStringW displayname((!node) ? root["username"].as_mstring() : node.as_mstring());
- if (!displayname.IsEmpty() && displayname != "null")
- setWString(hContact, "Nick", displayname);
- else
- delSetting(hContact, "Nick");
+ SetString(hContact, "Nick", (node) ? node : root["username"]);
}
}
@@ -285,24 +262,6 @@ void CSkypeProto::UpdateProfileCountry(const JSONNode &root, MCONTACT hContact)
else delSetting(hContact, "Country");
}
-void CSkypeProto::UpdateProfileState(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW province = root["province"].as_mstring();
- if (!province.IsEmpty() && province != "null")
- setWString(hContact, "State", province);
- else
- delSetting(hContact, "State");
-}
-
-void CSkypeProto::UpdateProfileCity(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW city = root["city"].as_mstring();
- if (!city.IsEmpty() && city != "null")
- setWString(hContact, "City", city);
- else
- delSetting(hContact, "City");
-}
-
void CSkypeProto::UpdateProfileLanguage(const JSONNode &root, MCONTACT hContact)
{
CMStringW isocode = root["language"].as_mstring();
@@ -312,24 +271,6 @@ void CSkypeProto::UpdateProfileLanguage(const JSONNode &root, MCONTACT hContact)
delSetting(hContact, "Language0");
}
-void CSkypeProto::UpdateProfileHomepage(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW homepage = root["homepage"].as_mstring();
- if (!homepage.IsEmpty() && homepage != "null")
- setWString(hContact, "Homepage", homepage);
- else
- delSetting(hContact, "Homepage");
-}
-
-void CSkypeProto::UpdateProfileAbout(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW about = root["about"].as_mstring();
- if (!about.IsEmpty() && about != "null")
- setWString(hContact, "About", about);
- else
- delSetting(hContact, "About");
-}
-
void CSkypeProto::UpdateProfileEmails(const JSONNode &root, MCONTACT hContact)
{
const JSONNode &node = root["emails"];
@@ -351,42 +292,6 @@ void CSkypeProto::UpdateProfileEmails(const JSONNode &root, MCONTACT hContact)
}
}
-void CSkypeProto::UpdateProfilePhoneMobile(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW province = root["phoneMobile"].as_mstring();
- if (!province.IsEmpty() && province != "null")
- setWString(hContact, "Cellular", province);
- else
- delSetting(hContact, "Cellular");
-}
-
-void CSkypeProto::UpdateProfilePhoneHome(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW province = root["phone"].as_mstring();
- if (!province.IsEmpty() && province != "null")
- setWString(hContact, "Phone", province);
- else
- delSetting(hContact, "Phone");
-}
-
-void CSkypeProto::UpdateProfilePhoneOffice(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW province = root["phoneOffice"].as_mstring();
- if (!province.IsEmpty() && province != "null")
- setWString(hContact, "CompanyPhone", province);
- else
- delSetting(hContact, "CompanyPhone");
-}
-
-void CSkypeProto::UpdateProfileXStatusMessage(const JSONNode &root, MCONTACT hContact)
-{
- CMStringW province = root["richMood"].as_mstring();
- if (!province.IsEmpty() && province != "null")
- setWString(hContact, "XStatusMsg", province);
- else
- delSetting(hContact, "XStatusMsg");
-}
-
void CSkypeProto::UpdateProfileAvatar(const JSONNode &root, MCONTACT hContact)
{
CMStringW province = root["avatarUrl"].as_mstring();
@@ -419,23 +324,23 @@ void CSkypeProto::LoadProfile(MHttpResponse *response, AsyncHttpRequest *pReques
else
m_szMyname = m_szSkypename;
- UpdateProfileFirstName(root, hContact);
- UpdateProfileLastName(root, hContact);
+ SetString(hContact, "City", root["city"]);
+ SetString(hContact, "About", root["about"]);
+ SetString(hContact, "Phone", root["phone"]);
+ SetString(hContact, "State", root["province"]);
+ SetString(hContact, "Cellular", root["phoneMobile"]);
+ SetString(hContact, "Homepage", root["homepage"]);
+ SetString(hContact, "LastName", root["lastname"]);
+ SetString(hContact, "FirstName", root["firstname"]);
+ SetString(hContact, "XStatusMsg", root["richMood"]);
+ SetString(hContact, "CompanyPhone", root["phoneOffice"]);
+
UpdateProfileDisplayName(root, hContact);
UpdateProfileGender(root, hContact);
UpdateProfileBirthday(root, hContact);
UpdateProfileCountry(root, hContact);
- UpdateProfileState(root, hContact);
- UpdateProfileCity(root, hContact);
UpdateProfileLanguage(root, hContact);
- UpdateProfileHomepage(root, hContact);
- UpdateProfileAbout(root, hContact);
- //jobtitle
UpdateProfileEmails(root, hContact);
- UpdateProfilePhoneMobile(root, hContact);
- UpdateProfilePhoneHome(root, hContact);
- UpdateProfilePhoneOffice(root, hContact);
- //richMood
UpdateProfileAvatar(root, hContact);
ProtoBroadcastAck(hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, 0);
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index b2772ddc8d..ac92faff72 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -225,22 +225,12 @@ private:
void SendPresence();
// profile
- void UpdateProfileFirstName(const JSONNode &root, MCONTACT hContact = NULL);
- void UpdateProfileLastName(const JSONNode &root, MCONTACT hContact = NULL);
void UpdateProfileDisplayName(const JSONNode &root, MCONTACT hContact = NULL);
void UpdateProfileGender(const JSONNode &root, MCONTACT hContact = NULL);
void UpdateProfileBirthday(const JSONNode &root, MCONTACT hContact = NULL);
void UpdateProfileCountry(const JSONNode &node, MCONTACT hContact = NULL);
- void UpdateProfileState(const JSONNode &node, MCONTACT hContact = NULL);
- void UpdateProfileCity(const JSONNode &node, MCONTACT hContact = NULL);
void UpdateProfileLanguage(const JSONNode &root, MCONTACT hContact = NULL);
- void UpdateProfileHomepage(const JSONNode &root, MCONTACT hContact = NULL);
- void UpdateProfileAbout(const JSONNode &node, MCONTACT hContact = NULL);
void UpdateProfileEmails(const JSONNode &root, MCONTACT hContact = NULL);
- void UpdateProfilePhoneMobile(const JSONNode &root, MCONTACT hContact = NULL);
- void UpdateProfilePhoneHome(const JSONNode &root, MCONTACT hContact = NULL);
- void UpdateProfilePhoneOffice(const JSONNode &root, MCONTACT hContact = NULL);
- void UpdateProfileXStatusMessage(const JSONNode &root, MCONTACT hContact = NULL);
void UpdateProfileAvatar(const JSONNode &root, MCONTACT hContact = NULL);
void __cdecl CSkypeProto::SendFileThread(void *p);
@@ -342,7 +332,8 @@ private:
void ProcessTimer();
- CMStringW RunConfirmationCode();
+ void SetString(MCONTACT hContact, const char *pszSetting, const JSONNode &node);
+
CMStringW ChangeTopicForm();
//events
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index 88317babc4..36128db115 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -480,6 +480,15 @@ const wchar_t* GetSkypeNick(const wchar_t *szSkypeId)
return szSkypeId;
}
+void CSkypeProto::SetString(MCONTACT hContact, const char *pszSetting, const JSONNode &node)
+{
+ CMStringW str = node.as_mstring();
+ if (str.IsEmpty() || str == L"null")
+ delSetting(hContact, pszSetting);
+ else
+ setWString(hContact, pszSetting, str);
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// url parsing