Akonadi

dbconfigmysql.h
1 /*
2  SPDX-FileCopyrightText: 2010 Tobias Koenig <[email protected]>
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 
13 namespace Akonadi
14 {
15 namespace Server
16 {
17 class DbConfigMysql : public QObject, public DbConfig
18 {
19  Q_OBJECT
20 
21 public:
22  DbConfigMysql();
23 
24  /**
25  * Returns the name of the used driver.
26  */
27  QString driverName() const override;
28 
29  /**
30  * Returns the database name.
31  */
32  QString databaseName() const override;
33 
34  /**
35  * This method is called whenever the Akonadi server is started
36  * and before the initial database connection is set up.
37  *
38  * At this point the default settings should be determined, merged
39  * with the given @p settings and written back if @p storeSettings is true.
40  */
41  bool init(QSettings &settings, bool storeSettings = true) override;
42 
43  /**
44  * This method checks if the requirements for this database connection are met
45  * in the system (QMYSQL driver is available, mysqld binary is found, etc.).
46  */
47  bool isAvailable(QSettings &settings) override;
48 
49  /**
50  * This method applies the configured settings to the QtSql @p database
51  * instance.
52  */
53  void apply(QSqlDatabase &database) override;
54 
55  /**
56  * Returns whether an internal server needs to be used.
57  */
58  bool useInternalServer() const override;
59 
60  /**
61  * This method is called to start an external server.
62  */
63  bool startInternalServer() override;
64 
65  /**
66  * This method is called to stop the external server.
67  */
68  void stopInternalServer() override;
69 
70  /// reimpl
71  void initSession(const QSqlDatabase &database) override;
72 
73 private Q_SLOTS:
74  void processFinished(int exitCode, QProcess::ExitStatus exitStatus);
75 
76 private:
77  int parseCommandLineToolsVersion() const;
78 
79  bool initializeMariaDBDatabase(const QString &confFile, const QString &dataDir) const;
80  bool initializeMySQL5_7_6Database(const QString &confFile, const QString &dataDir) const;
81  bool initializeMySQLDatabase(const QString &confFile, const QString &dataDir) const;
82 
83  QString mDatabaseName;
84  QString mHostName;
85  QString mUserName;
86  QString mPassword;
87  QString mConnectionOptions;
88  QString mMysqldPath;
89  QString mCleanServerShutdownCommand;
90  QString mMysqlInstallDbPath;
91  QString mMysqlCheckPath;
92  bool mInternalServer;
93  QProcess *mDatabaseProcess = nullptr;
94 };
95 
96 } // namespace Server
97 } // namespace Akonadi
98 
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
KGuiItem apply()
QCA_EXPORT void init()
Helper integration between Akonadi and Qt.
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Jul 2 2022 06:41:47 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.