some updates in timer handling

git-svn-id: file:///home/bas/coolstream_public_svn/THIRDPARTY/applications/neutrino-experimental@533 e54a6e83-5905-42d5-8d5c-058d10e6a962
This commit is contained in:
yjogol
2010-04-01 14:24:46 +00:00
parent 777605caa1
commit e413dc3ef0
3 changed files with 66 additions and 60 deletions

View File

@@ -1389,6 +1389,24 @@ void CControlAPI::SendTimers(CyhookHandler *hh)
} }
} }
//-----------------------------------------------------------------------------
void CControlAPI::_SendTime(CyhookHandler *hh, struct tm *Time, int digits){
char zTime[25] = {0};
char zDate[25] = {0};
strftime(zTime,20,"%H:%M",Time);
strftime(zDate,20,"%d.%m.%Y",Time);
hh->printf("\t\t\t\t\t<text>%s %s</text>\n",zDate,zTime);
hh->printf("\t\t\t\t\t<date>%s</date>\n",zDate);
hh->printf("\t\t\t\t\t<time>%s</time>\n",zTime);
hh->printf("\t\t\t\t\t<digits>%d</digits>\n",digits);
hh->printf("\t\t\t\t\t<day>%d</day>\n",Time->tm_mday);
hh->printf("\t\t\t\t\t<month>%d</month>\n",Time->tm_mon+1);
hh->printf("\t\t\t\t\t<year>%d</year>\n",Time->tm_year+1900);
hh->printf("\t\t\t\t\t<hour>%d</hour>\n",Time->tm_hour);
hh->printf("\t\t\t\t\t<min>%d</min>\n",Time->tm_min);
}
//-----------------------------------------------------------------------------
// build xml for all timer data (needed for yWeb 3)
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
void CControlAPI::SendTimersXML(CyhookHandler *hh) void CControlAPI::SendTimersXML(CyhookHandler *hh)
{ {
@@ -1409,14 +1427,10 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
// Look for Recording Safety Timers too // Look for Recording Safety Timers too
int pre=0, post=0; int pre=0, post=0;
//FIXME: determine recording safety status
//if(eventinfo->recordingSafety){
NeutrinoAPI->Timerd->getRecordingSafety(pre,post); NeutrinoAPI->Timerd->getRecordingSafety(pre,post);
//}
// hh->printf("\t\t\t<recording_safety>%d</recording_safety>\n",(int)timer->recordingSafety); // hh->printf("\t\t\t<recording_safety>%d</recording_safety>\n",(int)timer->recordingSafety);
hh->printf("\t\t\t<pre_delay>%d</pre_delay>\n",pre); hh->printf("\t\t\t<pre_delay>%d</pre_delay>\n",pre);
hh->printf("\t\t\t<post_delay>%d</post_delay>\n",post); hh->printf("\t\t\t<post_delay>%d</post_delay>\n",post);
// TODO: Timer config
hh->WriteLn("\t</config>\n"); hh->WriteLn("\t</config>\n");
// start timer list // start timer list
@@ -1430,50 +1444,53 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
hh->printf("\t\t\t<state>%d</state>\n",(int)timer->eventState); hh->printf("\t\t\t<state>%d</state>\n",(int)timer->eventState);
hh->printf("\t\t\t<type_number>%d</type_number>\n",(int)timer->eventType); hh->printf("\t\t\t<type_number>%d</type_number>\n",(int)timer->eventType);
// build alarm/stoptime // alarmtime
char zAlarmTime[25] = {0}; hh->WriteLn("\t\t\t<alarm>\n");
struct tm *alarmTime = localtime(&(timer->alarmTime));
strftime(zAlarmTime,20,"%d.%m. %H:%M",alarmTime); struct tm *alarmTime = localtime(&(timer->alarmTime));
hh->printf("\t\t\t<alarm_text>%s</alarm_text>\n",zAlarmTime); hh->WriteLn("\t\t\t\t<normal>\n");
hh->printf("\t\t\t<alarm>%d</alarm>\n",(int)timer->alarmTime); _SendTime(hh, alarmTime, (int)timer->alarmTime);
hh->WriteLn("\t\t\t\t</normal>\n");
char zSafetyAlarmTime[25] = {0};
time_t real_alarmTimeT = timer->alarmTime - pre; time_t real_alarmTimeT = timer->alarmTime - pre;
struct tm *safetyAlarmTime = localtime(&real_alarmTimeT); struct tm *safetyAlarmTime = localtime(&real_alarmTimeT);
strftime(zSafetyAlarmTime,20,"%d.%m. %H:%M",safetyAlarmTime); hh->WriteLn("\t\t\t\t<safety>\n");
hh->printf("\t\t\t<alarm_safety_text>%s</alarm_safety_text>\n",zSafetyAlarmTime); _SendTime(hh, safetyAlarmTime, (int)real_alarmTimeT);
hh->printf("\t\t\t<alarm_safety>%d</alarm_safety>\n",(int)real_alarmTimeT); hh->WriteLn("\t\t\t\t</safety>\n");
char zAnnounceTime[25] = {0}; hh->WriteLn("\t\t\t</alarm>\n");
// announcetime
hh->WriteLn("\t\t\t<announce>\n");
struct tm *announceTime = localtime(&(timer->announceTime)); struct tm *announceTime = localtime(&(timer->announceTime));
strftime(zAnnounceTime,20,"%d.%m. %H:%M",announceTime); hh->WriteLn("\t\t\t\t<normal>\n");
hh->printf("\t\t\t<announce_text>%s</announce_text>\n",zAnnounceTime); _SendTime(hh, announceTime, (int)timer->announceTime);
hh->printf("\t\t\t<announce>%d</announce>\n",(int)timer->announceTime); hh->WriteLn("\t\t\t\t</normal>\n");
char zSafetyAnnounceTime[25] = {0};
time_t real_announceTimeT = timer->announceTime - pre; time_t real_announceTimeT = timer->announceTime - pre;
struct tm *safetyAnnounceTime = localtime(&real_announceTimeT); struct tm *safetyAnnounceTime = localtime(&real_announceTimeT);
strftime(zSafetyAnnounceTime,20,"%d.%m. %H:%M",safetyAnnounceTime); hh->WriteLn("\t\t\t\t<safety>\n");
hh->printf("\t\t\t<announce_safety_text>%s</announce_safety_text>\n",zSafetyAnnounceTime); _SendTime(hh, safetyAnnounceTime, (int)real_announceTimeT);
hh->printf("\t\t\t<announce_safety>%d</announce_safety>\n",(int)real_announceTimeT); hh->WriteLn("\t\t\t\t</safety>\n");
hh->WriteLn("\t\t\t</announce>\n");
char zStopTime[25] = {0}; // stoptime
if(timer->stopTime > 0){ if(timer->stopTime > 0){
hh->WriteLn("\t\t\t<stop>\n");
struct tm *stopTime = localtime(&(timer->stopTime)); struct tm *stopTime = localtime(&(timer->stopTime));
strftime(zStopTime,20,"%d.%m. %H:%M",stopTime); hh->WriteLn("\t\t\t\t<normal>\n");
} _SendTime(hh, stopTime, (int)timer->stopTime);
hh->printf("\t\t\t<stop_text>%s</stop_text>\n",zStopTime); hh->WriteLn("\t\t\t\t</normal>\n");
hh->printf("\t\t\t<stop>%d</stop>\n",(int)timer->stopTime);
char zSafetyStopTime[25] = {0};
time_t real_stopTimeT = timer->stopTime - post; time_t real_stopTimeT = timer->stopTime - post;
if(timer->stopTime > 0){
struct tm *safetyStopTime = localtime(&real_stopTimeT); struct tm *safetyStopTime = localtime(&real_stopTimeT);
strftime(zSafetyStopTime,20,"%d.%m. %H:%M",safetyStopTime); hh->WriteLn("\t\t\t\t<safety>\n");
_SendTime(hh, safetyStopTime, (int)real_stopTimeT);
hh->WriteLn("\t\t\t\t</safety>\n");
hh->WriteLn("\t\t\t</stop>\n");
} }
hh->printf("\t\t\t<stop_safety_text>%s</stop_safety_text>\n",zSafetyStopTime);
hh->printf("\t\t\t<stop_safety>%d</stop_safety>\n",(int)real_stopTimeT);
// repeat // repeat
std::string zRep = NeutrinoAPI->timerEventRepeat2Str(timer->eventRepeat); std::string zRep = NeutrinoAPI->timerEventRepeat2Str(timer->eventRepeat);
@@ -1482,12 +1499,14 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
zRepCount = "-"; zRepCount = "-";
else else
zRepCount = (timer->repeatCount == 0) ? "&#x221E;" : string_printf("%dx",timer->repeatCount); zRepCount = (timer->repeatCount == 0) ? "&#x221E;" : string_printf("%dx",timer->repeatCount);
hh->printf("\t\t\t<repeat_count>%s</repeat_count>\n",zRepCount.c_str()); hh->WriteLn("\t\t\t<repeat>\n");
hh->printf("\t\t\t<repeat_number>%d</repeat_number>\n",(int)timer->eventRepeat); hh->printf("\t\t\t\t<count>%s</count>\n",zRepCount.c_str());
hh->printf("\t\t\t<repeat>%s</repeat>\n",zRep.c_str()); hh->printf("\t\t\t\t<number>%d</number>\n",(int)timer->eventRepeat);
hh->printf("\t\t\t\t<text>%s</text>\n",zRep.c_str());
char weekdays[8]={0}; char weekdays[8]={0};
NeutrinoAPI->Timerd->setWeekdaysToStr(timer->eventRepeat, weekdays); NeutrinoAPI->Timerd->setWeekdaysToStr(timer->eventRepeat, weekdays);
hh->printf("\t\t\t<repeat_weekdays>%s</repeat_weekdays>\n",weekdays); hh->printf("\t\t\t\t<weekdays>%s</weekdays>\n",weekdays);
hh->WriteLn("\t\t\t</repeat>\n");
// channel infos // channel infos
std::string channel_name = NeutrinoAPI->GetServiceName(timer->channel_id); std::string channel_name = NeutrinoAPI->GetServiceName(timer->channel_id);
@@ -1503,10 +1522,10 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
title = epgdata.title; title = epgdata.title;
} }
// timer specific data
switch(timer->eventType) switch(timer->eventType)
{ {
case CTimerd::TIMER_NEXTPROGRAM :{ case CTimerd::TIMER_NEXTPROGRAM :{
// hh->WriteLn("\t\t\t<type>next_program</type>\n");
hh->printf("\t\t\t<channel_id>" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "</channel_id>\n",timer->channel_id); hh->printf("\t\t\t<channel_id>" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "</channel_id>\n",timer->channel_id);
hh->printf("\t\t\t<channel_name>%s</channel_name>\n",channel_name.c_str()); hh->printf("\t\t\t<channel_name>%s</channel_name>\n",channel_name.c_str());
hh->printf("\t\t\t<title>%s</title>\n",title.c_str()); hh->printf("\t\t\t<title>%s</title>\n",title.c_str());
@@ -1514,7 +1533,6 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
break; break;
case CTimerd::TIMER_ZAPTO :{ case CTimerd::TIMER_ZAPTO :{
// hh->WriteLn("\t\t\t<type>zapto</type>\n");
hh->printf("\t\t\t<channel_id>" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "</channel_id>\n",timer->channel_id); hh->printf("\t\t\t<channel_id>" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "</channel_id>\n",timer->channel_id);
hh->printf("\t\t\t<channel_name>%s</channel_name>\n",channel_name.c_str()); hh->printf("\t\t\t<channel_name>%s</channel_name>\n",channel_name.c_str());
hh->printf("\t\t\t<title>%s</title>\n",title.c_str()); hh->printf("\t\t\t<title>%s</title>\n",title.c_str());
@@ -1522,7 +1540,6 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
break; break;
case CTimerd::TIMER_RECORD :{ case CTimerd::TIMER_RECORD :{
// hh->WriteLn("\t\t\t<type>record</type>\n");
hh->printf("\t\t\t<channel_id>" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "</channel_id>\n",timer->channel_id); hh->printf("\t\t\t<channel_id>" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "</channel_id>\n",timer->channel_id);
hh->printf("\t\t\t<channel_name>%s</channel_name>\n",channel_name.c_str()); hh->printf("\t\t\t<channel_name>%s</channel_name>\n",channel_name.c_str());
hh->printf("\t\t\t<title>%s</title>\n",title.c_str()); hh->printf("\t\t\t<title>%s</title>\n",title.c_str());
@@ -1545,13 +1562,11 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
break; break;
case CTimerd::TIMER_STANDBY :{ case CTimerd::TIMER_STANDBY :{
// hh->WriteLn("\t\t\t<type>standby</type>\n");
hh->printf("\t\t\t<status>%s</status>\n",(timer->standby_on)? "on" : "off"); hh->printf("\t\t\t<status>%s</status>\n",(timer->standby_on)? "on" : "off");
} }
break; break;
case CTimerd::TIMER_REMIND :{ case CTimerd::TIMER_REMIND :{
// hh->WriteLn("\t\t\t<type>remind</type>\n");
std::string _message; std::string _message;
_message = std::string(timer->message).substr(0,20); _message = std::string(timer->message).substr(0,20);
hh->printf("\t\t\t<message>%s</message>\n",_message.c_str()); hh->printf("\t\t\t<message>%s</message>\n",_message.c_str());
@@ -1559,18 +1574,15 @@ void CControlAPI::SendTimersXML(CyhookHandler *hh)
break; break;
case CTimerd::TIMER_EXEC_PLUGIN :{ case CTimerd::TIMER_EXEC_PLUGIN :{
// hh->WriteLn("\t\t\t<type>plugin</type>\n");
hh->printf("\t\t\t<plugin>%s</plugin>\n",timer->pluginName); hh->printf("\t\t\t<plugin>%s</plugin>\n",timer->pluginName);
} }
break; break;
case CTimerd::TIMER_SLEEPTIMER :{ case CTimerd::TIMER_SLEEPTIMER :{
// hh->WriteLn("\t\t\t<type>sleeptimer</type>\n");
} }
break; break;
case CTimerd::TIMER_IMMEDIATE_RECORD :{ case CTimerd::TIMER_IMMEDIATE_RECORD :{
// hh->WriteLn("\t\t\t<type>immediate_record</type>\n");
} }
break; break;
@@ -1726,16 +1738,13 @@ void CControlAPI::doNewTimer(CyhookHandler *hh)
tnull = time(NULL); tnull = time(NULL);
struct tm *alarmTime=localtime(&tnull); struct tm *alarmTime=localtime(&tnull);
alarmTime->tm_sec = 0; alarmTime->tm_sec = 0;
if(sscanf(hh->ParamList["alDate"].c_str(),"%2d.%2d.%4d",&(alarmTime->tm_mday), &(alarmTime->tm_mon), &(alarmTime->tm_year)) == 3) strptime(hh->ParamList["alDate"].c_str(), "%d.%m.%Y", alarmTime);
{
alarmTime->tm_mon -= 1;
alarmTime->tm_year -= 1900;
}
// Alarm Time - Format exact! HH:MM // Alarm Time - Format exact! HH:MM
if(hh->ParamList["alTime"] != "") if(hh->ParamList["alTime"] != "")
sscanf(hh->ParamList["alTime"].c_str(),"%2d.%2d",&(alarmTime->tm_hour), &(alarmTime->tm_min)); strptime(hh->ParamList["alTime"].c_str(), "%H:%M", alarmTime);
alHour = alarmTime->tm_hour; alHour = alarmTime->tm_hour;
correctTime(alarmTime); correctTime(alarmTime);
alarmTimeT = mktime(alarmTime); alarmTimeT = mktime(alarmTime);
announceTimeT = alarmTimeT; announceTimeT = alarmTimeT;
@@ -1743,15 +1752,12 @@ void CControlAPI::doNewTimer(CyhookHandler *hh)
stopTime->tm_sec = 0; stopTime->tm_sec = 0;
// Stop Time - Format exact! HH:MM // Stop Time - Format exact! HH:MM
if(hh->ParamList["stTime"] != "") if(hh->ParamList["stTime"] != "")
sscanf(hh->ParamList["stTime"].c_str(),"%2d.%2d",&(stopTime->tm_hour), &(stopTime->tm_min)); strptime(hh->ParamList["stTime"].c_str(), "%H:%M", stopTime);
// Stop Date - Format exact! DD.MM.YYYY // Stop Date - Format exact! DD.MM.YYYY
if(hh->ParamList["stDate"] != "") if(hh->ParamList["stDate"] != "")
if(sscanf(hh->ParamList["stDate"].c_str(),"%2d.%2d.%4d",&(stopTime->tm_mday), &(stopTime->tm_mon), &(stopTime->tm_year)) == 3) strptime(hh->ParamList["stDate"].c_str(), "%d.%m.%Y", stopTime);
{ stopTime->tm_sec = 0;
stopTime->tm_mon -= 1;
stopTime->tm_year -= 1900;
}
correctTime(stopTime); correctTime(stopTime);
stopTimeT = mktime(stopTime); stopTimeT = mktime(stopTime);
if(hh->ParamList["stDate"] == "" && alHour > stopTime->tm_hour) if(hh->ParamList["stDate"] == "" && alHour > stopTime->tm_hour)

View File

@@ -43,7 +43,7 @@ private:
friend class CNeutrinoWebserver; // for timer /fb/ compatibility friend class CNeutrinoWebserver; // for timer /fb/ compatibility
void doModifyTimer(CyhookHandler *hh); void doModifyTimer(CyhookHandler *hh);
void doNewTimer(CyhookHandler *hh); void doNewTimer(CyhookHandler *hh);
void _SendTime(CyhookHandler *hh, struct tm *Time, int digits);
//yweb //yweb
void YWeb_SendVideoStreamingPids(CyhookHandler *hh, int apid_no); void YWeb_SendVideoStreamingPids(CyhookHandler *hh, int apid_no);
void YWeb_SendRadioStreamingPid(CyhookHandler *hh); void YWeb_SendRadioStreamingPid(CyhookHandler *hh);

View File

@@ -282,7 +282,7 @@ function do_set_timer()
+"&rec_dir="+document.f.rec_dir.value +"&rec_dir="+document.f.rec_dir.value
+"&rs=1" +"&rs=1"
+"&update=1"; +"&update=1";
_url = _urlt.replace(/:/gi,"."); // _url = _urlt.replace(/:/gi,".");
/*_url = encodeURI(_url);*/ /*_url = encodeURI(_url);*/
loadSyncURL(_url); loadSyncURL(_url);
channels++; channels++;