From 6c5dfecc534c825a628221e0bc2f6fec2feafe7c Mon Sep 17 00:00:00 2001 From: Manuel Nickschas Date: Fri, 8 Feb 2008 21:41:04 +0000 Subject: [PATCH] Prevent the core from restoring its state if it is unconfigured. --- src/core/core.cpp | 45 +++++---------------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/src/core/core.cpp b/src/core/core.cpp index 32b34f53..e03543d7 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -64,14 +64,12 @@ void Core::init() { CoreSettings cs; - // TODO migrate old db settings - if(!(configured = initStorage(cs.storageSettings().toMap()))) { qWarning("Core is currently not configured!"); // try to migrate old settings QVariantMap old = cs.oldDbSettings().toMap(); - if(old.count() && old["Type"].toString() == "SQlite") { + if(old.count() && old["Type"].toString().toUpper() == "SQLITE") { QVariantMap newSettings; newSettings["Backend"] = "SQLite"; if((configured = initStorage(newSettings))) { @@ -106,6 +104,10 @@ void Core::saveState() { } void Core::restoreState() { + if(!instance()->configured) { + qWarning() << qPrintable(tr("Cannot restore a state for an unconfigured core!")); + return; + } if(instance()->sessions.count()) { qWarning() << qPrintable(tr("Calling restoreState() even though active sessions exist!")); return; @@ -402,43 +404,6 @@ void Core::clientDisconnected() { // Suggestion: kill sessions if they are not connected to any network and client. } -/* -void Core::processCoreSetup(QTcpSocket *socket, QVariantMap &msg) { - if(msg["HasSettings"].toBool()) { - QVariantMap auth; - auth["User"] = msg["User"]; - auth["Password"] = msg["Password"]; - msg.remove("User"); - msg.remove("Password"); - qDebug() << "Initializing storage provider" << msg["Type"].toString(); - - if(!initStorage(msg, true)) { - // notify client to start wizard again - qWarning("Core is currently not configured!"); - QVariantMap reply; - reply["StartWizard"] = true; - reply["StorageProviders"] = availableStorageProviders(); - SignalProxy::writeDataToDevice(socket, reply); - } else { - // write coresettings - CoreSettings s; - s.setDatabaseSettings(msg); - // write admin user to database & make the core listen again to connections - storage->addUser(auth["User"].toString(), auth["Password"].toString()); - startListening(); - // continue the normal procedure - //processClientInit(socket, auth); - } - } else { - // notify client to start wizard - QVariantMap reply; - reply["StartWizard"] = true; - reply["StorageProviders"] = availableStorageProviders(); - SignalProxy::writeDataToDevice(socket, reply); - } -} -*/ - void Core::setupClientSession(QTcpSocket *socket, UserId uid) { // Find or create session for validated user SessionThread *sess; -- 2.20.1