From 3a4d59c9ac7226432120633ad394464d37e5f497 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Fri, 25 May 2007 16:58:56 +0000 Subject: - first version of "userdef. times" in "What's on?" --- i18n.cpp | 22 ++++++++++++++++++++++ pages/setup.ecpp | 11 ++++++++++- pages/whats_on.ecpp | 50 ++++++++++++++++++++++++++++++++++++++++++++------ setup.cpp | 2 ++ setup.h | 3 +++ tools.cpp | 15 +++++++++++++++ tools.h | 1 + 7 files changed, 97 insertions(+), 7 deletions(-) diff --git a/i18n.cpp b/i18n.cpp index 2ca0b68..8400d6c 100644 --- a/i18n.cpp +++ b/i18n.cpp @@ -3483,6 +3483,28 @@ const tI18nPhrase Phrases[] = { "", // Dansk "", // Czech }, + { "additional fixed times in 'What's on?'", + "zusätzliche Zeitpunkte in 'Was läuft?'", + "", // Slovenski + "", // Italiono + "", // Nederlands + "", // Português + "", // Français + "", // Norsk + "", // Finnish + "", // Polski + "", // Español + "", // Greek + "", // Svenska + "", // Românã + "", // Magyar + "", // Català + "", // Russian + "", // Hrvatski + "", // Eesti + "", // Dansk + "", // Czech + }, /* { "", // English "", // Deutsch diff --git a/pages/setup.ecpp b/pages/setup.ecpp index 012d798..97fc199 100644 --- a/pages/setup.ecpp +++ b/pages/setup.ecpp @@ -10,6 +10,7 @@ using namespace std; bool useauth = 0; string login; string pass; + string times; <%session scope="global"> bool logged_in(false); @@ -27,12 +28,14 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); if (pass != "") LiveSetup().SetAdminPassword(pass); } - LiveSetup().SaveSetup(); + LiveSetup().SetTimes(times); + LiveSetup().SaveSetup(); } pageTitle = tr("Setup"); lastchannel = LiveSetup().GetLastChannel(); login = LiveSetup().GetAdminLogin(); useauth = LiveSetup().UseAuth(); + times = LiveSetup().GetTimes(); <& pageelems.doc_type &> @@ -88,6 +91,12 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); + + + <$ tr("additional fixed times in 'What's on?'") $>: + + + diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index bab6a57..ed7ff99 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -14,6 +14,8 @@ using namespace vdrlive; <%args> type = "now"; +string attime; +time_t seektime = 0; <%session scope="global"> bool logged_in(false); @@ -29,9 +31,13 @@ const cSchedules* Schedules = cSchedules::Schedules(schedulesLock); string head; if (type == "now") { head = tr("What's running at")+string(" ")+FormatDateTime(tr("%I:%M %p"), time(0)); -} else { - type="next"; +} else if (type == "next") { head = tr("What's on next?"); +} else if (type == "at") { + seektime = GetTimeT(attime); + if (seektime - time(0) + 3600 < 0) + seektime += 24 * 60 * 60; + head = tr("What's running at")+string(" ")+FormatDateTime(tr("%a, %b %d"), seektime) + string(" ") + FormatDateTime(tr("%I:%M %p"), seektime); } }> @@ -42,6 +48,13 @@ if (type == "now") { <& tooltip.javascript var=("domTT_styleClass") value=("domTTepg") &> <& pageelems.ajax_js &> + <& pageelems.logo &> @@ -49,15 +62,28 @@ if (type == "now") {
<{ EpgEvents epgEvents; - + time_t seektime = 0; + if (type == "at") + { + seektime = GetTimeT(attime); + if (seektime - time(0) + 3600 < 0) + seektime += 24 * 60 * 60; + } ReadLock channelsLock( Channels ); if (channelsLock) { int evntNr = 0; for (cChannel *Channel = Channels.First(); Channel && Channel->Number() <= LiveSetup().GetLastChannel(); Channel = Channels.Next(Channel)) { if (!Channel->GroupSep()) { const cSchedule *Schedule = Schedules->GetSchedule(Channel); - if (Schedule) { - const cEvent *Event = (type == "now" ? Schedule->GetPresentEvent() : Schedule->GetFollowingEvent()); + if (Schedule) { + const cEvent *Event = NULL; + if (type == "now") + Event = Schedule->GetPresentEvent(); + else if (type == "next") + Event = Schedule->GetFollowingEvent(); + else if (type == "at") + Event = Schedule->GetEventAround(seektime); + if (Event) { string evntId("eventId_"); evntId += lexical_cast(++evntNr); @@ -121,5 +147,17 @@ if (type == "now") { <%def whats_on_actions> <$ tr("Now") $>   -<$ tr("Next") $> +<$ tr("Next") $>   + diff --git a/setup.cpp b/setup.cpp index 247b81f..0b5a5c8 100644 --- a/setup.cpp +++ b/setup.cpp @@ -73,6 +73,7 @@ bool Setup::ParseSetupEntry( char const* name, char const* value ) else if ( strcmp( name, "UseAuth" ) == 0 ) m_useAuth = atoi( value ); else if ( strcmp( name, "AdminLogin" ) == 0 ) m_adminLogin = value; else if ( strcmp( name, "AdminPasswordMD5" ) == 0 ) m_adminPasswordMD5 = value; + else if ( strcmp( name, "UserdefTimes" ) == 0 ) m_times = value; else return false; return true; } @@ -141,6 +142,7 @@ bool Setup::SaveSetup() liveplugin->SetupStore("AdminLogin", m_adminLogin.c_str()); liveplugin->SetupStore("AdminPasswordMD5", m_adminPasswordMD5.c_str()); } + liveplugin->SetupStore("UserdefTimes", m_times.c_str()); return true; } diff --git a/setup.h b/setup.h index 85b19c0..e9e2aaa 100644 --- a/setup.h +++ b/setup.h @@ -32,12 +32,14 @@ public: std::string GetMD5HashAdminPassword() const; int GetAdminPasswordLength() const; bool UseAuth() const { return m_useAuth; } + std::string GetTimes() const { return m_times; } void SetLastChannel(int lastChannel) { m_lastChannel = lastChannel; } void SetAdminLogin(std::string login) { m_adminLogin = login; } std::string SetAdminPassword(std::string password); void SetUseAuth(int auth) { m_useAuth = auth; } void SetScrenshotInterval(int interval) { m_screenshotInterval = interval; } + void SetTimes(std::string times) { m_times = times; } bool SaveSetup(); @@ -64,6 +66,7 @@ private: int m_useAuth; std::string m_adminLogin; std::string m_adminPasswordMD5; + std::string m_times; bool CheckServerPort(); bool CheckServerIps(); diff --git a/tools.cpp b/tools.cpp index da3956f..a75068f 100644 --- a/tools.cpp +++ b/tools.cpp @@ -144,4 +144,19 @@ std::string MD5Hash(std::string const& str) return hashStr.str(); } +#define HOURS(x) ((x)/100) +#define MINUTES(x) ((x)%100) + +time_t GetTimeT(std::string timestring) // timestring in HH:MM +{ + timestring = StringReplace(timestring, ":", ""); + int iTime = lexical_cast< int >( timestring ); + struct tm tm_r; + time_t t = time(NULL); + tm* tmnow = localtime_r(&t, &tm_r); + tmnow->tm_hour = HOURS(iTime); + tmnow->tm_min = MINUTES(iTime); + return mktime(tmnow); +} + } // namespace vdrlive diff --git a/tools.h b/tools.h index 1576377..525df7d 100644 --- a/tools.h +++ b/tools.h @@ -32,6 +32,7 @@ std::string StringFormatBreak(std::string const& input); std::string StringTrim(const std::string& str); std::string ZeroPad(int number); std::string MD5Hash(std::string const& str); +time_t GetTimeT(std::string timestring); struct bad_lexical_cast: std::runtime_error { -- cgit v1.2.3