From fc3e59bd1f64c437fe74c74e2b30c558665d8c3a Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 10 Apr 2016 09:25:59 +0000 Subject: Weather code cleaning fix reapplied git-svn-id: http://svn.miranda-ng.org/main/trunk@16621 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Weather/src/stdafx.h | 3 +-- plugins/Weather/src/weather_contacts.cpp | 4 +-- plugins/Weather/src/weather_data.cpp | 45 ++++++++++++-------------------- plugins/Weather/src/weather_update.cpp | 2 +- 4 files changed, 21 insertions(+), 33 deletions(-) diff --git a/plugins/Weather/src/stdafx.h b/plugins/Weather/src/stdafx.h index 67eb99d4db..658894e12a 100644 --- a/plugins/Weather/src/stdafx.h +++ b/plugins/Weather/src/stdafx.h @@ -414,10 +414,9 @@ void GetID(TCHAR *pszID); TCHAR *GetError(int code); // functions in weather_data.c -void GetStationID(MCONTACT hContact, TCHAR* id, size_t idlen); +void GetStationID(MCONTACT hContact, TCHAR* id, int idlen); WEATHERINFO LoadWeatherInfo(MCONTACT Change); int DBGetData(MCONTACT hContact, char *setting, DBVARIANT *dbv); -int DBGetStaticString(MCONTACT hContact, const char *szModule, const char *valueName, TCHAR *dest, size_t dest_len); void EraseAllInfo(void); diff --git a/plugins/Weather/src/weather_contacts.cpp b/plugins/Weather/src/weather_contacts.cpp index f67fbee81f..60919e5b43 100644 --- a/plugins/Weather/src/weather_contacts.cpp +++ b/plugins/Weather/src/weather_contacts.cpp @@ -60,7 +60,7 @@ INT_PTR LoadForecast(WPARAM wParam, LPARAM) GetStationID(wParam, id, _countof(id)); if (id[0] != 0) { // check if the complte forecast URL is set. If it is not, display warning and quit - if (DBGetStaticString(wParam, WEATHERPROTONAME, "InfoURL", loc2, _countof(loc2)) || loc2[0] == 0) { + if (db_get_tstatic(wParam, WEATHERPROTONAME, "InfoURL", loc2, _countof(loc2)) || loc2[0] == 0) { MessageBox(NULL, NO_FORECAST_URL, TranslateT("Weather Protocol"), MB_ICONINFORMATION); return 1; } @@ -78,7 +78,7 @@ INT_PTR WeatherMap(WPARAM wParam, LPARAM) GetStationID(wParam, id, _countof(id)); if (id[0] != 0) { // check if the weather map URL is set. If it is not, display warning and quit - if (DBGetStaticString(wParam, WEATHERPROTONAME, "MapURL", loc2, _countof(loc2)) || loc2[0] == 0) { + if (db_get_tstatic(wParam, WEATHERPROTONAME, "MapURL", loc2, _countof(loc2)) || loc2[0] == 0) { MessageBox(NULL, NO_MAP_URL, TranslateT("Weather Protocol"), MB_ICONINFORMATION); return 1; } diff --git a/plugins/Weather/src/weather_data.cpp b/plugins/Weather/src/weather_data.cpp index 3ebd9ad0ba..24554f2f4f 100644 --- a/plugins/Weather/src/weather_data.cpp +++ b/plugins/Weather/src/weather_data.cpp @@ -30,10 +30,10 @@ saving individual weather data for a weather contact. // hContact = the current contact handle // return value = the string for station ID // -void GetStationID(MCONTACT hContact, TCHAR* id, size_t idlen) +void GetStationID(MCONTACT hContact, TCHAR* id, int idlen) { // accessing the database - if (DBGetStaticString(hContact, WEATHERPROTONAME, "ID", id, idlen)) + if (db_get_tstatic(hContact, WEATHERPROTONAME, "ID", id, idlen)) id[0] = 0; } @@ -49,35 +49,35 @@ WEATHERINFO LoadWeatherInfo(MCONTACT hContact) winfo.hContact = hContact; GetStationID(hContact, winfo.id, _countof(winfo.id)); - if (DBGetStaticString(hContact, WEATHERPROTONAME, "Nick", winfo.city, _countof(winfo.city))) + if (db_get_tstatic(hContact, WEATHERPROTONAME, "Nick", winfo.city, _countof(winfo.city))) _tcsncpy(winfo.city, NODATA, _countof(winfo.city) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Update", winfo.update, _countof(winfo.update))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Update", winfo.update, _countof(winfo.update))) _tcsncpy(winfo.update, NODATA, _countof(winfo.update) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Condition", winfo.cond, _countof(winfo.cond))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Condition", winfo.cond, _countof(winfo.cond))) _tcsncpy(winfo.cond, NODATA, _countof(winfo.cond) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Temperature", winfo.temp, _countof(winfo.temp))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Temperature", winfo.temp, _countof(winfo.temp))) _tcsncpy(winfo.temp, NODATA, _countof(winfo.temp) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "High", winfo.high, _countof(winfo.high))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "High", winfo.high, _countof(winfo.high))) _tcsncpy(winfo.high, NODATA, _countof(winfo.high) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Low", winfo.low, _countof(winfo.low))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Low", winfo.low, _countof(winfo.low))) _tcsncpy(winfo.low, NODATA, _countof(winfo.low) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Sunset", winfo.sunset, _countof(winfo.sunset))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Sunset", winfo.sunset, _countof(winfo.sunset))) _tcsncpy(winfo.sunset, NODATA, _countof(winfo.sunset) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Sunrise", winfo.sunrise, _countof(winfo.sunrise))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Sunrise", winfo.sunrise, _countof(winfo.sunrise))) _tcsncpy(winfo.sunrise, NODATA, _countof(winfo.sunrise) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Wind Speed", winfo.wind, _countof(winfo.wind))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Wind Speed", winfo.wind, _countof(winfo.wind))) _tcsncpy(winfo.wind, NODATA, _countof(winfo.wind) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Wind Direction", winfo.winddir, _countof(winfo.winddir))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Wind Direction", winfo.winddir, _countof(winfo.winddir))) _tcsncpy(winfo.winddir, NODATA, _countof(winfo.winddir) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, _countof(winfo.dewpoint))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, _countof(winfo.dewpoint))) _tcsncpy(winfo.dewpoint, NODATA, _countof(winfo.dewpoint) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Pressure", winfo.pressure, _countof(winfo.pressure))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Pressure", winfo.pressure, _countof(winfo.pressure))) _tcsncpy(winfo.pressure, NODATA, _countof(winfo.pressure) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Visibility", winfo.vis, _countof(winfo.vis))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Visibility", winfo.vis, _countof(winfo.vis))) _tcsncpy(winfo.vis, NODATA, _countof(winfo.vis) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Humidity", winfo.humid, _countof(winfo.humid))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Humidity", winfo.humid, _countof(winfo.humid))) _tcsncpy(winfo.humid, NODATA, _countof(winfo.humid) - 1); - if (DBGetStaticString(hContact, WEATHERCONDITION, "Feel", winfo.feel, _countof(winfo.feel))) + if (db_get_tstatic(hContact, WEATHERCONDITION, "Feel", winfo.feel, _countof(winfo.feel))) _tcsncpy(winfo.feel, NODATA, _countof(winfo.feel) - 1); winfo.status = (WORD)db_get_w(hContact, WEATHERPROTONAME, "StatusIcon", ID_STATUS_OFFLINE); @@ -100,17 +100,6 @@ int DBGetData(MCONTACT hContact, char *setting, DBVARIANT *dbv) return 0; } -int DBGetStaticString(MCONTACT hContact, const char *szModule, const char *valueName, TCHAR *dest, size_t dest_len) -{ - DBVARIANT dbv; - if (db_get_ts(hContact, szModule, valueName, &dbv)) - return 1; - - _tcsncpy(dest, dbv.ptszVal, dest_len); - dest[dest_len - 1] = 0; - db_free(&dbv); - return 0; -} //============ ERASE OLD SETTINGS ============ // diff --git a/plugins/Weather/src/weather_update.cpp b/plugins/Weather/src/weather_update.cpp index 741af5e004..be95d9e56e 100644 --- a/plugins/Weather/src/weather_update.cpp +++ b/plugins/Weather/src/weather_update.cpp @@ -325,7 +325,7 @@ void UpdateAll(BOOL AutoUpdate, BOOL RemoveData) INT_PTR UpdateSingleStation(WPARAM wParam, LPARAM) { if (IsMyContact(wParam)) { - // add the station to the end of the update queue + // add the station to the end of the update queue UpdateListAdd(wParam); // if it is not updating, then start the update thread process -- cgit v1.2.3