From d0ec6ac5a5e8858d423923778fdd5667297f63c2 Mon Sep 17 00:00:00 2001 From: Christian Wieninger Date: Wed, 23 May 2007 17:33:08 +0000 Subject: - show auth part only when enabled - common method Setup::SaveSetup to store setup values from osd and web frontend --- pages/setup.ecpp | 54 ++++++++++++++++++++++++++++++++++-------------------- setup.cpp | 26 ++++++++++++++++---------- setup.h | 5 +++++ 3 files changed, 55 insertions(+), 30 deletions(-) diff --git a/pages/setup.ecpp b/pages/setup.ecpp index e69ef66..012d798 100644 --- a/pages/setup.ecpp +++ b/pages/setup.ecpp @@ -10,7 +10,6 @@ using namespace std; bool useauth = 0; string login; string pass; - int passLength = 0; <%session scope="global"> bool logged_in(false); @@ -23,14 +22,18 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); if ( request.getMethod() == "POST") { LiveSetup().SetLastChannel(lastchannel); LiveSetup().SetUseAuth(useauth); - LiveSetup().SetAdminLogin(login); - LiveSetup().SetAdminPassword(pass); - return reply.redirect("setup.html"); + if (useauth) { + LiveSetup().SetAdminLogin(login); + if (pass != "") + LiveSetup().SetAdminPassword(pass); + } + LiveSetup().SaveSetup(); } pageTitle = tr("Setup"); lastchannel = LiveSetup().GetLastChannel(); login = LiveSetup().GetAdminLogin(); useauth = LiveSetup().UseAuth(); + <& pageelems.doc_type &> @@ -39,8 +42,18 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); <& tooltip.javascript var=("domTT_styleClass") value=("domTTepg") &> <& pageelems.ajax_js &> + - + <& pageelems.logo &> <& menu active=("setup") &>
@@ -48,7 +61,7 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); - + @@ -58,22 +71,23 @@ if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); - - - - - - - - - - - - - + -
<$ tr("Setup") $>
<$ tr("Last channel to display") $>:
<$ tr("Use authentication") $>:/>
<$ tr("Admin login") $>:
<$ tr("Admin password") $>: + onclick="changeduseauth(this)"/> + +
diff --git a/setup.cpp b/setup.cpp index 306d0e8..247b81f 100644 --- a/setup.cpp +++ b/setup.cpp @@ -28,6 +28,7 @@ Setup::Setup(): m_adminLogin("admin") { m_adminPasswordMD5 = "4:" + MD5Hash("live"); + liveplugin = cPluginManager::GetPlugin("live"); } bool Setup::ParseCommandLine( int argc, char* argv[] ) @@ -130,6 +131,19 @@ std::string Setup::SetAdminPassword(std::string password) return m_adminPasswordMD5; } +bool Setup::SaveSetup() +{ + if (!liveplugin) return false; + liveplugin->SetupStore("LastChannel", m_lastChannel); + liveplugin->SetupStore("UseAuth", m_useAuth); + if (m_useAuth) + { + liveplugin->SetupStore("AdminLogin", m_adminLogin.c_str()); + liveplugin->SetupStore("AdminPasswordMD5", m_adminPasswordMD5.c_str()); + } + return true; +} + Setup& LiveSetup() { static Setup instance; @@ -168,19 +182,11 @@ void cMenuSetupLive::Set(void) 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); - if (m_oldpasswordMD5 != m_newpasswordMD5) // only save the password if needed - { - std::string passwordMD5 = vdrlive::LiveSetup().SetAdminPassword(m_adminPassword); - SetupStore("AdminPasswordMD5", passwordMD5.c_str()); - } + vdrlive::LiveSetup().SetAdminPassword(m_adminPassword); + LiveSetup().SaveSetup(); } bool cMenuSetupLive::InEditMode(const char* ItemText, const char* ItemName, const char* ItemValue) diff --git a/setup.h b/setup.h index 40a6ed3..85b19c0 100644 --- a/setup.h +++ b/setup.h @@ -39,6 +39,8 @@ public: void SetUseAuth(int auth) { m_useAuth = auth; } void SetScrenshotInterval(int interval) { m_screenshotInterval = interval; } + bool SaveSetup(); + bool ParseCommandLine( int argc, char* argv[] ); char const* CommandLineHelp() const; @@ -48,6 +50,9 @@ private: Setup(); Setup( Setup const& ); + // me + cPlugin* liveplugin; + mutable std::string m_helpString; // commandline options int m_serverPort; -- cgit v1.2.3