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 /plugins/Scriver | |
parent | f12d6a4000cfce521392200635d1cadc63dba934 (diff) |
duplicate code removed
Diffstat (limited to 'plugins/Scriver')
-rw-r--r-- | plugins/Scriver/src/msgdialog.cpp | 3 | ||||
-rw-r--r-- | plugins/Scriver/src/msglog.cpp | 16 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.cpp | 8 | ||||
-rw-r--r-- | plugins/Scriver/src/msgs.h | 7 | ||||
-rw-r--r-- | plugins/Scriver/src/msgutils.cpp | 9 |
5 files changed, 17 insertions, 26 deletions
diff --git a/plugins/Scriver/src/msgdialog.cpp b/plugins/Scriver/src/msgdialog.cpp index 4112c792de..1eab95ef1a 100644 --- a/plugins/Scriver/src/msgdialog.cpp +++ b/plugins/Scriver/src/msgdialog.cpp @@ -1071,8 +1071,7 @@ INT_PTR CMsgDialog::DlgProc(UINT msg, WPARAM wParam, LPARAM lParam) MEVENT hDbEvent = m_hDbUnreadEventFirst;
m_hDbUnreadEventFirst = 0;
while (hDbEvent != 0) {
- DBEVENTINFO dbei = {};
- db_event_get(hDbEvent, &dbei);
+ DB::EventInfo dbei(hDbEvent, false);
if (!(dbei.flags & DBEF_SENT) && DbEventIsMessageOrCustom(dbei))
g_clistApi.pfnRemoveEvent(m_hContact, hDbEvent);
hDbEvent = db_event_next(m_hContact, hDbEvent);
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index 0359c1cdf7..891edbcbeb 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -52,18 +52,12 @@ struct LogStreamData static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb);
-bool DbEventIsCustomForMsgWindow(const DBEVENTINFO &dbei)
+bool DbEventIsMessageOrCustom(const DB::EventInfo &dbei)
{
- DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei.szModule, dbei.eventType);
- return et && (et->flags & DETF_MSGWINDOW);
+ return dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE || dbei.isSrmm();
}
-bool DbEventIsMessageOrCustom(const DBEVENTINFO &dbei)
-{
- return dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_FILE || DbEventIsCustomForMsgWindow(dbei);
-}
-
-bool DbEventIsShown(const DBEVENTINFO &dbei)
+bool DbEventIsShown(const DB::EventInfo &dbei)
{
switch (dbei.eventType) {
case EVENTTYPE_MESSAGE:
@@ -75,7 +69,7 @@ bool DbEventIsShown(const DBEVENTINFO &dbei) return 0;
}
- return DbEventIsCustomForMsgWindow(dbei);
+ return dbei.isSrmm();
}
static void AppendUnicodeToBuffer(CMStringA &buf, const wchar_t *line)
@@ -861,7 +855,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG if (dbei && DbEventIsShown(dbei)) {
dat->buffer = dat->pLog->CreateRTFFromEvent(dbei, dat);
- if (!(dbei.flags & DBEF_SENT) && (dbei.eventType == EVENTTYPE_MESSAGE || DbEventIsCustomForMsgWindow(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/plugins/Scriver/src/msgs.cpp b/plugins/Scriver/src/msgs.cpp index b3e0026f77..0bbd71f0c7 100644 --- a/plugins/Scriver/src/msgs.cpp +++ b/plugins/Scriver/src/msgs.cpp @@ -84,8 +84,8 @@ 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.eventType == EVENTTYPE_MESSAGE && (dbei.flags & DBEF_READ))
@@ -236,8 +236,8 @@ static void RestoreUnreadMessageAlerts(void) for (auto &hContact : Contacts()) {
for (MEVENT hDbEvent = db_event_firstUnread(hContact); hDbEvent; hDbEvent = db_event_next(hContact, hDbEvent)) {
- DBEVENTINFO dbei = {};
- if (db_event_get(hDbEvent, &dbei))
+ DB::EventInfo dbei(hDbEvent, false);
+ if (!dbei)
continue;
if (dbei.markedRead() || !DbEventIsMessageOrCustom(dbei) || !Proto_GetBaseAccountName(hContact))
continue;
diff --git a/plugins/Scriver/src/msgs.h b/plugins/Scriver/src/msgs.h index ce0e5c082c..36b036f77c 100644 --- a/plugins/Scriver/src/msgs.h +++ b/plugins/Scriver/src/msgs.h @@ -131,7 +131,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;
void LoadSettings() override;
void SetStatusText(const wchar_t *, HICON) override;
@@ -192,9 +192,8 @@ public: #define EVENTTYPE_JABBER_CHATSTATES 2000
#define EVENTTYPE_JABBER_PRESENCE 2001
-bool DbEventIsShown(const DBEVENTINFO &dbei);
-bool DbEventIsCustomForMsgWindow(const DBEVENTINFO &dbei);
-bool DbEventIsMessageOrCustom(const DBEVENTINFO &dbei);
+bool DbEventIsShown(const DB::EventInfo &dbei);
+bool DbEventIsMessageOrCustom(const DB::EventInfo &dbei);
void LoadMsgLogIcons(void);
void FreeMsgLogIcons(void);
int IsAutoPopup(MCONTACT hContact);
diff --git a/plugins/Scriver/src/msgutils.cpp b/plugins/Scriver/src/msgutils.cpp index b2abbe2a55..c0ed8bca78 100644 --- a/plugins/Scriver/src/msgutils.cpp +++ b/plugins/Scriver/src/msgutils.cpp @@ -73,7 +73,7 @@ void CMsgDialog::DrawNickList(USERINFO *ui, DRAWITEMSTRUCT *dis) SelectObject(dis->hDC, hOldFont); } -void CMsgDialog::EventAdded(MEVENT hDbEvent, const DBEVENTINFO &dbei) +void CMsgDialog::EventAdded(MEVENT hDbEvent, const DB::EventInfo &dbei) { if (m_hDbEventFirst == 0) m_hDbEventFirst = hDbEvent; @@ -101,7 +101,7 @@ void CMsgDialog::EventAdded(MEVENT hDbEvent, const DBEVENTINFO &dbei) else SendMessage(m_hwnd, DM_REMAKELOG, 0, 0); - if (!(dbei.flags & DBEF_SENT) && !DbEventIsCustomForMsgWindow(dbei)) { + if (!(dbei.flags & DBEF_SENT) && !dbei.isSrmm()) { if (!bIsActive) { m_iShowUnread = 1; UpdateIcon(); @@ -121,15 +121,14 @@ bool CMsgDialog::GetFirstEvent() // This finds the first message to display, it works like shit m_hDbEventFirst = db_event_firstUnread(m_hContact); if (m_hDbEventFirst != 0) { - DBEVENTINFO dbei = {}; - db_event_get(m_hDbEventFirst, &dbei); + DB::EventInfo dbei(m_hDbEventFirst, false); if (DbEventIsMessageOrCustom(dbei) && !(dbei.flags & DBEF_READ) && !(dbei.flags & DBEF_SENT)) notifyUnread = true; } DB::ECPTR pCursor(DB::EventsRev(m_hContact, m_hDbEventFirst)); - DBEVENTINFO dbei = {}; + DB::EventInfo dbei; MEVENT hPrevEvent; switch (historyMode) { case LOADHISTORY_COUNT: |