From 015380b9fd9f4e3b34edc83d2ee57db1aa809c34 Mon Sep 17 00:00:00 2001 From: martin Date: Sat, 15 Jan 2011 16:59:59 +0100 Subject: - make MultiSchedule duration configurable - by default show the channel group containing the current channel - show "switch to this channel"-buttons --- pages/multischedule.ecpp | 47 +++++++++++++++++++++++++++++++++++++++++++---- pages/setup.ecpp | 9 +++++++++ setup.cpp | 6 ++++++ setup.h | 3 +++ 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/pages/multischedule.ecpp b/pages/multischedule.ecpp index f3188f0..4ae0c7e 100644 --- a/pages/multischedule.ecpp +++ b/pages/multischedule.ecpp @@ -37,7 +37,7 @@ struct SchedEntry { std::vector times_start; <%args> - unsigned int channel = 0; + int channel = -1; unsigned int time_para = 0; <%session scope="global"> @@ -136,6 +136,29 @@ pageTitle = trVDR("Schedule"); } } } + if ( channel < 0 ) { + if (cDevice::CurrentChannel()) { + // find group corresponding to current channel + int curGroup =0; + int curChannel = cDevice::CurrentChannel(); + for ( std::vector< std::vector >::iterator grIt = channel_groups_numbers.begin(); + grIt != channel_groups_numbers.end() && channel < 0; ++grIt, ++curGroup ) + { + for ( std::vector::iterator chIt = (*grIt).begin(); + chIt != (*grIt).end() && channel < 0; ++ chIt ) + { + if ( *chIt == curChannel ) + channel_group = channel = curGroup; + } + } + // if nothing is found, fall back to group 0 + if ( channel < 0 ) + channel = 0; + } + else { + channel_group = channel; + } + } if ( channel >= channel_groups_numbers.size() ) channel = 0; @@ -172,7 +195,6 @@ pageTitle = trVDR("Schedule"); { times_names.push_back(FormatDateTime( tr("%A, %x"), midnight + MAX_HOURS*3600*i) +std::string(" ")+ FormatDateTime( tr("%I:%M %p"), midnight + MAX_HOURS*3600*i) ); - //times_names.push_back("today 0:00"); times_start.push_back( midnight + MAX_HOURS*3600*i ); } if ( time_para >= times_names.size() ) @@ -199,10 +221,23 @@ pageTitle = trVDR("Schedule"); if ( time_para >= times_start.size() ) time_para = times_start.size()-1; time_t sched_start = times_start[ time_para ]; - time_t sched_end = sched_start + 60 * 60 * MAX_HOURS; + time_t max_hours; + try { + max_hours = lexical_cast( LiveSetup().GetScheduleDuration() ); + } + catch ( const bad_lexical_cast & ) + { + esyslog("Live: could not convert '%s' into a schedule duration", LiveSetup().GetScheduleDuration().c_str()); + max_hours = 8; + }; + if (max_hours > 48) + max_hours = 48; + + time_t sched_end = sched_start + 60 * 60 * max_hours; int sched_end_row = ( sched_end - sched_start ) / 60 / MINUTES_PER_ROW; std::list table[MAX_CHANNELS]; std::vector channel_names(channel_groups_numbers[ channel ].size() ); + std::vector channel_IDs(channel_groups_numbers[ channel ].size() ); if ( channel >= channel_groups_numbers.size() ) channel = channel_groups_numbers.size()-1; //for ( int chan = 0; chanGroupSep() || Channel->Name() == '\0' ) continue; channel_names[ j ] = Channel->Name(); + channel_IDs[ j ] = Channel->GetChannelID(); cSchedule const* Schedule = schedules->GetSchedule( Channel ); if ( ! Schedule ) @@ -299,7 +335,10 @@ pageTitle = trVDR("Schedule"); for ( unsigned int channel = 0; channel< channel_names.size() ; channel++) { -
<$ StringEscapeAndBreak(channel_names[channel]) $>
+
<$ StringEscapeAndBreak(channel_names[channel]) $> + <& pageelems.ajax_action_href action="switch_channel" tip=(tr("Switch to this channel.")) param=(channel_IDs[channel]) image="zap.png" alt="" &> + <& pageelems.vlc_stream_channel channelId=(channel_IDs[channel]) &> +
  <%cpp> } diff --git a/pages/setup.ecpp b/pages/setup.ecpp index c1d328f..d5d4f2a 100644 --- a/pages/setup.ecpp +++ b/pages/setup.ecpp @@ -17,6 +17,7 @@ using namespace std; string pass; string times; string channelGroups; + string scheduleDuration; string startscreen; string theme; string localnetmask; @@ -60,6 +61,7 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) } LiveSetup().SetTimes(times); LiveSetup().SetChannelGroups(channelGroups); + LiveSetup().SetScheduleDuration(scheduleDuration); LiveSetup().SetStartScreen(startscreen); LiveSetup().SetTheme(theme); LiveSetup().SetShowLogo(!showLogo.empty()); @@ -88,6 +90,7 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) useauth = LiveSetup().GetUseAuth(); times = LiveSetup().GetTimes(); channelGroups = LiveSetup().GetChannelGroups(); + scheduleDuration = LiveSetup().GetScheduleDuration(); startscreen = LiveSetup().GetStartScreen(); theme = LiveSetup().GetTheme(); localnetmask = LiveSetup().GetLocalNetMask(); @@ -234,6 +237,11 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) <& tooltip.help text=(tr("Separate channels with a comma ',', separate groups with a semi-colon ';'")) &> + +
