summaryrefslogtreecommitdiff
path: root/plugins/Weather/src
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2016-04-09 21:43:00 +0000
committerKirill Volinsky <mataes2007@gmail.com>2016-04-09 21:43:00 +0000
commitdf4a8432b2872e78f6ffdcddab6a4b2a95c9770c (patch)
treefdc8d722f2858a8c1c12d604b575a1014d69ac65 /plugins/Weather/src
parent5a8128570b24a6bafc4b7caa0620a895bb971a1c (diff)
partly reverted last commit
git-svn-id: http://svn.miranda-ng.org/main/trunk@16618 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Weather/src')
-rw-r--r--plugins/Weather/src/stdafx.h3
-rw-r--r--plugins/Weather/src/weather_contacts.cpp4
-rw-r--r--plugins/Weather/src/weather_data.cpp45
-rw-r--r--plugins/Weather/src/weather_update.cpp2
4 files changed, 33 insertions, 21 deletions
diff --git a/plugins/Weather/src/stdafx.h b/plugins/Weather/src/stdafx.h
index 658894e12a..67eb99d4db 100644
--- a/plugins/Weather/src/stdafx.h
+++ b/plugins/Weather/src/stdafx.h
@@ -414,9 +414,10 @@ void GetID(TCHAR *pszID);
TCHAR *GetError(int code);
// functions in weather_data.c
-void GetStationID(MCONTACT hContact, TCHAR* id, int idlen);
+void GetStationID(MCONTACT hContact, TCHAR* id, size_t 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 60919e5b43..f67fbee81f 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 (db_get_tstatic(wParam, WEATHERPROTONAME, "InfoURL", loc2, _countof(loc2)) || loc2[0] == 0) {
+ if (DBGetStaticString(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 (db_get_tstatic(wParam, WEATHERPROTONAME, "MapURL", loc2, _countof(loc2)) || loc2[0] == 0) {
+ if (DBGetStaticString(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 24554f2f4f..3ebd9ad0ba 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, int idlen)
+void GetStationID(MCONTACT hContact, TCHAR* id, size_t idlen)
{
// accessing the database
- if (db_get_tstatic(hContact, WEATHERPROTONAME, "ID", id, idlen))
+ if (DBGetStaticString(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 (db_get_tstatic(hContact, WEATHERPROTONAME, "Nick", winfo.city, _countof(winfo.city)))
+ if (DBGetStaticString(hContact, WEATHERPROTONAME, "Nick", winfo.city, _countof(winfo.city)))
_tcsncpy(winfo.city, NODATA, _countof(winfo.city) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Update", winfo.update, _countof(winfo.update)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Update", winfo.update, _countof(winfo.update)))
_tcsncpy(winfo.update, NODATA, _countof(winfo.update) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Condition", winfo.cond, _countof(winfo.cond)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Condition", winfo.cond, _countof(winfo.cond)))
_tcsncpy(winfo.cond, NODATA, _countof(winfo.cond) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Temperature", winfo.temp, _countof(winfo.temp)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Temperature", winfo.temp, _countof(winfo.temp)))
_tcsncpy(winfo.temp, NODATA, _countof(winfo.temp) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "High", winfo.high, _countof(winfo.high)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "High", winfo.high, _countof(winfo.high)))
_tcsncpy(winfo.high, NODATA, _countof(winfo.high) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Low", winfo.low, _countof(winfo.low)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Low", winfo.low, _countof(winfo.low)))
_tcsncpy(winfo.low, NODATA, _countof(winfo.low) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Sunset", winfo.sunset, _countof(winfo.sunset)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Sunset", winfo.sunset, _countof(winfo.sunset)))
_tcsncpy(winfo.sunset, NODATA, _countof(winfo.sunset) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Sunrise", winfo.sunrise, _countof(winfo.sunrise)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Sunrise", winfo.sunrise, _countof(winfo.sunrise)))
_tcsncpy(winfo.sunrise, NODATA, _countof(winfo.sunrise) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Wind Speed", winfo.wind, _countof(winfo.wind)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Wind Speed", winfo.wind, _countof(winfo.wind)))
_tcsncpy(winfo.wind, NODATA, _countof(winfo.wind) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Wind Direction", winfo.winddir, _countof(winfo.winddir)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Wind Direction", winfo.winddir, _countof(winfo.winddir)))
_tcsncpy(winfo.winddir, NODATA, _countof(winfo.winddir) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, _countof(winfo.dewpoint)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Dewpoint", winfo.dewpoint, _countof(winfo.dewpoint)))
_tcsncpy(winfo.dewpoint, NODATA, _countof(winfo.dewpoint) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Pressure", winfo.pressure, _countof(winfo.pressure)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Pressure", winfo.pressure, _countof(winfo.pressure)))
_tcsncpy(winfo.pressure, NODATA, _countof(winfo.pressure) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Visibility", winfo.vis, _countof(winfo.vis)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Visibility", winfo.vis, _countof(winfo.vis)))
_tcsncpy(winfo.vis, NODATA, _countof(winfo.vis) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Humidity", winfo.humid, _countof(winfo.humid)))
+ if (DBGetStaticString(hContact, WEATHERCONDITION, "Humidity", winfo.humid, _countof(winfo.humid)))
_tcsncpy(winfo.humid, NODATA, _countof(winfo.humid) - 1);
- if (db_get_tstatic(hContact, WEATHERCONDITION, "Feel", winfo.feel, _countof(winfo.feel)))
+ if (DBGetStaticString(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,6 +100,17 @@ 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 be95d9e56e..741af5e004 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