summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2013-03-17 10:05:05 +0000
committerKirill Volinsky <mataes2007@gmail.com>2013-03-17 10:05:05 +0000
commit702f2b6951058a0569f0210a19545c79bcb5b511 (patch)
tree3c0ccc84ea301f551b09df916b1be14415b651a6
parentbe2dabbdefed00b5f9e6cc112fd2d95175da0089 (diff)
one more part of replacing own functions to core functions
git-svn-id: http://svn.miranda-ng.org/main/trunk@4068 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/IEView/src/HTMLBuilder.cpp97
-rw-r--r--plugins/IEView/src/IEView.cpp86
-rw-r--r--plugins/IEView/src/Options.cpp150
-rw-r--r--plugins/IEView/src/Template.cpp14
-rw-r--r--plugins/IEView/src/TemplateHTMLBuilder.cpp26
-rw-r--r--plugins/IEView/src/TextToken.cpp30
-rw-r--r--plugins/IEView/src/Utils.cpp217
-rw-r--r--plugins/IEView/src/Utils.h15
-rw-r--r--plugins/IEView/src/ieview_common.h3
-rw-r--r--plugins/IEView/src/ieview_main.cpp50
10 files changed, 214 insertions, 474 deletions
diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp
index 0739b6ff3b..ccda13793d 100644
--- a/plugins/IEView/src/HTMLBuilder.cpp
+++ b/plugins/IEView/src/HTMLBuilder.cpp
@@ -37,7 +37,7 @@ HTMLBuilder::HTMLBuilder() {
HTMLBuilder::~HTMLBuilder() {
if (lastIEViewEvent.pszProto != NULL) {
- delete (char*)lastIEViewEvent.pszProto;
+ mir_free((void*)lastIEViewEvent.pszProto);
}
}
@@ -113,9 +113,9 @@ char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const wchar_t
char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *text, int flags, bool isSent) {
char *outputStr = NULL;
if (text != NULL) {
- wchar_t *wtext = Utils::convertToWCS(text);
+ wchar_t *wtext = mir_a2t(text);
outputStr = encodeUTF8(hContact, proto, wtext, flags, isSent);
- delete wtext;
+ mir_free(wtext);
}
return outputStr;
}
@@ -123,32 +123,32 @@ char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *t
char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *text, int cp, int flags, bool isSent) {
char * outputStr = NULL;
if (text != NULL) {
- wchar_t *wtext = Utils::convertToWCS(text, cp);
+ wchar_t *wtext = mir_a2t_cp(text, cp);
outputStr = encodeUTF8(hContact, proto, wtext, flags, isSent);
- delete wtext;
+ mir_free(wtext);
}
return outputStr;
}
char *HTMLBuilder::getProto(HANDLE hContact) {
- return Utils::dupString(GetContactProto(hContact));
+ return mir_strdup(GetContactProto(hContact));
}
char *HTMLBuilder::getProto(const char *proto, HANDLE hContact) {
if (proto != NULL) {
- return Utils::dupString(proto);
+ return mir_strdup(proto);
}
- return Utils::dupString(GetContactProto(hContact));
+ return mir_strdup(GetContactProto(hContact));
}
char *HTMLBuilder::getRealProto(HANDLE hContact) {
if (hContact != NULL) {
- char *szProto = Utils::dupString(GetContactProto(hContact));
- if (szProto!=NULL && !strcmp(szProto,"MetaContacts")) {
- hContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
- if (hContact!=NULL) {
- delete szProto;
- szProto = Utils::dupString(GetContactProto(hContact));
+ char *szProto = mir_strdup(GetContactProto(hContact));
+ if (szProto != NULL && !strcmp(szProto, "MetaContacts")) {
+ hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
+ if (hContact != NULL) {
+ mir_free(szProto);
+ szProto = mir_strdup(GetContactProto(hContact));
}
}
return szProto;
@@ -157,13 +157,13 @@ char *HTMLBuilder::getRealProto(HANDLE hContact) {
}
char *HTMLBuilder::getRealProto(HANDLE hContact, const char *szProto) {
- if (szProto!=NULL && !strcmp(szProto,"MetaContacts")) {
- hContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
- if (hContact!=NULL) {
- return Utils::dupString(GetContactProto(hContact));
+ if (szProto != NULL && !strcmp(szProto, "MetaContacts")) {
+ hContact = (HANDLE)CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0);
+ if (hContact != NULL) {
+ return mir_strdup(GetContactProto(hContact));
}
}
- return Utils::dupString(szProto);
+ return mir_strdup(szProto);
}
HANDLE HTMLBuilder::getRealContact(HANDLE hContact) {
@@ -239,13 +239,14 @@ void HTMLBuilder::getUINs(HANDLE hContact, char *&uinIn, char *&uinOut) {
}
}
uinOut = mir_utf8encode(buf);
- delete szProto;
+ mir_free(szProto);
}
-wchar_t *HTMLBuilder::getContactName(HANDLE hContact, const char* szProto) {
- CONTACTINFO ci;
+wchar_t *HTMLBuilder::getContactName(HANDLE hContact, const char* szProto)
+{
+ CONTACTINFO ci = {0};
wchar_t *szName = NULL;
- ZeroMemory(&ci, sizeof(ci));
+
ci.cbSize = sizeof(ci);
ci.hContact = hContact;
ci.szProto = (char *)szProto;
@@ -256,10 +257,10 @@ wchar_t *HTMLBuilder::getContactName(HANDLE hContact, const char* szProto) {
if (!wcscmp((wchar_t *)ci.pszVal, TranslateW(L"'(Unknown Contact)'"))) {
ci.dwFlag &= ~CNF_UNICODE;
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
- szName = Utils::convertToWCS((char *)ci.pszVal);
+ szName = ci.pszVal;
}
} else {
- szName = Utils::dupString((wchar_t *)ci.pszVal);
+ szName = mir_tstrdup(ci.pszVal);
}
mir_free(ci.pszVal);
}
@@ -270,7 +271,7 @@ wchar_t *HTMLBuilder::getContactName(HANDLE hContact, const char* szProto) {
if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
if (ci.type == CNFT_ASCIIZ) {
if (ci.pszVal) {
- szName = Utils::convertToWCS((char *)ci.pszVal);
+ szName = ci.pszVal;
mir_free(ci.pszVal);
}
}
@@ -278,23 +279,25 @@ wchar_t *HTMLBuilder::getContactName(HANDLE hContact, const char* szProto) {
if (szName != NULL) return szName;
char *szNameStr = (char *)CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM)hContact, 0);
if (szNameStr != NULL) {
- return Utils::convertToWCS(szNameStr);
+ return mir_a2t(szNameStr);
}
- return Utils::dupString(TranslateT("(Unknown Contact)"));
+ return mir_tstrdup(TranslateT("(Unknown Contact)"));
}
-char *HTMLBuilder::getEncodedContactName(HANDLE hContact, const char* szProto, const char* szSmileyProto) {
+char *HTMLBuilder::getEncodedContactName(HANDLE 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);
- delete name;
+ mir_free(name);
return szName;
}
return encodeUTF8(hContact, szSmileyProto, TranslateT("(Unknown Contact)"), ENF_NAMESMILEYS, true);
}
-void HTMLBuilder::appendEventNew(IEView *view, IEVIEWEVENT *event) {
+void HTMLBuilder::appendEventNew(IEView *view, IEVIEWEVENT *event)
+{
setLastIEViewEvent(event);
appendEvent(view, event);
}
@@ -313,7 +316,7 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) {
newEvent.codepage = event->codepage;
}
if (event->cbSize >= IEVIEWEVENT_SIZE_V3 && event->pszProto != NULL) {
- szProto = Utils::dupString(event->pszProto);
+ szProto = mir_strdup(event->pszProto);
} else {
szProto = getProto(event->hContact);
}
@@ -365,8 +368,8 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) {
if (dbei.eventType == EVENTTYPE_MESSAGE || dbei.eventType == EVENTTYPE_URL || dbei.eventType == EVENTTYPE_STATUSCHANGE || dbei.eventType == EVENTTYPE_JABBER_CHATSTATES) {
DBEVENTGETTEXT temp = { &dbei, DBVT_WCHAR + ((event->dwFlags & IEEF_NO_UNICODE) ? DBVTF_DENYUNICODE : 0), newEvent.codepage };
WCHAR* pwszEventText = (WCHAR*)CallService(MS_DB_EVENT_GETTEXT,0,(LPARAM)&temp);
- eventData->pszTextW = Utils::dupString( pwszEventText );
- mir_free( pwszEventText );
+ eventData->pszTextW = mir_tstrdup(pwszEventText);
+ mir_free(pwszEventText);
if (dbei.eventType == EVENTTYPE_MESSAGE) {
eventData->iType = IEED_EVENT_MESSAGE;
} else if (dbei.eventType == EVENTTYPE_URL) {
@@ -379,26 +382,26 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) {
char* filename = ((char *)dbei.pBlob) + sizeof(DWORD);
char* descr = filename + lstrlenA(filename) + 1;
TCHAR *tStr = DbGetEventStringT(&dbei, filename);
- eventData->ptszText = Utils::dupString(tStr);
+ eventData->ptszText = mir_tstrdup(tStr);
mir_free(tStr);
if (*descr != '\0') {
tStr = DbGetEventStringT(&dbei, descr);
- eventData->ptszText2 = Utils::dupString(tStr);
+ eventData->ptszText2 = mir_tstrdup(tStr);
mir_free(tStr);
}
eventData->iType = IEED_EVENT_FILE;
} else if (dbei.eventType == EVENTTYPE_AUTHREQUEST) {
//blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
- eventData->ptszText = Utils::dupString(TranslateT(" requested authorisation"));
+ eventData->ptszText = mir_tstrdup(TranslateT(" requested authorisation"));
TCHAR *tStr = DbGetEventStringT(&dbei, (char *)dbei.pBlob + 8);
- eventData->ptszNick = Utils::dupString(tStr);
+ eventData->ptszNick = mir_tstrdup(tStr);
mir_free(tStr);
eventData->iType = IEED_EVENT_SYSTEM;
} else if (dbei.eventType == EVENTTYPE_ADDED) {
//blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ)
- eventData->ptszText = Utils::dupString(TranslateT(" was added."));
+ eventData->ptszText = mir_tstrdup(TranslateT(" was added."));
TCHAR *tStr = DbGetEventStringT(&dbei, (char *)dbei.pBlob + 8);
- eventData->ptszNick = Utils::dupString(tStr);
+ eventData->ptszNick = mir_tstrdup(tStr);
mir_free(tStr);
eventData->iType = IEED_EVENT_SYSTEM;
}
@@ -418,18 +421,18 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) {
for ( IEVIEWEVENTDATA* eventData2 = newEvent.eventData; eventData2 != NULL; eventData2 = eventData) {
eventData = eventData2->next;
if (eventData2->pszTextW != NULL) {
- delete (wchar_t*)eventData2->pszTextW;
+ mir_free((void*)eventData2->pszTextW);
}
if (eventData2->pszText2W != NULL) {
- delete (wchar_t*)eventData2->pszText2W;
+ mir_free((void*)eventData2->pszText2W);
}
if (eventData2->pszNickW != NULL) {
- delete (wchar_t*)eventData2->pszNickW;
+ mir_free((void*)eventData2->pszNickW);
}
delete eventData2;
}
if (szProto != NULL) {
- delete szProto;
+ mir_free(szProto);
}
}
@@ -444,7 +447,7 @@ ProtocolSettings* HTMLBuilder::getSRMMProtocolSettings(const char *protocolName)
ProtocolSettings* HTMLBuilder::getSRMMProtocolSettings(HANDLE hContact) {
char *szRealProto = getRealProto(hContact);
ProtocolSettings *protoSettings = getSRMMProtocolSettings(szRealProto);
- delete szRealProto;
+ mir_free(szRealProto);
return protoSettings;
}
@@ -496,10 +499,10 @@ void HTMLBuilder::setLastIEViewEvent(IEVIEWEVENT *event) {
lastIEViewEvent.hwnd = event->hwnd;
lastIEViewEvent.eventData = NULL;
if (lastIEViewEvent.pszProto != NULL) {
- delete (char *)lastIEViewEvent.pszProto ;
+ mir_free((void*)lastIEViewEvent.pszProto);
}
if (event->cbSize >= IEVIEWEVENT_SIZE_V3 && event->pszProto != NULL) {
- lastIEViewEvent.pszProto = Utils::dupString(event->pszProto);
+ lastIEViewEvent.pszProto = mir_strdup(event->pszProto);
} else {
lastIEViewEvent.pszProto = getProto(event->hContact);
}
diff --git a/plugins/IEView/src/IEView.cpp b/plugins/IEView/src/IEView.cpp
index 5d0709a5f8..1129af324e 100644
--- a/plugins/IEView/src/IEView.cpp
+++ b/plugins/IEView/src/IEView.cpp
@@ -256,25 +256,20 @@ IEView::IEView(HWND parent, HTMLBuilder* builder, int x, int y, int cx, int cy)
rcClient.top = y;
rcClient.right = x + cx;
rcClient.bottom = y + cy;
-#ifdef GECKO
- if (SUCCEEDED(CoCreateInstance(CLSID_MozillaBrowser, NULL, CLSCTX_INPROC, IID_IWebBrowser2, (LPVOID*)&pWebBrowser))) {
-#else
if (SUCCEEDED(CoCreateInstance(CLSID_WebBrowser, NULL, CLSCTX_INPROC, IID_IWebBrowser2, (LPVOID*)&pWebBrowser))) {
-#endif
-// pWebBrowser->put_RegisterAsBrowser(VARIANT_FALSE);
if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleObject, (void**)&pOleObject))) {
pOleObject->SetClientSite(this);
pOleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, &msg, this, 0, this->parent, &rcClient);
pOleObject->Release();
} else {
- MessageBoxA(NULL,"IID_IOleObject failed.","RESULT",MB_OK);
+ MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK);
}
if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleInPlaceObject, (void**)&pOleInPlace))) {
pOleInPlace->GetWindow(&hwnd);
pOleInPlace->Release();
} else {
- MessageBoxA(NULL,"IID_IOleInPlaceObject failed.","RESULT",MB_OK);
+ MessageBox(NULL, TranslateT("IID_IOleInPlaceObject failed."), TranslateT("RESULT"), MB_OK);
}
setBorder();
@@ -290,16 +285,12 @@ IEView::IEView(HWND parent, HTMLBuilder* builder, int x, int y, int cx, int cy)
// want to sink its events.
sink = new IEViewSink(this);
if (FAILED(m_pConnectionPoint->Advise((IUnknown *)sink, &m_dwCookie))) {
- MessageBoxA(NULL, "Failed to Advise", "C++ Event Sink", MB_OK);
+ MessageBox(NULL, TranslateT("Failed to Advise"), TranslateT("C++ Event Sink"), MB_OK);
}
}
pCPContainer->Release();
}
-#ifndef GECKO
setMainWndProc((WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) IEViewWindowProcedure));
-#else
-// setMainWndProc((WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) MozillaWindowProcedure));
-#endif
}
EnterCriticalSection(&mutex);
next = list;
@@ -330,7 +321,7 @@ IEView::~IEView() {
pOleObject->SetClientSite(NULL);
pOleObject->Release();
} else {
- MessageBoxA(NULL,"IID_IOleObject failed.","RESULT",MB_OK);
+ MessageBox(NULL, TranslateT("IID_IOleObject failed."), TranslateT("RESULT"), MB_OK);
}
if (builder != NULL) {
delete builder;
@@ -346,9 +337,7 @@ IEView::~IEView() {
if (selectedText != NULL) {
delete selectedText;
}
-#ifndef GECKO
pWebBrowser->Release();
-#endif
DestroyWindow(hwnd);
}
@@ -357,7 +346,7 @@ void IEView::init() {
isInited = true;
InitializeCriticalSection(&mutex);
if (FAILED(OleInitialize(NULL))) {
- MessageBoxA(NULL,"OleInitialize failed.","ERROR",MB_OK);
+ MessageBox(NULL, TranslateT("OleInitialize failed."), TranslateT("ERROR"), MB_OK);
}
}
@@ -682,9 +671,6 @@ STDMETHODIMP IEView::GetSecurityId(LPCWSTR pwszUrl, BYTE *pbSecurityId, DWORD *p
STDMETHODIMP IEView::ProcessUrlAction(LPCWSTR pwszUrl, DWORD dwAction, BYTE *pPolicy, DWORD cbPolicy, BYTE *pContext, DWORD cbContext, DWORD dwFlags, DWORD dwReserved) {
DWORD dwPolicy=URLPOLICY_ALLOW;
if (pwszUrl!=NULL && !wcscmp(pwszUrl, L"about:blank")) {
-// char str[1024];
-// sprintf(str, "kod: %08X", dwAction);
-// MessageBox(NULL,str, "Security", MB_OK);
if (dwAction <= URLACTION_ACTIVEX_MAX && dwAction >= URLACTION_ACTIVEX_MIN) {
//dwPolicy = URLPOLICY_DISALLOW;
//dwPolicy = URLPOLICY_ALLOW;
@@ -926,60 +912,8 @@ void IEView::appendEvent(IEVIEWEVENT *event) {
getFocus = false;
}
-void IEView::clear(IEVIEWEVENT *event) {
-#ifdef GECKO
- pWebBrowser->Navigate(L"about:blank", NULL, NULL, NULL, NULL);
- Utils::forkThread((void (__cdecl *)(void *))StartThread, 0, (void *) this);
- MSG msg;
- BOOL bRet;
- while( (bRet = GetMessage( &msg, NULL, 0, 0 )) != 0) {
- if (bRet == -1) {
- // handle the error and possibly exit
- } else {
- if (msg.message == WM_WAITWHILEBUSY) {
- break;
- } else {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- }
- }
- {
- IHTMLDocument2 *document = getDocument();
- if (document != NULL) {
- document->close();
- VARIANT open_name;
- VARIANT open_features;
- VARIANT 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);
-
- HRESULT hr = document->open(SysAllocString(L"text/html"),
- open_name,
- open_features,
- open_replace,
- &open_window);
- if (hr == S_OK) {
- // pWebBrowser->Refresh();
- }
- if (open_window != NULL) {
- open_window->Release();
- }
- document->Release();
- }
- if (builder!=NULL) {
- builder->clear(this, event);
- }
- clearRequired = false;
- getFocus = false;
-
- }
- return;
-#endif
+void IEView::clear(IEVIEWEVENT *event)
+{
IHTMLDocument2 *document = getDocument();
if (document == NULL) {
pWebBrowser->Navigate(L"about:blank", NULL, NULL, NULL, NULL);
@@ -1038,7 +972,7 @@ void* IEView::getSelection(IEVIEWEVENT *event) {
if (event->cbSize >= IEVIEWEVENT_SIZE_V2) {
cp = event->codepage;
}
- char *str = Utils::convertToString(selectedText, cp);
+ char *str = mir_t2a_cp(selectedText, cp);
delete selectedText;
selectedText = (BSTR) str;
}
@@ -1082,7 +1016,7 @@ BSTR IEView::getSelection() {
IHTMLTxtRange *pRange = NULL;
if (SUCCEEDED(pDisp->QueryInterface(IID_IHTMLTxtRange, (void**)&pRange))) {
if (SUCCEEDED(pRange->get_text(&text))) {
- text = Utils::dupString(text);
+ text = mir_tstrdup(text);
}
pRange->Release();
}
@@ -1106,7 +1040,7 @@ BSTR IEView::getHrefFromAnchor(IHTMLElement *element) {
VARIANT variant;
BSTR url;
if (SUCCEEDED(element->getAttribute(L"href", 2, &variant) && variant.vt == VT_BSTR)) {
- url = Utils::dupString(variant.bstrVal);
+ url = mir_tstrdup(variant.bstrVal);
SysFreeString(variant.bstrVal);
}
//pAnchor->get_href( &url );
diff --git a/plugins/IEView/src/Options.cpp b/plugins/IEView/src/Options.cpp
index f3864a46d0..278659d502 100644
--- a/plugins/IEView/src/Options.cpp
+++ b/plugins/IEView/src/Options.cpp
@@ -370,7 +370,7 @@ static void RefreshProtoList(HWND hwndDlg, int mode, bool protoTemplates) {
// strcat(protoName, " ");
// strcat(protoName, Translate("protocol"));
}
- tvi.item.pszText = Utils::convertToWCS(protoName);
+ tvi.item.pszText = mir_a2t(protoName);
tvi.item.lParam = (LPARAM)proto;
tvi.item.iImage = i;
tvi.item.iSelectedImage = i;
@@ -989,100 +989,100 @@ int Options::generalFlags;
ProtocolSettings *Options::protocolList = NULL;
ProtocolSettings::ProtocolSettings(const char *protocolName) {
- this->protocolName = Utils::dupString(protocolName);
+ this->protocolName = mir_strdup(protocolName);
next = NULL;
srmmEnable = false;
srmmMode = Options::MODE_COMPATIBLE;
srmmFlags = 0;
- srmmBackgroundFilename = Utils::dupString("");
- srmmCssFilename = Utils::dupString("");
- srmmTemplateFilename = Utils::dupString("");
+ srmmBackgroundFilename = mir_strdup("");
+ srmmCssFilename = mir_strdup("");
+ srmmTemplateFilename = mir_strdup("");
- srmmBackgroundFilenameTemp = Utils::dupString("");
- srmmCssFilenameTemp = Utils::dupString("");
- srmmTemplateFilenameTemp = Utils::dupString("");
+ srmmBackgroundFilenameTemp = mir_strdup("");
+ srmmCssFilenameTemp = mir_strdup("");
+ srmmTemplateFilenameTemp = mir_strdup("");
chatEnable = false;
chatMode = Options::MODE_COMPATIBLE;
chatFlags = 0;
- chatBackgroundFilename = Utils::dupString("");
- chatCssFilename = Utils::dupString("");
- chatTemplateFilename = Utils::dupString("");
+ chatBackgroundFilename = mir_strdup("");
+ chatCssFilename = mir_strdup("");
+ chatTemplateFilename = mir_strdup("");
- chatBackgroundFilenameTemp = Utils::dupString("");
- chatCssFilenameTemp = Utils::dupString("");
- chatTemplateFilenameTemp = Utils::dupString("");
+ chatBackgroundFilenameTemp = mir_strdup("");
+ chatCssFilenameTemp = mir_strdup("");
+ chatTemplateFilenameTemp = mir_strdup("");
historyEnable = false;
historyMode = Options::MODE_COMPATIBLE;
historyFlags = 0;
- historyBackgroundFilename = Utils::dupString("");
- historyCssFilename = Utils::dupString("");
- historyTemplateFilename = Utils::dupString("");
+ historyBackgroundFilename = mir_strdup("");
+ historyCssFilename = mir_strdup("");
+ historyTemplateFilename = mir_strdup("");
- historyBackgroundFilenameTemp = Utils::dupString("");
- historyCssFilenameTemp = Utils::dupString("");
- historyTemplateFilenameTemp = Utils::dupString("");
+ historyBackgroundFilenameTemp = mir_strdup("");
+ historyCssFilenameTemp = mir_strdup("");
+ historyTemplateFilenameTemp = mir_strdup("");
}
ProtocolSettings::~ProtocolSettings() {
- delete protocolName;
+ mir_free(protocolName);
if (srmmBackgroundFilename != NULL) {
- delete srmmBackgroundFilename;
+ mir_free(srmmBackgroundFilename);
}
if (srmmBackgroundFilenameTemp != NULL) {
- delete srmmBackgroundFilenameTemp;
+ mir_free(srmmBackgroundFilenameTemp);
}
if (srmmCssFilename != NULL) {
- delete srmmCssFilename;
+ mir_free(srmmCssFilename);
}
if (srmmCssFilenameTemp != NULL) {
- delete srmmCssFilenameTemp;
+ mir_free(srmmCssFilenameTemp);
}
if (srmmTemplateFilename != NULL) {
- delete srmmTemplateFilename;
+ mir_free(srmmTemplateFilename);
}
if (srmmTemplateFilenameTemp != NULL) {
- delete srmmTemplateFilenameTemp;
+ mir_free(srmmTemplateFilenameTemp);
}
if (chatBackgroundFilename != NULL) {
- delete chatBackgroundFilename;
+ mir_free(chatBackgroundFilename);
}
if (chatBackgroundFilenameTemp != NULL) {
- delete chatBackgroundFilenameTemp;
+ mir_free(chatBackgroundFilenameTemp);
}
if (chatCssFilename != NULL) {
- delete chatCssFilename;
+ mir_free(chatCssFilename);
}
if (chatCssFilenameTemp != NULL) {
- delete chatCssFilenameTemp;
+ mir_free(chatCssFilenameTemp);
}
if (chatTemplateFilename != NULL) {
- delete chatTemplateFilename;
+ mir_free(chatTemplateFilename);
}
if (chatTemplateFilenameTemp != NULL) {
- delete chatTemplateFilenameTemp;
+ mir_free(chatTemplateFilenameTemp);
}
if (historyBackgroundFilename != NULL) {
- delete historyBackgroundFilename;
+ mir_free(historyBackgroundFilename);
}
if (historyBackgroundFilenameTemp != NULL) {
- delete historyBackgroundFilenameTemp;
+ mir_free(historyBackgroundFilenameTemp);
}
if (historyCssFilename != NULL) {
- delete historyCssFilename;
+ mir_free(historyCssFilename);
}
if (historyCssFilenameTemp != NULL) {
- delete historyCssFilenameTemp;
+ mir_free(historyCssFilenameTemp);
}
if (historyTemplateFilename != NULL) {
- delete historyTemplateFilename;
+ mir_free(historyTemplateFilename);
}
if (historyTemplateFilenameTemp != NULL) {
- delete historyTemplateFilenameTemp;
+ mir_free(historyTemplateFilenameTemp);
}
}
@@ -1146,45 +1146,45 @@ ProtocolSettings * ProtocolSettings::getNext() {
void ProtocolSettings::setSRMMBackgroundFilename(const char *filename) {
if (srmmBackgroundFilename != NULL) {
- delete srmmBackgroundFilename;
+ mir_free(srmmBackgroundFilename);
}
- srmmBackgroundFilename = Utils::dupString(filename);
+ srmmBackgroundFilename = mir_strdup(filename);
}
void ProtocolSettings::setSRMMBackgroundFilenameTemp(const char *filename) {
if (srmmBackgroundFilenameTemp != NULL) {
- delete srmmBackgroundFilenameTemp;
+ mir_free(srmmBackgroundFilenameTemp);
}
- srmmBackgroundFilenameTemp = Utils::dupString(filename);
+ srmmBackgroundFilenameTemp = mir_strdup(filename);
}
void ProtocolSettings::setSRMMCssFilename(const char *filename) {
if (srmmCssFilename != NULL) {
- delete srmmCssFilename;
+ mir_free(srmmCssFilename);
}
- srmmCssFilename = Utils::dupString(filename);
+ srmmCssFilename = mir_strdup(filename);
}
void ProtocolSettings::setSRMMCssFilenameTemp(const char *filename) {
if (srmmCssFilenameTemp != NULL) {
- delete srmmCssFilenameTemp;
+ mir_free(srmmCssFilenameTemp);
}
- srmmCssFilenameTemp = Utils::dupString(filename);
+ srmmCssFilenameTemp = mir_strdup(filename);
}
void ProtocolSettings::setSRMMTemplateFilename(const char *filename) {
if (srmmTemplateFilename != NULL) {
- delete srmmTemplateFilename;
+ mir_free(srmmTemplateFilename);
}
- srmmTemplateFilename = Utils::dupString(filename);
+ srmmTemplateFilename = mir_strdup(filename);
TemplateMap::loadTemplates(getSRMMTemplateFilename(), getSRMMTemplateFilename(), false);
}
void ProtocolSettings::setSRMMTemplateFilenameTemp(const char *filename) {
if (srmmTemplateFilenameTemp != NULL) {
- delete srmmTemplateFilenameTemp;
+ mir_free(srmmTemplateFilenameTemp);
}
- srmmTemplateFilenameTemp = Utils::dupString(filename);
+ srmmTemplateFilenameTemp = mir_strdup(filename);
}
const char *ProtocolSettings::getSRMMBackgroundFilename() {
@@ -1263,45 +1263,45 @@ int ProtocolSettings::getSRMMFlagsTemp() {
void ProtocolSettings::setChatBackgroundFilename(const char *filename) {
if (chatBackgroundFilename != NULL) {
- delete chatBackgroundFilename;
+ mir_free(chatBackgroundFilename);
}
- chatBackgroundFilename = Utils::dupString(filename);
+ chatBackgroundFilename = mir_strdup(filename);
}
void ProtocolSettings::setChatBackgroundFilenameTemp(const char *filename) {
if (chatBackgroundFilenameTemp != NULL) {
- delete chatBackgroundFilenameTemp;
+ mir_free(chatBackgroundFilenameTemp);
}
- chatBackgroundFilenameTemp = Utils::dupString(filename);
+ chatBackgroundFilenameTemp = mir_strdup(filename);
}
void ProtocolSettings::setChatCssFilename(const char *filename) {
if (chatCssFilename != NULL) {
- delete chatCssFilename;
+ mir_free(chatCssFilename);
}
- chatCssFilename = Utils::dupString(filename);
+ chatCssFilename = mir_strdup(filename);
}
void ProtocolSettings::setChatCssFilenameTemp(const char *filename) {
if (chatCssFilenameTemp != NULL) {
- delete chatCssFilenameTemp;
+ mir_free(chatCssFilenameTemp);
}
- chatCssFilenameTemp = Utils::dupString(filename);
+ chatCssFilenameTemp = mir_strdup(filename);
}
void ProtocolSettings::setChatTemplateFilename(const char *filename) {
if (chatTemplateFilename != NULL) {
- delete chatTemplateFilename;
+ mir_free(chatTemplateFilename);
}
- chatTemplateFilename = Utils::dupString(filename);
+ chatTemplateFilename = mir_strdup(filename);
TemplateMap::loadTemplates(getChatTemplateFilename(), getChatTemplateFilename(), false);
}
void ProtocolSettings::setChatTemplateFilenameTemp(const char *filename) {
if (chatTemplateFilenameTemp != NULL) {
- delete chatTemplateFilenameTemp;
+ mir_free(chatTemplateFilenameTemp);
}
- chatTemplateFilenameTemp = Utils::dupString(filename);
+ chatTemplateFilenameTemp = mir_strdup(filename);
}
const char *ProtocolSettings::getChatBackgroundFilename() {
@@ -1380,45 +1380,45 @@ int ProtocolSettings::getChatFlagsTemp() {
void ProtocolSettings::setHistoryBackgroundFilename(const char *filename) {
if (historyBackgroundFilename != NULL) {
- delete historyBackgroundFilename;
+ mir_free(historyBackgroundFilename);
}
- historyBackgroundFilename = Utils::dupString(filename);
+ historyBackgroundFilename = mir_strdup(filename);
}
void ProtocolSettings::setHistoryBackgroundFilenameTemp(const char *filename) {
if (historyBackgroundFilenameTemp != NULL) {
- delete historyBackgroundFilenameTemp;
+ mir_free(historyBackgroundFilenameTemp);
}
- historyBackgroundFilenameTemp = Utils::dupString(filename);
+ historyBackgroundFilenameTemp = mir_strdup(filename);
}
void ProtocolSettings::setHistoryCssFilename(const char *filename) {
if (historyCssFilename != NULL) {
- delete historyCssFilename;
+ mir_free(historyCssFilename);
}
- historyCssFilename = Utils::dupString(filename);
+ historyCssFilename = mir_strdup(filename);
}
void ProtocolSettings::setHistoryCssFilenameTemp(const char *filename) {
if (historyCssFilenameTemp != NULL) {
- delete historyCssFilenameTemp;
+ mir_free(historyCssFilenameTemp);
}
- historyCssFilenameTemp = Utils::dupString(filename);
+ historyCssFilenameTemp = mir_strdup(filename);
}
void ProtocolSettings::setHistoryTemplateFilename(const char *filename) {
if (historyTemplateFilename != NULL) {
- delete historyTemplateFilename;
+ mir_free(historyTemplateFilename);
}
- historyTemplateFilename = Utils::dupString(filename);
+ historyTemplateFilename = mir_strdup(filename);
TemplateMap::loadTemplates(getHistoryTemplateFilename(), getHistoryTemplateFilename(), false);
}
void ProtocolSettings::setHistoryTemplateFilenameTemp(const char *filename) {
if (historyTemplateFilenameTemp != NULL) {
- delete historyTemplateFilenameTemp;
+ mir_free(historyTemplateFilenameTemp);
}
- historyTemplateFilenameTemp = Utils::dupString(filename);
+ historyTemplateFilenameTemp = mir_strdup(filename);
}
const char *ProtocolSettings::getHistoryBackgroundFilename() {
diff --git a/plugins/IEView/src/Template.cpp b/plugins/IEView/src/Template.cpp
index ac6ced05d0..10946b7acc 100644
--- a/plugins/IEView/src/Template.cpp
+++ b/plugins/IEView/src/Template.cpp
@@ -40,7 +40,7 @@ Token::Token(int type, const char *text, int escape) {
this->type = type;
this->escape = escape;
if (text!=NULL) {
- this->text = Utils::dupString(text);
+ this->text = mir_strdup(text);
} else {
this->text = NULL;
}
@@ -75,8 +75,8 @@ const char *Token::getText() {
Template::Template(const char *name, const char *text) {
next = NULL;
tokens = NULL;
- this->text = Utils::dupString(text);
- this->name = Utils::dupString(name);
+ this->text = mir_strdup(text);
+ this->name = mir_strdup(name);
tokenize();
}
@@ -155,7 +155,7 @@ static TokenDef tokenNames[] = {
void Template::tokenize() {
if (text!=NULL) {
// debugView->writef("Tokenizing: %s<br>---<br>", text);
- char *str = Utils::dupString(text);
+ char *str = mir_strdup(text);
Token *lastToken = NULL;
int lastTokenType = Token::PLAIN;
int lastTokenEscape = 0;
@@ -208,7 +208,7 @@ void Template::tokenize() {
lastTokenType = newTokenType;
i += newTokenSize;
}
- delete str;
+ mir_free(str);
}
}
@@ -222,7 +222,7 @@ TemplateMap::TemplateMap(const char *name) {
entries = NULL;
next = NULL;
filename = NULL;
- this->name = Utils::dupString(name);
+ this->name = mir_strdup(name);
this->grouping = false;
this->rtl = false;
}
@@ -439,7 +439,7 @@ void TemplateMap::setFilename(const char *filename) {
if (this->filename != NULL) {
delete this->filename;
}
- this->filename = Utils::dupString(filename);
+ this->filename = mir_strdup(filename);
Utils::convertPath(this->filename);
}
diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp
index daf79229a7..f7ffa2f1bd 100644
--- a/plugins/IEView/src/TemplateHTMLBuilder.cpp
+++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp
@@ -102,7 +102,7 @@ const char *TemplateHTMLBuilder::getFlashAvatar(const TCHAR *file, int index) {
_close(src);
urlBuf = strstr(pBuf, "<URL>");
if(urlBuf) {
- flashAvatars[index] = Utils::dupString(strtok(urlBuf + 5, "<\t\n\r"));
+ flashAvatars[index] = mir_strdup(strtok(urlBuf + 5, "<\t\n\r"));
}
}
}
@@ -198,8 +198,8 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr
szNameOut = getEncodedContactName(NULL, szProto, szRealProto);
szNameIn = getEncodedContactName(event->hContact, szProto, szRealProto);
} else {
- szNameOut = Utils::dupString("&nbsp;");
- szNameIn = Utils::dupString("&nbsp;");
+ szNameOut = mir_strdup("&nbsp;");
+ szNameIn = mir_strdup("&nbsp;");
}
sprintf(tempStr, "%snoavatar.png", tempBase);
szNoAvatar = mir_utf8encode(tempStr);
@@ -210,11 +210,11 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr
}
szAvatarIn = getAvatar(event->hContact, szRealProto);
if (szAvatarIn == NULL) {
- szAvatarIn = Utils::dupString(szNoAvatar);
+ szAvatarIn = mir_strdup(szNoAvatar);
}
szAvatarOut = getAvatar(NULL, szRealProto);
if (szAvatarOut == NULL) {
- szAvatarOut = Utils::dupString(szNoAvatar);
+ szAvatarOut = mir_strdup(szNoAvatar);
}
if (!DBGetContactSetting(event->hContact, "CList", "StatusMsg",&dbv)) {
if (strlen(dbv.pszVal) > 0) {
@@ -301,8 +301,8 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr
free(output);
}
if (szBase!=NULL) mir_free(szBase);
- if (szRealProto!=NULL) delete szRealProto;
- if (szProto!=NULL) delete szProto;
+ if (szRealProto!=NULL) mir_free(szRealProto);
+ if (szProto!=NULL) mir_free(szProto);
if (szUINIn!=NULL) mir_free(szUINIn);
if (szUINOut!=NULL) mir_free(szUINOut);
if (szNoAvatar!=NULL) mir_free(szNoAvatar);
@@ -374,8 +374,8 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event,
szNameOut = getEncodedContactName(NULL, szProto, szRealProto);
szNameIn = getEncodedContactName(event->hContact, szProto, szRealProto);
} else {
- szNameOut = Utils::dupString("&nbsp;");
- szNameIn = Utils::dupString("&nbsp;");
+ szNameOut = mir_strdup("&nbsp;");
+ szNameIn = mir_strdup("&nbsp;");
}
sprintf(tempStr, "%snoavatar.png", tempBase);
szNoAvatar = mir_utf8encode(tempStr);
@@ -389,11 +389,11 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event,
szAvatarIn = getAvatar(event->hContact, szRealProto);
}
if (szAvatarIn == NULL) {
- szAvatarIn = Utils::dupString(szNoAvatar);
+ szAvatarIn = mir_strdup(szNoAvatar);
}
szAvatarOut = getAvatar(NULL, szRealProto);
if (szAvatarOut == NULL) {
- szAvatarOut = Utils::dupString(szNoAvatar);
+ szAvatarOut = mir_strdup(szNoAvatar);
}
if(event->hContact != NULL) {
if (!DBGetContactSetting(event->hContact, "CList", "StatusMsg",&dbv)) {
@@ -626,8 +626,8 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event,
}
}
if (szBase!=NULL) mir_free(szBase);
- if (szRealProto!=NULL) delete szRealProto;
- if (szProto!=NULL) delete szProto;
+ if (szRealProto!=NULL) mir_free(szRealProto);
+ if (szProto!=NULL) mir_free(szProto);
if (szUINIn!=NULL) mir_free(szUINIn);
if (szUINOut!=NULL) mir_free(szUINOut);
if (szNoAvatar!=NULL) mir_free(szNoAvatar);
diff --git a/plugins/IEView/src/TextToken.cpp b/plugins/IEView/src/TextToken.cpp
index 1b6d2fed58..0c16b6aa55 100644
--- a/plugins/IEView/src/TextToken.cpp
+++ b/plugins/IEView/src/TextToken.cpp
@@ -26,8 +26,8 @@ TextToken::TextToken(int type, const char *text, int len) {
tag = 0;
end = false;
this->type = type;
- this->text = Utils::dupString(text, len);
- this->wtext = Utils::convertToWCS(this->text);
+ this->text = mir_strndup(text, len);
+ this->wtext = mir_a2t(this->text);
this->link = NULL;
this->wlink = NULL;
}
@@ -37,24 +37,24 @@ TextToken::TextToken(int type, const wchar_t *wtext, int len) {
tag = 0;
end = false;
this->type = type;
- this->wtext = Utils::dupString(wtext, len);
- this->text = Utils::convertToString(this->wtext);
+ this->wtext = mir_tstrndup(wtext, len);
+ this->text = mir_t2a(this->wtext);
this->link = NULL;
this->wlink = NULL;
}
TextToken::~TextToken() {
if (text!=NULL) {
- delete text;
+ mir_free(text);
}
if (wtext!=NULL) {
- delete wtext;
+ mir_free(wtext);
}
if (link!=NULL) {
- delete link;
+ mir_free(link);
}
if (wlink!=NULL) {
- delete wlink;
+ mir_free(wlink);
}
}
@@ -109,8 +109,8 @@ void TextToken::setLink(const char *link) {
if (this->wlink != NULL) {
delete this->wlink;
}
- this->link = Utils::dupString(link);
- this->wlink = Utils::convertToWCS(link);
+ this->link = mir_strdup(link);
+ this->wlink = mir_a2t(link);
}
void TextToken::setLink(const wchar_t *link) {
@@ -120,8 +120,8 @@ void TextToken::setLink(const wchar_t *link) {
if (this->wlink != NULL) {
delete this->wlink;
}
- this->link = Utils::convertToString(link);
- this->wlink = Utils::dupString(link);
+ this->link = mir_t2a(link);
+ this->wlink = mir_tstrdup(link);
}
static int countNoWhitespace(const wchar_t *str) {
@@ -145,11 +145,11 @@ TextToken* TextToken::tokenizeMath(const wchar_t *text) {
char* mthDelStart = (char *)CallService(MATH_GET_PARAMS, (WPARAM)MATH_PARAM_STARTDELIMITER, 0);
char* mthDelEnd = (char *)CallService(MATH_GET_PARAMS, (WPARAM)MATH_PARAM_ENDDELIMITER, 0);
if (mthDelStart!=NULL) {
- mathTagName[0] = Utils::convertToWCS(mthDelStart);
+ mathTagName[0] = mir_a2t(mthDelStart);
mathTagLen[0] = (int)wcslen(mathTagName[0]);
}
if (mthDelEnd!=NULL) {
- mathTagName[1] = Utils::convertToWCS(mthDelEnd);
+ mathTagName[1] = mir_a2t(mthDelEnd);
mathTagLen[1] = (int)wcslen(mathTagName[1]);
}
CallService(MTH_FREE_MATH_BUFFER,0, (LPARAM) mthDelStart);
@@ -307,7 +307,7 @@ TextToken* TextToken::tokenizeBBCodes(const wchar_t *text, int l) {
newTokenType = BBCODE;
newTokenSize = k - i;
if (bbTagArg[j]) {
- wchar_t *urlLink = Utils::dupString(text + tagArgStart, tagArgEnd - tagArgStart);
+ wchar_t *urlLink = mir_tstrndup(text + tagArgStart, tagArgEnd - tagArgStart);
bbToken->setLink(urlLink);
delete urlLink;
}
diff --git a/plugins/IEView/src/Utils.cpp b/plugins/IEView/src/Utils.cpp
index ab30e81e72..a53db0998f 100644
--- a/plugins/IEView/src/Utils.cpp
+++ b/plugins/IEView/src/Utils.cpp
@@ -22,41 +22,35 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "ieview_common.h"
wchar_t Utils::base_dir[MAX_PATH];
-unsigned Utils::hookNum = 0;
-unsigned Utils::serviceNum = 0;
-HANDLE* Utils::hHooks = NULL;
-HANDLE* Utils::hServices = NULL;
-const wchar_t *Utils::getBaseDir() {
- char temp[MAX_PATH];
- base_dir[0] = '\0';
- long tlen = PathToAbsolute("miranda32.exe", temp);
- if (tlen) {
- temp[tlen - 13]=0;
- MultiByteToWideChar(CP_ACP, 0, temp, (int)strlen(temp), base_dir, MAX_PATH);
- }
+const wchar_t *Utils::getBaseDir()
+{
+ PathToAbsoluteT(_T("miranda32.exe"), base_dir);
return base_dir;
}
-wchar_t* Utils::toAbsolute(wchar_t* relative) {
+wchar_t* Utils::toAbsolute(wchar_t* relative)
+{
const wchar_t* bdir = getBaseDir();
long len = (int)wcslen(bdir);
long tlen = len + (int)wcslen(relative);
wchar_t* result = new wchar_t[tlen + 1];
- if(result){
- wcscpy(result,bdir);
- wcscpy(result + len,relative);
+ if(result) {
+ wcscpy(result, bdir);
+ wcscpy(result + len, relative);
}
return result;
}
-static int countNoWhitespace(const wchar_t *str) {
+static int countNoWhitespace(const wchar_t *str)
+{
int c;
for (c=0; *str!='\n' && *str!='\r' && *str!='\t' && *str!=' ' && *str!='\0'; str++, c++);
return c;
}
-void Utils::appendText(char **str, int *sizeAlloced, const char *fmt, ...) {
+void Utils::appendText(char **str, int *sizeAlloced, const char *fmt, ...)
+{
va_list vararg;
char *p;
int size, len;
@@ -90,7 +84,8 @@ void Utils::appendText(char **str, int *sizeAlloced, const char *fmt, ...) {
va_end(vararg);
}
-void Utils::appendText(wchar_t **str, int *sizeAlloced, const wchar_t *fmt, ...) {
+void Utils::appendText(wchar_t **str, int *sizeAlloced, const wchar_t *fmt, ...)
+{
va_list vararg;
wchar_t *p;
int size, len;
@@ -124,87 +119,8 @@ void Utils::appendText(wchar_t **str, int *sizeAlloced, const wchar_t *fmt, ...)
va_end(vararg);
}
-char *Utils::dupString(const char *a) {
- if (a!=NULL) {
- char *b = new char[strlen(a)+1];
- strcpy(b, a);
- return b;
- }
- return NULL;
-}
-
-char *Utils::dupString(const char *a, int l) {
- if (a!=NULL) {
- char *b = new char[l+1];
- strncpy(b, a, l);
- b[l] ='\0';
- return b;
- }
- return NULL;
-}
-
-wchar_t *Utils::dupString(const wchar_t *a) {
- if (a!=NULL) {
- wchar_t *b = new wchar_t[wcslen(a)+1];
- wcscpy(b, a);
- return b;
- }
- return NULL;
-}
-
-wchar_t *Utils::dupString(const wchar_t *a, int l) {
- if (a!=NULL) {
- wchar_t *b = new wchar_t[l+1];
- wcsncpy(b, a, l);
- b[l] ='\0';
- return b;
- }
- return NULL;
-}
-
-
-wchar_t *Utils::convertToWCS(const char *a) {
- if (a!=NULL) {
- int len = (int)strlen(a)+1;
- wchar_t *b = new wchar_t[len];
- MultiByteToWideChar(CP_ACP, 0, a, len, b, len);
- return b;
- }
- return NULL;
-}
-
-wchar_t *Utils::convertToWCS(const char *a, int cp) {
- if (a!=NULL) {
- int len = (int)strlen(a)+1;
- wchar_t *b = new wchar_t[len];
- MultiByteToWideChar(cp, 0, a, len, b, len);
- return b;
- }
- return NULL;
-}
-
-char *Utils::convertToString(const wchar_t *a) {
- if (a!=NULL) {
- int len = (int)wcslen(a)+1;
- char *b = new char[len];
- WideCharToMultiByte(CP_ACP, 0, a, len, b, len, NULL, FALSE);
- return b;
- }
- return NULL;
-}
-
-
-char *Utils::convertToString(const wchar_t *a, int cp) {
- if (a!=NULL) {
- int len = (int)wcslen(a)+1;
- char *b = new char[len];
- WideCharToMultiByte(cp, 0, a, len, b, len, NULL, FALSE);
- return b;
- }
- return NULL;
-}
-
-void Utils::convertPath(char *path) {
+void Utils::convertPath(char *path)
+{
if (path != NULL) {
for (; *path!='\0'; path++) {
if (*path == '\\') *path = '/';
@@ -212,7 +128,8 @@ void Utils::convertPath(char *path) {
}
}
-void Utils::convertPath(wchar_t *path) {
+void Utils::convertPath(wchar_t *path)
+{
if (path != NULL) {
for (; *path!='\0'; path++) {
if (*path == '\\') *path = '/';
@@ -220,16 +137,8 @@ void Utils::convertPath(wchar_t *path) {
}
}
-DWORD Utils::safe_wcslen(wchar_t *msg, DWORD maxLen) {
- DWORD i;
- for (i = 0; i < maxLen; i++) {
- if (msg[i] == (wchar_t)0)
- return i;
- }
- return 0;
-}
-
-int Utils::detectURL(const wchar_t *text) {
+int Utils::detectURL(const wchar_t *text)
+{
int i;
for (i=0;text[i]!='\0';i++) {
if (!((text[i] >= '0' && text[i]<='9') || iswalpha(text[i]))) {
@@ -248,7 +157,8 @@ int Utils::detectURL(const wchar_t *text) {
return 0;
}
-char *Utils::escapeString(const char *a) {
+char *Utils::escapeString(const char *a)
+{
int i, l, len;
char *out;
if (a == NULL) {
@@ -273,92 +183,23 @@ char *Utils::escapeString(const char *a) {
return out;
}
-struct FORK_ARG {
- HANDLE hEvent;
- void (__cdecl *threadcode)(void*);
- void *arg;
-};
-
-static void __cdecl forkthread_r(struct FORK_ARG *fa)
+wchar_t *Utils::urlEncode(const wchar_t *text)
{
- void (*callercode)(void*) = fa->threadcode;
- void *arg = fa->arg;
- Thread_Push((HINSTANCE)callercode);
- SetEvent(fa->hEvent);
- callercode(arg);
- Thread_Pop();
- return;
-}
-
-unsigned long Utils::forkThread(void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg) {
-
- unsigned long rc;
- struct FORK_ARG fa;
-
- fa.hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
- fa.threadcode = threadcode;
- fa.arg = arg;
- rc = _beginthread((void (__cdecl *)(void*))forkthread_r, stacksize, &fa);
- if ((unsigned long) -1L != rc) {
- WaitForSingleObject(fa.hEvent, INFINITE);
- }
- CloseHandle(fa.hEvent);
- return rc;
-}
-
-HANDLE Utils::hookEvent_Ex(const char *name, MIRANDAHOOK hook) {
- hookNum ++;
- hHooks = (HANDLE *) mir_realloc(hHooks, sizeof(HANDLE) * (hookNum));
- hHooks[hookNum - 1] = HookEvent(name, hook);
- return hHooks[hookNum - 1] ;
-}
-
-HANDLE Utils::createServiceFunction_Ex(const char *name, MIRANDASERVICE service) {
- serviceNum++;
- hServices = (HANDLE *) mir_realloc(hServices, sizeof(HANDLE) * (serviceNum));
- hServices[serviceNum - 1] = CreateServiceFunction(name, service);
- return hServices[serviceNum - 1] ;
-}
-
-void Utils::unhookEvents_Ex() {
- unsigned i;
- for (i=0; i<hookNum ; ++i) {
- if (hHooks[i] != NULL) {
- UnhookEvent(hHooks[i]);
- }
- }
- mir_free(hHooks);
- hookNum = 0;
- hHooks = NULL;
-}
-
-void Utils::destroyServices_Ex() {
- unsigned i;
- for (i=0; i<serviceNum; ++i) {
- if (hServices[i] != NULL) {
- DestroyServiceFunction(hServices[i]);
- }
- }
- mir_free(hServices);
- serviceNum = 0;
- hServices = NULL;
-}
-
-wchar_t *Utils::urlEncode(const wchar_t *text) {
char *utf8 = mir_utf8encodeT(text);
wchar_t *result = urlEncode(utf8);
mir_free(utf8);
return result;
}
-wchar_t *Utils::urlEncode(const char *text) {
+wchar_t *Utils::urlEncode(const char *text)
+{
char *pszReturnString = (char *)CallService(MS_NETLIB_URLENCODE, 0, (LPARAM)text);
- wchar_t *result = convertToWCS(pszReturnString);
+ wchar_t *result = mir_a2t(pszReturnString);
HeapFree(GetProcessHeap(), 0, pszReturnString);
return result;
}
-
-void Utils::appendIcon(char **str, int *sizeAlloced, const char *iconFile) {
+void Utils::appendIcon(char **str, int *sizeAlloced, const char *iconFile)
+{
Utils::appendText(str, sizeAlloced, "<img class=\"img\" src=\"file://%s/plugins/ieview/%s\"/> ", workingDirUtf8, iconFile);
-}
+} \ No newline at end of file
diff --git a/plugins/IEView/src/Utils.h b/plugins/IEView/src/Utils.h
index 33bf23dbed..c3d7df78ec 100644
--- a/plugins/IEView/src/Utils.h
+++ b/plugins/IEView/src/Utils.h
@@ -40,25 +40,10 @@ public:
static void appendText(wchar_t **str, int *sizeAlloced, const wchar_t *fmt, ...);
static void convertPath(char *path);
static void convertPath(wchar_t *path);
- static char *dupString(const char *a);
- static char *dupString(const char *a, int l);
- static wchar_t *dupString(const wchar_t *a);
- static wchar_t *dupString(const wchar_t *a, int l);
- static wchar_t *convertToWCS(const char *a);
- static wchar_t *convertToWCS(const char *a, int cp);
- static char *convertToString(const wchar_t *a);
- 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 int detectURL(const wchar_t *text);
- static HANDLE hookEvent_Ex(const char *name, MIRANDAHOOK hook);
- static HANDLE createServiceFunction_Ex(const char *name, MIRANDASERVICE service);
- static void unhookEvents_Ex();
- static void destroyServices_Ex();
- static unsigned long forkThread(void (__cdecl *threadcode)(void*),unsigned long stacksize,void *arg);
static wchar_t *urlEncode(const wchar_t *a);
static wchar_t *urlEncode(const char *a);
-
};
#endif
diff --git a/plugins/IEView/src/ieview_common.h b/plugins/IEView/src/ieview_common.h
index a909a9a6b1..e4df51f61a 100644
--- a/plugins/IEView/src/ieview_common.h
+++ b/plugins/IEView/src/ieview_common.h
@@ -71,10 +71,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "Template.h"
#include "TextToken.h"
+#define ieviewModuleName "IEVIEW"
+
extern HINSTANCE hInstance;
extern IEView *debugView;
extern char *workingDirUtf8;
-extern char *ieviewModuleName;
extern HANDLE hHookOptionsChanged;
#endif
diff --git a/plugins/IEView/src/ieview_main.cpp b/plugins/IEView/src/ieview_main.cpp
index ebebe01351..20446ab8f4 100644
--- a/plugins/IEView/src/ieview_main.cpp
+++ b/plugins/IEView/src/ieview_main.cpp
@@ -20,12 +20,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "ieview_common.h"
-char *ieviewModuleName;
HINSTANCE hInstance;
char *workingDirUtf8;
-static int ModulesLoaded(WPARAM wParam, LPARAM lParam);
-static int PreShutdown(WPARAM wParam, LPARAM lParam);
int hLangpack;
PLUGININFOEX pluginInfoEx = {
@@ -42,7 +39,7 @@ PLUGININFOEX pluginInfoEx = {
{0x0495171b, 0x7137, 0x4ded, {0x97, 0xf8, 0xce, 0x6f, 0xed, 0x67, 0xd6, 0x91}}
};
-extern "C" BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpvReserved)
+BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpvReserved)
{
hInstance = hModule;
return TRUE;
@@ -53,11 +50,15 @@ extern "C" __declspec(dllexport) PLUGININFOEX *MirandaPluginInfoEx(DWORD miranda
return &pluginInfoEx;
}
-extern "C" int __declspec(dllexport) Load(void)
+static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
{
- char text[_MAX_PATH];
- char *p, *q;
+ IEView::init();
+ Options::init();
+ return 0;
+}
+extern "C" int __declspec(dllexport) Load(void)
+{
int wdsize = GetCurrentDirectory(0, NULL);
TCHAR *workingDir = new TCHAR[wdsize];
GetCurrentDirectory(wdsize, workingDir);
@@ -65,48 +66,23 @@ extern "C" int __declspec(dllexport) Load(void)
workingDirUtf8 = mir_utf8encodeT(workingDir);
delete workingDir;
- GetModuleFileNameA(hInstance, text, sizeof(text));
- p = strrchr(text, '\\');
- p++;
- q = strrchr(p, '.');
- *q = '\0';
- ieviewModuleName = _strdup(p);
- _strupr(ieviewModuleName);
-
-
mir_getLP(&pluginInfoEx);
- Utils::hookEvent_Ex(ME_OPT_INITIALISE, IEViewOptInit);
- Utils::hookEvent_Ex(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- Utils::hookEvent_Ex(ME_SYSTEM_PRESHUTDOWN, PreShutdown);
+ HookEvent(ME_OPT_INITIALISE, IEViewOptInit);
+ HookEvent(ME_SYSTEM_MODULESLOADED, ModulesLoaded);
- Utils::createServiceFunction_Ex(MS_IEVIEW_WINDOW, HandleIEWindow);
- Utils::createServiceFunction_Ex(MS_IEVIEW_EVENT, HandleIEEvent);
- Utils::createServiceFunction_Ex(MS_IEVIEW_NAVIGATE, HandleIENavigate);
+ CreateServiceFunction(MS_IEVIEW_WINDOW, HandleIEWindow);
+ CreateServiceFunction(MS_IEVIEW_EVENT, HandleIEEvent);
+ CreateServiceFunction(MS_IEVIEW_NAVIGATE, HandleIENavigate);
hHookOptionsChanged = CreateHookableEvent(ME_IEVIEW_OPTIONSCHANGED);
return 0;
}
-static int ModulesLoaded(WPARAM wParam, LPARAM lParam)
-{
- IEView::init();
- Options::init();
- return 0;
-}
-
-static int PreShutdown(WPARAM wParam, LPARAM lParam)
-{
- return 0;
-}
-
extern "C" int __declspec(dllexport) Unload(void)
{
Options::uninit();
- Utils::unhookEvents_Ex();
- Utils::destroyServices_Ex();
DestroyHookableEvent(hHookOptionsChanged);
IEView::release();
mir_free(workingDirUtf8);
- free( ieviewModuleName );
return 0;
}