summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2023-02-10 19:46:31 +0300
committerGeorge Hazan <ghazan@miranda.im>2023-02-10 19:46:31 +0300
commita7bf177e6e4aedcaafca186b50e6666788e45f98 (patch)
tree98b5d4a37a93b5f93eb2399ed38d696dea3c65bd /protocols
parent2046bf33c966d9db3fbc98c1e067788408751104 (diff)
ME_DB_EVENT_MARKED_READ: recursion prevention
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Discord/src/proto.cpp13
-rw-r--r--protocols/Discord/src/proto.h2
-rw-r--r--protocols/Facebook/src/proto.cpp1
-rw-r--r--protocols/Facebook/src/proto.h3
-rw-r--r--protocols/Facebook/src/server.cpp16
-rw-r--r--protocols/ICQ-WIM/src/proto.cpp21
-rw-r--r--protocols/ICQ-WIM/src/proto.h3
-rw-r--r--protocols/ICQ-WIM/src/server.cpp19
-rw-r--r--protocols/JabberG/src/jabber_events.cpp41
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp1
-rw-r--r--protocols/JabberG/src/jabber_proto.h2
-rw-r--r--protocols/JabberG/src/jabber_rc.cpp2
-rw-r--r--protocols/SkypeWeb/src/main.cpp6
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp5
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp1
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h8
-rw-r--r--protocols/Telegram/src/proto.cpp12
-rw-r--r--protocols/Telegram/src/proto.h2
-rw-r--r--protocols/Telegram/src/server.cpp2
-rw-r--r--protocols/Twitter/src/contacts.cpp13
-rw-r--r--protocols/Twitter/src/proto.cpp1
-rw-r--r--protocols/Twitter/src/proto.h2
-rw-r--r--protocols/VKontakte/src/misc.cpp2
-rw-r--r--protocols/VKontakte/src/vk_messages.cpp10
-rw-r--r--protocols/VKontakte/src/vk_proto.cpp1
-rw-r--r--protocols/VKontakte/src/vk_proto.h2
-rw-r--r--protocols/WhatsApp/src/iq.cpp2
27 files changed, 56 insertions, 137 deletions
diff --git a/protocols/Discord/src/proto.cpp b/protocols/Discord/src/proto.cpp
index 8e89312050..f984595ff4 100644
--- a/protocols/Discord/src/proto.cpp
+++ b/protocols/Discord/src/proto.cpp
@@ -70,7 +70,6 @@ CDiscordProto::CDiscordProto(const char *proto_name, const wchar_t *username) :
// Events
HookProtoEvent(ME_OPT_INITIALISE, &CDiscordProto::OnOptionsInit);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CDiscordProto::OnDbEventRead);
HookProtoEvent(ME_PROTO_ACCLISTCHANGED, &CDiscordProto::OnAccountChanged);
HookProtoEvent(PE_VOICE_CALL_STATE, &CDiscordProto::OnVoiceState);
@@ -598,17 +597,8 @@ void CDiscordProto::SendMarkRead()
}
}
-int CDiscordProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
+void CDiscordProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
{
- MCONTACT hContact = db_event_getContact(hDbEvent);
- if (!hContact)
- return 0;
-
- // filter out only events of my protocol
- const char *szProto = Proto_GetBaseAccountName(hContact);
- if (mir_strcmp(szProto, m_szModuleName))
- return 0;
-
if (m_bOnline) {
m_impl.m_markRead.Start(200);
@@ -619,7 +609,6 @@ int CDiscordProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
arMarkReadQueue.insert(pUser);
}
}
- return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Discord/src/proto.h b/protocols/Discord/src/proto.h
index 04645185d2..2c0bd0709a 100644
--- a/protocols/Discord/src/proto.h
+++ b/protocols/Discord/src/proto.h
@@ -377,6 +377,7 @@ public:
void OnBuildProtoMenu() override;
void OnContactDeleted(MCONTACT) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
void OnShutdown() override;
@@ -398,7 +399,6 @@ public:
int __cdecl OnOptionsInit(WPARAM, LPARAM);
int __cdecl OnAccountChanged(WPARAM, LPARAM);
- int __cdecl OnDbEventRead(WPARAM, LPARAM);
int __cdecl OnVoiceState(WPARAM, LPARAM);
diff --git a/protocols/Facebook/src/proto.cpp b/protocols/Facebook/src/proto.cpp
index f594a7ad91..82043fdf55 100644
--- a/protocols/Facebook/src/proto.cpp
+++ b/protocols/Facebook/src/proto.cpp
@@ -108,7 +108,6 @@ FacebookProto::FacebookProto(const char *proto_name, const wchar_t *username) :
HookProtoEvent(ME_GC_EVENT, &FacebookProto::GroupchatEventHook);
HookProtoEvent(ME_GC_BUILDMENU, &FacebookProto::GroupchatMenuHook);
HookProtoEvent(ME_OPT_INITIALISE, &FacebookProto::OnOptionsInit);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &FacebookProto::OnMarkedRead);
// Group chats
GCREGISTER gcr = {};
diff --git a/protocols/Facebook/src/proto.h b/protocols/Facebook/src/proto.h
index fa110918f4..20d218b4b1 100644
--- a/protocols/Facebook/src/proto.h
+++ b/protocols/Facebook/src/proto.h
@@ -532,10 +532,11 @@ public:
int SetStatus(int iNewStatus) override;
int UserIsTyping(MCONTACT hContact, int type) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
+
////////////////////////////////////////////////////////////////////////////////////////
// Events
- int __cdecl OnMarkedRead(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM, LPARAM);
int __cdecl GroupchatMenuHook(WPARAM, LPARAM);
diff --git a/protocols/Facebook/src/server.cpp b/protocols/Facebook/src/server.cpp
index cae092fcbd..a8fd12ebc7 100644
--- a/protocols/Facebook/src/server.cpp
+++ b/protocols/Facebook/src/server.cpp
@@ -447,19 +447,10 @@ LBL_Begin:
/////////////////////////////////////////////////////////////////////////////////////////
-int FacebookProto::OnMarkedRead(WPARAM, LPARAM hDbEvent)
+void FacebookProto::OnMarkRead(MCONTACT hContact, MEVENT)
{
- MCONTACT hContact = db_event_getContact(hDbEvent);
- if (!hContact)
- return 0;
-
- // filter out only events of my protocol
- const char *szProto = Proto_GetBaseAccountName(hContact);
- if (mir_strcmp(szProto, m_szModuleName))
- return 0;
-
if (m_bKeepUnread)
- return 0;
+ return;
JSONNode root; root << BOOL_PARAM("state", true) << INT_PARAM("syncSeqId", m_sid) << CHAR_PARAM("mark", "read");
if (isChatRoom(hContact))
@@ -467,7 +458,6 @@ int FacebookProto::OnMarkedRead(WPARAM, LPARAM hDbEvent)
else
root << CHAR_PARAM("otherUserFbId", getMStringA(hContact, DBKEY_ID));
MqttPublish("/mark_thread", root);
- return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -977,7 +967,7 @@ void FacebookProto::OnPublishReadReceipt(const JSONNode &root)
break;
if (!dbei.markedRead())
- db_event_markRead(pUser->hContact, ev);
+ db_event_markRead(pUser->hContact, ev, true);
}
}
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());
diff --git a/protocols/JabberG/src/jabber_events.cpp b/protocols/JabberG/src/jabber_events.cpp
index da9f81c7bc..d2a863bfa5 100644
--- a/protocols/JabberG/src/jabber_events.cpp
+++ b/protocols/JabberG/src/jabber_events.cpp
@@ -61,6 +61,23 @@ void CJabberProto::OnContactDeleted(MCONTACT hContact)
}
/////////////////////////////////////////////////////////////////////////////////////////
+// OnMarkRead - mark an event read
+
+void CJabberProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
+{
+ auto *pMark = m_arChatMarks.find((CChatMark *)&hDbEvent);
+ if (pMark) {
+ if (IsSendAck(hContact)) {
+ XmlNode reply("message"); reply << XATTR("to", pMark->szFrom) << XATTR("id", pMark->szId)
+ << XCHILDNS("displayed", JABBER_FEAT_CHAT_MARKERS) << XATTR("id", pMark->szId);
+ m_ThreadInfo->send(reply);
+ }
+
+ m_arChatMarks.remove(pMark);
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
// JabberDbSettingChanged - process database changes
static char* sttSettingToTchar(DBCONTACTWRITESETTING *cws)
@@ -157,30 +174,6 @@ void __cdecl CJabberProto::OnAddContactForever(MCONTACT hContact)
Contact::Hide(hContact, false);
}
-int __cdecl CJabberProto::OnDbMarkedRead(WPARAM, LPARAM hDbEvent)
-{
- MCONTACT hContact = db_event_getContact(hDbEvent);
- if (!hContact)
- return 0;
-
- // filter out only events of my protocol
- const char *szProto = Proto_GetBaseAccountName(hContact);
- if (mir_strcmp(szProto, m_szModuleName))
- return 0;
-
- auto *pMark = m_arChatMarks.find((CChatMark *)&hDbEvent);
- if (pMark) {
- if (IsSendAck(hContact)) {
- XmlNode reply("message"); reply << XATTR("to", pMark->szFrom) << XATTR("id", pMark->szId)
- << XCHILDNS("displayed", JABBER_FEAT_CHAT_MARKERS) << XATTR("id", pMark->szId);
- m_ThreadInfo->send(reply);
- }
-
- m_arChatMarks.remove(pMark);
- }
- return 0;
-}
-
int __cdecl CJabberProto::OnDbSettingChanged(WPARAM hContact, LPARAM lParam)
{
if (hContact == 0 || !m_bJabberOnline)
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 9762a297f8..6c425da2c4 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -199,7 +199,6 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) :
HookProtoEvent(ME_LANGPACK_CHANGED, &CJabberProto::OnLangChanged);
HookProtoEvent(ME_OPT_INITIALISE, &CJabberProto::OnOptionsInit);
HookProtoEvent(ME_SKIN_ICONSCHANGED, &CJabberProto::OnReloadIcons);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CJabberProto::OnDbMarkedRead);
HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &CJabberProto::OnDbSettingChanged);
m_iqManager.FillPermanentHandlers();
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index c2eaba0b3f..9f5d8d5c0b 100644
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -150,6 +150,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void OnBuildProtoMenu(void) override;
void OnContactDeleted(MCONTACT) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
void OnShutdown() override;
@@ -163,7 +164,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
//====| Events |======================================================================
void __cdecl OnAddContactForever(MCONTACT hContact);
- int __cdecl OnDbMarkedRead(WPARAM, LPARAM);
int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
int __cdecl OnIdleChanged(WPARAM, LPARAM);
int __cdecl OnLangChanged(WPARAM, LPARAM);
diff --git a/protocols/JabberG/src/jabber_rc.cpp b/protocols/JabberG/src/jabber_rc.cpp
index a5bae9e944..27d389cee3 100644
--- a/protocols/JabberG/src/jabber_rc.cpp
+++ b/protocols/JabberG/src/jabber_rc.cpp
@@ -564,7 +564,7 @@ int CJabberProto::AdhocForwardHandler(const TiXmlElement*, CJabberIqInfo *pInfo,
nEventsSent++;
- db_event_markRead(hContact, hDbEvent);
+ db_event_markRead(hContact, hDbEvent, true);
if (bRemoveCListEvents)
g_clistApi.pfnRemoveEvent(hContact, hDbEvent);
}
diff --git a/protocols/SkypeWeb/src/main.cpp b/protocols/SkypeWeb/src/main.cpp
index b1e3ddfb5b..1f7818b72a 100644
--- a/protocols/SkypeWeb/src/main.cpp
+++ b/protocols/SkypeWeb/src/main.cpp
@@ -51,10 +51,10 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC
/////////////////////////////////////////////////////////////////////////////////////////
-int CSkypeProto::OnModulesLoaded(WPARAM, LPARAM)
+static int OnModulesLoaded(WPARAM, LPARAM)
{
if (ServiceExists(MS_ASSOCMGR_ADDNEWURLTYPE)) {
- CreateServiceFunction(MODULE "/ParseUri", CSkypeProto::GlobalParseSkypeUriService);
+ CreateServiceFunction(MODULE "/ParseUri", &CSkypeProto::GlobalParseSkypeUriService);
AssocMgr_AddNewUrlTypeW("skype:", TranslateT("Skype Link Protocol"), g_plugin.getInst(), IDI_SKYPE, MODULE "/ParseUri", 0);
}
return 0;
@@ -73,7 +73,7 @@ int CMPlugin::Load()
g_hCallEvent = CreateHookableEvent(MODULE "/IncomingCall");
- HookEvent(ME_SYSTEM_MODULESLOADED, &CSkypeProto::OnModulesLoaded);
+ HookEvent(ME_SYSTEM_MODULESLOADED, OnModulesLoaded);
return 0;
}
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index 01a0235caa..59980fe873 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -172,11 +172,10 @@ void CSkypeProto::OnPrivateMessageEvent(const JSONNode &node)
}
}
-int CSkypeProto::OnDbEventRead(WPARAM hContact, LPARAM hDbEvent)
+void CSkypeProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
{
- if (IsOnline() && !isChatRoom(hContact) && !mir_strcmp(Proto_GetBaseAccountName(hContact), m_szModuleName))
+ if (IsOnline() && !isChatRoom(hContact))
MarkMessagesRead(hContact, hDbEvent);
- return 0;
}
void CSkypeProto::MarkMessagesRead(MCONTACT hContact, MEVENT hDbEvent)
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index 5288ea81ac..5a70b171a8 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -49,7 +49,6 @@ CSkypeProto::CSkypeProto(const char* protoName, const wchar_t* userName) :
CreateProtoService(PS_MENU_LOADHISTORY, &CSkypeProto::GetContactHistory);
HookProtoEvent(ME_OPT_INITIALISE, &CSkypeProto::OnOptionsInit);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CSkypeProto::OnDbEventRead);
CreateDirectoryTreeW(GetAvatarPath());
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index 4977bb71d3..f2d9c467ac 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -69,6 +69,7 @@ public:
void OnBuildProtoMenu(void) override;
void OnContactDeleted(MCONTACT) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
void OnShutdown() override;
@@ -85,10 +86,6 @@ public:
// languages
static void InitLanguages();
- // events
- static int OnModulesLoaded(WPARAM, LPARAM);
- int __cdecl OnDbEventRead(WPARAM, LPARAM);
-
// search
void __cdecl SearchBasicThread(void* id);
@@ -163,6 +160,8 @@ public:
bool CheckOauth(const char *szResponse);
void LoadProfile(NETLIBHTTPREQUEST *response, AsyncHttpRequest *pRequest);
+ static INT_PTR __cdecl GlobalParseSkypeUriService(WPARAM, LPARAM lParam);
+
private:
bool m_bHistorySynced;
@@ -357,7 +356,6 @@ private:
INT_PTR __cdecl GetContactHistory(WPARAM hContact, LPARAM lParam);
INT_PTR __cdecl SvcCreateChat(WPARAM, LPARAM);
INT_PTR __cdecl ParseSkypeUriService(WPARAM, LPARAM lParam);
- static INT_PTR __cdecl GlobalParseSkypeUriService(WPARAM, LPARAM lParam);
template<INT_PTR(__cdecl CSkypeProto::*Service)(WPARAM, LPARAM)>
static INT_PTR __cdecl GlobalService(WPARAM wParam, LPARAM lParam)
diff --git a/protocols/Telegram/src/proto.cpp b/protocols/Telegram/src/proto.cpp
index 1a353da02a..2ed51339d7 100644
--- a/protocols/Telegram/src/proto.cpp
+++ b/protocols/Telegram/src/proto.cpp
@@ -56,7 +56,6 @@ CTelegramProto::CTelegramProto(const char* protoName, const wchar_t* userName) :
CreateProtoService(PS_SETMYAVATAR, &CTelegramProto::SvcSetMyAvatar);
HookProtoEvent(ME_OPT_INITIALISE, &CTelegramProto::OnOptionsInit);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CTelegramProto::OnDbMarkedRead);
// avatar
CreateDirectoryTreeW(GetAvatarPath());
@@ -141,15 +140,10 @@ void CTelegramProto::OnErase()
DeleteDirectoryTreeW(GetProtoFolder(), false);
}
-int CTelegramProto::OnDbMarkedRead(WPARAM hContact, LPARAM hDbEvent)
+void CTelegramProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
{
if (!hContact)
- return 0;
-
- // filter out only events of my protocol
- const char *szProto = Proto_GetBaseAccountName(hContact);
- if (mir_strcmp(szProto, m_szModuleName))
- return 0;
+ return;
ptrA userId(getStringA(hContact, DBKEY_ID));
if (userId) {
@@ -169,8 +163,6 @@ int CTelegramProto::OnDbMarkedRead(WPARAM hContact, LPARAM hDbEvent)
m_impl.m_markRead.Start(500);
}
}
-
- return 0;
}
INT_PTR CTelegramProto::GetCaps(int type, MCONTACT)
diff --git a/protocols/Telegram/src/proto.h b/protocols/Telegram/src/proto.h
index d57f873bc3..1585f9d62d 100644
--- a/protocols/Telegram/src/proto.h
+++ b/protocols/Telegram/src/proto.h
@@ -242,6 +242,7 @@ public:
int SetStatus(int iNewStatus) override;
void OnContactDeleted(MCONTACT hContact) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
void OnShutdown() override;
void OnErase() override;
@@ -253,7 +254,6 @@ public:
// Events ////////////////////////////////////////////////////////////////////////////
int __cdecl OnOptionsInit(WPARAM, LPARAM);
- int __cdecl OnDbMarkedRead(WPARAM, LPARAM);
int __cdecl GcMenuHook(WPARAM, LPARAM);
int __cdecl GcEventHook(WPARAM, LPARAM);
diff --git a/protocols/Telegram/src/server.cpp b/protocols/Telegram/src/server.cpp
index bbe86146e7..34c8ff5936 100644
--- a/protocols/Telegram/src/server.cpp
+++ b/protocols/Telegram/src/server.cpp
@@ -385,7 +385,7 @@ void CTelegramProto::ProcessMarkRead(TD::updateChatReadInbox *pObj)
continue;
if (!dbei.markedRead())
- db_event_markRead(pUser->hContact, hEvent);
+ db_event_markRead(pUser->hContact, hEvent, true);
}
}
diff --git a/protocols/Twitter/src/contacts.cpp b/protocols/Twitter/src/contacts.cpp
index ce4795132b..09c8768582 100644
--- a/protocols/Twitter/src/contacts.cpp
+++ b/protocols/Twitter/src/contacts.cpp
@@ -169,24 +169,13 @@ void CTwitterProto::OnContactDeleted(MCONTACT hContact)
}
}
-int CTwitterProto::OnMarkedRead(WPARAM, LPARAM hDbEvent)
+void CTwitterProto::OnMarkRead(MCONTACT hContact, MEVENT hDbEvent)
{
- MCONTACT hContact = db_event_getContact(hDbEvent);
- if (!hContact)
- return 0;
-
- // filter out only events of my protocol
- const char *szProto = Proto_GetBaseAccountName(hContact);
- if (mir_strcmp(szProto, m_szModuleName))
- return 0;
-
auto *pMark = (m_arChatMarks.find((CChatMark *)&hDbEvent));
if (pMark) {
mark_read(hContact, pMark->szId);
m_arChatMarks.remove(pMark);
}
-
- return 0;
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/Twitter/src/proto.cpp b/protocols/Twitter/src/proto.cpp
index 0ee353ac67..aadfb416a2 100644
--- a/protocols/Twitter/src/proto.cpp
+++ b/protocols/Twitter/src/proto.cpp
@@ -36,7 +36,6 @@ CTwitterProto::CTwitterProto(const char *proto_name, const wchar_t *username) :
CreateProtoService(PS_SETMYAVATAR, &CTwitterProto::SetAvatar);
HookProtoEvent(ME_OPT_INITIALISE, &CTwitterProto::OnOptionsInit);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CTwitterProto::OnMarkedRead);
HookProtoEvent(ME_CLIST_PREBUILDSTATUSMENU, &CTwitterProto::OnBuildStatusMenu);
// Initialize hotkeys
diff --git a/protocols/Twitter/src/proto.h b/protocols/Twitter/src/proto.h
index 7fe4922552..d545f409db 100644
--- a/protocols/Twitter/src/proto.h
+++ b/protocols/Twitter/src/proto.h
@@ -167,6 +167,7 @@ public:
HANDLE GetAwayMsg(MCONTACT) override;
void OnContactDeleted(MCONTACT) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
void UpdateSettings();
@@ -190,7 +191,6 @@ public:
int __cdecl OnBuildStatusMenu(WPARAM, LPARAM);
int __cdecl OnChatOutgoing(WPARAM, LPARAM);
- int __cdecl OnMarkedRead(WPARAM, LPARAM);
int __cdecl OnOptionsInit(WPARAM,LPARAM);
int __cdecl OnPrebuildContactMenu(WPARAM,LPARAM);
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp
index bd7acbac2d..351dbebe48 100644
--- a/protocols/VKontakte/src/misc.cpp
+++ b/protocols/VKontakte/src/misc.cpp
@@ -816,7 +816,7 @@ void CVkProto::MarkDialogAsRead(MCONTACT hContact)
while (hDBEvent != 0) {
DBEVENTINFO dbei = {};
if (!db_event_get(hDBEvent, &dbei) && !mir_strcmp(m_szModuleName, dbei.szModule)) {
- db_event_markRead(hContact, hDBEvent);
+ db_event_markRead(hContact, hDBEvent, true);
g_clistApi.pfnRemoveEvent(hMContact, hDBEvent);
if (hContact != hMContact)
g_clistApi.pfnRemoveEvent(hContact, hDBEvent);
diff --git a/protocols/VKontakte/src/vk_messages.cpp b/protocols/VKontakte/src/vk_messages.cpp
index 2fde56a1d3..78ad3fd307 100644
--- a/protocols/VKontakte/src/vk_messages.cpp
+++ b/protocols/VKontakte/src/vk_messages.cpp
@@ -131,20 +131,12 @@ void CVkProto::OnSendMessage(NETLIBHTTPREQUEST *reply, AsyncHttpRequest *pReq)
/////////////////////////////////////////////////////////////////////////////////////////
-int CVkProto::OnDbEventRead(WPARAM, LPARAM hDbEvent)
+void CVkProto::OnMarkRead(MCONTACT hContact, MEVENT)
{
debugLogA("CVkProto::OnDbEventRead");
- MCONTACT hContact = db_event_getContact(hDbEvent);
- if (!hContact)
- return 0;
-
- CMStringA szProto(Proto_GetBaseAccountName(hContact));
- if (szProto.IsEmpty() || szProto != m_szModuleName)
- return 0;
if (m_vkOptions.iMarkMessageReadOn == MarkMsgReadOn::markOnRead)
MarkMessagesRead(hContact);
- return 0;
}
INT_PTR CVkProto::SvcMarkMessagesAsRead(WPARAM hContact, LPARAM)
diff --git a/protocols/VKontakte/src/vk_proto.cpp b/protocols/VKontakte/src/vk_proto.cpp
index b712b83eb2..9e7a621593 100644
--- a/protocols/VKontakte/src/vk_proto.cpp
+++ b/protocols/VKontakte/src/vk_proto.cpp
@@ -105,7 +105,6 @@ void CVkProto::OnModulesLoaded()
// Other hooks
HookProtoEvent(ME_MSG_WINDOWEVENT, &CVkProto::OnProcessSrmmEvent);
- HookProtoEvent(ME_DB_EVENT_MARKED_READ, &CVkProto::OnDbEventRead);
HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &CVkProto::OnDbSettingChanged);
//Sounds
diff --git a/protocols/VKontakte/src/vk_proto.h b/protocols/VKontakte/src/vk_proto.h
index 43936e8c5b..4c9cb67a08 100644
--- a/protocols/VKontakte/src/vk_proto.h
+++ b/protocols/VKontakte/src/vk_proto.h
@@ -69,6 +69,7 @@ struct CVkProto : public PROTO<CVkProto>
void OnBuildProtoMenu() override;
void OnContactDeleted(MCONTACT) override;
+ void OnMarkRead(MCONTACT, MEVENT) override;
void OnModulesLoaded() override;
void OnShutdown() override;
@@ -252,7 +253,6 @@ private:
//==== Hooks =========================================================================
int __cdecl OnProcessSrmmEvent(WPARAM, LPARAM);
- int __cdecl OnDbEventRead(WPARAM, LPARAM);
int __cdecl OnDbSettingChanged(WPARAM, LPARAM);
//==== Search ========================================================================
diff --git a/protocols/WhatsApp/src/iq.cpp b/protocols/WhatsApp/src/iq.cpp
index 24513dd06b..d08eee4b6a 100644
--- a/protocols/WhatsApp/src/iq.cpp
+++ b/protocols/WhatsApp/src/iq.cpp
@@ -499,7 +499,7 @@ void WhatsAppProto::ProcessReceipt(MCONTACT hContact, const char *msgId, bool bR
CallService(MS_MESSAGESTATE_UPDATE, hContact, bRead ? MRD_TYPE_READ : MRD_TYPE_DELIVERED);
if (bRead)
- db_event_markRead(hContact, hEvent);
+ db_event_markRead(hContact, hEvent, true);
}
void WhatsAppProto::OnReceiveReceipt(const WANode &node)