From 0590527b9f501bdb6716c7a6fb1b6c201c07eb9b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 10 Apr 2020 11:33:02 +0300 Subject: fixes #2317 (StdUserInfo: we need moar Unicode) --- src/core/stduserinfo/src/contactinfo.cpp | 310 +++++++++++++++---------------- src/core/stduserinfo/src/stdinfo.cpp | 71 ++++--- src/core/stduserinfo/src/userinfo.cpp | 22 +-- 3 files changed, 201 insertions(+), 202 deletions(-) (limited to 'src/core/stduserinfo') diff --git a/src/core/stduserinfo/src/contactinfo.cpp b/src/core/stduserinfo/src/contactinfo.cpp index d693f3677b..b76a5231f7 100644 --- a/src/core/stduserinfo/src/contactinfo.cpp +++ b/src/core/stduserinfo/src/contactinfo.cpp @@ -32,16 +32,17 @@ static INT_PTR CALLBACK EditUserEmailDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar switch (msg) { case WM_INITDIALOG: SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - if (*(char*)lParam) SetWindowText(hwndDlg, TranslateT("Edit e-mail address")); + if (*(char *)lParam) + SetWindowText(hwndDlg, TranslateT("Edit e-mail address")); TranslateDialogDefault(hwndDlg); - SetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)lParam); - EnableWindow(GetDlgItem(hwndDlg, IDOK), *(char*)lParam); + SetDlgItemTextA(hwndDlg, IDC_EMAIL, (char *)lParam); + EnableWindow(GetDlgItem(hwndDlg, IDOK), *(char *)lParam); return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: - GetDlgItemTextA(hwndDlg, IDC_EMAIL, (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA), 256); + GetDlgItemTextA(hwndDlg, IDC_EMAIL, (char *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA), 256); __fallthrough; case IDCANCEL: @@ -65,7 +66,7 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar switch (msg) { case WM_INITDIALOG: { - char *szText = (char*)lParam; + char *szText = (char *)lParam; int i, item, countryCount; struct CountryListEntry *countries; SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); @@ -92,7 +93,7 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar switch (LOWORD(wParam)) { case IDOK: { - char *szText = (char*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + char *szText = (char *)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); int isValid = 1; GetDlgItemTextA(hwndDlg, IDC_PHONE, szText, 252); if (mir_strlen(szText) < 7 || szText[0] != '+') isValid = 0; @@ -177,7 +178,7 @@ static INT_PTR CALLBACK EditUserPhoneDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar return FALSE; } -static int IsOverEmail(HWND hwndDlg, wchar_t* szEmail, int cchEmail) +static int IsOverEmail(HWND hwndDlg, wchar_t *szEmail, int cchEmail) { HWND hwndEmails = GetDlgItem(hwndDlg, IDC_EMAILS); @@ -217,168 +218,167 @@ static int IsOverEmail(HWND hwndDlg, wchar_t* szEmail, int cchEmail) INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { int i; + RECT rc; + LOGFONT lf; + MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); switch (msg) { case WM_INITDIALOG: TranslateDialogDefault(hwndDlg); SetWindowLongPtr(hwndDlg, GWLP_USERDATA, (LONG_PTR)lParam); - if (hEmailFont) DeleteObject(hEmailFont); - { - LOGFONT lf; - hEmailFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_EMAILS, WM_GETFONT, 0, 0); - GetObject(hEmailFont, sizeof(lf), &lf); - lf.lfUnderline = 1; - hEmailFont = CreateFontIndirect(&lf); - } + + if (hEmailFont) + DeleteObject(hEmailFont); + + hEmailFont = (HFONT)SendDlgItemMessage(hwndDlg, IDC_EMAILS, WM_GETFONT, 0, 0); + GetObject(hEmailFont, sizeof(lf), &lf); + lf.lfUnderline = 1; + hEmailFont = CreateFontIndirect(&lf); + if (hHandCursor == nullptr) hHandCursor = LoadCursor(nullptr, IDC_HAND); - { - RECT rc; - GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc); - rc.right -= GetSystemMetrics(SM_CXVSCROLL); - - LVCOLUMN lvc; - lvc.mask = LVCF_WIDTH; - ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_EMAILS), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); - ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PHONES), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); - lvc.cx = rc.right / 4; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 0, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 0, &lvc); - lvc.cx = rc.right - rc.right / 4 - 40; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 1, &lvc); - lvc.cx = rc.right - rc.right / 4 - 90; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 1, &lvc); - lvc.cx = 50; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 2, &lvc); - lvc.cx = 20; - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 2, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 3, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 3, &lvc); - ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 4, &lvc); - } + + GetClientRect(GetDlgItem(hwndDlg, IDC_EMAILS), &rc); + rc.right -= GetSystemMetrics(SM_CXVSCROLL); + + LVCOLUMN lvc; + lvc.mask = LVCF_WIDTH; + ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_EMAILS), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); + ListView_SetExtendedListViewStyleEx(GetDlgItem(hwndDlg, IDC_PHONES), LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP, LVS_EX_FULLROWSELECT | LVS_EX_INFOTIP); + lvc.cx = rc.right / 4; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 0, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 0, &lvc); + lvc.cx = rc.right - rc.right / 4 - 40; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 1, &lvc); + lvc.cx = rc.right - rc.right / 4 - 90; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 1, &lvc); + lvc.cx = 50; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 2, &lvc); + lvc.cx = 20; + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 2, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_EMAILS), 3, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 3, &lvc); + ListView_InsertColumn(GetDlgItem(hwndDlg, IDC_PHONES), 4, &lvc); break; case M_REMAKELISTS: - { - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); - if (hContact != NULL) { - char *szProto = Proto_GetBaseAccountName(hContact); - if (szProto == nullptr) - break; - - //e-mails - ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_EMAILS)); - - char idstr[33]; - wchar_t idstr2[33]; - DBVARIANT dbv; - - LVITEM lvi; - lvi.mask = LVIF_TEXT | LVIF_PARAM; - lvi.lParam = -1; - lvi.iSubItem = 0; - lvi.iItem = 0; - for (i = -1;; i++) { - if (i == -1) { - if (db_get_ws(hContact, szProto, "e-mail", &dbv)) - continue; - lvi.pszText = TranslateT("Primary"); - } - else { - mir_snprintf(idstr, "e-mail%d", i); - if (db_get_ws(hContact, szProto, idstr, &dbv)) - break; + if (hContact != NULL) { + char *szProto = Proto_GetBaseAccountName(hContact); + if (szProto == nullptr) + break; - lvi.pszText = idstr2; - mir_snwprintf(idstr2, L"%d", i + 2); - } - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.pwszVal); - db_free(&dbv); - lvi.iItem++; + //e-mails + ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_EMAILS)); + + char idstr[33]; + wchar_t idstr2[33]; + DBVARIANT dbv; + + LVITEM lvi; + lvi.mask = LVIF_TEXT | LVIF_PARAM; + lvi.lParam = -1; + lvi.iSubItem = 0; + lvi.iItem = 0; + for (i = -1;; i++) { + if (i == -1) { + if (db_get_ws(hContact, szProto, "e-mail", &dbv)) + continue; + lvi.pszText = TranslateT("Primary"); } - lvi.iSubItem = 0; - for (i = 0;; i++) { - lvi.lParam = i; - mir_snprintf(idstr, "Mye-mail%d", i); - if (g_plugin.getWString(hContact, idstr, &dbv)) + else { + mir_snprintf(idstr, "e-mail%d", i); + if (db_get_ws(hContact, szProto, idstr, &dbv)) break; + lvi.pszText = idstr2; - mir_snwprintf(idstr2, TranslateT("Custom %d"), i + 1); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.pwszVal); - db_free(&dbv); - lvi.iItem++; + mir_snwprintf(idstr2, L"%d", i + 2); } - lvi.mask = LVIF_PARAM; - lvi.lParam = -2; ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); - //phones - ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES)); - lvi.mask = LVIF_TEXT | LVIF_PARAM; - lvi.lParam = -1; - lvi.iSubItem = 0; - lvi.iItem = 0; - if (!db_get_ws(hContact, szProto, "Phone", &dbv)) { - lvi.pszText = TranslateT("Primary"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); - db_free(&dbv); - lvi.iItem++; - } - if (!db_get_ws(hContact, szProto, "Fax", &dbv)) { - lvi.pszText = TranslateT("Fax"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); - db_free(&dbv); - lvi.iItem++; - } - if (!db_get_ws(hContact, szProto, "Cellular", &dbv)) { - lvi.pszText = TranslateT("Mobile"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - if (mir_strlen(dbv.pszVal) > 4 && !mir_strcmp(dbv.pszVal + mir_strlen(dbv.pszVal) - 4, " SMS")) { - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, L"y"); - dbv.pwszVal[mir_wstrlen(dbv.pwszVal) - 4] = '\0'; - } - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); - db_free(&dbv); - lvi.iItem++; - } - if (!db_get_ws(hContact, szProto, "CompanyPhone", &dbv)) { - lvi.pszText = TranslateT("Work phone"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); - db_free(&dbv); - lvi.iItem++; - } - if (!db_get_ws(hContact, szProto, "CompanyFax", &dbv)) { - lvi.pszText = TranslateT("Work fax"); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); - db_free(&dbv); - lvi.iItem++; - } - lvi.iSubItem = 0; - for (i = 0;; i++) { - lvi.lParam = i; - mir_snprintf(idstr, "MyPhone%d", i); - if (g_plugin.getWString(hContact, idstr, &dbv)) - break; - lvi.pszText = idstr2; - mir_snwprintf(idstr2, TranslateT("Custom %d"), i + 1); - ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); - if (mir_wstrlen(dbv.pwszVal) > 4 && !mir_wstrcmp(dbv.pwszVal + mir_wstrlen(dbv.pwszVal) - 4, L" SMS")) { - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, L"y"); - dbv.pwszVal[mir_wstrlen(dbv.pwszVal) - 4] = '\0'; - } - ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); - db_free(&dbv); - lvi.iItem++; + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.pwszVal); + db_free(&dbv); + lvi.iItem++; + } + lvi.iSubItem = 0; + for (i = 0;; i++) { + lvi.lParam = i; + mir_snprintf(idstr, "Mye-mail%d", i); + if (g_plugin.getWString(hContact, idstr, &dbv)) + break; + lvi.pszText = idstr2; + mir_snwprintf(idstr2, TranslateT("Custom %d"), i + 1); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_EMAILS), lvi.iItem, 1, dbv.pwszVal); + db_free(&dbv); + lvi.iItem++; + } + lvi.mask = LVIF_PARAM; + lvi.lParam = -2; + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_EMAILS), &lvi); + //phones + ListView_DeleteAllItems(GetDlgItem(hwndDlg, IDC_PHONES)); + lvi.mask = LVIF_TEXT | LVIF_PARAM; + lvi.lParam = -1; + lvi.iSubItem = 0; + lvi.iItem = 0; + if (!db_get_ws(hContact, szProto, "Phone", &dbv)) { + lvi.pszText = TranslateT("Primary"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); + db_free(&dbv); + lvi.iItem++; + } + if (!db_get_ws(hContact, szProto, "Fax", &dbv)) { + lvi.pszText = TranslateT("Fax"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); + db_free(&dbv); + lvi.iItem++; + } + if (!db_get_ws(hContact, szProto, "Cellular", &dbv)) { + lvi.pszText = TranslateT("Mobile"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + if (mir_strlen(dbv.pszVal) > 4 && !mir_strcmp(dbv.pszVal + mir_strlen(dbv.pszVal) - 4, " SMS")) { + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, L"y"); + dbv.pwszVal[mir_wstrlen(dbv.pwszVal) - 4] = '\0'; } - lvi.mask = LVIF_PARAM; - lvi.lParam = -2; + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); + db_free(&dbv); + lvi.iItem++; + } + if (!db_get_ws(hContact, szProto, "CompanyPhone", &dbv)) { + lvi.pszText = TranslateT("Work phone"); ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); + db_free(&dbv); + lvi.iItem++; } + if (!db_get_ws(hContact, szProto, "CompanyFax", &dbv)) { + lvi.pszText = TranslateT("Work fax"); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); + db_free(&dbv); + lvi.iItem++; + } + lvi.iSubItem = 0; + for (i = 0;; i++) { + lvi.lParam = i; + mir_snprintf(idstr, "MyPhone%d", i); + if (g_plugin.getWString(hContact, idstr, &dbv)) + break; + lvi.pszText = idstr2; + mir_snwprintf(idstr2, TranslateT("Custom %d"), i + 1); + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); + if (mir_wstrlen(dbv.pwszVal) > 4 && !mir_wstrcmp(dbv.pwszVal + mir_wstrlen(dbv.pwszVal) - 4, L" SMS")) { + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 2, L"y"); + dbv.pwszVal[mir_wstrlen(dbv.pwszVal) - 4] = '\0'; + } + ListView_SetItemText(GetDlgItem(hwndDlg, IDC_PHONES), lvi.iItem, 1, dbv.pwszVal); + db_free(&dbv); + lvi.iItem++; + } + lvi.mask = LVIF_PARAM; + lvi.lParam = -2; + ListView_InsertItem(GetDlgItem(hwndDlg, IDC_PHONES), &lvi); } break; @@ -394,7 +394,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP switch (((LPNMHDR)lParam)->code) { case NM_CUSTOMDRAW: { - NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW*)lParam; + NMLVCUSTOMDRAW *nm = (NMLVCUSTOMDRAW *)lParam; switch (nm->nmcd.dwDrawStage) { case CDDS_PREPAINT: case CDDS_ITEMPREPAINT: @@ -402,7 +402,6 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP return TRUE; case CDDS_SUBITEM | CDDS_ITEMPREPAINT: - RECT rc; ListView_GetSubItemRect(nm->nmcd.hdr.hwndFrom, nm->nmcd.dwItemSpec, nm->iSubItem, LVIR_LABEL, &rc); if (nm->iSubItem == 1 && nm->nmcd.hdr.idFrom == IDC_EMAILS) { HFONT hoFont; @@ -438,8 +437,7 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; case NM_CLICK: - NMLISTVIEW *nm = (NMLISTVIEW*)lParam; - MCONTACT hContact = (MCONTACT)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); + NMLISTVIEW *nm = (NMLISTVIEW *)lParam; char *szIdTemplate = (nm->hdr.idFrom == IDC_PHONES) ? "MyPhone%d" : "Mye-mail%d"; wchar_t szEmail[256]; @@ -516,7 +514,9 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP break; case WM_SETCURSOR: - if (LOWORD(lParam) != HTCLIENT) break; + if (LOWORD(lParam) != HTCLIENT) + break; + if (GetForegroundWindow() == GetParent(hwndDlg)) { POINT pt; GetCursorPos(&pt); diff --git a/src/core/stduserinfo/src/stdinfo.cpp b/src/core/stduserinfo/src/stdinfo.cpp index 12dddb759b..9d280ef1c1 100644 --- a/src/core/stduserinfo/src/stdinfo.cpp +++ b/src/core/stduserinfo/src/stdinfo.cpp @@ -38,8 +38,8 @@ INT_PTR CALLBACK ContactDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule, char *szSetting, int special) { - char str[80], *pstr = nullptr; - wchar_t *ptstr = nullptr; + char *pstr = nullptr; + wchar_t *pwstr = nullptr, wstr[80]; DBVARIANT dbv = { DBVT_DELETED }; @@ -53,61 +53,61 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule switch (dbv.type) { case DBVT_BYTE: if (special == SVS_GENDER) { - if (dbv.cVal == 'M') ptstr = TranslateT("Male"); - else if (dbv.cVal == 'F') ptstr = TranslateT("Female"); + if (dbv.cVal == 'M') pwstr = TranslateT("Male"); + else if (dbv.cVal == 'F') pwstr = TranslateT("Female"); else unspecified = 1; } else if (special == SVS_MONTH) { if (dbv.bVal > 0 && dbv.bVal <= 12) { - pstr = str; - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1 - 1 + dbv.bVal, str, _countof(str)); + pwstr = wstr; + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SABBREVMONTHNAME1 - 1 + dbv.bVal, wstr, _countof(wstr)); } else unspecified = 1; } else if (special == SVS_TIMEZONE) { if (dbv.cVal == -100) unspecified = 1; else { - pstr = str; - mir_snprintf(str, dbv.cVal ? "UTC%+d:%02d" : "UTC", -dbv.cVal / 2, (dbv.cVal & 1) * 30); + pwstr = wstr; + mir_snwprintf(wstr, dbv.cVal ? L"UTC%+d:%02d" : L"UTC", -dbv.cVal / 2, (dbv.cVal & 1) * 30); } } else if (special == SVS_MARITAL) { switch (dbv.cVal) { case 0: - ptstr = TranslateT(""); + pwstr = TranslateT(""); break; case 10: - ptstr = TranslateT("Single"); + pwstr = TranslateT("Single"); break; case 11: - ptstr = TranslateT("Close relationships"); + pwstr = TranslateT("Close relationships"); break; case 12: - ptstr = TranslateT("Engaged"); + pwstr = TranslateT("Engaged"); break; case 20: - ptstr = TranslateT("Married"); + pwstr = TranslateT("Married"); break; case 30: - ptstr = TranslateT("Divorced"); + pwstr = TranslateT("Divorced"); break; case 31: - ptstr = TranslateT("Separated"); + pwstr = TranslateT("Separated"); break; case 40: - ptstr = TranslateT("Widowed"); + pwstr = TranslateT("Widowed"); break; case 50: - ptstr = TranslateT("Actively searching"); + pwstr = TranslateT("Actively searching"); break; case 60: - ptstr = TranslateT("In love"); + pwstr = TranslateT("In love"); break; case 70: - ptstr = TranslateT("It's complicated"); + pwstr = TranslateT("It's complicated"); break; case 80: - ptstr = TranslateT("In a civil union"); + pwstr = TranslateT("In a civil union"); break; default: unspecified = 1; @@ -115,7 +115,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule } else { unspecified = (special == SVS_ZEROISUNSPEC && dbv.bVal == 0); - pstr = _itoa(special == SVS_SIGNED ? dbv.cVal : dbv.bVal, str, 10); + pwstr = _itow(special == SVS_SIGNED ? dbv.cVal : dbv.bVal, wstr, 10); } break; @@ -126,18 +126,18 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule char szSettingName[100]; mir_snprintf(szSettingName, "%sName", szSetting); if (!db_get_ws(hContact, szModule, szSettingName, &dbv)) { - ptstr = dbv.pwszVal; + pwstr = dbv.pwszVal; unspecified = false; break; } } - pstr = Translate((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, wSave, 0)); - unspecified = pstr == nullptr; + pwstr = TranslateW(_A2T((char*)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, wSave, 0))); + unspecified = pwstr == nullptr; } else { unspecified = (special == SVS_ZEROISUNSPEC && dbv.wVal == 0); - pstr = _itoa(special == SVS_SIGNED ? dbv.sVal : dbv.wVal, str, 10); + pwstr = _itow(special == SVS_SIGNED ? dbv.sVal : dbv.wVal, wstr, 10); } break; @@ -146,10 +146,12 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule if (special == SVS_IP) { struct in_addr ia; ia.S_un.S_addr = htonl(dbv.dVal); - pstr = inet_ntoa(ia); - if (dbv.dVal == 0) unspecified = 1; + mir_wstrncpy(wstr, _A2T(inet_ntoa(ia)), _countof(wstr)); + pwstr = wstr; + if (dbv.dVal == 0) + unspecified = 1; } - else pstr = _itoa(special == SVS_SIGNED ? dbv.lVal : dbv.dVal, str, 10); + else pwstr = _itow(special == SVS_SIGNED ? dbv.lVal : dbv.dVal, wstr, 10); break; case DBVT_ASCIIZ: @@ -160,10 +162,7 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule case DBVT_UTF8: unspecified = (special == SVS_ZEROISUNSPEC && dbv.pszVal[0] == '\0'); if (!unspecified) { - WCHAR *wszStr; - mir_utf8decode(dbv.pszVal, &wszStr); - SetDlgItemTextW(hwndDlg, idCtrl, TranslateW(wszStr)); - mir_free(wszStr); + SetDlgItemTextW(hwndDlg, idCtrl, TranslateW(ptrW(mir_utf8decodeW(dbv.pszVal)))); goto LBL_Exit; } @@ -172,16 +171,16 @@ static void SetValue(HWND hwndDlg, int idCtrl, MCONTACT hContact, char *szModule break; default: - pstr = str; - mir_strcpy(str, "???"); + pwstr = wstr; + mir_wstrcpy(wstr, L"???"); break; } } if (unspecified) SetDlgItemText(hwndDlg, idCtrl, TranslateT("")); - else if (ptstr != nullptr) - SetDlgItemText(hwndDlg, idCtrl, ptstr); + else if (pwstr != nullptr) + SetDlgItemText(hwndDlg, idCtrl, pwstr); else SetDlgItemTextA(hwndDlg, idCtrl, pstr); diff --git a/src/core/stduserinfo/src/userinfo.cpp b/src/core/stduserinfo/src/userinfo.cpp index dcb7d77f3c..841172d4b7 100644 --- a/src/core/stduserinfo/src/userinfo.cpp +++ b/src/core/stduserinfo/src/userinfo.cpp @@ -40,15 +40,15 @@ struct DetailsPageInit struct DetailsPageData : public MNonCopyable { DLGTEMPLATE *pTemplate; - HINSTANCE hInst; - DLGPROC dlgProc; - LPARAM dlgParam; - HWND hwnd; - HTREEITEM hItem; - HPLUGIN pPlugin; - int changed; - DWORD dwFlags; - wchar_t *pwszTitle, *pwszTab; + HINSTANCE hInst; + DLGPROC dlgProc; + LPARAM dlgParam; + HWND hwnd; + HTREEITEM hItem; + HPLUGIN pPlugin; + int changed; + DWORD dwFlags; + wchar_t *pwszTitle, *pwszTab; ~DetailsPageData() { @@ -92,12 +92,12 @@ class CUserInfoDlg : public CDlgBase RECT m_rcDisplay, m_rcDisplayTab; int m_updateAnimFrame = 0; wchar_t m_szUpdating[64]; - int *m_infosUpdated = 0; + int *m_infosUpdated = 0; HANDLE m_hProtoAckEvent = 0; HANDLE m_hDllUnloadEvent = 0; - HWND m_tabs; + HWND m_tabs; OBJLIST m_pages; void BuildTree() -- cgit v1.2.3