summaryrefslogtreecommitdiff
path: root/protocols/Icq10/src/server.cpp
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-12-24 19:48:28 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-12-24 19:48:28 +0300
commit7f5b936071e3a02fee7f7156157f2d0f776bb395 (patch)
tree39ea508e39ebced43095885a67a747eba2eff8a3 /protocols/Icq10/src/server.cpp
parent53aaf4d4c34318d5953ca55d879e7153a7a30098 (diff)
Icq10: more avatar processing services
Diffstat (limited to 'protocols/Icq10/src/server.cpp')
-rw-r--r--protocols/Icq10/src/server.cpp106
1 files changed, 65 insertions, 41 deletions
diff --git a/protocols/Icq10/src/server.cpp b/protocols/Icq10/src/server.cpp
index b95ab64b14..bde7ef3319 100644
--- a/protocols/Icq10/src/server.cpp
+++ b/protocols/Icq10/src/server.cpp
@@ -209,60 +209,84 @@ void CIcqProto::OnReceiveAvatar(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pRe
/////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::ProcessEvent(const JSONNode &ev)
+void CIcqProto::ProcessBuddyList(const JSONNode &ev)
{
- CMStringW szType = ev["type"].as_mstring();
- if (szType == L"buddylist") {
- for (auto &it : ev["eventData"]["groups"]) {
- CMStringW szGroup = it["name"].as_mstring();
- Clist_GroupCreate(0, szGroup);
-
- for (auto &buddy : it["buddies"]) {
- DWORD dwUin = _wtol(buddy["aimId"].as_mstring());
- MCONTACT hContact = FindContactByUIN(dwUin);
- if (hContact == 0) {
- hContact = db_add_contact();
- Proto_AddToContact(hContact, m_szModuleName);
- setDword(hContact, "UIN", dwUin);
- {
- mir_cslock l(m_csCache);
- m_arCache.insert(new IcqCacheItem(dwUin, hContact));
- }
+ for (auto &it : ev["groups"]) {
+ CMStringW szGroup = it["name"].as_mstring();
+ Clist_GroupCreate(0, szGroup);
+
+ for (auto &buddy : it["buddies"]) {
+ DWORD dwUin = _wtol(buddy["aimId"].as_mstring());
+ MCONTACT hContact = FindContactByUIN(dwUin);
+ if (hContact == 0) {
+ hContact = db_add_contact();
+ Proto_AddToContact(hContact, m_szModuleName);
+ setDword(hContact, "UIN", dwUin);
+ {
+ mir_cslock l(m_csCache);
+ m_arCache.insert(new IcqCacheItem(dwUin, hContact));
}
+ }
- CMStringW wszNick(buddy["friendly"].as_mstring());
- if (!wszNick.IsEmpty())
- setWString(hContact, "Nick", wszNick);
-
- setDword(hContact, "Status", StatusFromString(buddy["state"].as_mstring()));
+ CMStringW wszNick(buddy["friendly"].as_mstring());
+ if (!wszNick.IsEmpty())
+ setWString(hContact, "Nick", wszNick);
- int lastLogin = buddy["lastseen"].as_int();
- if (lastLogin)
- setDword(hContact, "LoginTS", lastLogin);
+ setDword(hContact, "Status", StatusFromString(buddy["state"].as_mstring()));
- CMStringW wszStatus(buddy["statusMsg"].as_mstring());
- if (wszStatus.IsEmpty())
- db_unset(hContact, "CList", "StatusMsg");
- else
- db_set_ws(hContact, "CList", "StatusMsg", wszStatus);
+ int lastLogin = buddy["lastseen"].as_int();
+ if (lastLogin)
+ setDword(hContact, "LoginTS", lastLogin);
- CMStringW wszIconId(buddy["iconId"].as_mstring());
- CMStringW oldIconID(getMStringW(hContact, "IconId"));
- if (wszIconId != oldIconID) {
- setWString(hContact, "IconId", wszIconId);
+ CMStringW wszStatus(buddy["statusMsg"].as_mstring());
+ if (wszStatus.IsEmpty())
+ db_unset(hContact, "CList", "StatusMsg");
+ else
+ db_set_ws(hContact, "CList", "StatusMsg", wszStatus);
- CMStringA szUrl(buddy["buddyIcon"].as_mstring());
- auto *p = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, szUrl, &CIcqProto::OnReceiveAvatar);
- p->pUserInfo = (void*)hContact;
- Push(p);
- }
+ CMStringW wszIconId(buddy["iconId"].as_mstring());
+ CMStringW oldIconID(getMStringW(hContact, "IconId"));
+ if (wszIconId != oldIconID) {
+ setWString(hContact, "IconId", wszIconId);
- db_set_ws(hContact, "CList", "Group", szGroup);
+ CMStringA szUrl(buddy["buddyIcon"].as_mstring());
+ auto *p = new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, szUrl, &CIcqProto::OnReceiveAvatar);
+ p->pUserInfo = (void*)hContact;
+ Push(p);
}
+
+ db_set_ws(hContact, "CList", "Group", szGroup);
}
}
}
+void CIcqProto::ProcessEvent(const JSONNode &ev)
+{
+ const JSONNode &pData = ev["eventData"];
+ CMStringW szType = ev["type"].as_mstring();
+ if (szType == L"buddylist")
+ ProcessBuddyList(pData);
+ else if (szType == L"myInfo")
+ ProcessMyInfo(pData);
+
+}
+
+void CIcqProto::ProcessMyInfo(const JSONNode &ev)
+{
+ CMStringW wszNick(ev["friendly"].as_mstring());
+ if (!wszNick.IsEmpty())
+ setWString("Nick", wszNick);
+
+ CMStringW wszIconId(ev["iconId"].as_mstring());
+ CMStringW oldIconID(getMStringW("IconId"));
+ if (wszIconId != oldIconID) {
+ setWString("IconId", wszIconId);
+
+ CMStringA szUrl(ev["buddyIcon"].as_mstring());
+ Push(new AsyncHttpRequest(CONN_MAIN, REQUEST_GET, szUrl, &CIcqProto::OnReceiveAvatar));
+ }
+}
+
void CIcqProto::OnFetchEvents(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest*)
{
JsonReply root(pReply);