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/IEView/src/HTMLBuilder.cpp | 4 ++-- plugins/IEView/src/HTMLBuilder.h | 4 ++-- plugins/IEView/src/HistoryHTMLBuilder.cpp | 7 ++++--- plugins/IEView/src/HistoryHTMLBuilder.h | 2 +- plugins/IEView/src/ScriverHTMLBuilder.cpp | 6 +++--- plugins/IEView/src/ScriverHTMLBuilder.h | 2 +- plugins/IEView/src/TabSRMMHTMLBuilder.cpp | 8 ++++---- plugins/IEView/src/TabSRMMHTMLBuilder.h | 4 ++-- plugins/IEView/src/Utils.cpp | 12 ------------ plugins/IEView/src/Utils.h | 4 +--- 10 files changed, 20 insertions(+), 33 deletions(-) (limited to 'plugins/IEView/src') diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 2711b7da90..a314bbdce4 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -209,7 +209,7 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) g_clistApi.pfnRemoveEvent(event->hContact, hDbEvent); } - if (!isDbEventShown(&dbei)) { + if (!isDbEventShown(dbei)) { hDbEvent = db_event_next(event->hContact, hDbEvent); continue; } @@ -230,7 +230,7 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) eventData->szNick.w = getContactName(event->hContact, szProto); eventData->bIsMe = FALSE; } - if (dbei.eventType == EVENTTYPE_MESSAGE || Utils::DbEventIsForMsgWindow(&dbei)) { + if (dbei.eventType == EVENTTYPE_MESSAGE || dbei.isSrmm()) { eventData->szText.w = DbEvent_GetTextW(&dbei, newEvent.codepage); if (dbei.eventType == EVENTTYPE_MESSAGE) eventData->iType = IEED_EVENT_MESSAGE; diff --git a/plugins/IEView/src/HTMLBuilder.h b/plugins/IEView/src/HTMLBuilder.h index e1ebaa66d4..08d152d12b 100644 --- a/plugins/IEView/src/HTMLBuilder.h +++ b/plugins/IEView/src/HTMLBuilder.h @@ -62,14 +62,14 @@ protected: virtual char* getEncodedContactName(MCONTACT hContact, const char *szProto); virtual void getUINs(MCONTACT hContact, char *&uinIn, char *&uinOut); - virtual uint32_t getLastEventTime(); + virtual uint32_t getLastEventTime(); virtual void setLastEventTime(uint32_t); virtual int getLastEventType(); virtual void setLastEventType(int); virtual bool isSameDate(time_t time1, time_t time2); - virtual bool isDbEventShown(DBEVENTINFO * dbei) = 0; + virtual bool isDbEventShown(const DB::EventInfo &dbei) = 0; virtual ProtocolSettings *getSRMMProtocolSettings(MCONTACT hContact); virtual ProtocolSettings *getHistoryProtocolSettings(MCONTACT hContact); diff --git a/plugins/IEView/src/HistoryHTMLBuilder.cpp b/plugins/IEView/src/HistoryHTMLBuilder.cpp index 25014d36bb..66f17dad13 100644 --- a/plugins/IEView/src/HistoryHTMLBuilder.cpp +++ b/plugins/IEView/src/HistoryHTMLBuilder.cpp @@ -69,14 +69,15 @@ HistoryHTMLBuilder::HistoryHTMLBuilder() startedTime = time(0); } -bool HistoryHTMLBuilder::isDbEventShown(DBEVENTINFO *dbei) +bool HistoryHTMLBuilder::isDbEventShown(const DB::EventInfo &dbei) { - switch (dbei->eventType) { + switch (dbei.eventType) { case EVENTTYPE_MESSAGE: case EVENTTYPE_FILE: return 1; + default: - return Utils::DbEventIsForHistory(dbei); + return dbei.isHistory(); } } diff --git a/plugins/IEView/src/HistoryHTMLBuilder.h b/plugins/IEView/src/HistoryHTMLBuilder.h index f5023d7884..83b3f0e4b7 100644 --- a/plugins/IEView/src/HistoryHTMLBuilder.h +++ b/plugins/IEView/src/HistoryHTMLBuilder.h @@ -30,7 +30,7 @@ class HistoryHTMLBuilder :public TemplateHTMLBuilder protected: void loadMsgDlgFont(const char *, LOGFONTA *lf, COLORREF *colour, COLORREF *bkgColour); char *timestampToString(time_t check); - bool isDbEventShown(DBEVENTINFO *dbei); + bool isDbEventShown(const DB::EventInfo &dbei); void appendEventNonTemplate(IEView *, IEVIEWEVENT *event); const char *getTemplateFilename(ProtocolSettings *); int getFlags(ProtocolSettings *); diff --git a/plugins/IEView/src/ScriverHTMLBuilder.cpp b/plugins/IEView/src/ScriverHTMLBuilder.cpp index 19c3e85fae..76e8487fc1 100644 --- a/plugins/IEView/src/ScriverHTMLBuilder.cpp +++ b/plugins/IEView/src/ScriverHTMLBuilder.cpp @@ -68,15 +68,15 @@ ScriverHTMLBuilder::ScriverHTMLBuilder() startedTime = time(0); } -bool ScriverHTMLBuilder::isDbEventShown(DBEVENTINFO *dbei) +bool ScriverHTMLBuilder::isDbEventShown(const DB::EventInfo &dbei) { - switch (dbei->eventType) { + switch (dbei.eventType) { case EVENTTYPE_MESSAGE: return 1; case EVENTTYPE_FILE: return 1; default: - return Utils::DbEventIsForMsgWindow(dbei); + return dbei.isSrmm(); } } diff --git a/plugins/IEView/src/ScriverHTMLBuilder.h b/plugins/IEView/src/ScriverHTMLBuilder.h index 5b9d7170d0..45f138effb 100644 --- a/plugins/IEView/src/ScriverHTMLBuilder.h +++ b/plugins/IEView/src/ScriverHTMLBuilder.h @@ -30,7 +30,7 @@ class ScriverHTMLBuilder :public TemplateHTMLBuilder protected: void loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour); char *timestampToString(uint32_t dwFlags, time_t check, int groupStart); - bool isDbEventShown(DBEVENTINFO * dbei); + bool isDbEventShown(const DB::EventInfo &dbei); void appendEventNonTemplate(IEView *, IEVIEWEVENT *event); public: ScriverHTMLBuilder(); diff --git a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp index 85e6b8859e..a731831527 100644 --- a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp +++ b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp @@ -82,9 +82,9 @@ TabSRMMHTMLBuilder::TabSRMMHTMLBuilder() startedTime = time(0); } -bool TabSRMMHTMLBuilder::isDbEventShown(uint32_t dwFlags, DBEVENTINFO *dbei) +bool TabSRMMHTMLBuilder::isDbEventShown(uint32_t dwFlags, const DB::EventInfo &dbei) { - switch (dbei->eventType) { + switch (dbei.eventType) { case EVENTTYPE_MESSAGE: return 1; case EVENTTYPE_FILE: @@ -96,12 +96,12 @@ bool TabSRMMHTMLBuilder::isDbEventShown(uint32_t dwFlags, DBEVENTINFO *dbei) case EVENTTYPE_AUTHREQUEST: return 0; default: - return Utils::DbEventIsForMsgWindow(dbei); + return dbei.isSrmm(); } return 1; } -bool TabSRMMHTMLBuilder::isDbEventShown(DBEVENTINFO * dbei) +bool TabSRMMHTMLBuilder::isDbEventShown(const DB::EventInfo &dbei) { uint32_t dwFlags2 = db_get_b(0, SRMSGMOD_T, SRMSGSET_SHOWURLS, 0) ? MWF_SHOW_URLEVENTS : 0; dwFlags2 |= db_get_b(0, SRMSGMOD_T, SRMSGSET_SHOWFILES, 0) ? MWF_SHOW_FILEEVENTS : 0; diff --git a/plugins/IEView/src/TabSRMMHTMLBuilder.h b/plugins/IEView/src/TabSRMMHTMLBuilder.h index bfc7deb6ac..e2ffeed6f4 100644 --- a/plugins/IEView/src/TabSRMMHTMLBuilder.h +++ b/plugins/IEView/src/TabSRMMHTMLBuilder.h @@ -31,8 +31,8 @@ protected: virtual void loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour); char *timestampToString(uint32_t dwFlags, time_t check, int isGroupBreak); time_t getStartedTime(); - virtual bool isDbEventShown(uint32_t dwFlags, DBEVENTINFO * dbei); - bool isDbEventShown(DBEVENTINFO * dbei); + virtual bool isDbEventShown(uint32_t dwFlags, const DB::EventInfo &dbei); + bool isDbEventShown(const DB::EventInfo &dbei); void appendEventNonTemplate(IEView *, IEVIEWEVENT *event); public: TabSRMMHTMLBuilder(); diff --git a/plugins/IEView/src/Utils.cpp b/plugins/IEView/src/Utils.cpp index c29b4b3b21..ce3ebee636 100644 --- a/plugins/IEView/src/Utils.cpp +++ b/plugins/IEView/src/Utils.cpp @@ -115,15 +115,3 @@ void Utils::appendIcon(CMStringA &str, const char *iconFile) { str.AppendFormat(" ", workingDirUtf8, iconFile); } - -bool Utils::DbEventIsForMsgWindow(DBEVENTINFO *dbei) -{ - DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); - return et && (et->flags & DETF_MSGWINDOW); -} - -bool Utils::DbEventIsForHistory(DBEVENTINFO *dbei) -{ - DBEVENTTYPEDESCR *et = DbEvent_GetType(dbei->szModule, dbei->eventType); - return et && (et->flags & DETF_HISTORY); -} diff --git a/plugins/IEView/src/Utils.h b/plugins/IEView/src/Utils.h index 031e400bf4..173b451fc1 100644 --- a/plugins/IEView/src/Utils.h +++ b/plugins/IEView/src/Utils.h @@ -30,9 +30,7 @@ namespace Utils void convertPath(char *path); void convertPath(wchar_t *path); char *escapeString(const char *a); - int detectURL(const wchar_t *text); - bool DbEventIsForMsgWindow(DBEVENTINFO *dbei); - bool DbEventIsForHistory(DBEVENTINFO *dbei); + int detectURL(const wchar_t *text); }; #endif -- cgit v1.2.3