diff options
author | George Hazan <ghazan@miranda.im> | 2023-04-14 18:48:50 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-04-14 18:48:50 +0300 |
commit | 357bb36c10405e7571f9ebd41d8e11837ebd6175 (patch) | |
tree | a1cd0dabe39ce913f7bf3356e47fc1d18363940e /src/core | |
parent | f12d6a4000cfce521392200635d1cadc63dba934 (diff) |
duplicate code removed
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/stdmsg/src/msgdialog.cpp | 10 | ||||
-rw-r--r-- | src/core/stdmsg/src/msglog.cpp | 14 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 13 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 5 |
4 files changed, 17 insertions, 25 deletions
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index cfeca501ef..ef28b8fd99 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -1209,14 +1209,14 @@ void CMsgDialog::DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis) /////////////////////////////////////////////////////////////////////////////////////////
-void CMsgDialog::EventAdded(MEVENT hDbEvent, const DBEVENTINFO &dbei)
+void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei)
{
if (m_hDbEventFirst == 0)
m_hDbEventFirst = hDbEvent;
bool isMessage = (dbei.eventType == EVENTTYPE_MESSAGE), isSent = ((dbei.flags & DBEF_SENT) != 0);
bool isActive = IsActive();
- if (DbEventIsShown(&dbei)) {
+ if (DbEventIsShown(dbei)) {
// Sounds *only* for sent messages, not for custom events
if (isMessage && !isSent) {
if (isActive)
@@ -1255,10 +1255,10 @@ bool CMsgDialog::GetFirstEvent() if (hPrevEvent == 0)
break;
- DBEVENTINFO dbei = {};
m_hDbEventFirst = hPrevEvent;
- db_event_get(hPrevEvent, &dbei);
- if (!DbEventIsShown(&dbei))
+
+ DB::EventInfo dbei(hPrevEvent, false);
+ if (!DbEventIsShown(dbei))
i++;
}
break;
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index d9c7c5f69b..063c990114 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -189,15 +189,9 @@ static void SetToStyle(int style, CMStringA &dest) dest.AppendFormat("\\f%u\\cf%u\\b%d\\i%d\\fs%u ", style, style, lf.lfWeight >= FW_BOLD ? 1 : 0, lf.lfItalic, 2 * abs(lf.lfHeight) * 74 / logPixelSY);
}
-bool DbEventIsForMsgWindow(const DBEVENTINFO *dbei)
+bool DbEventIsShown(const DB::EventInfo &dbei)
{
- DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType);
- return et && (et->flags & DETF_MSGWINDOW);
-}
-
-bool DbEventIsShown(const DBEVENTINFO *dbei)
-{
- return dbei->eventType == EVENTTYPE_MESSAGE || dbei->eventType == EVENTTYPE_FILE || DbEventIsForMsgWindow(dbei);
+ return dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE || dbei.isSrmm();
}
#define RTFPICTHEADERMAXSIZE 78
@@ -288,10 +282,10 @@ public: if (!dbei)
return false;
- if (!DbEventIsShown(&dbei))
+ if (!DbEventIsShown(dbei))
return false;
- if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
+ if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || dbei.isSrmm())) {
db_event_markRead(dat->hContact, dat->hDbEvent);
g_clistApi.pfnRemoveEvent(dat->hContact, dat->hDbEvent);
}
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index c7303ce01d..c0e216c262 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -70,11 +70,11 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) if (hContact == 0 || Contact::IsGroupChat(hContact))
return 0;
- DBEVENTINFO dbei = {};
- if (db_event_get(hDbEvent, &dbei))
+ DB::EventInfo dbei(hDbEvent, false);
+ if (!dbei)
return 0;
- if (dbei.flags & (DBEF_SENT | DBEF_READ) || !(dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei)))
+ if (dbei.markedRead() || !DbEventIsShown(dbei))
return 0;
bool bPopup = false;
@@ -265,12 +265,11 @@ static void RestoreUnreadMessageAlerts(void) for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) {
bool autoPopup = false;
- DBEVENTINFO dbei = {};
- dbei.cbBlob = 0;
- if (db_event_get(hDbEvent, &dbei))
+ DB::EventInfo dbei(hDbEvent, false);
+ if (!dbei)
continue;
- if (!dbei.markedRead() && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) {
+ if (!dbei.markedRead() && DbEventIsShown(dbei)) {
int windowAlreadyExists = Srmm_FindWindow(hContact) != nullptr;
if (windowAlreadyExists)
continue;
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 2dc98a0e66..ce79ce26fa 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -138,7 +138,7 @@ public: void CloseTab() override;
void DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis) override;
- void EventAdded(MEVENT, const DBEVENTINFO &dbei) override;
+ void EventAdded(MEVENT, const DB::EventInfo &dbei) override;
bool GetFirstEvent() override;
bool IsActive() const override;
void LoadSettings() override;
@@ -158,8 +158,7 @@ extern LIST<CMsgDialog> g_arDialogs; /////////////////////////////////////////////////////////////////////////////////////////
-bool DbEventIsForMsgWindow(const DBEVENTINFO *dbei);
-bool DbEventIsShown(const DBEVENTINFO *dbei);
+bool DbEventIsShown(const DB::EventInfo &dbei);
int SendMessageDirect(const wchar_t *szMsg, MCONTACT hContact);
INT_PTR SendMessageCmd(MCONTACT hContact, wchar_t *msg);
|