diff options
author | Martin Wache <martin@debian.lan> | 2010-11-07 10:20:00 +0100 |
---|---|---|
committer | Martin Wache <martin@debian.lan> | 2010-11-07 10:20:00 +0100 |
commit | ff37e7006cea3b14bb108c68d60a97fe15074369 (patch) | |
tree | 599745deb2b43e4aa8c303fb40633757e2aa2b56 | |
parent | 0ce41c5a6c128c980be72985b6faf9e1f53ff5b9 (diff) | |
download | vdr-plugin-live-ff37e7006cea3b14bb108c68d60a97fe15074369.tar.gz vdr-plugin-live-ff37e7006cea3b14bb108c68d60a97fe15074369.tar.bz2 |
- first working version of multischedule
-rw-r--r-- | pages/Makefile | 4 | ||||
-rw-r--r-- | pages/menu.ecpp | 1 | ||||
-rw-r--r-- | pages/multischedule.ecpp | 188 |
3 files changed, 191 insertions, 2 deletions
diff --git a/pages/Makefile b/pages/Makefile index 7e0ab56..c70ecb6 100644 --- a/pages/Makefile +++ b/pages/Makefile @@ -13,8 +13,8 @@ VDRDIR ?= ../../../.. ### The object files (add further files here): -OBJS = menu.o recordings.o schedule.o screenshot.o timers.o \ - whats_on.o switch_channel.o keypress.o remote.o \ +OBJS = menu.o recordings.o schedule.o multischedule.o screenshot.o \ + timers.o whats_on.o switch_channel.o keypress.o remote.o \ channels_widget.o edit_timer.o error.o pageelems.o tooltip.o \ vlc.o searchtimers.o edit_searchtimer.o searchresults.o \ searchepg.o login.o ibox.o xmlresponse.o play_recording.o \ diff --git a/pages/menu.ecpp b/pages/menu.ecpp index 1159014..dbcb862 100644 --- a/pages/menu.ecpp +++ b/pages/menu.ecpp @@ -36,6 +36,7 @@ if (!component.empty()) { <div class="menu"> <a href="whats_on.html?type=now" <& menu.setactive current=("whats_on") &>><$ tr("What's on?") $></a> | <a href="schedule.html" <& menu.setactive current=("schedule") &>><$ trVDR("Schedule") $></a> + | <a href="multischedule.html" <& menu.setactive current=("multischedule") &>><$ trVDR("MultiSchedule") $></a> | <a href="timers.html" <& menu.setactive current=("timers") &>><$ trVDR("Timers") $></a> <%cpp> if ( LiveFeatures< features::epgsearch >().Recent() ) { diff --git a/pages/multischedule.ecpp b/pages/multischedule.ecpp new file mode 100644 index 0000000..ab97d9b --- /dev/null +++ b/pages/multischedule.ecpp @@ -0,0 +1,188 @@ +<%pre> +#include <vdr/plugin.h> +#include <vdr/channels.h> +#include <vdr/epg.h> +#include <vdr/config.h> +#include <vdr/device.h> +#include "exception.h" +#include "livefeatures.h" +#include "setup.h" +#include "tools.h" +#include "epg_events.h" +#include "i18n.h" + +using namespace std; +using namespace vdrlive; + +struct SchedEntry { + string title; + string short_description; + string description; + string start; + string end; + string day; + string epgid; + int start_row; + int row_count; +}; + +</%pre> +<%args> + int channel = -1; +</%args> +<%session scope="global"> +bool logged_in(false); +</%session> +<%request scope="page"> + cChannel* Channel; +</%request> +<%include>page_init.eh</%include> +<%cpp> +if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); +</%cpp> +<%cpp> + pageTitle = trVDR("Schedule"); + + cSchedulesLock schedulesLock; + cSchedules const* schedules = cSchedules::Schedules( schedulesLock ); + + ReadLock channelsLock( Channels ); + if ( !channelsLock ) + throw HtmlError( tr("Couldn't aquire access to channels, please try again later.") ); + + // cChannel* Channel; (see %request above) + if ( channel > 0 ) { + Channel = Channels.GetByNumber( channel ); + } + else { + if (cDevice::CurrentChannel()) { + Channel = Channels.GetByNumber(cDevice::CurrentChannel()); + } + else { + Channel = Channels.Get( Channels.GetNextNormal( -1 ) ); + } + } + if ( Channel == 0 ) + throw HtmlError( tr("Couldn't find channel or no channels available. Maybe you mistyped your request?") ); + + cSchedule const* Schedule = schedules->GetSchedule( Channel ); +</%cpp> +<& pageelems.doc_type &> +<html> + <head> + <title>VDR Live - <$ pageTitle $></title> + <& pageelems.stylesheets &> + <& pageelems.ajax_js &> + </head> + <body> + <& pageelems.logo &> + <& menu active=("multischedule") component=("schedule.channel_selection") &> + <div class="inhalt"> +<%cpp> + if ( Schedule == 0 ) { +</%cpp> + <$ tr("No schedules available for this channel") $>. +<%cpp> + } + else { + time_t now = time(NULL) - ::Setup.EPGLinger * 60; + time_t sched_start = 3600 * (now / 3600); // start at a full hour + // tChannelID channel_id(Channel->GetChannelID()); + // int evntNr = 0; +#define MAX_CHANNELS 5 +#define MAX_EVENTS 200 +#define MINUTES_PER_ROW 6 + SchedEntry table[MAX_CHANNELS][MAX_EVENTS]; + int prev_row = -1; + int count = 0; + for (const cEvent *Event = Schedule->Events()->First(); Event && count < MAX_EVENTS; + Event = Schedule->Events()->Next(Event)) { + if (Event->EndTime() <= sched_start ) + continue; + + EpgInfoPtr epgEvent = EpgEvents::CreateEpgInfo(Channel, Event); + SchedEntry &en=table[0][count]; + + en.title = epgEvent->Title(); + en.short_description = epgEvent->ShortDescr(); + en.description = epgEvent->LongDescr(); + en.start = epgEvent->StartTime(tr("%I:%M %p")); + en.end = epgEvent->EndTime(tr("%I:%M %p")); + en.day = epgEvent->StartTime(tr("%A, %b %d %Y")); + en.epgid = EpgEvents::EncodeDomId(Channel->GetChannelID(), Event->EventID()); + // string strEventID = lexical_cast<string>(Event->EventID(); + + en.start_row = prev_row > 0 ? prev_row : 0; + prev_row = en.start_row; + int end_time = Schedule->Events()->Next(Event) ? + Schedule->Events()->Next(Event)->StartTime() : + Event->EndTime(); + int next_event_start_row = (end_time - sched_start) / 60 / MINUTES_PER_ROW; + en.row_count = next_event_start_row - en.start_row; + if ( en.row_count < 2 ) + en.row_count = 2; + prev_row = en.start_row + en.row_count; + count++; + }; +</%cpp> + <table class="listing" cellspacing="0" cellpadding="0"> +<%cpp> + time_t sched_end = sched_start + 60 * 60 * 12; // 12 hr + int sched_end_row = ( sched_end - sched_start ) / 60 / MINUTES_PER_ROW; + int cur_event = 0; + for (int row = 0 ; row < sched_end_row; row++ ) + { + +</%cpp> + <tr class=" topaligned "> + <td> +<%cpp> + if ( (sched_start + row * 60 * MINUTES_PER_ROW ) % 3600 == 0 ) + { +</%cpp> + <$ FormatDateTime( tr("%I:%M %p"), sched_start + row * 60 * MINUTES_PER_ROW ) $> +<%cpp> + } + else + { +</%cpp> + +<%cpp> + } +</%cpp> + </td> +<%cpp> + if ( table[0][cur_event].start_row == row ) + { + SchedEntry &en=table[0][cur_event]; + bool truncated = false; +</%cpp> + <td class="topaligned leftcol rightcol" rowspan="<$ en.row_count $>"> + <div class="more withmargin"><a <& tooltip.hint text=(StringEscapeAndBreak(StringWordTruncate(en.description, 300, truncated)) + "<br />" + tr("Click to view details.")) &>><span class="title"><$ en.title $></span><br /><span class="short"><$ en.short_description.empty() ? " " : en.short_description $></span></a><$ en.start + "-" + en.end $></div></td> +<%cpp> + cur_event++; + } +</%cpp> + </tr> +<%cpp> + } +</%cpp> + </table> +<%cpp> + } +</%cpp> + </div> + </body> +</html> +<%include>page_exit.eh</%include> + +<%def channel_selection> +<form action="multischedule.html" method="get" id="channels"> + <span> + <label for="channel"><$ tr("Channel") $>: <span class="bold"><$ Channel->Number() $></span></label> + <& channels_widget name=("channel") selected=(Channel ? *Channel->GetChannelID().ToString() : "") onchange=("document.forms.channels.submit()") &> + <& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(Channel->GetChannelID()) image="zap.png" alt="" &> + <& pageelems.vlc_stream_channel channelId=(Channel->GetChannelID()) &> + </span> +</form> +</%def> |