Akonadi

dbconfigmysql.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#include <QObject>
11#include <QProcess>
12
13class QSqlDatabase;
14
15namespace Akonadi
16{
17namespace Server
18{
19class DbConfigMysql : public QObject, public DbConfig
20{
22
23public:
24 /**
25 * Constructs a new DbConfig for MySQL reading configuration from the standard akonadiserverrc config file.
26 */
27 explicit DbConfigMysql() = default;
28 /**
29 * Constructs a new DbConfig for MySQL reading configuration from the @p configFile.
30 */
31 explicit DbConfigMysql(const QString &configFile);
32
33 /**
34 * Destructor.
35 */
36 ~DbConfigMysql() override;
37
38 /**
39 * Returns the name of the used driver.
40 */
41 QString driverName() const override;
42
43 /**
44 * Returns the database name.
45 */
46 QString databaseName() const override;
47
48 /**
49 * Returns path to the database file or directory.
50 */
51 QString databasePath() const override;
52
53 /**
54 * Sets path to the database file or directory.
55 */
56 void setDatabasePath(const QString &path, QSettings &settings) override;
57
58 /**
59 * This method is called whenever the Akonadi server is started
60 * and before the initial database connection is set up.
61 *
62 * At this point the default settings should be determined, merged
63 * with the given @p settings and written back if @p storeSettings is true.
64 */
65 bool init(QSettings &settings, bool storeSettings = true, const QString &dbPathOveride = {}) override;
66
67 /**
68 * This method checks if the requirements for this database connection are met
69 * in the system (QMYSQL driver is available, mysqld binary is found, etc.).
70 */
71 bool isAvailable(QSettings &settings) override;
72
73 /**
74 * This method applies the configured settings to the QtSql @p database
75 * instance.
76 */
77 void apply(QSqlDatabase &database) override;
78
79 /**
80 * Returns whether an internal server needs to be used.
81 */
82 bool useInternalServer() const override;
83
84 /**
85 * This method is called to start an external server.
86 */
87 bool startInternalServer() override;
88
89 /**
90 * This method is called to stop the external server.
91 */
92 void stopInternalServer() override;
93
94 /// reimpl
95 void initSession(const QSqlDatabase &database) override;
96
97 /// reimpl
98 bool disableConstraintChecks(const QSqlDatabase &db) override;
99
100 /// reimpl
101 bool enableConstraintChecks(const QSqlDatabase &db) override;
102
103private Q_SLOTS:
104 void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
105
106private:
107 int parseCommandLineToolsVersion() const;
108
109 bool initializeMariaDBDatabase(const QString &confFile, const QString &dataDir) const;
110 bool initializeMySQL5_7_6Database(const QString &confFile, const QString &dataDir) const;
111 bool initializeMySQLDatabase(const QString &confFile, const QString &dataDir) const;
112
113 QString mDatabaseName;
114 QString mHostName;
115 QString mUserName;
116 QString mPassword;
117 QString mConnectionOptions;
118 QString mDataDir;
119 QString mMysqldPath;
120 QString mCleanServerShutdownCommand;
121 QString mMysqlInstallDbPath;
122 QString mMysqlCheckPath;
123 QString mMysqlUpgradePath;
124 bool mInternalServer = true;
125 std::unique_ptr<QProcess> mDatabaseProcess;
126};
127
128} // namespace Server
129} // namespace Akonadi
Helper integration between Akonadi and Qt.
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:31:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.