From 2439b18edd41da39ada76a0a6cece26151c34b46 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 4 Oct 2019 18:14:18 +0300 Subject: IEView: obsolete protocol management code removed --- plugins/ExternalAPI/m_ieview.h | 1 - plugins/IEView/src/ChatHTMLBuilder.cpp | 12 +-- plugins/IEView/src/HTMLBuilder.cpp | 127 ++++++++--------------------- plugins/IEView/src/HTMLBuilder.h | 27 +++--- plugins/IEView/src/HistoryHTMLBuilder.cpp | 9 +- plugins/IEView/src/MUCCHTMLBuilder.cpp | 20 ++--- plugins/IEView/src/ScriverHTMLBuilder.cpp | 9 +- plugins/IEView/src/TabSRMMHTMLBuilder.cpp | 10 +-- plugins/IEView/src/TemplateHTMLBuilder.cpp | 37 ++++----- plugins/IEView/src/TextToken.cpp | 4 +- plugins/IEView/src/TextToken.h | 2 +- 11 files changed, 92 insertions(+), 166 deletions(-) (limited to 'plugins') diff --git a/plugins/ExternalAPI/m_ieview.h b/plugins/ExternalAPI/m_ieview.h index 1e5e239892..7b5b866634 100644 --- a/plugins/ExternalAPI/m_ieview.h +++ b/plugins/ExternalAPI/m_ieview.h @@ -154,7 +154,6 @@ struct IEVIEWEVENT }; int count; // number of events to log int codepage; // ANSI codepage - const char *pszProto; // Name of the protocol }; #define MS_IEVIEW_EVENT "IEVIEW/Event" diff --git a/plugins/IEView/src/ChatHTMLBuilder.cpp b/plugins/IEView/src/ChatHTMLBuilder.cpp index 33f0f9e1f1..0a108fb138 100644 --- a/plugins/IEView/src/ChatHTMLBuilder.cpp +++ b/plugins/IEView/src/ChatHTMLBuilder.cpp @@ -97,7 +97,7 @@ void ChatHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) LOGFONTA lf; COLORREF color; - ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto); + ProtocolSettings *protoSettings = getChatProtocolSettings(event->hContact); if (protoSettings == nullptr) return; @@ -170,14 +170,14 @@ void ChatHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) ptrA szName, szText; if (eventData->dwFlags & IEEDF_UNICODE_TEXT) - szText = encodeUTF8(NULL, event->pszProto, eventData->szText.w, ENF_ALL | ENF_CHAT_FORMATTING, isSent); + szText = encodeUTF8(NULL, eventData->szText.w, ENF_ALL | ENF_CHAT_FORMATTING, isSent); else - szText = encodeUTF8(NULL, event->pszProto, eventData->szText.a, ENF_ALL | ENF_CHAT_FORMATTING, isSent); + szText = encodeUTF8(NULL, eventData->szText.a, ENF_ALL | ENF_CHAT_FORMATTING, isSent); if (eventData->dwFlags & IEEDF_UNICODE_NICK) - szName = encodeUTF8(NULL, event->pszProto, eventData->szNick.w, ENF_NAMESMILEYS, true); + szName = encodeUTF8(NULL, eventData->szNick.w, ENF_NAMESMILEYS, true); else - szName = encodeUTF8(NULL, event->pszProto, eventData->szNick.a, ENF_NAMESMILEYS, true); + szName = encodeUTF8(NULL, eventData->szNick.a, ENF_NAMESMILEYS, true); if (eventData->iType == IEED_GC_EVENT_MESSAGE) { iconFile = isSent ? "message_out_chat.gif" : "message_in_chat.gif"; @@ -255,7 +255,7 @@ void ChatHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) void ChatHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) { - ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto); + ProtocolSettings *protoSettings = getChatProtocolSettings(event->hContact); if (protoSettings != nullptr) appendEventNonTemplate(view, event); } diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 5995a342b3..5ec5978cb1 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -27,7 +27,6 @@ HTMLBuilder::HTMLBuilder() { lastIEViewEvent.iType = IEE_LOG_MEM_EVENTS; lastIEViewEvent.codepage = CP_ACP; - lastIEViewEvent.pszProto = nullptr; lastIEViewEvent.count = 0; lastIEViewEvent.dwFlags = 0; lastIEViewEvent.hContact = NULL; @@ -37,11 +36,9 @@ HTMLBuilder::HTMLBuilder() HTMLBuilder::~HTMLBuilder() { - if (lastIEViewEvent.pszProto != nullptr) - mir_free((void*)lastIEViewEvent.pszProto); } -bool HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *text, CMStringW &str, int level, int flags, bool isSent) +bool HTMLBuilder::encode(MCONTACT hContact, const wchar_t *text, CMStringW &str, int level, int flags, bool isSent) { TextToken *token = nullptr, *token2; switch (level) { @@ -62,7 +59,7 @@ bool HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *te break; case 3: if ((flags & ENF_SMILEYS) || ((Options::generalFlags & Options::GENERAL_SMILEYINNAMES) && (flags & ENF_NAMESMILEYS))) - token = TextToken::tokenizeSmileys(hContact, proto, text, isSent); + token = TextToken::tokenizeSmileys(hContact, text, isSent); break; } if (token != nullptr) { @@ -70,7 +67,7 @@ bool HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *te bool skip = false; token2 = token->getNext(); if (token->getType() == TextToken::TEXT) - skip = encode(hContact, proto, token->getTextW(), str, level + 1, flags, isSent); + skip = encode(hContact, token->getTextW(), str, level + 1, flags, isSent); if (!skip) token->toString(str); delete token; @@ -80,74 +77,44 @@ bool HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *te return false; } -char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const char *proto, const wchar_t *wtext, int flags, bool isSent) +char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const wchar_t *wtext, int flags, bool isSent) { if (wtext == nullptr) return nullptr; CMStringW str; - encode(hContact, proto, wtext, str, 0, flags, isSent); + encode(hContact, wtext, str, 0, flags, isSent); return mir_utf8encodeW(str); } -char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const char *proto, const char *text, int flags, bool isSent) +char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const char *text, int flags, bool isSent) { if (text == nullptr) return nullptr; - return encodeUTF8(hContact, proto, _A2T(text), flags, isSent); + return encodeUTF8(hContact, _A2T(text), flags, isSent); } -char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const char *proto, const char *text, int cp, int flags, bool isSent) +char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const char *text, int cp, int flags, bool isSent) { if (text == nullptr) return nullptr; ptrW wtext(mir_a2u_cp(text, cp)); - return encodeUTF8(hContact, proto, wtext, flags, isSent); + return encodeUTF8(hContact, wtext, flags, isSent); } -char* HTMLBuilder::getProto(MCONTACT hContact) -{ - return mir_strdup(GetContactProto(hContact)); -} - -char* HTMLBuilder::getProto(const char *proto, MCONTACT hContact) -{ - if (proto != nullptr) - return mir_strdup(proto); - - return mir_strdup(GetContactProto(hContact)); -} - -char* HTMLBuilder::getRealProto(MCONTACT hContact) +const char* HTMLBuilder::getRealProto(MCONTACT hContact) { if (hContact == NULL) return nullptr; - char *szProto = mir_strdup(GetContactProto(hContact)); - if (szProto != nullptr && !mir_strcmp(szProto, META_PROTO)) { - hContact = db_mc_getMostOnline(hContact); - if (hContact != NULL) - replaceStr(szProto, GetContactProto(hContact)); - } - return szProto; -} - -char* HTMLBuilder::getRealProto(MCONTACT hContact, const char *szProto) -{ - if (szProto != nullptr && !mir_strcmp(szProto, META_PROTO)) { - hContact = db_mc_getMostOnline(hContact); - if (hContact != NULL) - return mir_strdup(GetContactProto(hContact)); - } - return mir_strdup(szProto); + return GetContactProto(getRealContact(hContact)); } MCONTACT HTMLBuilder::getRealContact(MCONTACT hContact) { - char *szProto = GetContactProto(hContact); - if (szProto != nullptr && !mir_strcmp(szProto, META_PROTO)) + if (db_mc_isMeta(hContact)) hContact = db_mc_getMostOnline(hContact); return hContact; } @@ -207,11 +174,10 @@ wchar_t* HTMLBuilder::getContactName(MCONTACT hContact, const char *szProto) return mir_wstrdup(TranslateT("(Unknown Contact)")); } -char* HTMLBuilder::getEncodedContactName(MCONTACT hContact, const char* szProto, const char* szSmileyProto) +char* HTMLBuilder::getEncodedContactName(MCONTACT hContact, const char *szProto) { ptrW name(getContactName(hContact, szProto)); - return encodeUTF8(hContact, szSmileyProto, - (name != NULL) ? name : TranslateT("(Unknown Contact)"), ENF_NAMESMILEYS, true); + return encodeUTF8(hContact, (name != NULL) ? name : TranslateT("(Unknown Contact)"), ENF_NAMESMILEYS, true); } void HTMLBuilder::appendEventNew(IEView *view, IEVIEWEVENT *event) @@ -226,22 +192,16 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) MEVENT hDbEvent = event->hDbEventFirst; event->hDbEventFirst = NULL; - ptrA szProto; - if (event->pszProto != nullptr) - szProto = mir_strdup(event->pszProto); - else - szProto = getProto(event->hContact); + const char *szProto = GetContactProto(event->hContact); - IEVIEWEVENT newEvent = { sizeof(IEVIEWEVENT) }; + IEVIEWEVENT newEvent = {}; newEvent.iType = IEE_LOG_MEM_EVENTS; newEvent.codepage = CP_ACP; newEvent.codepage = event->codepage; - newEvent.pszProto = szProto; - newEvent.count = 0; newEvent.dwFlags = event->dwFlags; newEvent.hContact = event->hContact; newEvent.hwnd = event->hwnd; - newEvent.eventData = nullptr; + for (int eventIdx = 0; hDbEvent != NULL && (eventIdx < event->count || event->count == -1); eventIdx++) { DBEVENTINFO dbei = {}; dbei.cbBlob = db_event_getBlobSize(hDbEvent); @@ -333,49 +293,33 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) } } -ProtocolSettings* HTMLBuilder::getSRMMProtocolSettings(const char *protocolName) -{ - ProtocolSettings *protoSettings = Options::getProtocolSettings(protocolName); - if (protoSettings == nullptr || !protoSettings->isSRMMEnable()) - protoSettings = Options::getDefaultSettings(); - - return protoSettings; -} - ProtocolSettings* HTMLBuilder::getSRMMProtocolSettings(MCONTACT hContact) { - return getSRMMProtocolSettings(ptrA(getRealProto(hContact))); -} - -ProtocolSettings* HTMLBuilder::getHistoryProtocolSettings(const char *protocolName) -{ - ProtocolSettings *protoSettings = Options::getProtocolSettings(protocolName); - if (protoSettings == nullptr || !protoSettings->isHistoryEnable()) - protoSettings = Options::getDefaultSettings(); + auto *protoSettings = Options::getProtocolSettings(getRealProto(hContact)); + if (protoSettings != nullptr && protoSettings->isSRMMEnable()) + return protoSettings; - return protoSettings; + return Options::getDefaultSettings(); } ProtocolSettings* HTMLBuilder::getHistoryProtocolSettings(MCONTACT hContact) { - if (hContact != NULL) - return getHistoryProtocolSettings(ptrA(getRealProto(hContact))); + if (hContact != NULL) { + auto *protoSettings = Options::getProtocolSettings(getRealProto(hContact)); + if (protoSettings != nullptr && protoSettings->isHistoryEnable()) + return protoSettings; + } return Options::getDefaultSettings(); } -ProtocolSettings* HTMLBuilder::getChatProtocolSettings(const char *protocolName) -{ - ProtocolSettings *protoSettings = Options::getProtocolSettings(protocolName); - if (protoSettings == nullptr || !protoSettings->isChatEnable()) - protoSettings = Options::getDefaultSettings(); - - return protoSettings; -} - ProtocolSettings* HTMLBuilder::getChatProtocolSettings(MCONTACT hContact) { - return getChatProtocolSettings(ptrA(getRealProto(hContact))); + auto *protoSettings = Options::getProtocolSettings(getRealProto(hContact)); + if (protoSettings != nullptr && protoSettings->isChatEnable()) + return protoSettings; + + return Options::getDefaultSettings(); } void HTMLBuilder::setLastIEViewEvent(IEVIEWEVENT *event) @@ -388,13 +332,6 @@ void HTMLBuilder::setLastIEViewEvent(IEVIEWEVENT *event) lastIEViewEvent.hContact = event->hContact; lastIEViewEvent.hwnd = event->hwnd; lastIEViewEvent.eventData = nullptr; - if (lastIEViewEvent.pszProto != nullptr) - mir_free((void*)lastIEViewEvent.pszProto); - - if (event->pszProto != nullptr) - lastIEViewEvent.pszProto = mir_strdup(event->pszProto); - else - lastIEViewEvent.pszProto = getProto(event->hContact); } void HTMLBuilder::clear(IEView *view, IEVIEWEVENT *event) @@ -402,7 +339,7 @@ void HTMLBuilder::clear(IEView *view, IEVIEWEVENT *event) if (event != nullptr) { setLastIEViewEvent(event); - if (lastIEViewEvent.pszProto != nullptr || event->hContact == NULL) + if (event->hContact == NULL || GetContactProto(lastIEViewEvent.hContact)) buildHead(view, &lastIEViewEvent); } } diff --git a/plugins/IEView/src/HTMLBuilder.h b/plugins/IEView/src/HTMLBuilder.h index dcf4324e58..02793c3cdc 100644 --- a/plugins/IEView/src/HTMLBuilder.h +++ b/plugins/IEView/src/HTMLBuilder.h @@ -49,31 +49,30 @@ protected: ENF_ALL = 255, ENF_CHAT_FORMATTING = 256 }; - // virtual char *encode(const char *text, const char *proto, bool replaceSmiley); - virtual char* encodeUTF8(MCONTACT hContact, const char *proto, const wchar_t *text, int flags, bool isSent); - virtual char* encodeUTF8(MCONTACT hContact, const char *proto, const char *text, int flags, bool isSent); - virtual char* encodeUTF8(MCONTACT hContact, const char *proto, const char *text, int cp, int flags, bool isSent); - virtual bool encode(MCONTACT hContact, const char *proto, const wchar_t *text, CMStringW &str, int level, int flags, bool isSent); - virtual char* getProto(MCONTACT hContact); - virtual char* getProto(const char *proto, MCONTACT hContact); - virtual char* getRealProto(MCONTACT hContact); - virtual char* getRealProto(MCONTACT hContact, const char *proto); + + virtual char* encodeUTF8(MCONTACT hContact, const wchar_t *text, int flags, bool isSent); + virtual char* encodeUTF8(MCONTACT hContact, const char *text, int flags, bool isSent); + virtual char* encodeUTF8(MCONTACT hContact, const char *text, int cp, int flags, bool isSent); + virtual bool encode(MCONTACT hContact, const wchar_t *text, CMStringW &str, int level, int flags, bool isSent); + + virtual MCONTACT getRealContact(MCONTACT hContact); + virtual const char* getRealProto(MCONTACT hContact); + virtual wchar_t* getContactName(MCONTACT hContact, const char* szProto); - virtual char* getEncodedContactName(MCONTACT hContact, const char *szProto, const char *szSmileyProto); + virtual char* getEncodedContactName(MCONTACT hContact, const char *szProto); virtual void getUINs(MCONTACT hContact, char *&uinIn, char *&uinOut); - virtual MCONTACT getRealContact(MCONTACT hContact); + virtual DWORD getLastEventTime(); virtual void setLastEventTime(DWORD); + virtual int getLastEventType(); virtual void setLastEventType(int); + virtual bool isSameDate(time_t time1, time_t time2); virtual bool isDbEventShown(DBEVENTINFO * dbei) = 0; - virtual ProtocolSettings *getSRMMProtocolSettings(const char *protocolName); virtual ProtocolSettings *getSRMMProtocolSettings(MCONTACT hContact); - virtual ProtocolSettings *getHistoryProtocolSettings(const char *protocolName); virtual ProtocolSettings *getHistoryProtocolSettings(MCONTACT hContact); - virtual ProtocolSettings *getChatProtocolSettings(const char *protocolName); virtual ProtocolSettings *getChatProtocolSettings(MCONTACT hContact); void setLastIEViewEvent(IEVIEWEVENT *event); diff --git a/plugins/IEView/src/HistoryHTMLBuilder.cpp b/plugins/IEView/src/HistoryHTMLBuilder.cpp index 254da8de27..80eeb13765 100644 --- a/plugins/IEView/src/HistoryHTMLBuilder.cpp +++ b/plugins/IEView/src/HistoryHTMLBuilder.cpp @@ -221,7 +221,6 @@ void HistoryHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) void HistoryHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) { DWORD dwFlags = db_get_b(0, HPPMOD, SRMSGSET_SHOWICONS, 0) ? SMF_LOG_SHOWICONS : 0; - ptrA szRealProto(getRealProto(event->hContact)); IEVIEWEVENTDATA* eventData = event->eventData; for (int eventIdx = 0; eventData != nullptr && (eventIdx < event->count || event->count == -1); eventData = eventData->next, eventIdx++) { CMStringA str; @@ -230,14 +229,14 @@ void HistoryHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event { ptrA szName, szText; if (eventData->dwFlags & IEEDF_UNICODE_NICK) - szName = encodeUTF8(event->hContact, szRealProto, eventData->szNick.w, ENF_NAMESMILEYS, true); + szName = encodeUTF8(event->hContact, eventData->szNick.w, ENF_NAMESMILEYS, true); else - szName = encodeUTF8(event->hContact, szRealProto, eventData->szNick.a, ENF_NAMESMILEYS, true); + szName = encodeUTF8(event->hContact, eventData->szNick.a, ENF_NAMESMILEYS, true); if (eventData->dwFlags & IEEDF_UNICODE_TEXT) - szText = encodeUTF8(event->hContact, szRealProto, eventData->szText.w, ENF_ALL, isSent); + szText = encodeUTF8(event->hContact, eventData->szText.w, ENF_ALL, isSent); else - szText = encodeUTF8(event->hContact, szRealProto, eventData->szText.a, event->codepage, ENF_ALL, isSent); + szText = encodeUTF8(event->hContact, eventData->szText.a, event->codepage, ENF_ALL, isSent); /* History++-specific formatting */ const char *iconFile = nullptr; diff --git a/plugins/IEView/src/MUCCHTMLBuilder.cpp b/plugins/IEView/src/MUCCHTMLBuilder.cpp index dfe6f525eb..2fae53459e 100644 --- a/plugins/IEView/src/MUCCHTMLBuilder.cpp +++ b/plugins/IEView/src/MUCCHTMLBuilder.cpp @@ -115,7 +115,7 @@ void MUCCHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) { LOGFONTA lf; COLORREF color; - ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto); + ProtocolSettings *protoSettings = getChatProtocolSettings(event->hContact); if (protoSettings == nullptr) return; @@ -188,14 +188,14 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) ptrA szName, szText; if (eventData->iType == IEED_MUCC_EVENT_MESSAGE) { if (eventData->dwFlags & IEEDF_UNICODE_TEXT) - szText = encodeUTF8(NULL, event->pszProto, eventData->szText.w, ENF_ALL, isSent); + szText = encodeUTF8(NULL, eventData->szText.w, ENF_ALL, isSent); else - szText = encodeUTF8(NULL, event->pszProto, eventData->szText.a, ENF_ALL, isSent); + szText = encodeUTF8(NULL, eventData->szText.a, ENF_ALL, isSent); if (eventData->dwFlags & IEEDF_UNICODE_NICK) - szName = encodeUTF8(NULL, event->pszProto, eventData->szNick.w, ENF_NAMESMILEYS, true); + szName = encodeUTF8(NULL, eventData->szNick.w, ENF_NAMESMILEYS, true); else - szName = encodeUTF8(NULL, event->pszProto, eventData->szNick.a, ENF_NAMESMILEYS, true); + szName = encodeUTF8(NULL, eventData->szNick.a, ENF_NAMESMILEYS, true); str.AppendFormat("
", isSent ? "divOut" : "divIn"); if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) @@ -231,19 +231,19 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) className = "userJoined"; divName = "divUserJoined"; eventText = LPGEN("%s has joined."); - szText = encodeUTF8(NULL, event->pszProto, eventData->szNick.a, ENF_NONE, isSent); + szText = encodeUTF8(NULL, eventData->szNick.a, ENF_NONE, isSent); } else if (eventData->iType == IEED_MUCC_EVENT_LEFT) { className = "userLeft"; divName = "divUserJoined"; eventText = LPGEN("%s has left."); - szText = encodeUTF8(NULL, event->pszProto, eventData->szNick.a, ENF_NONE, isSent); + szText = encodeUTF8(NULL, eventData->szNick.a, ENF_NONE, isSent); } else { className = "topicChange"; divName = "divTopicChange"; eventText = LPGEN("The topic is %s."); - szText = encodeUTF8(NULL, event->pszProto, eventData->szText.a, ENF_ALL, isSent); + szText = encodeUTF8(NULL, eventData->szText.a, ENF_ALL, isSent); } str.AppendFormat("
", divName); if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) @@ -256,7 +256,7 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) } else if (eventData->iType == IEED_MUCC_EVENT_ERROR) { const char *className = "error"; - szText = encodeUTF8(NULL, event->pszProto, eventData->szText.a, ENF_NONE, isSent); + szText = encodeUTF8(NULL, eventData->szText.a, ENF_NONE, isSent); str.AppendFormat("
", "divError"); str.AppendFormat(" %s: %s", className, Translate("Error"), szText.get()); str.Append("
\n"); @@ -269,7 +269,7 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) void MUCCHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) { - ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto); + ProtocolSettings *protoSettings = getChatProtocolSettings(event->hContact); if (protoSettings != nullptr) appendEventNonTemplate(view, event); } diff --git a/plugins/IEView/src/ScriverHTMLBuilder.cpp b/plugins/IEView/src/ScriverHTMLBuilder.cpp index a47915f720..23f12d20f2 100644 --- a/plugins/IEView/src/ScriverHTMLBuilder.cpp +++ b/plugins/IEView/src/ScriverHTMLBuilder.cpp @@ -273,7 +273,6 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event dwFlags |= db_get_b(0, SRMMMOD, SRMSGSET_MESSAGEONNEWLINE, 0) ? SMF_LOG_MSGONNEWLINE : 0; dwFlags |= db_get_b(0, SRMMMOD, SRMSGSET_DRAWLINES, 0) ? SMF_LOG_DRAWLINES : 0; - ptrA szRealProto(getRealProto(event->hContact)); IEVIEWEVENTDATA* eventData = event->eventData; for (int eventIdx = 0; eventData != nullptr && (eventIdx < event->count || event->count == -1); eventData = eventData->next, eventIdx++) { const char *className = ""; @@ -290,14 +289,14 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event } ptrA szName, szText; if (eventData->dwFlags & IEEDF_UNICODE_NICK) - szName = encodeUTF8(event->hContact, szRealProto, eventData->szNick.w, ENF_NAMESMILEYS, true); + szName = encodeUTF8(event->hContact, eventData->szNick.w, ENF_NAMESMILEYS, true); else - szName = encodeUTF8(event->hContact, szRealProto, eventData->szNick.a, ENF_NAMESMILEYS, true); + szName = encodeUTF8(event->hContact, eventData->szNick.a, ENF_NAMESMILEYS, true); if (eventData->dwFlags & IEEDF_UNICODE_TEXT) - szText = encodeUTF8(event->hContact, szRealProto, eventData->szText.w, ENF_ALL, isSent); + szText = encodeUTF8(event->hContact, eventData->szText.w, ENF_ALL, isSent); else - szText = encodeUTF8(event->hContact, szRealProto, eventData->szText.a, event->codepage, ENF_ALL, isSent); + szText = encodeUTF8(event->hContact, eventData->szText.a, event->codepage, ENF_ALL, isSent); /* Scriver-specific formatting */ if ((dwFlags & SMF_LOG_DRAWLINES) && isGroupBreak && getLastEventType() != -1) { diff --git a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp index 67b32c90f1..2eeb4baca9 100644 --- a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp +++ b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp @@ -298,7 +298,6 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event dwFlags2 |= MWF_SHOW_MICROLF; dwFlags2 |= db_get_b(0, SRMSGMOD_T, "followupts", 1) ? MWF_SHOW_MARKFOLLOWUPTS : 0; - char *szRealProto = getRealProto(event->hContact); IEVIEWEVENTDATA* eventData = event->eventData; for (int eventIdx = 0; eventData != nullptr && (eventIdx < event->count || event->count == -1); eventData = eventData->next, eventIdx++) { if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_FILE || eventData->iType == IEED_EVENT_STATUSCHANGE) { @@ -316,14 +315,14 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event ptrA szName, szText; if (eventData->dwFlags & IEEDF_UNICODE_NICK) - szName = encodeUTF8(event->hContact, szRealProto, eventData->szNick.w, ENF_NAMESMILEYS, true); + szName = encodeUTF8(event->hContact, eventData->szNick.w, ENF_NAMESMILEYS, true); else - szName = encodeUTF8(event->hContact, szRealProto, eventData->szNick.a, ENF_NAMESMILEYS, true); + szName = encodeUTF8(event->hContact, eventData->szNick.a, ENF_NAMESMILEYS, true); if (eventData->dwFlags & IEEDF_UNICODE_TEXT) - szText = encodeUTF8(event->hContact, szRealProto, eventData->szText.w, ENF_ALL, isSent); + szText = encodeUTF8(event->hContact, eventData->szText.w, ENF_ALL, isSent); else - szText = encodeUTF8(event->hContact, szRealProto, eventData->szText.a, event->codepage, ENF_ALL, isSent); + szText = encodeUTF8(event->hContact, eventData->szText.a, event->codepage, ENF_ALL, isSent); /* TabSRMM-specific formatting */ CMStringA str; @@ -406,7 +405,6 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event } } - mir_free(szRealProto); view->documentClose(); } diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp index 30dc664cc2..df46c30801 100644 --- a/plugins/IEView/src/TemplateHTMLBuilder.cpp +++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp @@ -120,8 +120,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr char *szStatusMsg = nullptr; MCONTACT hRealContact = getRealContact(event->hContact); - char *szRealProto = getProto(hRealContact); - char *szProto = getProto(event->pszProto, event->hContact); + const char *szRealProto = GetContactProto(hRealContact); TemplateMap *tmpm = getTemplateMap(protoSettings); if (tmpm == nullptr) @@ -140,8 +139,8 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr char *szBase = mir_utf8encode(tempBase); getUINs(event->hContact, szUINIn, szUINOut); if (getFlags(protoSettings) & Options::LOG_SHOW_NICKNAMES) { - szNameOut = getEncodedContactName(NULL, szProto, szRealProto); - szNameIn = getEncodedContactName(event->hContact, szProto, szRealProto); + szNameOut = getEncodedContactName(NULL, szRealProto); + szNameIn = getEncodedContactName(event->hContact, szRealProto); } else { szNameOut = mir_strdup(" "); @@ -174,13 +173,13 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr db_free(&dbv); } - ptrW tszNick(Contact_GetInfo(CNF_NICK, event->hContact, szProto)); + ptrW tszNick(Contact_GetInfo(CNF_NICK, event->hContact, szRealProto)); if (tszNick != nullptr) szNickIn = encodeUTF8(event->hContact, szRealProto, tszNick, ENF_NAMESMILEYS, true); - tszNick = Contact_GetInfo(CNF_CUSTOMNICK, 0, szProto); + tszNick = Contact_GetInfo(CNF_CUSTOMNICK, 0, szRealProto); if (tszNick == nullptr) - Contact_GetInfo(CNF_NICK, 0, szProto); + Contact_GetInfo(CNF_NICK, 0, szRealProto); if (tszNick != nullptr) szNickOut = encodeUTF8(event->hContact, szRealProto, tszNick, ENF_NAMESMILEYS, true); @@ -248,8 +247,6 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr view->write(str); mir_free(szBase); - mir_free(szRealProto); - mir_free(szProto); mir_free(szUINIn); mir_free(szUINOut); mir_free(szNoAvatar); @@ -288,8 +285,8 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, bool isGrouping = false; MCONTACT hRealContact = getRealContact(event->hContact); - char *szRealProto = getProto(hRealContact); - char *szProto = getProto(event->pszProto, event->hContact); + const char *szRealProto = GetContactProto(hRealContact); + const char *szProto = GetContactProto(event->hContact); tempBase[0] = '\0'; TemplateMap *tmpm = getTemplateMap(protoSettings); @@ -311,8 +308,8 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, getUINs(event->hContact, szUINIn, szUINOut); if (event->hContact != NULL) { - szNameOut = getEncodedContactName(NULL, szProto, szRealProto); - szNameIn = getEncodedContactName(event->hContact, szProto, szRealProto); + szNameOut = getEncodedContactName(NULL, szRealProto); + szNameIn = getEncodedContactName(event->hContact, szRealProto); } else { szNameOut = mir_strdup(" "); @@ -390,18 +387,18 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, char *szName = nullptr, *szText = nullptr, *szFileDesc = nullptr; if (event->eventData->dwFlags & IEEDF_UNICODE_NICK) - szName = encodeUTF8(event->hContact, szRealProto, eventData->szNick.w, ENF_NAMESMILEYS, true); + szName = encodeUTF8(event->hContact, eventData->szNick.w, ENF_NAMESMILEYS, true); else - szName = encodeUTF8(event->hContact, szRealProto, eventData->szNick.a, ENF_NAMESMILEYS, true); + szName = encodeUTF8(event->hContact, eventData->szNick.a, ENF_NAMESMILEYS, true); if (eventData->dwFlags & IEEDF_UNICODE_TEXT) - szText = encodeUTF8(event->hContact, szRealProto, eventData->szText.w, ENF_ALL, isSent); + szText = encodeUTF8(event->hContact, eventData->szText.w, ENF_ALL, isSent); else - szText = encodeUTF8(event->hContact, szRealProto, eventData->szText.a, event->codepage, ENF_ALL, isSent); + szText = encodeUTF8(event->hContact, eventData->szText.a, event->codepage, ENF_ALL, isSent); if (eventData->dwFlags & IEEDF_UNICODE_TEXT2) - szFileDesc = encodeUTF8(event->hContact, szRealProto, eventData->szText2.w, 0, isSent); + szFileDesc = encodeUTF8(event->hContact, eventData->szText2.w, 0, isSent); else - szFileDesc = encodeUTF8(event->hContact, szRealProto, eventData->szText2.a, event->codepage, 0, isSent); + szFileDesc = encodeUTF8(event->hContact, eventData->szText2.a, event->codepage, 0, isSent); if (eventData->iType == IEED_EVENT_MESSAGE) { if (!isRTL) { @@ -548,8 +545,6 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, } } mir_free(szBase); - mir_free(szRealProto); - mir_free(szProto); mir_free(szUINIn); mir_free(szUINOut); mir_free(szNoAvatar); diff --git a/plugins/IEView/src/TextToken.cpp b/plugins/IEView/src/TextToken.cpp index 0e322d00ec..21c2e8452d 100644 --- a/plugins/IEView/src/TextToken.cpp +++ b/plugins/IEView/src/TextToken.cpp @@ -282,7 +282,7 @@ TextToken* TextToken::tokenizeLinks(const wchar_t *text) return firstToken; } -TextToken* TextToken::tokenizeSmileys(MCONTACT hContact, const char *proto, const wchar_t *text, bool isSent) +TextToken* TextToken::tokenizeSmileys(MCONTACT hContact, const wchar_t *text, bool isSent) { TextToken *firstToken = nullptr, *lastToken = nullptr; int l = (int)mir_wstrlen(text); @@ -291,7 +291,7 @@ TextToken* TextToken::tokenizeSmileys(MCONTACT hContact, const char *proto, cons SMADD_BATCHPARSE2 sp; sp.cbSize = sizeof(sp); - sp.Protocolname = proto; + sp.Protocolname = GetContactProto(hContact); sp.flag = SAFL_PATH | SAFL_UNICODE | (isSent ? SAFL_OUTGOING : 0); sp.wstr = (wchar_t *)text; sp.hContact = hContact; diff --git a/plugins/IEView/src/TextToken.h b/plugins/IEView/src/TextToken.h index 8cc048e18a..4d1fa10e38 100644 --- a/plugins/IEView/src/TextToken.h +++ b/plugins/IEView/src/TextToken.h @@ -85,7 +85,7 @@ public: static wchar_t* htmlEncode(const wchar_t *str); static TextToken* tokenizeLinks(const wchar_t *wtext); - static TextToken* tokenizeSmileys(MCONTACT hContact, const char *proto, const wchar_t *wtext, bool isSent); + static TextToken* tokenizeSmileys(MCONTACT hContact, const wchar_t *wtext, bool isSent); static TextToken* tokenizeBBCodes(const wchar_t *text); static TextToken* tokenizeChatFormatting(const wchar_t *text); }; -- cgit v1.2.3