From 012971bfceb38022ac90c47ce9dd8925094580e4 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 14 Mar 2023 17:44:39 +0300 Subject: fixes #3404 (wrong nicks in DbEditor, custom nick formatter removed) --- plugins/DbEditorPP/src/utils.cpp | 65 +++------------------------------------- 1 file changed, 4 insertions(+), 61 deletions(-) (limited to 'plugins/DbEditorPP/src/utils.cpp') diff --git a/plugins/DbEditorPP/src/utils.cpp b/plugins/DbEditorPP/src/utils.cpp index 6662ba4f83..63be5c2a86 100644 --- a/plugins/DbEditorPP/src/utils.cpp +++ b/plugins/DbEditorPP/src/utils.cpp @@ -17,8 +17,6 @@ along with this program. If not, see . #include "stdafx.h" -extern uint8_t nameOrder[NAMEORDERCOUNT]; - ///////////////////////////////////////////////////////////////////////////////////////// int ListView_GetItemTextA(HWND hwndLV, int i, int iSubItem, char *pszText, int cchTextMax) @@ -248,75 +246,20 @@ int GetContactName(MCONTACT hContact, const char *proto, wchar_t *value, int max char *szProto = (char*)proto; char tmp[FLD_SIZE]; - wchar_t name[NAME_SIZE]; name[0] = 0; if (hContact && (!proto || !proto[0])) if (!db_get_static(hContact, "Protocol", "p", tmp, _countof(tmp))) szProto = tmp; - for (int i = 0; i < NAMEORDERCOUNT - 1; i++) { - switch (nameOrder[i]) { - case 0: // custom name - GetValueW(hContact, "CList", "MyHandle", name, _countof(name)); - break; - - case 1: // nick - if (!szProto) break; - GetValueW(hContact, szProto, "Nick", name, _countof(name)); - break; - - case 2: // First Name - // if (!szProto) break; - // GetValueW(hContact, szProto, "FirstName", name, _countof(name)); - break; - - case 3: // E-mail - if (!szProto) break; - GetValueW(hContact, szProto, "e-mail", name, _countof(name)); - break; - - case 4: // Last Name - // GetValueW(hContact, szProto, "LastName", name, _countof(name)); - break; - - case 5: // Unique id - if (szProto) { - // protocol must define a PFLAG_UNIQUEIDSETTING - const char *uid = Proto_GetUniqueId(szProto); - if (uid) - GetValueW(hContact, szProto, uid, name, _countof(name)); - } - break; - - case 6: // first + last name - if (szProto) { - GetValueW(hContact, szProto, "FirstName", name, _countof(name)); - - int len = (int)mir_wstrlen(name); - if (len + 2 < _countof(name)) { - if (len) - mir_wstrncat(name, L" ", _countof(name)); - len++; - GetValueW(hContact, szProto, "LastName", &name[len], _countof(name) - len); - } - } - break; - } - - if (name[0]) - break; - } - - if (!name[0]) - mir_wstrncpy(name, TranslateT(""), _countof(name)); + ptrW pwszNick(Contact::GetInfo(CNF_DISPLAY, hContact, szProto)); if (szProto && szProto[0]) { if (g_Order) - mir_snwprintf(value, maxlen, L"(%S) %s", szProto, name); + mir_snwprintf(value, maxlen, L"(%S) %s", szProto, pwszNick.get()); else - mir_snwprintf(value, maxlen, L"%s (%S)", name, szProto); + mir_snwprintf(value, maxlen, L"%s (%S)", pwszNick.get(), szProto); } - else mir_wstrncpy(value, name, maxlen); + else mir_wstrncpy(value, pwszNick, maxlen); PROTOACCOUNT *pa = Proto_GetAccount(szProto); if (!pa->IsEnabled()) { -- cgit v1.2.3