diff options
author | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-10-09 13:36:44 +0000 |
---|---|---|
committer | Sergey Bolhovskoy <elzorfox@ya.ru> | 2015-10-09 13:36:44 +0000 |
commit | 7e1b4c5b01bce592238358e8cb0f8af856d44e40 (patch) | |
tree | 06cfab544844c64424583b964ee66b9022e3dcb2 /protocols/VKontakte/src | |
parent | f122850c8cbfca22d8d86cba68ba8abda55a36a9 (diff) |
VKontakte: fix(?) user status processing (and again)
git-svn-id: http://svn.miranda-ng.org/main/trunk@15524 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/VKontakte/src')
-rw-r--r-- | protocols/VKontakte/src/vk_proto.h | 2 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h index 58d509bc4d..cbf172d314 100644 --- a/protocols/VKontakte/src/vk_proto.h +++ b/protocols/VKontakte/src/vk_proto.h @@ -224,7 +224,7 @@ struct CVkProto : public PROTO<CVkProto> void RetrieveMyInfo(void);
void OnReceiveMyInfo(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void RetrieveUserInfo(LONG userId);
- void RetrieveUsersInfo(bool flag = false);
+ void RetrieveUsersInfo(bool flag = false, bool bRepeat = false);
void OnReceiveUserInfo(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
void RetrieveFriends();
void OnReceiveFriends(NETLIBHTTPREQUEST*, AsyncHttpRequest*);
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 15dc97a9ba..7a1e6e9a54 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -380,14 +380,14 @@ void CVkProto::RetrieveUserInfo(LONG userID) if (userID == VK_FEED_USER || !IsOnline())
return;
- CMString code(FORMAT, _T("var userIDs=\"%i\";var res=API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"});return{\"freeoffline\":0,\"users\":res};"),
+ CMString code(FORMAT, _T("var userIDs=\"%i\";var res=API.users.get({\"user_ids\":userIDs,\"fields\":\"%s\",\"name_case\":\"nom\"});return{\"freeoffline\":0,\"norepeat\":1,\"usercount\":res.length,\"users\":res};"),
userID, CMString(fieldsName));
Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo)
<< TCHAR_PARAM("code", code)
<< VER_API);
}
-void CVkProto::RetrieveUsersInfo(bool flag)
+void CVkProto::RetrieveUsersInfo(bool bFreeOffline, bool bRepeat)
{
debugLogA("CVkProto::RetrieveUsersInfo");
if (!IsOnline())
@@ -408,17 +408,17 @@ void CVkProto::RetrieveUsersInfo(bool flag) if (m_bNeedSendOnline)
codeformat += _T("API.account.setOnline();");
- if (flag && !m_bLoadFullCList)
+ if (bFreeOffline && !m_bLoadFullCList)
codeformat += CMString("var US=[];var res=[];var t=10;while(t>0){"
"US=API.users.get({\"user_ids\":userIDs,\"fields\":_fields,\"name_case\":\"nom\"});"
"var index=US.length;while(index>0){"
"index=index-1;if(US[index].online!=0){res.push(US[index]);};};"
"t=t-1;if(res.length>0)t=0;};"
- "return{\"freeoffline\":1,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
+ "return{\"freeoffline\":1,\"norepeat\":%d,\"usercount\":res.length,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
else
codeformat += CMString("var res=API.users.get({\"user_ids\":userIDs,\"fields\":_fields,\"name_case\":\"nom\"});"
- "return{\"freeoffline\":0,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
- code.AppendFormat(codeformat, userIDs, CMString(flag ? "online,status" : fieldsName));
+ "return{\"freeoffline\":0,\"norepeat\":%d,\"usercount\":res.length,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
+ code.AppendFormat(codeformat, userIDs, CMString(bFreeOffline ? "online,status" : fieldsName), (int)bRepeat);
Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo)
<< TCHAR_PARAM("code", code)
@@ -441,6 +441,11 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe if (!jnUsers)
return;
+ if (!jnResponse["norepeat"].as_bool() && jnResponse["usercount"].as_int() == 0) {
+ RetrieveUsersInfo(true, true);
+ return;
+ }
+
MCONTACT hContact;
LIST<void> arContacts(10, PtrKeySortT);
|