summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src/skype_contacts.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-03-20 20:17:29 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-03-20 20:17:29 +0000
commit3f403397d35d601078423e84d61ab0c1cce6203e (patch)
tree5060c0a07e7139148d9d0f1700288dd5e6b004f9 /protocols/SkypeWeb/src/skype_contacts.cpp
parent1e8dbc1ff44b65c0fbe4e83fa5a22641c9ab9f47 (diff)
SkypeWeb: added auth requests management
git-svn-id: http://svn.miranda-ng.org/main/trunk@12456 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_contacts.cpp')
-rw-r--r--protocols/SkypeWeb/src/skype_contacts.cpp57
1 files changed, 56 insertions, 1 deletions
diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp
index e0b8fc1722..08b0a6f063 100644
--- a/protocols/SkypeWeb/src/skype_contacts.cpp
+++ b/protocols/SkypeWeb/src/skype_contacts.cpp
@@ -83,6 +83,60 @@ MCONTACT CSkypeProto::AddContact(const char *skypename, bool isTemporary)
return hContact;
}
+void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response)
+{
+ if (response == NULL)
+ return;
+
+ 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)
+ break;
+
+ node = json_get(item, "sender");
+ ptrA skypename(mir_t2a(ptrT(json_as_string(node))));
+
+ JSONNODE *node = json_get(root, "greeting");
+ CMStringA reason = ptrA(mir_t2a(ptrT(json_as_string(node))));
+ if (reason != "null")
+ reason.Empty();
+
+ MCONTACT hContact = AddContact(skypename);
+ if (hContact)
+ {
+ delSetting(hContact, "Auth");
+
+ PROTORECVEVENT pre = { 0 };
+ pre.flags = PREF_UTF;
+ pre.timestamp = time(NULL);
+ pre.lParam = (DWORD)(sizeof(DWORD) * 2 + mir_strlen(skypename) + reason.GetLength() + 5);
+
+ /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), id(ASCIIZ), reason(ASCIIZ)*/
+ PBYTE pBlob, pCurBlob;
+ pCurBlob = pBlob = (PBYTE)mir_calloc(pre.lParam);
+
+ *((PDWORD)pCurBlob) = 0;
+ pCurBlob += sizeof(DWORD);
+ *((PDWORD)pCurBlob) = (DWORD)hContact;
+ pCurBlob += sizeof(DWORD);
+ pCurBlob += 3;
+ mir_strcpy((char*)pCurBlob, skypename);
+ pCurBlob += mir_strlen(skypename) + 1;
+ mir_strcpy((char*)pCurBlob, reason);
+ pre.szMessage = (char*)pBlob;
+
+ ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre);
+ }
+ }
+ json_delete(items);
+}
+
//[{"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)
{
@@ -162,9 +216,9 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response)
}
json_delete(items);
+ ptrA token(getStringA("TokenSecret"));
if (skypenames.getCount() > 0)
{
- ptrA token(getStringA("TokenSecret"));
PushRequest(new GetContactsInfoRequest(token, skypenames), &CSkypeProto::LoadContactsInfo);
for (size_t i = 0; i < skypenames.getCount(); i++)
@@ -173,6 +227,7 @@ void CSkypeProto::LoadContactList(const NETLIBHTTPREQUEST *response)
}
skypenames.destroy();
}
+ PushRequest(new GetContactsAuthRequest(token), &CSkypeProto::LoadContactsAuth);
}
INT_PTR CSkypeProto::OnRequestAuth(WPARAM hContact, LPARAM lParam)