summaryrefslogtreecommitdiff
path: root/pages/edit_timer.ecpp
diff options
context:
space:
mode:
Diffstat (limited to 'pages/edit_timer.ecpp')
-rw-r--r--pages/edit_timer.ecpp89
1 files changed, 54 insertions, 35 deletions
diff --git a/pages/edit_timer.ecpp b/pages/edit_timer.ecpp
index 5772f9f..27b0362 100644
--- a/pages/edit_timer.ecpp
+++ b/pages/edit_timer.ecpp
@@ -1,5 +1,8 @@
<%pre>
+#include <memory>
+#include <vdr/channels.h>
#include <vdr/config.h>
+#include <vdr/epg.h>
#include <vdr/i18n.h>
#include "exception.h"
#include "tools.h"
@@ -10,11 +13,15 @@ using namespace vdrlive;
</%pre>
<%args>
- timerid;
+ // input parameters
+ string timerid;
+ tChannelID channelid;
+ tEventID eventid = 0;
+ // form parameters
+ tChannelID channel;
bool active = true;
- channel = "";
- title = "";
- day = FormatDateTime( "%d", time( 0 ) );
+ string title = "";
+ string day = "";
bool wday_mon = false;
bool wday_tue = false;
bool wday_wed = false;
@@ -22,23 +29,19 @@ using namespace vdrlive;
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 = "";
+ 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 = "";
</%args>
<%include>page_init.eh</%include>
<%cpp>
pageTitle = tr("Edit timer");
- ReadLock channelsLock( Channels );
- if ( !channelsLock )
- throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") );
-
cMutexLock timersLock( &LiveTimerManager() );
SortedTimers& timers = LiveTimerManager().GetTimers();
@@ -46,12 +49,42 @@ using namespace vdrlive;
if ( !timerid.empty() ) {
timer = timers.GetByTimerId( timerid );
if ( timer == 0 )
- throw HtmlError( tr("Couldn't find channel. Maybe you mistyped your request?") );
+ throw HtmlError( tr("Couldn't find timer. Maybe you mistyped your request?") );
}
- if ( request.getMethod() != "POST" && timer != 0 ) {
+ 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;
+
+ LiveTimerManager().UpdateTimer( timer, flags, channel, weekdays, day, start, stop, priority, lifetime, title, aux );
+
+ return reply.redirect("timers.html");
+ }
+
+ auto_ptr< cTimer > eventTimer;
+ if ( timer == 0 ) {
+ 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 ) {
active = timer->Flags() & tfActive;
- channel = *timer->Channel()->GetChannelID().ToString();
+ channel = timer->Channel()->GetChannelID();
title = timer->File() ? timer->File() : "";
day = timer->Day() ? FormatDateTime( "%d", timer->Day() ) : "";
wday_mon = timer->WeekDays() & 0x01;
@@ -70,20 +103,6 @@ using namespace vdrlive;
lifetime = timer->Lifetime();
aux = timer->Aux() ? timer->Aux() : "";
}
-
- 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" : "-" );
- int start = start_h * 100 + start_m;
- int stop = end_h * 100 + end_m;
-
- LiveTimerManager().UpdateTimer( timer, flags, channel, weekdays, day, start, stop, priority, lifetime, title, aux );
-
- return reply.redirect("timers.html");
- }
</%cpp>
<& pageelems.doc_type &>
<html>
@@ -99,7 +118,7 @@ using namespace vdrlive;
<div class="right_area">
<div class="inhalt">
<& pageelems.header_box content=(timer ? tr("Edit timer") : tr("New timer")) &>
- <form method="POST" name="edit_timer">
+ <form method="POST" name="edit_timer" action="edit_timer.ecpp">
<input type="hidden" name="timerid" value="<$ timerid $>"/>
<input type="hidden" name="aux" value="<$ aux $>"/>
<table class="edit" cellpadding="0" cellspacing="0">
@@ -113,7 +132,7 @@ using namespace vdrlive;
<tr>
<td class="label"><$ tr("Channel") $>:</td>
<td>
-<& channels_widget name=("channel") channelid=(true) selected=(channel) &>
+<& channels_widget name=("channel") channelid=(true) selected=(*channel.ToString()) &>
</td>
</tr>