From 3abea4a9b102456ccbb5bc4b6ca1338fd7e83d1d Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 7 Nov 2023 13:14:28 +0300 Subject: =?UTF-8?q?fixes=20#3863=20(Sametime:=20=D0=BD=D0=B5=20=D0=B2?= =?UTF-8?q?=D1=81=D0=B5=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D0=B8=20=D0=BF?= =?UTF-8?q?=D0=BE=D0=BF=D0=B0=D0=B4=D0=B0=D1=8E=D1=82=20=D0=B2=20=D1=8F?= =?UTF-8?q?=D0=B7=D1=8B=D0=BA=D0=BE=D0=B2=D0=BE=D0=B9=20=D0=BF=D0=B0=D0=BA?= =?UTF-8?q?=D0=B5=D1=82)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Sametime/src/options.cpp | 47 ++++++++++++++------------------------ 1 file changed, 17 insertions(+), 30 deletions(-) (limited to 'protocols') diff --git a/protocols/Sametime/src/options.cpp b/protocols/Sametime/src/options.cpp index d34b6b5505..ea5813ad56 100644 --- a/protocols/Sametime/src/options.cpp +++ b/protocols/Sametime/src/options.cpp @@ -59,36 +59,22 @@ int client_ids[NUM_IDS] = { 0xFFFF }; - #define DEFAULT_CV_MAJOR (0x001e) #define DEFAULT_CV_MINOR (0x1f4b) -#define NUM_CVS 5 - -wchar_t* CV_names[NUM_CVS] = { - L"Sametime (Use old client version)", - L"Sametime (Miranda default)", - L"Sametime 8", - L"Sametime 8.5.1", - L"Sametime 8.5.2" -}; -int CV_major[NUM_CVS] = { - MW_PROTOCOL_VERSION_MAJOR, - 0x001e, - 0x001e, - 0x001e, - 0x001e -}; -int CV_minor[NUM_CVS] = { - MW_PROTOCOL_VERSION_MINOR, - 0x196f, - 0x1f4b, - 0x213f, - 0x2149 +struct +{ + const wchar_t *pwszName; + int major, minor; +} +static versions[] = { + { LPGENW("Sametime (Use old client version)"), MW_PROTOCOL_VERSION_MAJOR, MW_PROTOCOL_VERSION_MINOR }, + { LPGENW("Sametime (Miranda default)"), 0x001e, 0x196f }, + { LPGENW("Sametime 8"), 0x001e, 0x1f4b }, + { LPGENW("Sametime 8.5.1"), 0x001e, 0x213f }, + { LPGENW("Sametime 8.5.2"), 0x001e, 0x2149 }, }; - - static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { CSametimeProto* proto = (CSametimeProto*)GetWindowLongPtr(hwndDlg, GWLP_USERDATA); @@ -150,10 +136,11 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENTVN, CB_RESETCONTENT, 0, 0); pos = 0; - for (int i = 0; i < NUM_CVS; i++) { - pos = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENTVN, CB_ADDSTRING, -1, (LPARAM)CV_names[i]); + for (int i = 0; i < _countof(versions); i++) { + auto &CV = versions[i]; + pos = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENTVN, CB_ADDSTRING, -1, (LPARAM)TranslateW(CV.pwszName)); SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENTVN, CB_SETITEMDATA, pos, i); - if (CV_major[i] == proto->options.client_versionMajor && CV_minor[i] == proto->options.client_versionMinor) { + if (CV.major == proto->options.client_versionMajor && CV.minor == proto->options.client_versionMinor) { found = true; SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENTVN, CB_SETCURSEL, pos, 0); } @@ -309,8 +296,8 @@ static INT_PTR CALLBACK DlgProcOptNet(HWND hwndDlg, UINT msg, WPARAM wParam, LPA sel = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENTVN, CB_GETCURSEL, 0, 0); int CVpos = SendDlgItemMessage(hwndDlg, IDC_CMB_CLIENTVN, CB_GETITEMDATA, sel, 0); - proto->options.client_versionMajor = CV_major[CVpos]; - proto->options.client_versionMinor = CV_minor[CVpos]; + proto->options.client_versionMajor = versions[CVpos].major; + proto->options.client_versionMinor = versions[CVpos].minor; if (IsDlgButtonChecked(hwndDlg, IDC_RAD_ERRMB)) proto->options.err_method = ED_MB; else if (IsDlgButtonChecked(hwndDlg, IDC_RAD_ERRBAL)) proto->options.err_method = ED_BAL; -- cgit v1.2.3