Akonadi

dbconfigsqlite.h
1/*
2 SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "dbconfig.h"
10
11namespace Akonadi
12{
13namespace Server
14{
15class DbConfigSqlite : public DbConfig
16{
17public:
18 /**
19 * Constructs a new DbConfig for SQLite reading configuration from the standard akonadiserverrc config file.
20 */
21 explicit DbConfigSqlite() = default;
22
23 /**
24 * Constructs a new DbConfig for MySQL reading configuration from the @p configFile.
25 */
26 explicit DbConfigSqlite(const QString &configFile);
27
28 /**
29 * Returns the name of the used driver.
30 */
31 QString driverName() const override;
32
33 /**
34 * Returns the database name.
35 */
36 QString databaseName() const override;
37
38 /**
39 * Returns path to the database file or directory.
40 */
41 QString databasePath() const override;
42
43 /**
44 * Sets path to the database file or directory.
45 */
46 void setDatabasePath(const QString &path, QSettings &settings) override;
47
48 /**
49 * This method is called whenever the Akonadi server is started
50 * and before the initial database connection is set up.
51 *
52 * At this point the default settings should be determined, merged
53 * with the given @p settings and written back if @p storeSettings is true.
54 */
55 bool init(QSettings &settings, bool storeSettings = true, const QString &dbPathOverride = {}) override;
56
57 /**
58 * This method checks if the requirements for this database connection are met
59 * in the system (QSQLITE driver is available, object can be initialized, etc.).
60 */
61 bool isAvailable(QSettings &settings) override;
62
63 /**
64 * This method applies the configured settings to the QtSql @p database
65 * instance.
66 */
67 void apply(QSqlDatabase &database) override;
68
69 /**
70 * Returns whether an internal server needs to be used.
71 */
72 bool useInternalServer() const override;
73
74 /**
75 * Sets sqlite journal mode to WAL and synchronous mode to NORMAL
76 */
77 void setup() override;
78
79 /// reimpl
80 bool disableConstraintChecks(const QSqlDatabase &db) override;
81
82 /// reimpl
83 bool enableConstraintChecks(const QSqlDatabase &db) override;
84
85private:
86 bool setPragma(QSqlDatabase &db, QSqlQuery &query, const QString &pragma);
87
88 QString mDatabaseName;
89 QString mHostName;
90 QString mUserName;
91 QString mPassword;
92 QString mConnectionOptions;
93};
94
95} // namespace Server
96} // namespace Akonadi
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.