diff options
| author | George Hazan <george.hazan@gmail.com> | 2025-04-03 13:22:43 +0300 |
|---|---|---|
| committer | George Hazan <george.hazan@gmail.com> | 2025-04-03 13:22:43 +0300 |
| commit | 3ee53558d61ce75746f28c4a36255241895a98cb (patch) | |
| tree | 75c68e699d7d891e247cf633227ac958d2a5046e | |
| parent | 0fd6fe57ebca7ce96403487ca335d72dae249578 (diff) | |
obsolete function removed
| -rw-r--r-- | protocols/Weather/res/resource.rc | 2 | ||||
| -rw-r--r-- | protocols/Weather/src/proto.h | 1 | ||||
| -rw-r--r-- | protocols/Weather/src/weather_addstn.cpp | 2 | ||||
| -rw-r--r-- | protocols/Weather/src/weather_contacts.cpp | 18 | ||||
| -rw-r--r-- | protocols/Weather/src/weather_data.cpp | 16 | ||||
| -rw-r--r-- | protocols/Weather/src/weather_update.cpp | 7 |
6 files changed, 15 insertions, 31 deletions
diff --git a/protocols/Weather/res/resource.rc b/protocols/Weather/res/resource.rc index b03db42abc..29c85adfae 100644 --- a/protocols/Weather/res/resource.rc +++ b/protocols/Weather/res/resource.rc @@ -182,7 +182,7 @@ BEGIN CONTROL "History Log",IDC_TM7,"MButtonClass",WS_TABSTOP,2,221,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L EDITTEXT IDC_HTEXT,80,219,183,12,ES_AUTOHSCROLL GROUPBOX "Variable List",IDC_STATIC,207,14,99,191 - LTEXT "",IDC_VARLIST,213,25,86,157 + LTEXT "",IDC_VARLIST,213,25,86,172 CONTROL "Reset",IDC_RESET,"MButtonClass",WS_TABSTOP,266,208,40,21,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L EDITTEXT IDC_BTITLE2,80,28,125,12,ES_AUTOHSCROLL CONTROL "Status Message",IDC_TM8,"MButtonClass",WS_TABSTOP | 0x100,2,29,77,9,WS_EX_WINDOWEDGE | WS_EX_NOACTIVATE | 0x10000000L 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<CWeatherProto> // 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 @@ -26,18 +26,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 // return value = the current weather information in WEATHERINFO struct @@ -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<WIDATAITEM> &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(); |
