From e3a5dbf6f4e65af9e63b5362dbc0bd4985228ffa Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Tue, 25 Sep 2018 23:53:35 +0200 Subject: [PATCH] - webtv-setup: implement webradio-setup into webtv-setup code Conflicts: src/gui/webtv_setup.cpp Signed-off-by: Thilo Graf --- data/locale/deutsch.locale | 3 ++ data/locale/english.locale | 3 ++ src/gui/mediaplayer_setup.cpp | 10 ++++-- src/gui/webtv_setup.cpp | 68 ++++++++++++++++++++++++++--------- src/gui/webtv_setup.h | 4 ++- src/neutrino.cpp | 27 ++++++++++++-- src/neutrino_menue.h | 3 +- src/system/locals.h | 3 ++ src/system/locals_intern.h | 3 ++ src/system/settings.h | 1 + 10 files changed, 101 insertions(+), 24 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index b02dd0d8f..a4cc13643 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -1524,6 +1524,7 @@ menu.hint_volume Wählen Sie die Anzeigeoptionen für die Lautstärke menu.hint_volume_digits Zifferndarstellung der Lautstärkeanzeige ein- oder ausschalten 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_webradio_setup Hier konfigurierte WebRadio-Kanäle finden Sie in der Kanalverwaltung. 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 @@ -2565,6 +2566,8 @@ videomenu.videoformat_149 14:9 videomenu.videoformat_169 16:9 videomenu.videoformat_43 4:3 videomenu.videomode Videosystem +webradio.head WebRadio +webradio.xml WebRadio-Dateien webtv.head WebTV webtv.xml WebTV-Dateien webtv.xml.add Hinzufügen diff --git a/data/locale/english.locale b/data/locale/english.locale index 0243f63fe..3dff7d723 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -1524,6 +1524,7 @@ menu.hint_volume Configure Volume GUI options 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_webradio_setup WebRadio channels configured here will be available in the standard channel lists. 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 @@ -2565,6 +2566,8 @@ videomenu.videoformat_149 14:9 videomenu.videoformat_169 16:9 videomenu.videoformat_43 4:3 videomenu.videomode Digital video mode +webradio.head WebRadio +webradio.xml WebRadio files webtv.head WebTV webtv.xml WebTV files webtv.xml.add Add diff --git a/src/gui/mediaplayer_setup.cpp b/src/gui/mediaplayer_setup.cpp index 3b312ae95..1ac0e6d4f 100644 --- a/src/gui/mediaplayer_setup.cpp +++ b/src/gui/mediaplayer_setup.cpp @@ -101,19 +101,23 @@ int CMediaPlayerSetup::showMediaPlayerSetup() mediaSetup->addItem(GenericMenuSeparator); CWebTVSetup wsetup; - mf = new CMenuForwarder(LOCALE_WEBTV_HEAD, true, NULL, &wsetup, "show_menu", CRCInput::RC_yellow); + mf = new CMenuForwarder(LOCALE_WEBTV_HEAD, true, NULL, &wsetup, "webtv_menu", CRCInput::RC_yellow); mf->setHint(NEUTRINO_ICON_HINT_WEBTV, LOCALE_MENU_HINT_WEBTV_SETUP); mediaSetup->addItem(mf); + mf = new CMenuForwarder(LOCALE_WEBRADIO_HEAD, true, NULL, &wsetup, "webradio_menu", CRCInput::RC_blue); + mf->setHint(NEUTRINO_ICON_HINT_WEBTV /*FIXME*/, LOCALE_MENU_HINT_WEBRADIO_SETUP); + mediaSetup->addItem(mf); + + int shortcut = 1; CXMLTVSetup xmltvsetup; - mf = new CMenuForwarder(LOCALE_XMLTV_HEAD, true, NULL, &xmltvsetup, "show_menu", CRCInput::RC_blue); + mf = new CMenuForwarder(LOCALE_XMLTV_HEAD, true, NULL, &xmltvsetup, "show_menu", CRCInput::convertDigitToKey(shortcut++)); mf->setHint(NEUTRINO_ICON_HINT_XMLTV, LOCALE_MENU_HINT_XMLTV_SETUP); mediaSetup->addItem(mf); mediaSetup->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_MAINMENU_MOVIEPLAYER)); CMovieBrowser msetup; - int shortcut = 1; mf = new CMenuForwarder(LOCALE_MOVIEBROWSER_HEAD, true, NULL, &msetup, "show_menu", CRCInput::convertDigitToKey(shortcut++)); mf->setHint(NEUTRINO_ICON_HINT_MB, LOCALE_MENU_HINT_MOVIEBROWSER_SETUP); mediaSetup->addItem(mf); diff --git a/src/gui/webtv_setup.cpp b/src/gui/webtv_setup.cpp index 1bcaae9a1..1d629d603 100644 --- a/src/gui/webtv_setup.cpp +++ b/src/gui/webtv_setup.cpp @@ -1,8 +1,8 @@ /* - WebTV Setup - - (C) 2012-2013 by martii + WebTV/WebRadio Setup + Copyright (C) 2012-2013 martii + Copyright (C) 2018 by vanhofen License: GPL @@ -13,7 +13,7 @@ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License @@ -44,6 +44,7 @@ CWebTVSetup::CWebTVSetup() { + webradio = false; width = 75; selected = -1; item_offset = 0; @@ -108,7 +109,10 @@ int CWebTVSetup::exec(CMenuTarget *parent, const std::string &actionKey) if (fileBrowser.exec(dirname.c_str())) { f->setName(fileBrowser.getSelectedFile()->Name); - g_settings.last_webtv_dir = dirname; + if (webradio) + g_settings.last_webradio_dir = dirname; + else + g_settings.last_webtv_dir = dirname; changed = true; } } @@ -122,11 +126,14 @@ int CWebTVSetup::exec(CMenuTarget *parent, const std::string &actionKey) fileFilter.addFilter("tv"); fileFilter.addFilter("m3u"); fileBrowser.Filter = &fileFilter; - if (fileBrowser.exec(g_settings.last_webtv_dir.c_str()) == true) + if (fileBrowser.exec(webradio ? g_settings.last_webradio_dir.c_str() : g_settings.last_webtv_dir.c_str()) == true) { std::string s = fileBrowser.getSelectedFile()->Name; m->addItem(new CMenuForwarder(s, true, NULL, this, "c")); - g_settings.last_webtv_dir = s.substr(0, s.rfind('/')).c_str(); + if (webradio) + g_settings.last_webradio_dir = s.substr(0, s.rfind('/')).c_str(); + else + g_settings.last_webtv_dir = s.substr(0, s.rfind('/')).c_str(); changed = true; } return res; @@ -134,6 +141,8 @@ int CWebTVSetup::exec(CMenuTarget *parent, const std::string &actionKey) if (actionKey == "e" /* enter */) { std::string tpl = "http://xxx.xxx.xxx.xxx/control/xmltv.m3u"; + if (webradio) + tpl.clear(); // no template for webradio yet std::string entry = tpl; CKeyboardInput *e = new CKeyboardInput(LOCALE_WEBTV_XML_ENTER, &entry, 50); @@ -158,6 +167,10 @@ int CWebTVSetup::exec(CMenuTarget *parent, const std::string &actionKey) chooserDir(g_settings.livestreamScriptPath, false, action_str); return res; } + if (actionKey == "webradio_menu") + { + webradio = true; + } if (parent) parent->hide(); @@ -170,28 +183,35 @@ int CWebTVSetup::exec(CMenuTarget *parent, const std::string &actionKey) int CWebTVSetup::Show() { item_offset = 0; + std::list webchannels = (webradio ? g_settings.webradio_xml : g_settings.webtv_xml); - m = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_STREAMING, width, MN_WIDGET_ID_WEBTVSETUP); + m = new CMenuWidget(LOCALE_MAINMENU_SETTINGS, NEUTRINO_ICON_STREAMING, width, webradio ? MN_WIDGET_ID_WEBRADIOSETUP : MN_WIDGET_ID_WEBTVSETUP); m->addKey(CRCInput::RC_red, this, "d"); m->addKey(CRCInput::RC_green, this, "a"); m->addKey(CRCInput::RC_yellow, this, "e"); m->addKey(CRCInput::RC_blue, this, "r"); - m->addIntroItems(LOCALE_WEBTV_HEAD, LOCALE_LIVESTREAM_HEAD); + m->addIntroItems(webradio ? LOCALE_WEBRADIO_HEAD : LOCALE_WEBTV_HEAD, LOCALE_LIVESTREAM_HEAD); bool _mode_webtv = (CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_webtv) && (!CZapit::getInstance()->GetCurrentChannel()->getScriptName().empty()); + bool _mode_webradio = (CNeutrinoApp::getInstance()->getMode() == NeutrinoModes::mode_webradio) && + (!CZapit::getInstance()->GetCurrentChannel()->getScriptName().empty()); + CMenuForwarder *mf; int shortcut = 1; - mf = new CMenuForwarder(LOCALE_LIVESTREAM_SCRIPTPATH, !_mode_webtv, g_settings.livestreamScriptPath, this, "script_path", CRCInput::convertDigitToKey(shortcut++)); + mf = new CMenuForwarder(LOCALE_LIVESTREAM_SCRIPTPATH, !_mode_webtv || !_mode_webradio, g_settings.livestreamScriptPath, this, "script_path", CRCInput::convertDigitToKey(shortcut++)); m->addItem(mf); #if 0 mf = new CMenuForwarder(LOCALE_LIVESTREAM_RESOLUTION, _mode_webtv, NULL, new CWebTVResolution(), NULL, CRCInput::convertDigitToKey(shortcut++)); m->addItem(mf); #endif - m->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_WEBTV_XML)); + m->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, webradio ? LOCALE_WEBRADIO_XML : LOCALE_WEBTV_XML)); + + if (!webradio) + { // TODO: show/hide autoloaded content when switching g_settings.webtv_xml_auto char hint_text[1024]; @@ -203,7 +223,7 @@ int CWebTVSetup::Show() 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) + for (std::list::iterator it = webchannels.begin(); it != webchannels.end(); ++it) { if (webtv_xml_autodir((*it))) m->addItem(new CMenuForwarder(*it, false, "auto")); @@ -211,15 +231,17 @@ int CWebTVSetup::Show() 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) + for (std::list::iterator it = webchannels.begin(); it != webchannels.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? + m->setFooter(CWebTVSetupFooterButtons, CWebTVSetupFooterButtonCount); int res = m->exec(NULL, ""); m->hide(); @@ -228,14 +250,24 @@ int CWebTVSetup::Show() { CHintBox hint(LOCALE_MESSAGEBOX_INFO, LOCALE_SERVICEMENU_RELOAD_HINT); hint.paint(); - g_settings.webtv_xml.clear(); + webchannels.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()); + webchannels.push_back(f->getName()); } webtv_xml_auto(); + if (webradio) + { + g_settings.webradio_xml.clear(); + g_settings.webradio_xml = webchannels; + } + else + { + g_settings.webtv_xml.clear(); + g_settings.webtv_xml = webchannels; + } g_Zapit->reinitChannels(); changed = false; hint.hide(); @@ -276,6 +308,10 @@ int filefilter(const struct dirent *entry) void CWebTVSetup::webtv_xml_auto() { + // TODO: g_settings.webradio_xml_auto? + if (webradio) + return; + if (g_settings.webtv_xml_auto) { const char *dirs[] = {WEBTVDIR_VAR, WEBTVDIR}; diff --git a/src/gui/webtv_setup.h b/src/gui/webtv_setup.h index 7bbe6d834..8f87e245c 100644 --- a/src/gui/webtv_setup.h +++ b/src/gui/webtv_setup.h @@ -1,7 +1,8 @@ /* - WebTV setup menue + WebTV/WebRadio Setup Copyright (C) 2012-2013 martii + Copyright (C) 2018 by vanhofen License: GPL @@ -30,6 +31,7 @@ class CWebTVSetup : public CMenuTarget, CChangeObserver { private: + bool webradio; int width; int selected; int item_offset; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 41ccac4f3..0217d533e 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -621,6 +621,7 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.network_nfs_recordingdir = configfile.getString( "network_nfs_recordingdir", "/media/sda1/movies" ); g_settings.timeshiftdir = configfile.getString( "timeshiftdir", "" ); g_settings.downloadcache_dir = configfile.getString( "downloadcache_dir", g_settings.network_nfs_recordingdir.c_str()); + g_settings.last_webradio_dir = configfile.getString( "last_webradio_dir", CONFIGDIR); g_settings.last_webtv_dir = configfile.getString( "last_webtv_dir", CONFIGDIR); g_settings.temp_timeshift = configfile.getInt32( "temp_timeshift", 0 ); @@ -730,9 +731,20 @@ int CNeutrinoApp::loadSetup(const char * fname) because of driver- or firmware-issues or so. Not sure. So let's avoid loading webradio_xml to get an empty webradio bouquet. */ - std::string webradio_xml = configfile.getString("webradio_xml", WEBRADIO_XML); - if (file_size(webradio_xml.c_str())) - g_settings.webradio_xml.push_back(webradio_xml); + int webradio_count = configfile.getInt32("webradio_xml_count", 0); + if (webradio_count) { + for (int i = 0; i < webradio_count; i++) { + std::string k = "webradio_xml_" + to_string(i); + std::string webradio_xml = configfile.getString(k, ""); + if (webradio_xml.empty()) + continue; + g_settings.webradio_xml.push_back(webradio_xml); + } + } else { + std::string webradio_xml = configfile.getString("webradio_xml", WEBRADIO_XML); + if (file_size(webradio_xml.c_str())) + g_settings.webradio_xml.push_back(webradio_xml); + } #endif g_settings.xmltv_xml.clear(); @@ -1396,6 +1408,7 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setString( "network_nfs_recordingdir", g_settings.network_nfs_recordingdir); configfile.setString( "timeshiftdir", g_settings.timeshiftdir); configfile.setString( "downloadcache_dir", g_settings.downloadcache_dir); + configfile.setString( "last_webradio_dir", g_settings.last_webradio_dir); configfile.setString( "last_webtv_dir", g_settings.last_webtv_dir); configfile.setBool ("filesystem_is_utf8" , g_settings.filesystem_is_utf8 ); @@ -1439,6 +1452,14 @@ void CNeutrinoApp::saveSetup(const char * fname) } configfile.setInt32 ( "webtv_xml_count", g_settings.webtv_xml.size()); + int webradio_count = 0; + for (std::list::iterator it = g_settings.webradio_xml.begin(); it != g_settings.webradio_xml.end(); ++it) { + std::string k = "webradio_xml_" + to_string(webradio_count); + configfile.setString(k, *it); + webradio_count++; + } + configfile.setInt32 ( "webradio_xml_count", webradio_count); + int xmltv_count = 0; for (std::list::iterator it = g_settings.xmltv_xml.begin(); it != g_settings.xmltv_xml.end(); ++it) { std::string k = "xmltv_xml_" + to_string(xmltv_count); diff --git a/src/neutrino_menue.h b/src/neutrino_menue.h index 4411e7212..b69b0c122 100644 --- a/src/neutrino_menue.h +++ b/src/neutrino_menue.h @@ -107,7 +107,8 @@ enum MN_WIDGET_ID //audio setup MN_WIDGET_ID_AUDIOSETUP, - //webtv setup + //webtv/webradio setup + MN_WIDGET_ID_WEBRADIOSETUP, MN_WIDGET_ID_WEBTVSETUP, MN_WIDGET_ID_LIVESTREAM_RESOLUTION, diff --git a/src/system/locals.h b/src/system/locals.h index 79a553a13..f2b95da28 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -1551,6 +1551,7 @@ typedef enum LOCALE_MENU_HINT_VOLUME_DIGITS, LOCALE_MENU_HINT_VOLUME_POS, LOCALE_MENU_HINT_VOLUME_SIZE, + LOCALE_MENU_HINT_WEBRADIO_SETUP, LOCALE_MENU_HINT_WEBTV_SETUP, LOCALE_MENU_HINT_WEBTV_XML_AUTO, LOCALE_MENU_HINT_WINDOW_SIZE, @@ -2592,6 +2593,8 @@ typedef enum LOCALE_VIDEOMENU_VIDEOFORMAT_169, LOCALE_VIDEOMENU_VIDEOFORMAT_43, LOCALE_VIDEOMENU_VIDEOMODE, + LOCALE_WEBRADIO_HEAD, + LOCALE_WEBRADIO_XML, LOCALE_WEBTV_HEAD, LOCALE_WEBTV_XML, LOCALE_WEBTV_XML_ADD, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 3be5179cf..25486a9ea 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -1551,6 +1551,7 @@ const char * locale_real_names[] = "menu.hint_volume_digits", "menu.hint_volume_pos", "menu.hint_volume_size", + "menu.hint_webradio_setup", "menu.hint_webtv_setup", "menu.hint_webtv_xml_auto", "menu.hint_window_size", @@ -2592,6 +2593,8 @@ const char * locale_real_names[] = "videomenu.videoformat_169", "videomenu.videoformat_43", "videomenu.videomode", + "webradio.head", + "webradio.xml", "webtv.head", "webtv.xml", "webtv.xml.add", diff --git a/src/system/settings.h b/src/system/settings.h index 132573889..3efa68a89 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -482,6 +482,7 @@ struct SNeutrinoSettings std::string network_nfs_recordingdir; std::string timeshiftdir; std::string downloadcache_dir; + std::string last_webradio_dir; std::string last_webtv_dir; //recording