File indexing completed on 2025-01-19 03:53:32
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2007-03-18 0007 * Description : Core database access wrapper. 0008 * 0009 * SPDX-FileCopyrightText: 2016 by Swati Lodha <swatilodha27 at gmail dot com> 0010 * 0011 * SPDX-License-Identifier: GPL-2.0-or-later 0012 * 0013 * ============================================================ */ 0014 0015 #include "dbengineaccess.h" 0016 0017 // Qt includes 0018 0019 #include <QEventLoop> 0020 #include <QMutex> 0021 #include <QSqlDatabase> 0022 #include <QUuid> 0023 0024 // KDE includes 0025 0026 #include <klocalizedstring.h> 0027 0028 // Local includes 0029 0030 #include "digikam_debug.h" 0031 #include "dbengineparameters.h" 0032 #include "dbenginebackend.h" 0033 #include "dbengineerrorhandler.h" 0034 0035 namespace Digikam 0036 { 0037 0038 bool DbEngineAccess::checkReadyForUse(QString& error) 0039 { 0040 QStringList drivers = QSqlDatabase::drivers(); 0041 0042 // Retrieving DB settings from config file 0043 0044 DbEngineParameters internalServerParameters = DbEngineParameters::parametersFromConfig(); 0045 0046 // Checking for QSQLITE driver 0047 0048 if (internalServerParameters.SQLiteDatabaseType() == QLatin1String("QSQLITE")) 0049 { 0050 if (!drivers.contains(QLatin1String("QSQLITE"))) 0051 { 0052 qCDebug(DIGIKAM_COREDB_LOG) << "Core database: no Sqlite3 driver available.\n" 0053 "List of QSqlDatabase drivers: " << drivers; 0054 0055 error = i18n("The driver \"SQLITE\" for Sqlite3 databases is not available.\n" 0056 "digiKam depends on the drivers provided by the Qt::SQL module."); 0057 return false; 0058 } 0059 } 0060 0061 // Checking for QMYSQL driver 0062 0063 else if (internalServerParameters.MySQLDatabaseType() == QLatin1String("QMYSQL")) 0064 { 0065 if (!drivers.contains(QLatin1String("QMYSQL"))) 0066 { 0067 qCDebug(DIGIKAM_COREDB_LOG) << "Core database: no MySQL driver available.\n" 0068 "List of QSqlDatabase drivers: " << drivers; 0069 0070 error = i18n("The driver \"MYSQL\" for MySQL databases is not available.\n" 0071 "digiKam depends on the drivers provided by the Qt::SQL module."); 0072 return false; 0073 } 0074 } 0075 else 0076 { 0077 qCDebug(DIGIKAM_COREDB_LOG) << "Database could not be found"; 0078 error = QLatin1String("No valid database type available."); 0079 return false; 0080 } 0081 0082 return true; 0083 } 0084 0085 } // namespace Digikam