From 124c8c6d63766d127155ab3698807bed1d2e4112 Mon Sep 17 00:00:00 2001 From: svenhoefer Date: Sun, 16 Dec 2018 01:17:00 +0100 Subject: [PATCH] - timerlist: allow to enable/disable remote boxes Signed-off-by: Thilo Graf --- data/locale/deutsch.locale | 7 ++--- data/locale/english.locale | 7 ++--- src/gui/timerlist.cpp | 54 +++++++++++++++++++++++++++++++------- src/neutrino.cpp | 12 ++++++--- src/system/locals.h | 1 + src/system/locals_intern.h | 1 + src/system/settings.h | 1 + 7 files changed, 65 insertions(+), 18 deletions(-) diff --git a/data/locale/deutsch.locale b/data/locale/deutsch.locale index 89bc71733..50e30b9ac 100644 --- a/data/locale/deutsch.locale +++ b/data/locale/deutsch.locale @@ -2209,11 +2209,12 @@ recordingmenu.vcr Videorekorder recordingmenu.vtxt_pid Teletext aufnehmen recordingmenu.zap_on_announce Umschalten bei Ankündigung recordtimer.announce Die Aufnahme beginnt in wenigen Minuten. -remotebox_add hinzufügen +remotebox_add Hinzufügen remotebox_channel_na Kanal auf Remote-Box nicht verfügbar -remotebox_del löschen +remotebox_del Löschen remotebox_head Remote-Boxen -remotebox_mod bearbeiten +remotebox_mod Bearbeiten +remotebox_onoff Ein/Aus remotebox_pass Passwort remotebox_port Port remotebox_rbaddr Adresse diff --git a/data/locale/english.locale b/data/locale/english.locale index d4ba35ed7..33c99af23 100644 --- a/data/locale/english.locale +++ b/data/locale/english.locale @@ -2207,11 +2207,12 @@ recordingmenu.vcr vcr recordingmenu.vtxt_pid record teletext recordingmenu.zap_on_announce zap on recording announce recordtimer.announce Recording starts in a few minutes -remotebox_add add +remotebox_add Add remotebox_channel_na Channel not available on Remote-Box -remotebox_del delete +remotebox_del Delete remotebox_head Remote-Boxes -remotebox_mod modify +remotebox_mod Modify +remotebox_onoff On/Off remotebox_pass Password remotebox_port Port remotebox_rbaddr Address diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index 1c3178068..f00d5d0a8 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -360,6 +360,19 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) return menu_return::RETURN_REPAINT; } + if (actionKey == "onoff_ip") + { + bselected = remboxmenu->getSelected(); + CMenuItem* item = remboxmenu->getItem(bselected); + CMenuForwarder *f = static_cast(item); + std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); + std::advance(it, bselected-item_offset); + it->enabled = !it->enabled; + f->setInfoIconRight(it->enabled ? NEUTRINO_ICON_MARKER_DIALOG_OK : NEUTRINO_ICON_MARKER_DIALOG_OFF); + changed = true; + return menu_return::RETURN_REPAINT; + } + if (actionKey == "cha_ip") { bselected = remboxmenu->getSelected(); @@ -680,12 +693,15 @@ struct button_label TimerListButtons[] = // int to match the type in paintButtons int TimerListButtonsCount = sizeof(TimerListButtons)/sizeof(TimerListButtons[0]); -#define RemoteBoxFooterButtonCount 3 -static const struct button_label RemoteBoxFooterButtons[RemoteBoxFooterButtonCount] = { +static const struct button_label RemoteBoxButtons[] = +{ { NEUTRINO_ICON_BUTTON_RED, LOCALE_REMOTEBOX_DEL }, { NEUTRINO_ICON_BUTTON_GREEN, LOCALE_REMOTEBOX_ADD }, + { NEUTRINO_ICON_BUTTON_YELLOW, LOCALE_REMOTEBOX_ONOFF }, { NEUTRINO_ICON_BUTTON_OKAY, LOCALE_REMOTEBOX_MOD } }; +// int to match the type in paintButtons +int RemoteBoxButtonsCount = sizeof(RemoteBoxButtons)/sizeof(RemoteBoxButtons[0]); void CTimerList::updateEvents(void) { @@ -722,12 +738,21 @@ void CTimerList::RemoteBoxSelect() { int select = 0; - if (g_settings.timer_remotebox_ip.size() > 1) { + if (g_settings.timer_remotebox_ip.size() > 1) + { CMenuWidget *m = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER); CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); + // we don't show introitems, so we add a separator for a smoother view + m->addItem(GenericMenuSeparator); + + CMenuForwarder* mf; for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) - m->addItem(new CMenuForwarder(it->rbname, it->online, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); + { + mf = new CMenuForwarder(it->rbname, it->online && it->enabled, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str()); + mf->setInfoIconRight(it->enabled ? NEUTRINO_ICON_MARKER_DIALOG_OK : NEUTRINO_ICON_MARKER_DIALOG_OFF); + m->addItem(mf); + } m->enableSaveScreen(); m->exec(NULL, ""); @@ -736,7 +761,9 @@ void CTimerList::RemoteBoxSelect() } std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); - std::advance(it,select); + std::advance(it, select); + if (!it->enabled) + return; if (askUserOnRemoteTimerConflict(timerlist[selected].announceTime, timerlist[selected].stopTime, (char*) it->rbname.c_str())) { strncpy(timerlist[selected].remotebox_name,it->rbname.c_str(),sizeof(timerlist[selected].remotebox_name)); @@ -808,6 +835,9 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) std::string r_url; for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) { + if (!it->enabled) + continue; + r_url = "http://"; r_url += RemoteBoxConnectUrl(it->rbname); r_url += "/control/timer?format=json"; @@ -1118,14 +1148,20 @@ bool CTimerList::RemoteBoxSetup() remboxmenu = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER, 50); remboxmenu->addKey(CRCInput::RC_red, this, "del_ip"); remboxmenu->addKey(CRCInput::RC_green, this, "add_ip"); + remboxmenu->addKey(CRCInput::RC_yellow, this, "onoff_ip"); remboxmenu->addIntroItems(); item_offset = remboxmenu->getItemsCount(); + CMenuForwarder* mf; for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) - remboxmenu->addItem(new CMenuForwarder(it->rbname, true, NULL, this, "cha_ip")); + { + mf = new CMenuForwarder(it->rbname, true, NULL, this, "cha_ip"); + mf->setInfoIconRight(it->enabled ? NEUTRINO_ICON_MARKER_DIALOG_OK : NEUTRINO_ICON_MARKER_DIALOG_OFF); + remboxmenu->addItem(mf); + } - remboxmenu->setFooter(RemoteBoxFooterButtons, RemoteBoxFooterButtonCount); + remboxmenu->setFooter(RemoteBoxButtons, RemoteBoxButtonsCount); remboxmenu->enableSaveScreen(); remboxmenu->exec(NULL, ""); @@ -1138,10 +1174,10 @@ bool CTimerList::RemoteBoxSetup() CMenuItem *item = remboxmenu->getItem(i); CMenuForwarder *f = static_cast(item); for (std::vector::iterator it = old_timer_remotebox_ip.begin(); it != old_timer_remotebox_ip.end(); ++it) + { if (it->rbname == f->getName()) - { g_settings.timer_remotebox_ip.push_back(*it); - } + } } changed = false; ret = true; diff --git a/src/neutrino.cpp b/src/neutrino.cpp index 5ea89d54d..7bb1ed262 100644 --- a/src/neutrino.cpp +++ b/src/neutrino.cpp @@ -506,10 +506,13 @@ int CNeutrinoApp::loadSetup(const char * fname) g_settings.timer_remotebox_ip.clear(); int timer_remotebox_itemcount = configfile.getInt32("timer_remotebox_ip_count", 0); - if (timer_remotebox_itemcount) { - for (int i = 0; i < timer_remotebox_itemcount; i++) { + if (timer_remotebox_itemcount) + { + for (int i = 0; i < timer_remotebox_itemcount; i++) + { timer_remotebox_item timer_rb; timer_rb.online = false; + timer_rb.enabled = configfile.getBool("timer_remotebox_enabled_" + to_string(i), true); timer_rb.port = 0; std::string k; k = "timer_remotebox_ip_" + to_string(i); @@ -524,6 +527,7 @@ int CNeutrinoApp::loadSetup(const char * fname) timer_rb.pass = configfile.getString(k, ""); k = "timer_remotebox_rbname_" + to_string(i); timer_rb.rbname = configfile.getString(k, ""); + timer_rb.enabled = configfile.getBool("timer_remotebox_enabled_" + to_string(i), true); if (timer_rb.rbname.empty()) timer_rb.rbname = timer_rb.rbaddress; g_settings.timer_remotebox_ip.push_back(timer_rb); @@ -1326,7 +1330,9 @@ void CNeutrinoApp::saveSetup(const char * fname) configfile.setInt32("sleeptimer_min", g_settings.sleeptimer_min); int timer_remotebox_itemcount = 0; - for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) { + for (std::vector::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) + { + configfile.setBool("timer_remotebox_enabled_" + to_string(timer_remotebox_itemcount), it->enabled); std::string k; k = "timer_remotebox_ip_" + to_string(timer_remotebox_itemcount); configfile.setString(k, it->rbaddress); diff --git a/src/system/locals.h b/src/system/locals.h index dfe827662..dd37c8f35 100644 --- a/src/system/locals.h +++ b/src/system/locals.h @@ -2241,6 +2241,7 @@ typedef enum LOCALE_REMOTEBOX_DEL, LOCALE_REMOTEBOX_HEAD, LOCALE_REMOTEBOX_MOD, + LOCALE_REMOTEBOX_ONOFF, LOCALE_REMOTEBOX_PASS, LOCALE_REMOTEBOX_PORT, LOCALE_REMOTEBOX_RBADDR, diff --git a/src/system/locals_intern.h b/src/system/locals_intern.h index 49ccf129b..3cb19a408 100644 --- a/src/system/locals_intern.h +++ b/src/system/locals_intern.h @@ -2241,6 +2241,7 @@ const char * locale_real_names[] = "remotebox_del", "remotebox_head", "remotebox_mod", + "remotebox_onoff", "remotebox_pass", "remotebox_port", "remotebox_rbaddr", diff --git a/src/system/settings.h b/src/system/settings.h index caeb4acd6..51f37712a 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -178,6 +178,7 @@ struct timer_remotebox_item std::string pass; std::string rbname; std::string rbaddress; + bool enabled; bool online; };