mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-09-15 09:23:37 +02:00
timerlist: allow to enable/disable remote boxes
Origin commit data
------------------
Commit: 5b0ad234cd
Author: vanhofen <vanhofen@gmx.de>
Date: 2018-12-16 (Sun, 16 Dec 2018)
Origin message was:
------------------
- timerlist: allow to enable/disable remote boxes
This commit is contained in:
@@ -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<CMenuForwarder*>(item);
|
||||
std::vector<timer_remotebox_item>::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<timer_remotebox_item>::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<timer_remotebox_item>::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<timer_remotebox_item>::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<timer_remotebox_item>::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<CMenuForwarder*>(item);
|
||||
for (std::vector<timer_remotebox_item>::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;
|
||||
|
@@ -541,10 +541,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);
|
||||
@@ -559,6 +562,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);
|
||||
@@ -1436,7 +1440,9 @@ void CNeutrinoApp::saveSetup(const char * fname)
|
||||
configfile.setInt32("sleeptimer_min", g_settings.sleeptimer_min);
|
||||
|
||||
int timer_remotebox_itemcount = 0;
|
||||
for (std::vector<timer_remotebox_item>::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) {
|
||||
for (std::vector<timer_remotebox_item>::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);
|
||||
|
@@ -2436,6 +2436,7 @@ typedef enum
|
||||
LOCALE_REMOTEBOX_DEL,
|
||||
LOCALE_REMOTEBOX_HEAD,
|
||||
LOCALE_REMOTEBOX_MOD,
|
||||
LOCALE_REMOTEBOX_ONOFF,
|
||||
LOCALE_REMOTEBOX_PASS,
|
||||
LOCALE_REMOTEBOX_PORT,
|
||||
LOCALE_REMOTEBOX_RBADDR,
|
||||
|
@@ -2436,6 +2436,7 @@ const char * locale_real_names[] =
|
||||
"remotebox_del",
|
||||
"remotebox_head",
|
||||
"remotebox_mod",
|
||||
"remotebox_onoff",
|
||||
"remotebox_pass",
|
||||
"remotebox_port",
|
||||
"remotebox_rbaddr",
|
||||
|
@@ -178,6 +178,7 @@ struct timer_remotebox_item
|
||||
std::string pass;
|
||||
std::string rbname;
|
||||
std::string rbaddress;
|
||||
bool enabled;
|
||||
bool online;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user