diff options
author | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-01-02 19:18:27 +0000 |
---|---|---|
committer | Sascha Volkenandt <sascha (at) akv-soft (dot) de> | 2007-01-02 19:18:27 +0000 |
commit | 48c46dfdd986ad4a7a0692d05992f7882bef6a88 (patch) | |
tree | 88a3a88a7ab43632850569cba3ab48a1924d9e52 /tntconfig.cpp | |
download | vdr-plugin-live-48c46dfdd986ad4a7a0692d05992f7882bef6a88.tar.gz vdr-plugin-live-48c46dfdd986ad4a7a0692d05992f7882bef6a88.tar.bz2 |
- initial checkin
Diffstat (limited to 'tntconfig.cpp')
-rw-r--r-- | tntconfig.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tntconfig.cpp b/tntconfig.cpp new file mode 100644 index 0000000..78e3f45 --- /dev/null +++ b/tntconfig.cpp @@ -0,0 +1,65 @@ +#include <cerrno> +#include <cstring> +#include <fstream> +#include <sstream> +#include <stdexcept> +#include <vdr/plugin.h> +#include "setup.h" +#include "tntconfig.h" + +namespace vdrlive { + +using namespace std; + +TntConfig::TntConfig() +{ + WriteConfig(); +} + +void TntConfig::WriteConfig() +{ + WriteProperties(); + + ostringstream builder; + builder << cPlugin::ConfigDirectory( PLUGIN_NAME_I18N ) << "/httpd.config"; + m_configPath = builder.str(); + + ofstream file( m_configPath.c_str(), ios::out | ios::trunc ); + if ( !file ) { + ostringstream builder; + builder << "Can't open " << m_configPath << " for writing: " << strerror( errno ); + throw runtime_error( builder.str() ); + } + + // XXX modularize + file << "MapUrl /([^.]+)(\\..+)? $1@libtnt-live" << std::endl; + file << "Listen 0.0.0.0 8001" << std::endl; + file << "PropertyFile " << m_propertiesPath << std::endl; + file << "CompPath " << Setup::Get().GetLibraryPath() << "/" << std::endl; +} + +void TntConfig::WriteProperties() +{ + ostringstream builder; + builder << cPlugin::ConfigDirectory( PLUGIN_NAME_I18N ) << "/httpd.properties"; + m_propertiesPath = builder.str(); + + ofstream file( m_propertiesPath.c_str(), ios::out | ios::trunc ); + if ( !file ) { + ostringstream builder; + builder << "Can't open " << m_propertiesPath << " for writing: " << strerror( errno ); + throw runtime_error( builder.str() ); + } + + // XXX modularize + file << "rootLogger=INFO" << std::endl; + file << "logger.tntnet=INFO" << std::endl; +} + +TntConfig const& TntConfig::Get() +{ + static TntConfig instance; + return instance; +} + +} // namespace vdrlive |