diff options
-rw-r--r-- | live.cpp | 4 | ||||
-rw-r--r-- | setup.cpp | 45 | ||||
-rw-r--r-- | setup.h | 34 |
3 files changed, 80 insertions, 3 deletions
@@ -3,7 +3,7 @@ * * See the README file for copyright information and how to reach the author. * - * $Id: live.cpp,v 1.13 2007/01/18 18:29:30 lordjaxom Exp $ + * $Id: live.cpp,v 1.14 2007/04/26 16:17:36 thomas Exp $ */ #include <vdr/plugin.h> @@ -69,7 +69,7 @@ cString Plugin::Active(void) cMenuSetupPage *Plugin::SetupMenu(void) { - return NULL; + return new cMenuSetupLive(); } bool Plugin::SetupParse(const char *Name, const char *Value) @@ -8,8 +8,10 @@ #include <getopt.h> #include <stdint.h> #include <unistd.h> +#include <string> #include <arpa/inet.h> #include <vdr/tools.h> +#include <vdr/menuitems.h> #include "setup.h" namespace vdrlive { @@ -19,7 +21,10 @@ using namespace std; Setup::Setup(): m_serverPort( 8001 ), m_lastChannel( 0 ), - m_screenshotInterval( 1000 ) + m_screenshotInterval( 1000 ), + m_useAuth( 1 ), + m_adminLogin("admin"), + m_adminPassword("live") { } @@ -62,6 +67,9 @@ bool Setup::ParseSetupEntry( char const* name, char const* value ) { if ( strcmp( name, "LastChannel" ) == 0 ) m_lastChannel = atoi( value ); else if ( strcmp( name, "ScreenshotInterval" ) == 0 ) m_screenshotInterval = atoi( value ); + else if ( strcmp( name, "UseAuth" ) == 0 ) m_useAuth = atoi( value ); + else if ( strcmp( name, "AdminLogin" ) == 0 ) m_adminLogin = value; + else if ( strcmp( name, "AdminPassword" ) == 0 ) m_adminPassword = value; else return false; return true; } @@ -100,3 +108,38 @@ Setup& LiveSetup() } } // namespace vdrlive + +cMenuSetupLive::cMenuSetupLive(): + cMenuSetupPage() +{ + m_lastChannel = vdrlive::LiveSetup().GetLastChannel(); + m_useAuth = vdrlive::LiveSetup().UseAuth(); + strcpy(m_adminLogin, vdrlive::LiveSetup().GetAdminLogin().c_str()); + strcpy(m_adminPassword, vdrlive::LiveSetup().GetAdminPassword().c_str()); + + Clear(); + //Add(new cMenuEditIntItem(tr("Last channel to display"), &m_lastChannel, 0, 65536)); + Add(new cMenuEditChanItem(tr("Last channel to display"), &m_lastChannel, tr("No limit"))); + //Add(new cMenuEditIntItem(tr("Screenshot interval"), &m_lastChannel, 0, 65536)); + Add(new cMenuEditBoolItem(tr("Use authentication"), &m_useAuth, tr("No"), tr("Yes"))); + Add(new cMenuEditStrItem( tr("Admin login"), m_adminLogin, 12, tr(FileNameChars))); + Add(new cMenuEditStrItem( tr("Admin password"), m_adminPassword, 12, tr(FileNameChars))); + Display(); +} + +void cMenuSetupLive::Store(void) +{ + vdrlive::LiveSetup().SetLastChannel(m_lastChannel); + SetupStore("LastChannel", m_lastChannel); + + vdrlive::LiveSetup().SetUseAuth(m_useAuth); + SetupStore("UseAuth", m_useAuth); + + vdrlive::LiveSetup().SetAdminLogin(m_adminLogin); + SetupStore("AdminLogin", m_adminLogin); + + vdrlive::LiveSetup().SetAdminPassword(m_adminPassword); + SetupStore("AdminPassword", m_adminPassword); +} + + @@ -5,12 +5,14 @@ #include <numeric> #include <string> #include "live.h" +#include <vdr/menuitems.h> namespace vdrlive { class Setup { friend Setup& LiveSetup(); + friend class cMenuSetupLive; public: typedef std::list< std::string > IpList; @@ -21,6 +23,15 @@ public: // vdr-setup int GetLastChannel() const { return m_lastChannel == 0 ? std::numeric_limits< int >::max() : m_lastChannel; } int GetScreenshotInterval() const { return m_screenshotInterval; } + std::string GetAdminLogin() const { return m_adminLogin; } + std::string GetAdminPassword() const { return m_adminPassword; } + bool UseAuth() const { return m_useAuth; } + + void SetLastChannel(int lastChannel) { m_lastChannel = lastChannel; } + void SetAdminLogin(std::string login) { m_adminLogin = login; } + void SetAdminPassword(std::string password) { m_adminPassword = password; } + void SetUseAuth(int auth) { m_useAuth = auth; } + void SetScrenshotInterval(int interval) { m_screenshotInterval = interval; } bool ParseCommandLine( int argc, char* argv[] ); char const* CommandLineHelp() const; @@ -38,6 +49,10 @@ private: // setup options int m_lastChannel; int m_screenshotInterval; + + int m_useAuth; + std::string m_adminLogin; + std::string m_adminPassword; bool CheckServerPort(); bool CheckServerIps(); @@ -47,4 +62,23 @@ Setup& LiveSetup(); } // namespace vdrlive +class cMenuSetupLive : public cMenuSetupPage { + +protected: + virtual void Store(void); +// virtual eOSState ProcessKey(eKeys Key); + +public: + cMenuSetupLive(); + +private: + int m_lastChannel; + int m_screenshotInterval; + + int m_useAuth; + char m_adminLogin[20]; + char m_adminPassword[20]; +}; + + #endif // VDR_LIVE_SETUP_H |