diff options
author | George Hazan <george.hazan@gmail.com> | 2015-04-19 21:12:24 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-04-19 21:12:24 +0000 |
commit | 23da585729242bc135e7a6da0dc5bf699e6c9b54 (patch) | |
tree | d9588a9288ed88c36979d4d92538f3641796e2af /plugins | |
parent | 26ec77c0e1b49ac1dc002acc4da767d9de8e9703 (diff) |
- 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
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/IEView/src/ChatHTMLBuilder.cpp | 115 | ||||
-rw-r--r-- | plugins/IEView/src/HTMLBuilder.cpp | 109 | ||||
-rw-r--r-- | plugins/IEView/src/HTMLBuilder.h | 38 | ||||
-rw-r--r-- | plugins/IEView/src/HistoryHTMLBuilder.cpp | 101 | ||||
-rw-r--r-- | plugins/IEView/src/IEView.cpp | 485 | ||||
-rw-r--r-- | plugins/IEView/src/IEView.h | 9 | ||||
-rw-r--r-- | plugins/IEView/src/MUCCHTMLBuilder.cpp | 124 | ||||
-rw-r--r-- | plugins/IEView/src/ScriverHTMLBuilder.cpp | 161 | ||||
-rw-r--r-- | plugins/IEView/src/TabSRMMHTMLBuilder.cpp | 137 | ||||
-rw-r--r-- | plugins/IEView/src/Template.cpp | 12 | ||||
-rw-r--r-- | plugins/IEView/src/TemplateHTMLBuilder.cpp | 28 | ||||
-rw-r--r-- | plugins/IEView/src/TextToken.cpp | 77 | ||||
-rw-r--r-- | plugins/IEView/src/TextToken.h | 2 | ||||
-rw-r--r-- | plugins/IEView/src/Utils.cpp | 74 | ||||
-rw-r--r-- | plugins/IEView/src/Utils.h | 4 | ||||
-rw-r--r-- | plugins/IEView/src/Version.h | 4 | ||||
-rw-r--r-- | plugins/IEView/src/ieview_common.h | 6 |
17 files changed, 607 insertions, 879 deletions
diff --git a/plugins/IEView/src/ChatHTMLBuilder.cpp b/plugins/IEView/src/ChatHTMLBuilder.cpp index 1584907cf4..b8264298bb 100644 --- a/plugins/IEView/src/ChatHTMLBuilder.cpp +++ b/plugins/IEView/src/ChatHTMLBuilder.cpp @@ -82,12 +82,11 @@ void ChatHTMLBuilder::loadMsgDlgFont(int i, LOGFONTA * lf, COLORREF * colour) }
}
-char *ChatHTMLBuilder::timestampToString(time_t time)
+char* ChatHTMLBuilder::timestampToString(time_t time)
{
static char szResult[512];
static char str[80];
char *pszStamp = "[%H:%M]";
- //InitSetting( &g_Settings.pszTimeStamp, "HeaderTime", _T("[%H:%M]"));
strftime(str, 79, pszStamp, localtime(&time));
mir_strncpy(szResult, ptrA(mir_utf8encode(str)), 500);
return szResult;
@@ -97,51 +96,47 @@ void ChatHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) {
LOGFONTA lf;
COLORREF color;
- char *output = NULL;
- int outputSize;
+
ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto);
- if (protoSettings == NULL) {
+ if (protoSettings == NULL)
return;
- }
- if (protoSettings->getChatMode() == Options::MODE_TEMPLATE) {
- // buildHeadTemplate(view, event);
+
+ if (protoSettings->getChatMode() == Options::MODE_TEMPLATE)
return;
- }
+
+ CMStringA str;
if (protoSettings->getChatMode() == Options::MODE_CSS) {
const char *externalCSS = protoSettings->getChatCssFilename();
- Utils::appendText(&output, &outputSize, "<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
+ str.AppendFormat("<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
}
else {
HDC hdc = GetDC(NULL);
int logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
- Utils::appendText(&output, &outputSize, "<html><head>");
- Utils::appendText(&output, &outputSize, "<style type=\"text/css\">\n");
+ str.Append("<html><head>");
+ str.Append("<style type=\"text/css\">\n");
COLORREF bkgColor = db_get_dw(NULL, CHATMOD, "BackgroundLog", 0xFFFFFF);
- COLORREF inColor, outColor;
bkgColor = (((bkgColor & 0xFF) << 16) | (bkgColor & 0xFF00) | ((bkgColor & 0xFF0000) >> 16));
- inColor = outColor = bkgColor;
+ COLORREF inColor = bkgColor, outColor = bkgColor;
if (protoSettings->getChatFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".body {padding: 2px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
- protoSettings->getChatFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", (int)bkgColor, protoSettings->getChatBackgroundFilename());
- }
- else {
- Utils::appendText(&output, &outputSize, ".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n",
- (int)bkgColor);
+ str.AppendFormat(".body {padding: 2px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
+ protoSettings->getChatFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", bkgColor, protoSettings->getChatBackgroundFilename());
}
- Utils::appendText(&output, &outputSize, ".link {color: #0000FF; text-decoration: underline;}\n");
- Utils::appendText(&output, &outputSize, ".img {vertical-align: middle;}\n");
+ else str.AppendFormat(".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n", bkgColor);
+
+ str.Append(".link {color: #0000FF; text-decoration: underline;}\n");
+ str.Append(".img {vertical-align: middle;}\n");
if (protoSettings->getChatFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
}
else {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)outColor);
+ str.AppendFormat(".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", inColor);
+ str.AppendFormat(".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", outColor);
}
for (int i = 0; i < FONT_NUM; i++) {
loadMsgDlgFont(i, &lf, &color);
- Utils::appendText(&output, &outputSize, "%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
+ str.AppendFormat("%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
classNames[i],
lf.lfFaceName,
abs((signed char)lf.lfHeight) * 74 / logPixelSY,
@@ -149,12 +144,12 @@ void ChatHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) (int)(((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)),
lf.lfItalic ? "font-style: italic;" : "");
}
- Utils::appendText(&output, &outputSize, "</style></head><body class=\"body\">\n");
- }
- if (output != NULL) {
- view->write(output);
- free(output);
+ str.Append("</style></head><body class=\"body\">\n");
}
+
+ if (!str.IsEmpty())
+ view->write(str);
+
setLastEventType(-1);
}
@@ -167,12 +162,9 @@ void ChatHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) DWORD iconFlags = db_get_dw(NULL, CHATMOD, CHAT_ICON_FLAGS, 0);
IEVIEWEVENTDATA* eventData = event->eventData;
for (int eventIdx = 0; eventData != NULL && (eventIdx < event->count || event->count == -1); eventData = eventData->next, eventIdx++) {
- //DWORD dwFlags = eventData->dwFlags;
const char *iconFile = "";
DWORD dwData = eventData->dwData;
bool isSent = eventData->bIsMe != 0;
- int outputSize = 0;
- char *output = NULL;
const char *className = "";
bool showIcon = false;
@@ -238,44 +230,37 @@ void ChatHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) className = "information";
}
}
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", isSent ? "divOut" : "divIn");
- if (dwData & IEEDD_GC_SHOW_ICON) {
- Utils::appendIcon(&output, &outputSize, iconFile);
- }
- if (dwData & IEEDD_GC_SHOW_TIME) {
- Utils::appendText(&output, &outputSize, "<span class=\"timestamp\">%s </span>", timestampToString(eventData->time));
- }
- if ((dwData & IEEDD_GC_SHOW_NICK) && eventData->iType == IEED_GC_EVENT_MESSAGE) {
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s: </span>",
- isSent ? "nameOut" : "nameIn", szName);
- }
- if (dwData & IEEDD_GC_MSG_ON_NEW_LINE) {
- Utils::appendText(&output, &outputSize, "<br>");
- }
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">", className);
- Utils::appendText(&output, &outputSize, "%s", szText);
- Utils::appendText(&output, &outputSize, "</span></div>\n");
- if (output != NULL) {
- view->write(output);
- free(output);
- }
+
+ CMStringA str(FORMAT, "<div class=\"%s\">", isSent ? "divOut" : "divIn");
+ if (dwData & IEEDD_GC_SHOW_ICON)
+ Utils::appendIcon(str, iconFile);
+
+ if (dwData & IEEDD_GC_SHOW_TIME)
+ str.AppendFormat("<span class=\"timestamp\">%s </span>", timestampToString(eventData->time));
+
+ if ((dwData & IEEDD_GC_SHOW_NICK) && eventData->iType == IEED_GC_EVENT_MESSAGE)
+ str.AppendFormat("<span class=\"%s\">%s: </span>", isSent ? "nameOut" : "nameIn", szName);
+
+ if (dwData & IEEDD_GC_MSG_ON_NEW_LINE)
+ str.Append("<br>");
+
+ str.AppendFormat("<span class=\"%s\">", className);
+ str.Append(szText);
+ str.Append("</span></div>\n");
+
+ if (!str.IsEmpty())
+ view->write(str);
}
}
void ChatHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event)
{
ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto);
- if (protoSettings == NULL) {
- return;
- }
- // if (protoSettings->getSRMMMode() == Options::MODE_TEMPLATE) {
- // appendEventTemplate(view, event);
- // } else {
- appendEventNonTemplate(view, event);
- // }
+ if (protoSettings != NULL)
+ appendEventNonTemplate(view, event);
}
-bool ChatHTMLBuilder::isDbEventShown(DBEVENTINFO *)
+bool ChatHTMLBuilder::isDbEventShown(DBEVENTINFO*)
{
return true;
}
diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 28faa76b1f..de2e5e7b61 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -42,7 +42,7 @@ HTMLBuilder::~HTMLBuilder() mir_free((void*)lastIEViewEvent.pszProto);
}
-bool HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *text, wchar_t **output, int *outputSize, int level, int flags, bool isSent)
+bool HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *text, CMStringW &str, int level, int flags, bool isSent)
{
TextToken *token = NULL, *token2;
switch (level) {
@@ -71,9 +71,9 @@ 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(), output, outputSize, level + 1, flags, isSent);
+ skip = encode(hContact, proto, token->getTextW(), str, level + 1, flags, isSent);
if (!skip)
- token->toString(output, outputSize);
+ token->toString(str);
delete token;
}
return true;
@@ -81,47 +81,31 @@ bool HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *te return false;
}
-wchar_t* HTMLBuilder::encode(MCONTACT hContact, const char *proto, const wchar_t *text, int flags, bool isSent)
-{
- int outputSize;
- wchar_t *output = NULL;
- if (text != NULL)
- encode(hContact, proto, text, &output, &outputSize, 0, flags, isSent);
- return output;
-}
-
char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const char *proto, const wchar_t *wtext, int flags, bool isSent)
{
- char *outputStr = NULL;
- if (wtext != NULL) {
- wchar_t *output = encode(hContact, proto, wtext, flags, isSent);
- outputStr = mir_utf8encodeT(output);
- if (output != NULL)
- free(output);
- }
- return outputStr;
+ if (wtext == NULL)
+ return NULL;
+
+ CMStringW str;
+ encode(hContact, proto, wtext, str, 0, flags, isSent);
+ return mir_utf8encodeT(str);
}
char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const char *proto, const char *text, int flags, bool isSent)
{
- char *outputStr = NULL;
- if (text != NULL) {
- wchar_t *wtext = mir_a2t(text);
- outputStr = encodeUTF8(hContact, proto, wtext, flags, isSent);
- mir_free(wtext);
- }
- return outputStr;
+ if (text == NULL)
+ return NULL;
+
+ return encodeUTF8(hContact, proto, _A2T(text), flags, isSent);
}
char* HTMLBuilder::encodeUTF8(MCONTACT hContact, const char *proto, const char *text, int cp, int flags, bool isSent)
{
- char *outputStr = NULL;
- if (text != NULL) {
- wchar_t *wtext = mir_a2t_cp(text, cp);
- outputStr = encodeUTF8(hContact, proto, wtext, flags, isSent);
- mir_free(wtext);
- }
- return outputStr;
+ if (text == NULL)
+ return NULL;
+
+ ptrW wtext(mir_a2t_cp(text, cp));
+ return encodeUTF8(hContact, proto, wtext, flags, isSent);
}
char* HTMLBuilder::getProto(MCONTACT hContact)
@@ -145,15 +129,13 @@ char* HTMLBuilder::getRealProto(MCONTACT hContact) char *szProto = mir_strdup(GetContactProto(hContact));
if (szProto != NULL && !strcmp(szProto, META_PROTO)) {
hContact = db_mc_getMostOnline(hContact);
- if (hContact != NULL) {
- mir_free(szProto);
- szProto = mir_strdup(GetContactProto(hContact));
- }
+ if (hContact != NULL)
+ replaceStr(szProto, GetContactProto(hContact));
}
return szProto;
}
-char *HTMLBuilder::getRealProto(MCONTACT hContact, const char *szProto)
+char* HTMLBuilder::getRealProto(MCONTACT hContact, const char *szProto)
{
if (szProto != NULL && !strcmp(szProto, META_PROTO)) {
hContact = db_mc_getMostOnline(hContact);
@@ -248,32 +230,18 @@ void HTMLBuilder::getUINs(MCONTACT hContact, char *&uinIn, char *&uinOut) wchar_t *HTMLBuilder::getContactName(MCONTACT hContact, const char *szProto)
{
CONTACTINFO ci = { 0 };
- wchar_t *szName = NULL;
-
ci.cbSize = sizeof(ci);
ci.hContact = hContact;
ci.szProto = (char *)szProto;
ci.dwFlag = CNF_DISPLAY | CNF_UNICODE;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- if (ci.type == CNFT_ASCIIZ) {
- if (ci.pszVal) {
- szName = mir_tstrdup(ci.pszVal);
- mir_free(ci.pszVal);
- }
- }
- }
- if (szName != NULL) return szName;
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci))
+ if (ci.type == CNFT_ASCIIZ && ci.pszVal) // already mir_tstrdup'ed
+ return ci.pszVal;
ci.dwFlag = CNF_UNIQUEID;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- if (ci.type == CNFT_ASCIIZ) {
- if (ci.pszVal) {
- szName = mir_tstrdup(ci.pszVal);
- mir_free(ci.pszVal);
- }
- }
- }
- if (szName != NULL) return szName;
+ if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci))
+ if (ci.type == CNFT_ASCIIZ && ci.pszVal) // already mir_tstrdup'ed
+ return ci.pszVal;
TCHAR *szNameStr = pcli->pfnGetContactDisplayName(hContact, 0);
if (szNameStr != NULL)
@@ -282,16 +250,11 @@ wchar_t *HTMLBuilder::getContactName(MCONTACT hContact, const char *szProto) return mir_tstrdup(TranslateT("(Unknown Contact)"));
}
-char *HTMLBuilder::getEncodedContactName(MCONTACT hContact, const char* szProto, const char* szSmileyProto)
+char* HTMLBuilder::getEncodedContactName(MCONTACT hContact, const char* szProto, const char* szSmileyProto)
{
- char *szName = NULL;
- wchar_t *name = getContactName(hContact, szProto);
- if (name != NULL) {
- szName = encodeUTF8(hContact, szSmileyProto, name, ENF_NAMESMILEYS, true);
- mir_free(name);
- return szName;
- }
- return encodeUTF8(hContact, szSmileyProto, TranslateT("(Unknown Contact)"), ENF_NAMESMILEYS, true);
+ ptrW name(getContactName(hContact, szProto));
+ return encodeUTF8(hContact, szSmileyProto,
+ (name != NULL) ? name : TranslateT("(Unknown Contact)"), ENF_NAMESMILEYS, true);
}
void HTMLBuilder::appendEventNew(IEView *view, IEVIEWEVENT *event)
@@ -302,8 +265,7 @@ void HTMLBuilder::appendEventNew(IEView *view, IEVIEWEVENT *event) void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event)
{
- IEVIEWEVENTDATA* eventData;
- IEVIEWEVENTDATA* prevEventData = NULL;
+ IEVIEWEVENTDATA *prevEventData = NULL;
MEVENT hDbEvent = event->hDbEventFirst;
event->hDbEventFirst = NULL;
@@ -343,7 +305,7 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) hDbEvent = db_event_next(event->hContact, hDbEvent);
continue;
}
- eventData = new IEVIEWEVENTDATA;
+ IEVIEWEVENTDATA *eventData = new IEVIEWEVENTDATA;
eventData->cbSize = sizeof(IEVIEWEVENTDATA);
eventData->dwFlags = IEEDF_UNICODE_TEXT | IEEDF_UNICODE_NICK | IEEDF_UNICODE_TEXT2 |
(dbei.flags & DBEF_READ ? IEEDF_READ : 0) | (dbei.flags & DBEF_SENT ? IEEDF_SENT : 0) | (dbei.flags & DBEF_RTL ? IEEDF_RTL : 0);
@@ -409,12 +371,13 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) hDbEvent = db_event_next(event->hContact, hDbEvent);
}
appendEventNew(view, &newEvent);
- for (IEVIEWEVENTDATA* eventData2 = newEvent.eventData; eventData2 != NULL; eventData2 = eventData) {
- eventData = eventData2->next;
+ for (IEVIEWEVENTDATA* eventData2 = newEvent.eventData; eventData2 != NULL;) {
+ IEVIEWEVENTDATA *eventData = eventData2->next;
mir_free((void*)eventData2->pszTextW);
mir_free((void*)eventData2->pszText2W);
mir_free((void*)eventData2->pszNickW);
delete eventData2;
+ eventData2 = eventData;
}
}
diff --git a/plugins/IEView/src/HTMLBuilder.h b/plugins/IEView/src/HTMLBuilder.h index 9e2f2e3939..dcf4324e58 100644 --- a/plugins/IEView/src/HTMLBuilder.h +++ b/plugins/IEView/src/HTMLBuilder.h @@ -50,33 +50,35 @@ protected: 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 wchar_t *encode(MCONTACT hContact, const char *proto, const wchar_t *text, int flags, bool isSent);
- virtual bool encode(MCONTACT hContact, const char *proto, const wchar_t *text, wchar_t **output, int *outputSize, 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 wchar_t *getContactName(MCONTACT hContact, const char* szProto);
- virtual char *getEncodedContactName(MCONTACT hContact, const char *szProto, const char *szSmileyProto);
- virtual void getUINs(MCONTACT hContact, char *&uinIn, char *&uinOut);
+ 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 wchar_t* getContactName(MCONTACT hContact, const char* szProto);
+ virtual char* getEncodedContactName(MCONTACT hContact, const char *szProto, const char *szSmileyProto);
+ 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 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);
virtual void buildHead(IEView *, IEVIEWEVENT *event) = 0;
+
public:
HTMLBuilder();
virtual ~HTMLBuilder();
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, "<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
+ str.AppendFormat("<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
}
else {
- Utils::appendText(&output, &outputSize, "<html><head>");
- Utils::appendText(&output, &outputSize, "<style type=\"text/css\">\n");
+ str.Append("<html><head>");
+ str.Append("<style type=\"text/css\">\n");
COLORREF lineColor = db_get_dw(NULL, HPPMOD, "LineColour", 0xFFFFFF);
- lineColor = 0;//(((lineColor & 0xFF) << 16) | (lineColor & 0xFF00) | ((lineColor & 0xFF0000) >> 16));
+ lineColor = 0;
bkgColor = 0xFFFFFF;
- if (protoSettings->getHistoryFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".body {padding: 2px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
- protoSettings->getHistoryFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", (int)bkgColor, protoSettings->getHistoryBackgroundFilename());
- }
- else {
- Utils::appendText(&output, &outputSize, ".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n",
- (int)bkgColor);
- }
- Utils::appendText(&output, &outputSize, ".link {color: #0000FF; text-decoration: underline;}\n");
- Utils::appendText(&output, &outputSize, ".img {float: left; vertical-align: middle;}\n");
+ if (protoSettings->getHistoryFlags() & Options::LOG_IMAGE_ENABLED)
+ str.AppendFormat(".body {padding: 2px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
+ protoSettings->getHistoryFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", bkgColor, protoSettings->getHistoryBackgroundFilename());
+ else
+ str.AppendFormat(".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n", bkgColor);
+
+ str.Append(".link {color: #0000FF; text-decoration: underline;}\n");
+ str.Append(".img {float: left; vertical-align: middle;}\n");
for (i = 0; i < DIV_FONT_NUM; i++) {
loadMsgDlgFont(dbDivSettingNames[i], &lf, &color, &bkgColor);
- if (protoSettings->getHistoryFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, "%s {float: left; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s}\n",
+ if (protoSettings->getHistoryFlags() & Options::LOG_IMAGE_ENABLED)
+ str.AppendFormat("%s {float: left; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s}\n",
divClassNames[i],
(int)lineColor,
lf.lfFaceName,
@@ -193,9 +192,8 @@ void HistoryHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) lf.lfWeight >= FW_BOLD ? "bold" : "normal",
(int)(((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)),
lf.lfItalic ? "font-style: italic;" : "");
- }
- else {
- Utils::appendText(&output, &outputSize, "%s {float: left; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X; font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s}\n",
+ else
+ str.AppendFormat("%s {float: left; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X; font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s}\n",
divClassNames[i],
(int)lineColor,
(int)(((bkgColor & 0xFF) << 16) | (bkgColor & 0xFF00) | ((bkgColor & 0xFF0000) >> 16)),
@@ -204,11 +202,10 @@ void HistoryHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) lf.lfWeight >= FW_BOLD ? "bold" : "normal",
(int)(((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)),
lf.lfItalic ? "font-style: italic;" : "");
- }
}
for (i = 0; i < SPAN_FONT_NUM; i++) {
loadMsgDlgFont(dbSpanSettingNames[i], &lf, &color, NULL);
- Utils::appendText(&output, &outputSize, "%s {float: %s; font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
+ str.AppendFormat("%s {float: %s; font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
spanClassNames[i],
i < 2 ? "left" : "right; clear: right;",
lf.lfFaceName,
@@ -217,12 +214,12 @@ void HistoryHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) (int)(((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)),
lf.lfItalic ? "font-style: italic;" : "");
}
- Utils::appendText(&output, &outputSize, "</style></head><body class=\"body\">\n");
- }
- if (output != NULL) {
- view->write(output);
- free(output);
+ str.Append("</style></head><body class=\"body\">\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, "<div class=\"%s\">", "divSystem");
+ str.AppendFormat("<div class=\"%s\">", "divSystem");
break;
case IEED_EVENT_FILE:
iconFile = "file.gif";
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", isSent ? "divFileOut" : "divFileIn");
+ str.AppendFormat("<div class=\"%s\">", isSent ? "divFileOut" : "divFileIn");
break;
case IEED_EVENT_URL:
iconFile = "url.gif";
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", isSent ? "divUrlOut" : "divUrlIn");
+ str.AppendFormat("<div class=\"%s\">", isSent ? "divUrlOut" : "divUrlIn");
break;
default:
iconFile = "message.gif";
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", isSent ? "divMessageOut" : "divMessageIn");
+ str.AppendFormat("<div class=\"%s\">", 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, "<span class=\"%s\">%s:</span>", isSent ? "nameOut" : "nameIn", szName);
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s</span><br>", isSent ? "timeOut" : "timeIn", timestampToString(eventData->time));
+ str.AppendFormat("<span class=\"%s\">%s:</span>", isSent ? "nameOut" : "nameIn", szName);
+ str.AppendFormat("<span class=\"%s\">%s</span><br>", isSent ? "timeOut" : "timeIn", timestampToString(eventData->time));
if (eventData->iType == IEED_EVENT_FILE)
- Utils::appendText(&output, &outputSize, "%s:<br> %s", isSent ? Translate("Outgoing File Transfer") : Translate("Incoming File Transfer"), szText);
+ str.AppendFormat("%s:<br> %s", isSent ? Translate("Outgoing File Transfer") : Translate("Incoming File Transfer"), szText);
else if (eventData->iType == IEED_EVENT_URL)
- Utils::appendText(&output, &outputSize, "%s:<br> %s", isSent ? Translate("URL sent") : Translate("URL received"), szText);
+ str.AppendFormat("%s:<br> %s", isSent ? Translate("URL sent") : Translate("URL received"), szText);
else
- Utils::appendText(&output, &outputSize, "%s", szText);
+ str.AppendFormat("%s", szText);
- Utils::appendText(&output, &outputSize, "</div>\n");
+ str.Append("</div>\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);
- }
}
diff --git a/plugins/IEView/src/IEView.cpp b/plugins/IEView/src/IEView.cpp index a9d75c3a85..e2dbb86833 100644 --- a/plugins/IEView/src/IEView.cpp +++ b/plugins/IEView/src/IEView.cpp @@ -36,42 +36,33 @@ static LRESULT CALLBACK IEViewServerWindowProcedure(HWND hwnd, UINT message, WPA if (view != NULL) {
switch (message) {
case WM_KEYUP:
- if (LOWORD(wParam) == VK_ESCAPE && !(GetKeyState(VK_SHIFT) & 0x8000)
- && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000)) {
- //if (view->getBuilder() != NULL) {
+ if (LOWORD(wParam) == VK_ESCAPE && !(GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000))
SendMessage(GetParent(GetParent(GetParent(hwnd))), WM_COMMAND, IDCANCEL, 0);
- // } else {
-
- // }
- }
break;
+
case WM_KEYDOWN:
view->translateAccelerator(message, wParam, lParam);
break;
+
case WM_SETFOCUS:
- {
RECT rcWindow;
POINT cursor;
GetWindowRect(hwnd, &rcWindow);
GetCursorPos(&cursor);
- if (cursor.y > rcWindow.bottom || cursor.y < rcWindow.top ||
- cursor.x > rcWindow.right || cursor.x < rcWindow.left) {
- }
- else {
+ if (cursor.y <= rcWindow.bottom && cursor.y >= rcWindow.top && cursor.x <= rcWindow.right && cursor.x >= rcWindow.left)
view->mouseActivate();
- }
- if (view->setFocus((HWND)wParam)) {
+
+ if (view->setFocus((HWND)wParam))
return TRUE;
- }
- }
- break;
+ break;
+
case WM_LBUTTONDOWN:
POINT pt;
pt.x = LOWORD(lParam);
pt.y = HIWORD(lParam);
- if (view->mouseClick(pt)) {
+ if (view->mouseClick(pt))
return TRUE;
- }
+
break;
}
return CallWindowProc(view->getServerWndProc(), hwnd, message, wParam, lParam);
@@ -117,15 +108,15 @@ IEViewSink::~IEViewSink() {} STDMETHODIMP IEViewSink::QueryInterface(REFIID riid, PVOID *ppv)
{
*ppv = NULL;
- if (IID_IUnknown == riid) {
+ if (IID_IUnknown == riid)
*ppv = (IUnknown *)this;
- }
- if (IID_IDispatch == riid) {
+
+ if (IID_IDispatch == riid)
*ppv = (IDispatch *)this;
- }
- if (DIID_DWebBrowserEvents2 == riid) {
+
+ if (DIID_DWebBrowserEvents2 == riid)
*ppv = (DWebBrowserEvents2*)this;
- }
+
if (NULL != *ppv) {
((LPUNKNOWN)*ppv)->AddRef();
return NOERROR;
@@ -236,69 +227,50 @@ void IEView::setBorder() style &= ~(WS_EX_STATICEDGE);
#endif
}
- else {
- style |= (WS_EX_STATICEDGE);
- }
+ else style |= (WS_EX_STATICEDGE);
+
if (oldStyle != style) {
SetWindowLongPtr(hwnd, GWL_EXSTYLE, style);
SetWindowPos(getHWND(), NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
}
- // RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_FRAME | RDW_UPDATENOW);
}
-IEView::IEView(HWND parent, HTMLBuilder* builder, int x, int y, int cx, int cy)
+IEView::IEView(HWND _parent, HTMLBuilder *_builder, int x, int y, int cx, int cy)
{
MSG msg;
- IOleObject* pOleObject = NULL;
- IOleInPlaceObject *pOleInPlace;
- isContactSet = false;
- this->parent = parent;
- this->builder = builder;
- prev = next = NULL;
- hwnd = NULL;
- sink = NULL;
- pWebBrowser = NULL;
- m_pConnectionPoint = NULL;
- m_cRef = 0;
- selectedText = NULL;
- getFocus = false;
+ parent = _parent;
+ builder = _builder;
rcClient.left = x;
rcClient.top = y;
rcClient.right = x + cx;
rcClient.bottom = y + cy;
- if (SUCCEEDED(CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IWebBrowser2, (LPVOID*)&pWebBrowser))) {
- if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleObject, (void**)&pOleObject))) {
+ if (SUCCEEDED(pWebBrowser.CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC))) {
+ CComPtr<IOleObject> pOleObject;
+ if (SUCCEEDED(pWebBrowser.QueryInterface(&pOleObject))) {
pOleObject->SetClientSite(this);
pOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, this->parent, &rcClient);
- pOleObject->Release();
- }
- else {
- MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK);
}
+ else MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK);
- if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleInPlaceObject, (void**)&pOleInPlace))) {
+ CComPtr<IOleInPlaceObject> pOleInPlace;
+ if (SUCCEEDED(pWebBrowser.QueryInterface(&pOleInPlace)))
pOleInPlace->GetWindow(&hwnd);
- pOleInPlace->Release();
- }
- else {
+ else
MessageBox(NULL, TranslateT("IID_IOleInPlaceObject failed."), TranslateT("RESULT"), MB_OK);
- }
setBorder();
- IConnectionPointContainer* pCPContainer;
+ CComPtr<IConnectionPointContainer> pCPContainer;
// Step 1: Get a pointer to the connection point container.
- if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IConnectionPointContainer, (void**)&pCPContainer))) {
+ if (SUCCEEDED(pWebBrowser.QueryInterface(&pCPContainer))) {
// m_pConnectionPoint is defined like this:
// Step 2: Find the connection point.
if (SUCCEEDED(pCPContainer->FindConnectionPoint(DIID_DWebBrowserEvents2, &m_pConnectionPoint))) {
// Step 3: Advise the connection point that you
// want to sink its events.
sink = new IEViewSink(this);
- if (FAILED(m_pConnectionPoint->Advise((IUnknown *)sink, &m_dwCookie))) {
+ if (FAILED(m_pConnectionPoint->Advise(sink, &m_dwCookie)))
MessageBox(NULL, TranslateT("Failed to Advise"), TranslateT("C++ Event Sink"), MB_OK);
- }
}
- pCPContainer->Release();
}
setMainWndProc((WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)IEViewWindowProcedure));
}
@@ -315,7 +287,6 @@ IEView::IEView(HWND parent, HTMLBuilder* builder, int x, int y, int cx, int cy) IEView::~IEView()
{
- IOleObject* pOleObject = NULL;
{
mir_cslock lck(mutex);
if (list == this)
@@ -330,26 +301,24 @@ IEView::~IEView() next = NULL;
}
- if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleObject, (void**)&pOleObject))) {
+ CComPtr<IOleObject> pOleObject;
+ if (SUCCEEDED(pWebBrowser.QueryInterface(&pOleObject)))
pOleObject->SetClientSite(NULL);
- pOleObject->Release();
- }
- else MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK);
+ else
+ MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK);
if (builder != NULL) {
delete builder;
builder = NULL;
}
- if (m_pConnectionPoint != NULL) {
+
+ if (m_pConnectionPoint != NULL)
m_pConnectionPoint->Unadvise(m_dwCookie);
- m_pConnectionPoint->Release();
- }
mir_free(selectedText);
if (sink != NULL)
delete sink;
- pWebBrowser->Release();
DestroyWindow(hwnd);
}
@@ -554,12 +523,6 @@ STDMETHODIMP IEView::RequestNewObjectLayout(void) // IDocHostUIHandler
STDMETHODIMP IEView::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarget, IDispatch *)
{
- IOleCommandTarget * pOleCommandTarget;
- IOleWindow * pOleWindow;
- HWND hSPWnd;
- if (builder == NULL) {
- // return S_OK;
- }
#ifdef GECKO
{
return E_NOTIMPL;
@@ -592,23 +555,22 @@ STDMETHODIMP IEView::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarge */
}
#else
+ CComPtr<IOleCommandTarget> pOleCommandTarget;
if (SUCCEEDED(pcmdTarget->QueryInterface(IID_IOleCommandTarget, (void**)&pOleCommandTarget))) {
- if (SUCCEEDED(pOleCommandTarget->QueryInterface(IID_IOleWindow, (void**)&pOleWindow))) {
+ CComPtr<IOleWindow> pOleWindow;
+ if (SUCCEEDED(pOleCommandTarget.QueryInterface(&pOleWindow))) {
+ HWND hSPWnd;
pOleWindow->GetWindow(&hSPWnd);
+
HMENU hMenu = GetSubMenu(LoadMenu(hInstance, MAKEINTRESOURCE(IDR_CONTEXTMENU)), 0);
TranslateMenu(hMenu);
- if (dwID == 5) { // anchor
+ if (dwID == 5) // anchor
EnableMenuItem(hMenu, ID_MENU_COPYLINK, MF_BYCOMMAND | MF_ENABLED);
- }
- else if (dwID == 4) { // text select
+ else if (dwID == 4) // text select
EnableMenuItem(hMenu, ID_MENU_COPY, MF_BYCOMMAND | MF_ENABLED);
- }
- else if (dwID == 1) { // control (image)
+ else if (dwID == 1) // control (image)
EnableMenuItem(hMenu, ID_MENU_SAVEIMAGE, MF_BYCOMMAND | MF_ENABLED);
- }
- if (builder != NULL) {
- }
int iSelection = TrackPopupMenu(hMenu,
TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD,
ppt->x,
@@ -621,10 +583,7 @@ STDMETHODIMP IEView::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarge clear(NULL);
else
SendMessage(hSPWnd, WM_COMMAND, iSelection, (LPARAM)NULL);
-
- pOleWindow->Release();
}
- pOleCommandTarget->Release();
}
#endif
return S_OK;
@@ -752,17 +711,16 @@ STDMETHODIMP IEView::GetZoneMappings(DWORD, IEnumString **, DWORD) return INET_E_DEFAULT_ACTION;
}
-
-IHTMLDocument2 *IEView::getDocument()
+IHTMLDocument2* IEView::getDocument()
{
- HRESULT hr = S_OK;
- IHTMLDocument2 *document = NULL;
- IDispatch *dispatch = NULL;
- if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && (dispatch != NULL)) {
- hr = dispatch->QueryInterface(IID_IHTMLDocument2, (void **)&document);
- dispatch->Release();
+ CComPtr<IDispatch> dispatch;
+ if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && dispatch != NULL) {
+ CComPtr<IHTMLDocument2> document;
+ dispatch.QueryInterface(&document);
+ return document.Detach();
}
- return document;
+
+ return NULL;
}
void IEView::setWindowPos(int x, int y, int cx, int cy)
@@ -770,125 +728,97 @@ void IEView::setWindowPos(int x, int y, int cx, int cy) rcClient.left = x;
rcClient.top = y;
rcClient.right = cx;
- rcClient.bottom = cy;//y + cy;
- if (builder == NULL) {
- //scrollToTop();
- }
- else {
- // scrollToBottomSoft();
- }
+ rcClient.bottom = cy;
+
SetWindowPos(getHWND(), HWND_TOP, x, y, cx, cy, 0);
/*
- IOleInPlaceObject * inPlaceObject;
- if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleInPlaceObject, (void **)&inPlaceObject))) {
- inPlaceObject->SetObjectRects(&rcClient, &rcClient);
- inPlaceObject->Release();
- }
+ CComPtr<IOleInPlaceObject> inPlaceObject;
+ if (SUCCEEDED(pWebBrowser.QueryInterface(&inPlaceObject)))
+ inPlaceObject->SetObjectRects(&rcClient, &rcClient);
*/
- if (builder == NULL) {
- //scrollToTop();
- }
- else {
- // scrollToBottomSoft();
- }
}
void IEView::scrollToTop()
{
- IHTMLDocument2 *document = getDocument();
- if (document != NULL) {
- IHTMLWindow2* pWindow = NULL;
- if (SUCCEEDED(document->get_parentWindow(&pWindow)) && pWindow != NULL) {
+ CComPtr<IHTMLDocument2> document = getDocument();
+ if (document) {
+ CComPtr<IHTMLWindow2> pWindow;
+ if (SUCCEEDED(document->get_parentWindow(&pWindow)) && pWindow != NULL)
pWindow->scrollBy(-0x01FFFFFF, -0x01FFFFFF);
- pWindow->Release();
- }
- document->Release();
}
}
void IEView::scrollToBottomSoft()
{
- IHTMLDocument2 *document = getDocument();
- if (document != NULL) {
- IHTMLWindow2* pWindow = NULL;
- if (SUCCEEDED(document->get_parentWindow(&pWindow)) && (pWindow != NULL)) {
+ CComPtr<IHTMLDocument2> document = getDocument();
+ if (document) {
+ CComPtr<IHTMLWindow2> pWindow;
+ if (SUCCEEDED(document->get_parentWindow(&pWindow)) && pWindow != NULL)
pWindow->scrollBy(-0x01FFFFFF, 0x01FFFFFF);
- pWindow->Release();
- }
- document->Release();
}
}
void IEView::scrollToBottom()
{
- IHTMLDocument2 *document = getDocument();
- if (document != NULL) {
- IHTMLElementCollection *collection;
- IHTMLElement *element;
- IDispatch *dispatch;
- if (SUCCEEDED(document->get_all(&collection)) && (collection != NULL)) {
- long len;
- if (SUCCEEDED(collection->get_length(&len))) {
- VARIANT variant;
- variant.vt = VT_I4;
- variant.lVal = len - 1;
- if (SUCCEEDED(collection->item(variant, variant, &dispatch)) && (dispatch != NULL)) {
- if (SUCCEEDED(dispatch->QueryInterface(IID_IHTMLElement, (void**)&element)) && (element != NULL)) {
- variant.vt = VT_BOOL;
- variant.boolVal = VARIANT_FALSE;
- if (SUCCEEDED(element->scrollIntoView(variant))) {
- }
- element->Release();
- }
- dispatch->Release();
+ CComPtr<IHTMLDocument2> document = getDocument();
+ if (document == NULL)
+ return;
+
+ CComPtr<IHTMLElementCollection> collection;
+ if (SUCCEEDED(document->get_all(&collection)) && collection != NULL) {
+ long len;
+ if (SUCCEEDED(collection->get_length(&len))) {
+ VARIANT variant;
+ variant.vt = VT_I4;
+ variant.lVal = len - 1;
+
+ CComPtr<IDispatch> dispatch;
+ if (SUCCEEDED(collection->item(variant, variant, &dispatch)) && dispatch != NULL) {
+ CComPtr<IHTMLElement> element;
+ if (SUCCEEDED(dispatch.QueryInterface(&element)) && element != NULL) {
+ variant.vt = VT_BOOL;
+ variant.boolVal = VARIANT_FALSE;
+ element->scrollIntoView(variant);
}
}
- collection->Release();
- }
- IHTMLWindow2* pWindow = NULL;
- if (SUCCEEDED(document->get_parentWindow(&pWindow)) && (pWindow != NULL)) {
- pWindow->scrollBy(-0x0000FFFF, 0x0000FFFF);
- pWindow->Release();
}
- document->Release();
}
+
+ CComPtr<IHTMLWindow2> pWindow;
+ if (SUCCEEDED(document->get_parentWindow(&pWindow)) && pWindow != NULL)
+ pWindow->scrollBy(-0x0000FFFF, 0x0000FFFF);
}
void IEView::write(const wchar_t *text)
{
- IHTMLDocument2 *document = getDocument();
- if (document != NULL) {
- SAFEARRAY *safe_array = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);
- if (safe_array != NULL) {
- VARIANT *variant;
- ::SafeArrayAccessData(safe_array, (LPVOID *)&variant);
- variant->vt = VT_BSTR;
- variant->bstrVal = ::SysAllocString(text);
- ::SafeArrayUnaccessData(safe_array);
- document->write(safe_array);
- // ::SysFreeString(bstr); // don't free it !!!!!!!
- ::SafeArrayDestroy(safe_array);
- }
- document->Release();
+ CComPtr<IHTMLDocument2> document = getDocument();
+ if (document == NULL)
+ return;
+
+ SAFEARRAY *safe_array = ::SafeArrayCreateVector(VT_VARIANT, 0, 1);
+ if (safe_array != NULL) {
+ VARIANT *variant;
+ ::SafeArrayAccessData(safe_array, (LPVOID *)&variant);
+ variant->vt = VT_BSTR;
+ variant->bstrVal = ::SysAllocString(text);
+ ::SafeArrayUnaccessData(safe_array);
+ document->write(safe_array);
+ // ::SysFreeString(bstr); // don't free it !!!!!!!
+ ::SafeArrayDestroy(safe_array);
}
}
void IEView::write(const char *text)
{
- int textLen = (int)strlen(text) + 1;
- wchar_t *wcsTemp = new wchar_t[textLen];
- MultiByteToWideChar(CP_UTF8, 0, text, -1, wcsTemp, textLen);
- write(wcsTemp);
- delete[] wcsTemp;
+ write(ptrW(mir_utf8decodeW(text)));
}
void IEView::writef(const char *fmt, ...)
{
- char *str;
+ int strsize = 2048;
va_list vararg;
- int strsize;
va_start(vararg, fmt);
- str = (char *)malloc(strsize = 2048);
+ char *str = (char *)malloc(strsize);
while (mir_vsnprintf(str, strsize, fmt, vararg) == -1)
str = (char *)realloc(str, strsize += 2048);
va_end(vararg);
@@ -898,11 +828,7 @@ void IEView::writef(const char *fmt, ...) void IEView::navigate(const char *url)
{
- int textLen = (int)strlen(url) + 1;
- WCHAR *tTemp = new WCHAR[textLen];
- MultiByteToWideChar(CP_ACP, 0, url, -1, tTemp, textLen);
- pWebBrowser->Navigate(tTemp, NULL, NULL, NULL, NULL);
- delete tTemp;
+ pWebBrowser->Navigate(_A2T(url), NULL, NULL, NULL, NULL);
}
void IEView::navigate(const wchar_t *url)
@@ -927,61 +853,55 @@ void IEView::documentClose() void IEView::appendEventOld(IEVIEWEVENT *event)
{
- if (clearRequired) {
+ if (clearRequired)
clear(event);
- }
- if (builder != NULL) {
+
+ if (builder != NULL)
builder->appendEventOld(this, event);
- }
+
getFocus = false;
}
void IEView::appendEvent(IEVIEWEVENT *event)
{
- if (clearRequired) {
+ if (clearRequired)
clear(event);
- }
- if (event->eventData == NULL) { return; }
- if (builder != NULL) {
+ if (event->eventData == NULL)
+ return;
+
+ if (builder != NULL)
builder->appendEventNew(this, event);
- }
+
getFocus = false;
}
void IEView::clear(IEVIEWEVENT *event)
{
- IHTMLDocument2 *document = getDocument();
+ CComPtr<IHTMLDocument2> document = getDocument();
if (document == NULL) {
pWebBrowser->Navigate(L"about:blank", NULL, NULL, NULL, NULL);
HRESULT hr = S_OK;
- IHTMLDocument2 *document = NULL;
+ CComPtr<IHTMLDocument2> document;
while ((document == NULL) && (hr == S_OK)) {
Sleep(0);
- IDispatch *dispatch = NULL;
- if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && (dispatch != NULL)) {
- hr = dispatch->QueryInterface(IID_IHTMLDocument2, (void **)&document);
- dispatch->Release();
- }
- }
- if (document != NULL) {
- document->Release();
+ CComPtr<IDispatch> dispatch;
+ if (SUCCEEDED(pWebBrowser->get_Document(&dispatch)) && dispatch != NULL)
+ dispatch.QueryInterface(&document);
}
}
else {
document->close();
VARIANT open_name, open_features, open_replace;
- IDispatch *open_window = NULL;
+
VariantInit(&open_name);
open_name.vt = VT_BSTR;
open_name.bstrVal = SysAllocString(L"_self");
VariantInit(&open_features);
VariantInit(&open_replace);
+ CComPtr<IDispatch> open_window;
document->open(SysAllocString(L"text/html"), open_name, open_features, open_replace, &open_window);
- if (open_window != NULL)
- open_window->Release();
- document->Release();
}
if (builder != NULL)
builder->clear(this, event);
@@ -1022,14 +942,13 @@ void IEView::setContact(MCONTACT hContact) void IEView::translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- IOleInPlaceActiveObject* pIOIPAO;
- if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pIOIPAO))) {
+ CComPtr<IOleInPlaceActiveObject> pIOIPAO;
+ if (SUCCEEDED(pWebBrowser.QueryInterface(&pIOIPAO))) {
MSG msg;
msg.message = uMsg;
msg.wParam = wParam;
msg.lParam = lParam;
pIOIPAO->TranslateAccelerator(&msg);
- pIOIPAO->Release();
}
}
@@ -1038,29 +957,28 @@ void IEView::translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam) **/
WCHAR* IEView::getSelection()
{
- TCHAR *res = NULL;
- IHTMLDocument2 *document = getDocument();
- if (document != NULL) {
- IHTMLSelectionObject *pSelection = NULL;
- if (SUCCEEDED(document->get_selection(&pSelection)) && pSelection != NULL) {
- IDispatch *pDisp = NULL;
- if (SUCCEEDED(pSelection->createRange(&pDisp)) && pDisp != NULL) {
- IHTMLTxtRange *pRange = NULL;
- if (SUCCEEDED(pDisp->QueryInterface(IID_IHTMLTxtRange, (void**)&pRange))) {
- BSTR text = NULL;
- if (SUCCEEDED(pRange->get_text(&text))) {
- res = mir_wstrdup(text);
- ::SysFreeString(text);
- }
-
- pRange->Release();
- }
- pDisp->Release();
- }
- pSelection->Release();
- }
- document->Release();
- }
+ CComPtr<IHTMLDocument2> document = getDocument();
+ if (document == NULL)
+ return NULL;
+
+ CComPtr<IHTMLSelectionObject> pSelection;
+ if (FAILED(document->get_selection(&pSelection)) || pSelection == NULL)
+ return NULL;
+
+ CComPtr<IDispatch> pDisp;
+ if (FAILED(pSelection->createRange(&pDisp)) || pDisp == NULL)
+ return NULL;
+
+ CComPtr<IHTMLTxtRange> pRange;
+ if (FAILED(pDisp.QueryInterface(&pRange)))
+ return NULL;
+
+ BSTR text = NULL;
+ if (FAILED(pRange->get_text(&text)))
+ return NULL;
+
+ WCHAR *res = mir_wstrdup(text);
+ ::SysFreeString(text);
return res;
}
@@ -1068,98 +986,93 @@ WCHAR* IEView::getSelection() /**
* Returns the destination url (href) of the given anchor element (or parent anchor element)
**/
-WCHAR* IEView::getHrefFromAnchor(IHTMLElement *element)
-{
- if (element != NULL) {
- IHTMLAnchorElement * pAnchor;
- if (SUCCEEDED(element->QueryInterface(IID_IHTMLAnchorElement, (void**)&pAnchor)) && (pAnchor != NULL)) {
- VARIANT variant;
- BSTR url = NULL;
- if (SUCCEEDED(element->getAttribute(L"href", 2, &variant)) && (variant.vt == VT_BSTR)) {
- url = mir_wstrdup(variant.bstrVal);
- SysFreeString(variant.bstrVal);
- }
+WCHAR* IEView::getHrefFromAnchor(CComPtr<IHTMLElement> element)
+{
+ if (element == NULL)
+ return NULL;
- pAnchor->Release();
- return url;
+ CComPtr<IHTMLAnchorElement> pAnchor;
+ if (FAILED(element.QueryInterface(&pAnchor))) {
+ VARIANT variant;
+ WCHAR *url = NULL;
+ if (SUCCEEDED(element->getAttribute(L"href", 2, &variant)) && variant.vt == VT_BSTR) {
+ url = mir_wstrdup(variant.bstrVal);
+ ::SysFreeString(variant.bstrVal);
}
- IHTMLElement *parent;
- if (SUCCEEDED(element->get_parentElement(&parent)) && (parent != NULL)) {
- BSTR url = getHrefFromAnchor(parent);
- parent->Release();
- return url;
- }
+ return url;
}
+
+ CComPtr<IHTMLElement> parent;
+ if (SUCCEEDED(element->get_parentElement(&parent)) && parent != NULL)
+ return getHrefFromAnchor(parent);
+
return NULL;
}
bool IEView::mouseActivate()
{
- if (GetFocus() != hwnd) {
+ if (GetFocus() != hwnd)
getFocus = true;
- }
+
return false;
}
bool IEView::mouseClick(POINT pt)
{
- bool result = false;
if (GetFocus() != hwnd)
getFocus = true;
- IHTMLDocument2 *document = getDocument();
- if (document != NULL) {
- IHTMLElement *element;
- if (SUCCEEDED(document->elementFromPoint(pt.x, pt.y, &element)) && element != NULL) {
- WCHAR *url = getHrefFromAnchor(element);
- if (url != NULL) {
- if ((GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000))
- SendMessage(GetParent(hwnd), WM_COMMAND, IDCANCEL, 0);
-
- CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)url);
- mir_free(url);
- result = true;
- }
- element->Release();
+ CComPtr<IHTMLDocument2> document = getDocument();
+ if (document == NULL)
+ return false;
+
+ CComPtr<IHTMLElement> element;
+ if (SUCCEEDED(document->elementFromPoint(pt.x, pt.y, &element)) && element != NULL) {
+ ptrW url(getHrefFromAnchor(element));
+ if (url != NULL) {
+ if ((GetKeyState(VK_SHIFT) & 0x8000) && !(GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000))
+ SendMessage(GetParent(hwnd), WM_COMMAND, IDCANCEL, 0);
+
+ CallService(MS_UTILS_OPENURL, OUF_NEWWINDOW | OUF_TCHAR, (LPARAM)url);
+ return true;
}
- document->Release();
}
- return result;
+
+ return false;
}
bool IEView::setFocus(HWND)
{
- if (GetFocus() != hwnd && !getFocus) { // && IsChild(prevFocus, hwnd
+ if (GetFocus() != hwnd && !getFocus) {
SetFocus(GetParent(getHWND()));
- // SetFocus(prevFocus);
return true;
}
+
getFocus = false;
return false;
}
void IEView::saveDocument()
{
- IHTMLDocument2 *document = getDocument();
- if (document != NULL) {
- BSTR bCmd = SysAllocString(L"SaveAs");
- VARIANT_BOOL vb;
- VARIANT vValue;
- vValue.vt = VT_BOOL;
- vValue.boolVal = TRUE;
- document->execCommand(bCmd, VARIANT_FALSE, vValue, &vb);
- SysFreeString(bCmd);
- document->Release();
- }
+ CComPtr<IHTMLDocument2> document = getDocument();
+ if (document == NULL)
+ return;
+
+ BSTR bCmd = SysAllocString(L"SaveAs");
+ VARIANT vValue;
+ vValue.vt = VT_BOOL;
+ vValue.boolVal = TRUE;
+
+ VARIANT_BOOL vb;
+ document->execCommand(bCmd, VARIANT_FALSE, vValue, &vb);
+ ::SysFreeString(bCmd);
}
-void IEView::navigate(IEVIEWNAVIGATE * nav)
+void IEView::navigate(IEVIEWNAVIGATE *nav)
{
- if (nav->dwFlags & IENF_UNICODE) {
+ if (nav->dwFlags & IENF_UNICODE)
navigate(nav->urlW);
- }
- else {
+ else
navigate(nav->url);
- }
}
diff --git a/plugins/IEView/src/IEView.h b/plugins/IEView/src/IEView.h index 6621500830..e2e1cec47d 100644 --- a/plugins/IEView/src/IEView.h +++ b/plugins/IEView/src/IEView.h @@ -420,7 +420,8 @@ public: STDMETHODIMP_(void)FileDownload(VARIANT_BOOL*);
};
-class IEView :public IDispatch, public IOleClientSite, public IOleInPlaceSite, public IDocHostUIHandler, public IInternetSecurityManager, public IServiceProvider {
+class IEView :public IDispatch, public IOleClientSite, public IOleInPlaceSite, public IDocHostUIHandler, public IInternetSecurityManager, public IServiceProvider, public MZeroedObject
+{
private:
static IEView *list;
static mir_cs mutex;
@@ -431,9 +432,9 @@ private: RECT rcClient;
BOOL m_bInPlaceActive;
DWORD m_dwCookie;
- IConnectionPoint *m_pConnectionPoint;
+ CComPtr<IConnectionPoint> m_pConnectionPoint;
+ CComPtr<IWebBrowser2> pWebBrowser;
IEViewSink *sink;
- IWebBrowser2 *pWebBrowser;
HTMLBuilder *builder;
WNDPROC mainWndProc, docWndProc, serverWndProc;
@@ -508,7 +509,7 @@ private: STDMETHOD(GetZoneMappings)(DWORD dwZone, IEnumString **ppenumString, DWORD dwFlags);
IHTMLDocument2 *getDocument();
- WCHAR* getHrefFromAnchor(IHTMLElement *element);
+ WCHAR* getHrefFromAnchor(CComPtr<IHTMLElement> element);
WCHAR* getSelection();
void setBorder();
protected:
diff --git a/plugins/IEView/src/MUCCHTMLBuilder.cpp b/plugins/IEView/src/MUCCHTMLBuilder.cpp index de4e90fb00..cbce122cf4 100644 --- a/plugins/IEView/src/MUCCHTMLBuilder.cpp +++ b/plugins/IEView/src/MUCCHTMLBuilder.cpp @@ -123,57 +123,53 @@ void MUCCHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) {
LOGFONTA lf;
COLORREF color;
- char *output = NULL;
- int outputSize;
ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto);
- if (protoSettings == NULL) {
+ if (protoSettings == NULL)
return;
- }
- if (protoSettings->getChatMode() == Options::MODE_TEMPLATE) {
- // buildHeadTemplate(view, event);
+
+ if (protoSettings->getChatMode() == Options::MODE_TEMPLATE)
return;
- }
+
+ CMStringA str;
if (protoSettings->getChatMode() == Options::MODE_CSS) {
const char *externalCSS = protoSettings->getChatCssFilename();
- Utils::appendText(&output, &outputSize, "<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
+ str.AppendFormat("<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
}
else {
HDC hdc = GetDC(NULL);
int logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
- Utils::appendText(&output, &outputSize, "<html><head>");
- Utils::appendText(&output, &outputSize, "<style type=\"text/css\">\n");
+ str.Append("<html><head>");
+ str.Append("<style type=\"text/css\">\n");
COLORREF bkgColor = db_get_dw(NULL, MUCCMOD, "BackgroundLog", 0xFFFFFF);
COLORREF inColor, outColor;
bkgColor = (((bkgColor & 0xFF) << 16) | (bkgColor & 0xFF00) | ((bkgColor & 0xFF0000) >> 16));
inColor = outColor = bkgColor;
- if (protoSettings->getChatFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".body {padding: 2px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
+ if (protoSettings->getChatFlags() & Options::LOG_IMAGE_ENABLED)
+ str.AppendFormat(".body {padding: 2px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
protoSettings->getChatFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", (int)bkgColor, protoSettings->getChatBackgroundFilename());
- }
- else {
- Utils::appendText(&output, &outputSize, ".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n",
- (int)bkgColor);
- }
- Utils::appendText(&output, &outputSize, ".link {color: #0000FF; text-decoration: underline;}\n");
- Utils::appendText(&output, &outputSize, ".img {vertical-align: middle;}\n");
+ else
+ str.AppendFormat(".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n", bkgColor);
+
+ str.Append(".link {color: #0000FF; text-decoration: underline;}\n");
+ str.Append(".img {vertical-align: middle;}\n");
if (protoSettings->getChatFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divUserJoined {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divUserLeft {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divTopicChange {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divUserJoined {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divUserLeft {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divTopicChange {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
}
else {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)outColor);
- Utils::appendText(&output, &outputSize, ".divUserJoined {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
- Utils::appendText(&output, &outputSize, ".divUserLeft {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
- Utils::appendText(&output, &outputSize, ".divTopicChange {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
+ str.AppendFormat(".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", inColor);
+ str.AppendFormat(".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", outColor);
+ str.AppendFormat(".divUserJoined {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", inColor);
+ str.AppendFormat(".divUserLeft {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", inColor);
+ str.AppendFormat(".divTopicChange {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", inColor);
}
for (int i = 0; i < FONT_NUM; i++) {
loadMsgDlgFont(i, &lf, &color);
- Utils::appendText(&output, &outputSize, "%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
+ str.AppendFormat("%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
classNames[i],
lf.lfFaceName,
abs((signed char)lf.lfHeight) * 74 / logPixelSY,
@@ -181,12 +177,12 @@ void MUCCHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) (int)(((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)),
lf.lfItalic ? "font-style: italic;" : "");
}
- Utils::appendText(&output, &outputSize, "</style></head><body class=\"body\">\n");
- }
- if (output != NULL) {
- view->write(output);
- free(output);
+ str.Append("</style></head><body class=\"body\">\n");
}
+
+ if (!str.IsEmpty())
+ view->write(str);
+
setLastEventType(-1);
}
@@ -195,11 +191,8 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) IEVIEWEVENTDATA* eventData = event->eventData;
for (int eventIdx = 0; eventData != NULL && (eventIdx < event->count || event->count == -1); eventData = eventData->next, eventIdx++) {
DWORD dwData = eventData->dwData;
- char *style = NULL;
- int styleSize;
bool isSent = eventData->bIsMe != 0;
- int outputSize;
- char *output = NULL;
+ CMStringA str, style;
ptrA szName, szText;
if (eventData->iType == IEED_MUCC_EVENT_MESSAGE) {
if (eventData->dwFlags & IEEDF_UNICODE_TEXT)
@@ -212,37 +205,33 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) else
szName = encodeUTF8(NULL, event->pszProto, eventData->pszNick, ENF_NAMESMILEYS, true);
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", isSent ? "divOut" : "divIn");
+ str.AppendFormat("<div class=\"%s\">", isSent ? "divOut" : "divIn");
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));
+ str.AppendFormat("<span class=\"%s\">%s </span>", isSent ? "timestamp" : "timestamp", timestampToString(dwData, eventData->time));
if (dwData & IEEDD_MUCC_SHOW_NICK)
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s: </span>",
- isSent ? "nameOut" : "nameIn", szName);
+ str.AppendFormat("<span class=\"%s\">%s: </span>", isSent ? "nameOut" : "nameIn", szName);
if (dwData & IEEDD_MUCC_MSG_ON_NEW_LINE)
- Utils::appendText(&output, &outputSize, "<br>");
+ str.Append("<br>");
const char *className = isSent ? "messageOut" : "messageIn";
if (eventData->dwFlags & IEEDF_FORMAT_SIZE && eventData->fontSize > 0)
- Utils::appendText(&style, &styleSize, "font-size:%dpt;", eventData->fontSize);
+ style.AppendFormat("font-size:%dpt;", eventData->fontSize);
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));
+ style.AppendFormat("color:#%06X;", ((eventData->color & 0xFF) << 16) | (eventData->color & 0xFF00) | ((eventData->color & 0xFF0000) >> 16));
if (eventData->dwFlags & IEEDF_FORMAT_FONT)
- Utils::appendText(&style, &styleSize, "font-family:%s;", eventData->fontName);
+ style.AppendFormat("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");
- Utils::appendText(&style, &styleSize, "text-decoration: %s;", eventData->fontStyle & IE_FONT_UNDERLINE ? "underline" : "none");
+ style.AppendFormat("font-weight: %s;", eventData->fontStyle & IE_FONT_BOLD ? "bold" : "normal");
+ style.AppendFormat("font-style: %s;", eventData->fontStyle & IE_FONT_ITALIC ? "italic" : "normal");
+ style.AppendFormat("text-decoration: %s;", eventData->fontStyle & IE_FONT_UNDERLINE ? "underline" : "none");
}
- 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);
+ str.AppendFormat("<span class=\"%s\"><span style=\"%s\">%s</span></span>", className, style.c_str(), szText);
+ str.Append("</div>\n");
}
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;
@@ -264,28 +253,25 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) eventText = LPGEN("The topic is %s.");
szText = encodeUTF8(NULL, event->pszProto, eventData->pszText, ENF_ALL, isSent);
}
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", divName);
+ str.AppendFormat("<div class=\"%s\">", divName);
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));
+ str.AppendFormat("<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");
+ str.AppendFormat("<span class=\"%s\">", className);
+ str.AppendFormat(Translate(eventText), szText);
+ str.Append("</span>");
+ str.Append("</div>\n");
}
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");
+ str.AppendFormat("<div class=\"%s\">", "divError");
+ str.AppendFormat("<span class=\"%s\"> %s: %s</span>", className, Translate("Error"), szText);
+ str.Append("</div>\n");
}
- if (output != NULL) {
- view->write(output);
- free(output);
- }
+ if (!str.IsEmpty())
+ view->write(str);
}
}
diff --git a/plugins/IEView/src/ScriverHTMLBuilder.cpp b/plugins/IEView/src/ScriverHTMLBuilder.cpp index 9b60e69c5e..c7afe24d24 100644 --- a/plugins/IEView/src/ScriverHTMLBuilder.cpp +++ b/plugins/IEView/src/ScriverHTMLBuilder.cpp @@ -182,31 +182,30 @@ void ScriverHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) {
LOGFONTA lf;
COLORREF color;
- char *output = NULL;
- int outputSize;
+
ProtocolSettings *protoSettings = getSRMMProtocolSettings(event->hContact);
- if (protoSettings == NULL) {
+ if (protoSettings == NULL)
return;
- }
+
if (protoSettings->getSRMMMode() == Options::MODE_TEMPLATE) {
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, "<html><head><link rel=\"stylesheet\" href=\"file://%s\"/></head><body class=\"body\">\n", externalCSS);
- }
- else {
- Utils::appendText(&output, &outputSize, "<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
- }
+ if (strncmp(externalCSS, "http://", 7))
+ str.AppendFormat("<html><head><link rel=\"stylesheet\" href=\"file://%s\"/></head><body class=\"body\">\n", externalCSS);
+ else
+ str.AppendFormat("<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
}
else {
HDC hdc = GetDC(NULL);
int logPixelSY = GetDeviceCaps(hdc, LOGPIXELSY);
ReleaseDC(NULL, hdc);
- Utils::appendText(&output, &outputSize, "<html><head>");
- Utils::appendText(&output, &outputSize, "<style type=\"text/css\">\n");
+ str.Append("<html><head>");
+ str.Append("<style type=\"text/css\">\n");
COLORREF bkgColor = db_get_dw(NULL, SRMMMOD, "BkgColour", 0xFFFFFF);
COLORREF inColor = db_get_dw(NULL, SRMMMOD, "IncomingBkgColour", 0xFFFFFF);
COLORREF outColor = db_get_dw(NULL, SRMMMOD, "OutgoingBkgColour", 0xFFFFFF);
@@ -215,47 +214,45 @@ void ScriverHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) inColor = (((inColor & 0xFF) << 16) | (inColor & 0xFF00) | ((inColor & 0xFF0000) >> 16));
outColor = (((outColor & 0xFF) << 16) | (outColor & 0xFF00) | ((outColor & 0xFF0000) >> 16));
lineColor = (((lineColor & 0xFF) << 16) | (lineColor & 0xFF00) | ((lineColor & 0xFF0000) >> 16));
+ if (protoSettings->getSRMMFlags() & Options::LOG_IMAGE_ENABLED)
+ str.AppendFormat(".body {padding: 2px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
+ protoSettings->getSRMMFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", bkgColor, protoSettings->getSRMMBackgroundFilename());
+ else
+ str.AppendFormat(".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n", bkgColor);
+
+ str.Append(".link {color: #0000FF; text-decoration: underline;}\n");
+ str.Append(".img {}\n");
if (protoSettings->getSRMMFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".body {padding: 2px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
- protoSettings->getSRMMFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", (int)bkgColor, protoSettings->getSRMMBackgroundFilename());
+ str.Append(".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.AppendFormat(".divInGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", lineColor);
+ str.AppendFormat(".divOutGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", lineColor);
+ str.Append(".divInRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divOutRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.AppendFormat(".divInGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
+ str.AppendFormat(".divOutGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
}
else {
- Utils::appendText(&output, &outputSize, ".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n",
- (int)bkgColor);
+ str.AppendFormat(".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", inColor);
+ str.AppendFormat(".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", outColor);
+ str.AppendFormat(".divInGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
+ lineColor, inColor);
+ str.AppendFormat(".divOutGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
+ lineColor, outColor);
+ str.AppendFormat(".divInRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
+ str.AppendFormat(".divOutRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)outColor);
+ str.AppendFormat(".divInGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
+ lineColor, inColor);
+ str.AppendFormat(".divOutGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
+ lineColor, outColor);
}
- Utils::appendText(&output, &outputSize, ".link {color: #0000FF; text-decoration: underline;}\n");
- Utils::appendText(&output, &outputSize, ".img {}\n");
- if (protoSettings->getSRMMFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divInGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
- Utils::appendText(&output, &outputSize, ".divOutGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
- Utils::appendText(&output, &outputSize, ".divInRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divOutRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divInGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
- Utils::appendText(&output, &outputSize, ".divOutGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
- }
- else {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)outColor);
- Utils::appendText(&output, &outputSize, ".divInGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
- (int)lineColor, (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOutGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
- (int)lineColor, (int)outColor);
- Utils::appendText(&output, &outputSize, ".divInRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOutRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)outColor);
- Utils::appendText(&output, &outputSize, ".divInGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
- (int)lineColor, (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOutGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
- (int)lineColor, (int)outColor);
- }
- Utils::appendText(&output, &outputSize, ".divNotice {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divNoticeGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
- Utils::appendText(&output, &outputSize, ".divNoticeRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divNoticeGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
+ str.Append(".divNotice {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.AppendFormat(".divNoticeGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", lineColor);
+ str.Append(".divNoticeRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.AppendFormat(".divNoticeGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)lineColor);
for (int i = 0; i < FONT_NUM; i++) {
loadMsgDlgFont(i, &lf, &color);
- Utils::appendText(&output, &outputSize, "%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
+ str.AppendFormat("%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
classNames[i],
lf.lfFaceName,
abs((signed char)lf.lfHeight) * 74 / logPixelSY,
@@ -263,12 +260,12 @@ void ScriverHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) (int)(((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)),
lf.lfItalic ? "font-style: italic;" : "");
}
- Utils::appendText(&output, &outputSize, "</style></head><body class=\"body\">\n");
- }
- if (output != NULL) {
- view->write(output);
- free(output);
+ str.Append("</style></head><body class=\"body\">\n");
}
+
+ if (!str.IsEmpty())
+ view->write(str);
+
setLastEventType(-1);
}
@@ -292,15 +289,10 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event IEVIEWEVENTDATA* eventData = event->eventData;
for (int eventIdx = 0; eventData != NULL && (eventIdx < event->count || event->count == -1); eventData = eventData->next, eventIdx++) {
const char *className = "";
- int outputSize;
- char *output;
- output = NULL;
bool isSent = (eventData->dwFlags & IEEDF_SENT) != 0;
bool isRTL = (eventData->dwFlags & IEEDF_RTL) != 0;
showColon = false;
- if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_STATUSCHANGE ||
- eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_FILE)
- {
+ if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_STATUSCHANGE || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_FILE) {
int isGroupBreak = TRUE;
if ((dwFlags & SMF_LOG_GROUPMESSAGES) && eventData->dwFlags == LOWORD(getLastEventType()) &&
eventData->iType == IEED_EVENT_MESSAGE && HIWORD(getLastEventType()) == IEED_EVENT_MESSAGE &&
@@ -332,7 +324,9 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event else
className = isRTL ? isSent ? "divNoticeRTL" : "divNoticeRTL" : isSent ? "divNotice" : "divNotice";
}
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", className);
+
+ CMStringA str;
+ str.AppendFormat("<div class=\"%s\">", className);
if ((dwFlags & SMF_LOG_SHOWICONS) && isGroupBreak) {
const char *iconFile = "";
if (eventData->iType == IEED_EVENT_MESSAGE)
@@ -344,7 +338,7 @@ void ScriverHTMLBuilder::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 & SMF_LOG_SHOWTIME &&
@@ -364,72 +358,59 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event else timestampString = timestampToString(dwFlags, eventData->time, 0);
if (timestampString != NULL)
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s</span>",
- isSent ? "timeOut" : "timeIn", timestampString);
+ str.AppendFormat("<span class=\"%s\">%s</span>", isSent ? "timeOut" : "timeIn", timestampString);
if (eventData->iType != IEED_EVENT_MESSAGE)
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">: </span>",
- isSent ? "colonOut" : "colonIn");
+ str.AppendFormat("<span class=\"%s\">: </span>", isSent ? "colonOut" : "colonIn");
showColon = true;
}
if ((dwFlags & SMF_LOG_SHOWNICK && eventData->iType == IEED_EVENT_MESSAGE && isGroupBreak) || eventData->iType == IEED_EVENT_STATUSCHANGE) {
if (eventData->iType == IEED_EVENT_MESSAGE) {
if (showColon)
- Utils::appendText(&output, &outputSize, "<span class=\"%s\"> %s</span>",
- isSent ? "nameOut" : "nameIn", szName);
+ str.AppendFormat("<span class=\"%s\"> %s</span>", isSent ? "nameOut" : "nameIn", szName);
else
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s</span>",
- isSent ? "nameOut" : "nameIn", szName);
+ str.AppendFormat("<span class=\"%s\">%s</span>", isSent ? "nameOut" : "nameIn", szName);
showColon = true;
if (dwFlags & SMF_LOG_GROUPMESSAGES) {
- Utils::appendText(&output, &outputSize, "<br>");
+ str.Append("<br>");
showColon = false;
}
}
- else Utils::appendText(&output, &outputSize, "<span class=\"notices\">%s </span>", szName);
+ else str.AppendFormat("<span class=\"notices\">%s </span>", szName);
}
if (dwFlags & SMF_LOG_SHOWTIME && dwFlags & SMF_LOG_GROUPMESSAGES && dwFlags & SMF_LOG_MARKFOLLOWUPS
&& eventData->iType == IEED_EVENT_MESSAGE && isGroupBreak) {
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s</span>",
- isSent ? "timeOut" : "timeIn",
- timestampToString(dwFlags, eventData->time, 2));
+ str.AppendFormat("<span class=\"%s\">%s</span>", isSent ? "timeOut" : "timeIn", timestampToString(dwFlags, eventData->time, 2));
showColon = true;
}
if (showColon && eventData->iType == IEED_EVENT_MESSAGE)
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">: </span>",
- isSent ? "colonOut" : "colonIn");
+ str.AppendFormat("<span class=\"%s\">: </span>", isSent ? "colonOut" : "colonIn");
if (eventData->iType == IEED_EVENT_MESSAGE) {
if (dwFlags & SMF_LOG_MSGONNEWLINE && showColon)
- Utils::appendText(&output, &outputSize, "<br>");
+ str.Append("<br>");
className = isSent ? "messageOut" : "messageIn";
}
else className = "notices";
if (eventData->iType == IEED_EVENT_FILE) {
- if (isSent)
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s: %s</span>", className, Translate("File sent"), szText);
- else
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s: %s</span>", className, Translate("File received"), szText);
+ str.AppendFormat("<span class=\"%s\">%s: %s</span>", className,
+ (isSent) ? Translate("File sent") : Translate("File received"), szText);
}
else if (eventData->iType == IEED_EVENT_URL) {
- if (isSent)
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s: %s</span>", className, Translate("URL sent"), szText);
- else
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s: %s</span>", className, Translate("URL received"), szText);
+ str.AppendFormat("<span class=\"%s\">%s: %s</span>", className,
+ (isSent) ? Translate("URL sent") : Translate("URL received"), szText);
}
- else Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s</span>", className, szText);
+ else str.AppendFormat("<span class=\"%s\">%s</span>", className, szText);
- Utils::appendText(&output, &outputSize, "</div>\n");
+ str.Append("</div>\n");
setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType));
setLastEventTime(eventData->time);
- }
- if (output != NULL) {
- view->write(output);
- free(output);
+
+ view->write(str);
}
}
view->documentClose();
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, "<html><head><link rel=\"stylesheet\" href=\"file://%s\"/></head><body class=\"body\">\n", externalCSS);
+ str.AppendFormat("<html><head><link rel=\"stylesheet\" href=\"file://%s\"/></head><body class=\"body\">\n", externalCSS);
else
- Utils::appendText(&output, &outputSize, "<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\n", externalCSS);
+ str.AppendFormat("<html><head><link rel=\"stylesheet\" href=\"%s\"/></head><body class=\"body\">\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, "<html><head><style type=\"text/css\">\n");
+ str.Append("<html><head><style type=\"text/css\">\n");
COLORREF inColor, outColor;
COLORREF bkgColor = db_get_dw(NULL, TABSRMM_FONTMODULE, "BkgColour", 0xFFFFFF);
bkgColor = (((bkgColor & 0xFF) << 16) | (bkgColor & 0xFF00) | ((bkgColor & 0xFF0000) >> 16));
@@ -240,42 +240,38 @@ void TabSRMMHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) }
else inColor = outColor = bkgColor;
- if (protoSettings->getSRMMFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".body {margin: 0px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
- protoSettings->getSRMMFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", (int)bkgColor, protoSettings->getSRMMBackgroundFilename());
- }
- else Utils::appendText(&output, &outputSize, ".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n", (int)bkgColor);
+ if (protoSettings->getSRMMFlags() & Options::LOG_IMAGE_ENABLED)
+ str.AppendFormat(".body {margin: 0px; text-align: left; background-attachment: %s; background-color: #%06X; background-image: url('%s'); overflow: auto;}\n",
+ protoSettings->getSRMMFlags() & Options::LOG_IMAGE_SCROLL ? "scroll" : "fixed", bkgColor, protoSettings->getSRMMBackgroundFilename());
+ else
+ str.AppendFormat(".body {margin: 0px; text-align: left; background-color: #%06X; overflow: auto;}\n", bkgColor);
- Utils::appendText(&output, &outputSize, ".link {color: #0000FF; text-decoration: underline;}\n");
- Utils::appendText(&output, &outputSize, ".img {vertical-align: middle;}\n");
+ str.Append(".link {color: #0000FF; text-decoration: underline;}\n");
+ str.Append(".img {vertical-align: middle;}\n");
if (protoSettings->getSRMMFlags() & Options::LOG_IMAGE_ENABLED) {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divInGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)gridColor);
- Utils::appendText(&output, &outputSize, ".divOutGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)gridColor);
- Utils::appendText(&output, &outputSize, ".divInRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divOutRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
- Utils::appendText(&output, &outputSize, ".divInGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)gridColor);
- Utils::appendText(&output, &outputSize, ".divOutGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", (int)gridColor);
+ str.Append(".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.AppendFormat(".divInGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", gridColor);
+ str.AppendFormat(".divOutGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", gridColor);
+ str.Append(".divInRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.Append(".divOutRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word;}\n");
+ str.AppendFormat(".divInGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", gridColor);
+ str.AppendFormat(".divOutGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X}\n", gridColor);
}
else {
- Utils::appendText(&output, &outputSize, ".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)outColor);
- Utils::appendText(&output, &outputSize, ".divInGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
- (int)gridColor, (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOutGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
- (int)gridColor, (int)outColor);
- Utils::appendText(&output, &outputSize, ".divInRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOutRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", (int)outColor);
- Utils::appendText(&output, &outputSize, ".divInGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
- (int)gridColor, (int)inColor);
- Utils::appendText(&output, &outputSize, ".divOutGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n",
- (int)gridColor, (int)outColor);
+ str.AppendFormat(".divIn {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", inColor);
+ str.AppendFormat(".divOut {padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", outColor);
+ str.AppendFormat(".divInGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n", gridColor, inColor);
+ str.AppendFormat(".divOutGrid {padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n", gridColor, outColor);
+ str.AppendFormat(".divInRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", inColor);
+ str.AppendFormat(".divOutRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; background-color: #%06X;}\n", outColor);
+ str.AppendFormat(".divInGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n", gridColor, inColor);
+ str.AppendFormat(".divOutGridRTL {text-align: right; direction:RTL; unicode-bidi:embed; padding-left: 2px; padding-right: 2px; word-wrap: break-word; border-top: 1px solid #%06X; background-color: #%06X;}\n", gridColor, outColor);
}
for (int i = 0; i < FONT_NUM; i++) {
loadMsgDlgFont(i, &lf, &color);
- Utils::appendText(&output, &outputSize, "%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
+ str.AppendFormat("%s {font-family: %s; font-size: %dpt; font-weight: %s; color: #%06X; %s }\n",
classNames[i],
lf.lfFaceName,
abs((signed char)lf.lfHeight) * 74 / logPixelSY,
@@ -283,12 +279,12 @@ void TabSRMMHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) (int)(((color & 0xFF) << 16) | (color & 0xFF00) | ((color & 0xFF0000) >> 16)),
lf.lfItalic ? "font-style: italic;" : "");
}
- Utils::appendText(&output, &outputSize, "</style></head><body class=\"body\">\n");
- }
- if (output != NULL) {
- view->write(output);
- free(output);
+ str.Append("</style></head><body class=\"body\">\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, "<div class=\"%s\">", isRTL ? isSent ? "divOutGridRTL" : "divInGridRTL" : isSent ? "divOutGrid" : "divInGrid");
+ str.AppendFormat("<div class=\"%s\">", isRTL ? isSent ? "divOutGridRTL" : "divInGridRTL" : isSent ? "divOutGrid" : "divInGrid");
else
- Utils::appendText(&output, &outputSize, "<div class=\"%s\">", isRTL ? isSent ? "divOutRTL" : "divInRTL" : isSent ? "divOut" : "divIn");
+ str.AppendFormat("<div class=\"%s\">", 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, "<span class=\"%s\"><u>%s%s</span>",
- className, szName, (dwFlags & MWF_LOG_SHOWTIME) ? " </u>" : "</u>: ");
+ str.AppendFormat("<span class=\"%s\"><u>%s%s</span>", className, szName, (dwFlags & MWF_LOG_SHOWTIME) ? " </u>" : "</u>: ");
else
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s%s</span>",
- className, szName, (dwFlags & MWF_LOG_SHOWTIME) ? " " : ": ");
+ str.AppendFormat("<span class=\"%s\">%s%s</span>", 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, "<span class=\"%s\"><u>%s%s</span>",
- className, timestampToString(dwFlags, eventData->time, isGroupBreak),
- (!isGroupBreak || (eventData->iType == IEED_EVENT_STATUSCHANGE) || (dwFlags & MWF_LOG_SWAPNICK) || !(dwFlags & MWF_LOG_SHOWNICK)) ? "</u>: " : " </u>");
+ str.AppendFormat("<span class=\"%s\"><u>%s%s</span>", className, timestampToString(dwFlags, eventData->time, isGroupBreak),
+ (!isGroupBreak || (eventData->iType == IEED_EVENT_STATUSCHANGE) || (dwFlags & MWF_LOG_SWAPNICK) || !(dwFlags & MWF_LOG_SHOWNICK)) ? "</u>: " : " </u>");
else
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s%s</span>",
- className, timestampToString(dwFlags, eventData->time, isGroupBreak),
- (!isGroupBreak || (eventData->iType == IEED_EVENT_STATUSCHANGE) || (dwFlags & MWF_LOG_SWAPNICK) || !(dwFlags & MWF_LOG_SHOWNICK)) ? ": " : " ");
+ str.AppendFormat("<span class=\"%s\">%s%s</span>", 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, "<span class=\"statusChange\">%s </span>", szName);
+ str.AppendFormat("<span class=\"statusChange\">%s </span>", 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, "<span class=\"%s\"><u>%s</u>: </span>", className, szName);
+ str.AppendFormat("<span class=\"%s\"><u>%s</u>: </span>", className, szName);
else
- Utils::appendText(&output, &outputSize, "<span class=\"%s\">%s: </span>", className, szName);
+ str.AppendFormat("<span class=\"%s\">%s: </span>", className, szName);
}
}
if (dwFlags & MWF_LOG_NEWLINE && eventData->iType != IEED_EVENT_STATUSCHANGE && eventData->iType != IEED_EVENT_ERRMSG && isGroupBreak)
- Utils::appendText(&output, &outputSize, "<br>");
+ str.Append("<br>");
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, "<span class=\"%s\">%s</span>", className, szText);
- Utils::appendText(&output, &outputSize, "</div>\n");
+ str.AppendFormat("<span class=\"%s\">%s</span>", className, szText);
+ str.Append("</div>\n");
setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType));
setLastEventTime(eventData->time);
- }
- if (output != NULL) {
- view->write(output);
- free(output);
+
+ view->write(str);
}
}
diff --git a/plugins/IEView/src/Template.cpp b/plugins/IEView/src/Template.cpp index 8c9d8e7acb..fbf87fc871 100644 --- a/plugins/IEView/src/Template.cpp +++ b/plugins/IEView/src/Template.cpp @@ -354,8 +354,7 @@ TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename, char store[4096];
bool wasTemplate = false;
- char *templateText = NULL;
- int templateTextSize = 0;
+ CMStringA templateText;
while (fgets(store, sizeof(store), fh) != NULL) {
if (sscanf(store, "%s", tmp2) == EOF) continue;
//template start
@@ -370,19 +369,16 @@ TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename, if (wasTemplate)
tmap->addTemplate(lastTemplate, templateText);
- if (templateText)
- free(templateText), templateText = NULL;
- templateTextSize = 0;
+ templateText.Empty();
wasTemplate = true;
sscanf(store, "<!--%[^-]", lastTemplate);
}
else if (wasTemplate)
- Utils::appendText(&templateText, &templateTextSize, "%s", store);
+ templateText.Append(store);
}
if (wasTemplate)
tmap->addTemplate(lastTemplate, templateText);
- if (templateText)
- free(templateText), templateText = NULL;
+ templateText.Empty();
fclose(fh);
static const char *groupTemplates[] = { "MessageInGroupStart", "MessageInGroupInner",
diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp index 32711fbccf..864d37e6fe 100644 --- a/plugins/IEView/src/TemplateHTMLBuilder.cpp +++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp @@ -244,8 +244,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr tmplt = tmpm->getTemplate("HTMLStart");
}
- char *output = NULL;
- int outputSize;
+ CMStringA str;
if (tmplt != NULL) {
for (Token *token = tmplt->getTokens(); token != NULL; token = token->getNext()) {
@@ -291,16 +290,16 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr }
if (tokenVal != NULL) {
if (token->getEscape())
- Utils::appendText(&output, &outputSize, "%s", ptrA(Utils::escapeString(tokenVal)));
+ str.Append(ptrA(Utils::escapeString(tokenVal)));
else
- Utils::appendText(&output, &outputSize, "%s", tokenVal);
+ str.Append(tokenVal);
}
}
}
- if (output != NULL) {
- view->write(output);
- free(output);
- }
+
+ if (!str.IsEmpty())
+ view->write(str);
+
mir_free(szBase);
mir_free(szRealProto);
mir_free(szProto);
@@ -419,9 +418,8 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, 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_STATUSCHANGE || eventData->iType == IEED_EVENT_FILE || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_SYSTEM) {
+ CMStringA str;
bool isSent = (eventData->dwFlags & IEEDF_SENT) != 0;
bool isRTL = (eventData->dwFlags & IEEDF_RTL) && tmpm->isRTL();
bool isHistory = (eventData->time < (DWORD)getStartedTime() && (eventData->dwFlags & IEEDF_READ || eventData->dwFlags & IEEDF_SENT));
@@ -596,9 +594,9 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, }
if (tokenVal != NULL) {
if (token->getEscape())
- Utils::appendText(&output, &outputSize, "%s", ptrA(Utils::escapeString(tokenVal)));
+ str.Append(ptrA(Utils::escapeString(tokenVal)));
else
- Utils::appendText(&output, &outputSize, "%s", tokenVal);
+ str.Append(tokenVal);
}
}
}
@@ -608,10 +606,8 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, mir_free(szName);
mir_free(szText);
mir_free(szFileDesc);
- }
- if (output != NULL) {
- view->write(output);
- free(output);
+
+ view->write(str);
}
}
mir_free(szBase);
diff --git a/plugins/IEView/src/TextToken.cpp b/plugins/IEView/src/TextToken.cpp index 5af554cfb7..14c8b2500b 100644 --- a/plugins/IEView/src/TextToken.cpp +++ b/plugins/IEView/src/TextToken.cpp @@ -500,13 +500,13 @@ wchar_t *TextToken::htmlEncode(const wchar_t *str) return output;
}
-void TextToken::toString(wchar_t **str, int *sizeAlloced)
+void TextToken::toString(CMStringW &str)
{
wchar_t *eText = NULL, *eLink = NULL;
switch (type) {
case TEXT:
eText = htmlEncode(wtext);
- Utils::appendText(str, sizeAlloced, L"%s", eText);
+ str.Append(eText);
break;
case WWWLINK:
case LINK:
@@ -547,7 +547,7 @@ void TextToken::toString(wchar_t **str, int *sizeAlloced) };
- Utils::appendText(str, sizeAlloced, L"<div><object width=\"%d\" height=\"%d\">\
+ str.AppendFormat(L"<div><object width=\"%d\" height=\"%d\">\
<param name=\"movie\" value=\"http://www.youtube.com/v/%s&feature=player_embedded&version=3\"/>\
<param name=\"allowFullScreen\" value=\"true\"/>\
<param name=\"allowScriptAccess\" value=\"true\"/>\
@@ -558,126 +558,111 @@ void TextToken::toString(wchar_t **str, int *sizeAlloced) }
}
}
- Utils::appendText(str, sizeAlloced, L"<a class=\"link\" target=\"_self\" href=\"%s%s\">%s</a>", linkPrefix, eLink, eText);
+ str.AppendFormat(L"<a class=\"link\" target=\"_self\" href=\"%s%s\">%s</a>", linkPrefix, eLink, eText);
}
break;
case SMILEY:
eText = htmlEncode(wtext);
if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(wlink, L".swf") != NULL)) {
- Utils::appendText(str, sizeAlloced,
- L"<span title=\"%s\" class=\"img\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
+ str.AppendFormat(L"<span title=\"%s\" class=\"img\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" >\
<param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></span>",
eText, wlink);
}
- else {
- Utils::appendText(str, sizeAlloced, L"<img class=\"img\" src=\"file://%s\" title=\"%s\" alt=\"%s\" />", wlink, eText, eText);
- }
+ else str.AppendFormat(L"<img class=\"img\" src=\"file://%s\" title=\"%s\" alt=\"%s\" />", wlink, eText, eText);
break;
case MATH:
eText = htmlEncode(wtext);
- Utils::appendText(str, sizeAlloced, L"<img class=\"img\" src=\"file://%s\" title=\"%s\" alt=\"%s\" />", wlink, eText, eText);
+ str.AppendFormat(L"<img class=\"img\" src=\"file://%s\" title=\"%s\" alt=\"%s\" />", wlink, eText, eText);
break;
case BBCODE:
if (!end) {
switch (tag) {
case BB_B:
- //Utils::appendText(str, sizeAlloced, L"<span style=\"font-weight: bold;\">");
- Utils::appendText(str, sizeAlloced, L"<b>");
+ str.Append(L"<b>");
break;
case BB_I:
- //Utils::appendText(str, sizeAlloced, L"<span style=\"font-style: italic;\">");
- Utils::appendText(str, sizeAlloced, L"<i>");
+ str.Append(L"<i>");
break;
case BB_U:
- //Utils::appendText(str, sizeAlloced, L"<span style=\"text-decoration: underline;\">");
- Utils::appendText(str, sizeAlloced, L"<u>");
+ str.Append(L"<u>");
break;
case BB_S:
- //Utils::appendText(str, sizeAlloced, L"<span style=\"font-style: italic;\">");
- Utils::appendText(str, sizeAlloced, L"<s>");
+ str.Append(L"<s>");
break;
case BB_CODE:
- //Utils::appendText(str, sizeAlloced, L"<span style=\"font-style: italic;\">");
- Utils::appendText(str, sizeAlloced, L"<pre class=\"code\">");
+ str.Append(L"<pre class=\"code\">");
break;
case BB_IMG:
eText = htmlEncode(wtext);
if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && eText != NULL && (wcsstr(eText, L".swf") != NULL)) {
- Utils::appendText(str, sizeAlloced,
- L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
+ str.AppendFormat(L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"100%%\" >\
<param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></div>",
eText);
}
else {
- if (eText != NULL && wcsncmp(eText, L"http://", 7) && wcsncmp(eText, L"https://", 8)) {
- Utils::appendText(str, sizeAlloced, L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><img class=\"img\" style=\"width: expression((maxw = this.parentNode.offsetWidth ) > this.width ? 'auto' : maxw);\" src=\"file://%s\" /></div>", eText);
- }
- else {
- Utils::appendText(str, sizeAlloced, L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><img class=\"img\" style=\"width: expression((maxw = this.parentNode.offsetWidth ) > this.width ? 'auto' : maxw);\" src=\"%s\" /></div>", eText);
- }
+ if (eText != NULL && wcsncmp(eText, L"http://", 7) && wcsncmp(eText, L"https://", 8))
+ str.AppendFormat(L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><img class=\"img\" style=\"width: expression((maxw = this.parentNode.offsetWidth ) > this.width ? 'auto' : maxw);\" src=\"file://%s\" /></div>", eText);
+ else
+ str.AppendFormat(L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><img class=\"img\" style=\"width: expression((maxw = this.parentNode.offsetWidth ) > this.width ? 'auto' : maxw);\" src=\"%s\" /></div>", eText);
}
break;
case BB_BIMG:
eText = htmlEncode(mir_ptr<wchar_t>(Utils::toAbsolute(wtext)));
if ((Options::getGeneralFlags()&Options::GENERAL_ENABLE_FLASH) && (wcsstr(eText, L".swf") != NULL)) {
- Utils::appendText(str, sizeAlloced,
- L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
+ str.AppendFormat(L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" \
codebase=\"http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0\" width=\"100%%\" >\
<param NAME=\"movie\" VALUE=\"%s\"><param NAME=\"quality\" VALUE=\"high\"><PARAM NAME=\"loop\" VALUE=\"true\"></object></div>",
eText);
}
- else {
- Utils::appendText(str, sizeAlloced, L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><img class=\"img\" style=\"width: expression((maxw = this.parentNode.offsetWidth ) > this.width ? 'auto' : maxw);\" src=\"file://%s\" /></div>", eText);
- }
+ else str.AppendFormat(L"<div style=\"width: 100%%; border: 0; overflow: hidden;\"><img class=\"img\" style=\"width: expression((maxw = this.parentNode.offsetWidth ) > this.width ? 'auto' : maxw);\" src=\"file://%s\" /></div>", eText);
break;
case BB_URL:
eText = htmlEncode(wtext);
eLink = htmlEncode(wlink);
- Utils::appendText(str, sizeAlloced, L"<a href =\"%s\">%s</a>", eLink, eText);
+ str.AppendFormat(L"<a href =\"%s\">%s</a>", eLink, eText);
break;
case BB_COLOR:
eText = htmlEncode(wtext);
- //Utils::appendText(str, sizeAlloced, L"<span style=\"color: %s;\">", eText);
- Utils::appendText(str, sizeAlloced, L"<font color =\"%s\">", eText);
+ str.AppendFormat(L"<font color =\"%s\">", eText);
break;
case BB_BACKGROUND:
eText = htmlEncode(wtext);
- Utils::appendText(str, sizeAlloced, L"<span style=\"background: %s;\">", eText);
+ str.AppendFormat(L"<span style=\"background: %s;\">", eText);
break;
case BB_SIZE:
eText = htmlEncode(wtext);
- Utils::appendText(str, sizeAlloced, L"<span style=\"font-size: %s;\">", eText);
+ str.AppendFormat(L"<span style=\"font-size: %s;\">", eText);
break;
}
}
else {
switch (tag) {
case BB_B:
- Utils::appendText(str, sizeAlloced, L"</b>");
+ str.Append(L"</b>");
break;
case BB_I:
- Utils::appendText(str, sizeAlloced, L"</i>");
+ str.Append(L"</i>");
break;
case BB_U:
- Utils::appendText(str, sizeAlloced, L"</u>");
+ str.Append(L"</u>");
break;
case BB_S:
- Utils::appendText(str, sizeAlloced, L"</s>");
+ str.Append(L"</s>");
break;
case BB_CODE:
- Utils::appendText(str, sizeAlloced, L"</pre>");
+ str.Append(L"</pre>");
break;
case BB_COLOR:
- Utils::appendText(str, sizeAlloced, L"</font>");
+ str.Append(L"</font>");
break;
case BB_SIZE:
- Utils::appendText(str, sizeAlloced, L"</span>");
+ str.Append(L"</span>");
break;
case BB_BACKGROUND:
- Utils::appendText(str, sizeAlloced, L"</span>");
+ str.Append(L"</span>");
break;
}
}
diff --git a/plugins/IEView/src/TextToken.h b/plugins/IEView/src/TextToken.h index 512eca85fa..7e5ef3260c 100644 --- a/plugins/IEView/src/TextToken.h +++ b/plugins/IEView/src/TextToken.h @@ -81,7 +81,7 @@ public: void setLink(const char *link);
void setLink(const wchar_t *wlink);
- void toString(wchar_t **str, int *sizeAlloced);
+ void toString(CMStringW &str);
static wchar_t* htmlEncode(const wchar_t *str);
static TextToken* tokenizeLinks(const wchar_t *wtext);
diff --git a/plugins/IEView/src/Utils.cpp b/plugins/IEView/src/Utils.cpp index 0c2d2a8d6b..76a3488d90 100644 --- a/plugins/IEView/src/Utils.cpp +++ b/plugins/IEView/src/Utils.cpp @@ -49,76 +49,6 @@ static int countNoWhitespace(const wchar_t *str) return c;
}
-void Utils::appendText(char **str, int *sizeAlloced, const char *fmt, ...)
-{
- va_list vararg;
- char *p;
- int size, len;
-
- if (str == NULL) return;
-
- if (*str == NULL || *sizeAlloced <= 0) {
- *sizeAlloced = size = 2048;
- *str = (char *)malloc(size);
- len = 0;
- }
- else {
- len = (int)strlen(*str);
- size = *sizeAlloced - len;
- }
-
- if (size < 128) {
- size += 2048;
- (*sizeAlloced) += 2048;
- *str = (char *)realloc(*str, *sizeAlloced);
- }
- p = *str + len;
- va_start(vararg, fmt);
- while (mir_vsnprintf(p, size - 1, fmt, vararg) == -1) {
- size += 2048;
- (*sizeAlloced) += 2048;
- *str = (char *)realloc(*str, *sizeAlloced);
- p = *str + len;
- }
- p[size - 1] = '\0';
- va_end(vararg);
-}
-
-void Utils::appendText(wchar_t **str, int *sizeAlloced, const wchar_t *fmt, ...)
-{
- va_list vararg;
- wchar_t *p;
- int size, len;
-
- if (str == NULL) return;
-
- if (*str == NULL || *sizeAlloced <= 0) {
- *sizeAlloced = size = 2048;
- *str = (wchar_t *)malloc(size);
- len = 0;
- }
- else {
- len = (int)wcslen(*str);
- size = *sizeAlloced - sizeof(wchar_t) * len;
- }
-
- if (size < 128) {
- size += 2048;
- (*sizeAlloced) += 2048;
- *str = (wchar_t *)realloc(*str, *sizeAlloced);
- }
- p = *str + len;
- va_start(vararg, fmt);
- while (mir_vsnwprintf(p, size / sizeof(wchar_t) - 1, fmt, vararg) == -1) {
- size += 2048;
- (*sizeAlloced) += 2048;
- *str = (wchar_t *)realloc(*str, *sizeAlloced);
- p = *str + len;
- }
- p[size / sizeof(wchar_t) - 1] = '\0';
- va_end(vararg);
-}
-
void Utils::convertPath(char *path)
{
if (path != NULL) {
@@ -181,9 +111,9 @@ char *Utils::escapeString(const char *a) return out;
}
-void Utils::appendIcon(char **str, int *sizeAlloced, const char *iconFile)
+void Utils::appendIcon(CMStringA &str, const char *iconFile)
{
- Utils::appendText(str, sizeAlloced, "<img class=\"img\" src=\"file://%s/plugins/ieview/%s\"/> ", workingDirUtf8, iconFile);
+ str.AppendFormat("<img class=\"img\" src=\"file://%s/plugins/ieview/%s\"/> ", workingDirUtf8, iconFile);
}
bool Utils::DbEventIsForMsgWindow(DBEVENTINFO *dbei)
diff --git a/plugins/IEView/src/Utils.h b/plugins/IEView/src/Utils.h index 87f107ce09..38d8cdddc2 100644 --- a/plugins/IEView/src/Utils.h +++ b/plugins/IEView/src/Utils.h @@ -35,9 +35,7 @@ private: public:
static const wchar_t *getBaseDir();
static wchar_t* toAbsolute(wchar_t* relative);
- static void appendIcon(char **str, int *sizeAlloced, const char *iconFile);
- static void appendText(char **str, int *sizeAlloced, const char *fmt, ...);
- static void appendText(wchar_t **str, int *sizeAlloced, const wchar_t *fmt, ...);
+ static void appendIcon(CMStringA &str, const char *iconFile);
static void convertPath(char *path);
static void convertPath(wchar_t *path);
static char *escapeString(const char *a);
diff --git a/plugins/IEView/src/Version.h b/plugins/IEView/src/Version.h index 4452266fa0..3d524da0c5 100644 --- a/plugins/IEView/src/Version.h +++ b/plugins/IEView/src/Version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 1
-#define __MINOR_VERSION 4
+#define __MINOR_VERSION 5
#define __RELEASE_NUM 0
-#define __BUILD_NUM 4
+#define __BUILD_NUM 1
#include <stdver.h>
diff --git a/plugins/IEView/src/ieview_common.h b/plugins/IEView/src/ieview_common.h index fe3301f549..0e648ccfda 100644 --- a/plugins/IEView/src/ieview_common.h +++ b/plugins/IEView/src/ieview_common.h @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define _CRT_SECURE_NO_WARNINGS
#define _CRT_NONSTDC_NO_DEPRECATE
-#define _WIN32_WINNT 0x0501
+#define _WIN32_WINNT 0x0601
#include <windows.h>
#include <commctrl.h>
@@ -33,6 +33,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <process.h>
#include <shlguid.h>
#include <mshtml.h>
+
+#include <msapi/comptr.h>
+
#include <io.h>
#include <fcntl.h>
@@ -50,6 +53,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <m_chat.h>
#include <m_icolib.h>
#include <m_netlib.h>
+#include <m_string.h>
#include <m_smileyadd.h>
#include <m_ieview.h>
|