1 /* ============================================================ 2 * 3 * This file is a part of digiKam project 4 * https://www.digikam.org 5 * 6 * Date : 2007-03-18 7 * Description : Core database access wrapper. 8 * 9 * Copyright (C) 2016 by Swati Lodha <swatilodha27 at gmail dot com> 10 * 11 * This program is free software; you can redistribute it 12 * and/or modify it under the terms of the GNU General 13 * Public License as published by the Free Software Foundation; 14 * either version 2, or (at your option) 15 * any later version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * ============================================================ */ 23 24 #include "dbengineaccess.h" 25 26 // Qt includes 27 28 #include <QEventLoop> 29 #include <QMutex> 30 #include <QSqlDatabase> 31 #include <QUuid> 32 33 // KDE includes 34 35 #include <klocalizedstring.h> 36 37 // Local includes 38 39 #include "digikam_debug.h" 40 #include "dbengineparameters.h" 41 #include "dbenginebackend.h" 42 #include "dbengineerrorhandler.h" 43 44 namespace Digikam 45 { 46 checkReadyForUse(QString & error)47bool DbEngineAccess::checkReadyForUse(QString& error) 48 { 49 QStringList drivers = QSqlDatabase::drivers(); 50 51 // Retrieving DB settings from config file 52 53 DbEngineParameters internalServerParameters = DbEngineParameters::parametersFromConfig(); 54 55 // Checking for QSQLITE driver 56 57 if (internalServerParameters.SQLiteDatabaseType() == QLatin1String("QSQLITE")) 58 { 59 if (!drivers.contains(QLatin1String("QSQLITE"))) 60 { 61 qCDebug(DIGIKAM_COREDB_LOG) << "Core database: no Sqlite3 driver available.\n" 62 "List of QSqlDatabase drivers: " << drivers; 63 64 error = i18n("The driver \"SQLITE\" for Sqlite3 databases is not available.\n" 65 "digiKam depends on the drivers provided by the Qt::SQL module."); 66 return false; 67 } 68 } 69 70 // Checking for QMYSQL driver 71 72 else if (internalServerParameters.MySQLDatabaseType() == QLatin1String("QMYSQL")) 73 { 74 if (!drivers.contains(QLatin1String("QMYSQL"))) 75 { 76 qCDebug(DIGIKAM_COREDB_LOG) << "Core database: no MySQL driver available.\n" 77 "List of QSqlDatabase drivers: " << drivers; 78 79 error = i18n("The driver \"MYSQL\" for MySQL databases is not available.\n" 80 "digiKam depends on the drivers provided by the Qt::SQL module."); 81 return false; 82 } 83 } 84 else 85 { 86 qCDebug(DIGIKAM_COREDB_LOG) << "Database could not be found"; 87 error = QLatin1String("No valid database type available."); 88 return false; 89 } 90 91 return true; 92 } 93 94 } // namespace Digikam 95