From fb5ab7f9ecd74c28a4c658edd041af37a7c31a6e Mon Sep 17 00:00:00 2001 From: TangoCash Date: Mon, 6 Feb 2017 14:36:22 +0100 Subject: [PATCH] fix pre and post times, set menuentry for unavailable boxes inactiv --- src/gui/timerlist.cpp | 25 ++++++++++++++----------- src/system/settings.h | 1 + 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/gui/timerlist.cpp b/src/gui/timerlist.cpp index ab70eb431..929ab4bbe 100644 --- a/src/gui/timerlist.cpp +++ b/src/gui/timerlist.cpp @@ -439,14 +439,16 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "send_remotetimer") == 0) && RemoteBoxChanExists(timerlist[selected].channel_id)) { + int pre,post; + Timer->getRecordingSafety(pre,post); CHTTPTool httpTool; std::string r_url; r_url = "http://"; r_url += RemoteBoxConnectUrl(timerlist[selected].remotebox_name); 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 += "&alarm=" + to_string((int)timerlist[selected].alarmTime + pre); + r_url += "&stop=" + to_string((int)timerlist[selected].stopTime - post); + r_url += "&announce=" + to_string((int)timerlist[selected].announceTime + pre); 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"; @@ -458,13 +460,11 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) } else if ((strcmp(key, "fetch_remotetimer") == 0) && LocalBoxChanExists(timerlist[selected].channel_id)) { - int pre,post; - Timer->getRecordingSafety(pre,post); std::string remotebox_name = timerlist[selected].remotebox_name; std::string eventID = to_string((int)timerlist[selected].eventID); - int res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre, - timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime, + int res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + timerlist[selected].rem_pre, + timerlist[selected].stopTime - timerlist[selected].rem_post, 0, 0, timerlist[selected].announceTime + timerlist[selected].rem_pre, TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",false); if (res == -1) @@ -473,8 +473,8 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey) if (forceAdd) { - res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + pre, - timerlist[selected].stopTime - post, 0, 0, timerlist[selected].announceTime, + res = Timer->addRecordTimerEvent(timerlist[selected].channel_id, timerlist[selected].alarmTime + timerlist[selected].rem_pre, + timerlist[selected].stopTime - timerlist[selected].rem_post, 0, 0, timerlist[selected].announceTime + timerlist[selected].rem_pre, TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",true); } } @@ -709,7 +709,7 @@ void CTimerList::RemoteBoxSelect() CMenuSelectorTarget * selector = new CMenuSelectorTarget(&select); 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, true, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); + m->addItem(new CMenuForwarder(it->rbname, it->online, NULL, selector, to_string(std::distance(g_settings.timer_remotebox_ip.begin(),it)).c_str())); m->enableSaveScreen(true); m->exec(NULL, ""); @@ -804,7 +804,10 @@ void CTimerList::RemoteBoxTimerList(CTimerd::TimerList &rtimerlist) { printf("Failed to parse JSON\n"); printf("%s\n", reader.getFormattedErrorMessages().c_str()); - } + it->online = false; + } else + it->online = true; + Json::Value delays = root["data"]["timer"][0]; rem_pre = atoi(delays["config"].get("pre_delay","0").asString()); diff --git a/src/system/settings.h b/src/system/settings.h index 8d0e53e71..2d9d302d4 100644 --- a/src/system/settings.h +++ b/src/system/settings.h @@ -160,6 +160,7 @@ struct timer_remotebox_item std::string pass; std::string rbname; std::string rbaddress; + bool online; }; struct SNeutrinoSettings