diff options
author | George Hazan <ghazan@miranda.im> | 2023-02-10 19:46:31 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-02-10 19:46:31 +0300 |
commit | a7bf177e6e4aedcaafca186b50e6666788e45f98 (patch) | |
tree | 98b5d4a37a93b5f93eb2399ed38d696dea3c65bd /protocols/ICQ-WIM | |
parent | 2046bf33c966d9db3fbc98c1e067788408751104 (diff) |
ME_DB_EVENT_MARKED_READ: recursion prevention
Diffstat (limited to 'protocols/ICQ-WIM')
-rw-r--r-- | protocols/ICQ-WIM/src/proto.cpp | 21 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/proto.h | 3 | ||||
-rw-r--r-- | protocols/ICQ-WIM/src/server.cpp | 19 |
3 files changed, 12 insertions, 31 deletions
diff --git a/protocols/ICQ-WIM/src/proto.cpp b/protocols/ICQ-WIM/src/proto.cpp index ec3dd49ce6..4f34d1c0ff 100644 --- a/protocols/ICQ-WIM/src/proto.cpp +++ b/protocols/ICQ-WIM/src/proto.cpp @@ -76,7 +76,6 @@ CIcqProto::CIcqProto(const char *aProtoName, const wchar_t *aUserName) : // events
HookProtoEvent(ME_CLIST_GROUPCHANGE, &CIcqProto::OnGroupChange);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CIcqProto::OnDbEventRead);
HookProtoEvent(ME_GC_EVENT, &CIcqProto::GroupchatEventHook);
HookProtoEvent(ME_GC_BUILDMENU, &CIcqProto::GroupchatMenuHook);
HookProtoEvent(ME_OPT_INITIALISE, &CIcqProto::OnOptionsInit);
@@ -353,19 +352,19 @@ void CIcqProto::SendMarkRead() }
}
-int CIcqProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
+void CIcqProto::OnMarkRead(MCONTACT hContact, MEVENT)
{
- MCONTACT hContact = db_event_getContact(hDbEvent);
- if (!hContact)
- return 0;
+ if (!m_bOnline)
+ return;
- // filter out only events of my protocol
- const char *szProto = Proto_GetBaseAccountName(hContact);
- if (mir_strcmp(szProto, m_szModuleName))
- return 0;
+ m_impl.m_markRead.Start(200);
- MarkAsRead(hContact);
- return 0;
+ auto *pCache = FindContactByUIN(GetUserId(hContact));
+ if (pCache) {
+ mir_cslock lck(m_csMarkReadQueue);
+ if (m_arMarkReadQueue.indexOf(pCache) == -1)
+ m_arMarkReadQueue.insert(pCache);
+ }
}
int CIcqProto::OnGroupChange(WPARAM hContact, LPARAM lParam)
diff --git a/protocols/ICQ-WIM/src/proto.h b/protocols/ICQ-WIM/src/proto.h index 240d702ba4..c184e02c8e 100644 --- a/protocols/ICQ-WIM/src/proto.h +++ b/protocols/ICQ-WIM/src/proto.h @@ -260,7 +260,6 @@ class CIcqProto : public PROTO<CIcqProto> void EmailNotification(const wchar_t *pwszText);
void GetPermitDeny();
wchar_t* GetUIN(MCONTACT hContact);
- void MarkAsRead(MCONTACT hContact);
void MoveContactToGroup(MCONTACT hContact, const wchar_t *pwszGroup, const wchar_t *pwszNewGroup);
bool RetrievePassword();
void RetrieveUserHistory(MCONTACT, __int64 startMsgId, bool bCreateRead);
@@ -420,7 +419,6 @@ class CIcqProto : public PROTO<CIcqProto> // events
int __cdecl OnGroupChange(WPARAM, LPARAM);
- int __cdecl OnDbEventRead(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
int __cdecl OnUserInfoInit(WPARAM, LPARAM);
@@ -453,6 +451,7 @@ class CIcqProto : public PROTO<CIcqProto> void OnContactAdded(MCONTACT) override;
void OnContactDeleted(MCONTACT) override;
void OnEventEdited(MCONTACT, MEVENT) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
void OnShutdown() override;
diff --git a/protocols/ICQ-WIM/src/server.cpp b/protocols/ICQ-WIM/src/server.cpp index a5916cb40f..ab4741662a 100644 --- a/protocols/ICQ-WIM/src/server.cpp +++ b/protocols/ICQ-WIM/src/server.cpp @@ -265,23 +265,6 @@ void CIcqProto::OnLoggedOut() /////////////////////////////////////////////////////////////////////////////////////////
-void CIcqProto::MarkAsRead(MCONTACT hContact)
-{
- if (!m_bOnline)
- return;
-
- m_impl.m_markRead.Start(200);
-
- auto *pCache = FindContactByUIN(GetUserId(hContact));
- if (pCache) {
- mir_cslock lck(m_csMarkReadQueue);
- if (m_arMarkReadQueue.indexOf(pCache) == -1)
- m_arMarkReadQueue.insert(pCache);
- }
-}
-
-/////////////////////////////////////////////////////////////////////////////////////////
-
MCONTACT CIcqProto::ParseBuddyInfo(const JSONNode &buddy, MCONTACT hContact, bool bIsPartial)
{
// user chat?
@@ -941,7 +924,7 @@ void CIcqProto::OnFileInfo(NETLIBHTTPREQUEST *pReply, AsyncHttpRequest *pReq) if (szUrl.empty())
return;
- MarkAsRead(pReq->hContact);
+ OnMarkRead(pReq->hContact, 0);
bool bIsSticker;
CMStringW wszDescr(pInfo["file_name"].as_mstring());
|