From cf91db5000d4f11745e2fe8bb6e7f5c6c6ba162a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 15 Mar 2023 18:08:51 +0300 Subject: SRMM: common code exctracted to a Srmm_AddEvent() function --- src/core/stdmsg/src/msgs.cpp | 32 +++++--------------------------- src/mir_app/src/mir_app.def | 1 + src/mir_app/src/mir_app64.def | 1 + src/mir_app/src/srmm_util.cpp | 17 +++++++++++++++++ 4 files changed, 24 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 121856ce37..d2b21d2173 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -65,13 +65,13 @@ static int SRMMStatusToPf2(int status) return 0; } -static int MessageEventAdded(WPARAM hContact, LPARAM lParam) +static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) { if (hContact == 0 || Contact::IsGroupChat(hContact)) return 0; DBEVENTINFO dbei = {}; - if (db_event_get(lParam, &dbei)) + if (db_event_get(hDbEvent, &dbei)) return 0; if (dbei.flags & (DBEF_SENT | DBEF_READ) || !(dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) @@ -105,17 +105,7 @@ static int MessageEventAdded(WPARAM hContact, LPARAM lParam) } } - wchar_t toolTip[256]; - mir_snwprintf(toolTip, TranslateT("Message from %s"), Clist_GetContactDisplayName(hContact)); - - CLISTEVENT cle = {}; - cle.hContact = hContact; - cle.hDbEvent = lParam; - cle.flags = CLEF_UNICODE; - cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); - cle.pszService = MS_MSG_READMESSAGE; - cle.szTooltip.w = toolTip; - g_clistApi.pfnAddEvent(&cle); + Srmm_AddEvent(hContact, hDbEvent); return 0; } @@ -283,20 +273,8 @@ static void RestoreUnreadMessageAlerts(void) } } - wchar_t toolTip[256]; - - CLISTEVENT cle = {}; - cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); - cle.pszService = MS_MSG_READMESSAGE; - cle.flags = CLEF_UNICODE; - cle.szTooltip.w = toolTip; - - for (auto &e : arEvents) { - mir_snwprintf(toolTip, TranslateT("Message from %s"), Clist_GetContactDisplayName(e->hContact)); - cle.hContact = e->hContact; - cle.hDbEvent = e->hEvent; - g_clistApi.pfnAddEvent(&cle); - } + for (auto &e : arEvents) + Srmm_AddEvent(e->hContact, e->hEvent); } void RegisterSRMMFonts(void); diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index e994cf236b..d662635947 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -824,3 +824,4 @@ Srmm_CreateHotkey @886 NONAME ?getMStringU@PROTO_INTERFACE@@QAE?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@PBD0@Z @939 NONAME ?OnEventDeleted@PROTO_INTERFACE@@UAEXII@Z @940 NONAME Chat_IsMuted @941 NONAME +?Srmm_AddEvent@@YGXII@Z @942 NONAME diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index c953a52884..e88cb7f181 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -824,3 +824,4 @@ Srmm_CreateHotkey @886 NONAME ?getMStringU@PROTO_INTERFACE@@QEAA?AV?$CMStringT@DV?$ChTraitsCRT@D@@@@PEBD0@Z @939 NONAME ?OnEventDeleted@PROTO_INTERFACE@@UEAAXII@Z @940 NONAME Chat_IsMuted @941 NONAME +?Srmm_AddEvent@@YAXII@Z @942 NONAME diff --git a/src/mir_app/src/srmm_util.cpp b/src/mir_app/src/srmm_util.cpp index 080ff4ae5d..a6750fd86b 100644 --- a/src/mir_app/src/srmm_util.cpp +++ b/src/mir_app/src/srmm_util.cpp @@ -114,6 +114,23 @@ MIR_APP_DLL(CMsgDialog*) Srmm_FindDialog(MCONTACT hContact) return (hwnd) ? (CMsgDialog *)GetWindowLongPtr(hwnd, GWLP_USERDATA) : nullptr; } +///////////////////////////////////////////////////////////////////////////////////////// + +MIR_APP_DLL(void) Srmm_AddEvent(MCONTACT hContact, MEVENT hDbEvent) +{ + wchar_t toolTip[256]; + mir_snwprintf(toolTip, TranslateT("Message from %s"), Clist_GetContactDisplayName(hContact)); + + CLISTEVENT cle = {}; + cle.hContact = hContact; + cle.hDbEvent = hDbEvent; + cle.flags = CLEF_UNICODE; + cle.hIcon = Skin_LoadIcon(SKINICON_EVENT_MESSAGE); + cle.pszService = MS_MSG_READMESSAGE; + cle.szTooltip.w = toolTip; + g_clistApi.pfnAddEvent(&cle); +} + ///////////////////////////////////////////////////////////////////////////////////////// // serializes all thread-unsafe operation to the first thread -- cgit v1.2.3