X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fcore%2Fabstractsqlstorage.cpp;h=7e5dee59b5fcbc3b50c3db58923ac50ca617fc1b;hp=ccbc6bd97bd4472fc3e86599ec94e47cdd7fa428;hb=7c9c1b348382b8b77f96a883945c522d32a478d5;hpb=de6fd75928284a7c8788e00a36e5de7e64b9e168 diff --git a/src/core/abstractsqlstorage.cpp b/src/core/abstractsqlstorage.cpp index ccbc6bd9..7e5dee59 100644 --- a/src/core/abstractsqlstorage.cpp +++ b/src/core/abstractsqlstorage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-07 by the Quassel IRC Team * + * Copyright (C) 2005-07 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -83,36 +83,39 @@ void AbstractSqlStorage::addConnectionToPool() { } } -bool AbstractSqlStorage::init(const QVariantMap &settings) { +Storage::State AbstractSqlStorage::init(const QVariantMap &settings) { Q_UNUSED(settings) + QSqlDatabase db = logDb(); if(!db.isValid() || !db.isOpen()) - return false; + return NotAvailable; if(installedSchemaVersion() == -1) { qCritical() << "Storage Schema is missing!"; - return false; + return NeedsSetup; } if(installedSchemaVersion() > schemaVersion()) { qCritical() << "Installed Schema is newer then any known Version."; - return false; + return NotAvailable; } - + if(installedSchemaVersion() < schemaVersion()) { qWarning() << qPrintable(tr("Installed Schema (version %1) is not up to date. Upgrading to version %2...").arg(installedSchemaVersion()).arg(schemaVersion())); - if(!upgradeDb()) - return false; + if(!upgradeDb()) { + qWarning() << qPrintable(tr("Upgrade failed...")); + return NotAvailable; + } } - + quInfo() << "Storage Backend is ready. Quassel Schema Version:" << installedSchemaVersion(); - return true; + return IsReady; } QString AbstractSqlStorage::queryString(const QString &queryName, int version) { if(version == 0) version = schemaVersion(); - + QFileInfo queryInfo(QString(":/SQL/%1/%2/%3.sql").arg(displayName()).arg(version).arg(queryName)); if(!queryInfo.exists() || !queryInfo.isFile() || !queryInfo.isReadable()) { qCritical() << "Unable to read SQL-Query" << queryName << "for engine" << displayName(); @@ -124,7 +127,7 @@ QString AbstractSqlStorage::queryString(const QString &queryName, int version) { return QString(); QString query = QTextStream(&queryFile).readAll(); queryFile.close(); - + return query.trimmed(); } @@ -152,7 +155,7 @@ bool AbstractSqlStorage::setup(const QVariantMap &settings) { return false; } } - return true; + return setupSchemaVersion(schemaVersion()); } QStringList AbstractSqlStorage::upgradeQueries(int version) { @@ -179,7 +182,7 @@ bool AbstractSqlStorage::upgradeDb() { } } } - return true; + return updateSchemaVersion(schemaVersion()); } @@ -219,7 +222,7 @@ bool AbstractSqlStorage::watchQuery(QSqlQuery &query) { qCritical() << " Error Message:" << query.lastError().text(); qCritical() << " Driver Message:" << query.lastError().driverText(); qCritical() << " DB Message:" << query.lastError().databaseText(); - + return false; } return true;