summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_contacts.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-03-19 22:01:53 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-03-19 22:01:53 +0000
commit347b63f23b40b403470d9636d691337cf8713e54 (patch)
tree91869e69b4b08b2355c1bcf7713b61127f91b3d7 /protocols/SkypeWeb/src/skype_contacts.cpp
parent14834460074eebcee4a83917fbb806a95446aec3 (diff)
SkypeWeb:
- added own info reading - refactored contact info reading git-svn-id: http://svn.miranda-ng.org/main/trunk@12437 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_contacts.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp94
1 files changed, 24 insertions, 70 deletions
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index f403c462e5..e0b8fc1722 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -83,21 +83,21 @@ MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary)
return hContact;
}
-//[{ "username":"echo123", "firstname" : "Echo \/ Sound Test Service", "lastname" : null, "avatarUrl" : null, "mood" : null, "richMood" : null, "displayname" : null, "country" : null, "city" : null },...]
-void CSkypeProto::LoadProfiles(const NETLIBHTTPREQUEST *response)
+//[{"username":"echo123", "firstname" : "Echo \/ Sound Test Service", "lastname" : null, "avatarUrl" : null, "mood" : null, "richMood" : null, "displayname" : null, "country" : null, "city" : null},...]
+void CSkypeProto::LoadContactsInfo(const NETLIBHTTPREQUEST *response)
{
if (response == NULL)
return;
- JSONROOT root(response->pData);
- if (root == NULL)
+ JSONROOT root(response->pData);
+ if (root == NULL)
return;
JSONNODE *items = json_as_array(root), *item, *node;
- for (size_t i = 0; i < json_size(items); i++)
- {
- item = json_at(items, i);
- if (item == NULL)
+ for (size_t i = 0; i < json_size(items); i++)
+ {
+ item = json_at(items, i);
+ if (item == NULL)
break;
node = json_get(item, "username");
@@ -105,83 +105,37 @@ void CSkypeProto::LoadProfiles(const NETLIBHTTPREQUEST *response)
MCONTACT hContact = AddContact(skypename);
if (hContact)
{
- node = json_get(item, "fullname");
- CMString realname = ptrT(json_as_string(node));
- if (!realname.IsEmpty() && realname != "null")
- {
- size_t pos = realname.Find(' ', 1);
- if (mir_strcmpi(skypename, "echo123") != 0 && pos != -1)
- {
- setTString(hContact, "FirstName", realname.Mid(0, pos));
- setTString(hContact, "LastName", realname.Mid(pos + 1));
- }
- else
- {
- setTString(hContact, "FirstName", realname);
- delSetting(hContact, "LastName");
- }
- }
- else
- {
- delSetting(hContact, "FirstName");
- delSetting(hContact, "LastName");
- }
-
- node = json_get(item, "display_name");
- CMString nick = ptrT(json_as_string(node));
- if (!nick.IsEmpty() && nick != "null")
- setTString(hContact, "Nick", nick);
- else
- delSetting(hContact, "Nick");
-
- node = json_get(item, "avatarUrl");
- CMStringA avatarUrl = mir_t2a(ptrT(json_as_string(node)));
- if (avatarUrl && avatarUrl != "null")
- ; // TODO: load avatar
-
- node = json_get(item, "mood");
- CMString mood = ptrT(json_as_string(node));
- if (!mood.IsEmpty() && mood != "null")
- db_set_ts(hContact, "CList", "StatusMsg", mood);
- else
- db_unset(hContact, "CList", "StatusMsg");
-
- node = json_get(item, "richMood");
- ptrT richMood(json_as_string(node));
-
- node = json_get(item, "country");
- ptrA country(mir_t2a(ptrT(json_as_string(node))));
-
- node = json_get(item, "city");
- CMString city = ptrT(json_as_string(node));
- if (!city.IsEmpty() && city != "null")
- setTString(hContact, "City", city);
- else
- delSetting(hContact, "City");
+ UpdateProfileFirstName(item, hContact);
+ UpdateProfileLastName(item, hContact);
+ UpdateProfileDisplayName(item, hContact);
+ UpdateProfileCountry(item, hContact);
+ UpdateProfileCity(item, hContact);
+ UpdateProfileStatusMessage(item, hContact);
+ //richMood
+ UpdateProfileAvatar(item, hContact);
}
-
}
json_delete(items);
}
//[{"skypename":"echo123", "authorized" : true, "blocked" : false, ...},...]
// other properties is exists but empty
-void CSkypeProto::LoadContacts(const NETLIBHTTPREQUEST *response)
+void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response)
{
if (response == NULL)
return;
- JSONROOT root(response->pData);
- if (root == NULL)
+ JSONROOT root(response->pData);
+ if (root == NULL)
return;
LIST<char> skypenames(1);
JSONNODE *items = json_as_array(root), *item, *node;
- for (size_t i = 0; i < json_size(items); i++)
- {
- item = json_at(items, i);
- if (item == NULL)
+ for (size_t i = 0; i < json_size(items); i++)
+ {
+ item = json_at(items, i);
+ if (item == NULL)
break;
node = json_get(item, "skypename");
@@ -211,7 +165,7 @@ void CSkypeProto::LoadContacts(const NETLIBHTTPREQUEST *response)
if (skypenames.getCount() > 0)
{
ptrA token(getStringA("TokenSecret"));
- PushRequest(new GetProfilesRequest(token, skypenames), &CSkypeProto::LoadProfiles);
+ PushRequest(new GetContactsInfoRequest(token, skypenames), &CSkypeProto::LoadContactsInfo);
for (size_t i = 0; i < skypenames.getCount(); i++)
{