From 357bb36c10405e7571f9ebd41d8e11837ebd6175 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 14 Apr 2023 18:48:50 +0300 Subject: duplicate code removed --- plugins/TabSRMM/src/functions.h | 3 +-- plugins/TabSRMM/src/mim.cpp | 5 ++--- plugins/TabSRMM/src/msgdlgother.cpp | 8 ++++---- plugins/TabSRMM/src/msglog.cpp | 16 +++++----------- plugins/TabSRMM/src/msgs.h | 2 +- 5 files changed, 13 insertions(+), 21 deletions(-) (limited to 'plugins/TabSRMM/src') diff --git a/plugins/TabSRMM/src/functions.h b/plugins/TabSRMM/src/functions.h index e7311632d2..08178c67c1 100644 --- a/plugins/TabSRMM/src/functions.h +++ b/plugins/TabSRMM/src/functions.h @@ -84,8 +84,7 @@ void TSAPI CacheMsgLogIcons(); void TSAPI CacheLogFonts(); void TSAPI LoadIconTheme(); -bool DbEventIsForMsgWindow(const DBEVENTINFO *dbei); -bool DbEventIsShown(const DBEVENTINFO *dbei); +bool DbEventIsShown(const DB::EventInfo &dbei); // custom tab control diff --git a/plugins/TabSRMM/src/mim.cpp b/plugins/TabSRMM/src/mim.cpp index 434472f9b3..07ad8f5f68 100644 --- a/plugins/TabSRMM/src/mim.cpp +++ b/plugins/TabSRMM/src/mim.cpp @@ -373,15 +373,14 @@ int CMimAPI::MessageEventAdded(WPARAM hContact, LPARAM hDbEvent) if (hContact == 0 || Contact::IsGroupChat(hContact)) return 0; - DBEVENTINFO dbei = {}; - db_event_get(hDbEvent, &dbei); + DB::EventInfo dbei(hDbEvent, false); auto *pDlg = Srmm_FindDialog(hContact); if (pDlg == nullptr) pDlg = Srmm_FindDialog(db_event_getContact(hDbEvent)); BOOL isCustomEvent = IsCustomEvent(dbei.eventType); - bool isShownCustomEvent = DbEventIsForMsgWindow(&dbei); + bool isShownCustomEvent = dbei.isSrmm(); if (dbei.markedRead() || (isCustomEvent && !isShownCustomEvent)) return 0; diff --git a/plugins/TabSRMM/src/msgdlgother.cpp b/plugins/TabSRMM/src/msgdlgother.cpp index abf577fd40..2360894d31 100644 --- a/plugins/TabSRMM/src/msgdlgother.cpp +++ b/plugins/TabSRMM/src/msgdlgother.cpp @@ -538,7 +538,7 @@ void CMsgDialog::EnableSending(bool bMode) const ///////////////////////////////////////////////////////////////////////////////////////// -void CMsgDialog::EventAdded(MEVENT hDbEvent, const DBEVENTINFO &dbei) +void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) { if (m_hDbEventFirst == 0) m_hDbEventFirst = hDbEvent; @@ -546,7 +546,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DBEVENTINFO &dbei) bool bIsStatusChangeEvent = IsStatusEvent(dbei.eventType); bool bDisableNotify = (dbei.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ)); - if (!DbEventIsShown(&dbei)) + if (!DbEventIsShown(dbei)) return; if (dbei.eventType == EVENTTYPE_MESSAGE && !(dbei.flags & (DBEF_SENT))) { @@ -655,7 +655,7 @@ bool CMsgDialog::GetFirstEvent() if (m_bActualHistory) historyMode = LOADHISTORY_COUNT; - DBEVENTINFO dbei = {}; + DB::EventInfo dbei; DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst)); switch (historyMode) { @@ -676,7 +676,7 @@ bool CMsgDialog::GetFirstEvent() dbei.cbBlob = 0; m_hDbEventFirst = hPrevEvent; db_event_get(m_hDbEventFirst, &dbei); - if (!DbEventIsShown(&dbei)) + if (!DbEventIsShown(dbei)) i++; } break; diff --git a/plugins/TabSRMM/src/msglog.cpp b/plugins/TabSRMM/src/msglog.cpp index 36c76a92ad..ca45b886fb 100644 --- a/plugins/TabSRMM/src/msglog.cpp +++ b/plugins/TabSRMM/src/msglog.cpp @@ -405,18 +405,12 @@ static char *CreateRTFTail() return mir_strdup("}"); } -bool DbEventIsShown(const DBEVENTINFO *dbei) +bool DbEventIsShown(const DB::EventInfo &dbei) { - if (!IsCustomEvent(dbei->eventType) || DbEventIsForMsgWindow(dbei)) + if (!IsCustomEvent(dbei.eventType) || dbei.isSrmm()) return 1; - return IsStatusEvent(dbei->eventType); -} - -bool DbEventIsForMsgWindow(const DBEVENTINFO *dbei) -{ - DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); - return et && (et->flags & DETF_MSGWINDOW); + return IsStatusEvent(dbei.eventType); } static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb) @@ -637,7 +631,7 @@ char* CLogWindow::CreateRTFFromDbEvent(LogStreamData *streamData) else { dbei.cbBlob = -1; db_event_get(streamData->hDbEvent, &dbei); - if (!DbEventIsShown(&dbei)) + if (!DbEventIsShown(dbei)) return nullptr; } @@ -647,7 +641,7 @@ char* CLogWindow::CreateRTFFromDbEvent(LogStreamData *streamData) BOOL isSent = (dbei.flags & DBEF_SENT); BOOL bIsStatusChangeEvent = IsStatusEvent(dbei.eventType); - if (!isSent && (bIsStatusChangeEvent || dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsForMsgWindow(&dbei))) { + if (!isSent && (bIsStatusChangeEvent || dbei.eventType == EVENTTYPE_MESSAGE || dbei.isSrmm())) { db_event_markRead(streamData->hContact, streamData->hDbEvent); g_clistApi.pfnRemoveEvent(streamData->hContact, streamData->hDbEvent); } diff --git a/plugins/TabSRMM/src/msgs.h b/plugins/TabSRMM/src/msgs.h index d3bdec4c3d..ba0af19cfd 100644 --- a/plugins/TabSRMM/src/msgs.h +++ b/plugins/TabSRMM/src/msgs.h @@ -596,7 +596,7 @@ public: void AddLog() override; 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; -- cgit v1.2.3