mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-30 08:51:04 +02:00
Merge branch 'master' of https://github.com/tuxbox-neutrino/gui-neutrino into ni/tuxbox
Conflicts:
lib/timerdclient/timerdtypes.h
src/gui/channellist.cpp
src/system/httptool.h
Origin commit data
------------------
Branch: ni/coolstream
Commit: 0bb2f888c6
Author: vanhofen <vanhofen@gmx.de>
Date: 2016-10-21 (Fri, 21 Oct 2016)
------------------
This commit was generated by Migit
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
Timerliste by Zwen
|
||||
(C) 2009, 2011-2014 Stefan Seyfried
|
||||
Remote Timers by
|
||||
(C) 2016 TangoCash
|
||||
|
||||
Homepage: http://dbox.cyberphoria.org/
|
||||
|
||||
@@ -67,6 +69,9 @@
|
||||
#include <system/settings.h>
|
||||
#include <system/fsmounter.h>
|
||||
#include <system/helpers.h>
|
||||
#include <system/httptool.h>
|
||||
|
||||
#include <json/json.h>
|
||||
|
||||
#include <global.h>
|
||||
#include <neutrino.h>
|
||||
@@ -249,6 +254,15 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
std::string string_printf_helper(const char *fmt, ...) {
|
||||
va_list arglist;
|
||||
const int bufferlen = 4*1024;
|
||||
char buffer[bufferlen] = {0};
|
||||
va_start(arglist, fmt);
|
||||
vsnprintf(buffer, bufferlen, fmt, arglist);
|
||||
va_end(arglist);
|
||||
return std::string(buffer);
|
||||
}
|
||||
|
||||
CTimerList::CTimerList()
|
||||
{
|
||||
@@ -279,6 +293,42 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
{
|
||||
const char * key = actionKey.c_str();
|
||||
|
||||
if(actionKey == "add_ip") {
|
||||
std::string remoteip;
|
||||
CIPInput remotebox_NetworkIP(LOCALE_REMOTEBOX_IP , &remoteip);
|
||||
if (remotebox_NetworkIP.exec(NULL,"") == true) {
|
||||
remboxmenu->addItem(new CMenuForwarder(remoteip, true, NULL, this, "cha_ip"));
|
||||
remotebox_NetworkIP.hide();
|
||||
changed = true;
|
||||
}
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
if(actionKey == "del_ip") {
|
||||
bselected = remboxmenu->getSelected();
|
||||
if (bselected >= item_offset) {
|
||||
remboxmenu->removeItem(bselected);
|
||||
remboxmenu->hide();
|
||||
bselected = remboxmenu->getSelected();
|
||||
changed = true;
|
||||
}
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
if(actionKey == "cha_ip") {
|
||||
bselected = remboxmenu->getSelected();
|
||||
CMenuItem* item = remboxmenu->getItem(bselected);
|
||||
CMenuForwarder *f = static_cast<CMenuForwarder*>(item);
|
||||
std::string remoteip = f->getName();
|
||||
CIPInput remotebox_NetworkIP(LOCALE_REMOTEBOX_IP , &remoteip);
|
||||
if (remotebox_NetworkIP.exec(NULL,"") == true) {
|
||||
f->setName(remoteip);
|
||||
remotebox_NetworkIP.hide();
|
||||
changed = true;
|
||||
}
|
||||
return menu_return::RETURN_REPAINT;
|
||||
}
|
||||
|
||||
if (strcmp(key, "modifytimer") == 0)
|
||||
{
|
||||
timerlist[selected].announceTime = timerlist[selected].alarmTime -60;
|
||||
@@ -297,6 +347,23 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
timerlist[selected].alarmTime,
|
||||
timerlist[selected].stopTime, timerlist[selected].eventRepeat,
|
||||
timerlist[selected].repeatCount,timerlist[selected].recordingDir);
|
||||
} else if (timerlist[selected].eventType == CTimerd::TIMER_REMOTEBOX)
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
r_url += timerlist[selected].remotebox_ip;
|
||||
r_url += "/control/timer?action=new&update=1";
|
||||
r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime);
|
||||
r_url += "&stop=" + to_string((int)timerlist[selected].stopTime);
|
||||
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 += "&aj=on";
|
||||
r_url += "&rs=on";
|
||||
r_url += "&id=" + to_string((int)timerlist[selected].eventID);
|
||||
//printf("[remotetimer] url:%s\n",r_url.c_str());
|
||||
r_url = httpTool.downloadString(r_url);
|
||||
//printf("[remotetimer] status:%s\n",r_url.c_str());
|
||||
} else
|
||||
{
|
||||
Timer->modifyTimerEvent(timerlist[selected].eventID, timerlist[selected].announceTime,
|
||||
@@ -306,6 +373,73 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
}
|
||||
return menu_return::RETURN_EXIT;
|
||||
}
|
||||
else if ((strcmp(key, "send_remotetimer") == 0) && remoteChanExists(timerlist[selected].channel_id))
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
r_url += timerlist[selected].remotebox_ip;
|
||||
r_url += "/control/timer?action=new";
|
||||
r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime + timerlist[selected].rem_pre);
|
||||
r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - timerlist[selected].rem_post);
|
||||
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 += "&aj=on";
|
||||
r_url += "&rs=on";
|
||||
//printf("[remotetimer] url:%s\n",r_url.c_str());
|
||||
r_url = httpTool.downloadString(r_url);
|
||||
//printf("[remotetimer] status:%s\n",r_url.c_str());
|
||||
if (r_url=="ok")
|
||||
Timer->removeTimerEvent(timerlist[selected].eventID);
|
||||
}
|
||||
else if ((strcmp(key, "fetch_remotetimer") == 0) && localChanExists(timerlist[selected].channel_id))
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
r_url += timerlist[selected].remotebox_ip;
|
||||
r_url += "/control/timer?action=remove";
|
||||
r_url += "&id=" + to_string((int)timerlist[selected].eventID);
|
||||
//printf("[remotetimer] url:%s\n",r_url.c_str());
|
||||
r_url = httpTool.downloadString(r_url);
|
||||
//printf("[remotetimer] status:%s\n",r_url.c_str());
|
||||
if (r_url=="ok") {
|
||||
int pre,post;
|
||||
Timer->getRecordingSafety(pre,post);
|
||||
Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre,
|
||||
timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime,
|
||||
TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL));
|
||||
}
|
||||
}
|
||||
else if (strcmp(key, "del_remotetimer") == 0)
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
r_url += timerlist[selected].remotebox_ip;
|
||||
r_url += "/control/timer?action=remove";
|
||||
r_url += "&id=" + to_string((int)timerlist[selected].eventID);
|
||||
//printf("[remotetimer] url:%s\n",r_url.c_str());
|
||||
r_url = httpTool.downloadString(r_url);
|
||||
//printf("[remotetimer] status:%s\n",r_url.c_str());
|
||||
}
|
||||
else if (strcmp(key, "update_remotetimer") == 0)
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
r_url += timerlist[selected].remotebox_ip;
|
||||
r_url += "/control/timer?action=new&update=1";
|
||||
r_url += "&alarm=" + to_string((int)timerlist[selected].alarmTime);
|
||||
r_url += "&stop=" + to_string((int)timerlist[selected].stopTime);
|
||||
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 += "&aj=on";
|
||||
r_url += "&rs=on";
|
||||
//printf("[remotetimer] url:%s\n",r_url.c_str());
|
||||
r_url = httpTool.downloadString(r_url);
|
||||
//printf("[remotetimer] status:%s\n",r_url.c_str());
|
||||
}
|
||||
else if (strcmp(key, "newtimer") == 0)
|
||||
{
|
||||
timerNew.announceTime=timerNew.alarmTime-60;
|
||||
@@ -429,20 +563,30 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
}*/
|
||||
}
|
||||
|
||||
#define TimerListButtonsCount 5
|
||||
struct button_label TimerListButtons[TimerListButtonsCount] =
|
||||
struct button_label TimerListButtons[] =
|
||||
{
|
||||
{ NEUTRINO_ICON_BUTTON_RED , LOCALE_TIMERLIST_DELETE },
|
||||
{ NEUTRINO_ICON_BUTTON_GREEN , LOCALE_TIMERLIST_NEW },
|
||||
{ NEUTRINO_ICON_BUTTON_YELLOW , LOCALE_TIMERLIST_RELOAD },
|
||||
{ NEUTRINO_ICON_BUTTON_BLUE , LOCALE_TIMERLIST_MODIFY },
|
||||
{ NEUTRINO_ICON_BUTTON_INFO_SMALL, NONEXISTANT_LOCALE }
|
||||
{ NEUTRINO_ICON_BUTTON_INFO_SMALL, NONEXISTANT_LOCALE },
|
||||
{ NEUTRINO_ICON_BUTTON_MENU_SMALL, NONEXISTANT_LOCALE },
|
||||
{ NEUTRINO_ICON_BUTTON_PLAY , NONEXISTANT_LOCALE }
|
||||
};
|
||||
size_t TimerListButtonsCount = sizeof(TimerListButtons)/sizeof(TimerListButtons[0]);
|
||||
|
||||
#define RemoteBoxFooterButtonCount 3
|
||||
static const struct button_label RemoteBoxFooterButtons[RemoteBoxFooterButtonCount] = {
|
||||
{ NEUTRINO_ICON_BUTTON_RED, LOCALE_REMOTEBOX_DEL },
|
||||
{ NEUTRINO_ICON_BUTTON_GREEN, LOCALE_REMOTEBOX_ADD },
|
||||
{ NEUTRINO_ICON_BUTTON_OKAY, LOCALE_REMOTEBOX_MOD }
|
||||
};
|
||||
|
||||
void CTimerList::updateEvents(void)
|
||||
{
|
||||
timerlist.clear();
|
||||
Timer->getTimerList (timerlist);
|
||||
remoteTimerList (timerlist);
|
||||
sort(timerlist.begin(), timerlist.end());
|
||||
|
||||
theight = g_Font[SNeutrinoSettings::FONT_TYPE_MENU_TITLE]->getHeight();
|
||||
@@ -450,7 +594,8 @@ void CTimerList::updateEvents(void)
|
||||
//get footerHeight from paintButtons
|
||||
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
|
||||
|
||||
listmaxshow = (height-theight)/(fheight*2);
|
||||
@@ -472,6 +617,129 @@ void CTimerList::updateEvents(void)
|
||||
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(),sizeof(timerlist[selected].remotebox_ip));
|
||||
timerlist[selected].remotebox_ip[sizeof(timerlist[selected].remotebox_ip) - 1] = 0;
|
||||
}
|
||||
|
||||
int select = 0;
|
||||
CMenuWidget *m = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, 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()));
|
||||
|
||||
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(),sizeof(timerlist[selected].remotebox_ip));
|
||||
timerlist[selected].remotebox_ip[sizeof(timerlist[selected].remotebox_ip) - 1] = 0;
|
||||
}
|
||||
|
||||
bool CTimerList::remoteChanExists(t_channel_id channel_id)
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
r_url += timerlist[selected].remotebox_ip;
|
||||
r_url += "/control/getchannel?format=json&id=";
|
||||
r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, channel_id);
|
||||
r_url = httpTool.downloadString(r_url);
|
||||
|
||||
Json::Value root;
|
||||
Json::Reader reader;
|
||||
bool parsedSuccess = reader.parse(r_url, root, false);
|
||||
if (!parsedSuccess) {
|
||||
printf("Failed to parse JSON\n");
|
||||
printf("%s\n", reader.getFormattedErrorMessages().c_str());
|
||||
}
|
||||
|
||||
r_url = root.get("success","false").asString();
|
||||
|
||||
if (r_url == "false")
|
||||
ShowMsg(LOCALE_REMOTEBOX_CHANNEL_NA, convertChannelId2String(channel_id),
|
||||
CMessageBox::mbrOk, CMessageBox::mbOk, NULL, 450, 30, false);
|
||||
|
||||
return (r_url == "true");
|
||||
}
|
||||
|
||||
bool CTimerList::localChanExists(t_channel_id channel_id)
|
||||
{
|
||||
CZapitChannel * channel = CServiceManager::getInstance()->FindChannel(channel_id);
|
||||
if (channel)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void CTimerList::remoteTimerList(CTimerd::TimerList &rtimerlist)
|
||||
{
|
||||
if (g_settings.timer_remotebox_ip.size() == 0)
|
||||
return;
|
||||
|
||||
CHTTPTool httpTool;
|
||||
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 += *it;
|
||||
r_url += "/control/timer?format=json";
|
||||
r_url = httpTool.downloadString(r_url);
|
||||
//printf("[remotetimer] timers:%s\n",r_url.c_str());
|
||||
|
||||
Json::Value root;
|
||||
Json::Reader reader;
|
||||
bool parsedSuccess = reader.parse(r_url, root, false);
|
||||
if (!parsedSuccess) {
|
||||
printf("Failed to parse JSON\n");
|
||||
printf("%s\n", reader.getFormattedErrorMessages().c_str());
|
||||
}
|
||||
Json::Value delays = root["data"]["timer"][0];
|
||||
|
||||
rem_pre = atoi(delays["config"].get("pre_delay","0").asString());
|
||||
rem_post = atoi(delays["config"].get("post_delay","0").asString());
|
||||
|
||||
//printf("[remotetimer] pre:%d - post:%d\n", rem_pre, rem_post);
|
||||
|
||||
Json::Value remotetimers = root["data"]["timer"][0]["timer_list"];
|
||||
|
||||
for (unsigned int i= 0; i<remotetimers.size();i++) {
|
||||
CTimerd::responseGetTimer rtimer;
|
||||
if ( atoi(remotetimers[i].get("type_number","").asString()) == 5) {
|
||||
strncpy(rtimer.remotebox_ip,it->c_str(),sizeof(rtimer.remotebox_ip));
|
||||
rtimer.remotebox_ip[sizeof(rtimer.remotebox_ip) - 1] = 0;
|
||||
rtimer.rem_pre = rem_pre;
|
||||
rtimer.rem_post = rem_post;
|
||||
rtimer.eventID = atoi(remotetimers[i].get("id","").asString());
|
||||
rtimer.eventType = CTimerd::TIMER_REMOTEBOX;
|
||||
rtimer.eventState = (CTimerd::CTimerEventStates) atoi(remotetimers[i].get("state","").asString());
|
||||
if ( remotetimers[i]["repeat"].get("count","").asString() == "-")
|
||||
rtimer.repeatCount = 0;
|
||||
else
|
||||
rtimer.repeatCount = atoi(remotetimers[i]["repeat"].get("count","").asString());
|
||||
rtimer.eventRepeat = (CTimerd::CTimerEventRepeat)(atoi(remotetimers[i]["repeat"].get("number","").asString()) & 0x1FF);
|
||||
std::string wd = remotetimers[i]["repeat"].get("weekdays","").asString();
|
||||
CTimerdClient().getWeekdaysFromStr(&rtimer.eventRepeat, wd);
|
||||
rtimer.alarmTime = (time_t) atoll(remotetimers[i]["alarm"][0].get("digits","").asString().c_str());
|
||||
rtimer.announceTime = (time_t) atoll(remotetimers[i]["announce"][0].get("digits","").asString().c_str());
|
||||
rtimer.stopTime = (time_t) atoll(remotetimers[i]["stop"][0].get("digits","").asString().c_str());
|
||||
rtimer.epgID = (event_id_t) atoi(remotetimers[i].get("epg_id","").asString());
|
||||
sscanf(remotetimers[i].get("channel_id","").asString().c_str(), SCANF_CHANNEL_ID_TYPE, &rtimer.channel_id);
|
||||
strncpy(rtimer.epgTitle,remotetimers[i].get("title","").asString().c_str(),51);
|
||||
if (remotetimers[i]["audio"].get("apids_conf","").asString() == "true")
|
||||
rtimer.apids = TIMERD_APIDS_CONF;
|
||||
//printf("[remotetimer] r-timer:%s - %s\n", remotetimers[i].get("channel_id","").asString().c_str(), remotetimers[i].get("title","").asString().c_str());
|
||||
rtimerlist.push_back(rtimer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CTimerList::show()
|
||||
{
|
||||
@@ -551,8 +819,36 @@ int CTimerList::show()
|
||||
else
|
||||
update=true;
|
||||
}
|
||||
else if ((msg == CRCInput::RC_play) && !(timerlist.empty()) && (g_settings.timer_remotebox_ip.size() > 0))
|
||||
{
|
||||
if (timerlist[selected].eventType == CTimerd::TIMER_RECORD ) {
|
||||
select_remotebox_ip();
|
||||
if (exec(this,"send_remotetimer"))
|
||||
{
|
||||
res=menu_return::RETURN_EXIT_ALL;
|
||||
loop=false;
|
||||
}
|
||||
else
|
||||
update=true;
|
||||
} else if (timerlist[selected].eventType == CTimerd::TIMER_REMOTEBOX ) {
|
||||
if (exec(this,"fetch_remotetimer"))
|
||||
{
|
||||
res=menu_return::RETURN_EXIT_ALL;
|
||||
loop=false;
|
||||
}
|
||||
else
|
||||
update=true;
|
||||
}
|
||||
}
|
||||
else if ((msg == CRCInput::RC_red) && !(timerlist.empty()))
|
||||
{
|
||||
if ((timerlist[selected].eventType == CTimerd::TIMER_REMOTEBOX) && (timerlist[selected].eventState < CTimerd::TIMERSTATE_ISRUNNING)) {
|
||||
if (exec(this,"del_remotetimer"))
|
||||
{
|
||||
res=menu_return::RETURN_EXIT_ALL;
|
||||
loop=false;
|
||||
}
|
||||
} else {
|
||||
bool killTimer = true;
|
||||
if (CRecordManager::getInstance()->RecordingStatus(timerlist[selected].channel_id)) {
|
||||
CTimerd::RecordingStopInfo recinfo;
|
||||
@@ -575,10 +871,11 @@ int CTimerList::show()
|
||||
}
|
||||
}
|
||||
if (killTimer) {
|
||||
Timer->removeTimerEvent(timerlist[selected].eventID);
|
||||
Timer->removeTimerEvent(timerlist[selected].eventID);
|
||||
update = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (msg==CRCInput::RC_green)
|
||||
{
|
||||
if (newTimer()==menu_return::RETURN_EXIT_ALL)
|
||||
@@ -589,6 +886,11 @@ int CTimerList::show()
|
||||
else
|
||||
update=true;
|
||||
}
|
||||
else if (msg==CRCInput::RC_setup)
|
||||
{
|
||||
enterRemoteBox();
|
||||
update=true;
|
||||
}
|
||||
else if (msg==CRCInput::RC_yellow)
|
||||
{
|
||||
update=true;
|
||||
@@ -602,17 +904,12 @@ int CTimerList::show()
|
||||
loop=false;
|
||||
}
|
||||
#endif
|
||||
else if (msg==CRCInput::RC_setup)
|
||||
{
|
||||
res=menu_return::RETURN_EXIT_ALL;
|
||||
loop=false;
|
||||
}
|
||||
else if ( msg == CRCInput::RC_help || msg == CRCInput::RC_info)
|
||||
{
|
||||
CTimerd::responseGetTimer* timer=&timerlist[selected];
|
||||
if (timer!=NULL)
|
||||
{
|
||||
if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_ZAPTO)
|
||||
if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_REMOTEBOX || timer->eventType == CTimerd::TIMER_ZAPTO)
|
||||
{
|
||||
hide();
|
||||
if (timer->epgID != 0)
|
||||
@@ -655,6 +952,35 @@ void CTimerList::hide()
|
||||
}
|
||||
}
|
||||
|
||||
void CTimerList::enterRemoteBox()
|
||||
{
|
||||
remboxmenu = new CMenuWidget(LOCALE_REMOTEBOX_HEAD, NEUTRINO_ICON_TIMER);
|
||||
remboxmenu->addKey(CRCInput::RC_red, this, "del_ip");
|
||||
remboxmenu->addKey(CRCInput::RC_green, this, "add_ip");
|
||||
|
||||
remboxmenu->addIntroItems();
|
||||
|
||||
item_offset = remboxmenu->getItemsCount();
|
||||
for (std::list<std::string>::iterator it = g_settings.timer_remotebox_ip.begin();
|
||||
it != g_settings.timer_remotebox_ip.end(); ++it)
|
||||
remboxmenu->addItem(new CMenuForwarder(*it, true, NULL, this, "cha_ip"));
|
||||
|
||||
remboxmenu->setFooter(RemoteBoxFooterButtons, RemoteBoxFooterButtonCount);
|
||||
|
||||
remboxmenu->exec(NULL, "");
|
||||
remboxmenu->hide();
|
||||
if (changed) {
|
||||
g_settings.timer_remotebox_ip.clear();
|
||||
for (int i = item_offset; i < remboxmenu->getItemsCount(); i++) {
|
||||
CMenuItem *item = remboxmenu->getItem(i);
|
||||
CMenuForwarder *f = static_cast<CMenuForwarder*>(item);
|
||||
g_settings.timer_remotebox_ip.push_back(f->getName());
|
||||
}
|
||||
changed = false;
|
||||
}
|
||||
delete remboxmenu;
|
||||
}
|
||||
|
||||
void CTimerList::paintItem(int pos)
|
||||
{
|
||||
int ypos = y+ theight+ pos*fheight*2;
|
||||
@@ -714,7 +1040,8 @@ void CTimerList::paintItem(int pos)
|
||||
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*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
|
||||
if ((timer.eventType == CTimerd::TIMER_RECORD) && (CRecordManager::getInstance()->RecordingStatus(timer.channel_id))) {
|
||||
@@ -730,6 +1057,14 @@ void CTimerList::paintItem(int pos)
|
||||
}
|
||||
}
|
||||
|
||||
if ((timer.eventType == CTimerd::TIMER_REMOTEBOX) && timer.eventState == CTimerd::TIMERSTATE_ISRUNNING) {
|
||||
int icol_w, icol_h;
|
||||
frameBuffer->getIconSize(NEUTRINO_ICON_REC, &icol_w, &icol_h);
|
||||
if ((icol_w > 0) && (icol_h > 0)) {
|
||||
frameBuffer->paintIcon(NEUTRINO_ICON_REC, (x + real_width) - (icol_w + 8), ypos, 2*fheight);
|
||||
}
|
||||
}
|
||||
|
||||
std::string zAddData("");
|
||||
switch (timer.eventType)
|
||||
{
|
||||
@@ -783,6 +1118,57 @@ void CTimerList::paintItem(int pos)
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CTimerd::TIMER_REMOTEBOX :
|
||||
{
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
r_url += std::string(timer.remotebox_ip);
|
||||
r_url += "/control/getchannel?format=json&id=";
|
||||
r_url += string_printf_helper(PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS, timer.channel_id);
|
||||
r_url = httpTool.downloadString(r_url);
|
||||
|
||||
Json::Value root;
|
||||
Json::Reader reader;
|
||||
bool parsedSuccess = reader.parse(r_url, root, false);
|
||||
if (!parsedSuccess) {
|
||||
printf("Failed to parse JSON\n");
|
||||
printf("%s\n", reader.getFormattedErrorMessages().c_str());
|
||||
}
|
||||
|
||||
Json::Value remotechannel = root["data"]["channel"][0];
|
||||
|
||||
zAddData = remotechannel.get("name","").asString();
|
||||
if (timer.apids != TIMERD_APIDS_CONF)
|
||||
{
|
||||
std::string sep = "";
|
||||
zAddData += " (";
|
||||
if (timer.apids & TIMERD_APIDS_STD)
|
||||
{
|
||||
zAddData += "STD";
|
||||
sep = "/";
|
||||
}
|
||||
if (timer.apids & TIMERD_APIDS_ALT)
|
||||
{
|
||||
zAddData += sep;
|
||||
zAddData += "ALT";
|
||||
sep = "/";
|
||||
}
|
||||
if (timer.apids & TIMERD_APIDS_AC3)
|
||||
{
|
||||
zAddData += sep;
|
||||
zAddData += "AC3";
|
||||
// sep = "/";
|
||||
}
|
||||
zAddData += ')';
|
||||
}
|
||||
if (strlen(timer.epgTitle)!=0)
|
||||
{
|
||||
zAddData += " : ";
|
||||
zAddData += timer.epgTitle;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CTimerd::TIMER_STANDBY:
|
||||
{
|
||||
zAddData = g_Locale->getText(timer.standby_on ? LOCALE_TIMERLIST_STANDBY_ON : LOCALE_TIMERLIST_STANDBY_OFF);
|
||||
@@ -849,7 +1235,7 @@ void CTimerList::paintFoot()
|
||||
if (timer != NULL)
|
||||
{
|
||||
//replace info button with dummy if timer is not type REC or ZAP
|
||||
if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_ZAPTO)
|
||||
if (timer->eventType == CTimerd::TIMER_RECORD || timer->eventType == CTimerd::TIMER_REMOTEBOX || timer->eventType == CTimerd::TIMER_ZAPTO)
|
||||
TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_INFO_SMALL;
|
||||
else
|
||||
TimerListButtons[4].button = NEUTRINO_ICON_BUTTON_DUMMY_SMALL;
|
||||
@@ -915,6 +1301,8 @@ const char * CTimerList::convertTimerType2String(const CTimerd::CTimerEventTypes
|
||||
return g_Locale->getText(LOCALE_TIMERLIST_TYPE_SLEEPTIMER );
|
||||
case CTimerd::TIMER_EXEC_PLUGIN :
|
||||
return g_Locale->getText(LOCALE_TIMERLIST_TYPE_EXECPLUGIN );
|
||||
case CTimerd::TIMER_REMOTEBOX :
|
||||
return g_Locale->getText(LOCALE_TIMERLIST_TYPE_REMOTEBOX );
|
||||
default :
|
||||
return g_Locale->getText(LOCALE_TIMERLIST_TYPE_UNKNOWN );
|
||||
}
|
||||
|
Reference in New Issue
Block a user