From 37f0dfdfac4dc0af578769b02e29efb9926415bb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 6 Apr 2013 21:07:53 +0000 Subject: postfix to the standard functions patch by Mataes git-svn-id: http://svn.miranda-ng.org/main/trunk@4351 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/IEView/src/MUCCHTMLBuilder.cpp | 82 ++++++++++++++++------------------ 1 file changed, 39 insertions(+), 43 deletions(-) (limited to 'plugins/IEView/src/MUCCHTMLBuilder.cpp') diff --git a/plugins/IEView/src/MUCCHTMLBuilder.cpp b/plugins/IEView/src/MUCCHTMLBuilder.cpp index 6787de8e11..ee70762939 100644 --- a/plugins/IEView/src/MUCCHTMLBuilder.cpp +++ b/plugins/IEView/src/MUCCHTMLBuilder.cpp @@ -109,9 +109,7 @@ char *MUCCHTMLBuilder::timestampToString(DWORD dwData, time_t check) } CallService(MS_DB_TIME_TIMESTAMPTOSTRING, check, (LPARAM) & dbtts); strncat(szResult, str, 500); - char *tmp = mir_utf8encode(szResult); - lstrcpynA(szResult, tmp, 500); - mir_free(tmp); + lstrcpynA(szResult, mir_ptr(mir_utf8encode(szResult)), 500); return szResult; } @@ -192,40 +190,40 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) { int isSent = eventData->bIsMe; int outputSize; char *output = NULL; - char *szName = NULL, *szText = NULL; + mir_ptr szName, szText; if (eventData->iType == IEED_MUCC_EVENT_MESSAGE) { - if (eventData->dwFlags & IEEDF_UNICODE_TEXT) { + if (eventData->dwFlags & IEEDF_UNICODE_TEXT) szText = encodeUTF8(NULL, event->pszProto, eventData->pszTextW, ENF_ALL, isSent); - } else { + else szText = encodeUTF8(NULL, event->pszProto, eventData->pszText, ENF_ALL, isSent); - } - if (eventData->dwFlags & IEEDF_UNICODE_NICK) { + + if (eventData->dwFlags & IEEDF_UNICODE_NICK) szName = encodeUTF8(NULL, event->pszProto, eventData->pszNickW, ENF_NAMESMILEYS, true); - } else { + else szName = encodeUTF8(NULL, event->pszProto, eventData->pszNick, ENF_NAMESMILEYS, true); - } + Utils::appendText(&output, &outputSize, "
", isSent ? "divOut" : "divIn"); - if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) { + if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) Utils::appendText(&output, &outputSize, "%s ", isSent ? "timestamp" : "timestamp", timestampToString(dwData, eventData->time)); - } - if (dwData & IEEDD_MUCC_SHOW_NICK) { + + if (dwData & IEEDD_MUCC_SHOW_NICK) Utils::appendText(&output, &outputSize, "%s: ", isSent ? "nameOut" : "nameIn", szName); - } - if (dwData & IEEDD_MUCC_MSG_ON_NEW_LINE) { + + if (dwData & IEEDD_MUCC_MSG_ON_NEW_LINE) Utils::appendText(&output, &outputSize, "
"); - } + const char *className = isSent ? "messageOut" : "messageIn"; - if (eventData->dwFlags & IEEDF_FORMAT_SIZE && eventData->fontSize > 0) { + if (eventData->dwFlags & IEEDF_FORMAT_SIZE && eventData->fontSize > 0) Utils::appendText(&style, &styleSize, "font-size:%dpt;", eventData->fontSize); - } - if (eventData->dwFlags & IEEDF_FORMAT_COLOR && eventData->color!=0xFFFFFFFF) { + + if (eventData->dwFlags & IEEDF_FORMAT_COLOR && eventData->color!=0xFFFFFFFF) Utils::appendText(&style, &styleSize, "color:#%06X;", ((eventData->color & 0xFF) << 16) | (eventData->color & 0xFF00) | ((eventData->color & 0xFF0000) >> 16)); - } - if (eventData->dwFlags & IEEDF_FORMAT_FONT) { + + if (eventData->dwFlags & IEEDF_FORMAT_FONT) Utils::appendText(&style, &styleSize, "font-family:%s;", eventData->fontName); - } + if (eventData->dwFlags & IEEDF_FORMAT_STYLE) { Utils::appendText(&style, &styleSize, "font-weight: %s;", eventData->fontStyle & IE_FONT_BOLD ? "bold" : "normal"); Utils::appendText(&style, &styleSize, "font-style: %s;", eventData->fontStyle & IE_FONT_ITALIC ? "italic" : "normal"); @@ -233,64 +231,62 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) { } Utils::appendText(&output, &outputSize, "%s", className, style!=NULL ? style : "", szText); Utils::appendText(&output, &outputSize, "
\n"); - if (style!=NULL) free(style); - } else if (eventData->iType == IEED_MUCC_EVENT_JOINED || eventData->iType == IEED_MUCC_EVENT_LEFT || eventData->iType == IEED_MUCC_EVENT_TOPIC) { - const char *className, *divName; - const char *eventText; + if (style != NULL) + free(style); + } + else if (eventData->iType == IEED_MUCC_EVENT_JOINED || eventData->iType == IEED_MUCC_EVENT_LEFT || eventData->iType == IEED_MUCC_EVENT_TOPIC) { + const char *className, *divName, *eventText; if (eventData->iType == IEED_MUCC_EVENT_JOINED) { className = "userJoined"; divName = "divUserJoined"; eventText = LPGEN("%s has joined."); szText = encodeUTF8(NULL, event->pszProto, eventData->pszNick, ENF_NONE, isSent); - } else if (eventData->iType == IEED_MUCC_EVENT_LEFT) { + } + else if (eventData->iType == IEED_MUCC_EVENT_LEFT) { className = "userLeft"; divName = "divUserJoined"; eventText = LPGEN("%s has left."); szText = encodeUTF8(NULL, event->pszProto, eventData->pszNick, ENF_NONE, isSent); - } else { + } + else { className = "topicChange"; divName = "divTopicChange"; eventText = LPGEN("The topic is %s."); szText = encodeUTF8(NULL, event->pszProto, eventData->pszText, ENF_ALL, isSent); } Utils::appendText(&output, &outputSize, "
", divName); - if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) { + if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) Utils::appendText(&output, &outputSize, "%s ", isSent ? "timestamp" : "timestamp", timestampToString(dwData, eventData->time)); - } + Utils::appendText(&output, &outputSize, "", className); Utils::appendText(&output, &outputSize, Translate(eventText), szText); Utils::appendText(&output, &outputSize, ""); Utils::appendText(&output, &outputSize, "
\n"); - } else if (eventData->iType == IEED_MUCC_EVENT_ERROR) { + } + else if (eventData->iType == IEED_MUCC_EVENT_ERROR) { const char *className = "error"; szText = encodeUTF8(NULL, event->pszProto, eventData->pszText, ENF_NONE, isSent); Utils::appendText(&output, &outputSize, "
", "divError"); Utils::appendText(&output, &outputSize, " %s: %s", className, Translate("Error"), szText); Utils::appendText(&output, &outputSize, "
\n"); } - if (szName!=NULL) delete szName; - if (szText!=NULL) delete szText; + if (output != NULL) { view->write(output); free(output); } } -// view->scrollToBottom(); } -void MUCCHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) { +void MUCCHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) +{ ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto); - if (protoSettings == NULL) { - return; - } -// if (protoSettings->getSRMMMode() == Options::MODE_TEMPLATE) { - // appendEventTemplate(view, event); -// } else { + if (protoSettings != NULL) appendEventNonTemplate(view, event); -// } } -bool MUCCHTMLBuilder::isDbEventShown(DBEVENTINFO * dbei) { +bool MUCCHTMLBuilder::isDbEventShown(DBEVENTINFO *dbei) +{ return true; } -- cgit v1.2.3