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/main.cpp | 12 ------- plugins/DbEditorPP/src/main_window.cpp | 2 +- plugins/DbEditorPP/src/stdafx.h | 1 + plugins/DbEditorPP/src/utils.cpp | 65 +++------------------------------- plugins/DbEditorPP/src/version.h | 2 +- 5 files changed, 7 insertions(+), 75 deletions(-) (limited to 'plugins/DbEditorPP') diff --git a/plugins/DbEditorPP/src/main.cpp b/plugins/DbEditorPP/src/main.cpp index d13c44bf7a..1df7685049 100644 --- a/plugins/DbEditorPP/src/main.cpp +++ b/plugins/DbEditorPP/src/main.cpp @@ -7,7 +7,6 @@ bool g_bServiceMode = false; bool g_bUsePopups; CMPlugin g_plugin; -uint8_t nameOrder[NAMEORDERCOUNT]; HGENMENU hUserMenu; MCONTACT hRestore; @@ -185,17 +184,6 @@ int CMPlugin::Load() icex.dwSize = sizeof(INITCOMMONCONTROLSEX); icex.dwICC = ICC_LISTVIEW_CLASSES; InitCommonControlsEx(&icex); - - // Load the name order - for (int i = 0; i < NAMEORDERCOUNT; i++) - nameOrder[i] = i; - - DBVARIANT dbv = {}; - if (!db_get_s(0, "Contact", "NameOrder", &dbv, DBVT_BLOB)) { - memcpy(nameOrder, dbv.pbVal, dbv.cpbVal); - db_free(&dbv); - } - return 0; } diff --git a/plugins/DbEditorPP/src/main_window.cpp b/plugins/DbEditorPP/src/main_window.cpp index a83e35c4a8..1553cbc8ea 100644 --- a/plugins/DbEditorPP/src/main_window.cpp +++ b/plugins/DbEditorPP/src/main_window.cpp @@ -197,7 +197,7 @@ bool CMainDlg::OnInitDialog() mir_subclassWindow(m_modules.GetHwnd(), ModuleTreeSubclassProc); m_modules.SetImageList(hImg, TVSIL_NORMAL); - //setting list + // setting list mir_subclassWindow(m_settings.GetHwnd(), SettingListSubclassProc); m_settings.SetExtendedListViewStyle(32 | LVS_EX_SUBITEMIMAGES | LVS_EX_LABELTIP); //LVS_EX_GRIDLINES loadListSettings(m_settings.GetHwnd(), csSettingList); diff --git a/plugins/DbEditorPP/src/stdafx.h b/plugins/DbEditorPP/src/stdafx.h index 9ce98b774e..79e875b3b9 100644 --- a/plugins/DbEditorPP/src/stdafx.h +++ b/plugins/DbEditorPP/src/stdafx.h @@ -17,6 +17,7 @@ #include #include +#include #include #include #include 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()) { diff --git a/plugins/DbEditorPP/src/version.h b/plugins/DbEditorPP/src/version.h index 082cc92b36..555e890442 100644 --- a/plugins/DbEditorPP/src/version.h +++ b/plugins/DbEditorPP/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 4 #define __MINOR_VERSION 1 #define __RELEASE_NUM 0 -#define __BUILD_NUM 3 +#define __BUILD_NUM 4 #include -- cgit v1.2.3