summaryrefslogtreecommitdiff
path: root/plugins/IEView/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/IEView/src')
-rw-r--r--plugins/IEView/src/ChatHTMLBuilder.cpp4
-rw-r--r--plugins/IEView/src/HTMLBuilder.cpp6
-rw-r--r--plugins/IEView/src/HistoryHTMLBuilder.cpp4
-rw-r--r--plugins/IEView/src/MUCCHTMLBuilder.cpp4
-rw-r--r--plugins/IEView/src/ScriverHTMLBuilder.cpp4
-rw-r--r--plugins/IEView/src/TabSRMMHTMLBuilder.cpp8
-rw-r--r--plugins/IEView/src/TemplateHTMLBuilder.cpp72
-rw-r--r--plugins/IEView/src/Utils.cpp60
-rw-r--r--plugins/IEView/src/Utils.h4
-rw-r--r--plugins/IEView/src/ieview_main.cpp4
10 files changed, 61 insertions, 109 deletions
diff --git a/plugins/IEView/src/ChatHTMLBuilder.cpp b/plugins/IEView/src/ChatHTMLBuilder.cpp
index 8eedfa1ef1..636f070464 100644
--- a/plugins/IEView/src/ChatHTMLBuilder.cpp
+++ b/plugins/IEView/src/ChatHTMLBuilder.cpp
@@ -87,7 +87,9 @@ char *ChatHTMLBuilder::timestampToString(time_t time)
char *pszStamp = "[%H:%M]";
//InitSetting( &g_Settings.pszTimeStamp, "HeaderTime", _T("[%H:%M]"));
strftime(str, 79, pszStamp, localtime(&time));
- Utils::UTF8Encode(str, szResult, 500);
+ char *tmp = mir_utf8encode(str);
+ lstrcpynA(szResult, tmp, 500);
+ mir_free(tmp);
return szResult;
}
diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp
index 1ce651da9f..0739b6ff3b 100644
--- a/plugins/IEView/src/HTMLBuilder.cpp
+++ b/plugins/IEView/src/HTMLBuilder.cpp
@@ -102,7 +102,7 @@ char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const wchar_t
char *outputStr = NULL;
if (wtext != NULL) {
wchar_t *output = encode(hContact, proto, wtext, flags, isSent);
- outputStr = Utils::UTF8Encode(output);
+ outputStr = mir_utf8encodeT(output);
if (output != NULL) {
free(output);
}
@@ -224,7 +224,7 @@ void HTMLBuilder::getUINs(HANDLE hContact, char *&uinIn, char *&uinOut) {
break;
}
}
- uinIn = Utils::UTF8Encode(buf);
+ uinIn = mir_utf8encode(buf);
ci.hContact = NULL;
buf[0] = 0;
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
@@ -238,7 +238,7 @@ void HTMLBuilder::getUINs(HANDLE hContact, char *&uinIn, char *&uinOut) {
break;
}
}
- uinOut = Utils::UTF8Encode(buf);
+ uinOut = mir_utf8encode(buf);
delete szProto;
}
diff --git a/plugins/IEView/src/HistoryHTMLBuilder.cpp b/plugins/IEView/src/HistoryHTMLBuilder.cpp
index f0cb077253..129941cf5c 100644
--- a/plugins/IEView/src/HistoryHTMLBuilder.cpp
+++ b/plugins/IEView/src/HistoryHTMLBuilder.cpp
@@ -89,7 +89,9 @@ char *HistoryHTMLBuilder::timestampToString(DWORD dwFlags, time_t check) {
dbtts.szFormat = (char *)"d t";
CallService(MS_DB_TIME_TIMESTAMPTOSTRING, check, (LPARAM) & dbtts);
strncat(szResult, str, 500);
- Utils::UTF8Encode(szResult, szResult, 500);
+ char *tmp = mir_utf8encode(szResult);
+ lstrcpynA(szResult, tmp, 500);
+ mir_free(tmp);
return szResult;
}
diff --git a/plugins/IEView/src/MUCCHTMLBuilder.cpp b/plugins/IEView/src/MUCCHTMLBuilder.cpp
index 92603a3fc5..962fb44b5a 100644
--- a/plugins/IEView/src/MUCCHTMLBuilder.cpp
+++ b/plugins/IEView/src/MUCCHTMLBuilder.cpp
@@ -109,7 +109,9 @@ char *MUCCHTMLBuilder::timestampToString(DWORD dwData, time_t check)
}
CallService(MS_DB_TIME_TIMESTAMPTOSTRING, check, (LPARAM) & dbtts);
strncat(szResult, str, 500);
- Utils::UTF8Encode(szResult, szResult, 500);
+ char *tmp = mir_utf8encode(szResult);
+ lstrcpynA(szResult, tmp, 500);
+ mir_free(tmp);
return szResult;
}
diff --git a/plugins/IEView/src/ScriverHTMLBuilder.cpp b/plugins/IEView/src/ScriverHTMLBuilder.cpp
index cef26fc459..8d43424b26 100644
--- a/plugins/IEView/src/ScriverHTMLBuilder.cpp
+++ b/plugins/IEView/src/ScriverHTMLBuilder.cpp
@@ -171,7 +171,9 @@ char *ScriverHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int mod
//_tcsncat(szResult, str, 500);
strncat(szResult, str, 500);
}
- Utils::UTF8Encode(szResult, szResult, 500);
+ char *tmp = mir_utf8encode(szResult);
+ lstrcpynA(szResult, tmp, 500);
+ mir_free(tmp);
return szResult;
}
diff --git a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp
index 4bf26980c7..aad617fd6d 100644
--- a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp
+++ b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp
@@ -197,7 +197,9 @@ char *TabSRMMHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int isG
}
CallService(MS_DB_TIME_TIMESTAMPTOSTRING, check, (LPARAM) & dbtts);
strncat(szResult, str, 500);
- Utils::UTF8Encode(szResult, szResult, 500);
+ char *tmp = mir_utf8encode(szResult);
+ lstrcpynA(szResult, tmp, 500);
+ mir_free(tmp);
return szResult;
}
@@ -419,8 +421,8 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event
Utils::appendText(&output, &outputSize, "</div>\n");
setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType));
setLastEventTime(eventData->time);
- if (szName!=NULL) delete szName;
- if (szText!=NULL) delete szText;
+ if (szName!=NULL) mir_free(szName);
+ if (szText!=NULL) mir_free(szText);
}
if (output != NULL) {
view->write(output);
diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp
index 247b927888..daf79229a7 100644
--- a/plugins/IEView/src/TemplateHTMLBuilder.cpp
+++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp
@@ -82,7 +82,7 @@ char *TemplateHTMLBuilder::getAvatar(HANDLE hContact, const char * szProto) {
}
DBFreeVariant(&dbv);
}
- char* res = Utils::UTF8Encode(result);
+ char* res = mir_utf8encodeT(result);
Utils::convertPath(res);
return res;
}
@@ -145,7 +145,9 @@ char *TemplateHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int mo
CallService(MS_DB_TIME_TIMESTAMPTOSTRINGT, check, (LPARAM) & dbtts);
}
}
- Utils::UTF8Encode(str, szResult, 500);
+ char *tmp = mir_utf8encodeT(str);
+ lstrcpynA(szResult, tmp, 500);
+ mir_free(tmp);
return szResult;
}
@@ -190,7 +192,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr
pathrun++;
*pathrun = '\0';
- szBase = Utils::UTF8Encode(tempBase);
+ szBase = mir_utf8encode(tempBase);
getUINs(event->hContact, szUINIn, szUINOut);
if (getFlags(protoSettings) & Options::LOG_SHOW_NICKNAMES) {
szNameOut = getEncodedContactName(NULL, szProto, szRealProto);
@@ -200,11 +202,11 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr
szNameIn = Utils::dupString("&nbsp;");
}
sprintf(tempStr, "%snoavatar.png", tempBase);
- szNoAvatar = Utils::UTF8Encode(tempStr);
+ szNoAvatar = mir_utf8encode(tempStr);
if (access(szNoAvatar, 0) == -1)
{
sprintf(tempStr, "%snoavatar.jpg", tempBase);
- szNoAvatar = Utils::UTF8Encode(tempStr);
+ szNoAvatar = mir_utf8encode(tempStr);
}
szAvatarIn = getAvatar(event->hContact, szRealProto);
if (szAvatarIn == NULL) {
@@ -216,7 +218,7 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr
}
if (!DBGetContactSetting(event->hContact, "CList", "StatusMsg",&dbv)) {
if (strlen(dbv.pszVal) > 0) {
- szStatusMsg = Utils::UTF8Encode(dbv.pszVal);
+ szStatusMsg = mir_utf8encode(dbv.pszVal);
}
DBFreeVariant(&dbv);
}
@@ -298,19 +300,19 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr
view->write(output);
free(output);
}
- if (szBase!=NULL) delete szBase;
+ if (szBase!=NULL) mir_free(szBase);
if (szRealProto!=NULL) delete szRealProto;
if (szProto!=NULL) delete szProto;
- if (szUINIn!=NULL) delete szUINIn;
- if (szUINOut!=NULL) delete szUINOut;
- if (szNoAvatar!=NULL) delete szNoAvatar;
- if (szAvatarIn!=NULL) delete szAvatarIn;
- if (szAvatarOut!=NULL) delete szAvatarOut;
- if (szNameIn!=NULL) delete szNameIn;
- if (szNameOut!=NULL) delete szNameOut;
- if (szNickIn!=NULL) delete szNickIn;
- if (szNickOut!=NULL) delete szNickOut;
- if (szStatusMsg!=NULL) delete szStatusMsg;
+ if (szUINIn!=NULL) mir_free(szUINIn);
+ if (szUINOut!=NULL) mir_free(szUINOut);
+ if (szNoAvatar!=NULL) mir_free(szNoAvatar);
+ if (szAvatarIn!=NULL) mir_free(szAvatarIn);
+ if (szAvatarOut!=NULL) mir_free(szAvatarOut);
+ if (szNameIn!=NULL) mir_free(szNameIn);
+ if (szNameOut!=NULL) mir_free(szNameOut);
+ if (szNickIn!=NULL) mir_free(szNickIn);
+ if (szNickOut!=NULL) mir_free(szNickOut);
+ if (szStatusMsg!=NULL) mir_free(szStatusMsg);
//view->scrollToBottom();
groupTemplate = NULL;
iLastEventType = -1;
@@ -362,7 +364,7 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event,
*pathrun = '\0';
isGrouping = tmpm->isGrouping();
}
- szBase = Utils::UTF8Encode(tempBase);
+ szBase = mir_utf8encode(tempBase);
if (event->hContact != NULL) {
getUINs(event->hContact, szUINIn, szUINOut);
@@ -376,11 +378,11 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event,
szNameIn = Utils::dupString("&nbsp;");
}
sprintf(tempStr, "%snoavatar.png", tempBase);
- szNoAvatar = Utils::UTF8Encode(tempStr);
+ szNoAvatar = mir_utf8encode(tempStr);
if (access(szNoAvatar, 0) == -1)
{
sprintf(tempStr, "%snoavatar.jpg", tempBase);
- szNoAvatar = Utils::UTF8Encode(tempStr);
+ szNoAvatar = mir_utf8encode(tempStr);
}
if(event->hContact != NULL) {
@@ -396,7 +398,7 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event,
if(event->hContact != NULL) {
if (!DBGetContactSetting(event->hContact, "CList", "StatusMsg",&dbv)) {
if (strlen(dbv.pszVal) > 0) {
- szStatusMsg = Utils::UTF8Encode(dbv.pszVal);
+ szStatusMsg = mir_utf8encode(dbv.pszVal);
}
DBFreeVariant(&dbv);
}
@@ -614,28 +616,28 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event,
}
setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType));
setLastEventTime(eventData->time);
- if (szName!=NULL) delete szName;
- if (szText!=NULL) delete szText;
- if (szFileDesc!=NULL) delete szFileDesc;
+ if (szName!=NULL) mir_free(szName);
+ if (szText!=NULL) mir_free(szText);
+ if (szFileDesc!=NULL) mir_free(szFileDesc);
}
if (output != NULL) {
view->write(output);
free(output);
}
}
- if (szBase!=NULL) delete szBase;
+ if (szBase!=NULL) mir_free(szBase);
if (szRealProto!=NULL) delete szRealProto;
if (szProto!=NULL) delete szProto;
- if (szUINIn!=NULL) delete szUINIn;
- if (szUINOut!=NULL) delete szUINOut;
- if (szNoAvatar!=NULL) delete szNoAvatar;
- if (szAvatarIn!=NULL) delete szAvatarIn;
- if (szAvatarOut!=NULL) delete szAvatarOut;
- if (szNameIn!=NULL) delete szNameIn;
- if (szNameOut!=NULL) delete szNameOut;
- if (szNickIn!=NULL) delete szNickIn;
- if (szNickOut!=NULL) delete szNickOut;
- if (szStatusMsg!=NULL) delete szStatusMsg;
+ if (szUINIn!=NULL) mir_free(szUINIn);
+ if (szUINOut!=NULL) mir_free(szUINOut);
+ if (szNoAvatar!=NULL) mir_free(szNoAvatar);
+ if (szAvatarIn!=NULL) mir_free(szAvatarIn);
+ if (szAvatarOut!=NULL) mir_free(szAvatarOut);
+ if (szNameIn!=NULL) mir_free(szNameIn);
+ if (szNameOut!=NULL) mir_free(szNameOut);
+ if (szNickIn!=NULL) mir_free(szNickIn);
+ if (szNickOut!=NULL) mir_free(szNickOut);
+ if (szStatusMsg!=NULL) mir_free(szStatusMsg);
view->documentClose();
}
diff --git a/plugins/IEView/src/Utils.cpp b/plugins/IEView/src/Utils.cpp
index d9a3f85043..ab30e81e72 100644
--- a/plugins/IEView/src/Utils.cpp
+++ b/plugins/IEView/src/Utils.cpp
@@ -229,62 +229,6 @@ DWORD Utils::safe_wcslen(wchar_t *msg, DWORD maxLen) {
return 0;
}
-char * Utils::UTF8Encode(const wchar_t *wtext) {
- unsigned char *szOut;
- int len, i;
- const wchar_t *w;
-
- if (wtext == NULL) return NULL;
- for (len=0, w=wtext; *w; w++) {
- if (*w < 0x0080) len++;
- else if (*w < 0x0800) len += 2;
- else len += 3;
- }
- szOut = new unsigned char [len+1];
- if (szOut == NULL) return NULL;
-
- for (i=0, w=wtext; *w; w++) {
- if (*w < 0x0080)
- szOut[i++] = (unsigned char) *w;
- else if (*w < 0x0800) {
- szOut[i++] = 0xc0 | ((*w) >> 6);
- szOut[i++] = 0x80 | ((*w) & 0x3f);
- }
- else {
- szOut[i++] = 0xe0 | ((*w) >> 12);
- szOut[i++] = 0x80 | (((*w) >> 6) & 0x3f);
- szOut[i++] = 0x80 | ((*w) & 0x3f);
- }
- }
- szOut[i] = '\0';
- return (char *) szOut;
-}
-
-char *Utils::UTF8Encode(const char *text) {
- wchar_t *wtext = Utils::convertToWCS(text);
- char *atext = UTF8Encode(wtext);
- delete wtext;
- return atext;
-}
-
-void Utils::UTF8Encode(const char *text, char *output, int maxLen) {
- wchar_t *wtext = Utils::convertToWCS(text);
- char *atext = UTF8Encode(wtext);
- int slen = (int)strlen(atext) + 1;
- memcpy(output, atext, slen > maxLen ? maxLen : slen);
- output[maxLen - 1] = '\0';
- delete atext;
- delete wtext;
-}
-
-void Utils::UTF8Encode(const wchar_t *wtext, char *output, int maxLen) {
- char *atext = UTF8Encode(wtext);
- int slen = (int)strlen(atext) + 1;
- memcpy(output, atext, slen > maxLen ? maxLen : slen);
- output[maxLen - 1] = '\0';
- delete atext;
-}
-
int Utils::detectURL(const wchar_t *text) {
int i;
for (i=0;text[i]!='\0';i++) {
@@ -401,9 +345,9 @@ void Utils::destroyServices_Ex() {
}
wchar_t *Utils::urlEncode(const wchar_t *text) {
- char *utf8 = UTF8Encode(text);
+ char *utf8 = mir_utf8encodeT(text);
wchar_t *result = urlEncode(utf8);
- delete utf8;
+ mir_free(utf8);
return result;
}
diff --git a/plugins/IEView/src/Utils.h b/plugins/IEView/src/Utils.h
index 17639ede35..33bf23dbed 100644
--- a/plugins/IEView/src/Utils.h
+++ b/plugins/IEView/src/Utils.h
@@ -50,10 +50,6 @@ public:
static char *convertToString(const wchar_t *a, int cp);
static char *escapeString(const char *a);
static DWORD safe_wcslen(wchar_t *msg, DWORD maxLen);
- static char *UTF8Encode(const wchar_t *wtext);
- static char *UTF8Encode(const char *text);
- static void UTF8Encode(const char *text, char *output, int maxLen);
- static void UTF8Encode(const wchar_t *text, char *output, int maxLen);
static int detectURL(const wchar_t *text);
static HANDLE hookEvent_Ex(const char *name, MIRANDAHOOK hook);
static HANDLE createServiceFunction_Ex(const char *name, MIRANDASERVICE service);
diff --git a/plugins/IEView/src/ieview_main.cpp b/plugins/IEView/src/ieview_main.cpp
index 8462e0189d..ebebe01351 100644
--- a/plugins/IEView/src/ieview_main.cpp
+++ b/plugins/IEView/src/ieview_main.cpp
@@ -62,7 +62,7 @@ extern "C" int __declspec(dllexport) Load(void)
TCHAR *workingDir = new TCHAR[wdsize];
GetCurrentDirectory(wdsize, workingDir);
Utils::convertPath(workingDir);
- workingDirUtf8 = Utils::UTF8Encode(workingDir);
+ workingDirUtf8 = mir_utf8encodeT(workingDir);
delete workingDir;
GetModuleFileNameA(hInstance, text, sizeof(text));
@@ -106,7 +106,7 @@ extern "C" int __declspec(dllexport) Unload(void)
Utils::destroyServices_Ex();
DestroyHookableEvent(hHookOptionsChanged);
IEView::release();
- delete workingDirUtf8;
+ mir_free(workingDirUtf8);
free( ieviewModuleName );
return 0;
}