summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorSergey Bolhovskoy <elzorfox@ya.ru>2014-11-27 04:44:50 +0000
committerSergey Bolhovskoy <elzorfox@ya.ru>2014-11-27 04:44:50 +0000
commit605fd3596785efcfbb05b1d8d25764c5bf13852b (patch)
treeac82a2a336015043f5f0c5f621cffa8113146412 /protocols
parentf5c584f3073bbe65bbf4794e555aabd651476612 (diff)
VKontakte:
rework RetrieveUsersInfo (significant reduction of network traffic) version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@11117 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/VKontakte/src/version.h2
-rw-r--r--protocols/VKontakte/src/vk_thread.cpp12
2 files changed, 8 insertions, 6 deletions
diff --git a/protocols/VKontakte/src/version.h b/protocols/VKontakte/src/version.h
index e15680d850..d2776a5e3a 100644
--- a/protocols/VKontakte/src/version.h
+++ b/protocols/VKontakte/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 0
-#define __BUILD_NUM 29
+#define __BUILD_NUM 30
#include <stdver.h>
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp
index 30a9c4a50e..48e475e135 100644
--- a/protocols/VKontakte/src/vk_thread.cpp
+++ b/protocols/VKontakte/src/vk_thread.cpp
@@ -401,12 +401,14 @@ void CVkProto::RetrieveUsersInfo(bool flag)
userIDs.AppendFormat(L"%i", userID);
}
- CMString codeformat("var userIDs=\"%s\";"
- "return{\"users\":API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"})");
+ CMString codeformat("var userIDs=\"%s\";");
if (flag)
- codeformat += CMString(",\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
+ codeformat += CMString("var US=API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"});"
+ "var res=[];var index=US.length;while(index >0){index=index-1;if(US[index].online==1){res.unshift(US[index]);};};"
+ "return{\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
else
- codeformat += CMString("};");
+ codeformat += CMString("var res=API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"});"
+ "return{\"users\":res};");
code.AppendFormat(codeformat, userIDs.GetBuffer(), CMString(flag ? "online,status" : fieldsName).GetBuffer());
Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo)
@@ -429,7 +431,7 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe
JSONNODE *pUsers = json_get(pResponse, "users");
if (pUsers == NULL)
return;
-
+
for (size_t i = 0; SetContactInfo(json_at(pUsers, i)) != -1; i++);
JSONNODE *pRequests = json_get(pResponse, "requests");