diff options
author | George Hazan <ghazan@miranda.im> | 2018-12-24 20:10:10 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-12-24 20:10:10 +0300 |
commit | 47e705ac05b2572a687741af3a4141e560caf5d6 (patch) | |
tree | c50c808070bc22126be104ada6bb35aab16e41d8 | |
parent | 7ed195f3bfe7512511abe502b4eeb447281ac3c5 (diff) |
filtration of contacts that are not in our buddy list
-rw-r--r-- | protocols/Icq10/src/proto.h | 3 | ||||
-rw-r--r-- | protocols/Icq10/src/server.cpp | 17 | ||||
-rw-r--r-- | protocols/Icq10/src/utils.cpp | 5 |
3 files changed, 17 insertions, 8 deletions
diff --git a/protocols/Icq10/src/proto.h b/protocols/Icq10/src/proto.h index 41b816067b..82e65dcfcc 100644 --- a/protocols/Icq10/src/proto.h +++ b/protocols/Icq10/src/proto.h @@ -42,6 +42,7 @@ struct IcqCacheItem DWORD m_uin; MCONTACT m_hContact; + bool m_bInList = false; }; class CIcqProto : public PROTO<CIcqProto> @@ -86,7 +87,7 @@ class CIcqProto : public PROTO<CIcqProto> OBJLIST<IcqCacheItem> m_arCache; void InitContactCache(void); - MCONTACT FindContactByUIN(DWORD); + IcqCacheItem* FindContactByUIN(DWORD); void GetAvatarFileName(MCONTACT hContact, wchar_t *pszDest, size_t cbLen); diff --git a/protocols/Icq10/src/server.cpp b/protocols/Icq10/src/server.cpp index bde7ef3319..beb829fef7 100644 --- a/protocols/Icq10/src/server.cpp +++ b/protocols/Icq10/src/server.cpp @@ -217,17 +217,22 @@ void CIcqProto::ProcessBuddyList(const JSONNode &ev) for (auto &buddy : it["buddies"]) { DWORD dwUin = _wtol(buddy["aimId"].as_mstring()); - MCONTACT hContact = FindContactByUIN(dwUin); - if (hContact == 0) { - hContact = db_add_contact(); + + auto *pCache = FindContactByUIN(dwUin); + if (pCache == nullptr) { + MCONTACT hContact = db_add_contact(); Proto_AddToContact(hContact, m_szModuleName); setDword(hContact, "UIN", dwUin); + pCache = new IcqCacheItem(dwUin, hContact); { mir_cslock l(m_csCache); - m_arCache.insert(new IcqCacheItem(dwUin, hContact)); + m_arCache.insert(pCache); } } + MCONTACT hContact = pCache->m_hContact; + pCache->m_bInList = true; + CMStringW wszNick(buddy["friendly"].as_mstring()); if (!wszNick.IsEmpty()) setWString(hContact, "Nick", wszNick); @@ -258,6 +263,10 @@ void CIcqProto::ProcessBuddyList(const JSONNode &ev) db_set_ws(hContact, "CList", "Group", szGroup); } } + + for (auto &it : m_arCache) + if (!it->m_bInList) + db_set_b(it->m_hContact, "CList", "NotOnList", 1); } void CIcqProto::ProcessEvent(const JSONNode &ev) diff --git a/protocols/Icq10/src/utils.cpp b/protocols/Icq10/src/utils.cpp index d3c01b8dcb..12ba8eaacf 100644 --- a/protocols/Icq10/src/utils.cpp +++ b/protocols/Icq10/src/utils.cpp @@ -27,11 +27,10 @@ void CIcqProto::InitContactCache() m_arCache.insert(new IcqCacheItem(getDword(it, "UIN"), it)); } -MCONTACT CIcqProto::FindContactByUIN(DWORD dwUin) +IcqCacheItem* CIcqProto::FindContactByUIN(DWORD dwUin) { mir_cslock l(m_csCache); - auto *p = m_arCache.find((IcqCacheItem*)&dwUin); - return (p) ? p->m_hContact : 0; + return m_arCache.find((IcqCacheItem*)&dwUin); } ///////////////////////////////////////////////////////////////////////////////////////// |