Akonadi

dbconfigpostgresql.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 
11 #include <optional>
12 
13 namespace Akonadi
14 {
15 namespace Server
16 {
17 class DbConfigPostgresql : public DbConfig
18 {
19 public:
20  DbConfigPostgresql();
21 
22  /**
23  * Returns the name of the used driver.
24  */
25  QString driverName() const override;
26 
27  /**
28  * Returns the database name.
29  */
30  QString databaseName() const override;
31 
32  /**
33  * This method is called whenever the Akonadi server is started
34  * and before the initial database connection is set up.
35  *
36  * At this point the default settings should be determined, merged
37  * with the given @p settings and written back if @p storeSettings is true.
38  */
39  bool init(QSettings &settings, bool storeSettings = true) override;
40 
41  /**
42  * This method checks if the requirements for this database connection are
43  * met in the system (QPOSTGRESQL driver is available, postgresql binary is
44  * found, etc.).
45  */
46  bool isAvailable(QSettings &settings) override;
47 
48  /**
49  * This method applies the configured settings to the QtSql @p database
50  * instance.
51  */
52  void apply(QSqlDatabase &database) override;
53 
54  /**
55  * Returns whether an internal server needs to be used.
56  */
57  bool useInternalServer() const override;
58 
59  /**
60  * This method is called to start an external server.
61  */
62  bool startInternalServer() override;
63 
64  /**
65  * This method is called to stop the external server.
66  */
67  void stopInternalServer() override;
68 
69 protected:
70  QStringList postgresSearchPaths(const QString &versionedPath) const;
71 
72 private:
73  struct Versions {
74  int clusterVersion = 0;
75  int pgServerVersion = 0;
76  };
77  std::optional<Versions> checkPgVersion() const;
78  bool upgradeCluster(int clusterVersion);
79  bool runInitDb(const QString &dbDataPath);
80 
81  bool checkServerIsRunning();
82 
83  QString mDatabaseName;
84  QString mHostName;
85  int mHostPort;
86  QString mUserName;
87  QString mPassword;
88  QString mConnectionOptions;
89  QString mServerPath;
90  QString mInitDbPath;
91  QString mPgData;
92  QString mPgUpgradePath;
93  bool mInternalServer;
94 };
95 
96 } // namespace Server
97 } // namespace Akonadi
98 
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 Jun 25 2022 06:00:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.