mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-09-01 01:41:23 +02:00
- weather: introduce string g_settings.weather_postcode
Signed-off-by: Thilo Graf <dbt@novatux.de>
This commit is contained in:
@@ -181,12 +181,9 @@ bool CWeather::GetWeatherDetails()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CWeather::FindCoords(int postcode, std::string country, int pc_len)
|
||||
bool CWeather::FindCoords(std::string postcode, std::string country)
|
||||
{
|
||||
std::string pcode = to_string(postcode);
|
||||
unsigned int number_of_zeros = pc_len - pcode.length();
|
||||
pcode.insert(0, number_of_zeros, '0');
|
||||
std::string data = "http://api.openweathermap.org/geo/1.0/zip?zip=" + pcode + "," + country + "&appid=" + key;
|
||||
std::string data = "http://api.openweathermap.org/geo/1.0/zip?zip=" + postcode + "," + country + "&appid=" + key;
|
||||
JSONCPP_STRING answer;
|
||||
JSONCPP_STRING formattedErrors;
|
||||
Json::CharReaderBuilder builder;
|
||||
|
@@ -90,7 +90,7 @@ class CWeather
|
||||
~CWeather();
|
||||
bool checkUpdate(bool forceUpdate = false);
|
||||
void setCoords(std::string new_coords, std::string new_city = "Unknown");
|
||||
bool FindCoords(int postcode, std::string country = "DE", int pc_len = 5);
|
||||
bool FindCoords(std::string postcode, std::string country = "DE");
|
||||
|
||||
// globals
|
||||
std::string getCity()
|
||||
|
@@ -158,12 +158,11 @@ int CWeatherSetup::findLocation()
|
||||
{
|
||||
int ret = menu_return::RETURN_REPAINT;
|
||||
|
||||
int postcode = WEATHER_DEFAULT_POSTCODE;
|
||||
CIntInput zipcode(LOCALE_WEATHER_LOCATION_POSTCODE, &postcode, (unsigned int)5);
|
||||
CStringInput zipcode(LOCALE_WEATHER_LOCATION_POSTCODE, &g_settings.weather_postcode, 5);
|
||||
ret = zipcode.exec(NULL, "");
|
||||
zipcode.hide();
|
||||
|
||||
if (CWeather::getInstance()->FindCoords(postcode))
|
||||
if (CWeather::getInstance()->FindCoords(g_settings.weather_postcode))
|
||||
{
|
||||
CWeather::getInstance()->setCoords(g_settings.weather_location, g_settings.weather_city);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@
|
||||
|
||||
#define WEATHER_DEFAULT_CITY "Berlin"
|
||||
#define WEATHER_DEFAULT_LOCATION "52.52,13.40"
|
||||
#define WEATHER_DEFAULT_POSTCODE 10178
|
||||
#define WEATHER_DEFAULT_POSTCODE "10178"
|
||||
|
||||
#include <gui/widget/menue.h>
|
||||
|
||||
|
@@ -1114,6 +1114,7 @@ int CNeutrinoApp::loadSetup(const char *fname)
|
||||
|
||||
g_settings.weather_city = configfile.getString("weather_city", WEATHER_DEFAULT_CITY);
|
||||
g_settings.weather_location = configfile.getString("weather_location", WEATHER_DEFAULT_LOCATION);
|
||||
g_settings.weather_postcode = configfile.getString("weather_postcode", WEATHER_DEFAULT_POSTCODE);
|
||||
|
||||
g_settings.youtube_dev_id = YT_DEV_KEY;
|
||||
#if ENABLE_YOUTUBE_KEY_MANAGE
|
||||
@@ -2106,6 +2107,7 @@ void CNeutrinoApp::saveSetup(const char *fname)
|
||||
|
||||
configfile.setString("weather_city", g_settings.weather_city);
|
||||
configfile.setString("weather_location", g_settings.weather_location);
|
||||
configfile.setString("weather_postcode", g_settings.weather_postcode);
|
||||
|
||||
#if ENABLE_YOUTUBE_KEY_MANAGE
|
||||
configfile.setString("youtube_dev_id", g_settings.youtube_dev_id);
|
||||
|
@@ -911,6 +911,7 @@ struct SNeutrinoSettings
|
||||
|
||||
std::string weather_city;
|
||||
std::string weather_location;
|
||||
std::string weather_postcode;
|
||||
|
||||
std::string youtube_dev_id;
|
||||
int youtube_enabled;
|
||||
|
Reference in New Issue
Block a user