From dbca94ca6e16a5bc270332e09ea3703bb46ceeaf Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 23 Apr 2023 18:48:34 +0300 Subject: DbEventIsShown is added to g_chatApi to allow the core to filter group chat events too --- include/m_chat_int.h | 2 ++ plugins/Scriver/src/chat_main.cpp | 1 + plugins/TabSRMM/src/chat_main.cpp | 3 ++- plugins/TabSRMM/src/msglog.cpp | 2 +- src/core/stdmsg/src/chat_manager.cpp | 1 + src/core/stdmsg/src/stdafx.h | 31 +++++++++++++++---------------- src/mir_app/src/chat_tools.cpp | 2 +- src/mir_app/src/srmm_base.cpp | 6 ++---- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/include/m_chat_int.h b/include/m_chat_int.h index 95a8c10206..3698ef4203 100644 --- a/include/m_chat_int.h +++ b/include/m_chat_int.h @@ -319,6 +319,8 @@ struct CHAT_MANAGER MIR_APP_DLL(HICON) getIcon(int iEventType) const; // user-defined custom callbacks + bool (*DbEventIsShown)(const DB::EventInfo &dbei); + void (*OnCreateModule)(MODULEINFO*); void (*OnDestroyModule)(MODULEINFO*); diff --git a/plugins/Scriver/src/chat_main.cpp b/plugins/Scriver/src/chat_main.cpp index 0297bbef01..cee6777e6b 100644 --- a/plugins/Scriver/src/chat_main.cpp +++ b/plugins/Scriver/src/chat_main.cpp @@ -146,6 +146,7 @@ int Chat_Load() g_chatApi.OnFlashWindow = OnFlashWindow; g_chatApi.OnFlashHighlight = OnFlashHighlight; g_chatApi.ShowRoom = ShowRoom; + g_chatApi.DbEventIsShown = DbEventIsShown; Srmm_CreateHotkey(LPGEN("Messaging"), LPGEN("Action: Send message")); diff --git a/plugins/TabSRMM/src/chat_main.cpp b/plugins/TabSRMM/src/chat_main.cpp index 1a4a20082a..53e19d35a1 100644 --- a/plugins/TabSRMM/src/chat_main.cpp +++ b/plugins/TabSRMM/src/chat_main.cpp @@ -365,9 +365,10 @@ int Chat_Load() g_chatApi.OnCreateSession = OnCreateSession; g_chatApi.OnReplaceSession = OnReplaceSession; - g_chatApi.OnChangeNick = OnChangeNick; g_chatApi.ShowRoom = stubShowRoom; + g_chatApi.OnChangeNick = OnChangeNick; g_chatApi.OnLoadSettings = OnLoadSettings; + g_chatApi.DbEventIsShown = DbEventIsShown; Srmm_CreateHotkey(TABSRMM_HK_SECTION_GENERIC, LPGEN("Send message")); diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 04045292b2..49743a5544 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -327,7 +327,7 @@ static wchar_t* Template_MakeRelativeDate(HANDLE hTimeZone, time_t check, wchar_ bool DbEventIsShown(const DB::EventInfo &dbei) { if (!IsCustomEvent(dbei.eventType) || dbei.isSrmm()) - return 1; + return true; return IsStatusEvent(dbei.eventType); } diff --git a/src/core/stdmsg/src/chat_manager.cpp b/src/core/stdmsg/src/chat_manager.cpp index 4cdd7cbfbd..f7c693b01a 100644 --- a/src/core/stdmsg/src/chat_manager.cpp +++ b/src/core/stdmsg/src/chat_manager.cpp @@ -199,6 +199,7 @@ void Load_ChatModule() g_chatApi.OnFlashWindow = OnFlashWindow; g_chatApi.OnFlashHighlight = OnFlashHighlight; g_chatApi.ShowRoom = ShowRoom; + g_chatApi.DbEventIsShown = DbEventIsShown; Srmm_CreateHotkey(LPGEN("Messaging"), LPGEN("Send message")); diff --git a/src/core/stdmsg/src/stdafx.h b/src/core/stdmsg/src/stdafx.h index dc6fdc6c5d..40b2e4b02b 100644 --- a/src/core/stdmsg/src/stdafx.h +++ b/src/core/stdmsg/src/stdafx.h @@ -43,32 +43,31 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include -#include +#include #include +#include #include #include -#include -#include -#include -#include -#include #include -#include +#include +#include +#include +#include #include #include -#include -#include -#include #include -#include -#include -#include +#include +#include #include -#include -#include +#include #include +#include +#include +#include #include +#include +#include +#include ///////////////////////////////////////////////////////////////////////////////////////// // tabs.cpp diff --git a/src/mir_app/src/chat_tools.cpp b/src/mir_app/src/chat_tools.cpp index 50f16f07ba..4ed79d4cc7 100644 --- a/src/mir_app/src/chat_tools.cpp +++ b/src/mir_app/src/chat_tools.cpp @@ -730,7 +730,7 @@ void Chat_EventToGC(SESSION_INFO *si, MEVENT hDbEvent) return; auto *szProto = Proto_GetBaseAccountName(si->hContact); - if (mir_strcmp(szProto, dbei.szModule) || dbei.eventType != EVENTTYPE_MESSAGE || !dbei.szUserId) + if (mir_strcmp(szProto, dbei.szModule) || !g_chatApi.DbEventIsShown(dbei) || !dbei.szUserId) return; CMStringA szText((char *)dbei.pBlob); diff --git a/src/mir_app/src/srmm_base.cpp b/src/mir_app/src/srmm_base.cpp index a2b0441945..abf909314a 100644 --- a/src/mir_app/src/srmm_base.cpp +++ b/src/mir_app/src/srmm_base.cpp @@ -24,9 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "stdafx.h" #include "chat.h" -#include "resource.h" #include "skin.h" -#include CSrmmBaseDialog::CSrmmBaseDialog(CMPluginBase &pPlugin, int idDialog, SESSION_INFO *si) : CDlgBase(pPlugin, idDialog), @@ -633,13 +631,13 @@ void CSrmmBaseDialog::UpdateChatLog() auto *szProto = Proto_GetBaseAccountName(m_hContact); for (MEVENT hDbEvent = m_hDbEventFirst; hDbEvent; hDbEvent = db_event_next(m_hContact, hDbEvent)) { DB::EventInfo dbei(hDbEvent); - if (dbei && !mir_strcmp(szProto, dbei.szModule) && dbei.eventType == EVENTTYPE_MESSAGE && dbei.szUserId) { + if (dbei && !mir_strcmp(szProto, dbei.szModule) && g_chatApi.DbEventIsShown(dbei) && dbei.szUserId) { auto *pUser = g_chatApi.UM_FindUser(m_si, Utf2T(dbei.szUserId)); if (pUser == nullptr) continue; Utf2T wszUserId(dbei.szUserId); - CMStringW wszText(Utf2T((char*)dbei.pBlob)); + CMStringW wszText(ptrW(DbEvent_GetTextW(&dbei, CP_ACP))); wszText.Replace(L"%", L"%%"); GCEVENT gce = { m_si, GC_EVENT_MESSAGE }; -- cgit v1.2.3