summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-07 18:42:45 +0000
committerSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-07 18:42:45 +0000
commitab7a2112f96bb48ee2713ada4c9ce73322cf3cba (patch)
tree44f229f1c011fc135571849c386f78bbb5a9af48 /pages
parent9508850d788d905b21cd2622b22cb76e80cf34ca (diff)
downloadvdr-plugin-live-ab7a2112f96bb48ee2713ada4c9ce73322cf3cba.tar.gz
vdr-plugin-live-ab7a2112f96bb48ee2713ada4c9ce73322cf3cba.tar.bz2
- simplified error handling
- moved error_widget to error.ecpp as subcomponent - introduced error handling where necessary - moved creation of timer settings string from page to code - added redirect to edit_timer.ecpp after saving a timer
Diffstat (limited to 'pages')
-rw-r--r--pages/Makefile2
-rw-r--r--pages/channels_widget.ecpp37
-rw-r--r--pages/edit_timer.ecpp81
-rw-r--r--pages/error.ecpp28
-rw-r--r--pages/error_widget.ecpp10
-rw-r--r--pages/keypress.ecpp5
-rw-r--r--pages/page_exit.ecpp10
-rw-r--r--pages/page_init.ecpp12
-rw-r--r--pages/recordings.ecpp19
-rw-r--r--pages/remote.ecpp9
-rw-r--r--pages/schedule.ecpp28
-rw-r--r--pages/timers.ecpp22
-rw-r--r--pages/whats_on.ecpp2
13 files changed, 128 insertions, 137 deletions
diff --git a/pages/Makefile b/pages/Makefile
index f668a9f..8da6bb1 100644
--- a/pages/Makefile
+++ b/pages/Makefile
@@ -18,7 +18,7 @@ VDRDIR ?= ../../../..
OBJS = menu.o channels.o recordings.o schedule.o \
screenshot.o timers.o whats_on.o \
keypress.o remote.o channels_widget.o edit_timer.o \
- error_widget.o error.o pageelems.o tooltip_widget.o
+ error.o pageelems.o tooltip_widget.o
### Default rules:
diff --git a/pages/channels_widget.ecpp b/pages/channels_widget.ecpp
index bdc526c..df9219f 100644
--- a/pages/channels_widget.ecpp
+++ b/pages/channels_widget.ecpp
@@ -8,25 +8,26 @@ using namespace vdrlive;
</%pre>
<%args>
-name = "channel";
-int lastChannel = LiveSetup().GetLastChannel();
-selected;
-onchange;
-bool channelId = false;
+ name = "channel";
+ selected;
+ onchange;
+ bool channelid = false;
</%args>
<%cpp>
-ReadLock channelsLock( Channels );
-if ( !channelsLock )
- throw HtmlError( tr("Channels"), tr("Couldn't aquire access to channels, please try again later.") );
+ ReadLock channelsLock( Channels );
+ if ( !channelsLock )
+ throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") );
+
+ int lastChannel = LiveSetup().GetLastChannel();
</%cpp>
- <select name="<$ name $>" <{ reply.out() << ( !onchange.empty() ? "onchange=\""+onchange+"\"" : "" ); }>>
-% for ( cChannel *listChannel = Channels.First(); listChannel && listChannel->Number() <= lastChannel;
-% listChannel = Channels.Next( listChannel ) ) {
-% if ( listChannel->GroupSep() || *listChannel->Name() == '\0' )
-% continue;
+<select name="<$ name $>" <{ reply.out() << ( !onchange.empty() ? "onchange=\""+onchange+"\"" : "" ); }>>
+% for ( cChannel *listChannel = Channels.First(); listChannel && listChannel->Number() <= lastChannel;
+% listChannel = Channels.Next( listChannel ) ) {
+% if ( listChannel->GroupSep() || *listChannel->Name() == '\0' )
+% continue;
%
-% std::string listChannelId = *listChannel->GetChannelID().ToString();
- <option value="<? channelId ? *listChannel->GetChannelID().ToString() ?><? !channelId ? listChannel->Number() ?>"
- <{ reply.out() << ( listChannelId == selected ? "selected=\"selected\"" : "" ); }>><$ listChannel->Name() $></option>
-% }
- </select>
+% std::string listChannelId = *listChannel->GetChannelID().ToString();
+ <option value="<? channelid ? *listChannel->GetChannelID().ToString() ?><? !channelid ? listChannel->Number() ?>"
+ <{ reply.out() << ( listChannelId == selected ? "selected=\"selected\"" : "" ); }>><$ listChannel->Name() $></option>
+% }
+</select>
diff --git a/pages/edit_timer.ecpp b/pages/edit_timer.ecpp
index c1faede..1fa3e95 100644
--- a/pages/edit_timer.ecpp
+++ b/pages/edit_timer.ecpp
@@ -1,8 +1,6 @@
<%pre>
-#include <sstream>
#include <vdr/config.h>
#include <vdr/i18n.h>
-#include <tnt/savepoint.h>
#include "exception.h"
#include "tools.h"
#include "timers.h"
@@ -12,35 +10,34 @@ using namespace vdrlive;
</%pre>
<%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 = "";
+ 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 = "";
</%args>
-<%request scope="global">
-std::string pageTitle( tr("Edit timer") );
-</%request>
+<%include>page_init.ecpp</%include>
<%cpp>
-try {
+ pageTitle = tr("Edit timer");
+
ReadLock channelsLock( Channels );
if ( !channelsLock )
- throw HtmlError( tr("Channels"), tr("Couldn't aquire access to channels, please try again later.") );
+ throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") );
cMutexLock timersLock( &LiveTimerManager() );
SortedTimers& timers = LiveTimerManager().GetTimers();
@@ -49,7 +46,7 @@ try {
if ( !timerid.empty() ) {
timer = timers.GetByTimerId( timerid );
if ( timer == 0 )
- throw HtmlError( tr("Timers"), tr("Couldn't find channel. Maybe you mistyped your request?") );
+ throw HtmlError( tr("Couldn't find channel. Maybe you mistyped your request?") );
}
if ( request.getMethod() != "POST" && timer != 0 ) {
@@ -74,23 +71,19 @@ try {
aux = timer->Aux() ? timer->Aux() : "";
}
- std::string result;
+ 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;
+ int start = start_h * 100 + start_m;
+ int stop = end_h * 100 + end_m;
- std::string error = LiveTimerManager().UpdateTimer( timer, builder.str() );
- if ( !error.empty() )
- throw HtmlError( tr("Timers"), error );
- }
+ LiveTimerManager().UpdateTimer( timer, flags, channel, weekdays, day, start, stop, priority, lifetime, title, aux );
- tnt::Savepoint spoint( reply );
+ return reply.redirect("timers.html");
+ }
</%cpp>
<html>
<head>
@@ -118,7 +111,7 @@ try {
<tr>
<td class="label"><$ tr("Channel") $>:</td>
<td>
-<& channels_widget name=("channel") channelId=(true) selected=(channel) &>
+<& channels_widget name=("channel") channelid=(true) selected=(channel) &>
</td>
</tr>
@@ -179,12 +172,4 @@ try {
</div>
</body>
</html>
-<%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 );
-}
-</%cpp>
+<%include>page_exit.ecpp</%include>
diff --git a/pages/error.ecpp b/pages/error.ecpp
index 241f1a6..196f147 100644
--- a/pages/error.ecpp
+++ b/pages/error.ecpp
@@ -1,10 +1,12 @@
+<%pre>
+#include <vdr/i18n.h>
+
+</%pre>
<%args>
-errorTitle;
-errorMessage;
+ pageTitle;
+ errorTitle = tr("Page error");
+ errorMessage;
</%args>
-<%request scope="global">
-std::string pageTitle;
-</%request>
<html>
<head>
<title>VDR-Live - <$ pageTitle $></title>
@@ -16,10 +18,18 @@ std::string pageTitle;
<& menu >
</div>
<div class="inhalt">
- <div class="head_box">
- <$ pageTitle $>
- </div>
- <& error_widget errorTitle=(errorTitle) errorMessage=(errorMessage) &>
+ <& pageelems.header_box content=(pageTitle) &>
+ <& error.error_widget errorTitle=(errorTitle) errorMessage=(errorMessage) &>
</div>
</body>
</html>
+<%def error_widget>
+ <%args>
+ errorTitle;
+ errorMessage;
+ </%args>
+ <table class="error" cellpadding="0" cellspacing="0">
+ <tr><td class="title"><$ errorTitle $></td></tr>
+ <tr><td class="message"><$ errorMessage $></td></tr>
+ </table>
+</%def>
diff --git a/pages/error_widget.ecpp b/pages/error_widget.ecpp
deleted file mode 100644
index 2836546..0000000
--- a/pages/error_widget.ecpp
+++ /dev/null
@@ -1,10 +0,0 @@
-<%pre>
-</%pre>
-<%args>
-errorTitle;
-errorMessage;
-</%args>
- <table class="error" cellpadding="0" cellspacing="0">
- <tr><td class="title"><$ errorTitle $></td></tr>
- <tr><td class="message"><$ errorMessage $></td></tr>
- </table>
diff --git a/pages/keypress.ecpp b/pages/keypress.ecpp
index 2475dc1..a1f36fa 100644
--- a/pages/keypress.ecpp
+++ b/pages/keypress.ecpp
@@ -1,11 +1,12 @@
<%pre>
#include <vdr/remote.h>
+
</%pre>
<%args>
-int keycode = kNone;
+ int keycode = kNone;
</%args>
<%cpp>
-reply.setContentType("application/xml");
+ reply.setContentType("application/xml");
</%cpp>
<?xml version="1.0"?>
<service>
diff --git a/pages/page_exit.ecpp b/pages/page_exit.ecpp
new file mode 100644
index 0000000..94c46ed
--- /dev/null
+++ b/pages/page_exit.ecpp
@@ -0,0 +1,10 @@
+<# do not add to Makefile #>
+<%cpp>
+ spoint.commit();
+} catch ( HtmlError const& ex ) {
+ cxxtools::QueryParams param = qparam;
+ param.add( "pageTitle", pageTitle );
+ param.add( "errorMessage", ex.what() );
+ callComp( "error", request, reply, param );
+}
+</%cpp>
diff --git a/pages/page_init.ecpp b/pages/page_init.ecpp
new file mode 100644
index 0000000..c1d4680
--- /dev/null
+++ b/pages/page_init.ecpp
@@ -0,0 +1,12 @@
+<# do not add to Makefile #>
+<%pre>
+#include <tnt/savepoint.h>
+#include "exception.h"
+</%pre>
+<%request scope="global">
+std::string pageTitle;
+</%request>
+<%cpp>
+try {
+ tnt::Savepoint spoint( reply );
+</%cpp>
diff --git a/pages/recordings.ecpp b/pages/recordings.ecpp
index bed138f..8ea488e 100644
--- a/pages/recordings.ecpp
+++ b/pages/recordings.ecpp
@@ -2,7 +2,6 @@
#include <sstream>
#include <vdr/plugin.h>
#include <vdr/config.h>
-#include <tnt/savepoint.h>
#include "exception.h"
#include "tools.h"
#include "recordings.h"
@@ -12,15 +11,12 @@ using namespace vdrlive;
</%pre>
<%args>
</%args>
-<%request scope="global">
-std::string pageTitle(tr("Recordings"));
-</%request>
<%request scope="page">
RecordingsTree recordingsTree;
</%request>
+<%include>page_init.ecpp</%include>
<%cpp>
-try {
- tnt::Savepoint spoint(reply);
+ pageTitle = tr("Recordings");
</%cpp>
<html>
<head>
@@ -45,6 +41,8 @@ try {
</div>
</body>
</html>
+<%include>page_exit.ecpp</%include>
+
<%def recordings_item>
<%args>
path[];
@@ -104,12 +102,3 @@ for (iter = recordingsTree.begin(path); iter != end; iter++) {
}>
</ul>
</%def>
-<%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 );
-}
-</%cpp>
diff --git a/pages/remote.ecpp b/pages/remote.ecpp
index 994dc6f..ec593fb 100644
--- a/pages/remote.ecpp
+++ b/pages/remote.ecpp
@@ -5,6 +5,10 @@
using namespace vdrlive;
</%pre>
+<%include>page_init.ecpp</%include>
+<%cpp>
+ pageTitle = tr("Remote control");
+</%cpp>
<html>
<head>
<script type="text/javascript"><!--
@@ -96,7 +100,7 @@ using namespace vdrlive;
}
}
//--></script>
- <title>VDR-Live - <$ tr("Remote Control") $></title>
+ <title>VDR-Live - <$ pageTitle $></title>
<link rel="stylesheet" type="text/css" href="/styles.css" />
</head>
<body onload="StreamInit(); FillIntervals();">
@@ -105,7 +109,7 @@ using namespace vdrlive;
<& menu >
</div>
<div class="inhalt">
-<& pageelems.header_box content=(tr("Remote Control")) &>
+ <& pageelems.header_box content=(pageTitle) &>
<div class="screenshot">
<img src="screenshot.jpg" name="vdrlive" /><br />
<$ tr("Interval:") $> <select name="interval" onchange="ChangeInterval()"></select>
@@ -187,3 +191,4 @@ using namespace vdrlive;
</div>
</body>
</html>
+<%include>page_exit.ecpp</%include>
diff --git a/pages/schedule.ecpp b/pages/schedule.ecpp
index 20d3911..2577c6d 100644
--- a/pages/schedule.ecpp
+++ b/pages/schedule.ecpp
@@ -3,7 +3,6 @@
#include <vdr/channels.h>
#include <vdr/epg.h>
#include <vdr/config.h>
-#include <tnt/savepoint.h>
#include "exception.h"
#include "setup.h"
#include "tools.h"
@@ -12,19 +11,18 @@ using namespace vdrlive;
</%pre>
<%args>
-int channel = -1;
+ int channel = -1;
</%args>
-<%request scope="global">
-std::string pageTitle( tr("Schedule") );
-</%request>
+<%include>page_init.ecpp</%include>
<%cpp>
-try {
+ pageTitle = tr("Schedule");
+
cSchedulesLock schedulesLock;
cSchedules const* schedules = cSchedules::Schedules( schedulesLock );
ReadLock channelsLock( Channels );
if ( !channelsLock )
- throw HtmlError( tr("Channels"), tr("Couldn't aquire access to channels, please try again later.") );
+ throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") );
cChannel* Channel;
if ( channel > 0 )
@@ -33,13 +31,11 @@ try {
Channel = Channels.Get( Channels.GetNextNormal( -1 ) );
if ( Channel == 0 )
- throw HtmlError( tr("Channels"), tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") );
+ throw HtmlError( tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") );
cSchedule const* Schedule = schedules->GetSchedule( Channel );
if ( Schedule == 0 )
- throw HtmlError( tr("Schedule"), tr("No schedules available for this channel.") );
-
- tnt::Savepoint spoint( reply );
+ throw HtmlError( tr("No schedules available for this channel.") );
</%cpp>
<html>
<head>
@@ -101,12 +97,4 @@ try {
</div>
</body>
</html>
-<%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 );
-}
-</%cpp>
+<%include>page_exit.ecpp</%include>
diff --git a/pages/timers.ecpp b/pages/timers.ecpp
index 411dfe3..ff27a1e 100644
--- a/pages/timers.ecpp
+++ b/pages/timers.ecpp
@@ -6,29 +6,26 @@
using namespace vdrlive;
</%pre>
-<%args>
-</%args>
+<%include>page_init.ecpp</%include>
<%cpp>
-//cMutexLock timersLock( &LiveTimerManager() );
+ pageTitle = tr("Timers");
+
+ cMutexLock timersLock( &LiveTimerManager() );
+ SortedTimers& timers = LiveTimerManager().GetTimers();
</%cpp>
<html>
<head>
- <title>VDR-Live - <$ tr("Timers") $></title>
+ <title>VDR-Live - <$ pageTitle $></title>
<link rel="stylesheet" type="text/css" href="/styles.css" />
</head>
<body>
<div class="left_area">
<img src="logo.png" alt="VDR Live!" border="0" />
-<& menu >
+ <& menu >
</div>
<div class="inhalt">
-<& pageelems.header_box content=(tr("Timers")) &>
-<{
- cMutexLock timersLock( &LiveTimerManager() );
- SortedTimers& timers = LiveTimerManager().GetTimers();
-
- if (timers.size() == 0) {
-}>
+ <& pageelems.header_box content=(pageTitle) &>
+% if (timers.size() == 0) {
Keiner Timer definiert
% } else {
<table class="timers" cellspacing="0" cellpadding="0">
@@ -65,3 +62,4 @@ using namespace vdrlive;
</div>
</body>
</html>
+<%include>page_exit.ecpp</%include>
diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp
index a9e9744..d05b9fa 100644
--- a/pages/whats_on.ecpp
+++ b/pages/whats_on.ecpp
@@ -13,6 +13,7 @@ using namespace vdrlive;
<%args>
type = "now";
</%args>
+<%include>page_init.ecpp</%include>
<{
cSchedulesLock schedulesLock;
@@ -91,3 +92,4 @@ if (type == "now") {
</div>
</body>
</html>
+<%include>page_exit.ecpp</%include>