add multiple remote boxes

This commit is contained in:
TangoCash
2016-10-21 10:47:37 +02:00
committed by svenhoefer
parent 7f91b853f7
commit f354089763
5 changed files with 80 additions and 24 deletions

View File

@@ -162,6 +162,9 @@ class CTimerd
char pluginName[EXEC_PLUGIN_NAME_MAXLEN]; //only filled if applicable char pluginName[EXEC_PLUGIN_NAME_MAXLEN]; //only filled if applicable
char recordingDir[RECORD_DIR_MAXLEN]; //only filled if applicable char recordingDir[RECORD_DIR_MAXLEN]; //only filled if applicable
char epgTitle[EPG_TITLE_MAXLEN]; //only filled if applicable char epgTitle[EPG_TITLE_MAXLEN]; //only filled if applicable
char remotebox_ip[15];
int rem_pre;
int rem_post;
bool operator< (const responseGetTimer& a) const bool operator< (const responseGetTimer& a) const
{ {

View File

@@ -314,7 +314,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
CHTTPTool httpTool; CHTTPTool httpTool;
std::string r_url; std::string r_url;
r_url = "http://"; r_url = "http://";
r_url += g_settings.remotebox_address; r_url += timerlist[selected].remotebox_ip;
r_url += "/control/timer?action=new&update=1"; r_url += "/control/timer?action=new&update=1";
r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime); r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime);
r_url += "&stop=" + to_string((int)timerlist[selected].stopTime); r_url += "&stop=" + to_string((int)timerlist[selected].stopTime);
@@ -340,10 +340,10 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
CHTTPTool httpTool; CHTTPTool httpTool;
std::string r_url; std::string r_url;
r_url = "http://"; r_url = "http://";
r_url += g_settings.remotebox_address; r_url += timerlist[selected].remotebox_ip;
r_url += "/control/timer?action=new"; r_url += "/control/timer?action=new";
r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + rem_pre); r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + timerlist[selected].rem_pre);
r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - rem_post); r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - timerlist[selected].rem_post);
r_url += "&announce=" + to_string((int)timerlist[selected].announceTime); r_url += "&announce=" + to_string((int)timerlist[selected].announceTime);
r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id); r_url += "&channel_id=" + string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timerlist[selected].channel_id);
r_url += "&aj=on"; r_url += "&aj=on";
@@ -359,7 +359,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
CHTTPTool httpTool; CHTTPTool httpTool;
std::string r_url; std::string r_url;
r_url = "http://"; r_url = "http://";
r_url += g_settings.remotebox_address; r_url += timerlist[selected].remotebox_ip;
r_url += "/control/timer?action=remove"; r_url += "/control/timer?action=remove";
r_url += "&id=" + to_string((int)timerlist[selected].eventID); r_url += "&id=" + to_string((int)timerlist[selected].eventID);
//printf("[remotetimer] url:%s\n",r_url.c_str()); //printf("[remotetimer] url:%s\n",r_url.c_str());
@@ -378,7 +378,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
CHTTPTool httpTool; CHTTPTool httpTool;
std::string r_url; std::string r_url;
r_url = "http://"; r_url = "http://";
r_url += g_settings.remotebox_address; r_url += timerlist[selected].remotebox_ip;
r_url += "/control/timer?action=remove"; r_url += "/control/timer?action=remove";
r_url += "&id=" + to_string((int)timerlist[selected].eventID); r_url += "&id=" + to_string((int)timerlist[selected].eventID);
//printf("[remotetimer] url:%s\n",r_url.c_str()); //printf("[remotetimer] url:%s\n",r_url.c_str());
@@ -390,7 +390,7 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
CHTTPTool httpTool; CHTTPTool httpTool;
std::string r_url; std::string r_url;
r_url = "http://"; r_url = "http://";
r_url += g_settings.remotebox_address; r_url += timerlist[selected].remotebox_ip;
r_url += "/control/timer?action=new&update=1"; r_url += "/control/timer?action=new&update=1";
r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime); r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime);
r_url += "&stop=" + to_string((int)timerlist[selected].stopTime); r_url += "&stop=" + to_string((int)timerlist[selected].stopTime);
@@ -548,7 +548,8 @@ void CTimerList::updateEvents(void)
//get footerHeight from paintButtons //get footerHeight from paintButtons
footerHeight = ::paintButtons(TimerListButtons, TimerListButtonsCount, 0, 0, 0, 0, 0, false); footerHeight = ::paintButtons(TimerListButtons, TimerListButtonsCount, 0, 0, 0, 0, 0, false);
width = w_max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth()*56, 20); //width = w_max(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->getWidth()*56, 20);
width = frameBuffer->getScreenWidth()*0.9;
height = frameBuffer->getScreenHeight() - (2*theight); // max height height = frameBuffer->getScreenHeight() - (2*theight); // max height
listmaxshow = (height-theight)/(fheight*2); listmaxshow = (height-theight)/(fheight*2);
@@ -570,14 +571,35 @@ void CTimerList::updateEvents(void)
y = getScreenStartY(height); y = getScreenStartY(height);
} }
void CTimerList::select_remotebox_ip()
{
if (g_settings.timer_remotebox_ip.size() == 1) {
std::list<std::string>::iterator it = g_settings.timer_remotebox_ip.begin();
strncpy(timerlist[selected].remotebox_ip,it->c_str(),15);
}
int select = 0;
CMenuWidget *m = new CMenuWidget(LOCALE_TIMERLIST_NAME, NEUTRINO_ICON_TIMER);
CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select);
for (std::list<std::string>::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it)
m->addItem(new CMenuForwarder(*it, true, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str()));
int res = m->exec(NULL, "");
delete selector;
std::list<std::string>::iterator it = g_settings.timer_remotebox_ip.begin();
std::advance(it,select);
strncpy(timerlist[selected].remotebox_ip,it->c_str(),15);
}
bool CTimerList::remoteChanExists(t_channel_id channel_id) bool CTimerList::remoteChanExists(t_channel_id channel_id)
{ {
if (g_settings.remotebox_address.empty())
return false;
CHTTPTool httpTool; CHTTPTool httpTool;
std::string r_url; std::string r_url;
r_url = "http://"; r_url = "http://";
r_url += g_settings.remotebox_address; r_url += timerlist[selected].remotebox_ip;
r_url += "/control/getchannel?format=json&id="; r_url += "/control/getchannel?format=json&id=";
r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id); r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id);
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url);
@@ -596,8 +618,6 @@ bool CTimerList::remoteChanExists(t_channel_id channel_id)
bool CTimerList::localChanExists(t_channel_id channel_id) bool CTimerList::localChanExists(t_channel_id channel_id)
{ {
if (g_settings.remotebox_address.empty())
return false;
CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id); CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id);
if (channel) if (channel)
return true; return true;
@@ -607,12 +627,15 @@ bool CTimerList::localChanExists(t_channel_id channel_id)
void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist) void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist)
{ {
if (g_settings.remotebox_address.empty()) if (g_settings.timer_remotebox_ip.size() == 0)
return; return;
CHTTPTool httpTool; CHTTPTool httpTool;
std::string r_url; std::string r_url;
for (std::list<std::string>::iterator it = g_settings.timer_remotebox_ip.begin();
it != g_settings.timer_remotebox_ip.end(); ++it) {
r_url = "http://"; r_url = "http://";
r_url += g_settings.remotebox_address; r_url += *it;
r_url += "/control/timer?format=json"; r_url += "/control/timer?format=json";
r_url = httpTool.downloadString(r_url); r_url = httpTool.downloadString(r_url);
//printf("[remotetimer] timers:%s\n",r_url.c_str()); //printf("[remotetimer] timers:%s\n",r_url.c_str());
@@ -626,8 +649,8 @@ void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist)
} }
Json::Value delays = root["data"]["timer"][0]; Json::Value delays = root["data"]["timer"][0];
rem_pre = atoi(delays["config"].get("pre_delay","").asString()); rem_pre = atoi(delays["config"].get("pre_delay","0").asString());
rem_post = atoi(delays["config"].get("post_delay","").asString()); rem_post = atoi(delays["config"].get("post_delay","0").asString());
//printf("[remotetimer] pre:%d - post:%d\n", rem_pre, rem_post); //printf("[remotetimer] pre:%d - post:%d\n", rem_pre, rem_post);
@@ -636,6 +659,9 @@ void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist)
for (unsigned int i= 0; i<remotetimers.size();i++) { for (unsigned int i= 0; i<remotetimers.size();i++) {
CTimerd::responseGetTimer rtimer; CTimerd::responseGetTimer rtimer;
if ( atoi(remotetimers[i].get("type_number","").asString()) == 5) { if ( atoi(remotetimers[i].get("type_number","").asString()) == 5) {
strncpy(rtimer.remotebox_ip,it->c_str(),15);
rtimer.rem_pre = rem_pre;
rtimer.rem_post = rem_post;
rtimer.eventID = atoi(remotetimers[i].get("id","").asString()); rtimer.eventID = atoi(remotetimers[i].get("id","").asString());
rtimer.eventType = CTimerd::TIMER_REMOTEBOX; rtimer.eventType = CTimerd::TIMER_REMOTEBOX;
rtimer.eventState = (CTimerd::CTimerEventStates) atoi(remotetimers[i].get("state","").asString()); rtimer.eventState = (CTimerd::CTimerEventStates) atoi(remotetimers[i].get("state","").asString());
@@ -658,7 +684,7 @@ void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist)
rtimerlist.push_back(rtimer); rtimerlist.push_back(rtimer);
} }
} }
}
} }
int CTimerList::show() int CTimerList::show()
@@ -739,9 +765,10 @@ int CTimerList::show()
else else
update=true; update=true;
} }
else if ((msg == CRCInput::RC_play) && !(timerlist.empty()) && !(g_settings.remotebox_address.empty())) else if ((msg == CRCInput::RC_play) && !(timerlist.empty()) && (g_settings.timer_remotebox_ip.size() > 0))
{ {
if (timerlist[selected].eventType == CTimerd::TIMER_RECORD ) { if (timerlist[selected].eventType == CTimerd::TIMER_RECORD ) {
select_remotebox_ip();
if (exec(this,"send_remotetimer")) if (exec(this,"send_remotetimer"))
{ {
res=menu_return::RETURN_EXIT_ALL; res=menu_return::RETURN_EXIT_ALL;
@@ -784,7 +811,11 @@ int CTimerList::show()
} }
if (killTimer) { if (killTimer) {
if ((timerlist[selected].eventType == CTimerd::TIMER_REMOTEBOX) && (timerlist[selected].eventState < CTimerd::TIMERSTATE_ISRUNNING)) if ((timerlist[selected].eventType == CTimerd::TIMER_REMOTEBOX) && (timerlist[selected].eventState < CTimerd::TIMERSTATE_ISRUNNING))
exec(this,"del_remotetimer"); if (exec(this,"del_remotetimer"))
{
res=menu_return::RETURN_EXIT_ALL;
loop=false;
}
else else
Timer->removeTimerEvent(timerlist[selected].eventID); Timer->removeTimerEvent(timerlist[selected].eventID);
update = true; update = true;
@@ -875,11 +906,13 @@ void CTimerList::hide()
void CTimerList::enterRemoteBox() void CTimerList::enterRemoteBox()
{ {
/*
CMenuWidget* remboxmenu = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, 40, MN_WIDGET_ID_NETWORKSETUP); CMenuWidget* remboxmenu = new CMenuWidget(LOCALE_MAINSETTINGS_HEAD, NEUTRINO_ICON_SETTINGS, 40, MN_WIDGET_ID_NETWORKSETUP);
CIPInput remotebox_NetworkIP(LOCALE_NETWORKMENU_IPADDRESS , &g_settings.remotebox_address); CIPInput remotebox_NetworkIP(LOCALE_NETWORKMENU_IPADDRESS , &g_settings.remotebox_address);
CMenuForwarder *m1 = new CMenuForwarder(LOCALE_NETWORKMENU_IPADDRESS , true, g_settings.remotebox_address , &remotebox_NetworkIP ); CMenuForwarder *m1 = new CMenuForwarder(LOCALE_NETWORKMENU_IPADDRESS , true, g_settings.remotebox_address , &remotebox_NetworkIP );
remboxmenu->addItem( m1); remboxmenu->addItem( m1);
remboxmenu->exec(NULL, ""); remboxmenu->exec(NULL, "");
*/
} }
void CTimerList::paintItem(int pos) void CTimerList::paintItem(int pos)
@@ -941,7 +974,8 @@ void CTimerList::paintItem(int pos)
sprintf(srepeatcount,"%ux",timer.repeatCount); sprintf(srepeatcount,"%ux",timer.repeatCount);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+fw*13+(real_width-fw*23)/2,ypos+fheight, (real_width-fw*13)/2-5, srepeatcount, color, fheight); g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+fw*13+(real_width-fw*23)/2,ypos+fheight, (real_width-fw*13)/2-5, srepeatcount, color, fheight);
} }
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+fw*13+(real_width-fw*13)/2,ypos+fheight, (real_width-fw*13)/2-5, convertTimerType2String(timer.eventType), color, fheight); std::string t_type = (timer.eventType == CTimerd::TIMER_REMOTEBOX) ? std::string(convertTimerType2String(timer.eventType)) + " (" + std::string(timer.remotebox_ip) + ")" : convertTimerType2String(timer.eventType);
g_Font[SNeutrinoSettings::FONT_TYPE_MENU]->RenderString(x+fw*13+(real_width-fw*13)/2,ypos+fheight, (real_width-fw*13)/2-5, t_type, color, fheight);
// paint rec icon when recording in progress // paint rec icon when recording in progress
if ((timer.eventType == CTimerd::TIMER_RECORD) && (CRecordManager::getInstance()->RecordingStatus(timer.channel_id))) { if ((timer.eventType == CTimerd::TIMER_RECORD) && (CRecordManager::getInstance()->RecordingStatus(timer.channel_id))) {

View File

@@ -87,6 +87,7 @@ class CTimerList : public CMenuTarget, public CListHelpers
int saved_dispmode; int saved_dispmode;
void remoteTimerList(CTimerd::TimerList &timerlist); void remoteTimerList(CTimerd::TimerList &timerlist);
void enterRemoteBox(); void enterRemoteBox();
void select_remotebox_ip();
bool remoteChanExists(t_channel_id channel_id); bool remoteChanExists(t_channel_id channel_id);
bool localChanExists(t_channel_id channel_id); bool localChanExists(t_channel_id channel_id);
int rem_pre,rem_post; int rem_pre,rem_post;

View File

@@ -458,7 +458,17 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.shutdown_min = configfile.getInt32("shutdown_min", 180); g_settings.shutdown_min = configfile.getInt32("shutdown_min", 180);
g_settings.sleeptimer_min = configfile.getInt32("sleeptimer_min", 0); g_settings.sleeptimer_min = configfile.getInt32("sleeptimer_min", 0);
g_settings.remotebox_address = configfile.getString("timer_remotebox", ""); g_settings.timer_remotebox_ip.clear();
int timer_remotebox_ip_count = configfile.getInt32("timer_remotebox_ip_count", 0);
if (timer_remotebox_ip_count) {
for (int i = 0; i < timer_remotebox_ip_count; i++) {
std::string k = "timer_remotebox_ip_" + to_string(i);
std::string timer_remotebox_ip = configfile.getString(k, "");
if (timer_remotebox_ip.empty())
continue;
g_settings.timer_remotebox_ip.push_back(timer_remotebox_ip);
}
}
g_settings.infobar_sat_display = configfile.getBool("infobar_sat_display" , true ); g_settings.infobar_sat_display = configfile.getBool("infobar_sat_display" , true );
g_settings.infobar_show_channeldesc = configfile.getBool("infobar_show_channeldesc" , false ); g_settings.infobar_show_channeldesc = configfile.getBool("infobar_show_channeldesc" , false );
@@ -1045,7 +1055,15 @@ void CNeutrinoApp::saveSetup(const char * fname)
configfile.setInt32("shutdown_count" , g_settings.shutdown_count); configfile.setInt32("shutdown_count" , g_settings.shutdown_count);
configfile.setInt32("shutdown_min" , g_settings.shutdown_min ); configfile.setInt32("shutdown_min" , g_settings.shutdown_min );
configfile.setInt32("sleeptimer_min", g_settings.sleeptimer_min); configfile.setInt32("sleeptimer_min", g_settings.sleeptimer_min);
configfile.setString("timer_remotebox", g_settings.remotebox_address);
int timer_remotebox_ip_count = 0;
for (std::list<std::string>::iterator it = g_settings.timer_remotebox_ip.begin(); it != g_settings.timer_remotebox_ip.end(); ++it) {
std::string k = "timer_remotebox_ip_" + to_string(timer_remotebox_ip_count);
configfile.setString(k, *it);
timer_remotebox_ip_count++;
}
configfile.setInt32 ( "timer_remotebox_ip_count", g_settings.timer_remotebox_ip.size());
configfile.setBool("infobar_sat_display" , g_settings.infobar_sat_display ); configfile.setBool("infobar_sat_display" , g_settings.infobar_sat_display );
configfile.setBool("infobar_show_channeldesc" , g_settings.infobar_show_channeldesc ); configfile.setBool("infobar_show_channeldesc" , g_settings.infobar_show_channeldesc );
configfile.setInt32("infobar_subchan_disp_pos" , g_settings.infobar_subchan_disp_pos ); configfile.setInt32("infobar_subchan_disp_pos" , g_settings.infobar_subchan_disp_pos );

View File

@@ -450,7 +450,7 @@ struct SNeutrinoSettings
int recording_slow_warning; int recording_slow_warning;
int recording_startstop_msg; int recording_startstop_msg;
int shutdown_timer_record_type; int shutdown_timer_record_type;
std::string remotebox_address; std::list<std::string> timer_remotebox_ip;
std::string recording_filename_template; std::string recording_filename_template;
int recording_already_found_check; int recording_already_found_check;