Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes #10305. Remove mysql.txt support.

  • Loading branch information...
commit 3fb9d6eb779e08d91df8a849a5be38e219c34bed 1 parent fe11b61
@daniel-kristjansson daniel-kristjansson authored
Showing with 376 additions and 433 deletions.
  1. +3 −3 mythtv/bindings/perl/MythTV.pm
  2. +2 −2 mythtv/bindings/php/MythBackend.php
  3. +2 −2 mythtv/bindings/python/MythTV/static.py
  4. +1 −1  mythtv/docs/doxygen-architecture-document.cpp
  5. +5 −3 mythtv/libs/libmyth/backendselect.h
  6. +0 −2  mythtv/libs/libmyth/langsettings.cpp
  7. +112 −93 mythtv/libs/libmyth/mythcontext.cpp
  8. +1 −1  mythtv/libs/libmythbase/libmythbase.pro
  9. +8 −8 mythtv/libs/libmythbase/mythcorecontext.cpp
  10. +1 −2  mythtv/libs/libmythbase/mythcorecontext.h
  11. +69 −228 mythtv/libs/libmythbase/mythdb.cpp
  12. +3 −11 mythtv/libs/libmythbase/mythdb.h
  13. +78 −0 mythtv/libs/libmythbase/mythdbparams.cpp
  14. +15 −1 mythtv/libs/libmythbase/mythdbparams.h
  15. +0 −6 mythtv/libs/libmythbase/mythlocale.cpp
  16. +0 −1  mythtv/libs/libmythbase/mythtranslation.cpp
  17. +3 −3 mythtv/libs/libmythbase/mythversion.h
  18. +0 −1  mythtv/libs/libmythmetadata/parentalcontrols.cpp
  19. +0 −2  mythtv/libs/libmythui/myththemedmenu.cpp
  20. +65 −9 mythtv/libs/libmythupnp/configuration.cpp
  21. +3 −3 mythtv/libs/libmythupnp/configuration.h
  22. +2 −47 mythtv/programs/mythbackend/mythsettings.cpp
  23. +0 −1  mythtv/programs/mythbackend/mythsettings.h
  24. +1 −1  mythtv/programs/mythtv-setup/main.cpp
  25. +2 −2 mythtv/programs/mythtv-setup/startprompt.cpp
