diff options
author | George Hazan <ghazan@miranda.im> | 2017-05-29 23:45:19 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2017-05-29 23:45:19 +0300 |
commit | f63eb2bfc28dff8bbf9d56dd57b2bc6b53487f56 (patch) | |
tree | f2c2a56e945fc1ea44d5f22f95cd397a0d251fa2 /protocols/SkypeWeb/src/skype_contacts.cpp | |
parent | 133826f5022c5b0d9beca9285d66afcb604e2fc4 (diff) |
Skype:
- fixes #829;
- massive code cleaning
Diffstat (limited to 'protocols/SkypeWeb/src/skype_contacts.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_contacts.cpp | 86 |
1 files changed, 32 insertions, 54 deletions
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index d1781a386a..add5caadf7 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -25,8 +25,7 @@ WORD CSkypeProto::GetContactStatus(MCONTACT hContact) void CSkypeProto::SetContactStatus(MCONTACT hContact, WORD status)
{
WORD oldStatus = GetContactStatus(hContact);
- if (oldStatus != status)
- {
+ if (oldStatus != status) {
setWord(hContact, "Status", status);
if (status == ID_STATUS_OFFLINE)
db_unset(hContact, m_szModuleName, "MirVer");
@@ -35,8 +34,7 @@ void CSkypeProto::SetContactStatus(MCONTACT hContact, WORD status) void CSkypeProto::SetAllContactsStatus(WORD status)
{
- for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- {
+ for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (!isChatRoom(hContact))
SetContactStatus(hContact, status);
}
@@ -72,8 +70,7 @@ MCONTACT CSkypeProto::GetContactFromAuthEvent(MEVENT hEvent) MCONTACT CSkypeProto::FindContact(const char *skypename)
{
MCONTACT hContact = NULL;
- for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- {
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) {
if (!mir_strcmpi(skypename, Contacts[hContact]))
break;
}
@@ -84,16 +81,14 @@ MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary) {
MCONTACT hContact = FindContact(skypename);
- if (!hContact)
- {
+ if (!hContact) {
hContact = db_add_contact();
Proto_AddToContact(hContact, m_szModuleName);
setString(hContact, SKYPE_SETTINGS_ID, skypename);
DBVARIANT dbv;
- if (!getWString(SKYPE_SETTINGS_GROUP, &dbv))
- {
+ if (!getWString(SKYPE_SETTINGS_GROUP, &dbv)) {
db_set_ws(hContact, "CList", "Group", dbv.ptszVal);
db_free(&dbv);
}
@@ -117,8 +112,7 @@ void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response) return;
const JSONNode &items = root.as_array();
- for (size_t i = 0; i < items.size(); i++)
- {
+ for (size_t i = 0; i < items.size(); i++) {
const JSONNode &item = items.at(i);
if (!item)
break;
@@ -128,12 +122,10 @@ void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response) time_t eventTime = IsoToUnixTime(item["event_time_iso"].as_string().c_str());
MCONTACT hContact = AddContact(skypename.c_str());
- if (hContact)
- {
+ if (hContact) {
time_t lastEventTime = db_get_dw(hContact, m_szModuleName, "LastAuthRequestTime", 0);
- if (lastEventTime < eventTime)
- {
+ if (lastEventTime < eventTime) {
db_set_dw(hContact, m_szModuleName, "LastAuthRequestTime", eventTime);
delSetting(hContact, "Auth");
@@ -161,16 +153,14 @@ void CSkypeProto::LoadContactsInfo(const NETLIBHTTPREQUEST *response) return;
const JSONNode &items = root.as_array();
- for (size_t i = 0; i < items.size(); i++)
- {
+ for (size_t i = 0; i < items.size(); i++) {
const JSONNode &item = items.at(i);
if (!item)
break;
std::string skypename = item["username"].as_string();
MCONTACT hContact = AddContact(skypename.c_str());
- if (hContact)
- {
+ if (hContact) {
UpdateProfileCountry(item, hContact);
UpdateProfileCity(item, hContact);
UpdateProfileXStatusMessage(item, hContact);
@@ -193,8 +183,7 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response) LIST<char> skypenames(1);
bool loadAll = getBool("LoadAllContacts", false);
const JSONNode &items = root["contacts"].as_array();
- for (size_t i = 0; i < items.size(); i++)
- {
+ for (size_t i = 0; i < items.size(); i++) {
const JSONNode &item = items.at(i);
if (!item)
break;
@@ -208,29 +197,23 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response) CMStringW last_name = name["surname"].as_mstring();
CMStringW avatar_url = item["avatar_url"].as_mstring();
std::string type = item["type"].as_string();
-
- if (type == "skype" || loadAll)
- {
+
+ if (type == "skype" || loadAll) {
MCONTACT hContact = AddContact(skypename.c_str());
- if (hContact)
- {
- if (item["authorized"].as_bool())
- {
+ if (hContact) {
+ if (item["authorized"].as_bool()) {
delSetting(hContact, "Auth");
delSetting(hContact, "Grant");
}
else setByte(hContact, "Grant", 1);
- if (item["blocked"].as_bool())
- {
+ if (item["blocked"].as_bool()) {
db_set_dw(hContact, "Ignore", "Mask1", 127);
db_set_b(hContact, "CList", "Hidden", 1);
setByte(hContact, "IsBlocked", 1);
}
- else
- {
- if (db_get_b(hContact, m_szModuleName, "IsBlocked", 0))
- {
+ else {
+ if (db_get_b(hContact, m_szModuleName, "IsBlocked", 0)) {
db_set_dw(hContact, "Ignore", "Mask1", 0);
db_set_b(hContact, "CList", "Hidden", 0);
setByte(hContact, "IsBlocked", 0);
@@ -239,31 +222,28 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response) setString(hContact, "Type", type.c_str());
- if (display_name)
- setWString(hContact, "Nick", display_name);
- if (first_name)
- setWString(hContact, "FirstName", first_name);
+ if (display_name)
+ setWString(hContact, "Nick", display_name);
+ if (first_name)
+ setWString(hContact, "FirstName", first_name);
if (last_name)
- setWString(hContact, "LastName", last_name);
+ setWString(hContact, "LastName", last_name);
- if (item["mood"])
- {
+ if (item["mood"]) {
db_set_utf(hContact, "CList", "StatusMsg", ptrA(RemoveHtml(item["mood"].as_string().c_str())));
}
SetAvatarUrl(hContact, avatar_url);
ReloadAvatarInfo(hContact);
- for (size_t j = 0; j < phones.size(); j++)
- {
+ for (size_t j = 0; j < phones.size(); j++) {
const JSONNode &phone = phones.at(j);
if (!phone)
break;
CMStringW number = phone["number"].as_mstring();
- switch (phone["type"].as_int())
- {
+ switch (phone["type"].as_int()) {
case 0:
setWString(hContact, "Phone", number);
break;
@@ -273,22 +253,20 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response) }
}
- if (type == "skype") skypenames.insert(mir_strdup(skypename.c_str()));
+ if (type == "skype")
+ skypenames.insert(mir_strdup(skypename.c_str()));
}
}
}
- if (skypenames.getCount() > 0)
- {
+ if (skypenames.getCount() > 0) {
int i = 0;
- do
- {
+ do {
LIST<char> users(1);
for (; i < skypenames.getCount() && users.getCount() <= 50; i++)
users.insert(skypenames[i]);
PushRequest(new GetContactsInfoRequest(li, users), &CSkypeProto::LoadContactsInfo);
- }
- while(i < skypenames.getCount());
+ } while (i < skypenames.getCount());
FreeList(skypenames);
skypenames.destroy();
@@ -355,4 +333,4 @@ void CSkypeProto::OnUnblockContact(const NETLIBHTTPREQUEST *response, void *p) db_set_dw(hContact, "Ignore", "Mask1", 0);
db_set_b(hContact, "CList", "Hidden", 0);
db_set_b(hContact, m_szModuleName, "IsBlocked", 0);
-}
\ No newline at end of file +}
|