<%pre> #include #include #include #include #include "exception.h" #include "tools.h" #include "timers.h" using namespace std; using namespace vdrlive; <%args> timerid; bool active = true; channel = ""; title = ""; day = FormatDateTime( "%d", time( 0 ) ); 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 = StringToInt( FormatDateTime( "%H", time( 0 ) ) ); int start_m = StringToInt( FormatDateTime( "%M", time( 0 ) ) ); int end_h = StringToInt( FormatDateTime( "%H", time( 0 ) ) ); int end_m = StringToInt( FormatDateTime( "%M", time( 0 ) ) ); bool vps = ::Setup.UseVps; int priority = ::Setup.DefaultPriority; int lifetime = ::Setup.DefaultLifetime; aux = ""; <%request scope="global"> std::string pageTitle( tr("Edit timer") ); <%cpp> try { ReadLock channelsLock( Channels ); if ( !channelsLock ) throw HtmlError( tr("Channels"), tr("Couldn't aquire access to channels, please try again later.") ); cMutexLock timersLock( &LiveTimerManager() ); SortedTimers& timers = LiveTimerManager().GetTimers(); cTimer* timer = 0; if ( !timerid.empty() ) { timer = timers.GetByTimerId( timerid ); if ( timer == 0 ) throw HtmlError( tr("Timers"), tr("Couldn't find channel. Maybe you mistyped your request?") ); } if ( request.getMethod() != "POST" && timer != 0 ) { active = timer->Flags() & tfActive; channel = *timer->Channel()->GetChannelID().ToString(); title = timer->File() ? timer->File() : ""; day = timer->Day() ? FormatDateTime( "%d", timer->Day() ) : ""; 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() : ""; } std::string result; 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" : "-" ); ostringstream builder; builder << flags << ":" << channel << ":" << ( weekdays != "-------" ? weekdays : "" ) << ( weekdays == "-------" || day.empty() ? "" : "@" ) << day << ":" << ( start_h * 100 + start_m ) << ":" << ( end_h * 100 + end_m ) << ":" << priority << ":" << lifetime << ":" << title << ":" << aux; std::string error = LiveTimerManager().UpdateTimer( timer, builder.str() ); if ( !error.empty() ) throw HtmlError( tr("Timers"), error ); } tnt::Savepoint spoint( reply ); VDR Live - <$ timer ? tr("Edit timer") : tr("New timer") $>
VDR Live! <& menu >
<& pageelems.header_box content=(timer ? tr("Edit timer") : tr("New timer")) &>
<$ tr("Active") $>: type="radio"><$ tr("Yes") $> type="radio"><$ tr("No") $>
<$ tr("Channel") $>: <& channels_widget name=("channel") channelId=(true) selected=(channel) &>
<$ tr("Title" ) $>:
<$ tr("Day") $>:
<$ tr("Weekday") $>: /> <$ tr("Monday") $> /> <$ tr("Tuesday") $> /> <$ tr("Wednesday") $> /> <$ tr("Thursday") $> /> <$ tr("Friday") $> /> <$ tr("Saturday") $> /> <$ tr("Sunday") $>
<$ tr("Start") $>: :
<$ tr("Stop") $>: :
<$ tr("Use VPS") $>: />
<$ tr("Priority") $>:
<$ tr("Lifetime") $>:
<%cpp> spoint.commit(); } catch ( HtmlError const& ex ) { cxxtools::QueryParams param = qparam; param.add( "errorTitle", ex.GetTitle() ); param.add( "errorMessage", ex.GetMessage() ); callComp( "error", request, reply, param ); }