diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/acinclude.m4 neutrino-tangos/acinclude.m4 --- neutrino-tangos.dev/acinclude.m4 2023-02-20 08:42:57.844326553 +0100 +++ neutrino-tangos/acinclude.m4 2023-10-06 13:30:34.486851375 +0200 @@ -31,6 +31,12 @@ [WEATHER_DEV_KEY=""]) AC_DEFINE_UNQUOTED([WEATHER_DEV_KEY], ["$WEATHER_DEV_KEY"], [API dev key to get data from weather data base, required for additional weather informations]) +AC_ARG_WITH(weather-dev-ver, + AS_HELP_STRING([--with-weather-dev-ver=version], [API version to get data from weather data base, required for additional weather informations]), + [WEATHER_DEV_VER="$withval"], + [WEATHER_DEV_VER=""]) +AC_DEFINE_UNQUOTED([WEATHER_DEV_VER], ["$WEATHER_DEV_VER"], [API version to get data from weather data base, required for additional weather informations]) + AC_ARG_ENABLE([weather-key-manage], AS_HELP_STRING([--enable-weather-key-manage], [Enable manage weather api dev key via gui for additional weather informations @<:@default=yes@:>@]), [enable_weather_key_manage="$enableval"], diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/data/locale/deutsch.locale neutrino-tangos/data/locale/deutsch.locale --- neutrino-tangos.dev/data/locale/deutsch.locale 2023-02-20 08:42:57.848326611 +0100 +++ neutrino-tangos/data/locale/deutsch.locale 2023-10-06 14:27:14.379696379 +0200 @@ -2955,6 +2955,7 @@ videomenu.zappingmode_mutetilllock Schwarzes Bild bis lock videomenu.zappingmode_holdtilllock Standbild bis lock weather.api_key Wetter API Schlüssel (OpenWeather) +weather.api_ver Wetter API Version weather.direction_e O weather.direction_ene ONO weather.direction_ese OSO diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/data/locale/english.locale neutrino-tangos/data/locale/english.locale --- neutrino-tangos.dev/data/locale/english.locale 2023-02-20 08:42:57.852326670 +0100 +++ neutrino-tangos/data/locale/english.locale 2023-10-06 14:27:40.000092327 +0200 @@ -2958,6 +2958,7 @@ videomenu.zappingmode_mutetilllock Black screen till locked videomenu.zappingmode_holdtilllock Hold screen till locked weather.api_key Weather API key (OpenWeather) +weather.api_ver Weather API version weather.direction_e E weather.direction_ene ENE weather.direction_ese ESE diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/src/gui/weather.cpp neutrino-tangos/src/gui/weather.cpp --- neutrino-tangos.dev/src/gui/weather.cpp 2022-10-16 11:14:21.268362206 +0200 +++ neutrino-tangos/src/gui/weather.cpp 2023-10-06 14:13:33.066989367 +0200 @@ -54,6 +54,7 @@ CWeather::CWeather() { key = g_settings.weather_api_key; + api = g_settings.weather_api_version; v_forecast.clear(); last_time = 0; coords = ""; @@ -78,11 +79,29 @@ } } +void CWeather::updateApi() +{ + bool force = false; + if (key.compare(g_settings.weather_api_key)) + { + key = g_settings.weather_api_key; + force = true; + } + if (api.compare(g_settings.weather_api_version)) + { + api = g_settings.weather_api_version; + force = true; + } + checkUpdate(force); +} + bool CWeather::checkUpdate(bool forceUpdate) { time_t current_time = time(NULL); if (forceUpdate || (difftime(current_time, last_time) > (UPDATE_CYCLE * 60))) + { return GetWeatherDetails(); + } else return false; } @@ -99,7 +118,7 @@ std::string lat = coords.substr(0, coords.find_first_of(',')); std::string lon = coords.substr(coords.find_first_of(',') + 1); - std::string data = "https://api.openweathermap.org/data/2.5/onecall?lat=" + lat + "&lon=" + lon + "&units=metric&lang=de&exclude=minutely,hourly,flags,alerts&appid=" + key; + std::string data = "https://api.openweathermap.org/data/"+api+"/onecall?lat=" + lat + "&lon=" + lon + "&units=metric&lang=de&exclude=minutely,hourly,flags,alerts&appid=" + key; JSONCPP_STRING answer; JSONCPP_STRING formattedErrors; diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/src/gui/weather.h neutrino-tangos/src/gui/weather.h --- neutrino-tangos.dev/src/gui/weather.h 2022-10-16 11:14:21.268362206 +0200 +++ neutrino-tangos/src/gui/weather.h 2023-10-06 14:13:59.495398949 +0200 @@ -78,6 +78,7 @@ std::vector v_forecast; CComponentsForm *form; std::string key; + std::string api; bool GetWeatherDetails(); time_t last_time; std::string getDirectionString(int degree); @@ -86,6 +87,7 @@ static CWeather *getInstance(); CWeather(); ~CWeather(); + void updateApi(); bool checkUpdate(bool forceUpdate = false); void setCoords(std::string new_coords, std::string new_city = "Unknown"); bool FindCoords(std::string postalcode, std::string country = "DE"); diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/src/gui/weather_setup.cpp neutrino-tangos/src/gui/weather_setup.cpp --- neutrino-tangos.dev/src/gui/weather_setup.cpp 2022-10-16 11:14:21.268362206 +0200 +++ neutrino-tangos/src/gui/weather_setup.cpp 2023-10-06 14:25:13.093821757 +0200 @@ -37,11 +37,27 @@ #include +CMenuOptionChooser::keyval_ext WEATHER_API_OPTIONS[] = +{ + { 0, NONEXISTANT_LOCALE, "2.5" }, + { 1, NONEXISTANT_LOCALE, "3.0" } + +}; +#define WEATHER_API_OPTION_COUNT (sizeof(WEATHER_API_OPTIONS)/sizeof(CMenuOptionChooser::keyval_ext)) + CWeatherSetup::CWeatherSetup() { width = 40; selected = -1; - + weather_api_version = 0; + for (size_t i = 0; i < WEATHER_API_OPTION_COUNT; i++) + { + if (WEATHER_API_OPTIONS[i].valname == g_settings.weather_api_version) + { + weather_api_version = i; + break; + } + } locations.clear(); loadLocations(CONFIGDIR "/weather-favorites.xml"); loadLocations(WEATHERDIR "/weather-locations.xml"); @@ -90,6 +106,9 @@ ms_oservices->addItem(mf_we); #endif + weather_api = new CMenuOptionChooser(LOCALE_WEATHER_API_VER, &weather_api_version, WEATHER_API_OPTIONS, WEATHER_API_OPTION_COUNT, CApiKey::check_weather_api_key(), this); + ms_oservices->addItem(weather_api); + CMenuForwarder *mf_wl = new CMenuForwarder(LOCALE_WEATHER_LOCATION, g_settings.weather_enabled, g_settings.weather_city, this, "select_location"); mf_wl->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_LOCATION); ms_oservices->addItem(mf_wl); @@ -180,11 +199,19 @@ { g_settings.weather_enabled = g_settings.weather_enabled && CApiKey::check_weather_api_key(); if (g_settings.weather_enabled) + { + CWeather::getInstance()->updateApi(); weather_api_key_short = g_settings.weather_api_key.substr(0, 8) + "..."; + } else weather_api_key_short.clear(); weather_onoff->setActive(CApiKey::check_weather_api_key()); } + else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_WEATHER_API_VER)) + { + g_settings.weather_api_version = WEATHER_API_OPTIONS[weather_api_version].valname; + CWeather::getInstance()->updateApi(); + } return ret; } diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/src/gui/weather_setup.h neutrino-tangos/src/gui/weather_setup.h --- neutrino-tangos.dev/src/gui/weather_setup.h 2022-10-16 11:14:21.268362206 +0200 +++ neutrino-tangos/src/gui/weather_setup.h 2023-10-06 13:30:34.486851375 +0200 @@ -44,7 +44,9 @@ int width, selected; CMenuOptionChooser *weather_onoff; + CMenuOptionChooser *weather_api; std::string weather_api_key_short; + int weather_api_version; int showWeatherSetup(); int selectLocation(); diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/src/neutrino.cpp neutrino-tangos/src/neutrino.cpp --- neutrino-tangos.dev/src/neutrino.cpp 2023-02-20 08:42:57.856326728 +0100 +++ neutrino-tangos/src/neutrino.cpp 2023-10-06 13:30:34.490851439 +0200 @@ -1054,11 +1054,14 @@ //online services std::string weather_api_key = WEATHER_DEV_KEY; + std::string weather_api_ver = WEATHER_DEV_VER; #if ENABLE_WEATHER_KEY_MANAGE g_settings.weather_api_key = configfile.getString("weather_api_key", weather_api_key.empty() ? "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" : weather_api_key); + g_settings.weather_api_version = configfile.getString("weather_api_ver", weather_api_ver.empty() ? "2.5" : weather_api_ver); g_settings.weather_enabled = configfile.getInt32("weather_enabled", 1); #else g_settings.weather_api_key = weather_api_key; + g_settings.weather_api_version = weather_api_ver; g_settings.weather_enabled = 1; #endif g_settings.weather_enabled = g_settings.weather_enabled && CApiKey::check_weather_api_key(); @@ -1895,6 +1898,7 @@ //online services #ifndef WEATHER_DEV_KEY configfile.setString( "weather_api_key", g_settings.weather_api_key ); + configfile.setString( "weather_api_ver", g_settings.weather_api_version ); configfile.setInt32( "weather_enabled", g_settings.weather_enabled ); #endif configfile.setString( "weather_location", g_settings.weather_location ); diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/src/system/locals.h neutrino-tangos/src/system/locals.h --- neutrino-tangos.dev/src/system/locals.h 2023-02-20 08:42:57.856326728 +0100 +++ neutrino-tangos/src/system/locals.h 2023-10-06 13:30:34.490851439 +0200 @@ -2979,6 +2979,7 @@ LOCALE_VIDEOMENU_ZAPPINGMODE_MUTETILLLOCK, LOCALE_VIDEOMENU_ZAPPINGMODE_HOLDTILLLOCK, LOCALE_WEATHER_API_KEY, + LOCALE_WEATHER_API_VER, LOCALE_WEATHER_DIRECTION_E, LOCALE_WEATHER_DIRECTION_ENE, LOCALE_WEATHER_DIRECTION_ESE, diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/src/system/locals_intern.h neutrino-tangos/src/system/locals_intern.h --- neutrino-tangos.dev/src/system/locals_intern.h 2023-02-20 08:42:57.856326728 +0100 +++ neutrino-tangos/src/system/locals_intern.h 2023-10-06 13:30:34.490851439 +0200 @@ -2979,6 +2979,7 @@ "videomenu.zappingmode_mutetilllock", "videomenu.zappingmode_holdtilllock", "weather.api_key", + "weather.api_ver", "weather.direction_e", "weather.direction_ene", "weather.direction_ese", diff -Nur '--exclude-from=/home/tango/nmp_4x86/scripts/diff-exclude' neutrino-tangos.dev/src/system/settings.h neutrino-tangos/src/system/settings.h --- neutrino-tangos.dev/src/system/settings.h 2023-02-20 08:42:57.856326728 +0100 +++ neutrino-tangos/src/system/settings.h 2023-10-06 13:30:34.490851439 +0200 @@ -1036,6 +1036,7 @@ //online services std::string weather_api_key; + std::string weather_api_version; int weather_enabled; int weather_country;