diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 5eb82d734..b60a63732 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1525,6 +1525,7 @@ menu.hint_volume_digits Zifferndarstellung der Lautstärkeanzeige ein- oder auss menu.hint_volume_pos Wählen Sie die Position der Lautstärkeanzeige aus menu.hint_volume_size Wählen Sie die Höhe der Lautstärkeanzeige menu.hint_webtv_setup Hier konfigurierte WebTV-Kanäle finden Sie in der Kanalverwaltung. +menu.hint_webtv_xml_auto Lädt automatisch alle WebTV-Dateien aus %s/ und %s/ menu.hint_window_size Kanalliste, EPG-Infos und einige andere Fenster werden mit diesem Faktor skaliert menu.hint_youtube_dev_id Geben Sie die YouTube Dev ID ein. Eine leere Eingabe schaltet die YouTube-Unterstützung aus menu.hint_youtube_enabled Schaltet die YouTube-Unterstützung ein oder aus @@ -2564,9 +2565,12 @@ videomenu.videoformat_169 16:9 videomenu.videoformat_43 4:3 videomenu.videomode Videosystem webtv.head WebTV -webtv.xml WebTV-XML-Dateien -webtv.xml.add XML-Datei hinzufügen -webtv.xml.del XML-Datei entfernen +webtv.xml WebTV-Dateien +webtv.xml.add Hinzufügen +webtv.xml.auto WebTV-Dateien automatisch laden +webtv.xml.del Entfernen +webtv.xml.enter Eintragen +webtv.xml.reload Neu laden window_size Fenstergröße in % wizard.initial_settings Grundeinstellungen gefunden wizard.install_settings Kanalliste für Astra 19.2°E installieren? diff --git a/data/locale/english.locale b/data/locale/english.locale index 4144f595a..0baf106c8 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1525,6 +1525,7 @@ menu.hint_volume_digits Numeric display of the volumebar on/off menu.hint_volume_pos Select volume indicator position menu.hint_volume_size Select volume indicator height menu.hint_webtv_setup WebTV channels configured here will be available in the standard channel lists. +menu.hint_webtv_xml_auto Auto-load all existing WebTV files from %s/ and %s/ menu.hint_window_size Channellist, EPG-infos and some other windows are scaled by this factor menu.hint_youtube_dev_id Type your YouTube Dev ID. An empty input disables YouTube support menu.hint_youtube_enabled Enable or disable YouTube support @@ -2564,9 +2565,12 @@ videomenu.videoformat_169 16:9 videomenu.videoformat_43 4:3 videomenu.videomode Digital video mode webtv.head WebTV -webtv.xml WebTV XML files -webtv.xml.add Add XML file -webtv.xml.del Remove XML file +webtv.xml WebTV files +webtv.xml.add Add +webtv.xml.auto Auto-load WebTV files +webtv.xml.del Remove +webtv.xml.enter Enter +webtv.xml.reload Reload window_size Window size in % wizard.initial_settings Initial settings found wizard.install_settings Do you want to install channels for Astra 19.2°E? diff --git a/src/gui/webtv_setup.cpp b/src/gui/webtv_setup.cpp index 6d33a64f3..a58a986d2 100644 --- a/src/gui/webtv_setup.cpp +++ b/src/gui/webtv_setup.cpp @@ -35,9 +35,15 @@ #include #include "webtv_setup.h" + +#include +#include +#include +#include + CWebTVSetup::CWebTVSetup() { - width = 55; + width = 75; selected = -1; item_offset = 0; changed = false; @@ -54,10 +60,11 @@ const CMenuOptionChooser::keyval_ext LIVESTREAM_RESOLUTION_OPTIONS[] = }; #define LIVESTREAM_RESOLUTION_OPTION_COUNT (sizeof(LIVESTREAM_RESOLUTION_OPTIONS)/sizeof(CMenuOptionChooser::keyval_ext)) -#define CWebTVSetupFooterButtonCount 2 +#define CWebTVSetupFooterButtonCount 3 static const struct button_label CWebTVSetupFooterButtons[CWebTVSetupFooterButtonCount] = { { NEUTRINO_ICON_BUTTON_RED, LOCALE_WEBTV_XML_DEL }, - { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_WEBTV_XML_ADD } + { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_WEBTV_XML_ADD }, + { NEUTRINO_ICON_BUTTON_BLUE, LOCALE_WEBTV_XML_RELOAD } }; int CWebTVSetup::exec(CMenuTarget* parent, const std::string & actionKey) @@ -108,6 +115,11 @@ int CWebTVSetup::exec(CMenuTarget* parent, const std::string & actionKey) } return res; } + + if(actionKey == "r" /* reload */) { + changed = true; + return menu_return::RETURN_EXIT_ALL; + } if (actionKey == "script_path") { const char *action_str = "ScriptPath"; chooserDir(g_settings.livestreamScriptPath, false, action_str); @@ -129,6 +141,7 @@ int CWebTVSetup::Show() m = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_STREAMING, width, MN_WIDGET_ID_WEBTVSETUP); m->addKey(CRCInput::RC_red, this, "d"); m->addKey(CRCInput::RC_green, this, "a"); + m->addKey(CRCInput::RC_blue, this, "r"); m->addIntroItems(LOCALE_WEBTV_HEAD, LOCALE_LIVESTREAM_HEAD); @@ -146,30 +159,142 @@ int CWebTVSetup::Show() m->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_WEBTV_XML)); + // TODO: show/hide autoloaded content when switching g_settings.webtv_xml_auto + char hint_text[1024]; + snprintf(hint_text, sizeof(hint_text)-1, g_Locale->getText(LOCALE_MENU_HINT_WEBTV_XML_AUTO), WEBTVDIR, WEBTVDIR_VAR); + CMenuOptionChooser *oc = new CMenuOptionChooser(LOCALE_WEBTV_XML_AUTO, &g_settings.webtv_xml_auto, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true, this, CRCInput::convertDigitToKey(shortcut++)); + oc->setHint("", hint_text); + m->addItem(oc); + m->addItem(GenericMenuSeparator); + item_offset = m->getItemsCount(); + // show autoloaded webtv files for (std::list::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it) - m->addItem(new CMenuForwarder(*it, true, NULL, this, "c")); + { + if (webtv_xml_autodir((*it))) + m->addItem(new CMenuForwarder(*it, false, "auto")); + } + if (item_offset < m->getItemsCount()) + m->addItem(GenericMenuSeparator); + + item_offset = m->getItemsCount(); + // show users webtv files + for (std::list::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it) + { + if (!webtv_xml_autodir((*it))) + m->addItem(new CMenuForwarder(*it, true, NULL, this, "c")); + } m->setFooter(CWebTVSetupFooterButtons, CWebTVSetupFooterButtonCount); //Why we need here an extra buttonbar? int res = m->exec(NULL, ""); m->hide(); - if (changed) { - g_settings.webtv_xml.clear(); - for (int i = item_offset; i < m->getItemsCount(); i++) { - CMenuItem *item = m->getItem(i); - CMenuForwarder *f = static_cast(item); - g_settings.webtv_xml.push_back(f->getName()); - } - g_Zapit->reinitChannels(); - changed = false; + + if (changed) + { + g_settings.webtv_xml.clear(); + for (int i = item_offset; i < m->getItemsCount(); i++) + { + CMenuItem *item = m->getItem(i); + CMenuForwarder *f = static_cast(item); + g_settings.webtv_xml.push_back(f->getName()); + } + webtv_xml_auto(); + g_Zapit->reinitChannels(); + changed = false; } delete m; - return res; } + +bool CWebTVSetup::changeNotify(const neutrino_locale_t OptionName, void */*data*/) +{ + int ret = menu_return::RETURN_NONE; + + if (ARE_LOCALES_EQUAL(OptionName, LOCALE_WEBTV_XML_AUTO)) + { + changed = true; + ret = menu_return::RETURN_REPAINT; + } + + return ret; +} + + +int filefilter(const struct dirent *entry) +{ + int len = strlen(entry->d_name); + if (len > 3 && ( + (entry->d_name[len-3] == 'x' && entry->d_name[len-2] == 'm' && entry->d_name[len-1] == 'l') + || (entry->d_name[len-3] == 'm' && entry->d_name[len-2] == '3' && entry->d_name[len-1] == 'u') + || ( entry->d_name[len-2] == 't' && entry->d_name[len-1] == 'v') + ) + ) + return 1; + return 0; +} + + +void CWebTVSetup::webtv_xml_auto() +{ + if (g_settings.webtv_xml_auto) + { + const char *dirs[] = {WEBTVDIR_VAR, WEBTVDIR}; + struct dirent **filelist; + char webtv_file[1024] = {0}; + for (int i = 0; i < 2; i++) + { + int file_count = scandir(dirs[i], &filelist, filefilter, alphasort); + if (file_count > -1) + { + for (int count = 0; count < file_count; count++) + { + snprintf(webtv_file, sizeof(webtv_file), "%s/%s", dirs[i], filelist[count]->d_name); + if (file_size(webtv_file)) + { + bool found = false; + for (std::list::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); it++) + found |= ((*it).find(filelist[count]->d_name) != std::string::npos); + + if (!found) + { + printf("[CWebTVSetup] loading: %s\n", webtv_file); + g_settings.webtv_xml.push_back(webtv_file); + } + else + { + printf("[CWebTVSetup] skipping: %s\n", webtv_file); + } + } + } + } + } + } +} + + +bool CWebTVSetup::webtv_xml_autodir(std::string directory) +{ + if ( + (directory.empty()) + || (directory.find(WEBTVDIR) != std::string::npos) + || (directory.find(WEBTVDIR_VAR) != std::string::npos) + ) + return true; + return false; +} + +int xml_filter(const struct dirent *entry) +{ + int len = strlen(entry->d_name); + if (len > 3 && entry->d_name[len-3] == 'x' && entry->d_name[len-2] == 'm' && entry->d_name[len-1] == 'l') + return 1; + return 0; +} + + /* ## CWebTVResolution ############################################# */ CWebTVResolution::CWebTVResolution() diff --git a/src/gui/webtv_setup.h b/src/gui/webtv_setup.h index 698719ee8..e675b9881 100644 --- a/src/gui/webtv_setup.h +++ b/src/gui/webtv_setup.h @@ -27,7 +27,7 @@ #include #include -class CWebTVSetup : public CMenuTarget +class CWebTVSetup : public CMenuTarget, CChangeObserver { private: int width; @@ -39,6 +39,9 @@ class CWebTVSetup : public CMenuTarget CWebTVSetup(); int exec(CMenuTarget* parent, const std::string & actionKey); int Show(); + bool changeNotify(const neutrino_locale_t OptionName, void *data); + void webtv_xml_auto(); + bool webtv_xml_autodir(std::string directory); }; class CWebTVResolution : public CMenuTarget diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 1da9462c3..41ccac4f3 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -93,6 +93,7 @@ #include "gui/update.h" #include "gui/videosettings.h" #include "gui/audio_select.h" +#include "gui/webtv_setup.h" #include "gui/widget/hintbox.h" #include "gui/widget/icons.h" @@ -703,6 +704,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.logo_hdd_dir = configfile.getString( "logo_hdd_dir", "/media/sda1/logos" ); + g_settings.webtv_xml_auto = configfile.getInt32("webtv_xml_auto", 1); g_settings.webtv_xml.clear(); int webtv_count = configfile.getInt32("webtv_xml_count", 0); if (webtv_count) { @@ -719,6 +721,8 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.webtv_xml.push_back(webtv_xml); } + CWebTVSetup webtvsetup; + webtvsetup.webtv_xml_auto(); g_settings.webradio_xml.clear(); #ifndef BOXMODEL_CS_HD1 /* @@ -1426,7 +1430,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setString ( "plugins_lua", g_settings.plugins_lua ); configfile.setString ( "logo_hdd_dir", g_settings.logo_hdd_dir ); - + configfile.setInt32("webtv_xml_auto", g_settings.webtv_xml_auto); int webtv_count = 0; for (std::list::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it) { std::string k = "webtv_xml_" + to_string(webtv_count); diff --git a/src/system/locals.h b/src/system/locals.h index 82721dccd..911d656b9 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1552,6 +1552,7 @@ typedef enum LOCALE_MENU_HINT_VOLUME_POS, LOCALE_MENU_HINT_VOLUME_SIZE, LOCALE_MENU_HINT_WEBTV_SETUP, + LOCALE_MENU_HINT_WEBTV_XML_AUTO, LOCALE_MENU_HINT_WINDOW_SIZE, LOCALE_MENU_HINT_YOUTUBE_DEV_ID, LOCALE_MENU_HINT_YOUTUBE_ENABLED, @@ -2593,7 +2594,10 @@ typedef enum LOCALE_WEBTV_HEAD, LOCALE_WEBTV_XML, LOCALE_WEBTV_XML_ADD, + LOCALE_WEBTV_XML_AUTO, LOCALE_WEBTV_XML_DEL, + LOCALE_WEBTV_XML_ENTER, + LOCALE_WEBTV_XML_RELOAD, LOCALE_WINDOW_SIZE, LOCALE_WIZARD_INITIAL_SETTINGS, LOCALE_WIZARD_INSTALL_SETTINGS, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index eaebad214..e55b77b62 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1552,6 +1552,7 @@ const char * locale_real_names[] = "menu.hint_volume_pos", "menu.hint_volume_size", "menu.hint_webtv_setup", + "menu.hint_webtv_xml_auto", "menu.hint_window_size", "menu.hint_youtube_dev_id", "menu.hint_youtube_enabled", @@ -2593,7 +2594,10 @@ const char * locale_real_names[] = "webtv.head", "webtv.xml", "webtv.xml.add", + "webtv.xml.auto", "webtv.xml.del", + "webtv.xml.enter", + "webtv.xml.reload", "window_size", "wizard.initial_settings", "wizard.install_settings", diff --git a/src/system/settings.h b/src/system/settings.h index 785d800e9..132573889 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -330,6 +330,7 @@ struct SNeutrinoSettings std::list webtv_xml; std::list webradio_xml; std::list xmltv_xml; // see http://wiki.xmltv.org/ + int webtv_xml_auto; //personalize enum PERSONALIZE_SETTINGS //settings.h