diff options
38 files changed, 81 insertions, 142 deletions
diff --git a/include/delphi/m_database.inc b/include/delphi/m_database.inc index 3da8ce5123..4c41eac938 100644 --- a/include/delphi/m_database.inc +++ b/include/delphi/m_database.inc @@ -141,7 +141,7 @@ is invalid. This is the one database write operation that does not trigger an event.
Modules should not save flags states for any length of time.
}
-function db_event_markRead(hContact:TMCONTACT; hDbEvent:TMEVENT):int; stdcall; external CoreDLL;
+function db_event_markRead(hContact:TMCONTACT; hDbEvent:TMEVENT; flags:integer = 0):int; stdcall; external CoreDLL;
{
Retrieves a handle to the next event in a chain after hDbEvent
diff --git a/include/m_database.h b/include/m_database.h index 9aaffc79eb..1831946c67 100644 --- a/include/m_database.h +++ b/include/m_database.h @@ -351,7 +351,7 @@ EXTERN_C MIR_CORE_DLL(MEVENT) db_event_last(MCONTACT hContact); // This is the one database write operation that does not trigger an event.
// Modules should not save flags states for any length of time.
-EXTERN_C MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent);
+EXTERN_C MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent, bool bFromServer = false);
// Retrieves a handle to the next event in a chain after hDbEvent
// Returns the handle, or NULL if hDbEvent is invalid or is the last event
diff --git a/include/m_protoint.h b/include/m_protoint.h index 06d3267ff3..184d36d4c5 100644 --- a/include/m_protoint.h +++ b/include/m_protoint.h @@ -264,6 +264,9 @@ public: // called when an account gets physically removed from the database
virtual void OnErase();
+ // called when an event is marked read from Miranda (not from the server)
+ virtual void OnMarkRead(MCONTACT, MEVENT);
+
// the analog of ME_SYSTEM_MODULESLOADED for an account
virtual void OnModulesLoaded(void);
diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib Binary files differindex 5b29f95fd8..9962c6a371 100644 --- a/libs/win32/mir_app.lib +++ b/libs/win32/mir_app.lib diff --git a/libs/win32/mir_core.lib b/libs/win32/mir_core.lib Binary files differindex de44a083b2..7f562cba3f 100644 --- a/libs/win32/mir_core.lib +++ b/libs/win32/mir_core.lib diff --git a/libs/win64/mir_app.lib b/libs/win64/mir_app.lib Binary files differindex fc28af6423..91c52d10e6 100644 --- a/libs/win64/mir_app.lib +++ b/libs/win64/mir_app.lib diff --git a/plugins/Dbx_sqlite/src/dbevents.cpp b/plugins/Dbx_sqlite/src/dbevents.cpp index 0dadafa834..b16a1fd91f 100644 --- a/plugins/Dbx_sqlite/src/dbevents.cpp +++ b/plugins/Dbx_sqlite/src/dbevents.cpp @@ -391,8 +391,12 @@ BOOL CDbxSQLite::MarkEventRead(MCONTACT hContact, MEVENT hDbEvent) }
DBFlush();
+
+ if (rows == 0)
+ return 0;
+
NotifyEventHooks(g_hevMarkedRead, hContact, (LPARAM)hDbEvent);
- return (rows == 0 ? 0 : DBEF_READ);
+ return 1;
}
MCONTACT CDbxSQLite::GetEventContact(MEVENT hDbEvent)
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)
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index 81f0512e7f..208d93904c 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -818,3 +818,4 @@ Srmm_CreateHotkey @886 NONAME ?Chat_Terminate@@YGHPBD_N@Z @933 NONAME
?Chat_Control@@YGHPBDH@Z @934 NONAME
?UpdateChatLog@CSrmmBaseDialog@@IAEXXZ @935 NONAME
+?OnMarkRead@PROTO_INTERFACE@@UAEXII@Z @936 NONAME
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 901fc10164..451d75680a 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -818,3 +818,4 @@ Srmm_CreateHotkey @886 NONAME ?Chat_Terminate@@YAHPEBD_N@Z @933 NONAME
?Chat_Control@@YAHPEBDH@Z @934 NONAME
?UpdateChatLog@CSrmmBaseDialog@@IEAAXXZ @935 NONAME
+?OnMarkRead@PROTO_INTERFACE@@UEAAXII@Z @936 NONAME
diff --git a/src/mir_app/src/proto_interface.cpp b/src/mir_app/src/proto_interface.cpp index 801442d8fa..96c155a9a9 100644 --- a/src/mir_app/src/proto_interface.cpp +++ b/src/mir_app/src/proto_interface.cpp @@ -80,6 +80,9 @@ void PROTO_INTERFACE::OnEventEdited(MCONTACT, MEVENT) void PROTO_INTERFACE::OnErase()
{}
+void PROTO_INTERFACE::OnMarkRead(MCONTACT, MEVENT)
+{}
+
void PROTO_INTERFACE::OnModulesLoaded()
{}
diff --git a/src/mir_core/src/db.cpp b/src/mir_core/src/db.cpp index 23584d2fb1..63afe4d66b 100644 --- a/src/mir_core/src/db.cpp +++ b/src/mir_core/src/db.cpp @@ -440,9 +440,17 @@ MIR_CORE_DLL(MEVENT) db_event_last(MCONTACT hContact) return (g_pCurrDb == nullptr) ? 0 : g_pCurrDb->FindLastEvent(hContact);
}
-MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent)
+MIR_CORE_DLL(int) db_event_markRead(MCONTACT hContact, MEVENT hDbEvent, bool bFromServer)
{
- return (g_pCurrDb == nullptr) ? 0 : g_pCurrDb->MarkEventRead(hContact, hDbEvent);
+ if (g_pCurrDb == nullptr)
+ return 0;
+
+ if (!g_pCurrDb->MarkEventRead(hContact, hDbEvent))
+ return 0;
+
+ if (!bFromServer)
+ if (auto *ppro = Proto_GetInstance(hContact))
+ ppro->OnMarkRead(hContact, hDbEvent);
}
MIR_CORE_DLL(MEVENT) db_event_next(MCONTACT hContact, MEVENT hDbEvent)
|