mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-neutrino.git
synced 2025-08-26 23:13:00 +02:00
fix overlapping remote timers
Origin commit data
------------------
Branch: ni/coolstream
Commit: 7bd568dc9c
Author: TangoCash <eric@loxat.de>
Date: 2016-10-23 (Sun, 23 Oct 2016)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
committed by
Michael Liebmann
parent
d9af6bbfde
commit
38b2bc4a9f
@@ -394,22 +394,37 @@ int CTimerList::exec(CMenuTarget* parent, const std::string & actionKey)
|
||||
}
|
||||
else if ((strcmp(key, "fetch_remotetimer") == 0) && localChanExists(timerlist[selected].channel_id))
|
||||
{
|
||||
int pre,post;
|
||||
Timer->getRecordingSafety(pre,post);
|
||||
std::string remotebox_ip = timerlist[selected].remotebox_ip;
|
||||
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,
|
||||
TIMERD_APIDS_CONF, true, timerlist[selected].announceTime > time(NULL),"",false);
|
||||
|
||||
if (res == -1)
|
||||
{
|
||||
bool forceAdd = askUserOnTimerConflict(timerlist[selected].announceTime,timerlist[selected].stopTime);
|
||||
|
||||
if (forceAdd)
|
||||
{
|
||||
res = 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),"",true);
|
||||
}
|
||||
}
|
||||
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
r_url += timerlist[selected].remotebox_ip;
|
||||
r_url += remotebox_ip;
|
||||
r_url += "/control/timer?action=remove";
|
||||
r_url += "&id=" + to_string((int)timerlist[selected].eventID);
|
||||
r_url += "&id=" + eventID;
|
||||
//printf("[remotetimer] url:%s\n",r_url.c_str());
|
||||
if (res > 0)
|
||||
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)
|
||||
{
|
||||
@@ -619,12 +634,6 @@ void CTimerList::updateEvents(void)
|
||||
|
||||
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);
|
||||
@@ -638,12 +647,18 @@ void CTimerList::select_remotebox_ip()
|
||||
|
||||
std::list<std::string>::iterator it = g_settings.timer_remotebox_ip.begin();
|
||||
std::advance(it,select);
|
||||
if (askUserOnRemoteTimerConflict(timerlist[selected].announceTime, timerlist[selected].stopTime, (char*) it->c_str()))
|
||||
{
|
||||
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)
|
||||
{
|
||||
if (strcmp(timerlist[selected].remotebox_ip,"") == 0)
|
||||
return false;
|
||||
|
||||
CHTTPTool httpTool;
|
||||
std::string r_url;
|
||||
r_url = "http://";
|
||||
@@ -1654,6 +1669,72 @@ int CTimerList::newTimer()
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CTimerList::askUserOnRemoteTimerConflict(time_t announceTime, time_t stopTime, char * remotebox_ip)
|
||||
{
|
||||
CTimerd::TimerList overlappingTimers;
|
||||
int pre,post;
|
||||
Timer->getRecordingSafety(pre,post);
|
||||
|
||||
for (CTimerd::TimerList::iterator it = timerlist.begin();
|
||||
it != timerlist.end();++it)
|
||||
{
|
||||
|
||||
if (strcmp(it->remotebox_ip,remotebox_ip) == 0) {
|
||||
|
||||
if(it->stopTime != 0 && stopTime != 0)
|
||||
{
|
||||
// Check if both timers have start and end. In this case do not show conflict, if endtime is the same than the starttime of the following timer
|
||||
if ((stopTime+post > it->alarmTime) && (announceTime-pre < it->stopTime))
|
||||
{
|
||||
overlappingTimers.push_back(*it);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!((stopTime < it->announceTime) || (announceTime > it->stopTime)))
|
||||
{
|
||||
overlappingTimers.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string timerbuf = g_Locale->getText(LOCALE_TIMERLIST_OVERLAPPING_TIMER);
|
||||
timerbuf += "\n";
|
||||
for (CTimerd::TimerList::iterator it = overlappingTimers.begin();
|
||||
it != overlappingTimers.end(); ++it)
|
||||
{
|
||||
timerbuf += CTimerList::convertTimerType2String(it->eventType);
|
||||
timerbuf += " (";
|
||||
timerbuf += CTimerList::convertChannelId2String(it->channel_id); // UTF-8
|
||||
if (it->epgID != 0)
|
||||
{
|
||||
CEPGData epgdata;
|
||||
if (CEitManager::getInstance()->getEPGid(it->epgID, it->epg_starttime, &epgdata))
|
||||
{
|
||||
timerbuf += ":";
|
||||
timerbuf += epgdata.title;
|
||||
}
|
||||
else if (strlen(it->epgTitle)!=0)
|
||||
{
|
||||
timerbuf += ":";
|
||||
timerbuf += it->epgTitle;
|
||||
}
|
||||
}
|
||||
timerbuf += "):\n";
|
||||
|
||||
struct tm *annTime = localtime(&(it->announceTime));
|
||||
timerbuf += strftime("%d.%m. %H:%M\n",annTime);
|
||||
|
||||
struct tm *sTime = localtime(&(it->stopTime));
|
||||
timerbuf += strftime("%d.%m. %H:%M\n",sTime);
|
||||
}
|
||||
if (overlappingTimers.size() > 0)
|
||||
return (ShowMsg(LOCALE_MESSAGEBOX_INFO,timerbuf,CMessageBox::mbrNo,CMessageBox::mbNo|CMessageBox::mbYes) == CMessageBox::mbrYes);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
bool askUserOnTimerConflict(time_t announceTime, time_t stopTime, t_channel_id channel_id)
|
||||
{
|
||||
if (CFEManager::getInstance()->getEnabledCount() == 1) {
|
||||
|
@@ -95,6 +95,7 @@ class CTimerList : public CMenuTarget, public CListHelpers
|
||||
bool changed;
|
||||
int bselected;
|
||||
CMenuWidget *remboxmenu;
|
||||
bool askUserOnRemoteTimerConflict(time_t announceTime, time_t stopTime, char * remotebox_ip);
|
||||
|
||||
public:
|
||||
CTimerList();
|
||||
|
Reference in New Issue
Block a user