summaryrefslogtreecommitdiff
path: root/protocols/Icq10
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2018-12-28 15:59:56 +0300
committerGeorge Hazan <ghazan@miranda.im>2018-12-28 15:59:56 +0300
commit30ed9ea8b76aedb3c3c1ad253a3d45be9b4b638f (patch)
tree5c714a359d9dfc72dfef46e34b36a1b203828b0c /protocols/Icq10
parentbf902e3aa18387158d0593ae2ae57eaf0f35b8be (diff)
fixes #1674 (Miranda doesn't receive messages from unknown contacts)
Diffstat (limited to 'protocols/Icq10')
-rw-r--r--protocols/Icq10/src/proto.cpp12
-rw-r--r--protocols/Icq10/src/proto.h1
-rw-r--r--protocols/Icq10/src/server.cpp22
-rw-r--r--protocols/Icq10/src/utils.cpp21
4 files changed, 27 insertions, 29 deletions
diff --git a/protocols/Icq10/src/proto.cpp b/protocols/Icq10/src/proto.cpp
index c039dd4585..05f9b5ce4f 100644
--- a/protocols/Icq10/src/proto.cpp
+++ b/protocols/Icq10/src/proto.cpp
@@ -98,17 +98,8 @@ MCONTACT CIcqProto::AddToList(int flags, PROTOSEARCHRESULT *psr)
return 0;
DWORD dwUin = _wtol(psr->id.w);
- if (auto *p = FindContactByUIN(dwUin))
- return p->m_hContact;
-
- MCONTACT 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));
- }
+ MCONTACT hContact = CreateContact(dwUin, true);
if (psr->nick.w)
setWString(hContact, "Nick", psr->nick.w);
if (psr->firstName.w)
@@ -116,7 +107,6 @@ MCONTACT CIcqProto::AddToList(int flags, PROTOSEARCHRESULT *psr)
if (psr->lastName.w)
setWString(hContact, "LastName", psr->lastName.w);
- db_set_b(hContact, "CList", "NotOnList", 1);
return hContact;
}
diff --git a/protocols/Icq10/src/proto.h b/protocols/Icq10/src/proto.h
index c2c217969e..bfc6e82d28 100644
--- a/protocols/Icq10/src/proto.h
+++ b/protocols/Icq10/src/proto.h
@@ -123,6 +123,7 @@ class CIcqProto : public PROTO<CIcqProto>
void InitContactCache(void);
IcqCacheItem* FindContactByUIN(DWORD);
+ MCONTACT CreateContact(DWORD dwUin, bool bTemporary);
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 e3db21620f..f283f5bd9a 100644
--- a/protocols/Icq10/src/server.cpp
+++ b/protocols/Icq10/src/server.cpp
@@ -72,20 +72,8 @@ MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy)
{
DWORD dwUin = _wtol(buddy["aimId"].as_mstring());
- 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(pCache);
- }
- }
-
- MCONTACT hContact = pCache->m_hContact;
- pCache->m_bInList = true;
+ MCONTACT hContact = CreateContact(dwUin, false);
+ FindContactByUIN(dwUin)->m_bInList = true;
CMStringW wszNick(buddy["friendly"].as_mstring());
if (!wszNick.IsEmpty())
@@ -450,9 +438,7 @@ void CIcqProto::ProcessHistData(const JSONNode &ev)
{
DWORD dwUin = _wtol(ev["sn"].as_mstring());
- IcqCacheItem *pCache = FindContactByUIN(dwUin);
- if (pCache == nullptr)
- return;
+ MCONTACT hContact = CreateContact(dwUin, true);
for (auto &it : ev["tail"]["messages"]) {
CMStringA msgId(it["msgId"].as_mstring());
@@ -485,7 +471,7 @@ void CIcqProto::ProcessHistData(const JSONNode &ev)
pre.szMsgId = msgId;
pre.timestamp = it["time"].as_int();
pre.szMessage = szUtf;
- ProtoChainRecvMsg(pCache->m_hContact, &pre);
+ ProtoChainRecvMsg(hContact, &pre);
}
}
}
diff --git a/protocols/Icq10/src/utils.cpp b/protocols/Icq10/src/utils.cpp
index 412484ebda..d80537a4bc 100644
--- a/protocols/Icq10/src/utils.cpp
+++ b/protocols/Icq10/src/utils.cpp
@@ -33,6 +33,27 @@ IcqCacheItem* CIcqProto::FindContactByUIN(DWORD dwUin)
return m_arCache.find((IcqCacheItem*)&dwUin);
}
+MCONTACT CIcqProto::CreateContact(DWORD dwUin, bool bTemporary)
+{
+ auto *pCache = FindContactByUIN(dwUin);
+ if (pCache != nullptr)
+ return pCache->m_hContact;
+
+ 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(pCache);
+ }
+
+ if (bTemporary)
+ db_set_b(hContact, "CList", "NotOnList", 1);
+
+ return hContact;
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
void CIcqProto::CalcHash(AsyncHttpRequest *pReq)