From 23da585729242bc135e7a6da0dc5bf699e6c9b54 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 19 Apr 2015 21:12:24 +0000 Subject: - all strings operations were rewritten using CMString instead of ugly self-made buffers; - CComPtr<> introduced to simplify COM calls processing; - version bump. git-svn-id: http://svn.miranda-ng.org/main/trunk@12946 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/IEView/src/TabSRMMHTMLBuilder.cpp | 137 ++++++++++++++---------------- 1 file changed, 66 insertions(+), 71 deletions(-) (limited to 'plugins/IEView/src/TabSRMMHTMLBuilder.cpp') diff --git a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp index d574d6b034..981ffc047d 100644 --- a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp +++ b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp @@ -203,8 +203,6 @@ void TabSRMMHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) { LOGFONTA lf; COLORREF color; - char *output = NULL; - int outputSize; ProtocolSettings *protoSettings = getSRMMProtocolSettings(event->hContact); if (protoSettings == NULL) @@ -214,19 +212,21 @@ void TabSRMMHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) buildHeadTemplate(view, event, protoSettings); return; } + + CMStringA str; if (protoSettings->getSRMMMode() == Options::MODE_CSS) { const char *externalCSS = protoSettings->getSRMMCssFilename(); if (strncmp(externalCSS, "http://", 7)) - Utils::appendText(&output, &outputSize, "\n", externalCSS); + str.AppendFormat("\n", externalCSS); else - Utils::appendText(&output, &outputSize, "\n", externalCSS); + str.AppendFormat("\n", externalCSS); } else { HDC hdc = GetDC(NULL); int logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY); ReleaseDC(NULL, hdc); DWORD dwFlags = db_get_dw(NULL, SRMSGMOD_T, "mwflags", MWF_LOG_DEFAULT); - Utils::appendText(&output, &outputSize, "\n"); - } - if (output != NULL) { - view->write(output); - free(output); + str.Append("\n"); } + + if (!str.IsEmpty()) + view->write(str); + setLastEventType(-1); } @@ -312,8 +308,6 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event char *szRealProto = getRealProto(event->hContact); IEVIEWEVENTDATA* eventData = event->eventData; for (int eventIdx = 0; eventData != NULL && (eventIdx < event->count || event->count == -1); eventData = eventData->next, eventIdx++) { - int outputSize; - char *output = NULL; if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_FILE || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_STATUSCHANGE) { bool isGroupBreak = true; bool isSent = (eventData->dwFlags & IEEDF_SENT) != 0; @@ -339,10 +333,11 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event szText = encodeUTF8(event->hContact, szRealProto, eventData->pszText, event->codepage, eventData->iType == IEED_EVENT_MESSAGE ? ENF_ALL : 0, isSent); /* TabSRMM-specific formatting */ + CMStringA str; if ((dwFlags & MWF_LOG_GRID) && isGroupBreak && getLastEventType() != -1) - Utils::appendText(&output, &outputSize, "
", isRTL ? isSent ? "divOutGridRTL" : "divInGridRTL" : isSent ? "divOutGrid" : "divInGrid"); + str.AppendFormat("
", isRTL ? isSent ? "divOutGridRTL" : "divInGridRTL" : isSent ? "divOutGrid" : "divInGrid"); else - Utils::appendText(&output, &outputSize, "
", isRTL ? isSent ? "divOutRTL" : "divInRTL" : isSent ? "divOut" : "divIn"); + str.AppendFormat("
", isRTL ? isSent ? "divOutRTL" : "divInRTL" : isSent ? "divOut" : "divIn"); if (dwFlags & MWF_LOG_SHOWICONS && isGroupBreak) { const char *iconFile = ""; @@ -357,47 +352,49 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event else if (eventData->iType == IEED_EVENT_STATUSCHANGE) iconFile = "status.gif"; - Utils::appendIcon(&output, &outputSize, iconFile); + Utils::appendIcon(str, iconFile); } if ((dwFlags & MWF_LOG_SWAPNICK) && (dwFlags & MWF_LOG_SHOWNICK) && isGroupBreak && (eventData->iType != IEED_EVENT_STATUSCHANGE)) { - const char *className = ""; - if (!isHistory) className = isSent ? "nameOut" : "nameIn"; - else className = isSent ? "hNameOut" : "hNameIn"; + const char *className; + if (!isHistory) + className = isSent ? "nameOut" : "nameIn"; + else + className = isSent ? "hNameOut" : "hNameIn"; if (dwFlags & MWF_LOG_UNDERLINE) - Utils::appendText(&output, &outputSize, "%s%s", - className, szName, (dwFlags & MWF_LOG_SHOWTIME) ? " " : ": "); + str.AppendFormat("%s%s", className, szName, (dwFlags & MWF_LOG_SHOWTIME) ? " " : ": "); else - Utils::appendText(&output, &outputSize, "%s%s", - className, szName, (dwFlags & MWF_LOG_SHOWTIME) ? " " : ": "); + str.AppendFormat("%s%s", className, szName, (dwFlags & MWF_LOG_SHOWTIME) ? " " : ": "); } if (dwFlags & MWF_LOG_SHOWTIME && (isGroupBreak || dwFlags2 & MWF_SHOW_MARKFOLLOWUPTS)) { - const char *className = ""; - if (!isHistory) className = isSent ? "timeOut" : "timeIn"; - else className = isSent ? "hTimeOut" : "hTimeIn"; + const char *className; + if (!isHistory) + className = isSent ? "timeOut" : "timeIn"; + else + className = isSent ? "hTimeOut" : "hTimeIn"; if (dwFlags & MWF_LOG_UNDERLINE) - Utils::appendText(&output, &outputSize, "%s%s", - className, timestampToString(dwFlags, eventData->time, isGroupBreak), - (!isGroupBreak || (eventData->iType == IEED_EVENT_STATUSCHANGE) || (dwFlags & MWF_LOG_SWAPNICK) || !(dwFlags & MWF_LOG_SHOWNICK)) ? ": " : " "); + str.AppendFormat("%s%s", className, timestampToString(dwFlags, eventData->time, isGroupBreak), + (!isGroupBreak || (eventData->iType == IEED_EVENT_STATUSCHANGE) || (dwFlags & MWF_LOG_SWAPNICK) || !(dwFlags & MWF_LOG_SHOWNICK)) ? ": " : " "); else - Utils::appendText(&output, &outputSize, "%s%s", - className, timestampToString(dwFlags, eventData->time, isGroupBreak), - (!isGroupBreak || (eventData->iType == IEED_EVENT_STATUSCHANGE) || (dwFlags & MWF_LOG_SWAPNICK) || !(dwFlags & MWF_LOG_SHOWNICK)) ? ": " : " "); + str.AppendFormat("%s%s", className, timestampToString(dwFlags, eventData->time, isGroupBreak), + (!isGroupBreak || (eventData->iType == IEED_EVENT_STATUSCHANGE) || (dwFlags & MWF_LOG_SWAPNICK) || !(dwFlags & MWF_LOG_SHOWNICK)) ? ": " : " "); } if ((eventData->iType == IEED_EVENT_STATUSCHANGE) || ((dwFlags & MWF_LOG_SHOWNICK) && !(dwFlags & MWF_LOG_SWAPNICK) && isGroupBreak)) { if (eventData->iType == IEED_EVENT_STATUSCHANGE) - Utils::appendText(&output, &outputSize, "%s ", szName); + str.AppendFormat("%s ", szName); else { const char *className = ""; - if (!isHistory) className = isSent ? "nameOut" : "nameIn"; - else className = isSent ? "hNameOut" : "hNameIn"; + if (!isHistory) + className = isSent ? "nameOut" : "nameIn"; + else + className = isSent ? "hNameOut" : "hNameIn"; if (dwFlags & MWF_LOG_UNDERLINE) - Utils::appendText(&output, &outputSize, "%s: ", className, szName); + str.AppendFormat("%s: ", className, szName); else - Utils::appendText(&output, &outputSize, "%s: ", className, szName); + str.AppendFormat("%s: ", className, szName); } } if (dwFlags & MWF_LOG_NEWLINE && eventData->iType != IEED_EVENT_STATUSCHANGE && eventData->iType != IEED_EVENT_ERRMSG && isGroupBreak) - Utils::appendText(&output, &outputSize, "
"); + str.Append("
"); const char *className = ""; if (eventData->iType == IEED_EVENT_MESSAGE) { @@ -411,14 +408,12 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event else if (eventData->iType == IEED_EVENT_STATUSCHANGE) className = "statusChange"; - Utils::appendText(&output, &outputSize, "%s", className, szText); - Utils::appendText(&output, &outputSize, "
\n"); + str.AppendFormat("%s", className, szText); + str.Append("
\n"); setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType)); setLastEventTime(eventData->time); - } - if (output != NULL) { - view->write(output); - free(output); + + view->write(str); } } -- cgit v1.2.3