diff options
author | George Hazan <george.hazan@gmail.com> | 2016-05-18 17:21:08 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2016-05-18 17:21:08 +0000 |
commit | a1d6cb7bdc354be0968c6ba5ac4615e14a90eead (patch) | |
tree | a1ed17002c33644b3362e6c1e6572f3fa7ef17d7 | |
parent | fef6b799309b5b9d7cbb2845fa27b777477e2a61 (diff) |
these tons of code aren't needed anymore...
git-svn-id: http://svn.miranda-ng.org/main/trunk@16850 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
53 files changed, 384 insertions, 1393 deletions
diff --git a/bin10/lib/mir_app.lib b/bin10/lib/mir_app.lib Binary files differindex 15b7818db2..ebb1d7775a 100644 --- a/bin10/lib/mir_app.lib +++ b/bin10/lib/mir_app.lib diff --git a/bin10/lib/mir_app64.lib b/bin10/lib/mir_app64.lib Binary files differindex 4ea9579bad..cd768db41f 100644 --- a/bin10/lib/mir_app64.lib +++ b/bin10/lib/mir_app64.lib diff --git a/bin12/lib/mir_app.lib b/bin12/lib/mir_app.lib Binary files differindex 15b7818db2..ebb1d7775a 100644 --- a/bin12/lib/mir_app.lib +++ b/bin12/lib/mir_app.lib diff --git a/bin12/lib/mir_app64.lib b/bin12/lib/mir_app64.lib Binary files differindex 4ea9579bad..cd768db41f 100644 --- a/bin12/lib/mir_app64.lib +++ b/bin12/lib/mir_app64.lib diff --git a/bin14/lib/mir_app.lib b/bin14/lib/mir_app.lib Binary files differindex 15b7818db2..ebb1d7775a 100644 --- a/bin14/lib/mir_app.lib +++ b/bin14/lib/mir_app.lib diff --git a/bin14/lib/mir_app64.lib b/bin14/lib/mir_app64.lib Binary files differindex 4ea9579bad..cd768db41f 100644 --- a/bin14/lib/mir_app64.lib +++ b/bin14/lib/mir_app64.lib diff --git a/include/delphi/m_contacts.inc b/include/delphi/m_contacts.inc index 5381d41913..e6636c2e17 100644 --- a/include/delphi/m_contacts.inc +++ b/include/delphi/m_contacts.inc @@ -18,23 +18,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. {$IFNDEF M_CONTACTS}
{$DEFINE M_CONTACTS}
-type
- PCONTACTINFO = ^TCONTACTINFO;
- TCONTACTINFO = record
- cbSize : int;
- dwFlag : byte;
- hContact: TMCONTACT;
- szProto : PAnsiChar;
- _type : byte;
- retval: record // in C this is a nameless union
- case longint of
- 0: (bVal : byte);
- 1: (wVal : word);
- 2: (dVal : dword);
- 3: (szVal : TChar);
- 4: (cchVal: word);
- end;
- end;
const
@@ -90,23 +73,7 @@ const // you can get a function pointer to Miranda's free() via MS_SYSTEM_GET_MMI, see m_system.h
CNF_DISPLAYNC = 17;
-// Add this flag if you want to get the Unicode info
- CNF_UNICODE = $80;
-
-// If MS_CONTACT_GETCONTACTINFO returns 0 (valid), then one of the following
-// types is setting telling you what type of info you received
- CNFT_BYTE = 1;
- CNFT_WORD = 2;
- CNFT_DWORD = 3;
- CNFT_ASCIIZ = 4;
-
- {
- wParam : not used
- lParam : Pointer to an initialised TCONTACTINFO structure
- affects: Get contact information
- returns: Zero on success, non zero on failure.
- notes : If successful, the type is set and the result is put into the associated member of TCONTACTINFO
- }
- MS_CONTACT_GETCONTACTINFO:PAnsiChar = 'Miranda/Contact/GetContactInfo';
+// result must be freed using mir_free
+function Contact_GetInfo(iType:Integer; hContact:TMCONTACT; proto:PAnsiChar=0) : PWideChar; stdcall; external AppDLL;
{$ENDIF}
diff --git a/include/m_contacts.h b/include/m_contacts.h index e485922bd9..388cf11b43 100644 --- a/include/m_contacts.h +++ b/include/m_contacts.h @@ -21,20 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef M_CONTACTS_H__
#define M_CONTACTS_H__ 1
-typedef struct {
- int cbSize;
- BYTE dwFlag;
- MCONTACT hContact;
- char *szProto;
- BYTE type;
- union {
- BYTE bVal;
- WORD wVal;
- DWORD dVal;
- TCHAR *pszVal;
- WORD cchVal;
- };
-} CONTACTINFO;
+#ifndef M_CORE_H__
+#include <m_core.h>
+#endif
// Types of information you can retrieve by setting the dwFlag in CONTACTINFO
#define CNF_FIRSTNAME 1 // returns first name (string)
@@ -77,38 +66,17 @@ typedef struct { // Special types
// Return the custom name using the name order setting
-// IMPORTANT: When using CNF_DISPLAY you MUST free the string returned
-// You must **NOT** do this from your version of free() you have to use Miranda's free()
-// you can get a function pointer to Miranda's free() via MS_SYSTEM_GET_MMI, see m_system.h
#define CNF_DISPLAY 16
// Same as CNF_DISPLAY except the custom handle is not used
-// IMPORTANT: When using CNF_DISPLAYNC you MUST free the string returned
-// You must **NOT** do this from your version of free() you have to use Miranda's free()
-// you can get a function pointer to Miranda's free() via MS_SYSTEM_GET_MMI, see m_system.h
#define CNF_DISPLAYNC 17
-// Add this flag if you want to get the Unicode info
-#define CNF_UNICODE 0x80
-
-#if defined(_UNICODE)
- #define CNF_TCHAR CNF_UNICODE // will use TCHAR* instead of char*
-#else
- #define CNF_TCHAR 0 // will return char*, as usual
-#endif
-
-// If MS_CONTACT_GETCONTACTINFO returns 0 (valid), then one of the following
-// types is setting telling you what type of info you received
-#define CNFT_BYTE 1
-#define CNFT_WORD 2
-#define CNFT_DWORD 3
-#define CNFT_ASCIIZ 4
-
// Get contact information
-// wParam = not used
-// lParam = (CONTACTINFO *)
-// Returns 1 on failure to retrieve the info and 0 on success. If
-// sucessful, the type is set and the result is put into the associated
-// member of CONTACTINFO
-#define MS_CONTACT_GETCONTACTINFO "Miranda/Contact/GetContactInfo"
+// Returns NULL on failure to retrieve the info or a string on success.
+// If successful, this string must be freed using mir_free
+
+EXTERN_C MIR_APP_DLL(TCHAR*) Contact_GetInfo(
+ int type, // one of the CNF_* constants
+ MCONTACT hContact, // contact id or NULL for the global data
+ const char *szProto = NULL); // protocol for global data. if skipped, grabbed from hContact
#endif // M_CONTACTS_H__
diff --git a/plugins/AvatarHistory/src/utils.cpp b/plugins/AvatarHistory/src/utils.cpp index 637458b60d..39b4db8534 100644 --- a/plugins/AvatarHistory/src/utils.cpp +++ b/plugins/AvatarHistory/src/utils.cpp @@ -77,35 +77,6 @@ void ConvertToFilename(TCHAR *str, size_t size) }
}
-int GetUIDFromHContact(MCONTACT contact, TCHAR* uinout, int uinout_len)
-{
- bool found = true;
-
- CONTACTINFO cinfo = { sizeof(cinfo) };
- cinfo.hContact = contact;
- cinfo.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&cinfo) == 0) {
- if (cinfo.type == CNFT_ASCIIZ) {
- mir_tstrncpy(uinout, cinfo.pszVal, uinout_len);
- // It is up to us to free the string
- // The catch? We need to use Miranda's free(), not our CRT's :)
- mir_free(cinfo.pszVal);
- }
- else if (cinfo.type == CNFT_DWORD)
- _itot(cinfo.dVal,uinout,10);
- else if (cinfo.type == CNFT_WORD)
- _itot(cinfo.wVal,uinout,10);
- else
- found = false;
- }
- else found = false;
-
- if (!found)
- mir_tstrncpy(uinout, TranslateT("Unknown UIN"), uinout_len);
-
- return 0;
-}
-
TCHAR* GetExtension(TCHAR *file)
{
if (file == NULL) return _T("");
@@ -144,7 +115,8 @@ TCHAR* GetContactFolder(TCHAR *fn, MCONTACT hContact) GetProtocolFolder(fn, proto);
TCHAR uin[MAX_PATH];
- GetUIDFromHContact(hContact, uin, _countof(uin));
+ ptrT id(Contact_GetInfo(CNF_UNIQUEID, hContact, proto));
+ _tcsncpy_s(uin, (id == NULL) ? TranslateT("Unknown UIN") : id, _TRUNCATE);
ConvertToFilename(uin, MAX_PATH); //added so that weather id's like "yw/CI0000" work
mir_sntprintf(fn, MAX_PATH, _T("%s\\%s"), fn, uin);
CreateDirectoryTreeT(fn);
diff --git a/plugins/BasicHistory/src/EventList.cpp b/plugins/BasicHistory/src/EventList.cpp index 96caf57292..22c9122f11 100644 --- a/plugins/BasicHistory/src/EventList.cpp +++ b/plugins/BasicHistory/src/EventList.cpp @@ -396,40 +396,10 @@ std::wstring HistoryEventList::GetContactName() return TranslateT("System");
}
-void GetInfo(CONTACTINFO& ci, std::wstring& str)
-{
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- if (ci.type == CNFT_ASCIIZ) {
- str = ci.pszVal;
- mir_free(ci.pszVal);
- }
- else if (ci.type == CNFT_DWORD) {
- TCHAR buf[20];
- _ltot_s(ci.dVal, buf, 10);
- str = buf;
- }
- else if (ci.type == CNFT_WORD) {
- TCHAR buf[20];
- _ltot_s(ci.wVal, buf, 10);
- str = buf;
- }
- }
-}
-
std::wstring HistoryEventList::GetMyName()
{
- std::wstring myName;
- CONTACTINFO ci;
- memset(&ci, 0, sizeof(ci));
- ci.cbSize = sizeof(ci);
- ci.szProto = GetContactProto(m_hContact);
- ci.hContact = 0;
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- GetInfo(ci, myName);
- if (myName.empty())
- return TranslateT("Me");
-
- return myName;
+ ptrT name(Contact_GetInfo(CNF_DISPLAY, NULL, GetContactProto(m_hContact)));
+ return (name == NULL) ? TranslateT("Me") : name;
}
inline std::wstring GetProtocolName(MCONTACT hContact)
@@ -461,28 +431,14 @@ std::string HistoryEventList::GetBaseProtocol() std::wstring HistoryEventList::GetMyId()
{
- std::wstring myId;
- CONTACTINFO ci;
- memset(&ci, 0, sizeof(ci));
- ci.cbSize = sizeof(ci);
- ci.szProto = GetContactProto(m_hContact);
- ci.hContact = 0;
- ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
- GetInfo(ci, myId);
- return myId;
+ ptrT id(Contact_GetInfo(CNF_DISPLAYUID, NULL, GetContactProto(m_hContact)));
+ return (id == NULL) ? L"" : id;
}
inline std::wstring GetContactId(MCONTACT hContact)
{
- std::wstring id;
- CONTACTINFO ci;
- memset(&ci, 0, sizeof(ci));
- ci.cbSize = sizeof(ci);
- ci.szProto = GetContactProto(hContact);
- ci.hContact = hContact;
- ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
- GetInfo(ci, id);
- return id;
+ ptrT id(Contact_GetInfo(CNF_DISPLAYUID, hContact));
+ return (id == NULL) ? L"" : id;
}
std::wstring HistoryEventList::GetContactId()
diff --git a/plugins/CmdLine/src/utils.cpp b/plugins/CmdLine/src/utils.cpp index 993b300648..69d3d93578 100644 --- a/plugins/CmdLine/src/utils.cpp +++ b/plugins/CmdLine/src/utils.cpp @@ -152,29 +152,8 @@ int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, #pragma warning (disable: 4312)
char* GetContactName(MCONTACT hContact, char *szProto)
{
- char proto[200];
-
- CONTACTINFO ctInfo;
- memset(&ctInfo, 0, sizeof(ctInfo));
- ctInfo.cbSize = sizeof(ctInfo);
- if (szProto)
- ctInfo.szProto = szProto;
- else {
- GetContactProto(hContact, proto, sizeof(proto));
- ctInfo.szProto = proto;
- }
- ctInfo.dwFlag = CNF_DISPLAY;
- ctInfo.hContact = hContact;
-
- //_debug_message("retrieving contact name for %d", hContact);
- INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo);
- if (ret)
- return NULL;
-
- //_debug_message(" contact name %s", ctInfo.pszVal);
- char *buffer = strdup((char*)ctInfo.pszVal);
- mir_free(ctInfo.pszVal);
- return buffer;
+ ptrT name(Contact_GetInfo(CNF_DISPLAY, hContact, szProto));
+ return (name == NULL) ? NULL : strdup(_T2A(name));
}
#pragma warning (default: 4312)
@@ -196,42 +175,8 @@ char* GetContactID(MCONTACT hContact) char* GetContactID(MCONTACT hContact, char *szProto)
{
- CONTACTINFO ctInfo;
- memset(&ctInfo, 0, sizeof(ctInfo));
- ctInfo.cbSize = sizeof(ctInfo);
- ctInfo.szProto = szProto;
- ctInfo.dwFlag = CNF_UNIQUEID;
- ctInfo.hContact = hContact;
- INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo);
- if (ret)
- return NULL;
-
- char *buffer;
- char tmp[16];
- switch (ctInfo.type) {
- case CNFT_BYTE:
- mir_snprintf(tmp, "%d", ctInfo.bVal);
- buffer = strdup(tmp);
- break;
-
- case CNFT_WORD:
- mir_snprintf(tmp, "%d", ctInfo.wVal);
- buffer = strdup(tmp);
- break;
-
- case CNFT_DWORD:
- mir_snprintf(tmp, "%ld", ctInfo.dVal);
- buffer = strdup(tmp);
- break;
-
- case CNFT_ASCIIZ:
- default:
- buffer = _strdup((char*)ctInfo.pszVal);
- break;
- }
-
- mir_free(ctInfo.pszVal);
- return buffer;
+ ptrT name(Contact_GetInfo(CNF_UNIQUEID, hContact, szProto));
+ return (name == NULL) ? NULL : strdup(_T2A(name));
}
#pragma warning (default: 4312)
diff --git a/plugins/FavContacts/src/contact_cache.cpp b/plugins/FavContacts/src/contact_cache.cpp index d35e8c890e..38cd4abb62 100644 --- a/plugins/FavContacts/src/contact_cache.cpp +++ b/plugins/FavContacts/src/contact_cache.cpp @@ -116,23 +116,13 @@ float CContactCache::getWeight(int rate) static bool AppendInfo(TCHAR *buf, int size, MCONTACT hContact, int info)
{
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.hContact = hContact;
- ci.dwFlag = info;
- ci.dwFlag |= CNF_UNICODE;
-
- bool ret = false;
-
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci) && (ci.type == CNFT_ASCIIZ) && ci.pszVal) {
- if (*ci.pszVal && (mir_tstrlen(ci.pszVal) < size - 2)) {
- mir_tstrcpy(buf, ci.pszVal);
- ret = true;
- }
- mir_free(ci.pszVal);
+ ptrT str(Contact_GetInfo(info, hContact));
+ if (str != NULL) {
+ mir_tstrncpy(buf, str, size);
+ return true;
}
- return ret;
+ return false;
}
void CContactCache::TContactInfo::LoadInfo()
diff --git a/plugins/HistoryPlusPlus/hpp_contacts.pas b/plugins/HistoryPlusPlus/hpp_contacts.pas index fa8b9f6a4e..e898d003f3 100644 --- a/plugins/HistoryPlusPlus/hpp_contacts.pas +++ b/plugins/HistoryPlusPlus/hpp_contacts.pas @@ -88,7 +88,6 @@ end; function GetContactDisplayName(hContact: TMCONTACT; Proto: AnsiString = ''; Contact: boolean = false): String;
var
- ci: TContactInfo;
RetPWideChar, UW: PChar;
begin
if (hContact = 0) and Contact then
@@ -101,13 +100,9 @@ begin Result := TranslateW('''(Unknown Contact)''' { TRANSLATE-IGNORE } )
else
begin
- ci.cbSize := SizeOf(ci);
- ci.hContact := hContact;
- ci.szProto := PAnsiChar(Proto);
- ci.dwFlag := CNF_DISPLAY + CNF_UNICODE;
- if CallService(MS_CONTACT_GETCONTACTINFO, 0, LPARAM(@ci)) = 0 then
+ RetPWideChar := Contact_GetInfo(CNF_DISPLAY, hContact, PAnsiChar(Proto));
+ if RetPWideChar <> nil then
begin
- RetPWideChar := ci.retval.szVal.w;
UW := TranslateW('''(Unknown Contact)''' { TRANSLATE-IGNORE } );
if WideCompareText(RetPWideChar, UW) = 0 then
Result := AnsiToWideString(GetContactID(hContact, Proto), CP_ACP)
diff --git a/plugins/IEHistory/src/utils.cpp b/plugins/IEHistory/src/utils.cpp index d1f7f704bf..d34557b094 100644 --- a/plugins/IEHistory/src/utils.cpp +++ b/plugins/IEHistory/src/utils.cpp @@ -78,23 +78,10 @@ int Info(char *title, char *format, ...) returns the name of a contact */ -TCHAR *GetContactName(MCONTACT contact) +TCHAR* GetContactName(MCONTACT contact) { - CONTACTINFO ctInfo = { sizeof(ctInfo) }; - // if(db_mc_isMeta(contact)) - // contact=db_mc_getMostOnline(contact); - ctInfo.szProto = GetContactProto(contact); - ctInfo.dwFlag = CNF_DISPLAY; -#ifdef _UNICODE - ctInfo.dwFlag += CNF_UNICODE; -#endif - ctInfo.hContact = contact; - if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ctInfo)){ - return NULL; - } - TCHAR* buffer = _tcsdup(ctInfo.pszVal); - mir_free(ctInfo.pszVal); - return buffer; + ptrT name(Contact_GetInfo(CNF_DISPLAY, contact)); + return (name) ? _tcsdup(name) : NULL; } /* 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<char*>(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++) {
diff --git a/plugins/ImportTXT/General.pas b/plugins/ImportTXT/General.pas index 3fedce5df0..f68486afac 100644 --- a/plugins/ImportTXT/General.pas +++ b/plugins/ImportTXT/General.pas @@ -256,7 +256,6 @@ function GetContactByUID(const proto: AnsiString; const id: AnsiString): THandle var
Contact: THandle;
otherproto: AnsiString;
- ci: TCONTACTINFO;
idnum: integer;
tempwstr: PWideChar;
ws: WideString;
@@ -272,19 +271,13 @@ begin otherproto := Proto_GetProtoName(Contact);
if otherproto = proto then
begin
- ci.cbSize := SizeOf(ci);
- ci.dwFlag := CNF_UNIQUEID or CNF_UNICODE;
- ci.hContact := Contact;
- ci.szProto := PAnsiChar(otherproto);
- if CallService(MS_CONTACT_GETCONTACTINFO, 0, lparam(@ci)) = 0 then
+ tempwstr := Contact_GetInfo(CNF_UNIQUEID, Contact, PAnsiChar(otherproto));
+ if (tempwstr <> nil) and (tempwstr = ws) then
begin
- case (ci._type) of
- CNFT_BYTE: if ci.retval.bVal = idnum then break;
- CNFT_WORD: if ci.retval.wVal = idnum then break;
- CNFT_DWORD: if ci.retval.dVal = DWORD(idnum) then break;
- CNFT_ASCIIZ: if ws = ci.retval.szVal.w then break;
- end; // case
- end; // if
+ mir_free(tempwstr);
+ break;
+ end;
+ mir_free(tempwstr);
end; // if
Contact := db_find_next(Contact);
end; // while
@@ -298,7 +291,7 @@ function GetContactByNick(const proto: AnsiString; const Nick: WideString): THan var
Contact: THandle;
otherproto: AnsiString;
- ci: TCONTACTINFO;
+ tmpwstr: PWideChar;
begin
result := INVALID_HANDLE_VALUE;
Contact := db_find_first();
@@ -307,19 +300,14 @@ begin otherproto := Proto_GetProtoName(Contact);
if otherproto = proto then
begin
- ci.cbSize := SizeOf(ci);
- ci.dwFlag := CNF_NICK;
- ci.dwFlag := ci.dwFlag or CNF_UNICODE;
- ci.hContact := Contact;
- ci.szProto := PAnsiChar(otherproto);
- if CallService(MS_CONTACT_GETCONTACTINFO, 0, lparam(@ci)) = 0 then
+ tmpwstr := Contact_GetInfo(CNF_NICK, Contact, PAnsiChar(otherproto));
+ if (tmpwstr <> nil) and (Nick = tmpwstr) then
begin
- if Nick = ci.retval.szVal.w then
- begin
- result := Contact;
- break;
- end;
+ mir_free(tmpwstr);
+ result := Contact;
+ break;
end; // if
+ mir_free(tmpwstr);
end; // if
Contact := db_find_next(Contact);
end; // while
diff --git a/plugins/ListeningTo/src/listeningto.cpp b/plugins/ListeningTo/src/listeningto.cpp index ea276f77ff..5538f37b8b 100644 --- a/plugins/ListeningTo/src/listeningto.cpp +++ b/plugins/ListeningTo/src/listeningto.cpp @@ -461,7 +461,8 @@ INT_PTR MainMenuClicked(WPARAM wParam, LPARAM) return -1;
if (wParam < proto_items.size()) {
- ProtocolInfo &pi = proto_items[wParam];
EnableListeningTo(pi.proto, !ListeningToEnabled(pi.proto, TRUE));
+ ProtocolInfo &pi = proto_items[wParam];
+ EnableListeningTo(pi.proto, !ListeningToEnabled(pi.proto, TRUE));
}
return 0;
}
diff --git a/plugins/MirOTR/src/utils.cpp b/plugins/MirOTR/src/utils.cpp index 234f21cd1c..9d2d30a9ac 100644 --- a/plugins/MirOTR/src/utils.cpp +++ b/plugins/MirOTR/src/utils.cpp @@ -91,37 +91,13 @@ void otrl_privkey_hash_to_humanT(TCHAR human[45], const unsigned char hash[20]) *p = '\0'; } -char* contact_get_id(MCONTACT hContact, bool bNameOnError) { - char* pszUniqueID = NULL; - CONTACTINFO ci; - memset(&ci, 0, sizeof(ci)); - ci.cbSize = sizeof(ci); - ci.hContact = hContact; - ci.dwFlag = CNF_UNIQUEID; - - if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci) == 0) - { - if (ci.type == CNFT_ASCIIZ) { - pszUniqueID = (char*)ci.pszVal; // MS_CONTACT_GETCONTACTINFO uses mir_alloc - } else if (ci.type == CNFT_DWORD) { - pszUniqueID = (char*)mir_alloc(15); - if (pszUniqueID) - mir_snprintf(pszUniqueID, 15, ("%u"), ci.dVal); - } else if (ci.type == CNFT_WORD) { - pszUniqueID = (char*)mir_alloc(15); - if (pszUniqueID) - mir_snprintf(pszUniqueID, 15, ("%u"), ci.wVal); - } else if (ci.type == CNFT_BYTE) { - pszUniqueID = (char*)mir_alloc(15); - if (pszUniqueID) - mir_snprintf(pszUniqueID, 15, ("%u"), ci.bVal); - } - } - if (!pszUniqueID && bNameOnError) { - const TCHAR *name = pcli->pfnGetContactDisplayName(hContact, 0); - if (name) pszUniqueID = mir_t2a(name); - } - return pszUniqueID; +char* contact_get_id(MCONTACT hContact, bool bNameOnError) +{ + ptrT pszUniqueID(Contact_GetInfo(CNF_UNIQUEID, hContact)); + if (!pszUniqueID && bNameOnError) + pszUniqueID = mir_tstrdup(pcli->pfnGetContactDisplayName(hContact, 0)); + + return mir_t2a(pszUniqueID); } __inline const TCHAR* contact_get_nameT(MCONTACT hContact) { @@ -130,24 +106,8 @@ __inline const TCHAR* contact_get_nameT(MCONTACT hContact) { TCHAR* ProtoGetNickname(const char* proto) { - CONTACTINFO ci = {sizeof(ci)}; - ci.dwFlag = CNF_TCHAR | CNF_NICK; - ci.szProto = (char*)proto; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { - switch (ci.type) { - case CNFT_ASCIIZ: - return ci.pszVal; - case CNFT_DWORD: - mir_free(ci.pszVal); - ci.pszVal=(TCHAR*)mir_alloc(12*sizeof(TCHAR)); // long can only have up to 11 characters (unsigned = 10) - if(ci.pszVal) - _ltot(ci.dVal, ci.pszVal, 10); - return ci.pszVal; - default: - mir_free(ci.pszVal); - } - } - return mir_tstrdup(_T("")); + TCHAR *p = Contact_GetInfo(CNF_NICK, NULL, proto); + return (p != NULL) ? p : mir_tstrdup(_T("")); } void ShowPopup(const TCHAR* line1, const TCHAR* line2, int timeout, const MCONTACT hContact) { diff --git a/plugins/Msg_Export/src/utils.cpp b/plugins/Msg_Export/src/utils.cpp index 42df6bda09..b5d13d04af 100755 --- a/plugins/Msg_Export/src/utils.cpp +++ b/plugins/Msg_Export/src/utils.cpp @@ -973,23 +973,9 @@ void ExportDBEventInfo(MCONTACT hContact, DBEVENTINFO &dbei) for (int nCur = 0; nCur < 9; nCur++)
ReplaceAll(output, pszReplaceList[nCur], _DBGetString(hContact, sProto.c_str(), pszReplaceListA[nCur], _T("")));
- CONTACTINFO ci = {};
- ci.cbSize = sizeof(ci);
- ci.hContact = hContact;
- ci.szProto = (char*)sProto.c_str();
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { - switch (ci.type) { - case CNFT_ASCIIZ: - ReplaceAll(output, _T("%UIN%"), ci.pszVal);
- mir_free(ci.pszVal); - break; - case CNFT_DWORD: - mir_sntprintf(szTemp, _T("%u"), ci.dVal); - ReplaceAll(output, _T("%UIN%"), szTemp);
- break; - } - }
+ ptrT id(Contact_GetInfo(CNF_UNIQUEID, hContact, sProto.c_str()));
+ if (id != NULL)
+ ReplaceAll(output, _T("%UIN%"), id);
mir_sntprintf(szTemp, _T("%d"), db_get_w(hContact, sProto.c_str(), "Age", 0));
ReplaceAll(output, _T("%Age%"), szTemp);
@@ -1447,9 +1433,6 @@ void SaveSettings() TCHAR* GetMyOwnNick(MCONTACT hContact)
{
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.szProto = GetContactProto(hContact);
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- return CallService(MS_CONTACT_GETCONTACTINFO, 0, LPARAM(&ci)) ? mir_tstrdup(TranslateT("No_Nick")) : ci.pszVal;
+ TCHAR *p = Contact_GetInfo(CNF_DISPLAY, NULL, GetContactProto(hContact));
+ return (p != NULL) ? p : mir_tstrdup(TranslateT("No_Nick"));
}
diff --git a/plugins/MyDetails/src/data.cpp b/plugins/MyDetails/src/data.cpp index 88f9b1eab1..39132d8121 100644 --- a/plugins/MyDetails/src/data.cpp +++ b/plugins/MyDetails/src/data.cpp @@ -284,27 +284,10 @@ int Protocol::GetNickMaxLength() return ret;
}
-TCHAR *Protocol::GetNick()
+TCHAR* Protocol::GetNick()
{
- // Get it
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.hContact = NULL;
- ci.szProto = name;
- ci.dwFlag = CNF_DISPLAY;
-
-#ifdef UNICODE
- ci.dwFlag |= CNF_UNICODE;
-#endif
-
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
- // CNF_DISPLAY always returns a string type
- lcopystr(nickname, ci.pszVal, _countof(nickname));
- mir_free(ci.pszVal);
- }
- else
- lcopystr(nickname, _T(""), _countof(nickname));
-
+ ptrT nick(Contact_GetInfo(CNF_DISPLAY, NULL, name));
+ lcopystr(nickname, (nick != NULL) ? nick : _T(""), _countof(nickname));
return nickname;
}
diff --git a/plugins/QuickMessages/src/Utils.cpp b/plugins/QuickMessages/src/Utils.cpp index 7878317d5c..9067c7ac12 100644 --- a/plugins/QuickMessages/src/Utils.cpp +++ b/plugins/QuickMessages/src/Utils.cpp @@ -397,7 +397,6 @@ TCHAR* ParseString(MCONTACT hContact, TCHAR* ptszQValIn, TCHAR* ptszText, TCHAR* TCHAR* p = NULL; int NameLenght = 0; TCHAR* ptszName = NULL; - CONTACTINFO ci; if (!_tcschr(ptszQValue, varstr)) return ptszQValue; @@ -499,16 +498,10 @@ TCHAR* ParseString(MCONTACT hContact, TCHAR* ptszQValIn, TCHAR* ptszText, TCHAR* i = -1; break; case 'F': - memset(&ci, 0, sizeof(CONTACTINFO)); - ci.cbSize = sizeof(CONTACTINFO); - ci.hContact = hContact; - ci.dwFlag = CNF_FIRSTNAME | CNF_UNICODE; - ci.szProto = GetContactProto(hContact); - - if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) + ptszName = Contact_GetInfo(CNF_FIRSTNAME, hContact); + if (ptszName == NULL) break; - NameLenght = (int)mir_tstrlen(ci.pszVal); - ptszName = ci.pszVal; + NameLenght = (int)mir_tstrlen(ptszName); p = (TCHAR *)realloc(tempQValue, (QVSize + NameLenght + 1) * sizeof(TCHAR)); if (!p) { mir_free(ptszName); @@ -531,16 +524,11 @@ TCHAR* ParseString(MCONTACT hContact, TCHAR* ptszQValIn, TCHAR* ptszText, TCHAR* i = -1; break; case 'L': - memset(&ci, 0, sizeof(CONTACTINFO)); - ci.cbSize = sizeof(CONTACTINFO); - ci.hContact = hContact; - ci.dwFlag = CNF_LASTNAME | CNF_UNICODE; - ci.szProto = GetContactProto(hContact); - - if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) + ptszName = Contact_GetInfo(CNF_LASTNAME, hContact); + if (ptszName == NULL) break; - NameLenght = (int)mir_tstrlen(ci.pszVal); - ptszName = ci.pszVal; + + NameLenght = (int)mir_tstrlen(ptszName); p = (TCHAR *)realloc(tempQValue, (QVSize + NameLenght + 1) * sizeof(TCHAR)); if (!p) { mir_free(ptszName); diff --git a/plugins/QuickSearch/i_ok.inc b/plugins/QuickSearch/i_ok.inc index 009dcd6ba5..c710f76880 100644 --- a/plugins/QuickSearch/i_ok.inc +++ b/plugins/QuickSearch/i_ok.inc @@ -257,8 +257,8 @@ end; procedure LoadOneItem(hContact:THANDLE;column:pcolumnitem;proto:integer; var res:tQSRec);
var
lmodule:PAnsiChar;
+ pInfo:PWideChar;
DbEvent:TMEVENT;
- cni:TCONTACTINFO;
dbei:TDBEVENTINFO;
data:tSubstData;
begin
@@ -299,36 +299,14 @@ begin end;
QST_CONTACTINFO: begin
- FillChar(cni,SizeOf(cni),0);
- cni.cbSize :=sizeof(cni);
- cni.dwFlag :=cnftype or CNF_UNICODE;
- cni.hContact:=hContact;
- cni.szProto :=GetProtoName(proto);
- if CallService(MS_CONTACT_GETCONTACTINFO,0,tlparam(@cni))=0 then
+ pInfo := Contact_GetInfo(cnftype,hContact,nil);
+ if pInfo <> nil then
begin
- case cni._type of
- CNFT_ASCIIZ: begin
- if cni.retval.szVal.w<>nil then
- begin
- StrDupW(res.text,cni.retval.szVal.w);
- mir_free(cni.retval.szVal.w);
- end;
- exit;
- end;
- CNFT_BYTE :begin
- res.data:=cni.retval.bVal;
- if cnftype=CNF_GENDER then
- begin
- if not (res.data in [70,77]) then
- res.data:=DBReadByte(hContact,'UserInfo','Gender',0);
- exit;
- end
- end;
- CNFT_WORD :res.data:=cni.retval.wVal;
- CNFT_DWORD:res.data:=cni.retval.dVal;
- end;
- res.text:=int2strw(res.data);
+ StrDupW(res.text,pInfo);
+ mir_free(pInfo);
+ exit;
end;
+ res.text:=int2strw(res.data);
end;
QST_SETTING: begin
diff --git a/plugins/Scriver/src/msglog.cpp b/plugins/Scriver/src/msglog.cpp index fd908788d0..0f8ec8a47e 100644 --- a/plugins/Scriver/src/msglog.cpp +++ b/plugins/Scriver/src/msglog.cpp @@ -144,19 +144,9 @@ EventData* getEventFromDB(SrmmWindowData *dat, MCONTACT hContact, MEVENT hDbEven evt->time = dbei.timestamp;
evt->pszNick = NULL;
- if (evt->dwFlags & IEEDF_SENT) {
- CONTACTINFO ci = {};
- ci.cbSize = sizeof(ci);
- ci.szProto = dat->szProto;
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, LPARAM(&ci))) {
- if (ci.type == CNFT_ASCIIZ)
- evt->pszNickT = ci.pszVal;
- else
- evt->pszNickT = CMString(FORMAT, _T("%d"), ci.dVal).Detach();
- }
- }
- if (evt->pszNickT == NULL)
+ if (evt->dwFlags & IEEDF_SENT)
+ evt->pszNickT = Contact_GetInfo(CNF_DISPLAY, NULL);
+ else
evt->pszNickT = mir_tstrdup(pcli->pfnGetContactDisplayName(hContact, 0));
if (evt->eventType == EVENTTYPE_FILE) {
diff --git a/plugins/Scriver/src/utils.cpp b/plugins/Scriver/src/utils.cpp index 588871c788..8cc13d209b 100644 --- a/plugins/Scriver/src/utils.cpp +++ b/plugins/Scriver/src/utils.cpp @@ -387,24 +387,9 @@ void SetSearchEngineIcons(HMENU hMenu, HIMAGELIST hImageList) void GetContactUniqueId(SrmmWindowData *dat, char *buf, int maxlen)
{
- CONTACTINFO ci;
- memset(&ci, 0, sizeof(ci));
- ci.cbSize = sizeof(ci);
- ci.hContact = dat->hContact;
- ci.szProto = dat->szProto;
- ci.dwFlag = CNF_UNIQUEID;
- buf[0] = 0;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- strncpy_s(buf, maxlen, (char*)ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
- case CNFT_DWORD:
- mir_snprintf(buf, maxlen, "%u", ci.dVal);
- break;
- }
- }
+ ptrT id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact, dat->szProto));
+ if (id != NULL)
+ strncpy_s(buf, maxlen, _T2A(id), _TRUNCATE);
}
HWND CreateToolTip(HWND hwndParent, LPTSTR ptszText, LPTSTR ptszTitle, RECT *rect)
diff --git a/plugins/SeenPlugin/src/utils.cpp b/plugins/SeenPlugin/src/utils.cpp index cdbec7f7f4..08826a6b51 100644 --- a/plugins/SeenPlugin/src/utils.cpp +++ b/plugins/SeenPlugin/src/utils.cpp @@ -165,9 +165,8 @@ TCHAR* ParseString(TCHAR *szstring, MCONTACT hcontact) return sztemp;
}
- CONTACTINFO ci = { sizeof(CONTACTINFO) };
- ci.hContact = hcontact;
- ci.szProto = hcontact ? GetContactProto(hcontact) : courProtoName;
+ char *szProto = hcontact ? GetContactProto(hcontact) : courProtoName;
+ ptrT info;
TCHAR *d = sztemp;
for (TCHAR *p = szstring; *p; p++) {
@@ -257,9 +256,8 @@ TCHAR* ParseString(TCHAR *szstring, MCONTACT hcontact) goto LBL_charPtr;
case 'N':
- ci.dwFlag = CNF_NICK | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- charPtr = ci.pszVal;
+ if (info = Contact_GetInfo(CNF_NICK, hcontact, szProto)) {
+ charPtr = info;
goto LBL_charPtr;
}
goto LBL_noData;
@@ -274,26 +272,11 @@ TCHAR* ParseString(TCHAR *szstring, MCONTACT hcontact) break;
case 'u':
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_BYTE:
- _ltot(ci.bVal, szdbsetting, 10);
- break;
- case CNFT_WORD:
- _ltot(ci.wVal, szdbsetting, 10);
- break;
- case CNFT_DWORD:
- _ltot(ci.dVal, szdbsetting, 10);
- break;
- case CNFT_ASCIIZ:
- _tcsncpy(szdbsetting, ci.pszVal, _countof(szdbsetting));
- break;
- }
+ if (info = Contact_GetInfo(CNF_UNIQUEID, hcontact, szProto)) {
+ charPtr = info;
+ goto LBL_charPtr;
}
- else goto LBL_noData;
- charPtr = szdbsetting;
- goto LBL_charPtr;
+ goto LBL_noData;
case 's':
if (isetting = db_get_w(hcontact, S_MOD, hcontact ? "StatusTriger" : courProtoName, 0)) {
@@ -329,16 +312,15 @@ TCHAR* ParseString(TCHAR *szstring, MCONTACT hcontact) case 'i':
case 'r':
- if (isJabber(ci.szProto)) {
- if (db_get_ts(hcontact, ci.szProto, *p == 'i' ? "Resource" : "System", &dbv))
- goto LBL_noData;
-
- _tcsncpy(szdbsetting, dbv.ptszVal, _countof(szdbsetting));
- db_free(&dbv);
- charPtr = szdbsetting;
+ if (isJabber(szProto)) {
+ if (info = db_get_tsa(hcontact, szProto, *p == 'i' ? "Resource" : "System")) {
+ charPtr = info;
+ goto LBL_charPtr;
+ }
+ goto LBL_noData;
}
else {
- dwsetting = db_get_dw(hcontact, ci.szProto, *p == 'i' ? "IP" : "RealIP", 0);
+ dwsetting = db_get_dw(hcontact, szProto, *p == 'i' ? "IP" : "RealIP", 0);
if (!dwsetting)
goto LBL_noData;
@@ -349,7 +331,7 @@ TCHAR* ParseString(TCHAR *szstring, MCONTACT hcontact) goto LBL_charPtr;
case 'P':
- _tcsncpy(szdbsetting, ci.szProto ? _A2T(ci.szProto) : (wantempty ? _T("") : _T("ProtoUnknown")), _countof(szdbsetting));
+ _tcsncpy(szdbsetting, szProto ? _A2T(szProto) : (wantempty ? _T("") : _T("ProtoUnknown")), _countof(szdbsetting));
charPtr = szdbsetting;
goto LBL_charPtr;
@@ -358,27 +340,26 @@ TCHAR* ParseString(TCHAR *szstring, MCONTACT hcontact) goto LBL_charPtr;
case 'C': // Get Client Info
- if (!db_get_ts(hcontact, ci.szProto, "MirVer", &dbv)) {
- _tcsncpy(szdbsetting, dbv.ptszVal, _countof(szdbsetting));
- db_free(&dbv);
+ if (info = db_get_tsa(hcontact, szProto, "MirVer")) {
+ charPtr = info;
+ goto LBL_charPtr;
}
- else goto LBL_noData;
- charPtr = szdbsetting;
- goto LBL_charPtr;
+ goto LBL_noData;
case 't':
charPtr = _T("\t");
goto LBL_charPtr;
case 'A':
- {
- PROTOACCOUNT *pa = Proto_GetAccount(ci.szProto);
- if (!pa) goto LBL_noData;
- _tcsncpy(szdbsetting, pa->tszAccountName, _countof(szdbsetting));
- charPtr = szdbsetting;
+ {
+ PROTOACCOUNT *pa = Proto_GetAccount(szProto);
+ if (!pa)
+ goto LBL_noData;
+
+ _tcsncpy(szdbsetting, pa->tszAccountName, _countof(szdbsetting));
+ charPtr = szdbsetting;
+ }
goto LBL_charPtr;
- }
-
default:
*d++ = p[-1];
diff --git a/plugins/SendScreenshotPlus/src/CSendEmail.cpp b/plugins/SendScreenshotPlus/src/CSendEmail.cpp index 9b00c3b4f3..c674e13186 100644 --- a/plugins/SendScreenshotPlus/src/CSendEmail.cpp +++ b/plugins/SendScreenshotPlus/src/CSendEmail.cpp @@ -63,24 +63,8 @@ int CSendEmail::Send() mir_free(m_pszFileA); m_pszFileA = mir_t2a(m_pszFile); - - // AnsiString Email, Subject, FriendlyName; - CONTACTINFO ci = { 0 }; - ci.cbSize = sizeof(ci); - ci.hContact = m_hContact; - ci.szProto = m_pszProto; - //ci.dwFlag = CNF_TCHAR; - - ci.dwFlag = CNF_EMAIL | CNF_TCHAR; - CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci); - m_Email = mir_t2a(ci.pszVal); - - ci.dwFlag = CNF_DISPLAY | CNF_TCHAR; - CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci); - m_FriendlyName = mir_t2a(ci.pszVal); - - mir_free(ci.pszVal); - + m_Email = mir_t2a(ptrT(Contact_GetInfo(CNF_EMAIL, m_hContact, m_pszProto))); + m_FriendlyName = mir_t2a(ptrT(Contact_GetInfo(CNF_DISPLAY, m_hContact, m_pszProto))); m_Subject = mir_t2a(m_pszFileDesc); //SendByEmail(m_pszFileA, "", m_FriendlyName, m_Email, m_Subject); diff --git a/plugins/StopSpamMod/src/utilities.cpp b/plugins/StopSpamMod/src/utilities.cpp index cc13f07cbd..16265231d2 100755 --- a/plugins/StopSpamMod/src/utilities.cpp +++ b/plugins/StopSpamMod/src/utilities.cpp @@ -190,36 +190,9 @@ BOOL IsUrlContains(TCHAR * Str) tstring GetContactUid(MCONTACT hContact, tstring Protocol)
{
- tstring Uid;
- TCHAR dUid[32] = { 0 };
- char aUid[32] = { 0 };
char *szProto = mir_utf8encodeW(Protocol.c_str());
- CONTACTINFO ci;
- memset(&ci, 0, sizeof(ci));
-
- ci.hContact = hContact;
- ci.szProto = szProto;
- ci.cbSize = sizeof(ci);
-
- ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- Uid = ci.pszVal;
- mir_free((void *)ci.pszVal);
- break;
- case CNFT_DWORD:
- _itoa_s(ci.dVal, aUid, 32, 10);
- OemToChar(aUid, dUid);
- Uid = dUid;
- break;
- default:
- Uid = _T("");
- break;
- };
- }
- mir_free(szProto);
- return Uid;
+ ptrT uid(Contact_GetInfo(CNF_DISPLAYUID, hContact, szProto));
+ return (uid) ? uid : _T("");
}
void LogSpamToFile(MCONTACT hContact, tstring message)
diff --git a/plugins/TabSRMM/src/contactcache.cpp b/plugins/TabSRMM/src/contactcache.cpp index e51fee1f34..62781bbc5b 100644 --- a/plugins/TabSRMM/src/contactcache.cpp +++ b/plugins/TabSRMM/src/contactcache.cpp @@ -178,21 +178,9 @@ bool CContactCache::updateUIN() m_szUIN[0] = 0; if (m_Valid) { - CONTACTINFO ci = { sizeof(ci) }; - ci.hContact = getActiveContact(); - ci.szProto = const_cast<char *>(getActiveProto()); - ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR; - if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) { - switch (ci.type) { - case CNFT_ASCIIZ: - _tcsncpy_s(m_szUIN, ci.pszVal, _TRUNCATE); - mir_free(ci.pszVal); - break; - case CNFT_DWORD: - mir_sntprintf(m_szUIN, _T("%u"), ci.dVal); - break; - } - } + ptrT uid(Contact_GetInfo(CNF_DISPLAYUID, getActiveContact(), getActiveProto())); + if (uid != NULL) + _tcsncpy_s(m_szUIN, uid, _TRUNCATE); } return false; diff --git a/plugins/TabSRMM/src/msgdlgutils.cpp b/plugins/TabSRMM/src/msgdlgutils.cpp index c669c187cb..0e5bc78714 100644 --- a/plugins/TabSRMM/src/msgdlgutils.cpp +++ b/plugins/TabSRMM/src/msgdlgutils.cpp @@ -1037,25 +1037,11 @@ BOOL TSAPI DoRtfToTags(const TWindowData *dat, CMString &pszText, int iNumColors void TSAPI GetMYUIN(TWindowData *dat)
{
- CONTACTINFO ci = { sizeof(ci) };
- ci.szProto = const_cast<char *>(dat->cache->getActiveProto());
- ci.dwFlag = CNF_TCHAR | CNF_DISPLAYUID;
-
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- _tcsncpy_s(dat->myUin, ci.pszVal, _TRUNCATE);
- mir_free((void*)ci.pszVal);
- break;
- case CNFT_DWORD:
- mir_sntprintf(dat->myUin, _T("%u"), ci.dVal);
- break;
- default:
- dat->myUin[0] = 0;
- break;
- }
- }
- else dat->myUin[0] = 0;
+ ptrT uid(Contact_GetInfo(CNF_DISPLAYUID, NULL, dat->cache->getActiveProto()));
+ if (uid != NULL)
+ _tcsncpy_s(dat->myUin, uid, _TRUNCATE);
+ else
+ dat->myUin[0] = 0;
}
static int g_IEViewAvail = -1;
@@ -1748,37 +1734,14 @@ void TSAPI GetClientIcon(TWindowData *dat) void TSAPI GetMyNick(TWindowData *dat)
{
- CONTACTINFO ci;
-
- memset(&ci, 0, sizeof(ci));
- ci.cbSize = sizeof(ci);
- ci.hContact = NULL;
- ci.szProto = const_cast<char *>(dat->cache->getActiveProto());
- ci.dwFlag = CNF_TCHAR | CNF_NICK;
-
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- if (mir_tstrlen((TCHAR*)ci.pszVal) == 0 ||
- !mir_tstrcmp((TCHAR*)ci.pszVal, TranslateT("'(Unknown contact)'"))) {
- _tcsncpy_s(dat->szMyNickname, (dat->myUin[0] ? dat->myUin : TranslateT("'(Unknown contact)'")), _TRUNCATE);
- }
- else {
- _tcsncpy_s(dat->szMyNickname, (TCHAR*)ci.pszVal, _TRUNCATE);
- }
- break;
- case CNFT_DWORD:
- _ltot(ci.dVal, dat->szMyNickname, 10);
- break;
- default:
- _tcsncpy_s(dat->szMyNickname, _T("<undef>"), _TRUNCATE); // that really should *never* happen
- break;
- }
- mir_free(ci.pszVal);
- }
- else {
- _tcsncpy_s(dat->szMyNickname, _T("<undef>"), _TRUNCATE); // same here
+ ptrT tszNick(Contact_GetInfo(CNF_NICK, NULL, dat->cache->getActiveProto()));
+ if (tszNick != NULL) {
+ if (mir_tstrlen(tszNick) == 0 || !mir_tstrcmp(tszNick, TranslateT("'(Unknown contact)'")))
+ _tcsncpy_s(dat->szMyNickname, (dat->myUin[0] ? dat->myUin : TranslateT("'(Unknown contact)'")), _TRUNCATE);
+ else
+ _tcsncpy_s(dat->szMyNickname, tszNick, _TRUNCATE);
}
+ else _tcsncpy_s(dat->szMyNickname, _T("<undef>"), _TRUNCATE); // same here
}
HICON TSAPI MY_GetContactIcon(const TWindowData *dat, LPCSTR szSetting)
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp index 102fe49b42..a669db5ecd 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp @@ -291,25 +291,13 @@ void CExImContactBase::toIni(FILE* file, int modCount) } else { // Proto loaded - GetContactName(hContact,pszProto,0) - LPSTR pszCI = NULL; - CONTACTINFO ci = {}; - ci.cbSize = sizeof(ci); - ci.hContact = _hContact; - ci.szProto = _pszProto; - ci.dwFlag = CNF_DISPLAY; - if (!CallService(MS_CONTACT_GETCONTACTINFO, NULL, (LPARAM)&ci)) { - // CNF_DISPLAY always returns a string type - pszCI = (LPSTR)ci.pszVal; - } - LPSTR pszUID = uid2String(FALSE); + ptrT pszCI(Contact_GetInfo(CNF_DISPLAY, _hContact, _pszProto)); + ptrA pszUID(uid2String(FALSE)); if (_pszUIDKey && pszUID) - mir_snprintf(name, "%s *(%s)*<%s>*{%s}*", pszCI, _pszProto, _pszUIDKey, pszUID); + mir_snprintf(name, "%S *(%s)*<%s>*{%s}*", pszCI, _pszProto, _pszUIDKey, pszUID); else - mir_snprintf(name, "%s (%s)", pszCI, _pszProto); - - mir_free(pszCI); - mir_free(pszUID); - } // end else (Proto loaded) + mir_snprintf(name, "%S (%s)", pszCI, _pszProto); + } // it is not the best solution (but still works if only basic modules export) - need rework if (modCount > 3) diff --git a/plugins/Utils.pas/mircontacts.pas b/plugins/Utils.pas/mircontacts.pas index dc43b8d84e..43abcda5ba 100644 --- a/plugins/Utils.pas/mircontacts.pas +++ b/plugins/Utils.pas/mircontacts.pas @@ -85,8 +85,7 @@ end; function GetContactDisplayName(hContact: TMCONTACT; Proto: PAnsiChar = nil; Contact: boolean = false): PWideChar;
var
- ci: TContactInfo;
- pUnk:PWideChar;
+ pName, pUnk:PWideChar;
begin
if (hContact = 0) and Contact then
StrDupW(Result, TranslateW('Server'))
@@ -99,17 +98,14 @@ begin StrDupW(Result, pUnk)
else
begin
- ci.cbSize := SizeOf(ci);
- ci.hContact := hContact;
- ci.szProto := Proto;
- ci.dwFlag := CNF_DISPLAY + CNF_UNICODE;
- if CallService(MS_CONTACT_GETCONTACTINFO, 0, LPARAM(@ci)) = 0 then
+ pName := Contact_GetInfo(CNF_DISPLAY, hContact, Proto);
+ if pName <> nil then
begin
- if StrCmpW(ci.retval.szVal.w, pUnk)=0 then
+ if StrCmpW(pName, pUnk)=0 then
AnsiToWide(GetContactID(hContact, Proto), Result, CP_ACP)
else
- StrDupW(Result, ci.retval.szVal.w);
- mir_free(ci.retval.szVal.w);
+ StrDupW(Result, pName);
+ mir_free(pName);
end
else
AnsiToWide(GetContactID(hContact, Proto), Result);
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp index 7ab46f484e..88b93ea931 100644 --- a/plugins/Variables/src/contact.cpp +++ b/plugins/Variables/src/contact.cpp @@ -164,32 +164,7 @@ TCHAR* getContactInfoT(BYTE type, MCONTACT hContact) break;
}
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = hContact;
- ci.dwFlag = type | CNF_UNICODE;
- CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci);
-
- char szVal[16];
- memset(szVal, '\0', sizeof(szVal));
- switch (ci.type) {
- case CNFT_BYTE:
- if (type == CNF_GENDER) {
- szVal[0] = (char)ci.bVal; szVal[1] = 0;
- return mir_a2t(szVal);
- }
- return itot(ci.bVal);
-
- case CNFT_WORD:
- return itot(ci.wVal);
-
- case CNFT_DWORD:
- return itot(ci.dVal);
-
- case CNFT_ASCIIZ:
- return ci.pszVal;
- }
-
- return NULL;
+ return Contact_GetInfo(type, hContact);
}
// MS_VARS_GETCONTACTFROMSTRING
diff --git a/plugins/Variables/src/parse_miranda.cpp b/plugins/Variables/src/parse_miranda.cpp index e6431a19cb..42a9762bd4 100644 --- a/plugins/Variables/src/parse_miranda.cpp +++ b/plugins/Variables/src/parse_miranda.cpp @@ -361,15 +361,8 @@ static TCHAR* parseProtoInfo(ARGUMENTSINFO *ai) if (INT_PTR(szRes) == CALLSERVICE_NOTFOUND)
return NULL;
}
- else if (!mir_tstrcmp(ai->targv[2], _T(STR_PINICK))) {
- CONTACTINFO ci;
- ci.cbSize = sizeof(CONTACTINFO);
- ci.dwFlag = CNF_DISPLAY | CNF_UNICODE;
- ci.hContact = NULL;
- ci.szProto = szProto;
- CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci);
- tszRes = ci.pszVal;
- }
+ else if (!mir_tstrcmp(ai->targv[2], _T(STR_PINICK)))
+ tszRes = Contact_GetInfo(CNF_DISPLAY, NULL, szProto);
if (szRes == NULL && tszRes == NULL)
return NULL;
diff --git a/plugins/WhenWasIt/src/utils.cpp b/plugins/WhenWasIt/src/utils.cpp index 8018101d68..9667b1bc37 100644 --- a/plugins/WhenWasIt/src/utils.cpp +++ b/plugins/WhenWasIt/src/utils.cpp @@ -140,43 +140,13 @@ int GetStringFromDatabase(char *szSettingName, char *szError, char *szResult, si TCHAR* GetContactID(MCONTACT hContact)
{
- return GetContactID(hContact, GetContactProto(hContact));
+ return GetContactID(hContact, NULL);
}
TCHAR* GetContactID(MCONTACT hContact, char *szProto)
{
- CONTACTINFO ctInfo = { sizeof(ctInfo) };
- ctInfo.szProto = szProto;
- ctInfo.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- ctInfo.hContact = hContact;
- INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ctInfo);
- TCHAR *buffer;
- if (!ret) {
- TCHAR tmp[16];
- switch (ctInfo.type) {
- case CNFT_BYTE:
- mir_sntprintf(tmp, _T("%d"), ctInfo.bVal);
- buffer = _tcsdup(tmp);
- break;
-
- case CNFT_WORD:
- mir_sntprintf(tmp, _T("%d"), ctInfo.wVal);
- buffer = _tcsdup(tmp);
- break;
-
- case CNFT_DWORD:
- mir_sntprintf(tmp, _T("%ld"), ctInfo.dVal);
- buffer = _tcsdup(tmp);
- break;
-
- default:
- buffer = _tcsdup(ctInfo.pszVal);
- break;
- }
- }
-
- mir_free(ctInfo.pszVal);
- return (!ret) ? buffer : NULL;
+ ptrT res(Contact_GetInfo(CNF_UNIQUEID, hContact, szProto));
+ return (res) ? _tcsdup(res) : NULL;
}
MCONTACT GetContactFromID(TCHAR *szID, char *szProto)
diff --git a/plugins/YARelay/src/main.cpp b/plugins/YARelay/src/main.cpp index fb3e97319e..a39708cbce 100644 --- a/plugins/YARelay/src/main.cpp +++ b/plugins/YARelay/src/main.cpp @@ -151,20 +151,11 @@ static int MessageEventAdded(WPARAM hContact, LPARAM hDBEvent) case 'i':
case 'I':
{
- // get sender's uin
- CONTACTINFO ci = { sizeof(ci) };
- ci.dwFlag = CNF_UNIQUEID;
- if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci) == 0){
- if (ci.type == CNFT_ASCIIZ)
- _tcsncpy_s(buf, ci.pszVal, _TRUNCATE);
- else if (ci.type == CNFT_BYTE)
- mir_sntprintf(buf, _T("%u"), ci.bVal);
- else if (ci.type == CNFT_WORD)
- mir_sntprintf(buf, _T("%u"), ci.wVal);
- else if (ci.type == CNFT_DWORD)
- mir_sntprintf(buf, _T("%u"), ci.dVal);
- }
- else mir_sntprintf(buf, _T("%p"), hContact);
+ ptrT id(Contact_GetInfo(CNF_UNIQUEID, NULL));
+ if (id != NULL)
+ _tcsncpy_s(buf, id, _TRUNCATE);
+ else
+ mir_sntprintf(buf, _T("%p"), hContact);
}
szUtfMsg.append(T2Utf(buf));
break;
diff --git a/plugins/YahooGroups/src/utils.cpp b/plugins/YahooGroups/src/utils.cpp index 0557790b2d..b33d7d888f 100644 --- a/plugins/YahooGroups/src/utils.cpp +++ b/plugins/YahooGroups/src/utils.cpp @@ -158,35 +158,10 @@ int GetStringFromDatabase(char *szSettingName, WCHAR *szError, WCHAR *szResult, return GetStringFromDatabase(NULL, ModuleName, szSettingName, szError, szResult, count);
}
-TCHAR *GetContactName(MCONTACT hContact, char *szProto)
+TCHAR* GetContactName(MCONTACT hContact, char *szProto)
{
- CONTACTINFO ctInfo;
- char proto[200];
-
- memset(&ctInfo, 0, sizeof(ctInfo));
- ctInfo.cbSize = sizeof(ctInfo);
- if (szProto)
- {
- ctInfo.szProto = szProto;
- }
- else{
- GetContactProtocol(hContact, proto, sizeof(proto));
- ctInfo.szProto = proto;
- }
- ctInfo.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- ctInfo.hContact = hContact;
- //_debug_message("retrieving contact name for %d", hContact);
- INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo);
- //_debug_message(" contact name %s", ctInfo.pszVal);
- TCHAR *buffer;
- if (!ret)
- buffer = _tcsdup(ctInfo.pszVal);
-
- mir_free(ctInfo.pszVal);
- if (!ret)
- return buffer;
-
- return NULL;
+ ptrT id(Contact_GetInfo(CNF_DISPLAYUID, hContact, szProto));
+ return (id != NULL) ? _tcsdup(id) : NULL;
}
void GetContactProtocol(MCONTACT hContact, char *szProto, int size)
@@ -202,62 +177,10 @@ TCHAR *GetContactID(MCONTACT hContact) return GetContactID(hContact, protocol);
}
-TCHAR *GetContactID(MCONTACT hContact, char *szProto)
+TCHAR* GetContactID(MCONTACT hContact, char *szProto)
{
- CONTACTINFO ctInfo;
-
- memset(&ctInfo, 0, sizeof(ctInfo));
- ctInfo.cbSize = sizeof(ctInfo);
- ctInfo.szProto = szProto;
- ctInfo.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- ctInfo.hContact = hContact;
- INT_PTR ret = CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) &ctInfo);
- TCHAR *buffer;
- if (!ret)
- {
- TCHAR tmp[16];
- switch (ctInfo.type)
- {
- case CNFT_BYTE:
- {
- mir_sntprintf(tmp, _T("%d"), ctInfo.bVal);
- buffer = _tcsdup(tmp);
-
- break;
- }
-
- case CNFT_WORD:
- {
- mir_sntprintf(tmp, _T("%d"), ctInfo.wVal);
- buffer = _tcsdup(tmp);
-
- break;
- }
-
- case CNFT_DWORD:
- {
- mir_sntprintf(tmp, _T("%ld"), ctInfo.dVal);
- buffer = _tcsdup(tmp);
-
- break;
- }
-
- case CNFT_ASCIIZ:
- default:
- {
- buffer = _tcsdup(ctInfo.pszVal);
-
- break;
- }
- }
-
-
- }
- mir_free(ctInfo.pszVal);
- if (!ret)
- return buffer;
-
- return NULL;
+ ptrT id(Contact_GetInfo(CNF_DISPLAY, hContact, szProto));
+ return (id != NULL) ? _tcsdup(id) : NULL;
}
MCONTACT GetContactFromID(TCHAR *szID, char *szProto)
diff --git a/plugins/mRadio/i_myservice.inc b/plugins/mRadio/i_myservice.inc index 88ae278633..d55ab469e9 100644 --- a/plugins/mRadio/i_myservice.inc +++ b/plugins/mRadio/i_myservice.inc @@ -3,9 +3,9 @@ function Service_RadioPlayStop(wParam:WPARAM;lParam:LPARAM):int;cdecl;
var
p:PAnsiChar;
+ tmpw, res:PWideChar;
lnew:bool;
hContact:TMCONTACT;
- cni:TCONTACTINFO;
i:integer;
begin
result:=0;
@@ -21,30 +21,21 @@ begin // wParam = station name
else
begin
- FillChar(cni,SizeOf(cni),0);
- cni.cbSize :=sizeof(cni);
- if lParam=1 then
- cni.dwFlag:=CNF_DISPLAY
- else
- cni.dwFlag:=CNF_DISPLAY or CNF_UNICODE;
- cni.szProto :=PluginName;
-
+ AnsiToWide(pAnsiChar(wParam), tmpw);
hContact:=db_find_first(PluginName);
while hContact<>0 do
begin
- cni.hContact:=hContact;
- if CallService(MS_CONTACT_GETCONTACTINFO,0,tlparam(@cni))=0 then
+ res:=Contact_GetInfo(CNF_DISPLAY,hContact,PluginName);
+ if res <> nil then
begin
- if lParam=1 then
- i:=StrCmp(pAnsiChar(wParam),cni.retval.szVal.a)
- else
- i:=StrCmpW(pWideChar(wParam),cni.retval.szVal.w);
- mir_free(cni.retval.szVal.w);
+ i:=StrCmpW(tmpw, res);
+ mir_free(res);
if i=0 then
break;
end;
hContact:=db_find_next(hContact,PluginName);
end;
+ mFreeMem(tmpw);
end;
if hContact<>0 then
diff --git a/protocols/MSN/src/msn_std.cpp b/protocols/MSN/src/msn_std.cpp index 40fca05dc3..4df80b1c65 100644 --- a/protocols/MSN/src/msn_std.cpp +++ b/protocols/MSN/src/msn_std.cpp @@ -48,16 +48,13 @@ TCHAR* CMsnProto::GetContactNameT(MCONTACT hContact) if (hContact)
return (TCHAR*)pcli->pfnGetContactDisplayName(WPARAM(hContact), 0);
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- ci.szProto = m_szModuleName;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- if (m_DisplayNameCache) mir_free(m_DisplayNameCache);
- return (TCHAR*)m_DisplayNameCache = ci.pszVal;
+ TCHAR *str = Contact_GetInfo(CNF_DISPLAY, NULL, m_szModuleName);
+ if (str != NULL) {
+ mir_free(m_DisplayNameCache);
+ return m_DisplayNameCache = str;
}
- else
- return _T("Me");
+
+ return _T("Me");
}
unsigned MSN_GenRandom(void)
diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp index b429c2fee6..24ab3ec60b 100644 --- a/protocols/Tlen/src/tlen_muc.cpp +++ b/protocols/Tlen/src/tlen_muc.cpp @@ -72,20 +72,10 @@ static char *getDisplayName(TlenProtocol *proto, const char *id) if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) {
mir_snprintf(jid, "%s@%s", id, dbv.pszVal);
db_free(&dbv);
- if (((hContact=TlenHContactFromJID(proto, jid)) != NULL) || !mir_strcmp(id, proto->threadData->username)) {
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = hContact;
- ci.szProto = (char *)proto->m_szModuleName;
- ci.dwFlag = CNF_DISPLAY;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
- if (ci.type == CNFT_ASCIIZ) {
- if (ci.pszVal) {
- char* str = mir_t2a(ci.pszVal);
- mir_free(ci.pszVal);
- return str;
- }
- }
- }
+ if (((hContact = TlenHContactFromJID(proto, jid)) != NULL) || !mir_strcmp(id, proto->threadData->username)) {
+ ptrT szName(Contact_GetInfo(CNF_DISPLAY, hContact, proto->m_szModuleName));
+ if (szName)
+ return mir_t2a(szName);
}
}
return mir_strdup(id);
diff --git a/src/core/stdauth/src/auth.cpp b/src/core/stdauth/src/auth.cpp index adb4577ab3..da81b55068 100644 --- a/src/core/stdauth/src/auth.cpp +++ b/src/core/stdauth/src/auth.cpp @@ -44,7 +44,6 @@ INT_PTR ShowAddedWindow(WPARAM, LPARAM lParam) static int AuthEventAdded(WPARAM, LPARAM lParam)
{
- TCHAR szUid[128] = _T("");
TCHAR szTooltip[256];
MEVENT hDbEvent = (MEVENT)lParam;
@@ -66,27 +65,11 @@ static int AuthEventAdded(WPARAM, LPARAM lParam) cli.lParam = lParam;
cli.hDbEvent = hDbEvent;
- CONTACTINFO ci = {};
- ci.cbSize = sizeof(ci);
- ci.hContact = hContact;
- ci.szProto = GetContactProto(hContact);
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- _tcsncpy_s(szUid, ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
-
- case CNFT_DWORD:
- mir_sntprintf(szUid, _T("%u"), ci.dVal);
- break;
- }
- }
+ ptrT szUid(Contact_GetInfo(CNF_UNIQUEID, hContact));
if (dbei.eventType == EVENTTYPE_AUTHREQUEST) {
SkinPlaySound("AuthRequest");
- if (szUid[0])
+ if (szUid)
mir_sntprintf(szTooltip, TranslateT("%s requests authorization"), szUid);
else
mir_sntprintf(szTooltip, TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob);
@@ -97,7 +80,7 @@ static int AuthEventAdded(WPARAM, LPARAM lParam) }
else if (dbei.eventType == EVENTTYPE_ADDED) {
SkinPlaySound("AddedEvent");
- if (szUid[0])
+ if (szUid)
mir_sntprintf(szTooltip, TranslateT("%s added you to their contact list"), szUid);
else
mir_sntprintf(szTooltip, TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob);
diff --git a/src/core/stdfile/src/file.cpp b/src/core/stdfile/src/file.cpp index 33d6a5df66..2e6409bbfd 100644 --- a/src/core/stdfile/src/file.cpp +++ b/src/core/stdfile/src/file.cpp @@ -35,25 +35,11 @@ static HGENMENU hSRFileMenuItem; TCHAR* GetContactID(MCONTACT hContact)
{
char *szProto = GetContactProto(hContact);
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1) {
+ if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1)
if (TCHAR *theValue = db_get_tsa(hContact, szProto, "ChatRoomID"))
return theValue;
- }
- else {
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = hContact;
- ci.szProto = szProto;
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- return (TCHAR*)ci.pszVal;
- case CNFT_DWORD:
- return _itot(ci.dVal, (TCHAR*)mir_alloc(sizeof(TCHAR)*32), 10);
- }
- }
- }
- return NULL;
+
+ return Contact_GetInfo(CNF_UNIQUEID, hContact, szProto);
}
static INT_PTR SendFileCommand(WPARAM hContact, LPARAM)
diff --git a/src/core/stdfile/src/filerecvdlg.cpp b/src/core/stdfile/src/filerecvdlg.cpp index df3d46f881..47254f5499 100644 --- a/src/core/stdfile/src/filerecvdlg.cpp +++ b/src/core/stdfile/src/filerecvdlg.cpp @@ -247,34 +247,8 @@ INT_PTR CALLBACK DlgProcRecvFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l TimeZone_PrintTimeStamp(NULL, dbei.timestamp, _T("t d"), datetimestr, _countof(datetimestr), 0);
SetDlgItemText(hwndDlg, IDC_DATE, datetimestr);
- char* szProto = GetContactProto(dat->hContact);
- if (szProto) {
- int hasName = 0;
- char buf[128];
-
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.hContact = dat->hContact;
- ci.szProto = szProto;
- ci.dwFlag = CNF_UNIQUEID;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- hasName = 1;
- strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
- case CNFT_DWORD:
- hasName = 1;
- mir_snprintf(buf, "%u", ci.dVal);
- break;
- }
- }
- if (hasName)
- SetDlgItemTextA(hwndDlg, IDC_NAME, buf);
- else
- SetDlgItemText(hwndDlg, IDC_NAME, contactName);
- }
+ ptrT info(Contact_GetInfo(CNF_UNIQUEID, dat->hContact));
+ SetDlgItemText(hwndDlg, IDC_NAME, (info) ? info : contactName);
if (db_get_b(dat->hContact, "CList", "NotOnList", 0)) {
RECT rcBtn1, rcBtn2, rcDateCtrl;
diff --git a/src/core/stdfile/src/filesenddlg.cpp b/src/core/stdfile/src/filesenddlg.cpp index a2aa180770..2a5d28c7ef 100644 --- a/src/core/stdfile/src/filesenddlg.cpp +++ b/src/core/stdfile/src/filesenddlg.cpp @@ -238,34 +238,8 @@ INT_PTR CALLBACK DlgProcSendFile(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
SetDlgItemText(hwndDlg, IDC_TO, contactName);
- char *szProto = GetContactProto(dat->hContact);
- if (szProto) {
- int hasName = 0;
- char buf[128];
-
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = dat->hContact;
- ci.szProto = szProto;
- ci.dwFlag = CNF_UNIQUEID;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- hasName = 1;
- strncpy_s(buf, (char*)ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
- case CNFT_DWORD:
- hasName = 1;
- mir_snprintf(buf, "%u", ci.dVal);
- break;
- }
- }
-
- if (hasName)
- SetDlgItemTextA(hwndDlg, IDC_NAME, buf);
- else
- SetDlgItemText(hwndDlg, IDC_NAME, contactName);
- }
+ ptrT id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact));
+ SetDlgItemText(hwndDlg, IDC_NAME, (id) ? id : contactName);
if (fsd->ppFiles == NULL) {
EnableWindow(hwndDlg, FALSE);
diff --git a/src/core/stdmsg/src/msgdialog.cpp b/src/core/stdmsg/src/msgdialog.cpp index cd941d301c..22bf436713 100644 --- a/src/core/stdmsg/src/msgdialog.cpp +++ b/src/core/stdmsg/src/msgdialog.cpp @@ -920,27 +920,11 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l case DM_USERNAMETOCLIP:
if (dat->hContact) {
- TCHAR buf[128] = _T("");
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = dat->hContact;
- ci.szProto = dat->szProto;
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- _tcsncpy_s(buf, ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
-
- case CNFT_DWORD:
- mir_sntprintf(buf, _T("%u"), ci.dVal);
- break;
- }
- }
- if (buf[0] && OpenClipboard(hwndDlg)) {
+ ptrT id(Contact_GetInfo(CNF_UNIQUEID, dat->hContact, dat->szProto));
+ if (id != NULL && OpenClipboard(hwndDlg)) {
EmptyClipboard();
- HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_tstrlen(buf) * sizeof(TCHAR)+1);
- mir_tstrcpy((TCHAR*)GlobalLock(hData), buf);
+ HGLOBAL hData = GlobalAlloc(GMEM_MOVEABLE, mir_tstrlen(id) * sizeof(TCHAR)+1);
+ mir_tstrcpy((TCHAR*)GlobalLock(hData), id);
GlobalUnlock(hData);
SetClipboardData(CF_UNICODETEXT, hData);
CloseClipboard();
@@ -1025,29 +1009,8 @@ INT_PTR CALLBACK DlgProcMessage(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM l dat->wStatus = db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE);
TCHAR *contactName = pcli->pfnGetContactDisplayName(dat->hContact, 0);
- TCHAR buf[128] = _T("");
- if (mir_strcmp(dat->szProto, META_PROTO)) {
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.hContact = dat->hContact;
- ci.szProto = dat->szProto;
- ci.dwFlag = CNF_DISPLAYUID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- _tcsncpy_s(buf, ci.pszVal, _TRUNCATE);
- mir_free(ci.pszVal);
- break;
- case CNFT_DWORD:
- mir_sntprintf(buf, _T("%u"), ci.dVal);
- break;
- }
- }
- }
- if (buf[0])
- SetDlgItemText(hwndDlg, IDC_NAME, buf);
- else
- SetDlgItemText(hwndDlg, IDC_NAME, contactName);
+ ptrT id(Contact_GetInfo(CNF_DISPLAYUID, dat->hContact, dat->szProto));
+ SetDlgItemText(hwndDlg, IDC_NAME, (id) ? id : contactName);
TCHAR *szStatus = pcli->pfnGetStatusModeDescription(dat->szProto == NULL ? ID_STATUS_OFFLINE : db_get_w(dat->hContact, dat->szProto, "Status", ID_STATUS_OFFLINE), 0);
if (statusIcon)
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index 29ab6af1f9..38e583c2ca 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -271,27 +271,18 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT if (!(g_dat.flags & SMF_HIDENAMES) && dbei.eventType != EVENTTYPE_JABBER_CHATSTATES && dbei.eventType != EVENTTYPE_JABBER_PRESENCE) {
TCHAR *szName;
- CONTACTINFO ci = { 0 };
if (dbei.flags & DBEF_SENT) {
- ci.cbSize = sizeof(ci);
- ci.szProto = dbei.szModule;
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- // CNF_DISPLAY always returns a string type
- szName = ci.pszVal;
- }
+ if (TCHAR *p = Contact_GetInfo(CNF_DISPLAY, NULL, dbei.szModule))
+ szName = NEWTSTR_ALLOCA(p);
else
- // Shouldn't happen?
- szName = mir_tstrdup(TranslateT("Me"));
+ szName = TranslateT("Me");
}
else szName = pcli->pfnGetContactDisplayName(hContact, 0);
buffer.AppendFormat(" %s ", SetToStyle(dbei.flags & DBEF_SENT ? MSGFONTID_MYNAME : MSGFONTID_YOURNAME));
AppendToBufferWithRTF(buffer, szName);
showColon = 1;
- if (ci.pszVal)
- mir_free(ci.pszVal);
}
if (showColon)
@@ -302,18 +293,11 @@ static char* CreateRTFFromDbEvent(SrmmWindowData *dat, MCONTACT hContact, MEVENT case EVENTTYPE_JABBER_CHATSTATES:
case EVENTTYPE_JABBER_PRESENCE:
if (dbei.flags & DBEF_SENT) {
- CONTACTINFO ci = { sizeof(ci) };
- ci.hContact = NULL;
- ci.szProto = dbei.szModule;
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
-
- // CNF_DISPLAY always returns a string type
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci))
- szName = NEWTSTR_ALLOCA(ci.pszVal);
- else
- szName = _T("");
-
- mir_free(ci.pszVal);
+ if (TCHAR *p = Contact_GetInfo(CNF_DISPLAY, NULL, dbei.szModule)) {
+ szName = NEWTSTR_ALLOCA(p);
+ mir_free(p);
+ }
+ else szName = _T("");
}
else szName = pcli->pfnGetContactDisplayName(hContact, 0);
diff --git a/src/mir_app/src/clistsettings.cpp b/src/mir_app/src/clistsettings.cpp index b74bd28139..9f2b8f6593 100644 --- a/src/mir_app/src/clistsettings.cpp +++ b/src/mir_app/src/clistsettings.cpp @@ -109,27 +109,11 @@ TCHAR* fnGetContactDisplayName(MCONTACT hContact, int mode) return cacheEntry->tszName;
}
- CONTACTINFO ci;
- memset(&ci, 0, sizeof(ci));
- ci.cbSize = sizeof(ci);
- ci.hContact = hContact;
- if (ci.hContact == NULL)
- ci.szProto = "ICQ";
- ci.dwFlag = ((mode == GCDNF_NOMYHANDLE) ? CNF_DISPLAYNC : CNF_DISPLAY) | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci)) {
- if (ci.type == CNFT_ASCIIZ) {
- if (cacheEntry != NULL)
- replaceStrT(cacheEntry->tszName, ci.pszVal);
- return ci.pszVal;
- }
-
- if (ci.type == CNFT_DWORD) {
- TCHAR *buffer = (TCHAR*)mir_alloc(15 * sizeof(TCHAR));
- _ltot(ci.dVal, buffer, 10);
- if (cacheEntry != NULL)
- replaceStrT(cacheEntry->tszName, buffer);
- return buffer;
- }
+ ptrT tszDisplayName(Contact_GetInfo((mode == GCDNF_NOMYHANDLE) ? CNF_DISPLAYNC : CNF_DISPLAY, hContact));
+ if (tszDisplayName != NULL) {
+ if (cacheEntry != NULL)
+ replaceStrT(cacheEntry->tszName, tszDisplayName);
+ return tszDisplayName.detach();
}
CallContactService(hContact, PSS_GETINFO, SGIF_MINIMAL, 0);
diff --git a/src/mir_app/src/contacts.cpp b/src/mir_app/src/contacts.cpp index 652cde3a4c..e2c679dcc3 100644 --- a/src/mir_app/src/contacts.cpp +++ b/src/mir_app/src/contacts.cpp @@ -40,198 +40,159 @@ static TCHAR* nameOrderDescr[ NAMEORDERCOUNT ] = BYTE nameOrder[NAMEORDERCOUNT];
-static int GetDatabaseString(CONTACTINFO *ci, const char* setting, DBVARIANT* dbv)
+static int GetDatabaseString(MCONTACT hContact, const char *szProto, const char *szSetting, DBVARIANT *dbv)
{
- if (mir_strcmp(ci->szProto, "CList") && CallProtoService(ci->szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) {
- DBCONTACTGETSETTING cgs = { ci->szProto, setting, dbv };
- dbv->type = (ci->dwFlag & CNF_UNICODE) ? DBVT_WCHAR : DBVT_ASCIIZ;
+ if (mir_strcmp(szProto, "CList") && CallProtoService(szProto, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_INFOSETTINGSVC) {
+ DBCONTACTGETSETTING cgs = { szProto, szSetting, dbv };
+ dbv->type = DBVT_WCHAR;
- int res = CallProtoService(ci->szProto, PS_GETINFOSETTING, (WPARAM)ci->hContact, (LPARAM)&cgs);
+ int res = CallProtoService(szProto, PS_GETINFOSETTING, (WPARAM)hContact, (LPARAM)&cgs);
if (res != CALLSERVICE_NOTFOUND)
return res;
}
- if (ci->dwFlag & CNF_UNICODE)
- return db_get_ws(ci->hContact, ci->szProto, setting, dbv);
-
- return db_get_s(ci->hContact, ci->szProto, setting, dbv);
+ return db_get_ws(hContact, szProto, szSetting, dbv);
}
-static int ProcessDatabaseValueDefault(CONTACTINFO *ci, const char* setting)
+static TCHAR* ProcessDatabaseValueDefault(MCONTACT hContact, const char *szProto, const char *szSetting)
{
DBVARIANT dbv;
- if (!GetDatabaseString(ci, setting, &dbv)) {
+ if (!GetDatabaseString(hContact, szProto, szSetting, &dbv)) {
switch (dbv.type) {
case DBVT_ASCIIZ:
if (!dbv.pszVal[0]) break;
case DBVT_WCHAR:
if (!dbv.pwszVal[0]) break;
- ci->type = CNFT_ASCIIZ;
- ci->pszVal = dbv.ptszVal;
- return 0;
+ return dbv.ptszVal;
}
db_free(&dbv);
}
- if (db_get(ci->hContact, ci->szProto, setting, &dbv))
- return 1;
+ if (db_get(hContact, szProto, szSetting, &dbv))
+ return NULL;
+ TCHAR buf[40];
switch (dbv.type) {
case DBVT_BYTE:
- ci->type = CNFT_BYTE;
- ci->bVal = dbv.bVal;
- return 0;
+ return mir_tstrdup(_itot(dbv.bVal, buf, 10));
case DBVT_WORD:
- ci->type = CNFT_WORD;
- ci->wVal = dbv.wVal;
- return 0;
+ return mir_tstrdup(_itot(dbv.wVal, buf, 10));
case DBVT_DWORD:
- ci->type = CNFT_DWORD;
- ci->dVal = dbv.dVal;
- return 0;
+ return mir_tstrdup(_itot(dbv.dVal, buf, 10));
}
db_free(&dbv);
- return 1;
+ return NULL;
}
-static INT_PTR GetContactInfo(WPARAM, LPARAM lParam)
+MIR_APP_DLL(TCHAR*) Contact_GetInfo(int type, MCONTACT hContact, const char *szProto)
{
+ if (szProto == NULL)
+ szProto = Proto_GetBaseAccountName(hContact);
+ if (szProto == NULL)
+ return NULL;
+
+ char *uid;
+ TCHAR *res;
DBVARIANT dbv;
- CONTACTINFO *ci = (CONTACTINFO*)lParam;
- if (ci == NULL) return 1;
- if (ci->szProto == NULL) ci->szProto = Proto_GetBaseAccountName(ci->hContact);
- if (ci->szProto == NULL) return 1;
-
- ci->type = 0;
- switch (ci->dwFlag & 0x7F) {
- case CNF_FIRSTNAME: return ProcessDatabaseValueDefault(ci, "FirstName");
- case CNF_LASTNAME: return ProcessDatabaseValueDefault(ci, "LastName");
- case CNF_NICK: return ProcessDatabaseValueDefault(ci, "Nick");
- case CNF_EMAIL: return ProcessDatabaseValueDefault(ci, "e-mail");
- case CNF_CITY: return ProcessDatabaseValueDefault(ci, "City");
- case CNF_STATE: return ProcessDatabaseValueDefault(ci, "State");
- case CNF_PHONE: return ProcessDatabaseValueDefault(ci, "Phone");
- case CNF_HOMEPAGE: return ProcessDatabaseValueDefault(ci, "Homepage");
- case CNF_ABOUT: return ProcessDatabaseValueDefault(ci, "About");
- case CNF_AGE: return ProcessDatabaseValueDefault(ci, "Age");
- case CNF_GENDER: return ProcessDatabaseValueDefault(ci, "Gender");
- case CNF_FAX: return ProcessDatabaseValueDefault(ci, "Fax");
- case CNF_CELLULAR: return ProcessDatabaseValueDefault(ci, "Cellular");
- case CNF_BIRTHDAY: return ProcessDatabaseValueDefault(ci, "BirthDay");
- case CNF_BIRTHMONTH: return ProcessDatabaseValueDefault(ci, "BirthMonth");
- case CNF_BIRTHYEAR: return ProcessDatabaseValueDefault(ci, "BirthYear");
- case CNF_STREET: return ProcessDatabaseValueDefault(ci, "Street");
- case CNF_ZIP: return ProcessDatabaseValueDefault(ci, "ZIP");
- case CNF_LANGUAGE1: return ProcessDatabaseValueDefault(ci, "Language1");
- case CNF_LANGUAGE2: return ProcessDatabaseValueDefault(ci, "Language2");
- case CNF_LANGUAGE3: return ProcessDatabaseValueDefault(ci, "Language3");
- case CNF_CONAME: return ProcessDatabaseValueDefault(ci, "Company");
- case CNF_CODEPT: return ProcessDatabaseValueDefault(ci, "CompanyDepartment");
- case CNF_COPOSITION: return ProcessDatabaseValueDefault(ci, "CompanyPosition");
- case CNF_COSTREET: return ProcessDatabaseValueDefault(ci, "CompanyStreet");
- case CNF_COCITY: return ProcessDatabaseValueDefault(ci, "CompanyCity");
- case CNF_COSTATE: return ProcessDatabaseValueDefault(ci, "CompanyState");
- case CNF_COZIP: return ProcessDatabaseValueDefault(ci, "CompanyZIP");
- case CNF_COHOMEPAGE: return ProcessDatabaseValueDefault(ci, "CompanyHomepage");
+ switch (type) {
+ case CNF_FIRSTNAME: return ProcessDatabaseValueDefault(hContact, szProto, "FirstName");
+ case CNF_LASTNAME: return ProcessDatabaseValueDefault(hContact, szProto, "LastName");
+ case CNF_NICK: return ProcessDatabaseValueDefault(hContact, szProto, "Nick");
+ case CNF_EMAIL: return ProcessDatabaseValueDefault(hContact, szProto, "e-mail");
+ case CNF_CITY: return ProcessDatabaseValueDefault(hContact, szProto, "City");
+ case CNF_STATE: return ProcessDatabaseValueDefault(hContact, szProto, "State");
+ case CNF_PHONE: return ProcessDatabaseValueDefault(hContact, szProto, "Phone");
+ case CNF_HOMEPAGE: return ProcessDatabaseValueDefault(hContact, szProto, "Homepage");
+ case CNF_ABOUT: return ProcessDatabaseValueDefault(hContact, szProto, "About");
+ case CNF_AGE: return ProcessDatabaseValueDefault(hContact, szProto, "Age");
+ case CNF_GENDER: return ProcessDatabaseValueDefault(hContact, szProto, "Gender");
+ case CNF_FAX: return ProcessDatabaseValueDefault(hContact, szProto, "Fax");
+ case CNF_CELLULAR: return ProcessDatabaseValueDefault(hContact, szProto, "Cellular");
+ case CNF_BIRTHDAY: return ProcessDatabaseValueDefault(hContact, szProto, "BirthDay");
+ case CNF_BIRTHMONTH: return ProcessDatabaseValueDefault(hContact, szProto, "BirthMonth");
+ case CNF_BIRTHYEAR: return ProcessDatabaseValueDefault(hContact, szProto, "BirthYear");
+ case CNF_STREET: return ProcessDatabaseValueDefault(hContact, szProto, "Street");
+ case CNF_ZIP: return ProcessDatabaseValueDefault(hContact, szProto, "ZIP");
+ case CNF_LANGUAGE1: return ProcessDatabaseValueDefault(hContact, szProto, "Language1");
+ case CNF_LANGUAGE2: return ProcessDatabaseValueDefault(hContact, szProto, "Language2");
+ case CNF_LANGUAGE3: return ProcessDatabaseValueDefault(hContact, szProto, "Language3");
+ case CNF_CONAME: return ProcessDatabaseValueDefault(hContact, szProto, "Company");
+ case CNF_CODEPT: return ProcessDatabaseValueDefault(hContact, szProto, "CompanyDepartment");
+ case CNF_COPOSITION: return ProcessDatabaseValueDefault(hContact, szProto, "CompanyPosition");
+ case CNF_COSTREET: return ProcessDatabaseValueDefault(hContact, szProto, "CompanyStreet");
+ case CNF_COCITY: return ProcessDatabaseValueDefault(hContact, szProto, "CompanyCity");
+ case CNF_COSTATE: return ProcessDatabaseValueDefault(hContact, szProto, "CompanyState");
+ case CNF_COZIP: return ProcessDatabaseValueDefault(hContact, szProto, "CompanyZIP");
+ case CNF_COHOMEPAGE: return ProcessDatabaseValueDefault(hContact, szProto, "CompanyHomepage");
case CNF_CUSTOMNICK:
{
- char* saveProto = ci->szProto; ci->szProto = "CList";
- if (ci->hContact != NULL && !ProcessDatabaseValueDefault(ci, "MyHandle")) {
- ci->szProto = saveProto;
+ const char* saveProto = szProto; szProto = "CList";
+ if (hContact != NULL && !ProcessDatabaseValueDefault(hContact, szProto, "MyHandle")) {
+ szProto = saveProto;
return 0;
}
- ci->szProto = saveProto;
+ szProto = saveProto;
}
break;
case CNF_COUNTRY:
case CNF_COCOUNTRY:
- if (!GetDatabaseString(ci, (ci->dwFlag & 0x7F) == CNF_COUNTRY ? "CountryName" : "CompanyCountryName", &dbv))
- return 0;
+ if (!GetDatabaseString(hContact, szProto, type == CNF_COUNTRY ? "CountryName" : "CompanyCountryName", &dbv))
+ return dbv.ptszVal;
- if (!db_get(ci->hContact, ci->szProto, (ci->dwFlag & 0x7F) == CNF_COUNTRY ? "Country" : "CompanyCountry", &dbv)) {
+ if (!db_get(hContact, szProto, type == CNF_COUNTRY ? "Country" : "CompanyCountry", &dbv)) {
if (dbv.type == DBVT_WORD) {
- int i, countryCount;
+ int countryCount;
struct CountryListEntry *countries;
CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&countryCount, (LPARAM)&countries);
- for (i = 0; i < countryCount; i++) {
- if (countries[i].id != dbv.wVal) continue;
-
- if (ci->dwFlag & CNF_UNICODE) {
- int cbLen = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)countries[i].szName, -1, NULL, 0);
- WCHAR* buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*(cbLen + 1));
- if (buf != NULL)
- MultiByteToWideChar(CP_ACP, 0, (LPCSTR)countries[i].szName, -1, buf, cbLen);
- ci->pszVal = (TCHAR*)buf;
- }
- else ci->pszVal = (TCHAR*)mir_strdup(countries[i].szName);
-
- ci->type = CNFT_ASCIIZ;
- db_free(&dbv);
- return 0;
- }
+ for (int i = 0; i < countryCount; i++)
+ if (countries[i].id == dbv.wVal)
+ return mir_a2t(countries[i].szName);
+ }
+ else {
+ db_free(&dbv);
+ return ProcessDatabaseValueDefault(hContact, szProto, type == CNF_COUNTRY ? "Country" : "CompanyCountry");
}
- else return ProcessDatabaseValueDefault(ci, (ci->dwFlag & 0x7F) == CNF_COUNTRY ? "Country" : "CompanyCountry");
- db_free(&dbv);
}
break;
case CNF_FIRSTLAST:
- if (!GetDatabaseString(ci, "FirstName", &dbv)) {
+ if (!GetDatabaseString(hContact, szProto, "FirstName", &dbv)) {
DBVARIANT dbv2;
- if (!GetDatabaseString(ci, "LastName", &dbv2)) {
- ci->type = CNFT_ASCIIZ;
- if (ci->dwFlag & CNF_UNICODE) {
- size_t len = mir_wstrlen(dbv.pwszVal) + mir_wstrlen(dbv2.pwszVal) + 2;
- WCHAR* buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*len);
- if (buf != NULL)
- mir_wstrcat(mir_wstrcat(mir_wstrcpy(buf, dbv.pwszVal), L" "), dbv2.pwszVal);
- ci->pszVal = (TCHAR*)buf;
- }
- else {
- size_t len = mir_strlen(dbv.pszVal) + mir_strlen(dbv2.pszVal) + 2;
- char* buf = (char*)mir_alloc(len);
- if (buf != NULL)
- mir_strcat(mir_strcat(mir_strcpy(buf, dbv.pszVal), " "), dbv2.pszVal);
- ci->pszVal = (TCHAR*)buf;
- }
+ if (!GetDatabaseString(hContact, szProto, "LastName", &dbv2)) {
+ size_t len = mir_wstrlen(dbv.pwszVal) + mir_wstrlen(dbv2.pwszVal) + 2;
+ WCHAR* buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*len);
+ if (buf != NULL)
+ mir_wstrcat(mir_wstrcat(mir_wstrcpy(buf, dbv.pwszVal), L" "), dbv2.pwszVal);
db_free(&dbv);
db_free(&dbv2);
- return 0;
+ return buf;
}
db_free(&dbv);
}
break;
case CNF_UNIQUEID:
- {
- if (db_mc_isMeta(ci->hContact)) {
- TCHAR buf[40];
- _itot(ci->hContact, buf, 10);
- ci->pszVal = mir_tstrdup(buf);
- ci->type = CNFT_ASCIIZ;
- return 0;
- }
-
- char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid)
- if (!ProcessDatabaseValueDefault(ci, uid))
- return 0;
+ if (db_mc_isMeta(hContact)) {
+ TCHAR buf[40];
+ _itot(hContact, buf, 10);
+ return mir_tstrdup(buf);
}
+
+ uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid)
+ return ProcessDatabaseValueDefault(hContact, szProto, uid);
break;
case CNF_DISPLAYUID:
- {
- if (!ProcessDatabaseValueDefault(ci, "display_uid"))
- return 0;
- char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid)
- if (!ProcessDatabaseValueDefault(ci, uid))
- return 0;
-
- }
+ if (res = ProcessDatabaseValueDefault(hContact, szProto, "display_uid"))
+ return res;
+
+ uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid)
+ return ProcessDatabaseValueDefault(hContact, szProto, uid);
break;
case CNF_DISPLAYNC:
@@ -241,134 +202,84 @@ static INT_PTR GetContactInfo(WPARAM, LPARAM lParam) case 0: // custom name
// make sure we aren't in CNF_DISPLAYNC mode
// don't get custom name for NULL contact
- {
- char *saveProto = ci->szProto; ci->szProto = "CList";
- if (ci->hContact != NULL && (ci->dwFlag & 0x7F) == CNF_DISPLAY && !ProcessDatabaseValueDefault(ci, "MyHandle")) {
- ci->szProto = saveProto;
- return 0;
- }
- ci->szProto = saveProto;
- }
+ if (hContact != NULL && type == CNF_DISPLAY && (res = ProcessDatabaseValueDefault(hContact, "CList", "MyHandle")) != NULL)
+ return res;
break;
+
case 1:
- if (!ProcessDatabaseValueDefault(ci, "Nick")) // nick
- return 0;
+ if (res = ProcessDatabaseValueDefault(hContact, szProto, "Nick")) // nick
+ return res;
break;
case 2:
- if (!ProcessDatabaseValueDefault(ci, "FirstName")) // First Name
- return 0;
+ if (res = ProcessDatabaseValueDefault(hContact, szProto, "FirstName")) // First Name
+ return res;
break;
case 3:
- if (!ProcessDatabaseValueDefault(ci, "e-mail")) // E-mail
- return 0;
+ if (res = ProcessDatabaseValueDefault(hContact, szProto, "e-mail")) // E-mail
+ return res;
break;
case 4:
- if (!ProcessDatabaseValueDefault(ci, "LastName")) // Last Name
- return 0;
+ if (res = ProcessDatabaseValueDefault(hContact, szProto, "LastName")) // Last Name
+ return res;
break;
+
case 5: // Unique id
- {
- // protocol must define a PFLAG_UNIQUEIDSETTING
- char *uid = (char*)CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
- if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) {
- if (!GetDatabaseString(ci, uid, &dbv)) {
- if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD) {
- long value = (dbv.type == DBVT_BYTE) ? dbv.bVal : (dbv.type == DBVT_WORD ? dbv.wVal : dbv.dVal);
- if (ci->dwFlag & CNF_UNICODE) {
- WCHAR buf[40];
- _ltow(value, buf, 10);
- ci->pszVal = (TCHAR*)mir_wstrdup(buf);
- }
- else {
- char buf[40];
- _ltoa(value, buf, 10);
- ci->pszVal = (TCHAR*)mir_strdup(buf);
- }
- ci->type = CNFT_ASCIIZ;
- return 0;
- }
- if (dbv.type == DBVT_ASCIIZ && !(ci->dwFlag & CNF_UNICODE)) {
- ci->type = CNFT_ASCIIZ;
- ci->pszVal = dbv.ptszVal;
- return 0;
- }
- if (dbv.type == DBVT_WCHAR && (ci->dwFlag & CNF_UNICODE)) {
- ci->type = CNFT_ASCIIZ;
- ci->pszVal = dbv.ptszVal;
- return 0;
- }
+ // protocol must define a PFLAG_UNIQUEIDSETTING
+ uid = (char*)CallProtoService(szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0);
+ if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) {
+ if (!GetDatabaseString(hContact, szProto, uid, &dbv)) {
+ if (dbv.type == DBVT_BYTE || dbv.type == DBVT_WORD || dbv.type == DBVT_DWORD) {
+ long value = (dbv.type == DBVT_BYTE) ? dbv.bVal : (dbv.type == DBVT_WORD ? dbv.wVal : dbv.dVal);
+ WCHAR buf[40];
+ _ltow(value, buf, 10);
+ return mir_wstrdup(buf);
}
+ return dbv.ptszVal;
}
}
break;
+
case 6: // first + last name
case 7: // last + first name
- if (!GetDatabaseString(ci, nameOrder[i] == 6 ? "FirstName" : "LastName", &dbv)) {
+ if (!GetDatabaseString(hContact, szProto, nameOrder[i] == 6 ? "FirstName" : "LastName", &dbv)) {
DBVARIANT dbv2;
- if (!GetDatabaseString(ci, nameOrder[i] == 6 ? "LastName" : "FirstName", &dbv2)) {
- ci->type = CNFT_ASCIIZ;
-
- if (ci->dwFlag & CNF_UNICODE) {
- size_t len = mir_wstrlen(dbv.pwszVal) + mir_wstrlen(dbv2.pwszVal) + 2;
- WCHAR* buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*len);
- if (buf != NULL)
- mir_wstrcat(mir_wstrcat(mir_wstrcpy(buf, dbv.pwszVal), L" "), dbv2.pwszVal);
- ci->pszVal = (TCHAR*)buf;
- }
- else {
- size_t len = mir_strlen(dbv.pszVal) + mir_strlen(dbv2.pszVal) + 2;
- char* buf = (char*)mir_alloc(len);
- if (buf != NULL)
- mir_strcat(mir_strcat(mir_strcpy(buf, dbv.pszVal), " "), dbv2.pszVal);
- ci->pszVal = (TCHAR*)buf;
- }
+ if (!GetDatabaseString(hContact, szProto, nameOrder[i] == 6 ? "LastName" : "FirstName", &dbv2)) {
+ size_t len = mir_wstrlen(dbv.pwszVal) + mir_wstrlen(dbv2.pwszVal) + 2;
+ WCHAR* buf = (WCHAR*)mir_alloc(sizeof(WCHAR)*len);
+ if (buf != NULL)
+ mir_wstrcat(mir_wstrcat(mir_wstrcpy(buf, dbv.pwszVal), L" "), dbv2.pwszVal);
db_free(&dbv);
db_free(&dbv2);
- return 0;
+ return buf;
}
db_free(&dbv);
}
break;
case 8:
- if (ci->dwFlag & CNF_UNICODE)
- ci->pszVal = (TCHAR*)mir_wstrdup(TranslateW(L"'(Unknown contact)'"));
- else
- ci->pszVal = (TCHAR*)mir_strdup(Translate("'(Unknown contact)'"));
- ci->type = CNFT_ASCIIZ;
- return 0;
- }
- }
- break;
-
- case CNF_TIMEZONE:
- {
- HANDLE hTz = TimeZone_CreateByContact(ci->hContact, 0, TZF_KNOWNONLY);
- if (hTz) {
- LPTIME_ZONE_INFORMATION tzi = TimeZone_GetInfo(hTz);
- int offset = tzi->Bias + tzi->StandardBias;
-
- char str[80];
- mir_snprintf(str, offset ? "UTC%+d:%02d" : "UTC", offset / -60, abs(offset % 60));
- ci->pszVal = ci->dwFlag & CNF_UNICODE ? (TCHAR*)mir_a2u(str) : (TCHAR*)mir_strdup(str);
- ci->type = CNFT_ASCIIZ;
- return 0;
+ return mir_tstrdup(TranslateT("'(Unknown contact)'"));
}
}
break;
case CNF_MYNOTES:
- char* saveProto = ci->szProto; ci->szProto = "UserInfo";
- if (!ProcessDatabaseValueDefault(ci, "MyNotes")) {
- ci->szProto = saveProto;
- return 0;
+ return ProcessDatabaseValueDefault(hContact, "UserInfo", "MyNotes");
+
+ case CNF_TIMEZONE:
+ HANDLE hTz = TimeZone_CreateByContact(hContact, 0, TZF_KNOWNONLY);
+ if (hTz) {
+ LPTIME_ZONE_INFORMATION tzi = TimeZone_GetInfo(hTz);
+ int offset = tzi->Bias + tzi->StandardBias;
+
+ char str[80];
+ mir_snprintf(str, offset ? "UTC%+d:%02d" : "UTC", offset / -60, abs(offset % 60));
+ return mir_a2u(str);
}
- ci->szProto = saveProto;
break;
}
- return 1;
+ return NULL;
}
/////////////////////////////////////////////////////////////////////////////////////////
@@ -446,7 +357,6 @@ int LoadContactsModule(void) db_free(&dbv);
}
- CreateServiceFunction(MS_CONTACT_GETCONTACTINFO, GetContactInfo);
HookEvent(ME_OPT_INITIALISE, ContactOptInit);
return 0;
}
diff --git a/src/mir_app/src/meta_utils.cpp b/src/mir_app/src/meta_utils.cpp index 838faace9b..a8499971a4 100644 --- a/src/mir_app/src/meta_utils.cpp +++ b/src/mir_app/src/meta_utils.cpp @@ -40,35 +40,11 @@ POINT menuMousePoint; int Meta_SetNick(char *szProto)
{
- CONTACTINFO ci = { sizeof(ci) };
- ci.dwFlag = CNF_DISPLAY | CNF_TCHAR;
- ci.szProto = szProto;
- if (CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)&ci))
+ ptrT tszNick(Contact_GetInfo(CNF_DISPLAY, NULL, szProto));
+ if (tszNick == NULL)
return 1;
- switch (ci.type) {
- case CNFT_BYTE:
- if (db_set_b(NULL, META_PROTO, "Nick", ci.bVal))
- return 1;
- break;
- case CNFT_WORD:
- if (db_set_w(NULL, META_PROTO, "Nick", ci.wVal))
- return 1;
- break;
- case CNFT_DWORD:
- if (db_set_dw(NULL, META_PROTO, "Nick", ci.dVal))
- return 1;
- break;
- case CNFT_ASCIIZ:
- if (db_set_ts(NULL, META_PROTO, "Nick", ci.pszVal))
- return 1;
- mir_free(ci.pszVal);
- break;
- default:
- if (db_set_s(NULL, META_PROTO, "Nick", (char *)TranslateT("Sender")))
- return 1;
- break;
- }
+ db_set_ts(NULL, META_PROTO, "Nick", tszNick);
return 0;
}
diff --git a/src/mir_app/src/mir_app.def b/src/mir_app/src/mir_app.def index e142457c3c..83558a0ecf 100644 --- a/src/mir_app/src/mir_app.def +++ b/src/mir_app/src/mir_app.def @@ -259,3 +259,4 @@ Clist_GroupGetName @257 Clist_GroupRename @258
Clist_EndRebuild @259
Clist_GroupAdded @260
+Contact_GetInfo @261
diff --git a/src/mir_app/src/mir_app64.def b/src/mir_app/src/mir_app64.def index 6fd5286825..e4d27302d3 100644 --- a/src/mir_app/src/mir_app64.def +++ b/src/mir_app/src/mir_app64.def @@ -259,3 +259,4 @@ Clist_GroupGetName @257 Clist_GroupRename @258
Clist_EndRebuild @259
Clist_GroupAdded @260
+Contact_GetInfo @261
diff --git a/src/mir_app/src/path.cpp b/src/mir_app/src/path.cpp index fd697684b6..64426f4e4e 100644 --- a/src/mir_app/src/path.cpp +++ b/src/mir_app/src/path.cpp @@ -35,25 +35,10 @@ static TCHAR tszAvatarRoot[MAX_PATH]; TCHAR* GetContactID(MCONTACT hContact)
{
char *szProto = GetContactProto(hContact);
- if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1) {
+ if (db_get_b(hContact, szProto, "ChatRoom", 0) == 1)
return db_get_tsa(hContact, szProto, "ChatRoomID");
- }
- else {
- CONTACTINFO ci = {0};
- ci.cbSize = sizeof(ci);
- ci.hContact = hContact;
- ci.szProto = szProto;
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM) & ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- return (TCHAR *)ci.pszVal;
- case CNFT_DWORD:
- return _itot(ci.dVal, (TCHAR *)mir_alloc(sizeof(TCHAR)*32), 10);
- }
- }
- return NULL;
- }
+
+ return Contact_GetInfo(CNF_UNIQUEID, hContact, szProto);
}
/////////////////////////////////////////////////////////////////////////////////////////
diff --git a/src/mir_app/src/proto_opts.cpp b/src/mir_app/src/proto_opts.cpp index f87add9875..f7a72e5d70 100644 --- a/src/mir_app/src/proto_opts.cpp +++ b/src/mir_app/src/proto_opts.cpp @@ -626,26 +626,12 @@ INT_PTR CALLBACK AccMgrDlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM if (acc->ppro && Proto_IsProtocolLoaded(acc->szProtoName)) {
char *szIdName = (char *)acc->ppro->GetCaps(PFLAG_UNIQUEIDTEXT, 0);
- TCHAR *tszIdName = szIdName ? mir_a2t(szIdName) : mir_tstrdup(TranslateT("Account ID"));
-
- CONTACTINFO ci = { 0 };
- ci.cbSize = sizeof(ci);
- ci.hContact = NULL;
- ci.szProto = acc->szModuleName;
- ci.dwFlag = CNF_UNIQUEID | CNF_TCHAR;
- if (!CallService(MS_CONTACT_GETCONTACTINFO, 0, (LPARAM)& ci)) {
- switch (ci.type) {
- case CNFT_ASCIIZ:
- mir_sntprintf(text, size, _T("%s: %s"), tszIdName, ci.pszVal);
- mir_free(ci.pszVal);
- break;
- case CNFT_DWORD:
- mir_sntprintf(text, size, _T("%s: %d"), tszIdName, ci.dVal);
- break;
- }
- }
- else mir_sntprintf(text, size, _T("%s: %s"), tszIdName, TranslateT("<unknown>"));
- mir_free(tszIdName);
+ ptrT tszIdName(szIdName ? mir_a2t(szIdName) : mir_tstrdup(TranslateT("Account ID")));
+ ptrT tszUniqueID(Contact_GetInfo(CNF_UNIQUEID, NULL, acc->szModuleName));
+ if (tszUniqueID != NULL)
+ mir_sntprintf(text, size, _T("%s: %s"), tszIdName, tszUniqueID);
+ else
+ mir_sntprintf(text, size, _T("%s: %s"), tszIdName, TranslateT("<unknown>"));
}
else mir_sntprintf(text, size, TranslateT("Protocol is not loaded."));
|