diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp index 554410638..01ac27fd1 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.cpp @@ -282,8 +282,12 @@ void CControlAPI::TimerCGI(CyhookHandler *hh) hh->SendError(); } } - else - SendTimers(hh); + else { + if (hh->ParamList["format"] == "xml") + SendTimersXML(hh); + else + SendTimers(hh); + } } else hh->SendError(); @@ -1385,6 +1389,198 @@ void CControlAPI::SendTimers(CyhookHandler *hh) } } +//----------------------------------------------------------------------------- +void CControlAPI::SendTimersXML(CyhookHandler *hh) +{ + // Init local timer iterator + CTimerd::TimerList timerlist; // List of timers + timerlist.clear(); + NeutrinoAPI->Timerd->getTimerList(timerlist); + sort(timerlist.begin(), timerlist.end()); // sort timer + CTimerd::TimerList::iterator timer = timerlist.begin(); + + std::string xml_response = ""; + hh->SetHeader(HTTP_OK, "text/xml; charset=UTF-8"); + hh->WriteLn(""); + hh->WriteLn("\n"); + + // general timer configuration + hh->WriteLn("\t\n"); + + // Look for Recording Safety Timers too + int pre=0, post=0; + //FIXME: determine recording safety status + //if(eventinfo->recordingSafety){ + NeutrinoAPI->Timerd->getRecordingSafety(pre,post); + //} +// hh->printf("\t\t\t%d\n",(int)timer->recordingSafety); + hh->printf("\t\t\t%d\n",pre); + hh->printf("\t\t\t%d\n",post); + // TODO: Timer config + hh->WriteLn("\t\n"); + + // start timer list + hh->WriteLn("\t\n"); + + for(; timer != timerlist.end();timer++) + { + hh->WriteLn("\t\t\n"); + hh->printf("\t\t\t%s\n",(NeutrinoAPI->timerEventType2Str(timer->eventType)).c_str()); + hh->printf("\t\t\t%d\n",timer->eventID); + hh->printf("\t\t\t%d\n",(int)timer->eventState); + hh->printf("\t\t\t%d\n",(int)timer->eventType); + + // build alarm/stoptime + char zAlarmTime[25] = {0}; + struct tm *alarmTime = localtime(&(timer->alarmTime)); + strftime(zAlarmTime,20,"%d.%m. %H:%M",alarmTime); + hh->printf("\t\t\t%s\n",zAlarmTime); + hh->printf("\t\t\t%d\n",(int)timer->alarmTime); + + char zSafetyAlarmTime[25] = {0}; + time_t real_alarmTimeT = timer->alarmTime - pre; + struct tm *safetyAlarmTime = localtime(&real_alarmTimeT); + strftime(zSafetyAlarmTime,20,"%d.%m. %H:%M",safetyAlarmTime); + hh->printf("\t\t\t%s\n",zSafetyAlarmTime); + hh->printf("\t\t\t%d\n",(int)real_alarmTimeT); + + char zAnnounceTime[25] = {0}; + struct tm *announceTime = localtime(&(timer->announceTime)); + strftime(zAnnounceTime,20,"%d.%m. %H:%M",announceTime); + hh->printf("\t\t\t%s\n",zAnnounceTime); + hh->printf("\t\t\t%d\n",(int)timer->announceTime); + + char zSafetyAnnounceTime[25] = {0}; + time_t real_announceTimeT = timer->announceTime - pre; + struct tm *safetyAnnounceTime = localtime(&real_announceTimeT); + strftime(zSafetyAnnounceTime,20,"%d.%m. %H:%M",safetyAnnounceTime); + hh->printf("\t\t\t%s\n",zSafetyAnnounceTime); + hh->printf("\t\t\t%d\n",(int)real_announceTimeT); + + + char zStopTime[25] = {0}; + if(timer->stopTime > 0){ + struct tm *stopTime = localtime(&(timer->stopTime)); + strftime(zStopTime,20,"%d.%m. %H:%M",stopTime); + } + hh->printf("\t\t\t%s\n",zStopTime); + hh->printf("\t\t\t%d\n",(int)timer->stopTime); + + char zSafetyStopTime[25] = {0}; + time_t real_stopTimeT = timer->stopTime - post; + if(timer->stopTime > 0){ + struct tm *safetyStopTime = localtime(&real_stopTimeT); + strftime(zSafetyStopTime,20,"%d.%m. %H:%M",safetyStopTime); + } + hh->printf("\t\t\t%s\n",zSafetyStopTime); + hh->printf("\t\t\t%d\n",(int)real_stopTimeT); + + // repeat + std::string zRep = NeutrinoAPI->timerEventRepeat2Str(timer->eventRepeat); + std::string zRepCount; + if (timer->eventRepeat == CTimerd::TIMERREPEAT_ONCE) + zRepCount = "no"; + else + zRepCount = (timer->repeatCount == 0) ? "∞" : string_printf("%dx",timer->repeatCount); + hh->printf("\t\t\t%s\n",zRepCount.c_str()); + hh->printf("\t\t\t%d\n",(int)timer->eventRepeat); + char weekdays[8]={0}; + NeutrinoAPI->Timerd->setWeekdaysToStr(timer->eventRepeat, weekdays); + hh->printf("\t\t\t%s\n",weekdays); + + // channel infos + std::string channel_name = NeutrinoAPI->GetServiceName(timer->channel_id); + if (channel_name.empty()) + channel_name = NeutrinoAPI->Zapit->isChannelTVChannel(timer->channel_id) ? "Unknown TV-Channel" : "Unknown Radio-Channel"; + + // epg title + std::string title = timer->epgTitle; + if(timer->epgID!=0){ + CSectionsdClient sdc; + CEPGData epgdata; + if (sdc.getEPGid(timer->epgID, timer->epg_starttime, &epgdata)) + title = epgdata.title; + } + + switch(timer->eventType) + { + case CTimerd::TIMER_NEXTPROGRAM :{ +// hh->WriteLn("\t\t\tnext_program\n"); + hh->printf("\t\t\t" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "\n",timer->channel_id); + hh->printf("\t\t\t%s\n",channel_name.c_str()); + hh->printf("\t\t\t%s\n",title.c_str()); + } + break; + + case CTimerd::TIMER_ZAPTO :{ +// hh->WriteLn("\t\t\tzapto\n"); + hh->printf("\t\t\t" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "\n",timer->channel_id); + hh->printf("\t\t\t%s\n",channel_name.c_str()); + hh->printf("\t\t\t%s\n",title.c_str()); + } + break; + + case CTimerd::TIMER_RECORD :{ +// hh->WriteLn("\t\t\trecord\n"); + hh->printf("\t\t\t" PRINTF_CHANNEL_ID_TYPE_NO_LEADING_ZEROS "\n",timer->channel_id); + hh->printf("\t\t\t%s\n",channel_name.c_str()); + hh->printf("\t\t\t%s\n",title.c_str()); + + // audio + if( timer->apids != TIMERD_APIDS_CONF){ + hh->WriteLn("\t\t\t\n"); + } + hh->printf("\t\t\t%s\n",timer->recordingDir); + hh->printf("\t\t\t%d\n",(int)timer->epgID); + + } + break; + + case CTimerd::TIMER_STANDBY :{ +// hh->WriteLn("\t\t\tstandby\n"); + hh->printf("\t\t\t%s\n",(timer->standby_on)? "on" : "off"); + } + break; + + case CTimerd::TIMER_REMIND :{ +// hh->WriteLn("\t\t\tremind\n"); + std::string _message; + _message = std::string(timer->message).substr(0,20); + hh->printf("\t\t\t%s\n",_message.c_str()); + } + break; + + case CTimerd::TIMER_EXEC_PLUGIN :{ +// hh->WriteLn("\t\t\tplugin\n"); + hh->printf("\t\t\t%s\n",timer->pluginName); + } + break; + + case CTimerd::TIMER_SLEEPTIMER :{ +// hh->WriteLn("\t\t\tsleeptimer\n"); + } + break; + + case CTimerd::TIMER_IMMEDIATE_RECORD :{ +// hh->WriteLn("\t\t\timmediate_record\n"); + } + break; + + default:{} + } + hh->WriteLn("\t\t\n"); + } + hh->WriteLn("\t\n"); + hh->WriteLn("\n"); +} + //----------------------------------------------------------------------------- // yweb : Extentions //----------------------------------------------------------------------------- diff --git a/src/nhttpd/tuxboxapi/coolstream/controlapi.h b/src/nhttpd/tuxboxapi/coolstream/controlapi.h index 3a515228b..de9d93bcc 100644 --- a/src/nhttpd/tuxboxapi/coolstream/controlapi.h +++ b/src/nhttpd/tuxboxapi/coolstream/controlapi.h @@ -37,6 +37,7 @@ private: void SendBouquet(CyhookHandler *hh,int BouquetNr); void SendChannelList(CyhookHandler *hh); void SendTimers(CyhookHandler *hh); + void SendTimersXML(CyhookHandler *hh); // subs friend class CNeutrinoWebserver; // for timer /fb/ compatibility diff --git a/src/nhttpd/yconfig.h b/src/nhttpd/yconfig.h index 2fcf2c5ee..632efb2cf 100644 --- a/src/nhttpd/yconfig.h +++ b/src/nhttpd/yconfig.h @@ -25,7 +25,7 @@ //----------------------------------------------------------------------------- // General central Definitions //----------------------------------------------------------------------------- -#define HTTPD_VERSION "3.2.7" // Webserver version (can be overloaded) +#define HTTPD_VERSION "3.2.8" // Webserver version (can be overloaded) #define YHTTPD_VERSION "1.3.1" // Webserver version (Version of yhttpd-core!) #define IADDR_LOCAL "127.0.0.1" // local IP #define HTTPD_NAME "yhttpd" // Webserver name (can be overloaded)