From e44efd52b62e375eb76bec62b71e83d6b8b23972 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 23 Oct 2022 17:55:10 +0300 Subject: =?UTF-8?q?fixes=20#3227=20(ICQ:=20=D0=BD=D0=B5=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BF=D0=BE=D0=BB=D1=83?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=D0=BD=D1=84=D1=8B=20?= =?UTF-8?q?=D0=BE=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B0=D0=BA=D1=82=D0=B5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/ICQ-WIM/src/poll.cpp | 2 -- protocols/ICQ-WIM/src/proto.h | 4 +--- protocols/ICQ-WIM/src/server.cpp | 39 ++++++--------------------------------- protocols/ICQ-WIM/src/utils.cpp | 2 +- protocols/ICQ-WIM/src/version.h | 2 +- 5 files changed, 9 insertions(+), 40 deletions(-) diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index db15c5be6f..d7ca7298ad 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -72,8 +72,6 @@ void CIcqProto::ProcessBuddyList(const JSONNode &ev) for (auto &it : m_arCache) if (!it->m_bInList && !getBool(it->m_hContact, "IcqDeleted")) Contact::RemoveFromList(it->m_hContact); - - RetrieveUserInfo(); } void CIcqProto::ProcessDiff(const JSONNode &ev) diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index fdb8e39307..b909a0d74a 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -264,7 +264,7 @@ class CIcqProto : public PROTO void MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup, const wchar_t *pwszNewGroup); bool RetrievePassword(); void RetrieveUserHistory(MCONTACT, __int64 startMsgId, bool bCreateRead); - void RetrieveUserInfo(MCONTACT = INVALID_CONTACT_ID); + void RetrieveUserInfo(MCONTACT hContact); void SendMrimLogin(NETLIBHTTPREQUEST *pReply); void SetServerStatus(int iNewStatus); void ShutdownSession(void); @@ -286,8 +286,6 @@ class CIcqProto : public PROTO LIST m_arMarkReadQueue; void SendMarkRead(); - 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 9795da2c3c..167aabfee9 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -605,35 +605,10 @@ LBL_Error: 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); + auto *pReq = new AsyncRapiRequest(this, "getUserInfo", &CIcqProto::OnGetUserInfo); + pReq->params << WCHAR_PARAM("sn", GetUserId(hContact)); pReq->hContact = hContact; - pReq << AIMSID(this) << INT_PARAM("mdir", 1) << INT_PARAM("capabilities", 1); - return pReq; + Push(pReq); } void CIcqProto::RetrieveUserHistory(MCONTACT hContact, __int64 startMsgId, bool bCreateRead) @@ -1077,15 +1052,13 @@ void CIcqProto::OnGetUserHistory(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pR void CIcqProto::OnGetUserInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) { - JsonReply root(pReply); - if (root.error() != 200) { + RobustReply root(pReply); + if (root.error() != 20000) { ProtoBroadcastAck(pReq->hContact, ACKTYPE_GETINFO, ACKRESULT_FAILED, nullptr); return; } - auto &data = root.data(); - for (auto &it : data["users"]) - ParseBuddyInfo(it, pReq->hContact); + ParseBuddyInfo(root.results(), pReq->hContact, true); ProtoBroadcastAck(pReq->hContact, ACKTYPE_GETINFO, ACKRESULT_SUCCESS, nullptr); } diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index 98ccc45dfe..4fa65d0302 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -278,7 +278,7 @@ bool IsChat(const CMStringW &aimid) bool IsValidType(const JSONNode &n) { auto type = n["userType"].as_string(); - return type == "icq" || type == "aim" || type == "interop"; + return type == "icq" || type == "aim" || type == "interop" || type == ""; } int CIcqProto::StatusFromPresence(const JSONNode &presence, MCONTACT hContact) diff --git a/protocols/ICQ-WIM/src/version.h b/protocols/ICQ-WIM/src/version.h index bdad28cfc2..d66fea62b5 100644 --- a/protocols/ICQ-WIM/src/version.h +++ b/protocols/ICQ-WIM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 96 #define __RELEASE_NUM 2 -#define __BUILD_NUM 2 +#define __BUILD_NUM 3 #include -- cgit v1.2.3