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/HistoryHTMLBuilder.cpp | 101 ++++++++++++++---------------- 1 file changed, 47 insertions(+), 54 deletions(-) (limited to 'plugins/IEView/src/HistoryHTMLBuilder.cpp') diff --git a/plugins/IEView/src/HistoryHTMLBuilder.cpp b/plugins/IEView/src/HistoryHTMLBuilder.cpp index 1672002100..061f307059 100644 --- a/plugins/IEView/src/HistoryHTMLBuilder.cpp +++ b/plugins/IEView/src/HistoryHTMLBuilder.cpp @@ -152,40 +152,39 @@ void HistoryHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) LOGFONTA lf; int i; COLORREF color, bkgColor; - char *output = NULL; - int outputSize; + ProtocolSettings *protoSettings = getHistoryProtocolSettings(event->hContact); - if (protoSettings == NULL) { + if (protoSettings == NULL) return; - } + if (protoSettings->getHistoryMode() == Options::MODE_TEMPLATE) { buildHeadTemplate(view, event, protoSettings); return; } + + CMStringA str; if (protoSettings->getHistoryMode() == Options::MODE_CSS) { const char *externalCSS = protoSettings->getHistoryCssFilename(); - Utils::appendText(&output, &outputSize, "\n", externalCSS); + str.AppendFormat("\n", externalCSS); } else { - Utils::appendText(&output, &outputSize, ""); - Utils::appendText(&output, &outputSize, "\n"); - } - if (output != NULL) { - view->write(output); - free(output); + str.Append("\n"); } + + if (!str.IsEmpty()) + view->write(str); + setLastEventType(-1); } @@ -232,8 +229,7 @@ void HistoryHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event ptrA 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; + CMStringA str; bool isSent = (eventData->dwFlags & IEEDF_SENT) != 0; if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_STATUSCHANGE || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_FILE) @@ -253,42 +249,41 @@ void HistoryHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event const char *iconFile = NULL; switch (eventData->iType) { case IEED_EVENT_SYSTEM: - Utils::appendText(&output, &outputSize, "
", "divSystem"); + str.AppendFormat("
", "divSystem"); break; case IEED_EVENT_FILE: iconFile = "file.gif"; - Utils::appendText(&output, &outputSize, "
", isSent ? "divFileOut" : "divFileIn"); + str.AppendFormat("
", isSent ? "divFileOut" : "divFileIn"); break; case IEED_EVENT_URL: iconFile = "url.gif"; - Utils::appendText(&output, &outputSize, "
", isSent ? "divUrlOut" : "divUrlIn"); + str.AppendFormat("
", isSent ? "divUrlOut" : "divUrlIn"); break; default: iconFile = "message.gif"; - Utils::appendText(&output, &outputSize, "
", isSent ? "divMessageOut" : "divMessageIn"); + str.AppendFormat("
", isSent ? "divMessageOut" : "divMessageIn"); } if (dwFlags & SMF_LOG_SHOWICONS && iconFile != NULL) - Utils::appendIcon(&output, &outputSize, iconFile); + Utils::appendIcon(str, iconFile); else - Utils::appendText(&output, &outputSize, " "); + str.Append(" "); - Utils::appendText(&output, &outputSize, "%s:", isSent ? "nameOut" : "nameIn", szName); - Utils::appendText(&output, &outputSize, "%s
", isSent ? "timeOut" : "timeIn", timestampToString(eventData->time)); + str.AppendFormat("%s:", isSent ? "nameOut" : "nameIn", szName); + str.AppendFormat("%s
", isSent ? "timeOut" : "timeIn", timestampToString(eventData->time)); if (eventData->iType == IEED_EVENT_FILE) - Utils::appendText(&output, &outputSize, "%s:
%s", isSent ? Translate("Outgoing File Transfer") : Translate("Incoming File Transfer"), szText); + str.AppendFormat("%s:
%s", isSent ? Translate("Outgoing File Transfer") : Translate("Incoming File Transfer"), szText); else if (eventData->iType == IEED_EVENT_URL) - Utils::appendText(&output, &outputSize, "%s:
%s", isSent ? Translate("URL sent") : Translate("URL received"), szText); + str.AppendFormat("%s:
%s", isSent ? Translate("URL sent") : Translate("URL received"), szText); else - Utils::appendText(&output, &outputSize, "%s", szText); + str.AppendFormat("%s", szText); - Utils::appendText(&output, &outputSize, "
\n"); + str.Append("
\n"); setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType)); setLastEventTime(eventData->time); } - if (output != NULL) { - view->write(output); - free(output); - } + + if (!str.IsEmpty()) + view->write(str); } view->documentClose(); } @@ -296,13 +291,11 @@ void HistoryHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event void HistoryHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) { ProtocolSettings *protoSettings = getHistoryProtocolSettings(event->hContact); - if (protoSettings == NULL) { + if (protoSettings == NULL) return; - } - if (protoSettings->getHistoryMode() & Options::MODE_TEMPLATE) { + + if (protoSettings->getHistoryMode() & Options::MODE_TEMPLATE) appendEventTemplate(view, event, protoSettings); - } - else{ + else appendEventNonTemplate(view, event); - } } -- cgit v1.2.3