summaryrefslogtreecommitdiff
path: root/pages
diff options
context:
space:
mode:
authorSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-06 23:33:34 +0000
committerSascha Volkenandt <sascha (at) akv-soft (dot) de>2007-01-06 23:33:34 +0000
commit0252d06339a3f834d86aab32845e613314e5e367 (patch)
treec183ab25f92592cf8aa3d082e7aaabb6a47e9505 /pages
parentbb35bd7595564327881f5941d7853e427827f8b9 (diff)
downloadvdr-plugin-live-0252d06339a3f834d86aab32845e613314e5e367.tar.gz
vdr-plugin-live-0252d06339a3f834d86aab32845e613314e5e367.tar.bz2
- added simple error handling and regrouped web pages
Diffstat (limited to 'pages')
-rw-r--r--pages/channels_widget.ecpp27
-rw-r--r--pages/edit_timer.ecpp35
-rw-r--r--pages/schedule.ecpp94
-rw-r--r--pages/timers.ecpp9
4 files changed, 90 insertions, 75 deletions
diff --git a/pages/channels_widget.ecpp b/pages/channels_widget.ecpp
index 5bd69b2..bdc526c 100644
--- a/pages/channels_widget.ecpp
+++ b/pages/channels_widget.ecpp
@@ -1,5 +1,6 @@
<%pre>
#include <vdr/channels.h>
+#include "exception.h"
#include "setup.h"
#include "tools.h"
@@ -13,17 +14,19 @@ 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.") );
+</%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()) {
- std::string listChannelId = *listChannel->GetChannelID().ToString();
-}>
- <option value="<? channelId ? *listChannel->GetChannelID().ToString() ?><? !channelId ? listChannel->Number() ?>"
- <{ reply.out() << ( listChannelId == selected ? "selected=\"selected\"" : "" ); }>><$ listChannel->Name() $></option>
-<{
- }
- }
-}>
+% 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>
diff --git a/pages/edit_timer.ecpp b/pages/edit_timer.ecpp
index f093c99..948944d 100644
--- a/pages/edit_timer.ecpp
+++ b/pages/edit_timer.ecpp
@@ -1,9 +1,9 @@
<%pre>
#include <sstream>
-#include <vdr/plugin.h>
#include <vdr/config.h>
#include <vdr/i18n.h>
-#include "setup.h"
+#include <tnt/savepoint.h>
+#include "exception.h"
#include "tools.h"
#include "timers.h"
@@ -13,7 +13,6 @@ using namespace vdrlive;
</%pre>
<%args>
timerid;
-bool submit = false;
bool active = true;
channel = "";
title = "";
@@ -34,10 +33,14 @@ int priority = ::Setup.DefaultPriority;
int lifetime = ::Setup.DefaultLifetime;
aux = "";
</%args>
+<%request scope="global">
+std::string pageTitle( tr("Edit timer") );
+</%request>
<%cpp>
+try {
ReadLock channelsLock( Channels );
- if (!channelsLock)
- return DECLINED; // XXX error page
+ if ( !channelsLock )
+ throw HtmlError( tr("Channels"), tr("Couldn't aquire access to channels, please try again later.") );
cMutexLock timersLock( &LiveTimerManager() );
SortedTimers& timers = LiveTimerManager().GetTimers();
@@ -46,7 +49,7 @@ aux = "";
if ( !timerid.empty() ) {
timer = timers.GetByTimerId( timerid );
if ( timer == 0 )
- return DECLINED; // XXX error page
+ throw HtmlError( tr("Timers"), tr("Couldn't find channel. Maybe you mistyped your request?") );
}
if ( request.getMethod() != "POST" && timer != 0 ) {
@@ -72,14 +75,11 @@ aux = "";
}
std::string result;
- if ( submit ) {
+ 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" : "-" );
- //( wday_mon ? 0x01 : 0 ) | ( wday_tue ? 0x02 : 0 ) | ( wday_wed ? 0x04 : 0 ) |
- //( wday_thu ? 0x08 : 0 ) | ( wday_fri ? 0x10 : 0 ) | ( wday_sat ? 0x20 : 0 ) |
- //( wday_sun ? 0x40 : 0 );
ostringstream builder;
builder << flags << ":" << channel << ":" << ( weekdays != "-------" ? weekdays : "" )
<< ( weekdays == "-------" || day.empty() ? "" : "@" ) << day << ":" << ( start_h * 100 + start_m )
@@ -87,8 +87,10 @@ aux = "";
std::string error = LiveTimerManager().UpdateTimer( timer, builder.str() );
if ( !error.empty() )
- reply.out() << error;
+ throw HtmlError( tr("Timers"), error );
}
+
+ tnt::Savepoint spoint( reply );
</%cpp>
<html>
<head>
@@ -172,10 +174,19 @@ aux = "";
</tr>
<tr>
- <td class="buttonpanel" colspan="2"><button name="submit" type="submit" value="1"><$ tr("Save") $></button></td>
+ <td class="buttonpanel" colspan="2"><button name="submit" type="submit"><$ tr("Save") $></button></td>
</tr>
</table>
</form>
</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>
diff --git a/pages/schedule.ecpp b/pages/schedule.ecpp
index b22bf2a..20d3911 100644
--- a/pages/schedule.ecpp
+++ b/pages/schedule.ecpp
@@ -3,6 +3,8 @@
#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,29 +14,42 @@ using namespace vdrlive;
<%args>
int channel = -1;
</%args>
-<{
+<%request scope="global">
+std::string pageTitle( tr("Schedule") );
+</%request>
+<%cpp>
+try {
cSchedulesLock schedulesLock;
- const cSchedules* schedules = cSchedules::Schedules(schedulesLock);
- cChannel* Channel;
+ cSchedules const* schedules = cSchedules::Schedules( schedulesLock );
ReadLock channelsLock( Channels );
- if (channelsLock) {
- if (channel > 0) {
- Channel = Channels.GetByNumber(channel);
- } else {
- Channel = Channels.Get(Channels.GetNextNormal(-1));
- }
+ if ( !channelsLock )
+ throw HtmlError( tr("Channels"), tr("Couldn't aquire access to channels, please try again later.") );
-}>
+ cChannel* Channel;
+ if ( channel > 0 )
+ Channel = Channels.GetByNumber( channel );
+ else
+ 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?") );
+
+ cSchedule const* Schedule = schedules->GetSchedule( Channel );
+ if ( Schedule == 0 )
+ throw HtmlError( tr("Schedule"), tr("No schedules available for this channel.") );
+
+ tnt::Savepoint spoint( reply );
+</%cpp>
<html>
<head>
- <title>VDR Live - <$ tr("Schedule") $></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">
<div class="head_box">
@@ -43,18 +58,14 @@ int channel = -1;
<td><? Channel ? Channel->Name() ?></td>
<td>
<form name="channels" id="channels">
-<& channels_widget name=("channel") selected=(Channel ? *Channel->GetChannelID().ToString() : "") onchange=("document.forms.channels.submit()") &>
+ <& channels_widget name=("channel") selected=(Channel ? *Channel->GetChannelID().ToString() : "")
+ onchange=("document.forms.channels.submit()") &>
</form>
</td>
</tr>
</table>
</div>
-<{
- if (Channel) {
- const cSchedule *Schedule = schedules->GetSchedule(Channel);
- if (Schedule) {
-}>
<table class="schedule" cellspacing="0" callpadding="0">
<{
bool active_line = false;
@@ -76,33 +87,26 @@ int channel = -1;
if (current_day != day) {
current_day = day;
}>
- <tr>
- <td class="head" colspan="3"><$ current_day $></td>
- </tr>
-<{
- }
-}>
- <tr class="<? active_line ? "active" ?>">
- <td><$ start $> - <$ end $></td>
- <td><strong><$ title $></strong><br /><$ short_description $><br /></td>
- <td>&nbsp;</td>
- </tr>
-<{
- }
-}>
+ <tr>
+ <td class="head" colspan="3"><$ current_day $></td>
+ </tr>
+% }
+ <tr class="<? active_line ? "active" ?>">
+ <td><$ start $> - <$ end $></td>
+ <td><strong><$ title $></strong><br /><$ short_description $><br /></td>
+ <td>&nbsp;</td>
+ </tr>
+% }
</table>
-<{
- } else {
-}>
- Kein Schedule für Channel <$ Channel->Number() $>
-<{
- }
- } else {
-}>
- Kein Channel mit der Nummer <$ channel $>
-<{
- }
- }
-}>
+ </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>
diff --git a/pages/timers.ecpp b/pages/timers.ecpp
index 01d37f3..9c9593c 100644
--- a/pages/timers.ecpp
+++ b/pages/timers.ecpp
@@ -1,6 +1,4 @@
<%pre>
-#include <vdr/plugin.h>
-#include <vdr/config.h>
#include <vdr/i18n.h>
#include "timers.h"
#include "tools.h"
@@ -10,10 +8,9 @@ using namespace vdrlive;
</%pre>
<%args>
</%args>
-<{
-
-
-}>
+<%cpp>
+//cMutexLock timersLock( &LiveTimerManager() );
+</%cpp>
<html>
<head>
<title>VDR-Live - <$ tr("Timers") $></title>