From fee3fee5d2cda4766964b4c3a61a8b1d2ff5e128 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 7 Apr 2025 13:13:36 +0300 Subject: =?UTF-8?q?fixes=20#4961=20(Weather:=20=D0=BD=D0=B5=20=D0=B2=D1=81?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5=D1=87=D0=B8=D1=81=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D0=B2=20=D0=BD=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=D0=BA=D0=B0=D1=85=20=D0=BF=D0=BB=D0=B0=D0=B3=D0=B8=D0=BD?= =?UTF-8?q?=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Weather/src/proto.h | 1 + protocols/Weather/src/stdafx.h | 1 - protocols/Weather/src/weather_opt.cpp | 2 +- protocols/Weather/src/weather_update.cpp | 27 +++++++++++++++++++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/proto.h b/protocols/Weather/src/proto.h index afa5547431..e1115b65e3 100644 --- a/protocols/Weather/src/proto.h +++ b/protocols/Weather/src/proto.h @@ -181,6 +181,7 @@ class CWeatherProto : public PROTO int __cdecl OptInit(WPARAM, LPARAM); CMStringW GetTextValue(int c); + void GetVarsDescr(CMStringW &str); // popups int WPShowMessage(const wchar_t *lpzText, int kind); diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h index 70c602ed22..cf1f3240a3 100644 --- a/protocols/Weather/src/stdafx.h +++ b/protocols/Weather/src/stdafx.h @@ -147,7 +147,6 @@ void ConvertBackslashes(char *str); char *GetSearchStr(char *dis); CMStringW GetDisplay(WEATHERINFO *w, const wchar_t *dis); -void GetVarsDescr(CMStringW &str); wchar_t *GetError(int code); diff --git a/protocols/Weather/src/weather_opt.cpp b/protocols/Weather/src/weather_opt.cpp index 815fba5dd5..6203715b2a 100644 --- a/protocols/Weather/src/weather_opt.cpp +++ b/protocols/Weather/src/weather_opt.cpp @@ -418,7 +418,7 @@ public: // heading CMStringW str(TranslateT("Here is a list of custom variables that are currently available")); str += L"\n\n"; - GetVarsDescr(str); + m_proto->GetVarsDescr(str); // display the list in a message box MessageBox(nullptr, str, TranslateT("More Variables"), MB_OK | MB_ICONINFORMATION | MB_TOPMOST); diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index a64bf7e063..001a9d9eba 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -469,13 +469,32 @@ int CWeatherProto::GetWeatherData(MCONTACT hContact) return 0; } -void GetVarsDescr(CMStringW &str) +///////////////////////////////////////////////////////////////////////////////////////// + +static int enumSettings(const char *pszSetting, void *param) +{ + auto *pList = (OBJLIST*)param; + if (!pList->find((char*)pszSetting)) + pList->insert(newStr(pszSetting)); + return 0; +} + +void CWeatherProto::GetVarsDescr(CMStringW &wszDescr) { - for (int i = 1; i <= 7; i++) { - if (i != 1) + OBJLIST vars(10, mir_strcmp); + for (int i = 1; i <= 7; i++) + vars.insert(newStr(CMStringA(FORMAT, "Forecast Day %d", i))); + + for (auto &cc : AccContacts()) + db_enum_settings(cc, &enumSettings, WEATHERCONDITION, &vars); + + CMStringW str; + for (auto &it : vars) { + if (!str.IsEmpty()) str.Append(L", "); - str.AppendFormat(L"%%[Forecast Day %d]", i); + str.AppendFormat(L"%%[%S]", it); } + wszDescr += str; } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3