Akonadi

dbconfig.h
1 /*
2  Copyright (c) 2010 Tobias Koenig <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #ifndef DBCONFIG_H
21 #define DBCONFIG_H
22 
23 #include <QSettings>
24 #include <QSqlDatabase>
25 
26 namespace Akonadi
27 {
28 namespace Server
29 {
30 
35 class DbConfig
36 {
37 public:
38 
39  virtual ~DbConfig();
40 
44  static bool isConfigured();
45 
50  static DbConfig *configuredDatabase();
51 
55  virtual QString driverName() const = 0;
56 
60  virtual QString databaseName() const = 0;
61 
69  virtual bool init(QSettings &settings) = 0;
70 
75  virtual void apply(QSqlDatabase &database) = 0;
76 
82  virtual void initSession(const QSqlDatabase &database);
83 
87  virtual bool useInternalServer() const = 0;
88 
92  virtual bool startInternalServer();
93 
97  virtual void stopInternalServer();
98 
104  virtual qint64 sizeThreshold() const;
105 
109  virtual void setup();
110 
111 protected:
112  DbConfig();
113 
119  static QString defaultDatabaseName();
120 
124  int execute(const QString &cmd, const QStringList &args) const;
125 private:
126  qint64 mSizeThreshold;
127 };
128 
129 } // namespace Server
130 } // namespace Akonadi
131 
132 #endif
static bool isConfigured()
Returns whether database have been configured.
Definition: dbconfig.cpp:60
static DbConfig * configuredDatabase()
Returns the DbConfig instance for the database the user has configured.
Definition: dbconfig.cpp:65
A base class that provides an unique access layer to configuration and initialization of different da...
Definition: dbconfig.h:35
virtual qint64 sizeThreshold() const
Payload data bigger than this value will be stored in separate files, instead of the database...
Definition: dbconfig.cpp:119
virtual bool startInternalServer()
This method is called to start an external server.
Definition: dbconfig.cpp:103
virtual void stopInternalServer()
This method is called to stop the external server.
Definition: dbconfig.cpp:109
virtual void setup()
This method is called to setup initial database settings after a connection is established.
Definition: dbconfig.cpp:114
virtual QString driverName() const =0
Returns the name of the used driver.
int execute(const QString &cmd, const QStringList &args) const
Calls QProcess::execute() and also prints the command and arguments via qCDebug() ...
Definition: dbconfig.cpp:138
virtual bool init(QSettings &settings)=0
This method is called whenever the Akonadi server is started and before the initial database connecti...
virtual QString databaseName() const =0
Returns the database name.
static QString defaultDatabaseName()
Returns the suggested default database name, if none is specified in the configuration already...
Definition: dbconfig.cpp:124
Helper integration between Akonadi and Qt.
virtual void apply(QSqlDatabase &database)=0
This method applies the configured settings to the QtSql database instance.
virtual bool useInternalServer() const =0
Returns whether an internal server needs to be used.
virtual void initSession(const QSqlDatabase &database)
Do session setup/initialization work on database.
Definition: dbconfig.cpp:133
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon May 25 2020 22:46:08 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.