diff options
Diffstat (limited to 'protocols/VKontakte/src/vk_thread.cpp')
-rw-r--r-- | protocols/VKontakte/src/vk_thread.cpp | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/protocols/VKontakte/src/vk_thread.cpp b/protocols/VKontakte/src/vk_thread.cpp index 9976529a81..d0266a3930 100644 --- a/protocols/VKontakte/src/vk_thread.cpp +++ b/protocols/VKontakte/src/vk_thread.cpp @@ -380,7 +380,7 @@ 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,\"usercount\":res.length,\"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,\"users\":res};"),
userID, CMString(fieldsName));
Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo)
<< TCHAR_PARAM("code", code)
@@ -409,12 +409,15 @@ void CVkProto::RetrieveUsersInfo(bool flag) codeformat += _T("API.account.setOnline();");
if (flag && !m_bLoadFullCList)
- codeformat += CMString("var US=API.users.get({\"user_ids\":userIDs,\"fields\":_fields,\"name_case\":\"nom\"});"
- "var res=[];var index=US.length;var _count=index;while(index>0){index=index-1;if(US[index].online!=0){res.unshift(US[index]);};};"
- "return{\"freeoffline\":1,\"usercount\":_count,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
+ codeformat += CMString("var US=[];var res=[];var t=3;while(t>0){"
+ "US=API.users.get({\"user_ids\":userIDs,\"fields\":_fields,\"name_case\":\"nom\"});"
+ "var index=US.length;var _count=index;"
+ "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})};");
else
- codeformat += CMString("var res=API.users.get({\"user_ids\":userIDs,\"fields\":_fields,\"name_case\":\"nom\"});var _count=res.length;"
- "return{\"freeoffline\":0,\"usercount\":_count,\"users\":res,\"requests\":API.friends.getRequests({\"extended\":0,\"need_mutual\":0,\"out\":0})};");
+ 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));
Push(new AsyncHttpRequest(this, REQUEST_POST, "/method/execute.json", true, &CVkProto::OnReceiveUserInfo)
@@ -439,40 +442,36 @@ void CVkProto::OnReceiveUserInfo(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pRe return;
MCONTACT hContact;
+ LIST<void> arContacts(10, PtrKeySortT);
+
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ if (!isChatRoom(hContact))
+ arContacts.insert((HANDLE)hContact);
- debugLogA("CVkProto::OnReceiveUserInfo usercount = %d", jnResponse["usercount"].as_int());
- if (jnResponse["usercount"].as_int() > 0) {
- LIST<void> arContacts(10, PtrKeySortT);
- for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
- if (!isChatRoom(hContact))
- arContacts.insert((HANDLE)hContact);
-
- for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
- hContact = SetContactInfo((*it));
- if (hContact)
- arContacts.remove((HANDLE)hContact);
- }
+ for (auto it = jnUsers.begin(); it != jnUsers.end(); ++it) {
+ hContact = SetContactInfo((*it));
+ if (hContact)
+ arContacts.remove((HANDLE)hContact);
+ }
- if (jnResponse["freeoffline"].as_bool())
- for (int i = 0; i < arContacts.getCount(); i++) {
- hContact = (UINT_PTR)arContacts[i];
- LONG userID = getDword(hContact, "ID", -1);
- if (userID == m_myUserId || userID == VK_FEED_USER)
- continue;
+ if (jnResponse["freeoffline"].as_bool())
+ for (int i = 0; i < arContacts.getCount(); i++) {
+ hContact = (UINT_PTR)arContacts[i];
+ LONG userID = getDword(hContact, "ID", -1);
+ if (userID == m_myUserId || userID == VK_FEED_USER)
+ continue;
- int iContactStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
+ int iContactStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE);
- if ((iContactStatus == ID_STATUS_ONLINE)
- || (iContactStatus == ID_STATUS_INVISIBLE && time(NULL) - getDword(hContact, "InvisibleTS", 0) >= m_iInvisibleInterval * 60LL)) {
- setWord(hContact, "Status", ID_STATUS_OFFLINE);
- SetMirVer(hContact, -1);
- db_unset(hContact, m_szModuleName, "ListeningTo");
- }
+ if ((iContactStatus == ID_STATUS_ONLINE)
+ || (iContactStatus == ID_STATUS_INVISIBLE && time(NULL) - getDword(hContact, "InvisibleTS", 0) >= m_iInvisibleInterval * 60LL)) {
+ setWord(hContact, "Status", ID_STATUS_OFFLINE);
+ SetMirVer(hContact, -1);
+ db_unset(hContact, m_szModuleName, "ListeningTo");
}
+ }
- arContacts.destroy();
- }
-
+ arContacts.destroy();
AddFeedSpecialUser();
const JSONNode &jnRequests = jnResponse["requests"];
|