<$ tr("Duration of MultiSchedule in hours") $>:
+ + +
<$ tr("Show channels without EPG") $>:
@@ -247,6 +255,7 @@ if (!cUser::CurrentUserHasRightTo(UR_EDITSETUP)) + diff --git a/setup.cpp b/setup.cpp index 9517027..5737378 100644 --- a/setup.cpp +++ b/setup.cpp @@ -36,6 +36,8 @@ Setup::Setup(): m_screenshotInterval( 1000 ), m_useAuth( 1 ), m_adminLogin("admin"), + m_channelGroups( "" ), + m_scheduleDuration( "8" ), m_theme("marine"), m_lastwhatsonlistmode("detail"), m_tntnetloglevel("WARN"), @@ -121,6 +123,7 @@ bool Setup::ParseSetupEntry( char const* name, char const* value ) else if ( strcmp( name, "AdminPasswordMD5" ) == 0 ) m_adminPasswordMD5 = value; else if ( strcmp( name, "UserdefTimes" ) == 0 ) m_times = value; else if ( strcmp( name, "ChannelGroups" ) == 0 ) m_channelGroups = value; + else if ( strcmp( name, "ScheduleDuration" ) == 0 ) m_scheduleDuration = value; else if ( strcmp( name, "StartPage" ) == 0 ) m_startscreen = value; else if ( strcmp( name, "Theme" ) == 0 ) m_theme = value; else if ( strcmp( name, "LocalNetMask" ) == 0 ) { m_localnetmask = value; } @@ -224,6 +227,8 @@ std::string const Setup::GetStartScreenLink() const return "whats_on.html?type=next"; else if (m_startscreen == "schedule") return "schedule.html"; + else if (m_startscreen == "multischedule") + return "multischedule.html"; else if (m_startscreen == "timers") return "timers.html"; else if (m_startscreen == "recordings") @@ -286,6 +291,7 @@ bool Setup::SaveSetup() } liveplugin->SetupStore("UserdefTimes", m_times.c_str()); liveplugin->SetupStore("ChannelGroups", m_channelGroups.c_str()); + liveplugin->SetupStore("ScheduleDuration", m_scheduleDuration.c_str()); liveplugin->SetupStore("StartPage", m_startscreen.c_str()); liveplugin->SetupStore("Theme", m_theme.c_str()); liveplugin->SetupStore("LastWhatsOnListMode", m_lastwhatsonlistmode.c_str()); diff --git a/setup.h b/setup.h index a700276..a22051e 100644 --- a/setup.h +++ b/setup.h @@ -45,6 +45,7 @@ class Setup bool UseAuth() const; std::string const GetTimes() const { return m_times; } std::string const GetChannelGroups() const { return m_channelGroups; } + std::string const GetScheduleDuration() const { return m_scheduleDuration; } std::string const GetStartScreen() const { return m_startscreen; } std::string const GetStartScreenLink() const; std::string const GetTheme() const { return m_theme; } @@ -70,6 +71,7 @@ class Setup void SetScreenshotInterval(int interval) { m_screenshotInterval = interval; } void SetTimes(std::string const & times) { m_times = times; } void SetChannelGroups(std::string const & channelGroups) { m_channelGroups = channelGroups; } + void SetScheduleDuration(std::string const & scheduleDuration) { m_scheduleDuration = scheduleDuration; } void SetStartScreen(std::string const & startscreen) { m_startscreen = startscreen; } void SetTheme(std::string const & theme) { m_theme = theme; } void SetLocalNetMask(std::string const & localnetmask) { m_localnetmask = localnetmask; } @@ -122,6 +124,7 @@ class Setup std::string m_adminPasswordMD5; std::string m_times; std::string m_channelGroups; + std::string m_scheduleDuration; std::string m_startscreen; std::string m_theme; std::string m_localnetmask; -- cgit v1.2.3