diff options
author | Dieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de> | 2010-06-20 18:17:42 +0200 |
---|---|---|
committer | Dieter Hametner <dh (plus) vdr (at) gekrumbel (dot) de> | 2010-06-20 18:17:42 +0200 |
commit | 8edd4eb02751bbf45ab2833102dee3707fbbd499 (patch) | |
tree | cbfbebe9c403d896b1788f8fad124ee4d770002d | |
parent | a5f3edc89393f869bfc6cbcadff5b727562df88a (diff) | |
download | vdr-plugin-live-8edd4eb02751bbf45ab2833102dee3707fbbd499.tar.gz vdr-plugin-live-8edd4eb02751bbf45ab2833102dee3707fbbd499.tar.bz2 |
Reaction to a patch sent by Jan Willies for an other problem withcvs-commit-370
tntnet version string. Jan's patch resolved the immediate problem with
regard to the updated version but was not backwards compatible for older
tntnet version.
My changes to the code adressed that problem and added an enhancement
how to deal with that problem in the future.
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | pages/pageelems.ecpp | 3 | ||||
-rw-r--r-- | pages/recordings.ecpp | 2 | ||||
-rw-r--r-- | pages/recstream.ecpp | 3 | ||||
-rw-r--r-- | pages/vlc.ecpp | 3 | ||||
-rw-r--r-- | setup.cpp | 12 | ||||
-rw-r--r-- | setup.h | 10 | ||||
-rw-r--r-- | thread.cpp | 11 | ||||
-rw-r--r-- | tntconfig.cpp | 12 | ||||
-rw-r--r-- | tntconfig.h | 5 | ||||
-rw-r--r-- | tntfeatures.h | 27 |
11 files changed, 58 insertions, 32 deletions
@@ -48,7 +48,7 @@ TMPDIR ?= /tmp APIVERSION = $(shell sed -ne '/define APIVERSION/s/^.*"\(.*\)".*$$/\1/p' $(VDRDIR)/config.h) I18NTARG = $(shell if [ `echo $(APIVERSION) | tr [.] [0]` -ge "10507" ]; then echo "i18n"; fi) -TNTVERSION = $(shell tntnet-config --version | sed -e's/\.//g' | sed -e's/pre.*//g' | awk '/^..$$/ { print $$1."00"} /^...$$/ { print $$1."0"} /^....$$/ { print $$1 }') +TNTVERSION = $(shell tntnet-config --version | sed -e's/\.//g' | sed -e's/pre.*//g' | awk '/^..$$/ { print $$1."000"} /^...$$/ { print $$1."00"} /^....$$/ { print $$1."0" } /^.....$$/ { print $$1 }') TNTVERS7 = $(shell ver=$(TNTVERSION); if [ $$ver -ge "1606" ]; then echo "yes"; fi) ### The name of the distribution archive: diff --git a/pages/pageelems.ecpp b/pages/pageelems.ecpp index 58a1746..87ca604 100644 --- a/pages/pageelems.ecpp +++ b/pages/pageelems.ecpp @@ -4,6 +4,7 @@ #include <vdr/epg.h> #include "exception.h" #include "livefeatures.h" +#include "tntfeatures.h" #include "i18n.h" #include "setup.h" #include "timers.h" @@ -124,7 +125,7 @@ int update_status(1); string linkText; </%args> <%cpp> -#if TNTVERSION >= 1700 +#if TNT_WATCHDOG_SILENCE { </%cpp><a href="vlc.html?recid=<$ recid $>"><img src="<$ LiveSetup().GetThemedLink("img", "stream_button.png") $>" alt="" <& tooltip.hint text=(tr("Stream this recording into browser.")) &>></img> <$ linkText $></a> <%cpp> diff --git a/pages/recordings.ecpp b/pages/recordings.ecpp index 7b57c11..76bbe65 100644 --- a/pages/recordings.ecpp +++ b/pages/recordings.ecpp @@ -116,7 +116,7 @@ for (iter = recordingsTree->begin(path); iter != end; ++iter) { <li class="recording"> <& rec_item_dir name=(recItem->Name()) level=(level) &> <%cpp> -#if TNTVERSION >= 1606 +#if TNT_HAS_QUERYPARAMS tnt::QueryParams recItemParams(qparam, false); #else cxxtools::QueryParams recItemParams(qparam, false); diff --git a/pages/recstream.ecpp b/pages/recstream.ecpp index 552fb87..015206e 100644 --- a/pages/recstream.ecpp +++ b/pages/recstream.ecpp @@ -6,6 +6,7 @@ #include <tnt/httperror.h> #include <tnt/httpheader.h> #include <vdr/recording.h> +#include "tntfeatures.h" #include "setup.h" #include "recman.h" @@ -58,7 +59,7 @@ if (recording) { if (!reply.out()) { return HTTP_GONE; } -#if TNTVERSION >= 1700 +#if TNT_WATCHDOG_SILENCE request.touch(); // retrigger the watchdog. #endif } diff --git a/pages/vlc.ecpp b/pages/vlc.ecpp index 065969c..d1f1405 100644 --- a/pages/vlc.ecpp +++ b/pages/vlc.ecpp @@ -5,6 +5,7 @@ #include "setup.h" #include "tools.h" #include "users.h" +#include "tntfeatures.h" using namespace std; using namespace vdrlive; @@ -97,7 +98,7 @@ using namespace vdrlive; } </%cpp> <%cpp> -#if TNTVERSION >= 1606 +#if TNT_HAS_GETHOST string server = request.getHost(); server = server.substr(0, server.rfind(':')); #else @@ -23,7 +23,7 @@ using namespace std; Setup::Setup(): m_serverPort( 8008 ), -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT m_serverSslPort( 8443 ), m_serverSslCert(), m_serverSslKey(), @@ -55,7 +55,7 @@ bool Setup::ParseCommandLine( int argc, char* argv[] ) { "ip", required_argument, NULL, 'i' }, { "log", required_argument, NULL, 'l' }, { "epgimages", required_argument, NULL, 'e' }, -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT { "sslport", required_argument, NULL, 's' }, { "cert", required_argument, NULL, 'c' }, { "key", required_argument, NULL, 'k' }, @@ -70,7 +70,7 @@ bool Setup::ParseCommandLine( int argc, char* argv[] ) case 'i': m_serverIps.push_back( optarg ); break; case 'l': m_tntnetloglevel = optarg; break; case 'e': m_epgimagedir = optarg; break; -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT case 's': m_serverSslPort = atoi( optarg ); break; case 'c': m_serverSslCert = optarg; break; case 'k': m_serverSslKey = optarg; break; @@ -80,7 +80,7 @@ bool Setup::ParseCommandLine( int argc, char* argv[] ) } return CheckServerPort() && -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT CheckServerSslPort() && #endif CheckServerIps(); @@ -95,7 +95,7 @@ char const* Setup::CommandLineHelp() const << " -i IP, --ip=IP bind server only to specified IP, may appear\n" " multiple times\n" " (default: 0.0.0.0)\n" -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT << " -s PORT, --sslport=PORT use PORT to listen for incoming ssl connections\n" " (default: " << m_serverSslPort << ")\n" << " -c CERT, --cert=CERT full path to a custom ssl certificate file\n" @@ -143,7 +143,7 @@ bool Setup::CheckServerPort() return true; } -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT bool Setup::CheckServerSslPort() { if ( m_serverSslPort <= 0 || m_serverSslPort > numeric_limits< uint16_t >::max() ) { @@ -6,6 +6,7 @@ #include <numeric> #include <string> #include "live.h" +#include "tntfeatures.h" #include <vdr/menuitems.h> #define LIVEVERSION "0.2.0" @@ -14,9 +15,6 @@ namespace vdrlive { -// SSL-Support works from tntnet version 1.6.1 onwards. -#define TNTSSLSUPPORT TNTVERSION >= 1610 - // forward declaration, see below class cMenuSetupLive; @@ -31,7 +29,7 @@ class Setup // commandline int GetServerPort() const { return m_serverPort; } -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT int GetServerSslPort() const { return m_serverSslPort; } std::string GetServerSslCert() const { return m_serverSslCert; } std::string GetServerSslKey() const { return m_serverSslKey; } @@ -104,7 +102,7 @@ class Setup mutable std::string m_helpString; // commandline options int m_serverPort; -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT int m_serverSslPort; std::string m_serverSslCert; std::string m_serverSslKey; @@ -138,7 +136,7 @@ class Setup bool CheckServerPort(); bool CheckServerIps(); -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT bool CheckServerSslPort(); #endif }; @@ -11,7 +11,7 @@ namespace vdrlive { using namespace std; using namespace tnt; -#if TNTVERSION < 1606 +#if ! TNT_CONFIG_INTERNAL class ProtectedCString { public: @@ -23,7 +23,7 @@ public: private: char* m_string; }; -#endif // TNTVERSION < 1606 +#endif // ! TNT_CONFIG_INTERNAL ServerThread::ServerThread() { @@ -45,11 +45,8 @@ void ServerThread::Stop() void ServerThread::Action() { try { -#if TNTVERSION >= 1606 - // tnt::Tntconfig tntconfig; - // tntconfig.load(TntConfig::Get().GetConfigPath().c_str()); +#if TNT_CONFIG_INTERNAL m_server.reset(new Tntnet()); - //m_server->init(tntconfig); TntConfig::Get().Configure(*m_server); #else ProtectedCString configPath(TntConfig::Get().GetConfigPath().c_str()); @@ -58,7 +55,7 @@ void ServerThread::Action() int argc = sizeof( argv ) / sizeof( argv[0] ); m_server.reset(new Tntnet( argc, argv )); -#endif // TNTVERSION +#endif // TNT_CONFIG_INTERNAL m_server->run(); m_server.reset(0); } catch (exception const& ex) { diff --git a/tntconfig.cpp b/tntconfig.cpp index d35dad4..4f0df22 100644 --- a/tntconfig.cpp +++ b/tntconfig.cpp @@ -20,12 +20,12 @@ namespace vdrlive { TntConfig::TntConfig() { -#if TNTVERSION < 1606 +#if ! TNT_CONFIG_INTERNAL WriteConfig(); #endif } -#if TNTVERSION < 1606 +#if ! TNT_CONFIG_INTERNAL void TntConfig::WriteConfig() { WriteProperties(); @@ -131,7 +131,7 @@ namespace vdrlive { } #endif -#if TNTVERSION < 1606 +#if ! TNT_CONFIG_INTERNAL void TntConfig::WriteProperties() { ostringstream builder; @@ -151,7 +151,7 @@ namespace vdrlive { } #endif -#if TNTVERSION >= 1606 +#if TNT_CONFIG_INTERNAL void TntConfig::Configure(tnt::Tntnet& app) const { string const configDir(Plugin::GetConfigDirectory()); @@ -267,7 +267,7 @@ namespace vdrlive { } } -#if TNTSSLSUPPORT +#if TNT_SSL_SUPPORT int s_port = LiveSetup().GetServerSslPort(); string s_cert = LiveSetup().GetServerSslCert(); string s_key = LiveSetup().GetServerSslKey(); @@ -288,7 +288,7 @@ namespace vdrlive { else { esyslog( "ERROR: Unable to load cert/key (%s/%s): %s", s_cert.c_str(), s_key.c_str(), strerror( errno ) ); } -#endif // TNTSSLSUPPORT +#endif // TNT_SSL_SUPPORT std::istringstream logConf( "rootLogger=" + LiveSetup().GetTntnetLogLevel() + "\n" diff --git a/tntconfig.h b/tntconfig.h index 9c30e44..c02e6a0 100644 --- a/tntconfig.h +++ b/tntconfig.h @@ -3,10 +3,11 @@ #include <string> #include <tnt/tntnet.h> +#include "tntfeatures.h" namespace vdrlive { -#if TNTVERSION >= 1606 +#if TNT_CONFIG_INTERNAL class TntConfig { public: @@ -36,7 +37,7 @@ namespace vdrlive { void WriteProperties(); void WriteConfig(); }; -#endif +#endif // TNT_CONFIG_INTERNAL } // namespace vdrlive diff --git a/tntfeatures.h b/tntfeatures.h new file mode 100644 index 0000000..fb5d9c5 --- /dev/null +++ b/tntfeatures.h @@ -0,0 +1,27 @@ +#ifndef VDR_LIVE_TNTFEATURES_H +#define VDR_LIVE_TNTFEATURES_H + +// This header mapps tntversion strings, whose 'structure' changes over time, +// to features of tntnet used in the live plugin. This avoids scattering the +// version check for TNTVERSION over several source files in live. Thus when +// an other change in the structure of the version string was needed then only +// this file needs to be adapted. + +// SSL-Support works from tntnet version 1.6.1 onwards. +#define TNT_SSL_SUPPORT (TNTVERSION >= 16100) + +// Configuration of tntnet from within the source code and not with a +// dedicated config file. +#define TNT_CONFIG_INTERNAL (TNTVERSION >= 16060) + +// Query params are now in tntnet and not in cxxtools +#define TNT_HAS_QUERYPARAMS (TNTVERSION >= 16060) + +// One can request the host part of the request url +#define TNT_HAS_GETHOST (TNTVERSION >= 16060) + +// new version of TNTNET allow the request watchdog to be silenced. +#define TNT_WATCHDOG_SILENCE (TNTVERSION >= 16900) + + +#endif // VDR_LIVE_TNTFEATURES_H |