diff options
author | George Hazan <ghazan@miranda.im> | 2019-05-28 21:18:20 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-05-28 21:18:20 +0300 |
commit | 2610fee647614e9e13daef898b99315c26fa987c (patch) | |
tree | 0ab57057cac9f109a4946385c95f6323a4feba32 /protocols | |
parent | 4688195c4327ca3749230371b3634bfc74203f3d (diff) |
ICQ-WIM: fix for a problem with embedded groups
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/ICQ-WIM/src/http.cpp | 13 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/http.h | 11 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/poll.cpp | 2 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 6 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 2 |
5 files changed, 30 insertions, 4 deletions
diff --git a/protocols/ICQ-WIM/src/http.cpp b/protocols/ICQ-WIM/src/http.cpp index 693f320ca1..87819b1849 100644 --- a/protocols/ICQ-WIM/src/http.cpp +++ b/protocols/ICQ-WIM/src/http.cpp @@ -249,6 +249,19 @@ AsyncHttpRequest* operator<<(AsyncHttpRequest *pReq, const AIMSID ¶m) ///////////////////////////////////////////////////////////////////////////////////////// +MHttpRequest* operator<<(MHttpRequest *pReq, const GROUP_PARAM ¶m) +{ + if (param.wszValue) { + CMStringW tmp(param.wszValue); + tmp.Replace(L"\\", L">"); + tmp.Replace(L"/", L">"); + pReq << WCHAR_PARAM(param.szName, tmp); + } + return pReq; +} + +///////////////////////////////////////////////////////////////////////////////////////// + JsonReply::JsonReply(NETLIBHTTPREQUEST *pReply) { if (pReply == nullptr) { diff --git a/protocols/ICQ-WIM/src/http.h b/protocols/ICQ-WIM/src/http.h index 296abb2045..9f9270486c 100644 --- a/protocols/ICQ-WIM/src/http.h +++ b/protocols/ICQ-WIM/src/http.h @@ -19,6 +19,17 @@ struct AsyncHttpRequest : public MTHttpRequest<CIcqProto> ///////////////////////////////////////////////////////////////////////////////////////// +struct GROUP_PARAM : public WCHAR_PARAM +{ + __forceinline GROUP_PARAM(const char *p1, const wchar_t *p2) : + WCHAR_PARAM(p1, p2) + {} +}; + +MHttpRequest* operator<<(MHttpRequest *pReq, const GROUP_PARAM ¶m); + +///////////////////////////////////////////////////////////////////////////////////////// + class JsonReply { JSONNode *m_root = nullptr; diff --git a/protocols/ICQ-WIM/src/poll.cpp b/protocols/ICQ-WIM/src/poll.cpp index 01bc53200d..0f53a249fd 100644 --- a/protocols/ICQ-WIM/src/poll.cpp +++ b/protocols/ICQ-WIM/src/poll.cpp @@ -27,6 +27,7 @@ void CIcqProto::ProcessBuddyList(const JSONNode &ev) for (auto &it : ev["groups"]) { CMStringW szGroup = it["name"].as_mstring(); + szGroup.Replace(L">", L"\\"); bool bCreated = false; for (auto &buddy : it["buddies"]) { @@ -70,6 +71,7 @@ void CIcqProto::ProcessDiff(const JSONNode &ev) for (auto &it : block["data"]) { CMStringW szGroup = it["name"].as_mstring(); + szGroup.Replace(L">", L"\\"); bool bCreated = false; for (auto &buddy : it["buddies"]) { diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index 87b5f337f3..0ec2d4dc7e 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -249,15 +249,15 @@ int CIcqProto::OnGroupChange(WPARAM hContact, LPARAM lParam) auto *pReq = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/") << AIMSID(this); if (pParam->pszOldName == nullptr) { pReq->m_szUrl += "addGroup"; - pReq << WCHAR_PARAM("group", pParam->pszNewName); + pReq << GROUP_PARAM("group", pParam->pszNewName); } else if (pParam->pszNewName == nullptr) { pReq->m_szUrl += "removeGroup"; - pReq << WCHAR_PARAM("group", pParam->pszOldName); + pReq << GROUP_PARAM("group", pParam->pszOldName); } else { pReq->m_szUrl += "renameGroup"; - pReq << WCHAR_PARAM("oldGroup", pParam->pszOldName) << WCHAR_PARAM("newGroup", pParam->pszNewName); + pReq << GROUP_PARAM("oldGroup", pParam->pszOldName) << GROUP_PARAM("newGroup", pParam->pszNewName); } Push(pReq); } diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index a923fb4dec..38801c8a83 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -155,7 +155,7 @@ void CIcqProto::ConnectionFailed(int iReason, int iErrorCode) void CIcqProto::MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup, const wchar_t *pwszNewGroup) { Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, ICQ_API_SERVER "/buddylist/moveBuddy") - << AIMSID(this) << WCHAR_PARAM("buddy", GetUserId(hContact)) << WCHAR_PARAM("group", pwszGroup) << WCHAR_PARAM("newGroup", pwszNewGroup)); + << AIMSID(this) << WCHAR_PARAM("buddy", GetUserId(hContact)) << GROUP_PARAM("group", pwszGroup) << GROUP_PARAM("newGroup", pwszNewGroup)); } ///////////////////////////////////////////////////////////////////////////////////////// |