From c98ff02a2e28c4f720bacc642d674bd90762ac34 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 10 Feb 2019 19:01:23 +0300 Subject: ICQ-WIM: fix for retrieving info in large contact lists --- protocols/ICQ-WIM/src/proto.h | 2 ++ protocols/ICQ-WIM/src/server.cpp | 33 ++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) (limited to 'protocols') diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 564865f7db..dd241ad8fa 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -169,6 +169,8 @@ class CIcqProto : public PROTO LIST arMarkReadQueue; static void CALLBACK MarkReadTimerProc(HWND hwnd, UINT, UINT_PTR id, DWORD); + AsyncHttpRequest* UserInfoRequest(MCONTACT); + __int64 getId(MCONTACT hContact, const char *szSetting); void setId(MCONTACT hContact, const char *szSetting, __int64 iValue); diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index 1144df6b4b..920e826f78 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -422,18 +422,37 @@ bool CIcqProto::RefreshRobustToken() } void CIcqProto::RetrieveUserInfo(MCONTACT hContact) +{ + auto *pReq = UserInfoRequest(hContact); + + if (hContact == INVALID_CONTACT_ID) { + int i = 0; + for (auto &it : m_arCache) { + if (i == 0) + pReq = UserInfoRequest(hContact); + + pReq << WCHAR_PARAM("t", GetUserId(it->m_hContact)); + if (i == 100) { + i = 0; + Push(pReq); + + pReq = UserInfoRequest(hContact); + } + else i++; + } + } + else pReq << WCHAR_PARAM("t", GetUserId(hContact)); + + Push(pReq); +} + +AsyncHttpRequest* CIcqProto::UserInfoRequest(MCONTACT hContact) { auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/presence/get", &CIcqProto::OnGetUserInfo); pReq->flags |= NLHRF_NODUMPSEND; pReq->hContact = hContact; pReq << CHAR_PARAM("f", "json") << CHAR_PARAM("aimsid", m_aimsid) << INT_PARAM("mdir", 1) << INT_PARAM("capabilities", 1); - if (hContact == INVALID_CONTACT_ID) - for (auto &it : m_arCache) - pReq << WCHAR_PARAM("t", GetUserId(it->m_hContact)); - else - pReq << WCHAR_PARAM("t", GetUserId(hContact)); - - Push(pReq); + return pReq; } void CIcqProto::RetrieveUserHistory(MCONTACT hContact, __int64 startMsgId, __int64 endMsgId) -- cgit v1.2.3