View
6 mythtv/bindings/perl/MythTV.pm
@@ -8,7 +8,7 @@
#
# Version
- $VERSION = '.25svn';
+ $VERSION = '.26git';
# Load sub libraries
use IO::Socket::INET::MythTV;
@@ -106,8 +106,8 @@ package MythTV;
# Note: as of July 21, 2010, this is actually a string, to account for proto
# versions of the form "58a". This will get used if protocol versions are
# changed on a fixes branch ongoing.
- our $PROTO_VERSION = "73";
- our $PROTO_TOKEN = "D7FE8D6F";
+ our $PROTO_VERSION = "74";
+ our $PROTO_TOKEN = "SingingPotato";
# currentDatabaseVersion is defined in libmythtv in
# mythtv/libs/libmythtv/dbcheck.cpp and should be the current MythTV core
View
4 mythtv/bindings/php/MythBackend.php
@@ -11,8 +11,8 @@ class MythBackend {
// MYTH_PROTO_VERSION is defined in libmyth in mythtv/libs/libmyth/mythcontext.h
// and should be the current MythTV protocol version.
- static $protocol_version = '73';
- static $protocol_token = 'D7FE8D6F';
+ static $protocol_version = '74';
+ static $protocol_token = 'SingingPotato';
// The character string used by the backend to separate records
static $backend_separator = '[]:[]';
View
4 mythtv/bindings/python/MythTV/static.py
@@ -8,8 +8,8 @@
SCHEMA_VERSION = 1302
NVSCHEMA_VERSION = 1007
MUSICSCHEMA_VERSION = 1018
-PROTO_VERSION = '73'
-PROTO_TOKEN = 'D7FE8D6F'
+PROTO_VERSION = '74'
+PROTO_TOKEN = 'SingingPotato'
BACKEND_SEP = '[]:[]'
INSTALL_PREFIX = '/usr/local'
View
2  mythtv/docs/doxygen-architecture-document.cpp
@@ -576,7 +576,7 @@ Most MythTV programs follow a common sequence:
<li>Initialise the MythContext, which:</li>
<ul>
<li>Tries to find a database on localhost,
- or on the host specified in mysql.txt,</li>
+ or on the host specified in config.xml,</li>
<li>Tries to locate exactly one backend host via UPnP,
to find its database,</li>
<li>If possible, displays a list of all backends located via UPnP
View
8 mythtv/libs/libmyth/backendselect.h
@@ -19,9 +19,11 @@ struct DatabaseParams;
// location at this moment in time
// Some common UPnP search and XML value strings
const QString gBackendURI = "urn:schemas-mythtv-org:device:MasterMediaServer:1";
-const QString kDefaultBE = "UPnP/MythFrontend/DefaultBackend/";
-const QString kDefaultPIN = kDefaultBE + "SecurityPin";
-const QString kDefaultUSN = kDefaultBE + "USN";
+const QString kDefaultDB = "Database/";
+const QString kDefaultWOL = "WakeOnLAN/";
+const QString kDefaultMFE = "UPnP/MythFrontend/DefaultBackend/";
+const QString kDefaultPIN = kDefaultMFE + "SecurityPin";
+const QString kDefaultUSN = kDefaultMFE + "USN";
typedef QMap <QString, DeviceLocation*> ItemMap;
View
2  mythtv/libs/libmyth/langsettings.cpp
@@ -187,13 +187,11 @@ void LanguageSelection::Save(void)
MythUIButtonListItem *item = m_languageList->GetItemCurrent();
QString langCode = item->GetData().toString();
- gCoreContext->SetSetting("Language", langCode);
gCoreContext->SaveSetting("Language", langCode);
item = m_countryList->GetItemCurrent();
QString countryCode = item->GetData().toString();
- gCoreContext->SetSetting("Country", countryCode);
gCoreContext->SaveSetting("Country", countryCode);
if (m_language != langCode)
View
205 mythtv/libs/libmyth/mythcontext.cpp
@@ -14,7 +14,6 @@ using namespace std;
#include "config.h"
#include "mythcontext.h"
#include "exitcodes.h"
-#include "oldsettings.h"
#include "mythmiscutil.h"
#include "remotefile.h"
#include "mythplugin.h"
@@ -66,6 +65,7 @@ class MythContextPrivate : public QObject
void EndTempWindow(void);
bool LoadDatabaseSettings(void);
+ bool SaveDatabaseParams(const DatabaseParams &params, bool force);
bool PromptForDatabaseParams(const QString &error);
QString TestDBconnection(void);
@@ -75,7 +75,6 @@ class MythContextPrivate : public QObject
int ChooseBackend(const QString &error);
int UPnPautoconf(const int milliSeconds = 2000);
- void StoreConnectionInfo(void);
bool DefaultUPnP(QString &error);
bool UPnPconnect(const DeviceLocation *device, const QString &PIN);
@@ -217,6 +216,8 @@ MythContextPrivate::MythContextPrivate(MythContext *lparent)
MythContextPrivate::~MythContextPrivate()
{
+ if (m_pConfig)
+ delete m_pConfig;
if (m_ui)
DestroyMythUI();
if (m_sh)
@@ -240,10 +241,10 @@ void MythContextPrivate::TempMainWindow(bool languagePrompt)
SilenceDBerrors();
- gCoreContext->SetSetting("Theme", DEFAULT_UI_THEME);
+ gCoreContext->OverrideSettingForSession("Theme", DEFAULT_UI_THEME);
#ifdef Q_WS_MACX
// Qt 4.4 has window-focus problems
- gCoreContext->SetSetting("RunFrontendInWindow", "1");
+ gCoreContext->OverrideSettingForSession("RunFrontendInWindow", "1");
#endif
GetMythUI()->LoadQtConfig();
@@ -261,6 +262,7 @@ void MythContextPrivate::TempMainWindow(bool languagePrompt)
void MythContextPrivate::EndTempWindow(void)
{
DestroyMythMainWindow();
+ gCoreContext->ClearOverrideSettingForSession("Theme");
EnableDBerrors();
}
@@ -273,8 +275,7 @@ bool MythContextPrivate::Init(const bool gui,
m_gui = gui;
// We don't have a database yet, so lets use the config.xml file.
-
- m_pConfig = UPnp::GetConfiguration();
+ m_pConfig = new XmlConfiguration("config.xml");
// Creates screen saver control if we will have a GUI
if (gui)
@@ -333,11 +334,13 @@ bool MythContextPrivate::FindDatabase(const bool prompt, const bool noPrompt)
QString failure;
- // 1. Load either mysql.txt, or use sensible "localhost" defaults:
+ // 1. Either load config.xml or use sensible "localhost" defaults:
bool loaded = LoadDatabaseSettings();
+ DatabaseParams dbParamsFromFile = m_DBparams;
// In addition to the UI chooser, we can also try to autoSelect later,
- // but only if we're not doing manualSelect and there was no mysql.txt
+ // but only if we're not doing manualSelect and there was no
+ // valid config.xml
bool autoSelect = !manualSelect && !loaded;
// 2. If the user isn't forcing up the chooser UI, look for a default
@@ -424,41 +427,63 @@ bool MythContextPrivate::FindDatabase(const bool prompt, const bool noPrompt)
}
DBfound:
-#if 0
LOG(VB_GENERAL, LOG_DEBUG, "FindDatabase() - Success!");
-#endif
- StoreConnectionInfo();
+ SaveDatabaseParams(m_DBparams,
+ !loaded || m_DBparams.forceSave ||
+ dbParamsFromFile != m_DBparams);
EnableDBerrors();
ResetDatabase();
return true;
NoDBfound:
-#if 0
LOG(VB_GENERAL, LOG_DEBUG, "FindDatabase() - failed");
-#endif
return false;
}
-/** Load database and host settings from mysql.txt or config.xml,
- * or set some defaults.
- * \return true if mysql.txt or config.xml was parsed
+/** Load database and host settings from config.xml, or set some defaults.
+ * \return true if config.xml was parsed
*/
bool MythContextPrivate::LoadDatabaseSettings(void)
{
- bool ok = MythDB::LoadDatabaseParamsFromDisk(m_DBparams);
- if (!ok)
+ // try new format first
+ m_DBparams.LoadDefaults();
+
+ m_DBparams.localHostName = m_pConfig->GetValue("LocalHostName", "");
+
+ m_DBparams.dbHostName = m_pConfig->GetValue(kDefaultDB + "Host", "");
+ m_DBparams.dbUserName = m_pConfig->GetValue(kDefaultDB + "UserName", "");
+ m_DBparams.dbPassword = m_pConfig->GetValue(kDefaultDB + "Password", "");
+ m_DBparams.dbName = m_pConfig->GetValue(kDefaultDB + "DatabaseName", "");
+ m_DBparams.dbPort = m_pConfig->GetValue(kDefaultDB + "Port", 0);
+
+ m_DBparams.wolEnabled =
+ m_pConfig->GetValue(kDefaultWOL + "Enabled", false);
+ m_DBparams.wolReconnect =
+ m_pConfig->GetValue(kDefaultWOL + "SQLReconnectWaitTime", 0);
+ m_DBparams.wolRetry =
+ m_pConfig->GetValue(kDefaultWOL + "SQLConnectRetry", 0);
+ m_DBparams.wolCommand =
+ m_pConfig->GetValue(kDefaultWOL + "Command", "");
+
+ bool ok = m_DBparams.IsValid("config.xml");
+ if (!ok) // if new format fails, try legacy format
{
- XmlConfiguration cfg("config.xml");
- MythDB::LoadDefaultDatabaseParams(m_DBparams);
- m_DBparams.dbHostName = cfg.GetValue(kDefaultBE + "DBHostName", "");
- m_DBparams.dbUserName = cfg.GetValue(kDefaultBE + "DBUserName", "");
- m_DBparams.dbPassword = cfg.GetValue(kDefaultBE + "DBPassword", "");
- m_DBparams.dbName = cfg.GetValue(kDefaultBE + "DBName", "");
- m_DBparams.dbPort = cfg.GetValue(kDefaultBE + "DBPort", 0);
- ok = MythDB::ValidateDatabaseParams(m_DBparams, "config.xml");
+ m_DBparams.LoadDefaults();
+ m_DBparams.dbHostName = m_pConfig->GetValue(
+ kDefaultMFE + "DBHostName", "");
+ m_DBparams.dbUserName = m_pConfig->GetValue(
+ kDefaultMFE + "DBUserName", "");
+ m_DBparams.dbPassword = m_pConfig->GetValue(
+ kDefaultMFE + "DBPassword", "");
+ m_DBparams.dbName = m_pConfig->GetValue(
+ kDefaultMFE + "DBName", "");
+ m_DBparams.dbPort = m_pConfig->GetValue(
+ kDefaultMFE + "DBPort", 0);
+ m_DBparams.forceSave = true;
+ ok = m_DBparams.IsValid("config.xml");
}
if (!ok)
- MythDB::LoadDefaultDatabaseParams(m_DBparams);
+ m_DBparams.LoadDefaults();
gCoreContext->GetDB()->SetDatabaseParams(m_DBparams);
@@ -476,6 +501,10 @@ bool MythContextPrivate::LoadDatabaseSettings(void)
hostname = localhostname;
LOG(VB_GENERAL, LOG_NOTICE, "Empty LocalHostName.");
}
+ else
+ {
+ m_DBparams.localEnabled = true;
+ }
LOG(VB_GENERAL, LOG_INFO, QString("Using localhost value of %1")
.arg(hostname));
@@ -484,6 +513,59 @@ bool MythContextPrivate::LoadDatabaseSettings(void)
return ok;
}
+bool MythContextPrivate::SaveDatabaseParams(
+ const DatabaseParams &params, bool force)
+{
+ bool ret = true;
+
+ // only rewrite file if it has changed
+ if (params != m_DBparams || force)
+ {
+ m_pConfig->SetValue(
+ "LocalHostName", params.localHostName);
+
+ m_pConfig->SetValue(
+ kDefaultDB + "PingHost", params.dbHostPing);
+ m_pConfig->SetValue(
+ kDefaultDB + "Host", params.dbHostName);
+ m_pConfig->SetValue(
+ kDefaultDB + "UserName", params.dbUserName);
+ m_pConfig->SetValue(
+ kDefaultDB + "Password", params.dbPassword);
+ m_pConfig->SetValue(
+ kDefaultDB + "DatabaseName", params.dbName);
+ m_pConfig->SetValue(
+ kDefaultDB + "Port", params.dbPort);
+
+ m_pConfig->SetValue(
+ kDefaultWOL + "Enabled", params.wolEnabled);
+ m_pConfig->SetValue(
+ kDefaultWOL + "SQLReconnectWaitTime", params.wolReconnect);
+ m_pConfig->SetValue(
+ kDefaultWOL + "SQLConnectRetry", params.wolRetry);
+ m_pConfig->SetValue(
+ kDefaultWOL + "Command", params.wolCommand);
+
+ // clear out any legacy nodes..
+ m_pConfig->ClearValue(kDefaultMFE + "DBHostName");
+ m_pConfig->ClearValue(kDefaultMFE + "DBUserName");
+ m_pConfig->ClearValue(kDefaultMFE + "DBPassword");
+ m_pConfig->ClearValue(kDefaultMFE + "DBName");
+ m_pConfig->ClearValue(kDefaultMFE + "DBPort");
+
+ // actually save the file
+ m_pConfig->Save();
+
+ // Save the new settings:
+ m_DBparams = params;
+ gCoreContext->GetDB()->SetDatabaseParams(m_DBparams);
+
+ // If database has changed, force its use:
+ ResetDatabase();
+ }
+ return ret;
+}
+
bool MythContextPrivate::PromptForDatabaseParams(const QString &error)
{
bool accepted = false;
@@ -706,27 +788,6 @@ int MythContextPrivate::ChooseBackend(const QString &error)
}
/**
- * Try to store the current location of this backend in config.xml
- *
- * This is intended as a last resort for future connections
- * (e.g. Perl scripts, backend not running).
- *
- * Note that the Save() may fail (e.g. non writable ~/.mythtv)
- */
-void MythContextPrivate::StoreConnectionInfo(void)
-{
- if (!m_pConfig)
- return;
-
- m_pConfig->SetValue(kDefaultBE + "DBHostName", m_DBparams.dbHostName);
- m_pConfig->SetValue(kDefaultBE + "DBUserName", m_DBparams.dbUserName);
- m_pConfig->SetValue(kDefaultBE + "DBPassword", m_DBparams.dbPassword);
- m_pConfig->SetValue(kDefaultBE + "DBName", m_DBparams.dbName);
- m_pConfig->SetValue(kDefaultBE + "DBPort", m_DBparams.dbPort);
- m_pConfig->Save();
-}
-
-/**
* If there is only a single UPnP backend, use it.
*
* This does <i>not</i> prompt for PIN entry. If the backend requires one,
@@ -802,13 +863,9 @@ int MythContextPrivate::UPnPautoconf(const int milliSeconds)
*/
bool MythContextPrivate::DefaultUPnP(QString &error)
{
- Configuration *pConfig = new XmlConfiguration("config.xml");
QString loc = "DefaultUPnP() - ";
- QString localHostName = pConfig->GetValue(kDefaultBE + "LocalHostName", "");
- QString PIN = pConfig->GetValue(kDefaultPIN, "");
- QString USN = pConfig->GetValue(kDefaultUSN, "");
-
- delete pConfig;
+ QString PIN = m_pConfig->GetValue(kDefaultPIN, "");
+ QString USN = m_pConfig->GetValue(kDefaultUSN, "");
if (USN.isEmpty())
{
@@ -856,13 +913,6 @@ bool MythContextPrivate::DefaultUPnP(QString &error)
if (UPnPconnect(pDevLoc, PIN))
{
- if (localHostName.length())
- {
- m_DBparams.localHostName = localHostName;
- m_DBparams.localEnabled = true;
- gCoreContext->GetDB()->SetDatabaseParams(m_DBparams);
- }
-
pDevLoc->Release();
return true;
@@ -1176,38 +1226,7 @@ DatabaseParams MythContext::GetDatabaseParams(void)
bool MythContext::SaveDatabaseParams(const DatabaseParams &params)
{
- bool ret = true;
- DatabaseParams cur_params = GetDatabaseParams();
-
- // only rewrite file if it has changed
- if (params.dbHostName != cur_params.dbHostName ||
- params.dbHostPing != cur_params.dbHostPing ||
- params.dbPort != cur_params.dbPort ||
- params.dbUserName != cur_params.dbUserName ||
- params.dbPassword != cur_params.dbPassword ||
- params.dbName != cur_params.dbName ||
- params.dbType != cur_params.dbType ||
- params.localEnabled != cur_params.localEnabled ||
- params.wolEnabled != cur_params.wolEnabled ||
- (params.localEnabled &&
- (params.localHostName != cur_params.localHostName)) ||
- (params.wolEnabled &&
- (params.wolReconnect != cur_params.wolReconnect ||
- params.wolRetry != cur_params.wolRetry ||
- params.wolCommand != cur_params.wolCommand)))
- {
- ret = MythDB::SaveDatabaseParamsToDisk(params, GetConfDir(), true);
- if (ret)
- {
- // Save the new settings:
- d->m_DBparams = params;
- gCoreContext->GetDB()->SetDatabaseParams(d->m_DBparams);
-
- // If database has changed, force its use:
- d->ResetDatabase();
- }
- }
- return ret;
+ return d->SaveDatabaseParams(params, false);
}
/* vim: set expandtab tabstop=4 shiftwidth=4: */
View
2  mythtv/libs/libmythbase/libmythbase.pro
@@ -28,7 +28,7 @@ HEADERS += plist.h
SOURCES += mthread.cpp mthreadpool.cpp
SOURCES += mythsocket.cpp mythsocketthread.cpp msocketdevice.cpp
-SOURCES += mythdbcon.cpp mythdb.cpp oldsettings.cpp
+SOURCES += mythdbcon.cpp mythdb.cpp mythdbparams.cpp oldsettings.cpp
SOURCES += mythobservable.cpp mythevent.cpp httpcomms.cpp mcodecs.cpp
SOURCES += mythdirs.cpp mythsignalingtimer.cpp
SOURCES += lcddevice.cpp mythstorage.cpp remotefile.cpp
View
16 mythtv/libs/libmythbase/mythcorecontext.cpp
@@ -60,9 +60,9 @@ class MythCoreContextPrivate : public QObject
QObject *m_GUIobject;
QString m_appBinaryVersion;
- QMutex m_localHostLock; ///< Locking for thread-safe copying of:
- QString m_localHostname; ///< hostname from mysql.txt or gethostname()
- QMutex m_masterHostLock;
+ QMutex m_localHostLock; ///< Locking for m_localHostname
+ QString m_localHostname; ///< hostname from config.xml or gethostname()
+ QMutex m_masterHostLock; ///< Locking for m_masterHostname
QString m_masterHostname; ///< master backend hostname
QMutex m_sockLock; ///< protects both m_serverSock and m_eventSock
@@ -905,17 +905,17 @@ QString MythCoreContext::GetBackendServerIP(const QString &host)
return addr6;
}
-void MythCoreContext::SetSetting(const QString &key, const QString &newValue)
-{
- d->m_database->SetSetting(key, newValue);
-}
-
void MythCoreContext::OverrideSettingForSession(const QString &key,
const QString &value)
{
d->m_database->OverrideSettingForSession(key, value);
}
+void MythCoreContext::ClearOverrideSettingForSession(const QString &key)
+{
+ d->m_database->ClearOverrideSettingForSession(key);
+}
+
bool MythCoreContext::IsUIThread(void)
{
return is_current_thread(d->m_UIThread);
View
3  mythtv/libs/libmythbase/mythcorecontext.h
@@ -150,11 +150,10 @@ class MBASE_PUBLIC MythCoreContext : public MythObservable, public MythSocketCBs
QString GetBackendServerIP(void);
QString GetBackendServerIP(const QString &host);
- void SetSetting(const QString &key, const QString &newValue);
-
void ClearSettingsCache(const QString &myKey = QString(""));
void ActivateSettingsCache(bool activate = true);
void OverrideSettingForSession(const QString &key, const QString &value);
+ void ClearOverrideSettingForSession(const QString &key);
void dispatch(const MythEvent &event);
void dispatchNow(const MythEvent &event); // MDEPRECATED;
View
297 mythtv/libs/libmythbase/mythdb.cpp
@@ -12,7 +12,6 @@ using namespace std;
#include "mythdb.h"
#include "mythdbcon.h"
#include "mythlogging.h"
-#include "oldsettings.h"
#include "mythdirs.h"
#include "mythcorecontext.h"
@@ -21,6 +20,7 @@ static QMutex dbLock;
// For thread safety reasons this is not a QString
const char *kSentinelValue = "<settings_sentinel_value>";
+const char *kClearSettingValue = "<clear_setting_value>";
MythDB *MythDB::getMythDB(void)
{
@@ -72,8 +72,6 @@ class MythDBPrivate
QString m_localhostname;
MDBManager m_dbmanager;
- Settings *m_settings;
-
bool ignoreDatabase;
bool suppressDBMessages;
@@ -93,10 +91,9 @@ class MythDBPrivate
static const int settings_reserve = 61;
-MythDBPrivate::MythDBPrivate()
- : m_settings(new Settings()),
- ignoreDatabase(false), suppressDBMessages(true), useSettingsCache(false),
- haveDBConnection(false), haveSchema(false)
+MythDBPrivate::MythDBPrivate() :
+ ignoreDatabase(false), suppressDBMessages(true), useSettingsCache(false),
+ haveDBConnection(false), haveSchema(false)
{
m_localhostname.clear();
settingsCache.reserve(settings_reserve);
@@ -105,7 +102,6 @@ MythDBPrivate::MythDBPrivate()
MythDBPrivate::~MythDBPrivate()
{
LOG(VB_DATABASE, LOG_INFO, "Destroying MythDBPrivate");
- delete m_settings;
}
MythDB::MythDB()
@@ -123,11 +119,6 @@ MDBManager *MythDB::GetDBManager(void)
return &(d->m_dbmanager);
}
-Settings *MythDB::GetOldSettings(void)
-{
- return d->m_settings;
-}
-
QString MythDB::toCommaList(const QMap<QString, QVariant> &bindings,
uint indent, uint maxColumn)
{
@@ -266,10 +257,10 @@ bool MythDB::SaveSettingOnHost(const QString &key,
const QString &newValueRaw,
const QString &host)
{
- QString LOC = QString("SaveSettingOnHost('%1') ").arg(key);
+ QString loc = QString("SaveSettingOnHost('%1') ").arg(key);
if (key.isEmpty())
{
- LOG(VB_GENERAL, LOG_ERR, LOC + "- Illegal null key");
+ LOG(VB_GENERAL, LOG_ERR, loc + "- Illegal null key");
return false;
}
@@ -278,7 +269,12 @@ bool MythDB::SaveSettingOnHost(const QString &key,
if (d->ignoreDatabase)
{
if (host.toLower() == d->m_localhostname)
- OverrideSettingForSession(key, newValue);
+ {
+ if (newValue != kClearSettingValue)
+ OverrideSettingForSession(key, newValue);
+ else
+ ClearOverrideSettingForSession(key);
+ }
return true;
}
@@ -287,7 +283,7 @@ bool MythDB::SaveSettingOnHost(const QString &key,
if (host.toLower() == d->m_localhostname)
OverrideSettingForSession(key, newValue);
if (!d->suppressDBMessages)
- LOG(VB_GENERAL, LOG_ERR, LOC + "- No database yet");
+ LOG(VB_GENERAL, LOG_ERR, loc + "- No database yet");
SingleSetting setting;
setting.host = host;
setting.key = key;
@@ -313,9 +309,19 @@ bool MythDB::SaveSettingOnHost(const QString &key,
if (!host.isEmpty())
query.bindValue(":HOSTNAME", host);
- if (!query.exec() && !(GetMythDB()->SuppressDBMessages()))
- MythDB::DBError("Clear setting", query);
+ if (!query.exec())
+ {
+ if (!GetMythDB()->SuppressDBMessages())
+ MythDB::DBError("Clear setting", query);
+ }
+ else
+ {
+ success = true;
+ }
+ }
+ if (success && (newValue != kClearSettingValue))
+ {
if (!host.isEmpty())
query.prepare("INSERT INTO settings (value,data,hostname) "
"VALUES ( :VALUE, :DATA, :HOSTNAME );");
@@ -328,14 +334,16 @@ bool MythDB::SaveSettingOnHost(const QString &key,
if (!host.isEmpty())
query.bindValue(":HOSTNAME", host);
- if (query.exec())
- success = true;
- else if (!(GetMythDB()->SuppressDBMessages()))
- MythDB::DBError(LOC + "- query failure: ", query);
+ if (!query.exec())
+ {
+ success = false;
+ if (!(GetMythDB()->SuppressDBMessages()))
+ MythDB::DBError(loc + "- query failure: ", query);
+ }
}
- else
+ else if (!success)
{
- LOG(VB_GENERAL, LOG_ERR, LOC + "- database not open");
+ LOG(VB_GENERAL, LOG_ERR, loc + "- database not open");
}
ClearSettingsCache(host + ' ' + key);
@@ -343,10 +351,20 @@ bool MythDB::SaveSettingOnHost(const QString &key,
return success;
}
+bool MythDB::ClearSetting(const QString &key)
+{
+ return ClearSettingOnHost(key, d->m_localhostname);
+}
+
+bool MythDB::ClearSettingOnHost(const QString &key, const QString &host)
+{
+ return SaveSettingOnHost(key, kClearSettingValue, host);
+}
+
QString MythDB::GetSetting(const QString &_key, const QString &defaultval)
{
QString key = _key.toLower();
- QString value;
+ QString value = defaultval;
d->settingsCacheLock.lockForRead();
if (d->useSettingsCache)
@@ -369,17 +387,11 @@ QString MythDB::GetSetting(const QString &_key, const QString &defaultval)
d->settingsCacheLock.unlock();
if (d->ignoreDatabase || !HaveValidDatabase())
- return defaultval;
+ return value;
MSqlQuery query(MSqlQuery::InitCon());
if (!query.isConnected())
- {
- if (!d->suppressDBMessages)
- LOG(VB_GENERAL, LOG_ERR,
- QString("Database not open while trying to load setting: %1")
- .arg(key));
- return d->m_settings->GetSetting(key, defaultval);
- }
+ return value;
query.prepare(
"SELECT data "
@@ -404,10 +416,6 @@ QString MythDB::GetSetting(const QString &_key, const QString &defaultval)
{
value = query.value(0).toString();
}
- else
- {
- value = d->m_settings->GetSetting(key, defaultval);
- }
}
if (d->useSettingsCache && value != kSentinelValue)
@@ -688,13 +696,6 @@ double MythDB::GetFloatSettingOnHost(const QString &key, const QString &host)
return (retval == sentinel) ? 0.0 : retval.toDouble();
}
-void MythDB::SetSetting(const QString &key, const QString &newValueRaw)
-{
- QString newValue = (newValueRaw.isNull()) ? "" : newValueRaw;
- d->m_settings->SetSetting(key, newValue);
- ClearSettingsCache(key);
-}
-
void MythDB::GetResolutionSetting(const QString &type,
int &width, int &height,
double &forced_aspect,
@@ -789,6 +790,29 @@ void MythDB::OverrideSettingForSession(
d->settingsCacheLock.unlock();
}
+/// \brief Clears session Overrides for the given setting.
+void MythDB::ClearOverrideSettingForSession(const QString &key)
+{
+ QString mk = key.toLower();
+ QString mk2 = d->m_localhostname + ' ' + mk;
+
+ d->settingsCacheLock.lockForWrite();
+
+ SettingsMap::iterator oit = d->overriddenSettings.find(mk);
+ if (oit != d->overriddenSettings.end())
+ d->overriddenSettings.erase(oit);
+
+ SettingsMap::iterator sit = d->settingsCache.find(mk);
+ if (sit != d->settingsCache.end())
+ d->settingsCache.erase(sit);
+
+ sit = d->settingsCache.find(mk2);
+ if (sit != d->settingsCache.end())
+ d->settingsCache.erase(sit);
+
+ d->settingsCacheLock.unlock();
+}
+
static void clear(
SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
{
@@ -857,189 +881,6 @@ void MythDB::ActivateSettingsCache(bool activate)
ClearSettingsCache();
}
-bool MythDB::LoadDatabaseParamsFromDisk(DatabaseParams &params)
-{
- Settings settings;
- if (!settings.LoadSettingsFiles(
- "mysql.txt", GetInstallPrefix(), GetConfDir()))
- {
- LOG(VB_GENERAL, LOG_ERR, "Unable to read configuration file mysql.txt");
- return false;
- }
-
- params.dbHostName = settings.GetSetting("DBHostName");
- params.dbHostPing = settings.GetSetting("DBHostPing") != "no";
- params.dbPort = settings.GetNumSetting("DBPort", 3306);
- params.dbUserName = settings.GetSetting("DBUserName");
- params.dbPassword = settings.GetSetting("DBPassword");
- params.dbName = settings.GetSetting("DBName");
- params.dbType = settings.GetSetting("DBType");
-
- params.localHostName = settings.GetSetting("LocalHostName");
- params.localEnabled = !params.localHostName.isEmpty();
-
- params.wolReconnect =
- settings.GetNumSetting("WOLsqlReconnectWaitTime");
- params.wolEnabled = params.wolReconnect > 0;
-
- params.wolRetry = settings.GetNumSetting("WOLsqlConnectRetry");
- params.wolCommand = settings.GetSetting("WOLsqlCommand");
-
- return ValidateDatabaseParams(params, "mysql.txt");
-}
-
-bool MythDB::ValidateDatabaseParams(
- const DatabaseParams &params, const QString &source)
-{
- // Print some warnings if things look fishy..
- QString msg = QString(" is not set in %1").arg(source);
-
- if (params.dbHostName.isEmpty())
- {
- LOG(VB_GENERAL, LOG_ERR, "DBHostName" + msg);
- return false;
- }
- if (params.dbUserName.isEmpty())
- {
- LOG(VB_GENERAL, LOG_ERR, "DBUserName" + msg);
- return false;
- }
- if (params.dbPassword.isEmpty())
- {
- LOG(VB_GENERAL, LOG_ERR, "DBPassword" + msg);
- return false;
- }
- if (params.dbName.isEmpty())
- {
- LOG(VB_GENERAL, LOG_ERR, "DBName" + msg);
- return false;
- }
-
- return true;
-}
-
-// Sensible connection defaults.
-void MythDB::LoadDefaultDatabaseParams(DatabaseParams &params)
-{
- params.dbHostName = "localhost";
- params.dbHostPing = true;
- params.dbPort = 3306;
- params.dbUserName = "mythtv";
- params.dbPassword = "mythtv";
- params.dbName = "mythconverg";
- params.dbType = "QMYSQL";
- params.localEnabled = false;
- params.localHostName = "my-unique-identifier-goes-here";
- params.wolEnabled = false;
- params.wolReconnect = 0;
- params.wolRetry = 5;
- params.wolCommand = "echo 'WOLsqlServerCommand not set'";
-}
-
-bool MythDB::SaveDatabaseParamsToDisk(
- const DatabaseParams &params, const QString &confdir, bool overwrite)
-{
- QString path = confdir + "/mysql.txt";
- QFile * f = new QFile(path);
-
- if (!overwrite && f->exists())
- {
- return false;
- }
-
- QString dirpath = confdir;
- QDir createDir(dirpath);
-
- if (!createDir.exists())
- {
- if (!createDir.mkdir(dirpath))
- {
- LOG(VB_GENERAL, LOG_ERR,
- QString("Could not create %1").arg(dirpath));
- return false;
- }
- }
-
- if (!f->open(QIODevice::WriteOnly))
- {
- LOG(VB_GENERAL, LOG_ERR, QString("Could not open settings file %1 "
- "for writing").arg(path));
- return false;
- }
-
- LOG(VB_GENERAL, LOG_NOTICE, QString("Writing settings file %1").arg(path));
- QTextStream s(f);
- s << "DBHostName=" << params.dbHostName << endl;
-
- s << "\n"
- << "# By default, Myth tries to ping the DB host to see if it exists.\n"
- << "# If your DB host or network doesn't accept pings, set this to no:\n"
- << "#\n";
-
- if (params.dbHostPing)
- s << "#DBHostPing=no" << endl << endl;
- else
- s << "DBHostPing=no" << endl << endl;
-
- if (params.dbPort)
- s << "DBPort=" << params.dbPort << endl;
-
- s << "DBUserName=" << params.dbUserName << endl
- << "DBPassword=" << params.dbPassword << endl
- << "DBName=" << params.dbName << endl
- << "DBType=" << params.dbType << endl
- << endl
- << "# Set the following if you want to use something other than this\n"
- << "# machine's real hostname for identifying settings in the database.\n"
- << "# This is useful if your hostname changes often, as otherwise you\n"
- << "# will need to reconfigure mythtv every time.\n"
- << "# NO TWO HOSTS MAY USE THE SAME VALUE\n"
- << "#\n";
-
- if (params.localEnabled)
- s << "LocalHostName=" << params.localHostName << endl;
- else
- s << "#LocalHostName=my-unique-identifier-goes-here\n";
-
- s << endl
- << "# If you want your frontend to be able to wake your MySQL server\n"
- << "# using WakeOnLan, have a look at the following settings:\n"
- << "#\n"
- << "#\n"
- << "# The time the frontend waits (in seconds) between reconnect tries.\n"
- << "# This should be the rough time your MySQL server needs for startup\n"
- << "#\n";
-
- if (params.wolEnabled)
- s << "WOLsqlReconnectWaitTime=" << params.wolReconnect << endl;
- else
- s << "#WOLsqlReconnectWaitTime=0\n";
-
- s << "#\n"
- << "#\n"
- << "# This is the number of retries to wake the MySQL server\n"
- << "# until the frontend gives up\n"
- << "#\n";
-
- if (params.wolEnabled)
- s << "WOLsqlConnectRetry=" << params.wolRetry << endl;
- else
- s << "#WOLsqlConnectRetry=5\n";
-
- s << "#\n"
- << "#\n"
- << "# This is the command executed to wake your MySQL server.\n"
- << "#\n";
-
- if (params.wolEnabled)
- s << "WOLsqlCommand=" << params.wolCommand << endl;
- else
- s << "#WOLsqlCommand=echo 'WOLsqlServerCommand not set'\n";
-
- f->close();
- return true;
-}
-
void MythDB::WriteDelayedSettings(void)
{
if (!HaveValidDatabase())
View
14 mythtv/libs/libmythbase/mythdb.h
@@ -9,7 +9,6 @@
#include "mythdbparams.h"
class MythDBPrivate;
-class Settings;
class MDBManager;
class MBASE_PUBLIC MythDB
@@ -17,7 +16,6 @@ class MBASE_PUBLIC MythDB
friend class MSqlQuery;
public:
MDBManager *GetDBManager(void);
- Settings *GetOldSettings(void);
static QString GetError(const QString &where, const MSqlQuery &query);
static void DBError(const QString &where, const MSqlQuery &query);
@@ -38,11 +36,14 @@ class MBASE_PUBLIC MythDB
void ClearSettingsCache(const QString &key = QString());
void ActivateSettingsCache(bool activate = true);
void OverrideSettingForSession(const QString &key, const QString &newValue);
+ void ClearOverrideSettingForSession(const QString &key);
void SaveSetting(const QString &key, int newValue);
void SaveSetting(const QString &key, const QString &newValue);
bool SaveSettingOnHost(const QString &key, const QString &newValue,
const QString &host);
+ bool ClearSetting(const QString &key);
+ bool ClearSettingOnHost(const QString &key, const QString &host);
bool GetSettings(QMap<QString,QString> &_key_value_pairs);
@@ -71,8 +72,6 @@ class MBASE_PUBLIC MythDB
void GetResolutionSetting(const QString &type, int &width, int &height,
int index=-1);
- void SetSetting(const QString &key, const QString &newValue);
-
void WriteDelayedSettings(void);
void SetHaveDBConnection(bool connected);
@@ -85,13 +84,6 @@ class MBASE_PUBLIC MythDB
static QString toCommaList(const QMap<QString, QVariant> &bindings,
uint indent = 0, uint softMaxColumn = 80);
- static bool LoadDatabaseParamsFromDisk(DatabaseParams &params);
- static bool ValidateDatabaseParams(
- const DatabaseParams &params, const QString &source);
- static void LoadDefaultDatabaseParams(DatabaseParams &params);
- static bool SaveDatabaseParamsToDisk(
- const DatabaseParams &params, const QString &confdir, bool overwrite);
-
protected:
MythDB();
~MythDB();
View
78 mythtv/libs/libmythbase/mythdbparams.cpp
@@ -0,0 +1,78 @@
+#include "mythdbparams.h"
+#include "mythlogging.h"
+
+/// Load sensible connection defaults.
+void DatabaseParams::LoadDefaults(void)
+{
+ dbHostName = "localhost";
+ dbHostPing = true;
+ dbPort = 3306;
+ dbUserName = "mythtv";
+ dbPassword = "mythtv";
+ dbName = "mythconverg";
+ dbType = "QMYSQL";
+
+ localEnabled = false;
+ localHostName = "my-unique-identifier-goes-here";
+
+ wolEnabled = false;
+ wolReconnect = 0;
+ wolRetry = 5;
+ wolCommand = "echo 'WOLsqlServerCommand not set'";
+
+ forceSave = false;
+
+ verVersion.clear();
+ verBranch.clear();
+ verProtocol.clear();
+ verBinary.clear();
+ verSchema.clear();
+}
+
+bool DatabaseParams::IsValid(const QString &source) const
+{
+ // Print some warnings if things look fishy..
+ QString msg = QString(" is not set in %1").arg(source);
+
+ if (dbHostName.isEmpty())
+ {
+ LOG(VB_GENERAL, LOG_ERR, "DBHostName" + msg);
+ return false;
+ }
+ if (dbUserName.isEmpty())
+ {
+ LOG(VB_GENERAL, LOG_ERR, "DBUserName" + msg);
+ return false;
+ }
+ if (dbPassword.isEmpty())
+ {
+ LOG(VB_GENERAL, LOG_ERR, "DBPassword" + msg);
+ return false;
+ }
+ if (dbName.isEmpty())
+ {
+ LOG(VB_GENERAL, LOG_ERR, "DBName" + msg);
+ return false;
+ }
+
+ return true;
+}
+
+bool DatabaseParams::operator==(const DatabaseParams &other) const
+{
+ return
+ dbHostName == other.dbHostName &&
+ dbHostPing == other.dbHostPing &&
+ dbPort == other.dbPort &&
+ dbUserName == other.dbUserName &&
+ dbPassword == other.dbPassword &&
+ dbName == other.dbName &&
+ dbType == other.dbType &&
+ localEnabled == other.localEnabled &&
+ wolEnabled == other.wolEnabled &&
+ (!localEnabled || (localHostName == other.localHostName)) &&
+ (!wolEnabled ||
+ (wolReconnect == other.wolReconnect &&
+ wolRetry == other.wolRetry &&
+ wolCommand == other.wolCommand));
+}
View
16 mythtv/libs/libmythbase/mythdbparams.h
@@ -1,11 +1,23 @@
#ifndef MYTHDBPARAMS_H_
#define MYTHDBPARAMS_H_
+#include <QString>
+
#include "mythbaseexp.h"
/// Structure containing the basic Database parameters
-struct MBASE_PUBLIC DatabaseParams
+class MBASE_PUBLIC DatabaseParams
{
+ public:
+ DatabaseParams() { LoadDefaults(); }
+
+ void LoadDefaults(void);
+ bool IsValid(const QString &source = QString("Unknown")) const;
+
+ bool operator==(const DatabaseParams &other) const;
+ bool operator!=(const DatabaseParams &other) const
+ { return !((*this)==other); }
+
QString dbHostName; ///< database server
bool dbHostPing; ///< Can we test connectivity using ping?
int dbPort; ///< database port
@@ -22,6 +34,8 @@ struct MBASE_PUBLIC DatabaseParams
int wolRetry; ///< times to retry to reconnect
QString wolCommand; ///< command to use for wake-on-lan
+ bool forceSave; ///< set to true to force a save of the settings file
+
QString verVersion; ///< git version string
QString verBranch; ///< git branch
QString verProtocol; ///< backend protocol
View
6 mythtv/libs/libmythbase/mythlocale.cpp
@@ -179,20 +179,14 @@ void MythLocale::SaveLocaleDefaults(bool overwrite)
{
MythDB *mythDB = MythDB::getMythDB();
if (overwrite || mythDB->GetSetting(it.key()).isEmpty())
- {
- mythDB->SetSetting(it.key(), it.value());
mythDB->SaveSettingOnHost(it.key(), it.value(), "");
- }
}
for (it = m_hostSettings.begin(); it != m_hostSettings.end(); ++it)
{
MythDB *mythDB = MythDB::getMythDB();
if (overwrite || mythDB->GetSetting(it.key()).isEmpty())
- {
- mythDB->SetSetting(it.key(), it.value());
mythDB->SaveSetting(it.key(), it.value());
- }
}
}
View
1  mythtv/libs/libmythbase/mythtranslation.cpp
@@ -52,7 +52,6 @@ void MythTranslation::load(const QString &module_name)
if (lang == "en")
{
- gCoreContext->SetSetting("Language", "en_US");
gCoreContext->SaveSetting("Language", "en_US");
lang = "en_us";
}
View
6 mythtv/libs/libmythbase/mythversion.h
@@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
-#define MYTH_BINARY_VERSION "0.26.20120503-1"
+#define MYTH_BINARY_VERSION "0.26.20120504-1"
/** \brief Increment this whenever the MythTV network protocol changes.
*
@@ -35,8 +35,8 @@
* mythtv/bindings/python/MythTV/static.py (version number)
* mythtv/bindings/python/MythTV/mythproto.py (layout)
*/
-#define MYTH_PROTO_VERSION "73"
-#define MYTH_PROTO_TOKEN "D7FE8D6F"
+#define MYTH_PROTO_VERSION "74"
+#define MYTH_PROTO_TOKEN "SingingPotato"
/** \brief Increment this whenever the MythTV core database schema changes.
*
View
1  mythtv/libs/libmythmetadata/parentalcontrols.cpp
@@ -277,7 +277,6 @@ class ParentalLevelChangeCheckerPrivate : public QObject
{
// Two minute window
last_time_stamp = curr_time.toString(Qt::ISODate);
- gCoreContext->SetSetting("VideoPasswordTime", last_time_stamp);
gCoreContext->SaveSetting("VideoPasswordTime", last_time_stamp);
return true;
}
View
2  mythtv/libs/libmythui/myththemedmenu.cpp
@@ -398,7 +398,6 @@ void MythThemedMenu::customEvent(QEvent *event)
QString timestamp_setting = QString("%1Time").arg(button.password);
QDateTime curr_time = QDateTime::currentDateTime();
QString last_time_stamp = curr_time.toString(Qt::TextDate);
- GetMythDB()->SetSetting(timestamp_setting, last_time_stamp);
GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp);
buttonAction(item, true);
}
@@ -897,7 +896,6 @@ bool MythThemedMenu::checkPinCode(const QString &password_setting)
if (last_time.secsTo(curr_time) < 120)
{
last_time_stamp = curr_time.toString(Qt::TextDate);
- GetMythDB()->SetSetting(timestamp_setting, last_time_stamp);
GetMythDB()->SaveSetting(timestamp_setting, last_time_stamp);
return true;
}
View
74 mythtv/libs/libmythupnp/configuration.cpp
@@ -10,6 +10,8 @@
//
//////////////////////////////////////////////////////////////////////////////
+#include <unistd.h> // for fsync
+
#include <iostream>
#include <QDir>
@@ -87,14 +89,15 @@ bool XmlConfiguration::Save( void )
if (m_sFileName.isEmpty()) // Special case. No file is created
return true;
- QString sName = m_sPath + '/' + m_sFileName;
+ QString config_temppath = m_sPath + '/' + m_sFileName + ".new";
+ QString config_filepath = m_sPath + '/' + m_sFileName;
+ QString config_origpath = m_sPath + '/' + m_sFileName + ".orig";
- QFile file( sName );
+ QFile file(config_temppath);
if (!file.exists())
{
- QDir createDir( m_sPath );
-
+ QDir createDir(m_sPath);
if (!createDir.exists())
{
if (!createDir.mkdir(m_sPath))
@@ -106,21 +109,46 @@ bool XmlConfiguration::Save( void )
}
}
- if (!file.open( QIODevice::WriteOnly | QIODevice::Truncate ))
+ if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
LOG(VB_GENERAL, LOG_ERR,
- QString("Could not open settings file %1 for writing").arg(sName));
+ QString("Could not open settings file %1 for writing")
+ .arg(config_temppath));
return false;
}
- QTextStream ts( &file );
+ {
+ QTextStream ts(&file);
+ m_config.save(ts, 2);
+ }
- m_config.save( ts, 2 );
+ file.flush();
+
+ fsync(file.handle());
file.close();
- return true;
+ bool ok = true;
+ if (QFile::exists(config_filepath))
+ ok = QFile::rename(config_filepath, config_origpath);
+
+ if (ok)
+ {
+ ok = file.rename(config_filepath);
+ if (ok)
+ QFile::remove(config_origpath);
+ else if (QFile::exists(config_origpath))
+ QFile::rename(config_origpath, config_filepath);
+ }
+
+ if (!ok)
+ {
+ LOG(VB_GENERAL, LOG_ERR,
+ QString("Could not save settings file %1").arg(config_filepath));
+ }
+
+ return ok;
}
//////////////////////////////////////////////////////////////////////////////
@@ -257,6 +285,25 @@ void XmlConfiguration::SetValue( const QString &sSetting, QString sValue )
}
}
+//////////////////////////////////////////////////////////////////////////////
+//
+//////////////////////////////////////////////////////////////////////////////
+
+void XmlConfiguration::ClearValue( const QString &sSetting )
+{
+ QDomNode node = FindNode(sSetting);
+ if (!node.isNull())
+ {
+ QDomNode parent = node.parentNode();
+ parent.removeChild(node);
+ while (parent.childNodes().count() == 0)
+ {
+ QDomNode next_parent = parent.parentNode();
+ next_parent.removeChild(parent);
+ parent = next_parent;
+ }
+ }
+}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -324,3 +371,12 @@ void DBConfiguration::SetValue( const QString &sSetting, QString sValue )
{
GetMythDB()->SaveSetting( sSetting, sValue );
}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//////////////////////////////////////////////////////////////////////////////
+
+void DBConfiguration::ClearValue( const QString &sSetting )
+{
+ GetMythDB()->ClearSetting( sSetting );
+}
View
6 mythtv/libs/libmythupnp/configuration.h
@@ -32,7 +32,7 @@ class UPNP_PUBLIC Configuration
virtual void SetValue( const QString &sSetting, int value ) = 0;
virtual void SetValue( const QString &sSetting, QString value ) = 0;
-
+ virtual void ClearValue( const QString &sSetting ) = 0;
};
@@ -73,7 +73,7 @@ class UPNP_PUBLIC XmlConfiguration : public Configuration
virtual void SetValue( const QString &sSetting, int value );
virtual void SetValue( const QString &sSetting, QString value );
-
+ virtual void ClearValue( const QString &sSetting );
};
//////////////////////////////////////////////////////////////////////////////
@@ -96,7 +96,7 @@ class UPNP_PUBLIC DBConfiguration : public Configuration
virtual void SetValue( const QString &sSetting, int value );
virtual void SetValue( const QString &sSetting, QString value );
-
+ virtual void ClearValue( const QString &sSetting );
};
#endif
View
49 mythtv/programs/mythbackend/mythsettings.cpp
@@ -355,15 +355,7 @@ QMap<QString,QString> GetSettingsMap(MythSettingList &settings,
QMap<QString,QString> result;
MSqlQuery query(MSqlQuery::InitCon());
- QString list = extract_query_list(settings, MythSetting::kFile);
- if (!list.isEmpty())
- {
- result = GetConfigFileSettingValues();
- if (result.isEmpty())
- return result;
- }
-
- list = extract_query_list(settings, MythSetting::kHost);
+ QString list = extract_query_list(settings, MythSetting::kHost);
QString qstr =
"SELECT value, data "
"FROM settings "
@@ -474,31 +466,6 @@ QString StringListToJSON(const QString &key,
return result;
}
-QMap<QString,QString> GetConfigFileSettingValues(void)
-{
- QMap<QString,QString> map;
- DatabaseParams params;
- if (!MythDB::LoadDatabaseParamsFromDisk(params))
- MythDB::LoadDefaultDatabaseParams(params);
-
- map["dbHostName"] = params.dbHostName;
- map["dbPort"] = QString::number(params.dbPort);
- map["dbPing"] = QString::number(params.dbHostPing);
- map["dbName"] = params.dbName;
- map["dbUserName"] = params.dbUserName;
- map["dbPassword"] = params.dbPassword;
- map["dbHostID"] = params.localHostName;
- map["dbWOLEnabled"] =
- QString::number(params.wolEnabled);
- map["dbWOLReconnectCount"] =
- QString::number(params.wolReconnect);
- map["dbWOLRetryCount"] =
- QString::number(params.wolRetry);
- map["dbWOLCommand"] = params.wolCommand;
-
- return map;
-}
-
bool parse_dom(MythSettingList &settings, const QDomElement &element,
const QString &filename, const QString &group,
bool includeAllChildren, bool &foundGroup)
@@ -706,19 +673,7 @@ bool load_settings(MythSettingList &settings, const QString &hostname)
{
MSqlQuery query(MSqlQuery::InitCon());
- QString list = extract_query_list(settings, MythSetting::kFile);
- if (!list.isEmpty())
- {
- QMap<QString,QString> map = GetConfigFileSettingValues();
- if (map.isEmpty())
- return false;
-
- MythSettingList::const_iterator it = settings.begin();
- for (; it != settings.end(); ++it)
- fill_setting(*it, map, MythSetting::kFile);
- }
-
- list = extract_query_list(settings, MythSetting::kHost);
+ QString list = extract_query_list(settings, MythSetting::kHost);
QString qstr =
"SELECT value, data "
"FROM settings "
View
1  mythtv/programs/mythbackend/mythsettings.h
@@ -125,7 +125,6 @@ bool check_settings(MythSettingList &database_settings,
QStringList GetSettingValueList(const QString &type);
QString StringMapToJSON(const QMap<QString,QString> &map);
QString StringListToJSON(const QString &key, const QStringList &sList);
-QMap<QString,QString> GetConfigFileSettingValues();
QMap<QString,QString> GetSettingsMap(MythSettingList &settings, const QString &hostname);
#endif
View
2  mythtv/programs/mythtv-setup/main.cpp
@@ -348,7 +348,7 @@ int main(int argc, char *argv[])
if (use_display)
{
- gCoreContext->SetSetting("Theme", DEFAULT_UI_THEME);
+ gCoreContext->OverrideSettingForSession("Theme", DEFAULT_UI_THEME);
GetMythUI()->LoadQtConfig();
QString fileprefix = GetConfDir();
View
4 mythtv/programs/mythtv-setup/startprompt.cpp
@@ -44,7 +44,7 @@ void StartPrompter::handleStart()
void StartPrompter::leaveBackendRunning()
{
LOG(VB_GENERAL, LOG_INFO, "Continuing with backend running");
- gCoreContext->SetSetting("AutoRestartBackend", "0");
+ gCoreContext->OverrideSettingForSession("AutoRestartBackend", "0");
}
void StartPrompter::stopBackend()
@@ -56,7 +56,7 @@ void StartPrompter::stopBackend()
{
myth_system(commandString);
}
- gCoreContext->SetSetting("AutoRestartBackend", "1");
+ gCoreContext->OverrideSettingForSession("AutoRestartBackend", "1");
}
void StartPrompter::backendRunningPrompt(void)
Please sign in to comment.
Something went wrong with that request. Please try again.