diff options
author | George Hazan <george.hazan@gmail.com> | 2013-04-06 21:07:53 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2013-04-06 21:07:53 +0000 |
commit | 37f0dfdfac4dc0af578769b02e29efb9926415bb (patch) | |
tree | cadf855bb7a074eb78f45b725e5b9a3e965fa045 /plugins/IEView/src/MUCCHTMLBuilder.cpp | |
parent | e7891a7f13d94b6eae7f74f7354e0a3643d1de01 (diff) |
postfix to the standard functions patch by Mataes
git-svn-id: http://svn.miranda-ng.org/main/trunk@4351 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/IEView/src/MUCCHTMLBuilder.cpp')
-rw-r--r-- | plugins/IEView/src/MUCCHTMLBuilder.cpp | 82 |
1 files changed, 39 insertions, 43 deletions
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<char>(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<char> 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, "<div class=\"%s\">", 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, "<span class=\"%s\">%s </span>",
isSent ? "timestamp" : "timestamp", timestampToString(dwData, eventData->time));
- }
- if (dwData & IEEDD_MUCC_SHOW_NICK) {
+
+ if (dwData & IEEDD_MUCC_SHOW_NICK)
Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s: </span>",
isSent ? "nameOut" : "nameIn", szName);
- }
- if (dwData & IEEDD_MUCC_MSG_ON_NEW_LINE) {
+
+ if (dwData & IEEDD_MUCC_MSG_ON_NEW_LINE)
Utils::appendText(&output, &outputSize, "<br>");
- }
+
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, "<span class=\"%s\"><span style=\"%s\">%s</span></span>", className, style!=NULL ? style : "", szText);
Utils::appendText(&output, &outputSize, "</div>\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, "<div class=\"%s\">", 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, "<span class=\"%s\">%s </span>",
isSent ? "timestamp" : "timestamp", timestampToString(dwData, eventData->time));
- }
+
Utils::appendText(&output, &outputSize, "<span class=\"%s\">", className);
Utils::appendText(&output, &outputSize, Translate(eventText), szText);
Utils::appendText(&output, &outputSize, "</span>");
Utils::appendText(&output, &outputSize, "</div>\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, "<div class=\"%s\">", "divError");
Utils::appendText(&output, &outputSize, "<span class=\"%s\"> %s: %s</span>", className, Translate("Error"), szText);
Utils::appendText(&output, &outputSize, "</div>\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;
}
|