<%pre> #include #include #include #include #include #include "exception.h" #include "tools.h" #include "timers.h" #include "setup.h" #include "epg_events.h" #include "timerconflict.h" #include "i18n.h" #include "livefeatures.h" #include "epgsearch.h" using namespace std; using namespace vdrlive; <%args> // input parameters string timerid; string epgid; string async; // form parameters tChannelID channel; bool active = true; string title = ""; string date = ""; bool wday_mon = false; bool wday_tue = false; bool wday_wed = false; bool wday_thu = false; bool wday_fri = false; bool wday_sat = false; bool wday_sun = false; int start_h = 0; int start_m = 0; int end_h = 0; int end_m = 0; bool vps = 0; int priority = 0; int lifetime = 0; string aux = ""; string directory = ""; <%session scope="global"> bool logged_in(false); string edit_timerreferer; TimerConflictNotifier timerNotifier; <%request scope="page"> cTimer* timer; <%include>page_init.eh <%cpp> if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); bool ajaxReq = !async.empty() && (lexical_cast(async) != 0); tChannelID channelid = tChannelID(); tEventID eventid = tEventID(); string message; cMutexLock timersLock( &LiveTimerManager() ); SortedTimers& timers = LiveTimerManager().GetTimers(); timer = 0; if ( !timerid.empty() ) { string tId = SortedTimers::DecodeDomId(timerid); // dsyslog("DEBUG: TIMER: tId = %s", tId.c_str()); timer = timers.GetByTimerId(tId); if ( timer == 0 ) throw HtmlError( tr("Couldn't find timer. Maybe you mistyped your request?") ); } if ( request.getMethod() == "POST" ) { uint flags = ( active ? tfActive : 0 ) | ( vps ? tfVps : 0 ); string weekdays = string( wday_mon ? "M" : "-" ) + ( wday_tue ? "T" : "-" ) + ( wday_wed ? "W" : "-" ) + ( wday_thu ? "T" : "-" ) + ( wday_fri ? "F" : "-" ) + ( wday_sat ? "S" : "-" ) + ( wday_sun ? "S" : "-" ); int start = start_h * 100 + start_m; int stop = end_h * 100 + end_m; if (!directory.empty()) title = directory + "~" + title; if (title.empty()) message = tr("Please set a title for the timer!"); else { // TRANSLATORS: only adjust the ordering and separators, don't translate the m's, d's and y's time_t tdate = GetDateFromDatePicker(date, tr("mm/dd/yyyy")); string sdate = DatePickerToC(tdate, "yyyy-mm-dd"); LiveTimerManager().UpdateTimer( timer, flags, channel, weekdays, sdate, start, stop, priority, lifetime, title, aux ); timerNotifier.SetTimerModification(); return reply.redirect(!edit_timerreferer.empty()?edit_timerreferer:"timers.html"); } } if (message.empty()) edit_timerreferer = request.getHeader("Referer:", "timers.html"); auto_ptr< cTimer > eventTimer; if ( timer == 0 && !epgid.empty()) { EpgEvents::DecodeDomId(epgid, channelid, eventid); if ( channelid.Valid() && eventid != 0 ) { cerr << "grabbing event" << endl << endl; cSchedulesLock schedLock; cSchedules const* schedules = cSchedules::Schedules( schedLock ); cSchedule const* schedule = schedules->GetSchedule( channelid ); eventTimer.reset( new cTimer( schedule->GetEvent( eventid ) ) ); } else { cerr << "grabbing new timer" << endl << endl; eventTimer.reset( new cTimer() ); eventTimer->SetFlags( tfActive ); } timer = eventTimer.get(); } if (timer == 0) { timer = new cTimer(); timer->SetFlags(tfActive); } if ( timer != 0 ) { active = timer->Flags() & tfActive; channel = timer->Channel()->GetChannelID(); title = timer->File() ? timer->File() : ""; if ( LiveFeatures< features::epgsearch >().Recent() ) { vector< string > directories = StringSplit( title, '~' ); if (directories.size() > 1) { directory = directories[0]; title = title.substr(directory.size()+1); } } // TRANSLATORS: only adjust the ordering and separators, don't translate the m's, d's and y's date = timer->Day() ? DatePickerToC(timer->Day(), tr("mm/dd/yyyy")) : ""; wday_mon = timer->WeekDays() & 0x01; wday_tue = timer->WeekDays() & 0x02; wday_wed = timer->WeekDays() & 0x04; wday_thu = timer->WeekDays() & 0x08; wday_fri = timer->WeekDays() & 0x10; wday_sat = timer->WeekDays() & 0x20; wday_sun = timer->WeekDays() & 0x40; start_h = ( timer->Start() / 100 ) % 100; start_m = timer->Start() % 100; end_h = ( timer->Stop() / 100 ) % 100; end_m = timer->Stop() % 100; vps = timer->Flags() & tfVps; priority = timer->Priority(); lifetime = timer->Lifetime(); aux = timer->Aux() ? timer->Aux() : ""; } <& pageelems.doc_type &> VDR Live - <$ timer ? tr("Edit timer") : tr("New timer") $> <%cpp> if (!ajaxReq) { <& pageelems.stylesheets &> <& pageelems.ajax_js &> <%cpp> } <%cpp> if (!ajaxReq) { <& pageelems.logo &> <& menu active=("timers") &> <%cpp> }
<%cpp> if ( LiveFeatures< features::epgsearch >().Recent() ) { RecordingDirs recordingdirs(true); <%cpp> }
<$ timer ? tr("Edit timer") : tr("New timer") $>
<$ trVDR("Active") $>:
type="radio">
type="radio">
<$ trVDR("Channel") $>:
<& channels_widget name=("channel") channelid=(true) selected=(channel) &>
<$ tr("Title" ) $>:
<$ tr("Directory" ) $>:
<$ trVDR("Day") $>:
<$ tr("Weekday") $>:
/>
/>
/>
/>
/>
/>
/>
<$ trVDR("Start") $>:
:
<$ trVDR("Stop") $>:
:
<$ tr("Use VPS") $>:
/>
<$ trVDR("Priority") $>:
<$ trVDR("Lifetime") $>:
<$ message $>
<%include>page_exit.eh