From a1d6cb7bdc354be0968c6ba5ac4615e14a90eead Mon Sep 17 00:00:00 2001 From: George Hazan Date: Wed, 18 May 2016 17:21:08 +0000 Subject: these tons of code aren't needed anymore... git-svn-id: http://svn.miranda-ng.org/main/trunk@16850 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/IEView/src/HTMLBuilder.cpp | 69 +++++++----------------------- plugins/IEView/src/TemplateHTMLBuilder.cpp | 46 ++++++-------------- 2 files changed, 30 insertions(+), 85 deletions(-) (limited to 'plugins/IEView/src') diff --git a/plugins/IEView/src/HTMLBuilder.cpp b/plugins/IEView/src/HTMLBuilder.cpp index 272b08e891..c80d259648 100644 --- a/plugins/IEView/src/HTMLBuilder.cpp +++ b/plugins/IEView/src/HTMLBuilder.cpp @@ -182,65 +182,28 @@ bool HTMLBuilder::isSameDate(time_t time1, time_t time2) void HTMLBuilder::getUINs(MCONTACT hContact, char *&uinIn, char *&uinOut) { - CONTACTINFO ci = { 0 }; - char buf[128] = { 0 }; - const char *szProto = GetContactProto(hContact); - hContact = getRealContact(hContact); - ci.cbSize = sizeof(ci); - ci.hContact = hContact; - ci.szProto = const_cast(szProto); - ci.dwFlag = CNF_UNIQUEID; + ptrT id(Contact_GetInfo(CNF_UNIQUEID, hContact)); + uinIn = mir_utf8encodeT((id != NULL) ? id : _T("")); - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) { - switch (ci.type) { - case CNFT_ASCIIZ: - strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE); - mir_free(ci.pszVal); - break; - case CNFT_DWORD: - mir_snprintf(buf, "%u", ci.dVal); - break; - } - } - uinIn = mir_utf8encode(buf); - ci.hContact = NULL; - - buf[0] = 0; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) { - switch (ci.type) { - case CNFT_ASCIIZ: - strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE); - mir_free(ci.pszVal); - break; - case CNFT_DWORD: - mir_snprintf(buf, "%u", ci.dVal); - break; - } - } - uinOut = mir_utf8encode(buf); + id = Contact_GetInfo(CNF_UNIQUEID, NULL); + uinOut = mir_utf8encodeT((id != NULL) ? id : _T("")); } -wchar_t *HTMLBuilder::getContactName(MCONTACT hContact, const char *szProto) +wchar_t* HTMLBuilder::getContactName(MCONTACT hContact, const char *szProto) { - CONTACTINFO ci = { 0 }; - ci.cbSize = sizeof(ci); - ci.hContact = hContact; - ci.szProto = (char *)szProto; - ci.dwFlag = CNF_DISPLAY | CNF_UNICODE; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) - if (ci.type == CNFT_ASCIIZ && ci.pszVal) // already mir_tstrdup'ed - return ci.pszVal; - - ci.dwFlag = CNF_UNIQUEID; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) - if (ci.type == CNFT_ASCIIZ && ci.pszVal) // already mir_tstrdup'ed - return ci.pszVal; - - TCHAR *szNameStr = pcli->pfnGetContactDisplayName(hContact, 0); - if (szNameStr != NULL) - return mir_tstrdup(szNameStr); + TCHAR *str = Contact_GetInfo(CNF_DISPLAY, hContact, szProto); + if (str != NULL) + return str; + + str = Contact_GetInfo(CNF_UNIQUEID, hContact, szProto); + if (str != NULL) + return str; + + str = pcli->pfnGetContactDisplayName(hContact, 0); + if (str != NULL) + return mir_tstrdup(str); return mir_tstrdup(TranslateT("(Unknown Contact)")); } diff --git a/plugins/IEView/src/TemplateHTMLBuilder.cpp b/plugins/IEView/src/TemplateHTMLBuilder.cpp index ad7271e9a8..4ace2ae70b 100644 --- a/plugins/IEView/src/TemplateHTMLBuilder.cpp +++ b/plugins/IEView/src/TemplateHTMLBuilder.cpp @@ -178,22 +178,13 @@ void TemplateHTMLBuilder::buildHeadTemplate(IEView *view, IEVIEWEVENT *event, Pr db_free(&dbv); } - CONTACTINFO ci; - memset(&ci, 0, sizeof(ci)); - ci.cbSize = sizeof(ci); - ci.hContact = event->hContact; - ci.szProto = szProto; - ci.dwFlag = CNF_NICK | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) - szNickIn = encodeUTF8(event->hContact, szRealProto, ci.pszVal, ENF_NAMESMILEYS, true); - - memset(&ci, 0, sizeof(ci)); - ci.cbSize = sizeof(ci); - ci.hContact = NULL; - ci.szProto = szProto; - ci.dwFlag = CNF_NICK | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) - szNickOut = encodeUTF8(event->hContact, szRealProto, ci.pszVal, ENF_NAMESMILEYS, true); + ptrT tszNick(Contact_GetInfo(CNF_NICK, event->hContact, szProto)); + if (tszNick != NULL) + szNickIn = encodeUTF8(event->hContact, szRealProto, tszNick, ENF_NAMESMILEYS, true); + + tszNick = Contact_GetInfo(CNF_NICK, NULL, szProto); + if (tszNick != NULL) + szNickOut = encodeUTF8(event->hContact, szRealProto, tszNick, ENF_NAMESMILEYS, true); Template *tmplt = NULL; if (tmpm) { @@ -361,22 +352,13 @@ void TemplateHTMLBuilder::appendEventTemplate(IEView *view, IEVIEWEVENT *event, } } - CONTACTINFO ci; - memset(&ci, 0, sizeof(ci)); - ci.cbSize = sizeof(ci); - ci.hContact = event->hContact; - ci.szProto = szProto; - ci.dwFlag = CNF_NICK | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) - szNickIn = encodeUTF8(event->hContact, szRealProto, ci.pszVal, ENF_NAMESMILEYS, true); - - memset(&ci, 0, sizeof(ci)); - ci.cbSize = sizeof(ci); - ci.hContact = NULL; - ci.szProto = szProto; - ci.dwFlag = CNF_NICK | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) - szNickOut = encodeUTF8(event->hContact, szRealProto, ci.pszVal, ENF_NAMESMILEYS, true); + ptrT tszNick(Contact_GetInfo(CNF_NICK, event->hContact, szProto)); + if (tszNick != NULL) + szNickIn = encodeUTF8(event->hContact, szRealProto, tszNick, ENF_NAMESMILEYS, true); + + tszNick = Contact_GetInfo(CNF_NICK, NULL, szProto); + if (tszNick != NULL) + szNickOut = encodeUTF8(event->hContact, szRealProto, tszNick, ENF_NAMESMILEYS, true); IEVIEWEVENTDATA* eventData = event->eventData; for (int eventIdx = 0; eventData != NULL && (eventIdx < event->count || event->count == -1); eventData = eventData->next, eventIdx++) { -- cgit v1.2.3