diff options
author | George Hazan <george.hazan@gmail.com> | 2024-07-21 16:17:48 +0300 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2024-07-21 16:17:48 +0300 |
commit | 5fd260b7c4c98bfa2d17a301d832a859c2af1f92 (patch) | |
tree | 648dfe9336191c8fafdf7772f376f8e60337388a /protocols/ICQ-WIM | |
parent | 17b6a94812b2dbf4af29fb5d84064ceb1c7d393e (diff) |
fixes #4555 (Задваиваются контакты протоколов, где есть кэш)
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 37 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 58 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/utils.cpp | 34 |
3 files changed, 65 insertions, 64 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index cba66077db..d224b7d265 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -134,7 +134,6 @@ CIcqProto::~CIcqProto() void CIcqProto::OnModulesLoaded()
{
- InitContactCache();
InitMenus();
HookProtoEvent(ME_USERINFO_INITIALISE, &CIcqProto::OnUserInfoInit);
@@ -148,6 +147,42 @@ void CIcqProto::OnShutdown() m_bTerminated = true;
}
+void CIcqProto::OnCacheInit()
+{
+ mir_cslock l(m_csCache);
+ for (auto &it : AccContacts()) {
+ m_bCacheInited = true;
+
+ if (isChatRoom(it))
+ continue;
+
+ // that was previously an ICQ contact
+ ptrW wszUin(GetUIN(it));
+ if (wszUin != nullptr) {
+ delSetting(it, "UIN");
+ setWString(it, DB_KEY_ID, wszUin);
+ }
+ // that was previously a MRA contact
+ else {
+ CMStringW wszEmail(getMStringW(it, "e-mail"));
+ if (!wszEmail.IsEmpty()) {
+ delSetting(it, "e-mail");
+ setWString(it, DB_KEY_ID, wszEmail);
+ }
+ }
+
+ CMStringW wszId = GetUserId(it);
+ auto *pUser = FindUser(wszId);
+ if (pUser == nullptr) {
+ pUser = new IcqUser(wszId, it);
+
+ mir_cslock lck(m_csCache);
+ m_arCache.insert(pUser);
+ }
+ pUser->m_iProcessedMsgId = getId(it, DB_KEY_LASTMSGID);
+ }
+}
+
void CIcqProto::OnContactAdded(MCONTACT hContact)
{
CMStringW wszId(getMStringW(hContact, DB_KEY_ID));
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 27bc6b2490..778a8a5236 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -378,7 +378,6 @@ class CIcqProto : public PROTO<CIcqProto> mir_cs m_csCache;
OBJLIST<IcqUser> m_arCache;
- void InitContactCache(void);
IcqUser* FindUser(const CMStringW &pwszId);
MCONTACT CreateContact(const CMStringW &pwszId, bool bTemporary);
@@ -431,34 +430,35 @@ class CIcqProto : public PROTO<CIcqProto> ////////////////////////////////////////////////////////////////////////////////////////
// PROTO_INTERFACE
- MCONTACT AddToList( int flags, PROTOSEARCHRESULT *psr) override;
-
- int AuthRecv(MCONTACT, DB::EventInfo &dbei) override;
- int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override;
-
- INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override;
- int GetInfo(MCONTACT hContact, int infoType) override;
-
- HANDLE SearchBasic(const wchar_t *id) override;
-
- HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override;
- int SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *msg) override;
-
- int SetStatus(int iNewStatus) override;
-
- int UserIsTyping(MCONTACT hContact, int type) override;
-
- void OnBuildProtoMenu(void) override;
- void OnContactAdded(MCONTACT) override;
- bool OnContactDeleted(MCONTACT, uint32_t flags) override;
- MWindow OnCreateAccMgrUI(MWindow) override;
- void OnEventDeleted(MCONTACT, MEVENT, int) override;
- void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei) override;
- void OnMarkRead(MCONTACT, MEVENT) override;
- void OnModulesLoaded() override;
- void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override;
- void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *ft) override;
- void OnShutdown() override;
+ MCONTACT AddToList( int flags, PROTOSEARCHRESULT *psr) override;
+
+ int AuthRecv(MCONTACT, DB::EventInfo &dbei) override;
+ int AuthRequest(MCONTACT hContact, const wchar_t *szMessage) override;
+
+ INT_PTR GetCaps(int type, MCONTACT hContact = NULL) override;
+ int GetInfo(MCONTACT hContact, int infoType) override;
+
+ HANDLE SearchBasic(const wchar_t *id) override;
+
+ HANDLE SendFile(MCONTACT hContact, const wchar_t *szDescription, wchar_t **ppszFiles) override;
+ int SendMsg(MCONTACT hContact, MEVENT hReplyEvent, const char *msg) override;
+
+ int SetStatus(int iNewStatus) override;
+
+ int UserIsTyping(MCONTACT hContact, int type) override;
+
+ void OnBuildProtoMenu(void) override;
+ void OnCacheInit() override;
+ void OnContactAdded(MCONTACT) override;
+ bool OnContactDeleted(MCONTACT, uint32_t flags) override;
+ MWindow OnCreateAccMgrUI(MWindow) override;
+ void OnEventDeleted(MCONTACT, MEVENT, int) override;
+ void OnEventEdited(MCONTACT, MEVENT, const DBEVENTINFO &dbei) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
+ void OnModulesLoaded() override;
+ void OnReceiveOfflineFile(DB::FILE_BLOB &blob) override;
+ void OnSendOfflineFile(DB::EventInfo &dbei, DB::FILE_BLOB &blob, void *ft) override;
+ void OnShutdown() override;
public:
CIcqProto(const char*, const wchar_t*);
diff --git a/protocols/ICQ-WIM/src/utils.cpp b/protocols/ICQ-WIM/src/utils.cpp index 460e20ff2f..722314bc55 100644 --- a/protocols/ICQ-WIM/src/utils.cpp +++ b/protocols/ICQ-WIM/src/utils.cpp @@ -20,40 +20,6 @@ #include "stdafx.h"
-void CIcqProto::InitContactCache()
-{
- mir_cslock l(m_csCache);
- for (auto &it : AccContacts()) {
- if (isChatRoom(it))
- continue;
-
- // that was previously an ICQ contact
- ptrW wszUin(GetUIN(it));
- if (wszUin != nullptr) {
- delSetting(it, "UIN");
- setWString(it, DB_KEY_ID, wszUin);
- }
- // that was previously a MRA contact
- else {
- CMStringW wszEmail(getMStringW(it, "e-mail"));
- if (!wszEmail.IsEmpty()) {
- delSetting(it, "e-mail");
- setWString(it, DB_KEY_ID, wszEmail);
- }
- }
-
- CMStringW wszId = GetUserId(it);
- auto *pUser = FindUser(wszId);
- if (pUser == nullptr) {
- pUser = new IcqUser(wszId, it);
-
- mir_cslock lck(m_csCache);
- m_arCache.insert(pUser);
- }
- pUser->m_iProcessedMsgId = getId(it, DB_KEY_LASTMSGID);
- }
-}
-
IcqUser* CIcqProto::FindUser(const CMStringW &wszId)
{
IcqUser tmp(wszId, -1);
|