File indexing completed on 2025-01-05 04:46:57
0001 /* 0002 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "dbconfig.h" 0010 0011 namespace Akonadi 0012 { 0013 namespace Server 0014 { 0015 class DbConfigSqlite : public DbConfig 0016 { 0017 public: 0018 /** 0019 * Constructs a new DbConfig for SQLite reading configuration from the standard akonadiserverrc config file. 0020 */ 0021 explicit DbConfigSqlite() = default; 0022 0023 /** 0024 * Constructs a new DbConfig for MySQL reading configuration from the @p configFile. 0025 */ 0026 explicit DbConfigSqlite(const QString &configFile); 0027 0028 /** 0029 * Returns the name of the used driver. 0030 */ 0031 QString driverName() const override; 0032 0033 /** 0034 * Returns the database name. 0035 */ 0036 QString databaseName() const override; 0037 0038 /** 0039 * Returns path to the database file or directory. 0040 */ 0041 QString databasePath() const override; 0042 0043 /** 0044 * Sets path to the database file or directory. 0045 */ 0046 void setDatabasePath(const QString &path, QSettings &settings) override; 0047 0048 /** 0049 * This method is called whenever the Akonadi server is started 0050 * and before the initial database connection is set up. 0051 * 0052 * At this point the default settings should be determined, merged 0053 * with the given @p settings and written back if @p storeSettings is true. 0054 */ 0055 bool init(QSettings &settings, bool storeSettings = true, const QString &dbPathOverride = {}) override; 0056 0057 /** 0058 * This method checks if the requirements for this database connection are met 0059 * in the system (QSQLITE driver is available, object can be initialized, etc.). 0060 */ 0061 bool isAvailable(QSettings &settings) override; 0062 0063 /** 0064 * This method applies the configured settings to the QtSql @p database 0065 * instance. 0066 */ 0067 void apply(QSqlDatabase &database) override; 0068 0069 /** 0070 * Returns whether an internal server needs to be used. 0071 */ 0072 bool useInternalServer() const override; 0073 0074 /** 0075 * Sets sqlite journal mode to WAL and synchronous mode to NORMAL 0076 */ 0077 void setup() override; 0078 0079 /// reimpl 0080 bool disableConstraintChecks(const QSqlDatabase &db) override; 0081 0082 /// reimpl 0083 bool enableConstraintChecks(const QSqlDatabase &db) override; 0084 0085 private: 0086 bool setPragma(QSqlDatabase &db, QSqlQuery &query, const QString &pragma); 0087 0088 QString mDatabaseName; 0089 QString mHostName; 0090 QString mUserName; 0091 QString mPassword; 0092 QString mConnectionOptions; 0093 }; 0094 0095 } // namespace Server 0096 } // namespace Akonadi