From 3ee53558d61ce75746f28c4a36255241895a98cb Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 3 Apr 2025 13:22:43 +0300 Subject: obsolete function removed --- protocols/Weather/src/proto.h | 1 - protocols/Weather/src/weather_addstn.cpp | 2 +- protocols/Weather/src/weather_contacts.cpp | 18 ++++++++---------- protocols/Weather/src/weather_data.cpp | 16 ++-------------- protocols/Weather/src/weather_update.cpp | 7 +++---- 5 files changed, 14 insertions(+), 30 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/proto.h b/protocols/Weather/src/proto.h index e83fee46eb..afa5547431 100644 --- a/protocols/Weather/src/proto.h +++ b/protocols/Weather/src/proto.h @@ -151,7 +151,6 @@ class CWeatherProto : public PROTO // data void ConvertDataValue(WIDATAITEM *UpdateData); void EraseAllInfo(void); - void GetStationID(MCONTACT hContact, wchar_t *id, int idlen); WEATHERINFO LoadWeatherInfo(MCONTACT hContact); MHttpResponse* RunQuery(const wchar_t *id, int days); diff --git a/protocols/Weather/src/weather_addstn.cpp b/protocols/Weather/src/weather_addstn.cpp index 1bdfb9b49d..026b9f8c67 100644 --- a/protocols/Weather/src/weather_addstn.cpp +++ b/protocols/Weather/src/weather_addstn.cpp @@ -88,7 +88,7 @@ MCONTACT CWeatherProto::AddToList(int, PROTOSEARCHRESULT *psr) // if no default station is found, set the new contact as default station if (opt.Default[0] == 0) { - GetStationID(hContact, opt.Default, _countof(opt.Default)); + wcsncpy_s(opt.Default, getMStringW(hContact, "ID"), _countof(opt.Default)); opt.DefStn = hContact; ptrW wszNick(getWStringA(hContact, "Nick")); diff --git a/protocols/Weather/src/weather_contacts.cpp b/protocols/Weather/src/weather_contacts.cpp index 2661c1b20e..2f5a08f4ef 100644 --- a/protocols/Weather/src/weather_contacts.cpp +++ b/protocols/Weather/src/weather_contacts.cpp @@ -53,13 +53,12 @@ INT_PTR CWeatherProto::ViewLog(WPARAM wParam, LPARAM lParam) // read complete forecast // wParam = current contact -INT_PTR CWeatherProto::LoadForecast(WPARAM wParam, LPARAM) +INT_PTR CWeatherProto::LoadForecast(WPARAM hContact, LPARAM) { - wchar_t id[256]; - GetStationID(wParam, id, _countof(id)); - if (id[0] != 0) { + CMStringW wszID(getMStringW(hContact, "ID")); + if (!wszID.IsEmpty()) { // set the url and open the webpage - CMStringA szUrl("https://www.visualcrossing.com/weather-forecast/" + mir_urlEncode(T2Utf(id)) + "/metric"); + CMStringA szUrl("https://www.visualcrossing.com/weather-forecast/" + mir_urlEncode(T2Utf(wszID)) + "/metric"); Utils_OpenUrl(szUrl); } return 0; @@ -69,13 +68,12 @@ INT_PTR CWeatherProto::LoadForecast(WPARAM wParam, LPARAM) // load weather map // wParam = current contact -INT_PTR CWeatherProto::WeatherMap(WPARAM wParam, LPARAM) +INT_PTR CWeatherProto::WeatherMap(WPARAM hContact, LPARAM) { - wchar_t id[256]; - GetStationID(wParam, id, _countof(id)); - if (id[0] != 0) { + CMStringW wszID(getMStringW(hContact, "ID")); + if (!wszID.IsEmpty()) { // set the url and open the webpage - CMStringA szUrl("https://www.visualcrossing.com/weather-history/" + mir_urlEncode(T2Utf(id)) + "/metric"); + CMStringA szUrl("https://www.visualcrossing.com/weather-history/" + mir_urlEncode(T2Utf(wszID)) + "/metric"); Utils_OpenUrl(szUrl); } diff --git a/protocols/Weather/src/weather_data.cpp b/protocols/Weather/src/weather_data.cpp index a02ae0dc1f..76e50ca139 100644 --- a/protocols/Weather/src/weather_data.cpp +++ b/protocols/Weather/src/weather_data.cpp @@ -25,18 +25,6 @@ saving individual weather data for a weather contact. #include "stdafx.h" -///////////////////////////////////////////////////////////////////////////////////////// -// get station ID from DB -// hContact = the current contact handle -// return value = the string for station ID - -void CWeatherProto::GetStationID(MCONTACT hContact, wchar_t *id, int idlen) -{ - // accessing the database - if (db_get_wstatic(hContact, m_szModuleName, "ID", id, idlen)) - id[0] = 0; -} - ///////////////////////////////////////////////////////////////////////////////////////// // initialize weather info by loading values from database // hContact = current contact handle @@ -49,7 +37,7 @@ WEATHERINFO CWeatherProto::LoadWeatherInfo(MCONTACT hContact) // if the string is not found in database, a value of "N/A" is stored in the field WEATHERINFO winfo; winfo.hContact = hContact; - GetStationID(hContact, winfo.id, _countof(winfo.id)); + wcsncpy_s(winfo.id, getMStringW(hContact, "ID"), _countof(winfo.id)); if (db_get_wstatic(hContact, m_szModuleName, "Nick", winfo.city, _countof(winfo.city))) wcsncpy(winfo.city, NODATA, _countof(winfo.city) - 1); @@ -121,7 +109,7 @@ void CWeatherProto::EraseAllInfo() // if no default station find, assign a new one if (opt.Default[0] == 0) { - GetStationID(hContact, opt.Default, _countof(opt.Default)); + wcsncpy_s(opt.Default, getMStringW(hContact, "ID"), _countof(opt.Default)); opt.DefStn = hContact; if (!getWString(hContact, "Nick", &dbv)) { diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index 15713e110e..58a785add5 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -403,15 +403,14 @@ static void getData(OBJLIST &arValues, const JSONNode &node) int CWeatherProto::GetWeatherData(MCONTACT hContact) { // get each part of the id's - wchar_t id[256]; - GetStationID(hContact, id, _countof(id)); - if (id[0] == 0) + CMStringW wszID(getMStringW(hContact, "ID")); + if (wszID.IsEmpty()) return INVALID_ID; uint16_t cond = NA; // download the html file from the internet - WeatherReply reply(RunQuery(id, 7)); + WeatherReply reply(RunQuery(wszID, 7)); if (!reply) return reply.error(); -- cgit v1.2.3 From f46c2504821b4c5cb03d04a2ac6cf02ddec7ce99 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 3 Apr 2025 13:55:34 +0300 Subject: static buffers are evil --- protocols/Weather/src/stdafx.h | 2 +- protocols/Weather/src/weather_conv.cpp | 59 +++++++++++++++--------------- protocols/Weather/src/weather_opt.cpp | 47 ++++++++++++------------ protocols/Weather/src/weather_popup.cpp | 4 +- protocols/Weather/src/weather_update.cpp | 24 ++++-------- protocols/Weather/src/weather_userinfo.cpp | 20 +++------- 6 files changed, 69 insertions(+), 87 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h index eec03bd13e..cf1f3240a3 100644 --- a/protocols/Weather/src/stdafx.h +++ b/protocols/Weather/src/stdafx.h @@ -146,7 +146,7 @@ void TrimString(wchar_t *str); void ConvertBackslashes(char *str); char *GetSearchStr(char *dis); -wchar_t *GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t* str); +CMStringW GetDisplay(WEATHERINFO *w, const wchar_t *dis); wchar_t *GetError(int code); diff --git a/protocols/Weather/src/weather_conv.cpp b/protocols/Weather/src/weather_conv.cpp index d9f35264b0..4d2c79f0ce 100644 --- a/protocols/Weather/src/weather_conv.cpp +++ b/protocols/Weather/src/weather_conv.cpp @@ -399,7 +399,7 @@ char* GetSearchStr(char *dis) // dis = the string to parse // return value = the parsed string -wchar_t* GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t *str) +CMStringW GetDisplay(WEATHERINFO *w, const wchar_t *dis) { wchar_t lpzDate[32], chr; char name[256], temp[2]; @@ -407,7 +407,7 @@ wchar_t* GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t *str) size_t i; // Clear the string - str[0] = 0; + CMStringW str; // looking character by character for (i = 0; i < mir_wstrlen(dis); i++) { @@ -416,10 +416,10 @@ wchar_t* GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t *str) i++; chr = dis[i]; switch (chr) { - case '%': mir_wstrcat(str, L"%"); break; - case 't': mir_wstrcat(str, L"\t"); break; - case 'n': mir_wstrcat(str, L"\r\n"); break; - case '\\': mir_wstrcat(str, L"\\"); break; + case '%': str.Append(L"%"); break; + case 't': str.Append(L"\t"); break; + case 'n': str.Append(L"\r\n"); break; + case '\\': str.Append(L"\\"); break; } } @@ -430,29 +430,31 @@ wchar_t* GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t *str) // turn capitalized characters to small case if (chr < 'a' && chr != '[' && chr != '%') chr = (char)((int)chr + 32); switch (chr) { - case 'c': mir_wstrcat(str, w->cond); break; + case 'c': str.Append(w->cond); break; case 'd': // get the current date GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, lpzDate, _countof(lpzDate)); - mir_wstrcat(str, lpzDate); break; - case 'e': mir_wstrcat(str, w->dewpoint); break; - case 'f': mir_wstrcat(str, w->feel); break; - case 'h': mir_wstrcat(str, w->high); break; - case 'i': mir_wstrcat(str, w->winddir); break; - case 'l': mir_wstrcat(str, w->low); break; - case 'm': mir_wstrcat(str, w->humid); break; - case 'n': mir_wstrcat(str, w->city); break; - case 'p': mir_wstrcat(str, w->pressure); break; - case 'r': mir_wstrcat(str, w->sunrise); break; - case 's': mir_wstrcat(str, w->id); break; - case 't': mir_wstrcat(str, w->temp); break; + str.Append(lpzDate); break; + case 'e': str.Append(w->dewpoint); break; + case 'f': str.Append(w->feel); break; + case 'h': str.Append(w->high); break; + case 'i': str.Append(w->winddir); break; + case 'l': str.Append(w->low); break; + case 'm': str.Append(w->humid); break; + case 'n': str.Append(w->city); break; + case 'p': str.Append(w->pressure); break; + case 'r': str.Append(w->sunrise); break; + case 's': str.Append(w->id); break; + case 't': str.Append(w->temp); break; case 'u': - if (mir_wstrcmp(w->update, NODATA)) mir_wstrcat(str, w->update); - else mir_wstrcat(str, TranslateT("")); + if (mir_wstrcmp(w->update, NODATA)) + str.Append(w->update); + else + str.Append(TranslateT("")); break; - case 'v': mir_wstrcat(str, w->vis); break; - case 'w': mir_wstrcat(str, w->wind); break; - case 'y': mir_wstrcat(str, w->sunset); break; - case '%': mir_wstrcat(str, L"%"); break; + case 'v': str.Append(w->vis); break; + case 'w': str.Append(w->wind); break; + case 'y': str.Append(w->sunset); break; + case '%': str.Append(L"%"); break; case '[': // custom variables i++; name[0] = 0; @@ -464,17 +466,14 @@ wchar_t* GetDisplay(WEATHERINFO *w, const wchar_t *dis, wchar_t *str) // access the database to get its value if (!db_get_ws(w->hContact, WEATHERCONDITION, name, &dbv)) { if (dbv.pwszVal != TranslateW(NODATA) && dbv.pwszVal != TranslateT("")) - mir_wstrcat(str, dbv.pwszVal); + str.Append(dbv.pwszVal); db_free(&dbv); } break; } } // if the character is not a variable, write the original character to the new string - else { - mir_snwprintf(lpzDate, L"%c", dis[i]); - mir_wstrcat(str, lpzDate); - } + else str.AppendChar(dis[i]); } return str; diff --git a/protocols/Weather/src/weather_opt.cpp b/protocols/Weather/src/weather_opt.cpp index a0b42e21be..015fda2c6c 100644 --- a/protocols/Weather/src/weather_opt.cpp +++ b/protocols/Weather/src/weather_opt.cpp @@ -367,8 +367,8 @@ public: bool OnApply() override { // save the option - wchar_t textstr[MAX_TEXT_SIZE]; for (auto &it : controls) { + wchar_t textstr[MAX_TEXT_SIZE]; GetDlgItemText(m_hwnd, it.id, textstr, _countof(textstr)); if (!mir_wstrcmpi(textstr, GetDefaultText(it.c))) m_proto->delSetting(it.setting); @@ -384,42 +384,41 @@ public: void onClick_TM(CCtrlButton *pButton) { // display the menu - RECT pos; - GetWindowRect(pButton->GetHwnd(), &pos); HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_TMMENU)); HMENU hMenu1 = GetSubMenu(hMenu, 0); TranslateMenu(hMenu1); - { - auto &var = controls[pButton->GetCtrlId() - IDC_TM1]; - - switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, m_hwnd, nullptr)) { - case ID_MPREVIEW: - { - // show the preview in a message box, using the weather data from the default station - WEATHERINFO winfo = m_proto->LoadWeatherInfo(m_proto->opt.DefStn); - wchar_t buf[MAX_TEXT_SIZE], str[4096]; - GetDlgItemTextW(m_hwnd, var.id, buf, _countof(buf)); - GetDisplay(&winfo, buf, str); - MessageBox(nullptr, str, TranslateT("Weather Protocol Text Preview"), MB_OK | MB_TOPMOST); - } - break; - - case ID_MRESET: - SetDlgItemTextW(m_hwnd, var.id, GetDefaultText(var.c)); - break; + + auto &var = controls[pButton->GetCtrlId() - IDC_TM1]; + + RECT pos; + GetWindowRect(pButton->GetHwnd(), &pos); + switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, m_hwnd, nullptr)) { + case ID_MPREVIEW: + { + // show the preview in a message box, using the weather data from the default station + WEATHERINFO winfo = m_proto->LoadWeatherInfo(m_proto->opt.DefStn); + wchar_t buf[MAX_TEXT_SIZE]; + GetDlgItemTextW(m_hwnd, var.id, buf, _countof(buf)); + MessageBox(nullptr, GetDisplay(&winfo, buf), TranslateT("Weather Protocol Text Preview"), MB_OK | MB_TOPMOST); } - DestroyMenu(hMenu); + break; + + case ID_MRESET: + SetDlgItemTextW(m_hwnd, var.id, GetDefaultText(var.c)); + break; } + DestroyMenu(hMenu); } void onClick_Reset(CCtrlButton *) { // left click action selection menu - RECT pos; - GetWindowRect(btnReset.GetHwnd(), &pos); HMENU hMenu = LoadMenu(g_plugin.getInst(), MAKEINTRESOURCE(IDR_TMENU)); HMENU hMenu1 = GetSubMenu(hMenu, 0); TranslateMenu(hMenu1); + + RECT pos; + GetWindowRect(btnReset.GetHwnd(), &pos); switch (TrackPopupMenu(hMenu1, TPM_LEFTBUTTON | TPM_RETURNCMD, pos.left, pos.bottom, 0, m_hwnd, nullptr)) { case ID_T1: // reset to the strings in memory, discard all changes diff --git a/protocols/Weather/src/weather_popup.cpp b/protocols/Weather/src/weather_popup.cpp index 91dcf51cb9..b9f938e41d 100644 --- a/protocols/Weather/src/weather_popup.cpp +++ b/protocols/Weather/src/weather_popup.cpp @@ -120,8 +120,8 @@ int CWeatherProto::WeatherPopup(MCONTACT hContact, bool bAlways) POPUPDATAW ppd; ppd.lchContact = hContact; ppd.PluginData = ppd.lchIcon = GetStatusIcon(winfo.hContact); - GetDisplay(&winfo, GetTextValue('P'), ppd.lpwzContactName); - GetDisplay(&winfo, GetTextValue('p'), ppd.lpwzText); + wcsncpy_s(ppd.lpwzContactName, GetDisplay(&winfo, GetTextValue('P')), _TRUNCATE); + wcsncpy_s(ppd.lpwzText, GetDisplay(&winfo, GetTextValue('p')), _TRUNCATE); ppd.PluginWindowProc = PopupDlgProc; ppd.colorBack = (opt.UseWinColors) ? GetSysColor(COLOR_BTNFACE) : opt.BGColour; ppd.colorText = (opt.UseWinColors) ? GetSysColor(COLOR_WINDOWTEXT) : opt.TextColour; diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index 58a785add5..3f189274e5 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -32,7 +32,6 @@ menu items). int CWeatherProto::UpdateWeather(MCONTACT hContact) { - wchar_t str2[MAX_TEXT_SIZE]; DBVARIANT dbv; BOOL Ch = FALSE; @@ -128,22 +127,18 @@ int CWeatherProto::UpdateWeather(MCONTACT hContact) setWord(hContact, "Status", iStatus); AvatarDownloaded(hContact); - GetDisplay(&winfo, GetTextValue('C'), str2); - db_set_ws(hContact, "CList", "MyHandle", str2); + db_set_ws(hContact, "CList", "MyHandle", GetDisplay(&winfo, GetTextValue('C'))); - GetDisplay(&winfo, GetTextValue('S'), str2); - if (str2[0]) + CMStringW str2(GetDisplay(&winfo, GetTextValue('S'))); + if (!str2.IsEmpty()) db_set_ws(hContact, "CList", "StatusMsg", str2); else db_unset(hContact, "CList", "StatusMsg"); - - ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, nullptr, (LPARAM)(str2[0] ? str2 : nullptr)); + ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, nullptr, (LPARAM)(str2.IsEmpty() ? nullptr : str2.c_str())); // save descriptions in MyNotes - GetDisplay(&winfo, GetTextValue('N'), str2); - db_set_ws(hContact, "UserInfo", "MyNotes", str2); - GetDisplay(&winfo, GetTextValue('X'), str2); - db_set_ws(hContact, WEATHERCONDITION, "WeatherInfo", str2); + db_set_ws(hContact, "UserInfo", "MyNotes", GetDisplay(&winfo, GetTextValue('N'))); + db_set_ws(hContact, WEATHERCONDITION, "WeatherInfo", GetDisplay(&winfo, GetTextValue('X'))); // set the update tag setByte(hContact, "IsUpdated", TRUE); @@ -174,8 +169,7 @@ int CWeatherProto::UpdateWeather(MCONTACT hContact) db_free(&dbv); if (file != nullptr) { // write data to the file and close - GetDisplay(&winfo, GetTextValue('E'), str2); - fputws(str2, file); + fputws(GetDisplay(&winfo, GetTextValue('E')), file); fclose(file); } } @@ -183,9 +177,7 @@ int CWeatherProto::UpdateWeather(MCONTACT hContact) if (getByte(hContact, "History")) { // internal log using history - GetDisplay(&winfo, GetTextValue('H'), str2); - - T2Utf szMessage(str2); + T2Utf szMessage(GetDisplay(&winfo, GetTextValue('H'))); DBEVENTINFO dbei = {}; dbei.szModule = m_szModuleName; diff --git a/protocols/Weather/src/weather_userinfo.cpp b/protocols/Weather/src/weather_userinfo.cpp index 0679ddf6e9..1207d01b4a 100644 --- a/protocols/Weather/src/weather_userinfo.cpp +++ b/protocols/Weather/src/weather_userinfo.cpp @@ -151,8 +151,6 @@ public: { m_list.DeleteAllItems(); - wchar_t str[4096]; - // load weather information from the contact into the WEATHERINFO struct WEATHERINFO winfo = m_proto->LoadWeatherInfo(hContact); // check if data exist. If not, display error message box @@ -160,13 +158,11 @@ public: SetDlgItemTextW(m_hwnd, IDC_MTEXT, TranslateT("No information available.\r\nPlease update weather condition first.")); else { // set the display text and show the message box - GetDisplay(&winfo, m_proto->GetTextValue('B'), str); - SetDlgItemTextW(m_hwnd, IDC_MTEXT, str); + SetDlgItemTextW(m_hwnd, IDC_MTEXT, GetDisplay(&winfo, m_proto->GetTextValue('B'))); } - GetDisplay(&winfo, L"%c, %t", str); SetWindowTextW(m_hwnd, winfo.city); - SetDlgItemTextW(m_hwnd, IDC_HEADERBAR, str); + SetDlgItemTextW(m_hwnd, IDC_HEADERBAR, GetDisplay(&winfo, L"%c, %t")); // get all the settings and store them in a temporary list LIST arSettings(10); @@ -311,9 +307,8 @@ public: ppro = (CWeatherProto *)Proto_GetContactInstance(m_hContact); // load weather info for the contact - wchar_t str[MAX_TEXT_SIZE]; WEATHERINFO w = ppro->LoadWeatherInfo(m_hContact); - SetDlgItemText(m_hwnd, IDC_INFO1, GetDisplay(&w, TranslateT("Current condition for %n"), str)); + SetDlgItemText(m_hwnd, IDC_INFO1, GetDisplay(&w, TranslateT("Current condition for %n"))); SendDlgItemMessage(m_hwnd, IDC_INFOICON, STM_SETICON, (WPARAM)ppro->GetStatusIconBig(m_hContact), 0); @@ -327,19 +322,16 @@ public: SendDlgItemMessage(m_hwnd, IDC_INFO2, WM_SETFONT, (WPARAM)CreateFontIndirect(&lf), 0); // set the text for displaying other current weather conditions data - GetDisplay(&w, L"%c %t", str); - SetDlgItemText(m_hwnd, IDC_INFO2, str); + SetDlgItemText(m_hwnd, IDC_INFO2, GetDisplay(&w, L"%c %t")); SetDlgItemText(m_hwnd, IDC_INFO3, w.feel); SetDlgItemText(m_hwnd, IDC_INFO4, w.pressure); - GetDisplay(&w, L"%i %w", str); - SetDlgItemText(m_hwnd, IDC_INFO5, str); + SetDlgItemText(m_hwnd, IDC_INFO5, GetDisplay(&w, L"%i %w")); SetDlgItemText(m_hwnd, IDC_INFO6, w.dewpoint); SetDlgItemText(m_hwnd, IDC_INFO7, w.sunrise); SetDlgItemText(m_hwnd, IDC_INFO8, w.sunset); SetDlgItemText(m_hwnd, IDC_INFO9, w.high); SetDlgItemText(m_hwnd, IDC_INFO10, w.low); - GetDisplay(&w, TranslateT("Last update on: %u"), str); - SetDlgItemText(m_hwnd, IDC_INFO11, str); + SetDlgItemText(m_hwnd, IDC_INFO11, GetDisplay(&w, TranslateT("Last update on: %u"))); SetDlgItemText(m_hwnd, IDC_INFO12, w.humid); SetDlgItemText(m_hwnd, IDC_INFO13, w.vis); return true; -- cgit v1.2.3 From 4d051e1f4afd92b8dbc0e9129c903af377ad7f76 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 3 Apr 2025 14:38:09 +0300 Subject: code cleaning --- protocols/Weather/src/stdafx.h | 1 + protocols/Weather/src/weather_opt.cpp | 35 +++++++++++++++++++++++++++++--- protocols/Weather/src/weather_update.cpp | 6 ++++++ 3 files changed, 39 insertions(+), 3 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/stdafx.h b/protocols/Weather/src/stdafx.h index cf1f3240a3..70c602ed22 100644 --- a/protocols/Weather/src/stdafx.h +++ b/protocols/Weather/src/stdafx.h @@ -147,6 +147,7 @@ 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 015fda2c6c..c5323919be 100644 --- a/protocols/Weather/src/weather_opt.cpp +++ b/protocols/Weather/src/weather_opt.cpp @@ -295,8 +295,6 @@ public: ///////////////////////////////////////////////////////////////////////////////////////// // text option dialog -#define VAR_LIST_OPT TranslateT("%c\tcurrent condition\n%d\tcurrent date\n%e\tdewpoint\n%f\tfeel-like temp\n%h\ttoday's high\n%i\twind direction\n%l\ttoday's low\n%m\thumidity\n%n\tstation name\n%p\tpressure\n%r\tsunrise time\n%s\tstation ID\n%t\ttemperature\n%u\tupdate time\n%v\tvisibility\n%w\twind speed\n%y\tsun set\n----------\n\\n\tnew line") - struct { wchar_t c; @@ -315,6 +313,32 @@ static controls[] = { 'S', IDC_BTITLE2, "StatusText" }, }; +struct +{ + wchar_t symbol; + const wchar_t *pwszText; +} +static variables[] = +{ + { 'c', LPGENW("Current condition") }, + { 'd', LPGENW("Current date") }, + { 'e', LPGENW("Dewpoint") }, + { 'f', LPGENW("Feel-like temp") }, + { 'h', LPGENW("Today's high") }, + { 'i', LPGENW("Wind direction") }, + { 'l', LPGENW("Today's low") }, + { 'm', LPGENW("Humidity") }, + { 'n', LPGENW("Station name") }, + { 'p', LPGENW("Pressure") }, + { 'r', LPGENW("Sunrise") }, + { 's', LPGENW("Station ID") }, + { 't', LPGENW("Temperature") }, + { 'u', LPGENW("Update time") }, + { 'v', LPGENW("Visibility") }, + { 'w', LPGENW("Wind speed") }, + { 'y', LPGENW("Sunset") }, +}; + class COptionsTextDlg : public CWeatherDlgBase { CCtrlMButton btnReset, tm1, tm2, tm3, tm4, tm5, tm6, tm7, tm8; @@ -346,7 +370,12 @@ public: SetWindowPos(m_hwnd, HWND_TOPMOST, rc.left, rc.top, 0, 0, SWP_NOSIZE); // generate the display text for variable list - SetDlgItemTextW(m_hwnd, IDC_VARLIST, VAR_LIST_OPT); + CMStringW str; + for (auto &it : variables) + str.AppendFormat(L"%c\t%s\r\n", it.symbol, TranslateW(it.pwszText)); + str.Append(L"----------\r\n"); + str.AppendFormat(L"\\n\t%s\r\n", TranslateT("new line")); + SetDlgItemTextW(m_hwnd, IDC_VARLIST, str); for (auto &it : controls) SetDlgItemTextW(m_hwnd, it.id, m_proto->GetTextValue(it.c)); diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index 3f189274e5..fc3d49afd9 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -468,6 +468,12 @@ int CWeatherProto::GetWeatherData(MCONTACT hContact) return 0; } +void GetVarsDescr(CMStringW &str) +{ + for (int i=1; i <= 7; i++) + str.AppendFormat(L"a%d\t%s %d\r\n", i, TranslateT("Forecast Day"), i); +} + ///////////////////////////////////////////////////////////////////////////////////////// // main auto-update timer -- cgit v1.2.3 From 18738a3452bc980a943734aad8fa1c23366342ce Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 3 Apr 2025 14:50:35 +0300 Subject: =?UTF-8?q?files=20#4837=20(Weather:=20=D0=BD=D0=B5=20=D1=80=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82=20=D0=BA=D0=BD=D0=BE=D0=BF?= =?UTF-8?q?=D0=BA=D0=B0=20"=D0=95=D1=89=D1=91=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5")?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Weather/src/resource.h | 1 + protocols/Weather/src/weather_opt.cpp | 16 +++++++++++++++- protocols/Weather/src/weather_update.cpp | 7 +++++-- 3 files changed, 21 insertions(+), 3 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/resource.h b/protocols/Weather/src/resource.h index e53877d0ee..809c94857b 100644 --- a/protocols/Weather/src/resource.h +++ b/protocols/Weather/src/resource.h @@ -109,6 +109,7 @@ #define IDC_INFO10 2091 #define IDC_INFO12 2092 #define IDC_INFO13 2093 +#define IDC_MORE 2094 #define IDC_MOREDETAIL 2095 #define IDC_DATALIST 2096 #define IDC_MUPDATE 2097 diff --git a/protocols/Weather/src/weather_opt.cpp b/protocols/Weather/src/weather_opt.cpp index c5323919be..7c0829b006 100644 --- a/protocols/Weather/src/weather_opt.cpp +++ b/protocols/Weather/src/weather_opt.cpp @@ -341,11 +341,12 @@ static variables[] = class COptionsTextDlg : public CWeatherDlgBase { - CCtrlMButton btnReset, tm1, tm2, tm3, tm4, tm5, tm6, tm7, tm8; + CCtrlMButton btnMore, btnReset, tm1, tm2, tm3, tm4, tm5, tm6, tm7, tm8; public: COptionsTextDlg(CWeatherProto *ppro) : CWeatherDlgBase(ppro, IDD_TEXTOPT), + btnMore(this, IDC_MORE), btnReset(this, IDC_RESET), tm1(this, IDC_TM1), tm2(this, IDC_TM2), @@ -356,6 +357,7 @@ public: tm7(this, IDC_TM7), tm8(this, IDC_TM8) { + btnMore.OnClick = Callback(this, &COptionsTextDlg::onClick_More); btnReset.OnClick = Callback(this, &COptionsTextDlg::onClick_Reset); tm1.OnClick = tm2.OnClick = tm3.OnClick = tm4.OnClick = tm5.OnClick = tm6.OnClick = tm7.OnClick = tm8.OnClick = @@ -389,6 +391,7 @@ public: tm6.MakeFlat(); tm7.MakeFlat(); tm8.MakeFlat(); + btnMore.MakeFlat(); btnReset.MakeFlat(); return true; } @@ -410,6 +413,17 @@ public: return true; } + void onClick_More(CCtrlButton *) + { + // heading + CMStringW str(TranslateT("Here is a list of custom variables that are currently available")); + str += L"\n\n"; + GetVarsDescr(str); + + // display the list in a message box + MessageBox(nullptr, str, TranslateT("More Variables"), MB_OK | MB_ICONINFORMATION | MB_TOPMOST); + } + void onClick_TM(CCtrlButton *pButton) { // display the menu diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index fc3d49afd9..3082d8d2c1 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -470,8 +470,11 @@ int CWeatherProto::GetWeatherData(MCONTACT hContact) void GetVarsDescr(CMStringW &str) { - for (int i=1; i <= 7; i++) - str.AppendFormat(L"a%d\t%s %d\r\n", i, TranslateT("Forecast Day"), i); + for (int i = 1; i <= 7; i++) { + if (i != 1) + str.Append(L", "); + str.AppendFormat(L"%%[Forecast Day %d]", i); + } } ///////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 6c3f22e92e25d3bb3a6e6129f8a18d2a35a625aa Mon Sep 17 00:00:00 2001 From: dartraiden Date: Sat, 5 Apr 2025 21:10:42 +0300 Subject: Add percentage symbol to variabled --- protocols/Weather/src/weather_opt.cpp | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/weather_opt.cpp b/protocols/Weather/src/weather_opt.cpp index 7c0829b006..815fba5dd5 100644 --- a/protocols/Weather/src/weather_opt.cpp +++ b/protocols/Weather/src/weather_opt.cpp @@ -320,23 +320,23 @@ struct } static variables[] = { - { 'c', LPGENW("Current condition") }, - { 'd', LPGENW("Current date") }, - { 'e', LPGENW("Dewpoint") }, - { 'f', LPGENW("Feel-like temp") }, - { 'h', LPGENW("Today's high") }, - { 'i', LPGENW("Wind direction") }, - { 'l', LPGENW("Today's low") }, - { 'm', LPGENW("Humidity") }, - { 'n', LPGENW("Station name") }, - { 'p', LPGENW("Pressure") }, - { 'r', LPGENW("Sunrise") }, - { 's', LPGENW("Station ID") }, - { 't', LPGENW("Temperature") }, - { 'u', LPGENW("Update time") }, - { 'v', LPGENW("Visibility") }, - { 'w', LPGENW("Wind speed") }, - { 'y', LPGENW("Sunset") }, + { '%c', LPGENW("Current condition") }, + { '%d', LPGENW("Current date") }, + { '%e', LPGENW("Dewpoint") }, + { '%f', LPGENW("Feel-like temp") }, + { '%h', LPGENW("Today's high") }, + { '%i', LPGENW("Wind direction") }, + { '%l', LPGENW("Today's low") }, + { '%m', LPGENW("Humidity") }, + { '%n', LPGENW("Station name") }, + { '%p', LPGENW("Pressure") }, + { '%r', LPGENW("Sunrise") }, + { '%s', LPGENW("Station ID") }, + { '%t', LPGENW("Temperature") }, + { '%u', LPGENW("Update time") }, + { '%v', LPGENW("Visibility") }, + { '%w', LPGENW("Wind speed") }, + { '%y', LPGENW("Sunset") }, }; class COptionsTextDlg : public CWeatherDlgBase -- cgit v1.2.3 From 7b14d12d7f84d63b1332aa1ba74c2c67f76c5095 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 6 Apr 2025 19:38:13 +0300 Subject: =?UTF-8?q?fixes=20#4943=20(Weather:=20=D0=BD=D0=B5=20=D1=85=D0=B2?= =?UTF-8?q?=D0=B0=D1=82=D0=B0=D0=B5=D1=82=20=D0=B4=D0=B0=D1=82=20=D0=B8?= =?UTF-8?q?=D0=BB=D0=B8,=20=D1=85=D0=BE=D1=82=D1=8F=20=D0=B1=D1=8B,=20?= =?UTF-8?q?=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD=D0=B8=D0=B9=20=D0=B4=D0=BD?= =?UTF-8?q?=D0=B5=D0=B9=20=D0=BD=D0=B5=D0=B4=D0=B5=D0=BB=D0=B8=20=D1=83=20?= =?UTF-8?q?5-=D0=B4=D0=BD=D0=B5=D0=B2=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B3=D0=BD=D0=BE=D0=B7=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Weather/src/weather_update.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index 3082d8d2c1..a64bf7e063 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -373,6 +373,7 @@ static double g_elevation = 0; static void getData(OBJLIST &arValues, const JSONNode &node) { + arValues.insert(new WIDATAITEM(LPGENW("Date"), L"", parseConditions(node["datetime"].as_mstring()))); arValues.insert(new WIDATAITEM(LPGENW("Condition"), L"", parseConditions(node["conditions"].as_mstring()))); arValues.insert(new WIDATAITEM(LPGENW("Temperature"), L"C", node["temp"].as_mstring())); arValues.insert(new WIDATAITEM(LPGENW("High"), L"C", node["tempmax"].as_mstring())); -- cgit v1.2.3 From 96b6aa5171e1ba63aab8beb6aed48780016bb787 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 6 Apr 2025 19:45:37 +0300 Subject: =?UTF-8?q?fixes=20#4942=20(Weather:=20=D1=84=D1=80=D0=B5=D0=B9?= =?UTF-8?q?=D0=BC=20=D0=BF=D1=80=D0=BE=D0=BF=D0=B0=D0=B4=D0=B0=D0=B5=D1=82?= =?UTF-8?q?=20=D0=BF=D0=BE=D1=81=D0=BB=D0=B5=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D1=83=D1=81=D0=BA=D0=B0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Weather/src/weather_proto.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/weather_proto.cpp b/protocols/Weather/src/weather_proto.cpp index 6df768e7ac..3c5f8f1057 100644 --- a/protocols/Weather/src/weather_proto.cpp +++ b/protocols/Weather/src/weather_proto.cpp @@ -32,8 +32,6 @@ CWeatherProto::CWeatherProto(const char *protoName, const wchar_t *userName) : HookProtoEvent(ME_CLIST_DOUBLECLICKED, &CWeatherProto::BriefInfoEvt); HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &CWeatherProto::BuildContactMenu); - InitMwin(); - // load options and set defaults LoadOptions(); @@ -63,6 +61,8 @@ CWeatherProto::~CWeatherProto() void CWeatherProto::OnModulesLoaded() { + InitMwin(); + // timer for the first update m_impl.m_start.Start(5000); // first update is 5 sec after load -- cgit v1.2.3 From d1acb4b4fefc08eaf631fdf51b4afefd9007d11e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 7 Apr 2025 12:51:57 +0300 Subject: fixes #4942 completely --- protocols/Weather/src/weather_mwin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/weather_mwin.cpp b/protocols/Weather/src/weather_mwin.cpp index 57b775c81b..058c6e56ad 100644 --- a/protocols/Weather/src/weather_mwin.cpp +++ b/protocols/Weather/src/weather_mwin.cpp @@ -340,7 +340,7 @@ void CWeatherProto::InitMwin(void) g_plugin.addFont(&fontid); for (auto &hContact : AccContacts()) - if (g_plugin.getDword(hContact, "mwin")) + if (getDword(hContact, "mwin")) AddFrameWindow(hContact); hFontHook = HookEvent(ME_FONT_RELOAD, RedrawFrame); @@ -349,7 +349,7 @@ void CWeatherProto::InitMwin(void) void CWeatherProto::DestroyMwin(void) { for (auto &hContact : AccContacts()) { - uint32_t frameId = g_plugin.getDword(hContact, "mwin"); + uint32_t frameId = getDword(hContact, "mwin"); if (frameId) CallService(MS_CLIST_FRAMES_REMOVEFRAME, frameId, 0); } -- cgit v1.2.3 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 From 10b4babe8fd486a878626208fb1442d497fe5959 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 7 Apr 2025 13:40:59 +0300 Subject: =?UTF-8?q?fixes=20#4959=20(Weather:=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5=20=D0=B7=D0=B0=D0=BC=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=BB=D0=B8=D1=81=D1=8C=20=D0=BD=D0=B0=20=D0=BA?= =?UTF-8?q?=D0=B0=D0=BA=D0=B8=D0=B5-=D1=82=D0=BE=20=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=BE=D0=BD=D0=BD=D0=B8=D0=B5=20=D1=81=D0=B8?= =?UTF-8?q?=D0=BC=D0=B2=D0=BE=D0=BB=D1=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/Weather/src/weather_opt.cpp | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/weather_opt.cpp b/protocols/Weather/src/weather_opt.cpp index 6203715b2a..765309e414 100644 --- a/protocols/Weather/src/weather_opt.cpp +++ b/protocols/Weather/src/weather_opt.cpp @@ -320,23 +320,23 @@ struct } static variables[] = { - { '%c', LPGENW("Current condition") }, - { '%d', LPGENW("Current date") }, - { '%e', LPGENW("Dewpoint") }, - { '%f', LPGENW("Feel-like temp") }, - { '%h', LPGENW("Today's high") }, - { '%i', LPGENW("Wind direction") }, - { '%l', LPGENW("Today's low") }, - { '%m', LPGENW("Humidity") }, - { '%n', LPGENW("Station name") }, - { '%p', LPGENW("Pressure") }, - { '%r', LPGENW("Sunrise") }, - { '%s', LPGENW("Station ID") }, - { '%t', LPGENW("Temperature") }, - { '%u', LPGENW("Update time") }, - { '%v', LPGENW("Visibility") }, - { '%w', LPGENW("Wind speed") }, - { '%y', LPGENW("Sunset") }, + { 'c', LPGENW("Current condition") }, + { 'd', LPGENW("Current date") }, + { 'e', LPGENW("Dewpoint") }, + { 'f', LPGENW("Feel-like temp") }, + { 'h', LPGENW("Today's high") }, + { 'i', LPGENW("Wind direction") }, + { 'l', LPGENW("Today's low") }, + { 'm', LPGENW("Humidity") }, + { 'n', LPGENW("Station name") }, + { 'p', LPGENW("Pressure") }, + { 'r', LPGENW("Sunrise") }, + { 's', LPGENW("Station ID") }, + { 't', LPGENW("Temperature") }, + { 'u', LPGENW("Update time") }, + { 'v', LPGENW("Visibility") }, + { 'w', LPGENW("Wind speed") }, + { 'y', LPGENW("Sunset") }, }; class COptionsTextDlg : public CWeatherDlgBase @@ -374,7 +374,7 @@ public: // generate the display text for variable list CMStringW str; for (auto &it : variables) - str.AppendFormat(L"%c\t%s\r\n", it.symbol, TranslateW(it.pwszText)); + str.AppendFormat(L"%%%c\t%s\r\n", it.symbol, TranslateW(it.pwszText)); str.Append(L"----------\r\n"); str.AppendFormat(L"\\n\t%s\r\n", TranslateT("new line")); SetDlgItemTextW(m_hwnd, IDC_VARLIST, str); -- cgit v1.2.3 From 8bf8ad407ea2e8eddeaa73ac71abea3fa98c8580 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 7 Apr 2025 13:57:40 +0300 Subject: the simpler the better --- protocols/Weather/src/weather_update.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/Weather/src') diff --git a/protocols/Weather/src/weather_update.cpp b/protocols/Weather/src/weather_update.cpp index 001a9d9eba..82437dbb72 100644 --- a/protocols/Weather/src/weather_update.cpp +++ b/protocols/Weather/src/weather_update.cpp @@ -481,7 +481,7 @@ static int enumSettings(const char *pszSetting, void *param) void CWeatherProto::GetVarsDescr(CMStringW &wszDescr) { - OBJLIST vars(10, mir_strcmp); + OBJLIST vars(10, strcmp); for (int i = 1; i <= 7; i++) vars.insert(newStr(CMStringA(FORMAT, "Forecast Day %d", i))); -- cgit v1.2.3