From 605fd3596785efcfbb05b1d8d25764c5bf13852b Mon Sep 17 00:00:00 2001 From: Sergey Bolhovskoy Date: Thu, 27 Nov 2014 04:44:50 +0000 Subject: 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 --- protocols/VKontakte/src/version.h | 2 +- protocols/VKontakte/src/vk_thread.cpp | 12 +++++++----- 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 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"); -- cgit v1.2.3