mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-03 02:41:12 +02:00
weather: introduce string g_settings.weather_postcode
Origin commit data
------------------
Commit: 46cf941937
Author: vanhofen <vanhofen@gmx.de>
Date: 2022-01-22 (Sat, 22 Jan 2022)
Origin message was:
------------------
- weather: introduce string g_settings.weather_postcode
This commit is contained in:
@@ -182,12 +182,9 @@ bool CWeather::GetWeatherDetails()
|
|||||||
return false;
|
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);
|
std::string data = "http://api.openweathermap.org/geo/1.0/zip?zip=" + postcode + "," + country + "&appid=" + key;
|
||||||
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;
|
|
||||||
JSONCPP_STRING answer;
|
JSONCPP_STRING answer;
|
||||||
JSONCPP_STRING formattedErrors;
|
JSONCPP_STRING formattedErrors;
|
||||||
Json::CharReaderBuilder builder;
|
Json::CharReaderBuilder builder;
|
||||||
|
@@ -91,7 +91,7 @@ class CWeather
|
|||||||
~CWeather();
|
~CWeather();
|
||||||
bool checkUpdate(bool forceUpdate = false);
|
bool checkUpdate(bool forceUpdate = false);
|
||||||
void setCoords(std::string new_coords, std::string new_city = "Unknown");
|
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
|
// globals
|
||||||
std::string getCity()
|
std::string getCity()
|
||||||
|
@@ -158,12 +158,11 @@ int CWeatherSetup::findLocation()
|
|||||||
{
|
{
|
||||||
int ret = menu_return::RETURN_REPAINT;
|
int ret = menu_return::RETURN_REPAINT;
|
||||||
|
|
||||||
int postcode = WEATHER_DEFAULT_POSTCODE;
|
CStringInput zipcode(LOCALE_WEATHER_LOCATION_POSTCODE, &g_settings.weather_postcode, 5);
|
||||||
CIntInput zipcode(LOCALE_WEATHER_LOCATION_POSTCODE, &postcode, (unsigned int)5);
|
|
||||||
ret = zipcode.exec(NULL, "");
|
ret = zipcode.exec(NULL, "");
|
||||||
zipcode.hide();
|
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);
|
CWeather::getInstance()->setCoords(g_settings.weather_location, g_settings.weather_city);
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
#define WEATHER_DEFAULT_CITY "Berlin"
|
#define WEATHER_DEFAULT_CITY "Berlin"
|
||||||
#define WEATHER_DEFAULT_LOCATION "52.52,13.40"
|
#define WEATHER_DEFAULT_LOCATION "52.52,13.40"
|
||||||
#define WEATHER_DEFAULT_POSTCODE 10178
|
#define WEATHER_DEFAULT_POSTCODE "10178"
|
||||||
|
|
||||||
#include <gui/widget/menue.h>
|
#include <gui/widget/menue.h>
|
||||||
|
|
||||||
|
@@ -1116,6 +1116,7 @@ int CNeutrinoApp::loadSetup(const char *fname)
|
|||||||
|
|
||||||
g_settings.weather_city = configfile.getString("weather_city", WEATHER_DEFAULT_CITY);
|
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_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;
|
g_settings.youtube_dev_id = YT_DEV_KEY;
|
||||||
#if ENABLE_YOUTUBE_KEY_MANAGE
|
#if ENABLE_YOUTUBE_KEY_MANAGE
|
||||||
@@ -2147,6 +2148,7 @@ void CNeutrinoApp::saveSetup(const char *fname)
|
|||||||
|
|
||||||
configfile.setString("weather_city", g_settings.weather_city);
|
configfile.setString("weather_city", g_settings.weather_city);
|
||||||
configfile.setString("weather_location", g_settings.weather_location);
|
configfile.setString("weather_location", g_settings.weather_location);
|
||||||
|
configfile.setString("weather_postcode", g_settings.weather_postcode);
|
||||||
|
|
||||||
#if ENABLE_YOUTUBE_KEY_MANAGE
|
#if ENABLE_YOUTUBE_KEY_MANAGE
|
||||||
configfile.setString("youtube_dev_id", g_settings.youtube_dev_id);
|
configfile.setString("youtube_dev_id", g_settings.youtube_dev_id);
|
||||||
|
@@ -915,6 +915,7 @@ struct SNeutrinoSettings
|
|||||||
|
|
||||||
std::string weather_city;
|
std::string weather_city;
|
||||||
std::string weather_location;
|
std::string weather_location;
|
||||||
|
std::string weather_postcode;
|
||||||
|
|
||||||
std::string youtube_dev_id;
|
std::string youtube_dev_id;
|
||||||
int youtube_enabled;
|
int youtube_enabled;
|
||||||
|
Reference in New Issue
Block a user