diff --git a/mythtv/docs/doxygen-architecture-document.cpp b/mythtv/docs/doxygen-architecture-document.cpp
index 464a5f4..8b8e90fa 100644
--- a/mythtv/docs/doxygen-architecture-document.cpp
+++ b/mythtv/docs/doxygen-architecture-document.cpp
@@ -576,7 +576,7 @@ Most MythTV programs follow a common sequence:
Initialise the MythContext, which:
- Tries to find a database on localhost,
- or on the host specified in mysql.txt,
+ or on the host specified in config.xml,
- Tries to locate exactly one backend host via UPnP,
to find its database,
- If possible, displays a list of all backends located via UPnP
diff --git a/mythtv/libs/libmyth/backendselect.h b/mythtv/libs/libmyth/backendselect.h
index 560622c..c96fdb9 100644
--- a/mythtv/libs/libmyth/backendselect.h
+++ b/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 ItemMap;
diff --git a/mythtv/libs/libmyth/langsettings.cpp b/mythtv/libs/libmyth/langsettings.cpp
index 5cbe870..70ccd7f 100644
--- a/mythtv/libs/libmyth/langsettings.cpp
+++ b/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)
diff --git a/mythtv/libs/libmyth/mythcontext.cpp b/mythtv/libs/libmyth/mythcontext.cpp
index ea8c07d..5c71274 100644
--- a/mythtv/libs/libmyth/mythcontext.cpp
+++ b/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 "util.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 ¶ms, 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 ¶ms, 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 not 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 ¶ms)
{
- 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: */
diff --git a/mythtv/libs/libmythbase/libmythbase.pro b/mythtv/libs/libmythbase/libmythbase.pro
index 7049ebe..b87a51a 100644
--- a/mythtv/libs/libmythbase/libmythbase.pro
+++ b/mythtv/libs/libmythbase/libmythbase.pro
@@ -27,7 +27,7 @@ HEADERS += mythscheduler.h filesysteminfo.h hardwareprofile.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
diff --git a/mythtv/libs/libmythbase/mythcorecontext.cpp b/mythtv/libs/libmythbase/mythcorecontext.cpp
index 5f1b84c..17033d7 100644
--- a/mythtv/libs/libmythbase/mythcorecontext.cpp
+++ b/mythtv/libs/libmythbase/mythcorecontext.cpp
@@ -55,7 +55,7 @@ class MythCoreContextPrivate : public QObject
QString m_appBinaryVersion;
QMutex m_hostnameLock; ///< Locking for thread-safe copying of:
- QString m_localHostname; ///< hostname from mysql.txt or gethostname()
+ QString m_localHostname; ///< hostname from config.xml or gethostname()
QString m_masterHostname; ///< master backend hostname
QMutex m_sockLock; ///< protects both m_serverSock and m_eventSock
@@ -839,17 +839,17 @@ double MythCoreContext::GetFloatSettingOnHost(const QString &key,
return d->m_database->GetFloatSettingOnHost(key, host, defaultval);
}
-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);
diff --git a/mythtv/libs/libmythbase/mythcorecontext.h b/mythtv/libs/libmythbase/mythcorecontext.h
index ca2e0c2..824457c 100644
--- a/mythtv/libs/libmythbase/mythcorecontext.h
+++ b/mythtv/libs/libmythbase/mythcorecontext.h
@@ -145,11 +145,10 @@ class MBASE_PUBLIC MythCoreContext : public MythObservable, public MythSocketCBs
double GetFloatSettingOnHost(const QString &key, const QString &host,
double defaultval = 0.0);
- 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;
diff --git a/mythtv/libs/libmythbase/mythdb.cpp b/mythtv/libs/libmythbase/mythdb.cpp
index adfe3c5..aefdcbf 100644
--- a/mythtv/libs/libmythbase/mythdb.cpp
+++ b/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 = "";
+const char *kClearSettingValue = "";
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 &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,6 +351,16 @@ 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();
@@ -375,15 +393,6 @@ QString MythDB::GetSetting(const QString &_key, const QString &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);
- }
-
query.prepare(
"SELECT data "
"FROM settings "
@@ -407,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)
@@ -697,13 +702,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,
@@ -798,6 +796,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)
{
@@ -866,189 +887,6 @@ void MythDB::ActivateSettingsCache(bool activate)
ClearSettingsCache();
}
-bool MythDB::LoadDatabaseParamsFromDisk(DatabaseParams ¶ms)
-{
- 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 ¶ms, 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 ¶ms)
-{
- 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 ¶ms, 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())
diff --git a/mythtv/libs/libmythbase/mythdb.h b/mythtv/libs/libmythbase/mythdb.h
index 79abe56..ac2a8ec 100644
--- a/mythtv/libs/libmythbase/mythdb.h
+++ b/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 &_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 &bindings,
uint indent = 0, uint softMaxColumn = 80);
- static bool LoadDatabaseParamsFromDisk(DatabaseParams ¶ms);
- static bool ValidateDatabaseParams(
- const DatabaseParams ¶ms, const QString &source);
- static void LoadDefaultDatabaseParams(DatabaseParams ¶ms);
- static bool SaveDatabaseParamsToDisk(
- const DatabaseParams ¶ms, const QString &confdir, bool overwrite);
-
protected:
MythDB();
~MythDB();
diff --git a/mythtv/libs/libmythbase/mythdbparams.cpp b/mythtv/libs/libmythbase/mythdbparams.cpp
new file mode 100644
index 0000000..273804c
--- /dev/null
+++ b/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));
+}
diff --git a/mythtv/libs/libmythbase/mythdbparams.h b/mythtv/libs/libmythbase/mythdbparams.h
index a60f576..a6d349d 100644
--- a/mythtv/libs/libmythbase/mythdbparams.h
+++ b/mythtv/libs/libmythbase/mythdbparams.h
@@ -1,11 +1,23 @@
#ifndef MYTHDBPARAMS_H_
#define MYTHDBPARAMS_H_
+#include
+
#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
diff --git a/mythtv/libs/libmythbase/mythlocale.cpp b/mythtv/libs/libmythbase/mythlocale.cpp
index e22d55c..9142bb8 100644
--- a/mythtv/libs/libmythbase/mythlocale.cpp
+++ b/mythtv/libs/libmythbase/mythlocale.cpp
@@ -168,20 +168,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());
- }
}
}
diff --git a/mythtv/libs/libmythbase/mythtranslation.cpp b/mythtv/libs/libmythbase/mythtranslation.cpp
index 46adf08..6690cf9 100644
--- a/mythtv/libs/libmythbase/mythtranslation.cpp
+++ b/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";
}
diff --git a/mythtv/libs/libmythmetadata/parentalcontrols.cpp b/mythtv/libs/libmythmetadata/parentalcontrols.cpp
index 74b2054..124c832 100644
--- a/mythtv/libs/libmythmetadata/parentalcontrols.cpp
+++ b/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;
}
diff --git a/mythtv/libs/libmythui/myththemedmenu.cpp b/mythtv/libs/libmythui/myththemedmenu.cpp
index bfd5429..8b1f6fa 100644
--- a/mythtv/libs/libmythui/myththemedmenu.cpp
+++ b/mythtv/libs/libmythui/myththemedmenu.cpp
@@ -424,7 +424,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);
}
@@ -923,7 +922,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;
}
diff --git a/mythtv/libs/libmythupnp/configuration.cpp b/mythtv/libs/libmythupnp/configuration.cpp
index 1447355..6af7286 100644
--- a/mythtv/libs/libmythupnp/configuration.cpp
+++ b/mythtv/libs/libmythupnp/configuration.cpp
@@ -21,6 +21,8 @@
//
//////////////////////////////////////////////////////////////////////////////
+#include // for fsync
+
#include
#include
@@ -98,14 +100,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))
@@ -117,21 +120,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);
+ }
+
+ file.flush();
- m_config.save( ts, 2 );
+ 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;
}
//////////////////////////////////////////////////////////////////////////////
@@ -268,6 +296,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;
+ }
+ }
+}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@@ -335,3 +382,12 @@ void DBConfiguration::SetValue( const QString &sSetting, QString sValue )
{
GetMythDB()->SaveSetting( sSetting, sValue );
}
+
+//////////////////////////////////////////////////////////////////////////////
+//
+//////////////////////////////////////////////////////////////////////////////
+
+void DBConfiguration::ClearValue( const QString &sSetting )
+{
+ GetMythDB()->ClearSetting( sSetting );
+}
diff --git a/mythtv/libs/libmythupnp/configuration.h b/mythtv/libs/libmythupnp/configuration.h
index ee3f51e..4873fec 100644
--- a/mythtv/libs/libmythupnp/configuration.h
+++ b/mythtv/libs/libmythupnp/configuration.h
@@ -43,7 +43,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;
};
@@ -84,7 +84,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 );
};
//////////////////////////////////////////////////////////////////////////////
@@ -107,7 +107,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
diff --git a/mythtv/programs/mythbackend/mythsettings.cpp b/mythtv/programs/mythbackend/mythsettings.cpp
index 4b033cc..cfdebfa 100644
--- a/mythtv/programs/mythbackend/mythsettings.cpp
+++ b/mythtv/programs/mythbackend/mythsettings.cpp
@@ -355,15 +355,7 @@ QMap GetSettingsMap(MythSettingList &settings,
QMap 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 GetConfigFileSettingValues(void)
-{
- QMap 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 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 "
diff --git a/mythtv/programs/mythbackend/mythsettings.h b/mythtv/programs/mythbackend/mythsettings.h
index 43fa892..2c6f812 100644
--- a/mythtv/programs/mythbackend/mythsettings.h
+++ b/mythtv/programs/mythbackend/mythsettings.h
@@ -125,7 +125,6 @@ bool check_settings(MythSettingList &database_settings,
QStringList GetSettingValueList(const QString &type);
QString StringMapToJSON(const QMap &map);
QString StringListToJSON(const QString &key, const QStringList &sList);
-QMap GetConfigFileSettingValues();
QMap GetSettingsMap(MythSettingList &settings, const QString &hostname);
#endif
diff --git a/mythtv/programs/mythtv-setup/main.cpp b/mythtv/programs/mythtv-setup/main.cpp
index 266256a..2e82fdd 100644
--- a/mythtv/programs/mythtv-setup/main.cpp
+++ b/mythtv/programs/mythtv-setup/main.cpp
@@ -342,7 +342,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();
diff --git a/mythtv/programs/mythtv-setup/startprompt.cpp b/mythtv/programs/mythtv-setup/startprompt.cpp
index b49385a..e61cf12 100644
--- a/mythtv/programs/mythtv-setup/startprompt.cpp
+++ b/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)