add weather via Dark Sky API -step1-

Signed-off-by: Thilo Graf <dbt@novatux.de>

Build errors fixed, missing code disabled
This commit is contained in:
TangoCash
2019-03-20 15:27:14 +01:00
committed by Thilo Graf
parent 69ae7d89e3
commit f7219894bc
31 changed files with 786 additions and 7 deletions

View File

@@ -34,6 +34,7 @@
#include <system/helpers.h>
#include <system/debug.h>
#include <gui/miscsettings_menu.h>
#include <gui/weather.h>
#include <gui/cec_setup.h>
#include <gui/filebrowser.h>
#include <gui/keybind_setup.h>
@@ -143,6 +144,16 @@ int CMiscMenue::exec(CMenuTarget* parent, const std::string &actionKey)
{
return showMiscSettingsMenuOnlineServices();
}
#if 0
else if(actionKey == "plugins")
{
return showMiscSettingsMenuPlugins();
}
#endif
else if(actionKey == "select_location")
{
return showMiscSettingsSelectWeatherLocation();
}
else if(actionKey == "epg_read_now")
{
struct stat my_stat;
@@ -164,6 +175,8 @@ int CMiscMenue::exec(CMenuTarget* parent, const std::string &actionKey)
return showMiscSettingsMenu();
}
#include <gui/weather_locations.h>
#if 0 //not used
#define MISCSETTINGS_FB_DESTINATION_OPTION_COUNT 3
const CMenuOptionChooser::keyval MISCSETTINGS_FB_DESTINATION_OPTIONS[MISCSETTINGS_FB_DESTINATION_OPTION_COUNT] =
@@ -593,6 +606,25 @@ int CMiscMenue::showMiscSettingsMenuOnlineServices()
CMenuWidget *ms_oservices = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_ONLINESERVICES);
ms_oservices->addIntroItems(LOCALE_MISCSETTINGS_ONLINESERVICES);
// weather
weather_onoff = new CMenuOptionChooser(LOCALE_WEATHER_ENABLED, &g_settings.weather_enabled, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, CApiKey::check_weather_api_key());
weather_onoff->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_ENABLED);
ms_oservices->addItem(weather_onoff);
CMenuForwarder *mf_wl = new CMenuForwarder(LOCALE_WEATHER_LOCATION, g_settings.weather_enabled, NULL, this, "select_location");
mf_wl->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_LOCATION);
ms_oservices->addItem(mf_wl);
#if ENABLE_WEATHER_KEY_MANAGE
changeNotify(LOCALE_WEATHER_API_KEY, NULL);
CKeyboardInput weather_api_key_input(LOCALE_WEATHER_API_KEY, &g_settings.weather_api_key, 32, this);
CMenuForwarder *mf_we = new CMenuForwarder(LOCALE_WEATHER_API_KEY, true, weather_api_key_short, &weather_api_key_input);
mf_we->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_WEATHER_API_KEY);
ms_oservices->addItem(mf_we);
ms_oservices->addItem(GenericMenuSeparator);
#endif
// tmdb
tmdb_onoff = new CMenuOptionChooser(LOCALE_TMDB_ENABLED, &g_settings.tmdb_enabled, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, CApiKey::check_tmdb_api_key());
tmdb_onoff->setHint(NEUTRINO_ICON_HINT_SETTINGS, LOCALE_MENU_HINT_TMDB_ENABLED);
@@ -655,6 +687,66 @@ int CMiscMenue::showMiscSettingsMenuOnlineServices()
delete ms_oservices;
return res;
}
#if 0
// plugins
int CMiscMenue::showMiscSettingsMenuPlugins()
{
CMenuWidget *ms_plugins = new CMenuWidget(LOCALE_MISCSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, width, MN_WIDGET_ID_MISCSETUP_PLUGINS);
ms_plugins->addIntroItems(LOCALE_PLUGINS_CONTROL);
CMenuForwarder * mf = new CMenuForwarder(LOCALE_PLUGINS_HDD_DIR, true, g_settings.plugin_hdd_dir, this, "plugin_dir");
mf->setHint("", LOCALE_MENU_HINT_PLUGINS_HDD_DIR);
ms_plugins->addItem(mf);
mf = new CMenuForwarder(LOCALE_MPKEY_PLUGIN, true, g_settings.movieplayer_plugin, this, "movieplayer_plugin");
mf->setHint("", LOCALE_MENU_HINT_MOVIEPLAYER_PLUGIN);
ms_plugins->addItem(mf);
ms_plugins->addItem(GenericMenuSeparatorLine);
CPluginsHideMenu pluginsHideMenu;
mf = new CMenuForwarder(LOCALE_PLUGINS_HIDE, true, NULL, &pluginsHideMenu, NULL, CRCInput::RC_red);
mf->setHint(NEUTRINO_ICON_HINT_IMAGELOGO, LOCALE_MENU_HINT_PLUGINS_HIDE);
ms_plugins->addItem(mf);
int res = ms_plugins->exec(NULL, "");
delete ms_plugins;
return res;
}
#endif
int CMiscMenue::showMiscSettingsSelectWeatherLocation()
{
int select = 0;
int res = 0;
if (WEATHER_LOCATION_OPTION_COUNT > 1)
{
CMenuWidget *m = new CMenuWidget(LOCALE_WEATHER_LOCATION, NEUTRINO_ICON_LANGUAGE);
CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select);
m->addItem(GenericMenuSeparator);
CMenuForwarder* mf;
for (size_t i = 0; i < WEATHER_LOCATION_OPTION_COUNT; i++)
{
mf = new CMenuForwarder(WEATHER_LOCATION_OPTIONS[i].key, true, NULL, selector, to_string(i).c_str());
mf->setHint(NEUTRINO_ICON_HINT_SETTINGS, WEATHER_LOCATION_OPTIONS[i].value.c_str());
m->addItem(mf);
}
m->enableSaveScreen();
res = m->exec(NULL, "");
if (!m->gotAction())
return res;
delete selector;
}
g_settings.weather_location = WEATHER_LOCATION_OPTIONS[select].value;
g_settings.weather_city = std::string(WEATHER_LOCATION_OPTIONS[select].key);
CWeather::getInstance()->setCoords(g_settings.weather_location, g_settings.weather_city);
return res;
}
#ifdef CPU_FREQ
//CPU
@@ -742,6 +834,15 @@ bool CMiscMenue::changeNotify(const neutrino_locale_t OptionName, void * /*data*
ret = menu_return::RETURN_REPAINT;
}
#endif
else if (ARE_LOCALES_EQUAL(OptionName, LOCALE_WEATHER_API_KEY))
{
g_settings.weather_enabled = g_settings.weather_enabled && CApiKey::check_weather_api_key();
if (g_settings.weather_enabled)
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_TMDB_API_KEY))
{
g_settings.tmdb_enabled = g_settings.tmdb_enabled && CApiKey::check_tmdb_api_key();