From 37f0dfdfac4dc0af578769b02e29efb9926415bb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 6 Apr 2013 21:07:53 +0000 Subject: postfix to the standard functions patch by Mataes git-svn-id: http://svn.miranda-ng.org/main/trunk@4351 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/IEView/src/ChatHTMLBuilder.cpp | 29 +- plugins/IEView/src/HTMLBuilder.cpp | 151 ++--- plugins/IEView/src/HistoryHTMLBuilder.cpp | 42 +- plugins/IEView/src/IEView.cpp | 264 ++++---- plugins/IEView/src/MUCCHTMLBuilder.cpp | 82 ++- plugins/IEView/src/Options.cpp | 1015 ++++++++++++++-------------- plugins/IEView/src/ScriverHTMLBuilder.cpp | 11 +- plugins/IEView/src/TabSRMMHTMLBuilder.cpp | 95 ++- plugins/IEView/src/Template.cpp | 281 ++++---- plugins/IEView/src/TemplateHTMLBuilder.cpp | 392 ++++++----- plugins/IEView/src/TextToken.cpp | 105 ++- plugins/IEView/src/Utils.cpp | 14 +- plugins/IEView/src/ieview_services.cpp | 84 ++- 13 files changed, 1273 insertions(+), 1292 deletions(-) (limited to 'plugins/IEView/src') diff --git a/plugins/IEView/src/ChatHTMLBuilder.cpp b/plugins/IEView/src/ChatHTMLBuilder.cpp index ff441a8642..774f766a0a 100644 --- a/plugins/IEView/src/ChatHTMLBuilder.cpp +++ b/plugins/IEView/src/ChatHTMLBuilder.cpp @@ -87,13 +87,12 @@ char *ChatHTMLBuilder::timestampToString(time_t time) char *pszStamp = "[%H:%M]"; //InitSetting( &g_Settings.pszTimeStamp, "HeaderTime", _T("[%H:%M]")); strftime(str, 79, pszStamp, localtime(&time)); - char *tmp = mir_utf8encode(str); - lstrcpynA(szResult, tmp, 500); - mir_free(tmp); + lstrcpynA(szResult, mir_ptr(mir_utf8encode(str)), 500); return szResult; } -void ChatHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) { +void ChatHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) +{ LOGFONTA lf; COLORREF color; char *output = NULL; @@ -158,7 +157,8 @@ void ChatHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) { * The following method is going to be completely rewritten soon. Do not modify or complain for the time being... */ -void ChatHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) { +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++) { @@ -168,25 +168,26 @@ void ChatHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) { int isSent = eventData->bIsMe; int outputSize = 0; char *output = NULL; - char *szName = NULL, *szText = NULL; const char *className = ""; bool showIcon = false; - if (eventData->dwFlags & IEEDF_UNICODE_TEXT) { + mir_ptr szName, szText; + if (eventData->dwFlags & IEEDF_UNICODE_TEXT) szText = encodeUTF8(NULL, event->pszProto, eventData->pszTextW, ENF_ALL | ENF_CHAT_FORMATTING, isSent); - } else { + else szText = encodeUTF8(NULL, event->pszProto, (char *)eventData->pszText, ENF_ALL | ENF_CHAT_FORMATTING, isSent); - } - if (eventData->dwFlags & IEEDF_UNICODE_NICK) { + + if (eventData->dwFlags & IEEDF_UNICODE_NICK) szName = encodeUTF8(NULL, event->pszProto, eventData->pszNickW, ENF_NAMESMILEYS, true); - } else { + else szName = encodeUTF8(NULL, event->pszProto, (char *) eventData->pszNick, ENF_NAMESMILEYS, true); - } + if (eventData->iType == IEED_GC_EVENT_MESSAGE) { iconFile = isSent ? "message_out_chat.gif" : "message_in_chat.gif"; showIcon = iconFlags & (isSent ? GC_EVENT_MESSAGE : GC_EVENT_MESSAGE); className = isSent ? "messageOut" : "messageIn"; - } else { + } + else { if (eventData->iType == IEED_GC_EVENT_ACTION) { iconFile = "action.gif"; className = "action"; @@ -244,8 +245,6 @@ void ChatHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) { view->write(output); free(output); } - if (szName!=NULL) delete szName; - if (szText!=NULL) delete szText; } } diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 0007feb8ab..6fad7a6fd5 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -35,13 +35,14 @@ HTMLBuilder::HTMLBuilder() { lastIEViewEvent.eventData = NULL; } -HTMLBuilder::~HTMLBuilder() { - if (lastIEViewEvent.pszProto != NULL) { +HTMLBuilder::~HTMLBuilder() +{ + if (lastIEViewEvent.pszProto != NULL) mir_free((void*)lastIEViewEvent.pszProto); - } } -bool HTMLBuilder::encode(HANDLE hContact, const char *proto, const wchar_t *text, wchar_t **output, int *outputSize, int level, int flags, bool isSent) { +bool HTMLBuilder::encode(HANDLE hContact, const char *proto, const wchar_t *text, wchar_t **output, int *outputSize, int level, int flags, bool isSent) +{ TextToken *token = NULL, *token2; switch (level) { case 0: @@ -66,22 +67,18 @@ bool HTMLBuilder::encode(HANDLE hContact, const char *proto, const wchar_t *text token = TextToken::tokenizeLinks(text); break; case 4: - if ((flags & ENF_SMILEYS) || - ((Options::getGeneralFlags() & Options::GENERAL_SMILEYINNAMES) && (flags & ENF_NAMESMILEYS))) { + if ((flags & ENF_SMILEYS) || ((Options::getGeneralFlags() & Options::GENERAL_SMILEYINNAMES) && (flags & ENF_NAMESMILEYS))) token = TextToken::tokenizeSmileys(hContact, proto, text, isSent); - } break; } if (token!=NULL) { - for (token2 = token;token!=NULL;token=token2) { + for (token2 = token; token != NULL; token = token2) { bool skip = false; token2 = token->getNext(); - if (token->getType() == TextToken::TEXT) { + if (token->getType() == TextToken::TEXT) skip = encode(hContact, proto, token->getTextW(), output, outputSize, level+1, flags, isSent); - } - if (!skip) { + if (!skip) token->toString(output, outputSize); - } delete token; } return true; @@ -89,28 +86,29 @@ bool HTMLBuilder::encode(HANDLE hContact, const char *proto, const wchar_t *text return false; } -wchar_t * HTMLBuilder::encode(HANDLE hContact, const char *proto, const wchar_t *text, int flags, bool isSent) { +wchar_t* HTMLBuilder::encode(HANDLE hContact, const char *proto, const wchar_t *text, int flags, bool isSent) +{ int outputSize; wchar_t *output = NULL; - if (text != NULL) { + if (text != NULL) encode(hContact, proto, text, &output, &outputSize, 0, flags, isSent); - } return output; } -char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const wchar_t *wtext, int flags, bool isSent) { +char* HTMLBuilder::encodeUTF8(HANDLE 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) { + if (output != NULL) free(output); - } } return outputStr; } -char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *text, int flags, bool isSent) { +char* HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *text, int flags, bool isSent) +{ char *outputStr = NULL; if (text != NULL) { wchar_t *wtext = mir_a2t(text); @@ -120,8 +118,9 @@ char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *t return outputStr; } -char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *text, int cp, int flags, bool isSent) { - char * outputStr = NULL; +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 = mir_a2t_cp(text, cp); outputStr = encodeUTF8(hContact, proto, wtext, flags, isSent); @@ -130,67 +129,75 @@ char * HTMLBuilder::encodeUTF8(HANDLE hContact, const char *proto, const char *t return outputStr; } -char *HTMLBuilder::getProto(HANDLE hContact) { +char* HTMLBuilder::getProto(HANDLE hContact) +{ return mir_strdup(GetContactProto(hContact)); } -char *HTMLBuilder::getProto(const char *proto, HANDLE hContact) { - if (proto != NULL) { +char* HTMLBuilder::getProto(const char *proto, HANDLE hContact) +{ + if (proto != NULL) return mir_strdup(proto); - } + return mir_strdup(GetContactProto(hContact)); } -char *HTMLBuilder::getRealProto(HANDLE hContact) { - if (hContact != NULL) { - 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)); - } +char* HTMLBuilder::getRealProto(HANDLE hContact) +{ + if (hContact == NULL) + return NULL; + + 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; } - return NULL; + return szProto; } -char *HTMLBuilder::getRealProto(HANDLE hContact, const char *szProto) { +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) { + if (hContact != NULL) return mir_strdup(GetContactProto(hContact)); - } } return mir_strdup(szProto); } -HANDLE HTMLBuilder::getRealContact(HANDLE hContact) { +HANDLE HTMLBuilder::getRealContact(HANDLE hContact) +{ char *szProto = GetContactProto(hContact); - if (szProto != NULL && !strcmp(szProto,"MetaContacts")) { + if (szProto != NULL && !strcmp(szProto,"MetaContacts")) hContact = (HANDLE) CallService(MS_MC_GETMOSTONLINECONTACT, (WPARAM) hContact, 0); - } return hContact; } -int HTMLBuilder::getLastEventType() { +int HTMLBuilder::getLastEventType() +{ return iLastEventType; } -void HTMLBuilder::setLastEventType(int t) { +void HTMLBuilder::setLastEventType(int t) +{ iLastEventType = t; } -DWORD HTMLBuilder::getLastEventTime() { +DWORD HTMLBuilder::getLastEventTime() +{ return lastEventTime; } -void HTMLBuilder::setLastEventTime(DWORD t) { +void HTMLBuilder::setLastEventTime(DWORD t) +{ lastEventTime = t; } -bool HTMLBuilder::isSameDate(time_t time1, time_t time2) { +bool HTMLBuilder::isSameDate(time_t time1, time_t time2) +{ struct tm tm_t1, tm_t2; tm_t1 = *localtime((time_t *)(&time1)); tm_t2 = *localtime((time_t *)(&time2)); @@ -201,7 +208,8 @@ bool HTMLBuilder::isSameDate(time_t time1, time_t time2) { return false; } -void HTMLBuilder::getUINs(HANDLE hContact, char *&uinIn, char *&uinOut) { +void HTMLBuilder::getUINs(HANDLE hContact, char *&uinIn, char *&uinOut) +{ CONTACTINFO ci; char buf[128]; char *szProto; @@ -304,18 +312,17 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) HANDLE hDbEvent = event->hDbEventFirst; event->hDbEventFirst = NULL; - IEVIEWEVENT newEvent = { sizeof (IEVIEWEVENT) }; - newEvent.iType = IEE_LOG_MEM_EVENTS; - newEvent.codepage = CP_ACP; - if (event->cbSize >= IEVIEWEVENT_SIZE_V2) - newEvent.codepage = event->codepage; - - char *szProto; + mir_ptr szProto; if (event->cbSize >= IEVIEWEVENT_SIZE_V3 && event->pszProto != NULL) szProto = mir_strdup(event->pszProto); else szProto = getProto(event->hContact); + IEVIEWEVENT newEvent = { sizeof (IEVIEWEVENT) }; + newEvent.iType = IEE_LOG_MEM_EVENTS; + newEvent.codepage = CP_ACP; + if (event->cbSize >= IEVIEWEVENT_SIZE_V2) + newEvent.codepage = event->codepage; newEvent.pszProto = szProto; newEvent.count = 0; newEvent.dwFlags = event->dwFlags; @@ -378,30 +385,21 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) //blob is: sequenceid(DWORD),filename(ASCIIZ),description(ASCIIZ) char* filename = ((char *)dbei.pBlob) + sizeof(DWORD); char* descr = filename + lstrlenA(filename) + 1; - TCHAR *tStr = DbGetEventStringT(&dbei, filename); - eventData->ptszText = mir_tstrdup(tStr); - mir_free(tStr); - if (*descr != '\0') { - tStr = DbGetEventStringT(&dbei, descr); - eventData->ptszText2 = mir_tstrdup(tStr); - mir_free(tStr); - } + eventData->ptszText = DbGetEventStringT(&dbei, filename); + if (*descr != '\0') + eventData->ptszText2 = DbGetEventStringT(&dbei, descr); 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 = mir_tstrdup(TranslateT(" requested authorisation")); - TCHAR *tStr = DbGetEventStringT(&dbei, (char *)dbei.pBlob + 8); - eventData->ptszNick = mir_tstrdup(tStr); - mir_free(tStr); + eventData->ptszNick = DbGetEventStringT(&dbei, (char *)dbei.pBlob + 8); 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 = mir_tstrdup(TranslateT(" was added.")); - TCHAR *tStr = DbGetEventStringT(&dbei, (char *)dbei.pBlob + 8); - eventData->ptszNick = mir_tstrdup(tStr); - mir_free(tStr); + eventData->ptszNick = DbGetEventStringT(&dbei, (char *)dbei.pBlob + 8); eventData->iType = IEED_EVENT_SYSTEM; } free(dbei.pBlob); @@ -419,20 +417,11 @@ void HTMLBuilder::appendEventOld(IEView *view, IEVIEWEVENT *event) appendEventNew(view, &newEvent); for ( IEVIEWEVENTDATA* eventData2 = newEvent.eventData; eventData2 != NULL; eventData2 = eventData) { eventData = eventData2->next; - if (eventData2->pszTextW != NULL) { - mir_free((void*)eventData2->pszTextW); - } - if (eventData2->pszText2W != NULL) { - mir_free((void*)eventData2->pszText2W); - } - if (eventData2->pszNickW != NULL) { - mir_free((void*)eventData2->pszNickW); - } + mir_free((void*)eventData2->pszTextW); + mir_free((void*)eventData2->pszText2W); + mir_free((void*)eventData2->pszNickW); delete eventData2; } - if (szProto != NULL) { - mir_free(szProto); - } } ProtocolSettings* HTMLBuilder::getSRMMProtocolSettings(const char *protocolName) diff --git a/plugins/IEView/src/HistoryHTMLBuilder.cpp b/plugins/IEView/src/HistoryHTMLBuilder.cpp index 4b5fae0478..c5ccebfa6a 100644 --- a/plugins/IEView/src/HistoryHTMLBuilder.cpp +++ b/plugins/IEView/src/HistoryHTMLBuilder.cpp @@ -89,9 +89,7 @@ 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); - char *tmp = mir_utf8encode(szResult); - lstrcpynA(szResult, tmp, 500); - mir_free(tmp); + lstrcpynA(szResult, mir_ptr(mir_utf8encode(szResult)), 500); return szResult; } @@ -230,10 +228,10 @@ void HistoryHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event char *output = NULL; int isSent = eventData->dwFlags & IEEDF_SENT; int isRTL = eventData->dwFlags & IEEDF_RTL; - if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_STATUSCHANGE - || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_FILE) { - char *szName = NULL; - char *szText = NULL; + if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_STATUSCHANGE || + eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_FILE) + { + mir_ptr szName, szText; if (eventData->dwFlags & IEEDF_UNICODE_NICK) szName = encodeUTF8(event->hContact, szRealProto, eventData->pszNickW, ENF_NAMESMILEYS, true); else @@ -248,20 +246,20 @@ void HistoryHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event const char *className = NULL; const char *iconFile = NULL; switch (eventData->iType) { - case IEED_EVENT_SYSTEM: - Utils::appendText(&output, &outputSize, "
", "divSystem"); - break; - case IEED_EVENT_FILE: - iconFile = "file.gif"; - Utils::appendText(&output, &outputSize, "
", isSent ? "divFileOut" : "divFileIn"); - break; - case IEED_EVENT_URL: - iconFile = "url.gif"; - Utils::appendText(&output, &outputSize, "
", isSent ? "divUrlOut" : "divUrlIn"); - break; - default: - iconFile = "message.gif"; - Utils::appendText(&output, &outputSize, "
", isSent ? "divMessageOut" : "divMessageIn"); + case IEED_EVENT_SYSTEM: + Utils::appendText(&output, &outputSize, "
", "divSystem"); + break; + case IEED_EVENT_FILE: + iconFile = "file.gif"; + Utils::appendText(&output, &outputSize, "
", isSent ? "divFileOut" : "divFileIn"); + break; + case IEED_EVENT_URL: + iconFile = "url.gif"; + Utils::appendText(&output, &outputSize, "
", isSent ? "divUrlOut" : "divUrlIn"); + break; + default: + iconFile = "message.gif"; + Utils::appendText(&output, &outputSize, "
", isSent ? "divMessageOut" : "divMessageIn"); } if (dwFlags & SMF_LOG_SHOWICONS && iconFile != NULL) Utils::appendIcon(&output, &outputSize, iconFile); @@ -280,8 +278,6 @@ void HistoryHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event Utils::appendText(&output, &outputSize, "
\n"); setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType)); setLastEventTime(eventData->time); - if (szName!=NULL) delete szName; - if (szText!=NULL) delete szText; } if (output != NULL) { view->write(output); diff --git a/plugins/IEView/src/IEView.cpp b/plugins/IEView/src/IEView.cpp index 8b0ce78ff4..edecd1e419 100644 --- a/plugins/IEView/src/IEView.cpp +++ b/plugins/IEView/src/IEView.cpp @@ -292,37 +292,40 @@ IEView::IEView(HWND parent, HTMLBuilder* builder, int x, int y, int cx, int cy) } setMainWndProc((WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) IEViewWindowProcedure)); } - EnterCriticalSection(&mutex); - next = list; - if (next != NULL) { - next->prev = this; + { + mir_cslock lck(mutex); + next = list; + if (next != NULL) + next->prev = this; + list = this; } - list = this; - LeaveCriticalSection(&mutex); -// clear(); + pWebBrowser->put_RegisterAsDropTarget(VARIANT_FALSE); } -IEView::~IEView() { - IOleObject* pOleObject = NULL; - EnterCriticalSection(&mutex); - if (list == this) { - list = next; - } else if (prev!=NULL) { - prev->next = next; - } - if (next != NULL) { - next->prev = prev; +IEView::~IEView() +{ + IOleObject* pOleObject = NULL; + { + mir_cslock lck(mutex); + if (list == this) + list = next; + else if (prev != NULL) + prev->next = next; + + if (next != NULL) + next->prev = prev; + + prev = NULL; + next = NULL; } - prev = NULL; - next = NULL; - LeaveCriticalSection(&mutex); + if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleObject, (void**)&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; @@ -331,74 +334,83 @@ IEView::~IEView() { m_pConnectionPoint->Unadvise(m_dwCookie); m_pConnectionPoint->Release(); } - if (sink != NULL) { + + mir_free(selectedText); + + if (sink != NULL) delete sink; - } - if (selectedText != NULL) { - delete selectedText; - } pWebBrowser->Release(); DestroyWindow(hwnd); } -void IEView::init() { +void IEView::init() +{ if (isInited) return; + isInited = true; InitializeCriticalSection(&mutex); - if (FAILED(OleInitialize(NULL))) { + if (FAILED(OleInitialize(NULL))) MessageBox(NULL, TranslateT("OleInitialize failed."), TranslateT("ERROR"), MB_OK); - } } -void IEView::release() { - if (!isInited) return; +void IEView::release() +{ + if (!isInited) + return; + EnterCriticalSection(&mutex); - while (list != NULL) { + while (list != NULL) delete list; - } + LeaveCriticalSection(&mutex); DeleteCriticalSection(&mutex); } -IEView* IEView::get(HWND hwnd) { - IEView *ptr; +IEView* IEView::get(HWND hwnd) +{ if (list == NULL) return NULL; - EnterCriticalSection(&mutex); - for (ptr = list; ptr !=NULL; ptr=ptr->next) { - if (ptr->hwnd == hwnd) { - break; - } - } - LeaveCriticalSection(&mutex); - return ptr; + + mir_cslock lock(mutex); + for (IEView *ptr = list; ptr !=NULL; ptr=ptr->next) + if (ptr->hwnd == hwnd) + return ptr; + + return NULL; } -void IEView::setMainWndProc(WNDPROC wndProc) { +void IEView::setMainWndProc(WNDPROC wndProc) +{ mainWndProc = wndProc; } -WNDPROC IEView::getMainWndProc() { +WNDPROC IEView::getMainWndProc() +{ return mainWndProc; } -void IEView::setDocWndProc(WNDPROC wndProc) { +void IEView::setDocWndProc(WNDPROC wndProc) +{ docWndProc = wndProc; } -WNDPROC IEView::getDocWndProc() { +WNDPROC IEView::getDocWndProc() +{ return docWndProc; } -void IEView::setServerWndProc(WNDPROC wndProc) { +void IEView::setServerWndProc(WNDPROC wndProc) +{ serverWndProc = wndProc; } -WNDPROC IEView::getServerWndProc() { +WNDPROC IEView::getServerWndProc() +{ return serverWndProc; } // IUnknown -STDMETHODIMP IEView::QueryInterface(REFIID riid, PVOID *ppv) { +STDMETHODIMP IEView::QueryInterface(REFIID riid, PVOID *ppv) +{ *ppv=NULL; if (IID_IUnknown==riid) *ppv=this; @@ -410,9 +422,9 @@ STDMETHODIMP IEView::QueryInterface(REFIID riid, PVOID *ppv) { *ppv=(IDocHostUIHandler*)this;//m_pIOleIPSite; if (IID_IInternetSecurityManager==riid) *ppv=(IInternetSecurityManager*)this; - if (IID_IServiceProvider==riid) { + if (IID_IServiceProvider==riid) *ppv=(IServiceProvider*)this; - } + if (NULL!=*ppv) { ((LPUNKNOWN)*ppv)->AddRef(); return NOERROR; @@ -420,12 +432,14 @@ STDMETHODIMP IEView::QueryInterface(REFIID riid, PVOID *ppv) { return E_NOINTERFACE; } -STDMETHODIMP_(ULONG) IEView::AddRef(void) { +STDMETHODIMP_(ULONG) IEView::AddRef(void) +{ ++m_cRef; return m_cRef; } -STDMETHODIMP_(ULONG) IEView::Release(void) { +STDMETHODIMP_(ULONG) IEView::Release(void) +{ --m_cRef; return m_cRef; } @@ -445,33 +459,38 @@ STDMETHODIMP IEView::Invoke(DISPID dispIdMember, REFIID riid, LCID lcid , WORD w } // IOleWindow -STDMETHODIMP IEView::GetWindow(HWND *phwnd) { +STDMETHODIMP IEView::GetWindow(HWND *phwnd) +{ *phwnd = parent; return S_OK; } -STDMETHODIMP IEView::ContextSensitiveHelp(BOOL fEnterMode) { +STDMETHODIMP IEView::ContextSensitiveHelp(BOOL fEnterMode) +{ return E_NOTIMPL; } // IOleInPlace -STDMETHODIMP IEView::CanInPlaceActivate(void) { +STDMETHODIMP IEView::CanInPlaceActivate(void) +{ return S_OK; } -STDMETHODIMP IEView::OnInPlaceActivate(void) { +STDMETHODIMP IEView::OnInPlaceActivate(void) +{ m_bInPlaceActive = TRUE; return S_OK; } -STDMETHODIMP IEView::OnUIActivate(void) { +STDMETHODIMP IEView::OnUIActivate(void) +{ return E_NOTIMPL; } STDMETHODIMP IEView::GetWindowContext(IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect, LPRECT lprcClipRect, - LPOLEINPLACEFRAMEINFO lpFrameInfo) { - + LPOLEINPLACEFRAMEINFO lpFrameInfo) +{ lprcPosRect->left = rcClient.left; lprcPosRect->top = rcClient.top; lprcPosRect->right = rcClient.right; @@ -483,52 +502,65 @@ STDMETHODIMP IEView::GetWindowContext(IOleInPlaceFrame **ppFrame, IOleInPlaceUIW return S_OK; } -STDMETHODIMP IEView::Scroll(SIZE scrollExtant) { +STDMETHODIMP IEView::Scroll(SIZE scrollExtant) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::OnUIDeactivate(BOOL fUndoable) { +STDMETHODIMP IEView::OnUIDeactivate(BOOL fUndoable) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::OnInPlaceDeactivate( void) { +STDMETHODIMP IEView::OnInPlaceDeactivate(void) +{ m_bInPlaceActive = FALSE; return S_OK; } -STDMETHODIMP IEView::DiscardUndoState( void) { +STDMETHODIMP IEView::DiscardUndoState(void) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::DeactivateAndUndo( void) { +STDMETHODIMP IEView::DeactivateAndUndo(void) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::OnPosRectChange(LPCRECT lprcPosRect) { +STDMETHODIMP IEView::OnPosRectChange(LPCRECT lprcPosRect) +{ return E_NOTIMPL; } // IOleClientSite -STDMETHODIMP IEView::SaveObject(void) { +STDMETHODIMP IEView::SaveObject(void) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) { +STDMETHODIMP IEView::GetMoniker(DWORD dwAssign, DWORD dwWhichMoniker, IMoniker **ppmk) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::GetContainer(IOleContainer **ppContainer) { +STDMETHODIMP IEView::GetContainer(IOleContainer **ppContainer) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::ShowObject(void) { +STDMETHODIMP IEView::ShowObject(void) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::OnShowWindow(BOOL fShow) { +STDMETHODIMP IEView::OnShowWindow(BOOL fShow) +{ return E_NOTIMPL; } -STDMETHODIMP IEView::RequestNewObjectLayout(void) { +STDMETHODIMP IEView::RequestNewObjectLayout(void) +{ return E_NOTIMPL; } // IDocHostUIHandler -STDMETHODIMP IEView::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarget, IDispatch *pdispReserved) { +STDMETHODIMP IEView::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarget, IDispatch *pdispReserved) +{ IOleCommandTarget * pOleCommandTarget; IOleWindow * pOleWindow; HWND hSPWnd; @@ -602,7 +634,8 @@ STDMETHODIMP IEView::ShowContextMenu(DWORD dwID, POINT *ppt, IUnknown *pcmdTarge #endif return S_OK; } -STDMETHODIMP IEView::GetHostInfo(DOCHOSTUIINFO *pInfo) { +STDMETHODIMP IEView::GetHostInfo(DOCHOSTUIINFO *pInfo) +{ pInfo->dwFlags = DOCHOSTUIFLAG_NO3DBORDER;// | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE; if (builder == NULL) { pInfo->dwFlags |= DOCHOSTUIFLAG_DIALOG; @@ -610,7 +643,8 @@ STDMETHODIMP IEView::GetHostInfo(DOCHOSTUIINFO *pInfo) { return S_OK; } STDMETHODIMP IEView::ShowUI(DWORD dwID, IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget, - IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc) { + IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc) +{ return S_OK; } @@ -824,7 +858,8 @@ void IEView::scrollToBottom() {/* } } -void IEView::write(const wchar_t *text) { +void IEView::write(const wchar_t *text) +{ IHTMLDocument2 *document = getDocument(); if (document != NULL) { SAFEARRAY *safe_array = SafeArrayCreateVector(VT_VARIANT,0,1); @@ -843,7 +878,8 @@ void IEView::write(const wchar_t *text) { } } -void IEView::write(const char *text) { +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); @@ -851,7 +887,8 @@ void IEView::write(const char *text) { delete [] wcsTemp; } -void IEView::writef(const char *fmt, ...) { +void IEView::writef(const char *fmt, ...) +{ char *str; va_list vararg; int strsize; @@ -864,7 +901,8 @@ void IEView::writef(const char *fmt, ...) { free(str); } -void IEView::navigate(const char *url) { +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); @@ -930,67 +968,62 @@ void IEView::clear(IEVIEWEVENT *event) if (document != NULL) { document->Release(); } - } else { + } + else { document->close(); - VARIANT open_name; - VARIANT open_features; - VARIANT open_replace; - IDispatch *open_window = NULL; + VARIANT open_name, open_features, open_replace; + IDispatch *open_window = NULL; VariantInit(&open_name); - open_name.vt = VT_BSTR; + 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) { + 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) { + if (builder != NULL) builder->clear(this, event); - } + clearRequired = false; getFocus = false; setBorder(); } -void* IEView::getSelection(IEVIEWEVENT *event) { - if (selectedText!=NULL) delete selectedText; +void* IEView::getSelection(IEVIEWEVENT *event) +{ + mir_free(selectedText); selectedText = getSelection(); - if (selectedText == NULL || wcslen(selectedText)== 0) return NULL; + if (selectedText == NULL || wcslen(selectedText)== 0) + return NULL; + if (event->dwFlags & IEEF_NO_UNICODE) { int cp = CP_ACP; - if (event->cbSize >= IEVIEWEVENT_SIZE_V2) { + if (event->cbSize >= IEVIEWEVENT_SIZE_V2) cp = event->codepage; - } + char *str = mir_t2a_cp(selectedText, cp); - delete selectedText; - selectedText = (BSTR) str; + mir_free(selectedText); + selectedText = (BSTR)str; } - return (void *)selectedText; + return (void*)selectedText; } - -HWND IEView::getHWND() { +HWND IEView::getHWND() +{ return hwnd; } - -void IEView::setContact(HANDLE hContact) { +void IEView::setContact(HANDLE hContact) +{ this->hContact = hContact; isContactSet = true; } -void IEView::translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam) { +void IEView::translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam) +{ IOleInPlaceActiveObject* pIOIPAO; if (SUCCEEDED(pWebBrowser->QueryInterface(IID_IOleInPlaceActiveObject, (void**)&pIOIPAO))) { MSG msg; @@ -1005,7 +1038,8 @@ void IEView::translateAccelerator(UINT uMsg, WPARAM wParam, LPARAM lParam) { /** * Returns the selected text within the active document **/ -BSTR IEView::getSelection() { +BSTR IEView::getSelection() +{ BSTR text = NULL; IHTMLDocument2 *document = getDocument(); if (document != NULL) { @@ -1015,9 +1049,9 @@ BSTR IEView::getSelection() { if (SUCCEEDED(pSelection->createRange( &pDisp )) && pDisp != NULL) { IHTMLTxtRange *pRange = NULL; if (SUCCEEDED(pDisp->QueryInterface(IID_IHTMLTxtRange, (void**)&pRange))) { - if (SUCCEEDED(pRange->get_text(&text))) { + if (SUCCEEDED(pRange->get_text(&text))) text = mir_tstrdup(text); - } + pRange->Release(); } pDisp->Release(); diff --git a/plugins/IEView/src/MUCCHTMLBuilder.cpp b/plugins/IEView/src/MUCCHTMLBuilder.cpp index 6787de8e11..ee70762939 100644 --- a/plugins/IEView/src/MUCCHTMLBuilder.cpp +++ b/plugins/IEView/src/MUCCHTMLBuilder.cpp @@ -109,9 +109,7 @@ char *MUCCHTMLBuilder::timestampToString(DWORD dwData, time_t check) } CallService(MS_DB_TIME_TIMESTAMPTOSTRING, check, (LPARAM) & dbtts); strncat(szResult, str, 500); - char *tmp = mir_utf8encode(szResult); - lstrcpynA(szResult, tmp, 500); - mir_free(tmp); + lstrcpynA(szResult, mir_ptr(mir_utf8encode(szResult)), 500); return szResult; } @@ -192,40 +190,40 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) { int isSent = eventData->bIsMe; int outputSize; char *output = NULL; - char *szName = NULL, *szText = NULL; + mir_ptr szName, szText; if (eventData->iType == IEED_MUCC_EVENT_MESSAGE) { - if (eventData->dwFlags & IEEDF_UNICODE_TEXT) { + if (eventData->dwFlags & IEEDF_UNICODE_TEXT) szText = encodeUTF8(NULL, event->pszProto, eventData->pszTextW, ENF_ALL, isSent); - } else { + else szText = encodeUTF8(NULL, event->pszProto, eventData->pszText, ENF_ALL, isSent); - } - if (eventData->dwFlags & IEEDF_UNICODE_NICK) { + + if (eventData->dwFlags & IEEDF_UNICODE_NICK) szName = encodeUTF8(NULL, event->pszProto, eventData->pszNickW, ENF_NAMESMILEYS, true); - } else { + else szName = encodeUTF8(NULL, event->pszProto, eventData->pszNick, ENF_NAMESMILEYS, true); - } + Utils::appendText(&output, &outputSize, "
", isSent ? "divOut" : "divIn"); - if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) { + if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) Utils::appendText(&output, &outputSize, "%s ", isSent ? "timestamp" : "timestamp", timestampToString(dwData, eventData->time)); - } - if (dwData & IEEDD_MUCC_SHOW_NICK) { + + if (dwData & IEEDD_MUCC_SHOW_NICK) Utils::appendText(&output, &outputSize, "%s: ", isSent ? "nameOut" : "nameIn", szName); - } - if (dwData & IEEDD_MUCC_MSG_ON_NEW_LINE) { + + if (dwData & IEEDD_MUCC_MSG_ON_NEW_LINE) Utils::appendText(&output, &outputSize, "
"); - } + const char *className = isSent ? "messageOut" : "messageIn"; - if (eventData->dwFlags & IEEDF_FORMAT_SIZE && eventData->fontSize > 0) { + if (eventData->dwFlags & IEEDF_FORMAT_SIZE && eventData->fontSize > 0) Utils::appendText(&style, &styleSize, "font-size:%dpt;", eventData->fontSize); - } - if (eventData->dwFlags & IEEDF_FORMAT_COLOR && eventData->color!=0xFFFFFFFF) { + + if (eventData->dwFlags & IEEDF_FORMAT_COLOR && eventData->color!=0xFFFFFFFF) Utils::appendText(&style, &styleSize, "color:#%06X;", ((eventData->color & 0xFF) << 16) | (eventData->color & 0xFF00) | ((eventData->color & 0xFF0000) >> 16)); - } - if (eventData->dwFlags & IEEDF_FORMAT_FONT) { + + if (eventData->dwFlags & IEEDF_FORMAT_FONT) Utils::appendText(&style, &styleSize, "font-family:%s;", eventData->fontName); - } + if (eventData->dwFlags & IEEDF_FORMAT_STYLE) { Utils::appendText(&style, &styleSize, "font-weight: %s;", eventData->fontStyle & IE_FONT_BOLD ? "bold" : "normal"); Utils::appendText(&style, &styleSize, "font-style: %s;", eventData->fontStyle & IE_FONT_ITALIC ? "italic" : "normal"); @@ -233,64 +231,62 @@ void MUCCHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event) { } Utils::appendText(&output, &outputSize, "%s", className, style!=NULL ? style : "", szText); Utils::appendText(&output, &outputSize, "
\n"); - if (style!=NULL) free(style); - } else if (eventData->iType == IEED_MUCC_EVENT_JOINED || eventData->iType == IEED_MUCC_EVENT_LEFT || eventData->iType == IEED_MUCC_EVENT_TOPIC) { - const char *className, *divName; - const char *eventText; + if (style != NULL) + free(style); + } + else if (eventData->iType == IEED_MUCC_EVENT_JOINED || eventData->iType == IEED_MUCC_EVENT_LEFT || eventData->iType == IEED_MUCC_EVENT_TOPIC) { + const char *className, *divName, *eventText; if (eventData->iType == IEED_MUCC_EVENT_JOINED) { className = "userJoined"; divName = "divUserJoined"; eventText = LPGEN("%s has joined."); szText = encodeUTF8(NULL, event->pszProto, eventData->pszNick, ENF_NONE, isSent); - } else if (eventData->iType == IEED_MUCC_EVENT_LEFT) { + } + else if (eventData->iType == IEED_MUCC_EVENT_LEFT) { className = "userLeft"; divName = "divUserJoined"; eventText = LPGEN("%s has left."); szText = encodeUTF8(NULL, event->pszProto, eventData->pszNick, ENF_NONE, isSent); - } else { + } + else { className = "topicChange"; divName = "divTopicChange"; eventText = LPGEN("The topic is %s."); szText = encodeUTF8(NULL, event->pszProto, eventData->pszText, ENF_ALL, isSent); } Utils::appendText(&output, &outputSize, "
", divName); - if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) { + if (dwData & IEEDD_MUCC_SHOW_TIME || dwData & IEEDD_MUCC_SHOW_DATE) Utils::appendText(&output, &outputSize, "%s ", isSent ? "timestamp" : "timestamp", timestampToString(dwData, eventData->time)); - } + Utils::appendText(&output, &outputSize, "", className); Utils::appendText(&output, &outputSize, Translate(eventText), szText); Utils::appendText(&output, &outputSize, ""); Utils::appendText(&output, &outputSize, "
\n"); - } else if (eventData->iType == IEED_MUCC_EVENT_ERROR) { + } + else if (eventData->iType == IEED_MUCC_EVENT_ERROR) { const char *className = "error"; szText = encodeUTF8(NULL, event->pszProto, eventData->pszText, ENF_NONE, isSent); Utils::appendText(&output, &outputSize, "
", "divError"); Utils::appendText(&output, &outputSize, " %s: %s", className, Translate("Error"), szText); Utils::appendText(&output, &outputSize, "
\n"); } - if (szName!=NULL) delete szName; - if (szText!=NULL) delete szText; + if (output != NULL) { view->write(output); free(output); } } -// view->scrollToBottom(); } -void MUCCHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) { +void MUCCHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) +{ ProtocolSettings *protoSettings = getChatProtocolSettings(event->pszProto); - if (protoSettings == NULL) { - return; - } -// if (protoSettings->getSRMMMode() == Options::MODE_TEMPLATE) { - // appendEventTemplate(view, event); -// } else { + if (protoSettings != NULL) appendEventNonTemplate(view, event); -// } } -bool MUCCHTMLBuilder::isDbEventShown(DBEVENTINFO * dbei) { +bool MUCCHTMLBuilder::isDbEventShown(DBEVENTINFO *dbei) +{ return true; } diff --git a/plugins/IEView/src/Options.cpp b/plugins/IEView/src/Options.cpp index d8e34f7c87..673aaca570 100644 --- a/plugins/IEView/src/Options.cpp +++ b/plugins/IEView/src/Options.cpp @@ -49,7 +49,8 @@ static tabPages[] = { IEViewHistoryOptDlgProc, IDD_SRMM_OPTIONS, LPGENT("History") } }; -static LPARAM GetItemParam(HWND hwndTreeView, HTREEITEM hItem) { +static LPARAM GetItemParam(HWND hwndTreeView, HTREEITEM hItem) +{ TVITEM tvi = {0}; tvi.mask = TVIF_PARAM; tvi.hItem = hItem == NULL ? TreeView_GetSelection(hwndTreeView) : hItem; @@ -57,16 +58,16 @@ static LPARAM GetItemParam(HWND hwndTreeView, HTREEITEM hItem) { return tvi.lParam; } -static void SaveSRMMProtoSettings(HWND hwndDlg, ProtocolSettings *proto) { +static void SaveSRMMProtoSettings(HWND hwndDlg, ProtocolSettings *proto) +{ if (proto != NULL) { char path[MAX_PATH]; - int i; - i = Options::MODE_COMPATIBLE; - if (IsDlgButtonChecked(hwndDlg, IDC_MODE_TEMPLATE)) { + int i = Options::MODE_COMPATIBLE; + if (IsDlgButtonChecked(hwndDlg, IDC_MODE_TEMPLATE)) i = Options::MODE_TEMPLATE; - } else if (IsDlgButtonChecked(hwndDlg, IDC_MODE_CSS)) { + else if (IsDlgButtonChecked(hwndDlg, IDC_MODE_CSS)) i = Options::MODE_CSS; - } + proto->setSRMMModeTemp(i); i = IsDlgButtonChecked(hwndDlg, IDC_BACKGROUND_IMAGE) ? Options::LOG_IMAGE_ENABLED : 0; i |= IsDlgButtonChecked(hwndDlg, IDC_SCROLL_BACKGROUND_IMAGE) ? Options::LOG_IMAGE_SCROLL : 0; @@ -90,13 +91,12 @@ static void SaveSRMMProtoSettings(HWND hwndDlg, ProtocolSettings *proto) { static void SaveChatProtoSettings(HWND hwndDlg, ProtocolSettings *proto) { if (proto != NULL) { char path[MAX_PATH]; - int i; - i = Options::MODE_COMPATIBLE; - if (IsDlgButtonChecked(hwndDlg, IDC_MODE_TEMPLATE)) { + int i = Options::MODE_COMPATIBLE; + if (IsDlgButtonChecked(hwndDlg, IDC_MODE_TEMPLATE)) i = Options::MODE_TEMPLATE; - } else if (IsDlgButtonChecked(hwndDlg, IDC_MODE_CSS)) { + else if (IsDlgButtonChecked(hwndDlg, IDC_MODE_CSS)) i = Options::MODE_CSS; - } + proto->setChatModeTemp(i); i = IsDlgButtonChecked(hwndDlg, IDC_BACKGROUND_IMAGE) ? Options::LOG_IMAGE_ENABLED : 0; i |= IsDlgButtonChecked(hwndDlg, IDC_SCROLL_BACKGROUND_IMAGE) ? Options::LOG_IMAGE_SCROLL : 0; @@ -117,16 +117,16 @@ static void SaveChatProtoSettings(HWND hwndDlg, ProtocolSettings *proto) { } } -static void SaveHistoryProtoSettings(HWND hwndDlg, ProtocolSettings *proto) { +static void SaveHistoryProtoSettings(HWND hwndDlg, ProtocolSettings *proto) +{ if (proto != NULL) { char path[MAX_PATH]; - int i; - i = Options::MODE_COMPATIBLE; - if (IsDlgButtonChecked(hwndDlg, IDC_MODE_TEMPLATE)) { + int i = Options::MODE_COMPATIBLE; + if (IsDlgButtonChecked(hwndDlg, IDC_MODE_TEMPLATE)) i = Options::MODE_TEMPLATE; - } else if (IsDlgButtonChecked(hwndDlg, IDC_MODE_CSS)) { + else if (IsDlgButtonChecked(hwndDlg, IDC_MODE_CSS)) i = Options::MODE_CSS; - } + proto->setHistoryModeTemp(i); i = IsDlgButtonChecked(hwndDlg, IDC_BACKGROUND_IMAGE) ? Options::LOG_IMAGE_ENABLED : 0; i |= IsDlgButtonChecked(hwndDlg, IDC_SCROLL_BACKGROUND_IMAGE) ? Options::LOG_IMAGE_SCROLL : 0; @@ -147,8 +147,8 @@ static void SaveHistoryProtoSettings(HWND hwndDlg, ProtocolSettings *proto) { } } -static void UpdateControlsState(HWND hwndDlg) { - +static void UpdateControlsState(HWND hwndDlg) +{ BOOL bChecked = IsDlgButtonChecked(hwndDlg, IDC_MODE_TEMPLATE); EnableWindow(GetDlgItem(hwndDlg, IDC_TEMPLATES_FILENAME), bChecked); EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE_TEMPLATES), bChecked); @@ -172,27 +172,28 @@ static void UpdateControlsState(HWND hwndDlg) { EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE_BACKGROUND_IMAGE), bChecked); } -static void SetIcon(HWND hwnd, DWORD id, int index, bool condition) { +static void SetIcon(HWND hwnd, DWORD id, int index, bool condition) +{ HICON hIcon; - if (condition) { + if (condition) hIcon = ImageList_GetIcon(hImageList,index + 1,ILD_NORMAL); - } else { + else hIcon = ImageList_GetIcon(hImageList,index + 0,ILD_NORMAL); - } + hIcon = (HICON) SendDlgItemMessage(hwnd, id, STM_SETICON,(WPARAM)hIcon, 0); - if (hIcon != NULL) { + if (hIcon != NULL) DestroyIcon(hIcon); - } } - -static void UpdateTemplateIcons(HWND hwnd, const char *path) { +static void UpdateTemplateIcons(HWND hwnd, const char *path) +{ TemplateMap *tmap = TemplateMap::loadTemplates(path, path, true); if (tmap != NULL) { SetIcon(hwnd, IDC_GROUPSUPPORT, 0, tmap->isGrouping()); SetIcon(hwnd, IDC_RTLSUPPORT, 2, tmap->isRTL()); delete tmap; - } else { + } + else { SetIcon(hwnd, IDC_GROUPSUPPORT, 0, false); SetIcon(hwnd, IDC_RTLSUPPORT, 2, false); } @@ -646,56 +647,52 @@ static INT_PTR CALLBACK IEViewSRMMOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar if (strcmpi(proto->getProtocolName(), "_default_")) proto->setSRMMEnableTemp( TreeView_GetCheckState((HWND)wParam, (HTREEITEM) lParam)); - if ((HTREEITEM) lParam != TreeView_GetSelection((HWND)wParam)) { + if ((HTREEITEM) lParam != TreeView_GetSelection((HWND)wParam)) TreeView_SelectItem((HWND)wParam, (HTREEITEM) lParam); - } else { + else UpdateSRMMProtoInfo(hwndDlg, proto); - } + MarkChanges(2, hwndDlg); } break; case WM_NOTIFY: - { - if (((LPNMHDR)lParam)->idFrom == IDC_PROTOLIST) { - switch (((LPNMHDR)lParam)->code) { - case NM_CLICK: - { - TVHITTESTINFO ht = {0}; - DWORD dwpos = GetMessagePos(); - POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos)); - MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1); - TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht); - if (TVHT_ONITEMSTATEICON & ht.flags) { - PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, (LPARAM)ht.hItem); - return FALSE; - } - } - break; - case TVN_KEYDOWN: - if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE) - PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, - (LPARAM)TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom)); - break; - case TVN_SELCHANGEDA: - case TVN_SELCHANGEDW: - { - ProtocolSettings *proto = (ProtocolSettings *)GetItemParam(GetDlgItem(hwndDlg, IDC_PROTOLIST), (HTREEITEM) NULL); - SaveSRMMProtoSettings(hwndDlg, srmmCurrentProtoItem); - UpdateSRMMProtoInfo(hwndDlg, proto); - } - break; + if (((LPNMHDR)lParam)->idFrom == IDC_PROTOLIST) { + switch (((LPNMHDR)lParam)->code) { + case NM_CLICK: + { + TVHITTESTINFO ht = {0}; + DWORD dwpos = GetMessagePos(); + POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos)); + MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1); + TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht); + if (TVHT_ONITEMSTATEICON & ht.flags) { + PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, (LPARAM)ht.hItem); + return FALSE; + } + } + break; + case TVN_KEYDOWN: + if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE) + PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, + (LPARAM)TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom)); + break; + case TVN_SELCHANGEDA: + case TVN_SELCHANGEDW: + { + ProtocolSettings *proto = (ProtocolSettings *)GetItemParam(GetDlgItem(hwndDlg, IDC_PROTOLIST), (HTREEITEM) NULL); + SaveSRMMProtoSettings(hwndDlg, srmmCurrentProtoItem); + UpdateSRMMProtoInfo(hwndDlg, proto); } break; } - switch (((LPNMHDR) lParam)->code) { - case PSN_APPLY: - SaveSRMMProtoSettings(hwndDlg, srmmCurrentProtoItem); - ApplyChanges(2); - return TRUE; - } + break; + } + switch (((LPNMHDR) lParam)->code) { + case PSN_APPLY: + SaveSRMMProtoSettings(hwndDlg, srmmCurrentProtoItem); + ApplyChanges(2); + return TRUE; } - break; - case WM_DESTROY: break; } return FALSE; @@ -706,78 +703,76 @@ static INT_PTR CALLBACK IEViewHistoryOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w char path[MAX_PATH], filter[MAX_PATH]; switch (msg) { case WM_INITDIALOG: - { - MarkInitialized(4); - TranslateDialogDefault(hwndDlg); - historyCurrentProtoItem = NULL; - RefreshProtoList(hwndDlg, 2, true); - return TRUE; - } + MarkInitialized(4); + TranslateDialogDefault(hwndDlg); + historyCurrentProtoItem = NULL; + RefreshProtoList(hwndDlg, 2, true); + return TRUE; + case WM_COMMAND: - { - switch (LOWORD(wParam)) { - case IDC_BACKGROUND_IMAGE_FILENAME: - case IDC_EXTERNALCSS_FILENAME: - case IDC_EXTERNALCSS_FILENAME_RTL: - case IDC_TEMPLATES_FILENAME: - if ((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) - MarkChanges(4, hwndDlg); - break; - case IDC_SCROLL_BACKGROUND_IMAGE: - case IDC_LOG_SHOW_NICKNAMES: - case IDC_LOG_SHOW_TIME: - case IDC_LOG_SHOW_DATE: - case IDC_LOG_SHOW_SECONDS: - case IDC_LOG_LONG_DATE: - case IDC_LOG_RELATIVE_DATE: - case IDC_LOG_GROUP_MESSAGES: + switch (LOWORD(wParam)) { + case IDC_BACKGROUND_IMAGE_FILENAME: + case IDC_EXTERNALCSS_FILENAME: + case IDC_EXTERNALCSS_FILENAME_RTL: + case IDC_TEMPLATES_FILENAME: + if ((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) MarkChanges(4, hwndDlg); - break; - case IDC_BACKGROUND_IMAGE: - bChecked = IsDlgButtonChecked(hwndDlg, IDC_MODE_COMPATIBLE) && IsDlgButtonChecked(hwndDlg, IDC_BACKGROUND_IMAGE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BACKGROUND_IMAGE_FILENAME), bChecked); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE_BACKGROUND_IMAGE), bChecked); - EnableWindow(GetDlgItem(hwndDlg, IDC_SCROLL_BACKGROUND_IMAGE), bChecked); + break; + case IDC_SCROLL_BACKGROUND_IMAGE: + case IDC_LOG_SHOW_NICKNAMES: + case IDC_LOG_SHOW_TIME: + case IDC_LOG_SHOW_DATE: + case IDC_LOG_SHOW_SECONDS: + case IDC_LOG_LONG_DATE: + case IDC_LOG_RELATIVE_DATE: + case IDC_LOG_GROUP_MESSAGES: + MarkChanges(4, hwndDlg); + break; + case IDC_BACKGROUND_IMAGE: + bChecked = IsDlgButtonChecked(hwndDlg, IDC_MODE_COMPATIBLE) && IsDlgButtonChecked(hwndDlg, IDC_BACKGROUND_IMAGE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BACKGROUND_IMAGE_FILENAME), bChecked); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE_BACKGROUND_IMAGE), bChecked); + EnableWindow(GetDlgItem(hwndDlg, IDC_SCROLL_BACKGROUND_IMAGE), bChecked); + MarkChanges(4, hwndDlg); + break; + case IDC_BROWSE_TEMPLATES: + mir_snprintf(filter, SIZEOF(filter), "%s (*.ivt)%c*.ivt%c%s%c*.*%c%c", Translate("Template"), 0, 0, Translate("All Files"), 0, 0, 0); + if (BrowseFile(hwndDlg, filter, "ivt", path, SIZEOF(path))) { + SetDlgItemTextA(hwndDlg, IDC_TEMPLATES_FILENAME, path); + UpdateTemplateIcons(hwndDlg, path); MarkChanges(4, hwndDlg); - break; - case IDC_BROWSE_TEMPLATES: - mir_snprintf(filter, SIZEOF(filter), "%s (*.ivt)%c*.ivt%c%s%c*.*%c%c", Translate("Template"), 0, 0, Translate("All Files"), 0, 0, 0); - if (BrowseFile(hwndDlg, filter, "ivt", path, SIZEOF(path))) { - SetDlgItemTextA(hwndDlg, IDC_TEMPLATES_FILENAME, path); - UpdateTemplateIcons(hwndDlg, path); - MarkChanges(4, hwndDlg); - } - break; - case IDC_BROWSE_BACKGROUND_IMAGE: - mir_snprintf(filter, SIZEOF(filter), "%s (*.jpg,*.gif,*.png,*.bmp)%c*.ivt%c%s%c*.*%c%c", Translate("All Images"), 0, 0, Translate("All Files"), 0, 0, 0); - if (BrowseFile(hwndDlg, filter, "jpg", path, SIZEOF(path))) { - SetDlgItemTextA(hwndDlg,IDC_BACKGROUND_IMAGE_FILENAME,path); - MarkChanges(4, hwndDlg); - } - break; - case IDC_BROWSE_EXTERNALCSS: - mir_snprintf(filter, SIZEOF(filter), "%s (*.css)%c*.ivt%c%s%c*.*%c%c", Translate("Style Sheet"), 0, 0, Translate("All Files"), 0, 0, 0); - if (BrowseFile(hwndDlg, filter, "css", path, SIZEOF(path))) { - SetDlgItemTextA(hwndDlg, IDC_EXTERNALCSS_FILENAME, path); - MarkChanges(4, hwndDlg); - } - break; - case IDC_BROWSE_EXTERNALCSS_RTL: - mir_snprintf(filter, SIZEOF(filter), "%s (*.css)%c*.ivt%c%s%c*.*%c%c", Translate("Style Sheet"), 0, 0, Translate("All Files"), 0, 0, 0); - if (BrowseFile(hwndDlg, filter, "css", path, SIZEOF(path))) { - SetDlgItemTextA(hwndDlg, IDC_EXTERNALCSS_FILENAME_RTL, path); - MarkChanges(4, hwndDlg); - } - break; - case IDC_MODE_COMPATIBLE: - case IDC_MODE_CSS: - case IDC_MODE_TEMPLATE: - UpdateControlsState(hwndDlg); + } + break; + case IDC_BROWSE_BACKGROUND_IMAGE: + mir_snprintf(filter, SIZEOF(filter), "%s (*.jpg,*.gif,*.png,*.bmp)%c*.ivt%c%s%c*.*%c%c", Translate("All Images"), 0, 0, Translate("All Files"), 0, 0, 0); + if (BrowseFile(hwndDlg, filter, "jpg", path, SIZEOF(path))) { + SetDlgItemTextA(hwndDlg,IDC_BACKGROUND_IMAGE_FILENAME,path); MarkChanges(4, hwndDlg); - break; } + break; + case IDC_BROWSE_EXTERNALCSS: + mir_snprintf(filter, SIZEOF(filter), "%s (*.css)%c*.ivt%c%s%c*.*%c%c", Translate("Style Sheet"), 0, 0, Translate("All Files"), 0, 0, 0); + if (BrowseFile(hwndDlg, filter, "css", path, SIZEOF(path))) { + SetDlgItemTextA(hwndDlg, IDC_EXTERNALCSS_FILENAME, path); + MarkChanges(4, hwndDlg); + } + break; + case IDC_BROWSE_EXTERNALCSS_RTL: + mir_snprintf(filter, SIZEOF(filter), "%s (*.css)%c*.ivt%c%s%c*.*%c%c", Translate("Style Sheet"), 0, 0, Translate("All Files"), 0, 0, 0); + if (BrowseFile(hwndDlg, filter, "css", path, SIZEOF(path))) { + SetDlgItemTextA(hwndDlg, IDC_EXTERNALCSS_FILENAME_RTL, path); + MarkChanges(4, hwndDlg); + } + break; + case IDC_MODE_COMPATIBLE: + case IDC_MODE_CSS: + case IDC_MODE_TEMPLATE: + UpdateControlsState(hwndDlg); + MarkChanges(4, hwndDlg); + break; } break; + case UM_CHECKSTATECHANGE: { ProtocolSettings *proto = (ProtocolSettings *)GetItemParam((HWND)wParam, (HTREEITEM) lParam); @@ -793,48 +788,45 @@ static INT_PTR CALLBACK IEViewHistoryOptDlgProc(HWND hwndDlg, UINT msg, WPARAM w MarkChanges(4, hwndDlg); } break; + case WM_NOTIFY: - { - if (((LPNMHDR)lParam)->idFrom == IDC_PROTOLIST) { - switch (((LPNMHDR)lParam)->code) { - case NM_CLICK: - { - TVHITTESTINFO ht = {0}; - DWORD dwpos = GetMessagePos(); - POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos)); - MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1); - TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht); - if (TVHT_ONITEMSTATEICON & ht.flags) { - PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, (LPARAM)ht.hItem); - return FALSE; - } + if (((LPNMHDR)lParam)->idFrom == IDC_PROTOLIST) { + switch (((LPNMHDR)lParam)->code) { + case NM_CLICK: + { + TVHITTESTINFO ht = {0}; + DWORD dwpos = GetMessagePos(); + POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos)); + MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1); + TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht); + if (TVHT_ONITEMSTATEICON & ht.flags) { + PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, (LPARAM)ht.hItem); + return FALSE; } - break; - case TVN_KEYDOWN: - if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE) - PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, - (LPARAM)TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom)); - break; - case TVN_SELCHANGEDA: - case TVN_SELCHANGEDW: - { - ProtocolSettings *proto = (ProtocolSettings *)GetItemParam(GetDlgItem(hwndDlg, IDC_PROTOLIST), (HTREEITEM) NULL); - SaveHistoryProtoSettings(hwndDlg, historyCurrentProtoItem); - UpdateHistoryProtoInfo(hwndDlg, proto); - } - break; - } - break; - } - switch (((LPNMHDR) lParam)->code) { - case PSN_APPLY: - SaveHistoryProtoSettings(hwndDlg, historyCurrentProtoItem); - ApplyChanges(4); - return TRUE; + } + break; + case TVN_KEYDOWN: + if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE) + PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, + (LPARAM)TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom)); + break; + case TVN_SELCHANGEDA: + case TVN_SELCHANGEDW: + { + ProtocolSettings *proto = (ProtocolSettings *)GetItemParam(GetDlgItem(hwndDlg, IDC_PROTOLIST), (HTREEITEM) NULL); + SaveHistoryProtoSettings(hwndDlg, historyCurrentProtoItem); + UpdateHistoryProtoInfo(hwndDlg, proto); + } + break; } + break; + } + switch (((LPNMHDR) lParam)->code) { + case PSN_APPLY: + SaveHistoryProtoSettings(hwndDlg, historyCurrentProtoItem); + ApplyChanges(4); + return TRUE; } - break; - case WM_DESTROY: break; } return FALSE; @@ -845,79 +837,76 @@ static INT_PTR CALLBACK IEViewGroupChatsOptDlgProc(HWND hwndDlg, UINT msg, WPARA char path[MAX_PATH], filter[MAX_PATH]; switch (msg) { case WM_INITDIALOG: - { - MarkInitialized(8); - TranslateDialogDefault(hwndDlg); - chatCurrentProtoItem = NULL; - RefreshProtoList(hwndDlg, 1, true); - return TRUE; - } - break; + MarkInitialized(8); + TranslateDialogDefault(hwndDlg); + chatCurrentProtoItem = NULL; + RefreshProtoList(hwndDlg, 1, true); + return TRUE; + case WM_COMMAND: - { - switch (LOWORD(wParam)) { - case IDC_BACKGROUND_IMAGE_FILENAME: - case IDC_EXTERNALCSS_FILENAME: - case IDC_EXTERNALCSS_FILENAME_RTL: - case IDC_TEMPLATES_FILENAME: - if ((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) - MarkChanges(8, hwndDlg); - break; - case IDC_SCROLL_BACKGROUND_IMAGE: - case IDC_LOG_SHOW_NICKNAMES: - case IDC_LOG_SHOW_TIME: - case IDC_LOG_SHOW_DATE: - case IDC_LOG_SHOW_SECONDS: - case IDC_LOG_LONG_DATE: - case IDC_LOG_RELATIVE_DATE: - case IDC_LOG_GROUP_MESSAGES: + switch (LOWORD(wParam)) { + case IDC_BACKGROUND_IMAGE_FILENAME: + case IDC_EXTERNALCSS_FILENAME: + case IDC_EXTERNALCSS_FILENAME_RTL: + case IDC_TEMPLATES_FILENAME: + if ((HWND)lParam==GetFocus() && HIWORD(wParam)==EN_CHANGE) MarkChanges(8, hwndDlg); - break; - case IDC_BACKGROUND_IMAGE: - bChecked = IsDlgButtonChecked(hwndDlg, IDC_MODE_COMPATIBLE) && IsDlgButtonChecked(hwndDlg, IDC_BACKGROUND_IMAGE); - EnableWindow(GetDlgItem(hwndDlg, IDC_BACKGROUND_IMAGE_FILENAME), bChecked); - EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE_BACKGROUND_IMAGE), bChecked); - EnableWindow(GetDlgItem(hwndDlg, IDC_SCROLL_BACKGROUND_IMAGE), bChecked); + break; + case IDC_SCROLL_BACKGROUND_IMAGE: + case IDC_LOG_SHOW_NICKNAMES: + case IDC_LOG_SHOW_TIME: + case IDC_LOG_SHOW_DATE: + case IDC_LOG_SHOW_SECONDS: + case IDC_LOG_LONG_DATE: + case IDC_LOG_RELATIVE_DATE: + case IDC_LOG_GROUP_MESSAGES: + MarkChanges(8, hwndDlg); + break; + case IDC_BACKGROUND_IMAGE: + bChecked = IsDlgButtonChecked(hwndDlg, IDC_MODE_COMPATIBLE) && IsDlgButtonChecked(hwndDlg, IDC_BACKGROUND_IMAGE); + EnableWindow(GetDlgItem(hwndDlg, IDC_BACKGROUND_IMAGE_FILENAME), bChecked); + EnableWindow(GetDlgItem(hwndDlg, IDC_BROWSE_BACKGROUND_IMAGE), bChecked); + EnableWindow(GetDlgItem(hwndDlg, IDC_SCROLL_BACKGROUND_IMAGE), bChecked); + MarkChanges(8, hwndDlg); + break; + case IDC_BROWSE_TEMPLATES: + mir_snprintf(filter, SIZEOF(filter), "%s (*.ivt)%c*.ivt%c%s%c*.*%c%c", Translate("Template"), 0, 0, Translate("All Files"), 0, 0, 0); + if (BrowseFile(hwndDlg, filter, "ivt", path, SIZEOF(path))) { + SetDlgItemTextA(hwndDlg, IDC_TEMPLATES_FILENAME, path); + UpdateTemplateIcons(hwndDlg, path); MarkChanges(8, hwndDlg); - break; - case IDC_BROWSE_TEMPLATES: - mir_snprintf(filter, SIZEOF(filter), "%s (*.ivt)%c*.ivt%c%s%c*.*%c%c", Translate("Template"), 0, 0, Translate("All Files"), 0, 0, 0); - if (BrowseFile(hwndDlg, filter, "ivt", path, SIZEOF(path))) { - SetDlgItemTextA(hwndDlg, IDC_TEMPLATES_FILENAME, path); - UpdateTemplateIcons(hwndDlg, path); - MarkChanges(8, hwndDlg); - } - break; - case IDC_BROWSE_BACKGROUND_IMAGE: - mir_snprintf(filter, SIZEOF(filter), "%s (*.jpg,*.gif,*.png,*.bmp)%c*.ivt%c%s%c*.*%c%c", Translate("All Images"), 0, 0, Translate("All Files"), 0, 0, 0); - if (BrowseFile(hwndDlg, filter, "jpg", path, SIZEOF(path))) { - SetDlgItemTextA(hwndDlg,IDC_BACKGROUND_IMAGE_FILENAME,path); - MarkChanges(8, hwndDlg); - } - break; - case IDC_BROWSE_EXTERNALCSS: - mir_snprintf(filter, SIZEOF(filter), "%s (*.css)%c*.ivt%c%s%c*.*%c%c", Translate("Style Sheet"), 0, 0, Translate("All Files"), 0, 0, 0); - if (BrowseFile(hwndDlg, filter, "css", path, SIZEOF(path))) { - SetDlgItemTextA(hwndDlg, IDC_EXTERNALCSS_FILENAME, path); - MarkChanges(8, hwndDlg); - } - break; - case IDC_BROWSE_EXTERNALCSS_RTL: - mir_snprintf(filter, SIZEOF(filter), "%s (*.css)%c*.ivt%c%s%c*.*%c%c", Translate("Style Sheet"), 0, 0, Translate("All Files"), 0, 0, 0); - if (BrowseFile(hwndDlg, filter, "css", path, SIZEOF(path))) { - SetDlgItemTextA(hwndDlg, IDC_EXTERNALCSS_FILENAME_RTL, path); - MarkChanges(8, hwndDlg); - } - break; - case IDC_MODE_COMPATIBLE: - case IDC_MODE_CSS: - case IDC_MODE_TEMPLATE: - UpdateControlsState(hwndDlg); + } + break; + case IDC_BROWSE_BACKGROUND_IMAGE: + mir_snprintf(filter, SIZEOF(filter), "%s (*.jpg,*.gif,*.png,*.bmp)%c*.ivt%c%s%c*.*%c%c", Translate("All Images"), 0, 0, Translate("All Files"), 0, 0, 0); + if (BrowseFile(hwndDlg, filter, "jpg", path, SIZEOF(path))) { + SetDlgItemTextA(hwndDlg,IDC_BACKGROUND_IMAGE_FILENAME,path); + MarkChanges(8, hwndDlg); + } + break; + case IDC_BROWSE_EXTERNALCSS: + mir_snprintf(filter, SIZEOF(filter), "%s (*.css)%c*.ivt%c%s%c*.*%c%c", Translate("Style Sheet"), 0, 0, Translate("All Files"), 0, 0, 0); + if (BrowseFile(hwndDlg, filter, "css", path, SIZEOF(path))) { + SetDlgItemTextA(hwndDlg, IDC_EXTERNALCSS_FILENAME, path); MarkChanges(8, hwndDlg); - break; } + break; + case IDC_BROWSE_EXTERNALCSS_RTL: + mir_snprintf(filter, SIZEOF(filter), "%s (*.css)%c*.ivt%c%s%c*.*%c%c", Translate("Style Sheet"), 0, 0, Translate("All Files"), 0, 0, 0); + if (BrowseFile(hwndDlg, filter, "css", path, SIZEOF(path))) { + SetDlgItemTextA(hwndDlg, IDC_EXTERNALCSS_FILENAME_RTL, path); + MarkChanges(8, hwndDlg); + } + break; + case IDC_MODE_COMPATIBLE: + case IDC_MODE_CSS: + case IDC_MODE_TEMPLATE: + UpdateControlsState(hwndDlg); + MarkChanges(8, hwndDlg); + break; } break; + case UM_CHECKSTATECHANGE: { ProtocolSettings *proto = (ProtocolSettings *)GetItemParam((HWND)wParam, (HTREEITEM) lParam); @@ -934,47 +923,43 @@ static INT_PTR CALLBACK IEViewGroupChatsOptDlgProc(HWND hwndDlg, UINT msg, WPARA } break; case WM_NOTIFY: - { - if (((LPNMHDR)lParam)->idFrom == IDC_PROTOLIST) { - switch (((LPNMHDR)lParam)->code) { - case NM_CLICK: - { - TVHITTESTINFO ht = {0}; - DWORD dwpos = GetMessagePos(); - POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos)); - MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1); - TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht); - if (TVHT_ONITEMSTATEICON & ht.flags) { - PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, (LPARAM)ht.hItem); - return FALSE; - } - } - break; - case TVN_KEYDOWN: - if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE) - PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, - (LPARAM)TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom)); - break; - case TVN_SELCHANGEDA: - case TVN_SELCHANGEDW: - { - ProtocolSettings *proto = (ProtocolSettings *)GetItemParam(GetDlgItem(hwndDlg, IDC_PROTOLIST), (HTREEITEM) NULL); - SaveChatProtoSettings(hwndDlg, chatCurrentProtoItem); - UpdateChatProtoInfo(hwndDlg, proto); + if (((LPNMHDR)lParam)->idFrom == IDC_PROTOLIST) { + switch (((LPNMHDR)lParam)->code) { + case NM_CLICK: + { + TVHITTESTINFO ht = {0}; + DWORD dwpos = GetMessagePos(); + POINTSTOPOINT(ht.pt, MAKEPOINTS(dwpos)); + MapWindowPoints(HWND_DESKTOP, ((LPNMHDR)lParam)->hwndFrom, &ht.pt, 1); + TreeView_HitTest(((LPNMHDR)lParam)->hwndFrom, &ht); + if (TVHT_ONITEMSTATEICON & ht.flags) { + PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, (LPARAM)ht.hItem); + return FALSE; } - break; - } - break; - } - switch (((LPNMHDR) lParam)->code) { - case PSN_APPLY: - SaveChatProtoSettings(hwndDlg, chatCurrentProtoItem); - ApplyChanges(8); - return TRUE; + } + break; + case TVN_KEYDOWN: + if (((LPNMTVKEYDOWN) lParam)->wVKey == VK_SPACE) + PostMessage(hwndDlg, UM_CHECKSTATECHANGE, (WPARAM)((LPNMHDR)lParam)->hwndFrom, + (LPARAM)TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom)); + break; + case TVN_SELCHANGEDA: + case TVN_SELCHANGEDW: + { + ProtocolSettings *proto = (ProtocolSettings *)GetItemParam(GetDlgItem(hwndDlg, IDC_PROTOLIST), (HTREEITEM) NULL); + SaveChatProtoSettings(hwndDlg, chatCurrentProtoItem); + UpdateChatProtoInfo(hwndDlg, proto); + } + break; } + break; + } + switch (((LPNMHDR) lParam)->code) { + case PSN_APPLY: + SaveChatProtoSettings(hwndDlg, chatCurrentProtoItem); + ApplyChanges(8); + return TRUE; } - break; - case WM_DESTROY: break; } return FALSE; @@ -982,13 +967,14 @@ static INT_PTR CALLBACK IEViewGroupChatsOptDlgProc(HWND hwndDlg, UINT msg, WPARA bool Options::isInited = false; bool Options::bMathModule = false; -bool Options::bSmileyAdd = false; +bool Options::bSmileyAdd = false; int Options::avatarServiceFlags = 0; -int Options::generalFlags; +int Options::generalFlags; ProtocolSettings *Options::protocolList = NULL; -ProtocolSettings::ProtocolSettings(const char *protocolName) { +ProtocolSettings::ProtocolSettings(const char *protocolName) +{ this->protocolName = mir_strdup(protocolName); next = NULL; srmmEnable = false; @@ -1026,67 +1012,32 @@ ProtocolSettings::ProtocolSettings(const char *protocolName) { } -ProtocolSettings::~ProtocolSettings() { +ProtocolSettings::~ProtocolSettings() +{ mir_free(protocolName); - if (srmmBackgroundFilename != NULL) { - mir_free(srmmBackgroundFilename); - } - if (srmmBackgroundFilenameTemp != NULL) { - mir_free(srmmBackgroundFilenameTemp); - } - if (srmmCssFilename != NULL) { - mir_free(srmmCssFilename); - } - if (srmmCssFilenameTemp != NULL) { - mir_free(srmmCssFilenameTemp); - } - if (srmmTemplateFilename != NULL) { - mir_free(srmmTemplateFilename); - } - if (srmmTemplateFilenameTemp != NULL) { - mir_free(srmmTemplateFilenameTemp); - } - - if (chatBackgroundFilename != NULL) { - mir_free(chatBackgroundFilename); - } - if (chatBackgroundFilenameTemp != NULL) { - mir_free(chatBackgroundFilenameTemp); - } - if (chatCssFilename != NULL) { - mir_free(chatCssFilename); - } - if (chatCssFilenameTemp != NULL) { - mir_free(chatCssFilenameTemp); - } - if (chatTemplateFilename != NULL) { - mir_free(chatTemplateFilename); - } - if (chatTemplateFilenameTemp != NULL) { - mir_free(chatTemplateFilenameTemp); - } - - if (historyBackgroundFilename != NULL) { - mir_free(historyBackgroundFilename); - } - if (historyBackgroundFilenameTemp != NULL) { - mir_free(historyBackgroundFilenameTemp); - } - if (historyCssFilename != NULL) { - mir_free(historyCssFilename); - } - if (historyCssFilenameTemp != NULL) { - mir_free(historyCssFilenameTemp); - } - if (historyTemplateFilename != NULL) { - mir_free(historyTemplateFilename); - } - if (historyTemplateFilenameTemp != NULL) { - mir_free(historyTemplateFilenameTemp); - } -} - -void ProtocolSettings::copyToTemp() { + mir_free(srmmBackgroundFilename); + mir_free(srmmBackgroundFilenameTemp); + mir_free(srmmCssFilename); + mir_free(srmmCssFilenameTemp); + mir_free(srmmTemplateFilename); + mir_free(srmmTemplateFilenameTemp); + mir_free(chatBackgroundFilename); + mir_free(chatBackgroundFilenameTemp); + mir_free(chatCssFilename); + mir_free(chatCssFilenameTemp); + mir_free(chatTemplateFilename); + mir_free(chatTemplateFilenameTemp); + + mir_free(historyBackgroundFilename); + mir_free(historyBackgroundFilenameTemp); + mir_free(historyCssFilename); + mir_free(historyCssFilenameTemp); + mir_free(historyTemplateFilename); + mir_free(historyTemplateFilenameTemp); +} + +void ProtocolSettings::copyToTemp() +{ setSRMMModeTemp(getSRMMMode()); setSRMMFlagsTemp(getSRMMFlags()); setSRMMBackgroundFilenameTemp(getSRMMBackgroundFilename()); @@ -1109,7 +1060,8 @@ void ProtocolSettings::copyToTemp() { setHistoryEnableTemp(isHistoryEnable()); } -void ProtocolSettings::copyFromTemp() { +void ProtocolSettings::copyFromTemp() +{ setSRMMMode(getSRMMModeTemp()); setSRMMFlags(getSRMMFlagsTemp()); setSRMMBackgroundFilename(getSRMMBackgroundFilenameTemp()); @@ -1132,368 +1084,390 @@ void ProtocolSettings::copyFromTemp() { setHistoryEnable(isHistoryEnableTemp()); } -void ProtocolSettings::setNext(ProtocolSettings *next) { +void ProtocolSettings::setNext(ProtocolSettings *next) +{ this->next = next; } -const char *ProtocolSettings::getProtocolName() { +const char *ProtocolSettings::getProtocolName() +{ return protocolName; } -ProtocolSettings * ProtocolSettings::getNext() { +ProtocolSettings * ProtocolSettings::getNext() +{ return next; } -void ProtocolSettings::setSRMMBackgroundFilename(const char *filename) { - if (srmmBackgroundFilename != NULL) { - mir_free(srmmBackgroundFilename); - } - srmmBackgroundFilename = mir_strdup(filename); +void ProtocolSettings::setSRMMBackgroundFilename(const char *filename) +{ + replaceStr(srmmBackgroundFilename, filename); } -void ProtocolSettings::setSRMMBackgroundFilenameTemp(const char *filename) { - if (srmmBackgroundFilenameTemp != NULL) { - mir_free(srmmBackgroundFilenameTemp); - } - srmmBackgroundFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setSRMMBackgroundFilenameTemp(const char *filename) +{ + replaceStr(srmmBackgroundFilenameTemp, filename); } -void ProtocolSettings::setSRMMCssFilename(const char *filename) { - if (srmmCssFilename != NULL) { - mir_free(srmmCssFilename); - } - srmmCssFilename = mir_strdup(filename); +void ProtocolSettings::setSRMMCssFilename(const char *filename) +{ + replaceStr(srmmCssFilename, filename); } -void ProtocolSettings::setSRMMCssFilenameTemp(const char *filename) { - if (srmmCssFilenameTemp != NULL) { - mir_free(srmmCssFilenameTemp); - } - srmmCssFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setSRMMCssFilenameTemp(const char *filename) +{ + replaceStr(srmmCssFilenameTemp, filename); } -void ProtocolSettings::setSRMMTemplateFilename(const char *filename) { - if (srmmTemplateFilename != NULL) { - mir_free(srmmTemplateFilename); - } - srmmTemplateFilename = mir_strdup(filename); +void ProtocolSettings::setSRMMTemplateFilename(const char *filename) +{ + replaceStr(srmmTemplateFilename, filename); TemplateMap::loadTemplates(getSRMMTemplateFilename(), getSRMMTemplateFilename(), false); } -void ProtocolSettings::setSRMMTemplateFilenameTemp(const char *filename) { - if (srmmTemplateFilenameTemp != NULL) { - mir_free(srmmTemplateFilenameTemp); - } - srmmTemplateFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setSRMMTemplateFilenameTemp(const char *filename) +{ + replaceStr(srmmTemplateFilenameTemp, filename); } -const char *ProtocolSettings::getSRMMBackgroundFilename() { +const char *ProtocolSettings::getSRMMBackgroundFilename() +{ return srmmBackgroundFilename; } -const char *ProtocolSettings::getSRMMBackgroundFilenameTemp() { +const char *ProtocolSettings::getSRMMBackgroundFilenameTemp() +{ return srmmBackgroundFilenameTemp; } -const char *ProtocolSettings::getSRMMCssFilename() { +const char *ProtocolSettings::getSRMMCssFilename() +{ return srmmCssFilename; } -const char *ProtocolSettings::getSRMMCssFilenameTemp() { +const char *ProtocolSettings::getSRMMCssFilenameTemp() +{ return srmmCssFilenameTemp; } -const char *ProtocolSettings::getSRMMTemplateFilename() { +const char *ProtocolSettings::getSRMMTemplateFilename() +{ return srmmTemplateFilename; } -const char *ProtocolSettings::getSRMMTemplateFilenameTemp() { +const char *ProtocolSettings::getSRMMTemplateFilenameTemp() +{ return srmmTemplateFilenameTemp; } -void ProtocolSettings::setSRMMEnable(bool enable) { +void ProtocolSettings::setSRMMEnable(bool enable) +{ this->srmmEnable = enable; } -bool ProtocolSettings::isSRMMEnable() { +bool ProtocolSettings::isSRMMEnable() +{ return srmmEnable; } -void ProtocolSettings::setSRMMEnableTemp(bool enable) { +void ProtocolSettings::setSRMMEnableTemp(bool enable) +{ this->srmmEnableTemp = enable; } -bool ProtocolSettings::isSRMMEnableTemp() { +bool ProtocolSettings::isSRMMEnableTemp() +{ return srmmEnableTemp; } -void ProtocolSettings::setSRMMMode(int mode) { +void ProtocolSettings::setSRMMMode(int mode) +{ this->srmmMode = mode; } -int ProtocolSettings::getSRMMMode() { +int ProtocolSettings::getSRMMMode() +{ return srmmMode; } -void ProtocolSettings::setSRMMModeTemp(int mode) { +void ProtocolSettings::setSRMMModeTemp(int mode) +{ this->srmmModeTemp = mode; } -int ProtocolSettings::getSRMMModeTemp() { +int ProtocolSettings::getSRMMModeTemp() +{ return srmmModeTemp; } -void ProtocolSettings::setSRMMFlags(int flags) { +void ProtocolSettings::setSRMMFlags(int flags) +{ this->srmmFlags = flags; } -int ProtocolSettings::getSRMMFlags() { +int ProtocolSettings::getSRMMFlags() +{ return srmmFlags; } -void ProtocolSettings::setSRMMFlagsTemp(int flags) { +void ProtocolSettings::setSRMMFlagsTemp(int flags) +{ this->srmmFlagsTemp = flags; } -int ProtocolSettings::getSRMMFlagsTemp() { +int ProtocolSettings::getSRMMFlagsTemp() +{ return srmmFlagsTemp; } /* */ -void ProtocolSettings::setChatBackgroundFilename(const char *filename) { - if (chatBackgroundFilename != NULL) { - mir_free(chatBackgroundFilename); - } - chatBackgroundFilename = mir_strdup(filename); +void ProtocolSettings::setChatBackgroundFilename(const char *filename) +{ + replaceStr(chatBackgroundFilename, filename); } -void ProtocolSettings::setChatBackgroundFilenameTemp(const char *filename) { - if (chatBackgroundFilenameTemp != NULL) { - mir_free(chatBackgroundFilenameTemp); - } - chatBackgroundFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setChatBackgroundFilenameTemp(const char *filename) +{ + replaceStr(chatBackgroundFilenameTemp, filename); } -void ProtocolSettings::setChatCssFilename(const char *filename) { - if (chatCssFilename != NULL) { - mir_free(chatCssFilename); - } - chatCssFilename = mir_strdup(filename); +void ProtocolSettings::setChatCssFilename(const char *filename) +{ + replaceStr(chatCssFilename, filename); } -void ProtocolSettings::setChatCssFilenameTemp(const char *filename) { - if (chatCssFilenameTemp != NULL) { - mir_free(chatCssFilenameTemp); - } - chatCssFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setChatCssFilenameTemp(const char *filename) +{ + replaceStr(chatCssFilenameTemp, filename); } -void ProtocolSettings::setChatTemplateFilename(const char *filename) { - if (chatTemplateFilename != NULL) { - mir_free(chatTemplateFilename); - } - chatTemplateFilename = mir_strdup(filename); +void ProtocolSettings::setChatTemplateFilename(const char *filename) +{ + replaceStr(chatTemplateFilename, filename); TemplateMap::loadTemplates(getChatTemplateFilename(), getChatTemplateFilename(), false); } -void ProtocolSettings::setChatTemplateFilenameTemp(const char *filename) { - if (chatTemplateFilenameTemp != NULL) { - mir_free(chatTemplateFilenameTemp); - } - chatTemplateFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setChatTemplateFilenameTemp(const char *filename) +{ + replaceStr(chatTemplateFilenameTemp, filename); } -const char *ProtocolSettings::getChatBackgroundFilename() { +const char *ProtocolSettings::getChatBackgroundFilename() +{ return chatBackgroundFilename; } -const char *ProtocolSettings::getChatBackgroundFilenameTemp() { +const char *ProtocolSettings::getChatBackgroundFilenameTemp() +{ return chatBackgroundFilenameTemp; } -const char *ProtocolSettings::getChatCssFilename() { +const char *ProtocolSettings::getChatCssFilename() +{ return chatCssFilename; } -const char *ProtocolSettings::getChatCssFilenameTemp() { +const char *ProtocolSettings::getChatCssFilenameTemp() +{ return chatCssFilenameTemp; } -const char *ProtocolSettings::getChatTemplateFilename() { +const char *ProtocolSettings::getChatTemplateFilename() +{ return chatTemplateFilename; } -const char *ProtocolSettings::getChatTemplateFilenameTemp() { +const char *ProtocolSettings::getChatTemplateFilenameTemp() +{ return chatTemplateFilenameTemp; } -void ProtocolSettings::setChatEnable(bool enable) { +void ProtocolSettings::setChatEnable(bool enable) +{ this->chatEnable = enable; } -bool ProtocolSettings::isChatEnable() { +bool ProtocolSettings::isChatEnable() +{ return chatEnable; } -void ProtocolSettings::setChatEnableTemp(bool enable) { +void ProtocolSettings::setChatEnableTemp(bool enable) +{ this->chatEnableTemp = enable; } -bool ProtocolSettings::isChatEnableTemp() { +bool ProtocolSettings::isChatEnableTemp() +{ return chatEnableTemp; } -void ProtocolSettings::setChatMode(int mode) { +void ProtocolSettings::setChatMode(int mode) +{ this->chatMode = mode; } -int ProtocolSettings::getChatMode() { +int ProtocolSettings::getChatMode() +{ return chatMode; } -void ProtocolSettings::setChatModeTemp(int mode) { +void ProtocolSettings::setChatModeTemp(int mode) +{ this->chatModeTemp = mode; } -int ProtocolSettings::getChatModeTemp() { +int ProtocolSettings::getChatModeTemp() +{ return chatModeTemp; } -void ProtocolSettings::setChatFlags(int flags) { +void ProtocolSettings::setChatFlags(int flags) +{ this->chatFlags = flags; } -int ProtocolSettings::getChatFlags() { +int ProtocolSettings::getChatFlags() +{ return chatFlags; } -void ProtocolSettings::setChatFlagsTemp(int flags) { +void ProtocolSettings::setChatFlagsTemp(int flags) +{ this->chatFlagsTemp = flags; } -int ProtocolSettings::getChatFlagsTemp() { +int ProtocolSettings::getChatFlagsTemp() +{ return chatFlagsTemp; } /* */ -void ProtocolSettings::setHistoryBackgroundFilename(const char *filename) { - if (historyBackgroundFilename != NULL) { - mir_free(historyBackgroundFilename); - } - historyBackgroundFilename = mir_strdup(filename); +void ProtocolSettings::setHistoryBackgroundFilename(const char *filename) +{ + replaceStr(historyBackgroundFilename, filename); } -void ProtocolSettings::setHistoryBackgroundFilenameTemp(const char *filename) { - if (historyBackgroundFilenameTemp != NULL) { - mir_free(historyBackgroundFilenameTemp); - } - historyBackgroundFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setHistoryBackgroundFilenameTemp(const char *filename) +{ + replaceStr(historyBackgroundFilenameTemp, filename); } -void ProtocolSettings::setHistoryCssFilename(const char *filename) { - if (historyCssFilename != NULL) { - mir_free(historyCssFilename); - } - historyCssFilename = mir_strdup(filename); +void ProtocolSettings::setHistoryCssFilename(const char *filename) +{ + replaceStr(historyCssFilename, filename); } -void ProtocolSettings::setHistoryCssFilenameTemp(const char *filename) { - if (historyCssFilenameTemp != NULL) { - mir_free(historyCssFilenameTemp); - } - historyCssFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setHistoryCssFilenameTemp(const char *filename) +{ + replaceStr(historyCssFilenameTemp, filename); } -void ProtocolSettings::setHistoryTemplateFilename(const char *filename) { - if (historyTemplateFilename != NULL) { - mir_free(historyTemplateFilename); - } - historyTemplateFilename = mir_strdup(filename); +void ProtocolSettings::setHistoryTemplateFilename(const char *filename) +{ + replaceStr(historyTemplateFilename, filename); TemplateMap::loadTemplates(getHistoryTemplateFilename(), getHistoryTemplateFilename(), false); } -void ProtocolSettings::setHistoryTemplateFilenameTemp(const char *filename) { - if (historyTemplateFilenameTemp != NULL) { - mir_free(historyTemplateFilenameTemp); - } - historyTemplateFilenameTemp = mir_strdup(filename); +void ProtocolSettings::setHistoryTemplateFilenameTemp(const char *filename) +{ + replaceStr(historyTemplateFilenameTemp, filename); } -const char *ProtocolSettings::getHistoryBackgroundFilename() { +const char *ProtocolSettings::getHistoryBackgroundFilename() +{ return historyBackgroundFilename; } -const char *ProtocolSettings::getHistoryBackgroundFilenameTemp() { +const char *ProtocolSettings::getHistoryBackgroundFilenameTemp() +{ return historyBackgroundFilenameTemp; } -const char *ProtocolSettings::getHistoryCssFilename() { +const char *ProtocolSettings::getHistoryCssFilename() +{ return historyCssFilename; } -const char *ProtocolSettings::getHistoryCssFilenameTemp() { +const char *ProtocolSettings::getHistoryCssFilenameTemp() +{ return historyCssFilenameTemp; } -const char *ProtocolSettings::getHistoryTemplateFilename() { +const char *ProtocolSettings::getHistoryTemplateFilename() +{ return historyTemplateFilename; } -const char *ProtocolSettings::getHistoryTemplateFilenameTemp() { +const char *ProtocolSettings::getHistoryTemplateFilenameTemp() +{ return historyTemplateFilenameTemp; } -void ProtocolSettings::setHistoryEnable(bool enable) { +void ProtocolSettings::setHistoryEnable(bool enable) +{ this->historyEnable = enable; } -bool ProtocolSettings::isHistoryEnable() { +bool ProtocolSettings::isHistoryEnable() +{ return historyEnable; } -void ProtocolSettings::setHistoryEnableTemp(bool enable) { +void ProtocolSettings::setHistoryEnableTemp(bool enable) +{ this->historyEnableTemp = enable; } -bool ProtocolSettings::isHistoryEnableTemp() { +bool ProtocolSettings::isHistoryEnableTemp() +{ return historyEnableTemp; } -void ProtocolSettings::setHistoryMode(int mode) { +void ProtocolSettings::setHistoryMode(int mode) +{ this->historyMode = mode; } -int ProtocolSettings::getHistoryMode() { +int ProtocolSettings::getHistoryMode() +{ return historyMode; } -void ProtocolSettings::setHistoryModeTemp(int mode) { +void ProtocolSettings::setHistoryModeTemp(int mode) +{ this->historyModeTemp = mode; } -int ProtocolSettings::getHistoryModeTemp() { +int ProtocolSettings::getHistoryModeTemp() +{ return historyModeTemp; } -void ProtocolSettings::setHistoryFlags(int flags) { +void ProtocolSettings::setHistoryFlags(int flags) +{ this->historyFlags = flags; } -int ProtocolSettings::getHistoryFlags() { +int ProtocolSettings::getHistoryFlags() +{ return historyFlags; } -void ProtocolSettings::setHistoryFlagsTemp(int flags) { +void ProtocolSettings::setHistoryFlagsTemp(int flags) +{ this->historyFlagsTemp = flags; } -int ProtocolSettings::getHistoryFlagsTemp() { +int ProtocolSettings::getHistoryFlagsTemp() +{ return historyFlagsTemp; } -void Options::init() { +void Options::init() +{ if (isInited) return; isInited = true; DBVARIANT dbv; @@ -1638,80 +1612,83 @@ void Options::init() { bMathModule = (bool) ServiceExists(MTH_GET_GIF_UNICODE); bSmileyAdd = (bool) ServiceExists(MS_SMILEYADD_BATCHPARSE); avatarServiceFlags = 0; - if (ServiceExists(MS_AV_GETAVATARBITMAP)) { + if (ServiceExists(MS_AV_GETAVATARBITMAP)) avatarServiceFlags = AVATARSERVICE_PRESENT; - } - - -// mathModuleFlags = ServiceExists(MTH_GET_HTML_SOURCE) ? GENERAL_ENABLE_MATHMODULE : 0; } -void Options::uninit() { +void Options::uninit() +{ ProtocolSettings *p, *p1; - for ( p = protocolList; p != NULL; p = p1 ) { + for (p = protocolList; p != NULL; p = p1 ) { p1 = p->getNext(); delete p; } - if (hImageList != NULL) { + if (hImageList != NULL) ImageList_Destroy(hImageList); - } - if (hProtocolImageList != NULL) { + if (hProtocolImageList != NULL) ImageList_Destroy(hProtocolImageList); - } } -void Options::setGeneralFlags(int flags) { +void Options::setGeneralFlags(int flags) +{ generalFlags = flags; db_set_dw(NULL, ieviewModuleName, DBS_BASICFLAGS, (DWORD) flags); } -int Options::getGeneralFlags() { +int Options::getGeneralFlags() +{ return generalFlags; } -void Options::setEmbedsize(int size){ +void Options::setEmbedsize(int size) +{ db_set_dw(NULL, ieviewModuleName, "Embedsize", (DWORD) size); } -int Options::getEmbedsize() { +int Options::getEmbedsize() +{ return db_get_dw(NULL, ieviewModuleName, "Embedsize", 0); } -bool Options::isMathModule() { +bool Options::isMathModule() +{ return bMathModule; } -bool Options::isSmileyAdd() { +bool Options::isSmileyAdd() +{ return bSmileyAdd; } -int Options::getAvatarServiceFlags() { +int Options::getAvatarServiceFlags() +{ return avatarServiceFlags; } -ProtocolSettings * Options::getProtocolSettings() { +ProtocolSettings * Options::getProtocolSettings() +{ return protocolList; } -ProtocolSettings * Options::getProtocolSettings(const char *protocolName) { - for (ProtocolSettings *proto=protocolList;proto!=NULL;proto=proto->getNext()) { - if (!strcmpi(proto->getProtocolName(), protocolName)) { +ProtocolSettings * Options::getProtocolSettings(const char *protocolName) +{ + for (ProtocolSettings *proto = protocolList; proto != NULL; proto = proto->getNext()) + if (!strcmpi(proto->getProtocolName(), protocolName)) return proto; - } - } + return NULL; } -void Options::resetProtocolSettings() { - for (ProtocolSettings *proto=Options::getProtocolSettings();proto!=NULL;proto=proto->getNext()) { +void Options::resetProtocolSettings() +{ + for (ProtocolSettings *proto=Options::getProtocolSettings();proto!=NULL;proto=proto->getNext()) proto->copyToTemp(); - } } -void Options::saveProtocolSettings() { - ProtocolSettings *proto; - int i; - for (i=0,proto=Options::getProtocolSettings();proto!=NULL;proto=proto->getNext(),i++) { +void Options::saveProtocolSettings() +{ + ProtocolSettings *proto = Options::getProtocolSettings(); + for (int i = 0; proto != NULL; proto = proto->getNext(),i++) { char dbsName[256]; char tmpPath[MAX_PATH]; proto->copyFromTemp(); diff --git a/plugins/IEView/src/ScriverHTMLBuilder.cpp b/plugins/IEView/src/ScriverHTMLBuilder.cpp index 6c11c4be51..a3752d753c 100644 --- a/plugins/IEView/src/ScriverHTMLBuilder.cpp +++ b/plugins/IEView/src/ScriverHTMLBuilder.cpp @@ -171,9 +171,7 @@ char *ScriverHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int mod //_tcsncat(szResult, str, 500); strncat(szResult, str, 500); } - char *tmp = mir_utf8encode(szResult); - lstrcpynA(szResult, tmp, 500); - mir_free(tmp); + lstrcpynA(szResult, mir_ptr(mir_utf8encode(szResult)), 500); return szResult; } @@ -302,7 +300,7 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event (((eventData->time < startedTime) == (getLastEventTime() < startedTime)) || !(eventData->dwFlags & IEEDF_READ))) { isGroupBreak = FALSE; } - char *szName = NULL, *szText = NULL; + mir_ptr szName, szText; if (eventData->dwFlags & IEEDF_UNICODE_NICK) szName = encodeUTF8(event->hContact, szRealProto, eventData->pszNickW, ENF_NAMESMILEYS, true); else @@ -371,8 +369,7 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event if (eventData->iType == IEED_EVENT_MESSAGE) { if (showColon) Utils::appendText(&output, &outputSize, " %s", - isSent ? "nameOut" : "nameIn", - szName); + isSent ? "nameOut" : "nameIn", szName); else Utils::appendText(&output, &outputSize, "%s", isSent ? "nameOut" : "nameIn", szName); @@ -421,8 +418,6 @@ void ScriverHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event Utils::appendText(&output, &outputSize, "
\n"); setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType)); setLastEventTime(eventData->time); - if (szName!=NULL) delete szName; - if (szText!=NULL) delete szText; } if (output != NULL) { view->write(output); diff --git a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp index 23a2706b57..c589a520ca 100644 --- a/plugins/IEView/src/TabSRMMHTMLBuilder.cpp +++ b/plugins/IEView/src/TabSRMMHTMLBuilder.cpp @@ -197,15 +197,12 @@ char *TabSRMMHTMLBuilder::timestampToString(DWORD dwFlags, time_t check, int isG } CallService(MS_DB_TIME_TIMESTAMPTOSTRING, check, (LPARAM) & dbtts); strncat(szResult, str, 500); - char *tmp = mir_utf8encode(szResult); - lstrcpynA(szResult, tmp, 500); - mir_free(tmp); + lstrcpynA(szResult, mir_ptr(mir_utf8encode(szResult)), 500); return szResult; } - - -void TabSRMMHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) { +void TabSRMMHTMLBuilder::buildHead(IEView *view, IEVIEWEVENT *event) +{ LOGFONTA lf; COLORREF color; char *output = NULL; @@ -316,37 +313,37 @@ void TabSRMMHTMLBuilder::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++) { int outputSize; - char *output; - output = NULL; + char *output = NULL; if (eventData->iType == IEED_EVENT_MESSAGE || eventData->iType == IEED_EVENT_FILE || eventData->iType == IEED_EVENT_URL || eventData->iType == IEED_EVENT_STATUSCHANGE) { int isGroupBreak = TRUE; int isSent = (eventData->dwFlags & IEEDF_SENT); int isRTL = eventData->dwFlags & IEEDF_RTL; int isHistory = (eventData->time < (DWORD)getStartedTime() && (eventData->dwFlags & IEEDF_READ || eventData->dwFlags & IEEDF_SENT)); - if (dwFlags & MWF_LOG_GROUPMODE && eventData->dwFlags == LOWORD(getLastEventType()) - && eventData->iType == IEED_EVENT_MESSAGE && HIWORD(getLastEventType()) == IEED_EVENT_MESSAGE - && ((eventData->time < today) == (getLastEventTime() < today)) - && (((eventData->time < (DWORD)startedTime) == (getLastEventTime() < (DWORD)startedTime)) || !(eventData->dwFlags & IEEDF_READ))) { + if (dwFlags & MWF_LOG_GROUPMODE && eventData->dwFlags == LOWORD(getLastEventType()) && + eventData->iType == IEED_EVENT_MESSAGE && HIWORD(getLastEventType()) == IEED_EVENT_MESSAGE && + ((eventData->time < today) == (getLastEventTime() < today)) && + (((eventData->time < (DWORD)startedTime) == (getLastEventTime() < (DWORD)startedTime)) || !(eventData->dwFlags & IEEDF_READ))) + { isGroupBreak = FALSE; } - char *szName = NULL; - char *szText = NULL; - if (eventData->dwFlags & IEEDF_UNICODE_NICK) { + + mir_ptr szName, szText; + if (eventData->dwFlags & IEEDF_UNICODE_NICK) szName = encodeUTF8(event->hContact, szRealProto, eventData->pszNickW, ENF_NAMESMILEYS, true); - } else { + else szName = encodeUTF8(event->hContact, szRealProto, eventData->pszNick, ENF_NAMESMILEYS, true); - } - if (eventData->dwFlags & IEEDF_UNICODE_TEXT) { + + if (eventData->dwFlags & IEEDF_UNICODE_TEXT) szText = encodeUTF8(event->hContact, szRealProto, eventData->pszTextW, eventData->iType == IEED_EVENT_MESSAGE ? ENF_ALL : 0, isSent); - } else { + else szText = encodeUTF8(event->hContact, szRealProto, eventData->pszText, event->codepage, eventData->iType == IEED_EVENT_MESSAGE ? ENF_ALL : 0, isSent); - } + /* TabSRMM-specific formatting */ - if ((dwFlags & MWF_LOG_GRID) && isGroupBreak && getLastEventType()!=-1) { + if ((dwFlags & MWF_LOG_GRID) && isGroupBreak && getLastEventType() != -1) Utils::appendText(&output, &outputSize, "
", isRTL ? isSent ? "divOutGridRTL" : "divInGridRTL" : isSent ? "divOutGrid" : "divInGrid"); - } else { + else Utils::appendText(&output, &outputSize, "
", isRTL ? isSent ? "divOutRTL" : "divInRTL" : isSent ? "divOut" : "divIn"); - } + if (dwFlags & MWF_LOG_SHOWICONS && isGroupBreak) { const char *iconFile = ""; if (eventData->iType == IEED_EVENT_MESSAGE) { @@ -365,64 +362,58 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event const char *className = ""; if (!isHistory) className = isSent ? "nameOut" : "nameIn"; else className = isSent ? "hNameOut" : "hNameIn"; - if (dwFlags & MWF_LOG_UNDERLINE) { + if (dwFlags & MWF_LOG_UNDERLINE) Utils::appendText(&output, &outputSize, "%s%s", className, szName, (dwFlags & MWF_LOG_SHOWTIME) ? " " :": "); - } else { + else Utils::appendText(&output, &outputSize, "%s%s", 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"; - if (dwFlags & MWF_LOG_UNDERLINE) { + if (dwFlags & MWF_LOG_UNDERLINE) Utils::appendText(&output, &outputSize, "%s%s", className, timestampToString(dwFlags, eventData->time, isGroupBreak), (!isGroupBreak || (eventData->iType == IEED_EVENT_STATUSCHANGE) || (dwFlags & MWF_LOG_SWAPNICK) || !(dwFlags & MWF_LOG_SHOWNICK)) ? ": " : " "); - } else { + else Utils::appendText(&output, &outputSize, "%s%s", 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) { + if (eventData->iType == IEED_EVENT_STATUSCHANGE) Utils::appendText(&output, &outputSize, "%s ", szName); - } else { + else { const char *className = ""; if (!isHistory) className = isSent ? "nameOut" : "nameIn"; else className = isSent ? "hNameOut" : "hNameIn"; - if (dwFlags & MWF_LOG_UNDERLINE) { - Utils::appendText(&output, &outputSize, "%s: ", - className, szName); - } else { - Utils::appendText(&output, &outputSize, "%s: ", - className, szName); - } + if (dwFlags & MWF_LOG_UNDERLINE) + Utils::appendText(&output, &outputSize, "%s: ", className, szName); + else + Utils::appendText(&output, &outputSize, "%s: ", className, szName); } } - if (dwFlags & MWF_LOG_NEWLINE && eventData->iType != IEED_EVENT_STATUSCHANGE && eventData->iType != IEED_EVENT_ERRMSG && isGroupBreak) { + if (dwFlags & MWF_LOG_NEWLINE && eventData->iType != IEED_EVENT_STATUSCHANGE && eventData->iType != IEED_EVENT_ERRMSG && isGroupBreak) Utils::appendText(&output, &outputSize, "
"); - } + const char *className = ""; if (eventData->iType == IEED_EVENT_MESSAGE) { if (!isHistory) className = isSent ? "messageOut" : "messageIn"; else className = isSent ? "hMessageOut" : "hMessageIn"; - } else if (eventData->iType == IEED_EVENT_FILE) { + } + else if (eventData->iType == IEED_EVENT_FILE) className = isHistory ? "hMiscIn" : "miscIn"; - } else if (eventData->iType == IEED_EVENT_URL) { + else if (eventData->iType == IEED_EVENT_URL) className = isHistory ? "hMiscIn" : "miscIn"; - } else if (eventData->iType == IEED_EVENT_STATUSCHANGE) { + else if (eventData->iType == IEED_EVENT_STATUSCHANGE) className = "statusChange"; - } + Utils::appendText(&output, &outputSize, "%s", className, szText); Utils::appendText(&output, &outputSize, "
\n"); setLastEventType(MAKELONG(eventData->dwFlags, eventData->iType)); setLastEventTime(eventData->time); - if (szName!=NULL) mir_free(szName); - if (szText!=NULL) mir_free(szText); } if (output != NULL) { view->write(output); @@ -434,14 +425,14 @@ void TabSRMMHTMLBuilder::appendEventNonTemplate(IEView *view, IEVIEWEVENT *event view->documentClose(); } -void TabSRMMHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) { +void TabSRMMHTMLBuilder::appendEvent(IEView *view, IEVIEWEVENT *event) +{ ProtocolSettings *protoSettings = getSRMMProtocolSettings(event->hContact); - if (protoSettings == NULL) { + if (protoSettings == NULL) return; - } - if (protoSettings->getSRMMMode() == Options::MODE_TEMPLATE) { + + if (protoSettings->getSRMMMode() == Options::MODE_TEMPLATE) appendEventTemplate(view, event, protoSettings); - } else { + else appendEventNonTemplate(view, event); - } } diff --git a/plugins/IEView/src/Template.cpp b/plugins/IEView/src/Template.cpp index 5400906ae7..20a3dd2cc9 100644 --- a/plugins/IEView/src/Template.cpp +++ b/plugins/IEView/src/Template.cpp @@ -21,58 +21,65 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "ieview_common.h" -TokenDef::TokenDef(const char *tokenString) { +TokenDef::TokenDef(const char *tokenString) +{ this->tokenString = tokenString; this->tokenLen = (int)strlen(tokenString); this->token = 0; this->escape = 0; } -TokenDef::TokenDef(const char *tokenString, int token, int escape) { +TokenDef::TokenDef(const char *tokenString, int token, int escape) +{ this->tokenString = tokenString; this->token = token; this->tokenLen = (int)strlen(tokenString); this->escape = escape; } -Token::Token(int type, const char *text, int escape) { +Token::Token(int type, const char *text, int escape) +{ next = NULL; this->type = type; this->escape = escape; - if (text!=NULL) { + if (text!=NULL) this->text = mir_strdup(text); - } else { + else this->text = NULL; - } } -Token::~Token() { - if (text!=NULL) { - mir_free(text); - } +Token::~Token() +{ + mir_free(text); } -Token * Token::getNext() { +Token* Token::getNext() +{ return next; } -void Token::setNext(Token *ptr) { +void Token::setNext(Token *ptr) +{ next = ptr; } -int Token::getType() { +int Token::getType() +{ return type; } -int Token::getEscape() { +int Token::getEscape() +{ return escape; } -const char *Token::getText() { +const char* Token::getText() +{ return text; } -Template::Template(const char *name, const char *text) { +Template::Template(const char *name, const char *text) +{ next = NULL; tokens = NULL; this->text = mir_strdup(text); @@ -80,9 +87,10 @@ Template::Template(const char *name, const char *text) { tokenize(); } -Template::~Template() { - if (text != NULL) mir_free(text); - if (name != NULL) mir_free(name); +Template::~Template() +{ + mir_free(text); + mir_free(name); Token *ptr = tokens, *ptr2; tokens = NULL; for (;ptr!=NULL;ptr = ptr2) { @@ -91,22 +99,26 @@ Template::~Template() { } } -const char *Template::getText() { +const char* Template::getText() +{ return text; } -const char *Template::getName() { +const char* Template::getName() +{ return name; } -Template* Template::getNext() { +Template* Template::getNext() +{ return next; } -bool Template::equals(const char *name) { - if (!strcmp(name, this->name)) { +bool Template::equals(const char *name) +{ + if (!strcmp(name, this->name)) return true; - } + return false; } @@ -152,73 +164,77 @@ static TokenDef tokenNames[] = { TokenDef("%\\fileDesc%", Token::FILEDESC, 1) }; -void Template::tokenize() { - if (text!=NULL) { -// debugView->writef("Tokenizing: %s
---
", text); - char *str = mir_strdup(text); - Token *lastToken = NULL; - int lastTokenType = Token::PLAIN; - int lastTokenEscape = 0; - int l = (int)strlen(str); - for (int i=0, lastTokenStart=0; i<=l;) { - Token *newToken; - int newTokenType = 0, newTokenSize = 0, newTokenEscape = 0; - if (str[i]=='\0') { - newTokenType = Token::END; - newTokenSize = 1; - newTokenEscape = 0; - } else { - bool found = false; - for (unsigned int j=0; j<(sizeof(tokenNames)/sizeof(tokenNames[0])); j++) { - if (!strncmp(str+i, tokenNames[j].tokenString, tokenNames[j].tokenLen)) { - newTokenType = tokenNames[j].token; - newTokenSize = tokenNames[j].tokenLen; - newTokenEscape = tokenNames[j].escape; - found = true; - break; - } - } - if (!found) { - newTokenType = Token::PLAIN; - newTokenSize = 1; - newTokenEscape = 0; +void Template::tokenize() +{ + if (text == NULL) + return; + + char *str = mir_strdup(text); + Token *lastToken = NULL; + int lastTokenType = Token::PLAIN; + int lastTokenEscape = 0; + int l = (int)strlen(str); + for (int i=0, lastTokenStart=0; i<=l;) { + Token *newToken; + int newTokenType = 0, newTokenSize = 0, newTokenEscape = 0; + if (str[i]=='\0') { + newTokenType = Token::END; + newTokenSize = 1; + newTokenEscape = 0; + } + else { + bool found = false; + for (unsigned int j=0; j<(sizeof(tokenNames)/sizeof(tokenNames[0])); j++) { + if (!strncmp(str+i, tokenNames[j].tokenString, tokenNames[j].tokenLen)) { + newTokenType = tokenNames[j].token; + newTokenSize = tokenNames[j].tokenLen; + newTokenEscape = tokenNames[j].escape; + found = true; + break; } } - if (newTokenType != Token::PLAIN) { - if (str[i + newTokenSize] == '%') { - //newTokenSize++; - } - str[i] = '\0'; + if (!found) { + newTokenType = Token::PLAIN; + newTokenSize = 1; + newTokenEscape = 0; } - if ((lastTokenType!=newTokenType || lastTokenEscape != newTokenEscape) && i!=lastTokenStart) { - if (lastTokenType == Token::PLAIN) { - newToken = new Token(lastTokenType, str+lastTokenStart, lastTokenEscape); - } else { - newToken = new Token(lastTokenType, NULL, lastTokenEscape); - } - if (lastToken != NULL) { - lastToken->setNext(newToken); - } else { - tokens = newToken; - } - lastToken = newToken; - lastTokenStart = i; + } + if (newTokenType != Token::PLAIN) { + if (str[i + newTokenSize] == '%') { + //newTokenSize++; } - lastTokenEscape = newTokenEscape; - lastTokenType = newTokenType; - i += newTokenSize; + str[i] = '\0'; + } + if ((lastTokenType != newTokenType || lastTokenEscape != newTokenEscape) && i != lastTokenStart) { + if (lastTokenType == Token::PLAIN) + newToken = new Token(lastTokenType, str+lastTokenStart, lastTokenEscape); + else + newToken = new Token(lastTokenType, NULL, lastTokenEscape); + + if (lastToken != NULL) + lastToken->setNext(newToken); + else + tokens = newToken; + + lastToken = newToken; + lastTokenStart = i; } - mir_free(str); + lastTokenEscape = newTokenEscape; + lastTokenType = newTokenType; + i += newTokenSize; } + mir_free(str); } -Token * Template::getTokens() { +Token* Template::getTokens() +{ return tokens; } TemplateMap* TemplateMap::mapList = NULL; -TemplateMap::TemplateMap(const char *name) { +TemplateMap::TemplateMap(const char *name) +{ entries = NULL; next = NULL; filename = NULL; @@ -227,17 +243,16 @@ TemplateMap::TemplateMap(const char *name) { this->rtl = false; } -TemplateMap::~TemplateMap() { - if (name != NULL) { - mir_free(name); - } - if (filename != NULL) { - delete filename; - } +TemplateMap::~TemplateMap() +{ + mir_free(name); + mir_free(filename); + clear(); } -TemplateMap* TemplateMap::add(const char *id, const char *filename) { +TemplateMap* TemplateMap::add(const char *id, const char *filename) +{ TemplateMap *map; for (map=mapList; map!=NULL; map=map->next) { if (!strcmp(map->name, id)) { @@ -253,13 +268,15 @@ TemplateMap* TemplateMap::add(const char *id, const char *filename) { return map; } -void TemplateMap::addTemplate(const char *name, const char *text) { +void TemplateMap::addTemplate(const char *name, const char *text) +{ Template *tmplate = new Template(name, text); tmplate->next = entries; entries = tmplate; } -void TemplateMap::clear() { +void TemplateMap::clear() +{ Template *ptr, *ptr2; ptr = entries; entries = NULL; @@ -321,23 +338,23 @@ static TokenDef templateNames[] = { TokenDef("") }; -TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename, bool onlyInfo) { - FILE* fh; +TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename, bool onlyInfo) +{ char lastTemplate[1024], tmp2[1024]; unsigned int i=0; - TemplateMap *tmap; - if (filename == NULL || strlen(filename) == 0) { + if (filename == NULL || strlen(filename) == 0) return NULL; - } - fh = fopen(filename, "rt"); - if (fh == NULL) { + + FILE *fh = fopen(filename, "rt"); + if (fh == NULL) return NULL; - } - if (!onlyInfo) { + + TemplateMap *tmap; + if (!onlyInfo) tmap = TemplateMap::add(id, filename); - } else { + else tmap = new TemplateMap(id); - } + char store[4096]; bool wasTemplate = false; char *templateText = NULL; @@ -353,23 +370,23 @@ TemplateMap* TemplateMap::loadTemplateFile(const char *id, const char *filename, } } if (bFound) { - if (wasTemplate) { + if (wasTemplate) tmap->addTemplate(lastTemplate, templateText); - } - if (templateText!=NULL) { + + if (templateText != NULL) free (templateText); - } + templateText = NULL; templateTextSize = 0; wasTemplate = true; sscanf(store, "