From 4fb0ce9c0662a7b7c3bce712577743e2a56444c0 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Fri, 20 Jul 2007 16:06:51 +0000 Subject: - Added support for EPG images: Specify the directory with your EPG images via the new commandline option '-e ' or '--epgimages= like -P'live -e /video/epgimages' --- doc/ChangeLog | 6 ++++++ epg_events.cpp | 27 +++++++++++++++++++++++++++ epg_events.h | 3 +++ pages/content.ecpp | 9 ++++++++- pages/pageelems.ecpp | 27 +++++++++++---------------- setup.cpp | 17 ++++++++++------- setup.h | 3 +++ tntconfig.cpp | 3 +++ 8 files changed, 71 insertions(+), 24 deletions(-) diff --git a/doc/ChangeLog b/doc/ChangeLog index 1eb4787..ade99b5 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -1,3 +1,9 @@ +2007-07-20 Christian Wieninger + Added support for EPG images: Specify the directory with your + EPG images via the new commandline option '-e ' or + '--epgimages= like + -P'live -e /video/epgimages' + 2007-07-12 Dieter Hametner Changed the javascript base of live. We now use the 'mootools' diff --git a/epg_events.cpp b/epg_events.cpp index 049e27f..89c1347 100644 --- a/epg_events.cpp +++ b/epg_events.cpp @@ -1,9 +1,11 @@ #include +#include #include "tools.h" #include "recordings.h" #include "epg_events.h" +#include "setup.h" using namespace std; @@ -275,4 +277,29 @@ namespace vdrlive { return EpgInfoPtr(new EpgString(id, caption, info)); } + + list EpgEvents::EpgImages(const std::string& epgid) + { + list images; + + size_t delimPos = epgid.find_last_of('_'); + string imageId = epgid.substr(delimPos+1); + imageId = imageId.substr(0, imageId.size()-1); // tvm2vdr seems always to use one digit less + + const string filemask(LiveSetup().GetEpgImageDir() + "/" + imageId + "*.*"); + glob_t globbuf; + globbuf.gl_offs = 0; + if (!LiveSetup().GetEpgImageDir().empty() && glob(filemask.c_str(), GLOB_DOOFFS, NULL, &globbuf) == 0) + { + for(int i=0; i<(int)globbuf.gl_pathc; i++) + { + const string imagefile(globbuf.gl_pathv[i]); + size_t delimPos = imagefile.find_last_of('/'); + images.push_back(imagefile.substr(delimPos+1)); + } + globfree(&globbuf); + } + return images; + } + }; // namespace vdrlive diff --git a/epg_events.h b/epg_events.h index 8536463..f055045 100644 --- a/epg_events.h +++ b/epg_events.h @@ -2,6 +2,7 @@ #define VDR_LIVE_WHATS_ON_H #include +#include #include #include @@ -179,6 +180,8 @@ namespace vdrlive * passed string informations */ static EpgInfoPtr CreateEpgInfo(const std::string& id, const std::string& caption, const std::string& info); + + static std::list EpgImages(const std::string& epgid); private: }; }; // namespace vdrlive diff --git a/pages/content.ecpp b/pages/content.ecpp index 1438790..f95dd4c 100644 --- a/pages/content.ecpp +++ b/pages/content.ecpp @@ -26,8 +26,15 @@ reply.setContentType(mime); // FileCache::ptr_type f = LiveFileCache().get("/tmp/live/" + request.getPathInfo()); string path(request.getPathInfo()); -FileCache::ptr_type f = LiveFileCache().get(Plugin::GetConfigDirectory() + "/" + path); +FileCache::ptr_type f; + +if (path.find(LiveSetup().GetEpgImageDir()) != 0) + f = LiveFileCache().get(Plugin::GetConfigDirectory() + "/" + path); +else + f = LiveFileCache().get(path); + if (f.get() == 0) { +cout << "declined" << endl; return DECLINED; } string ctime = tnt::HttpMessage::htdate(f->ctime()); diff --git a/pages/pageelems.ecpp b/pages/pageelems.ecpp index 6de3bfc..1116d51 100644 --- a/pages/pageelems.ecpp +++ b/pages/pageelems.ecpp @@ -8,6 +8,7 @@ #include "setup.h" #include "timers.h" #include "tools.h" +#include "epg_events.h" using namespace std; using namespace vdrlive; @@ -34,25 +35,12 @@ int update_status(1); <# ---------------------------------------------------------------------- #> <%def logo> -<%cpp> - if (LiveSetup().GetShowLogo() - || (LiveSetup().GetUseAjax() && LiveSetup().GetShowInfoBox())) { -
-<%cpp> - } - <# ---------------------------------------------------------------------- #> @@ -136,7 +124,6 @@ int update_status(1); <# ---------------------------------------------------------------------- #> <%def ajax_js> -<%cpp>if (LiveSetup().GetUseAjax()) { @@ -153,7 +140,6 @@ int update_status(1); }); --> <%cpp> } -<%cpp> } <# ---------------------------------------------------------------------- #> @@ -202,6 +188,15 @@ int update_status(1);
<%cpp> reply.out() << StringEscapeAndBreak(long_descr);
+
+
+<%cpp> list images = EpgEvents::EpgImages(boxId); + for(std::list::iterator it = images.begin(); it != images.end(); ++it ) { + + +<%cpp> } + +
diff --git a/setup.cpp b/setup.cpp index 930a111..5565ddd 100644 --- a/setup.cpp +++ b/setup.cpp @@ -44,15 +44,17 @@ bool Setup::ParseCommandLine( int argc, char* argv[] ) { "port", required_argument, NULL, 'p' }, { "ip", required_argument, NULL, 'i' }, { "log", required_argument, NULL, 'l' }, + { "epgimages", required_argument, NULL, 'e' }, { 0 } }; int optchar, optind = 0; - while ( ( optchar = getopt_long( argc, argv, "p:i:l:", opts, &optind ) ) != -1 ) { + while ( ( optchar = getopt_long( argc, argv, "p:i:l:e:", opts, &optind ) ) != -1 ) { switch ( optchar ) { case 'p': m_serverPort = atoi( optarg ); break; case 'i': m_serverIps.push_back( optarg ); break; case 'l': m_tntnetloglevel = optarg; break; + case 'e': m_epgimagedir = optarg; break; default: return false; } } @@ -65,12 +67,13 @@ char const* Setup::CommandLineHelp() const { if ( m_helpString.empty() ) { ostringstream builder; - builder << " -p PORT, --port=PORT use PORT to listen for incoming connections\n" - " (default: " << m_serverPort << ")\n" - << " -i IP, --ip=IP bind server only to specified IP, may appear\n" - " multiple times\n" - " (default: 0.0.0.0)\n" - << " -l level, --log=level log level for tntnet (values: INFO, DEBUG,...)\n"; + builder << " -p PORT, --port=PORT use PORT to listen for incoming connections\n" + " (default: " << m_serverPort << ")\n" + << " -i IP, --ip=IP bind server only to specified IP, may appear\n" + " multiple times\n" + " (default: 0.0.0.0)\n" + << " -l level, --log=level log level for tntnet (values: INFO, DEBUG,...)\n" + << " -e , --epgimages= directory for epgimages\n"; m_helpString = builder.str(); } return m_helpString.c_str(); diff --git a/setup.h b/setup.h index 2ac7f06..73d825c 100644 --- a/setup.h +++ b/setup.h @@ -48,6 +48,7 @@ class Setup bool GetShowLogo() const { return m_showLogo != 0; } bool GetUseAjax() const { return m_useAjax != 0; } bool GetShowInfoBox() const { return m_showInfoBox != 0; } + std::string GetEpgImageDir() { return m_epgimagedir; } void SetLastChannel(int lastChannel) { m_lastChannel = lastChannel; } void SetAdminLogin(std::string login) { m_adminLogin = login; } @@ -85,6 +86,8 @@ class Setup // commandline options int m_serverPort; IpList m_serverIps; + std::string m_epgimagedir; + // setup options int m_lastChannel; int m_screenshotInterval; diff --git a/tntconfig.cpp b/tntconfig.cpp index 1094b8a..286ada7 100644 --- a/tntconfig.cpp +++ b/tntconfig.cpp @@ -49,6 +49,9 @@ void TntConfig::WriteConfig() file << "MapUrl ^/themes/([^/]*)/img.*/(.+)\\.(.+) content@ common/img/$2.$3 image/$3" << endl; file << "MapUrl ^/themes/([^/]*)/img.*/(.+)\\.(.+) $2@" << endl; + // Epg images + file << "MapUrl ^/epgimages/(.*)\\.(.+) content@ " << LiveSetup().GetEpgImageDir() << "/$1.$2 image/$2" << endl; + // select additional (not build in) javascript. file << "MapUrl ^/js([^.]*/)(.*\\.js) content@ js$1$2 text/javascript" << endl; -- cgit v1.2.3