summaryrefslogtreecommitdiff
path: root/protocols/ICQ-WIM/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2019-12-15 21:08:51 +0300
committerGeorge Hazan <ghazan@miranda.im>2019-12-15 21:08:51 +0300
commitdf0a0e35d4862a8a1e35238452d61a45b7687965 (patch)
tree7ea95e9c3102f39441979497730cab89fca28533 /protocols/ICQ-WIM/src
parent077ffccc634e59303ab1cd4e239c6d0211340513 (diff)
ICQ-WIM: added error code detection during addBuddy (we don't allow to add deleted contacts)
Diffstat (limited to 'protocols/ICQ-WIM/src')
-rw-r--r--protocols/ICQ-WIM/src/server.cpp25
1 files changed, 23 insertions, 2 deletions
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp
index 44cfa13278..6e3f28caeb 100644
--- a/protocols/ICQ-WIM/src/server.cpp
+++ b/protocols/ICQ-WIM/src/server.cpp
@@ -599,8 +599,29 @@ void CIcqProto::OnAddBuddy(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq)
{
JsonReply root(pReply);
if (root.error() == 200) {
- RetrieveUserInfo(pReq->hContact);
- Contact_PutOnList(pReq->hContact);
+ CMStringW wszId = getMStringW(pReq->hContact, DB_KEY_ID);
+ for (auto &it : root.data()["results"]) {
+ if (it["buddy"].as_mstring() != wszId)
+ continue;
+
+ int iResultCode = it["resultCode"].as_int();
+ if (iResultCode == 0) {
+ RetrieveUserInfo(pReq->hContact);
+ Contact_PutOnList(pReq->hContact);
+ }
+ else {
+ debugLogA("Contact %d failed to add: error %d", pReq->hContact, iResultCode);
+
+ POPUPDATAW Popup = {};
+ Popup.lchIcon = IcoLib_GetIconByHandle(Skin_GetIconHandle(SKINICON_ERROR));
+ wcsncpy_s(Popup.lpwzText, TranslateT("Buddy addition failed"), _TRUNCATE);
+ wcsncpy_s(Popup.lpwzContactName, Clist_GetContactDisplayName(pReq->hContact), _TRUNCATE);
+ Popup.iSeconds = 20;
+ PUAddPopupW(&Popup);
+
+ Contact_RemoveFromList(pReq->hContact);
+ }
+ }
}
}