digiKam
databaseserver.h
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of digiKam project
4  * https://www.digikam.org
5  *
6  * Date : 2009-11-14
7  * Description : Mysql internal database server
8  *
9  * Copyright (C) 2009-2011 by Holger Foerster <Hamsi2k at freenet dot de>
10  * Copyright (C) 2010-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  * Copyright (C) 2016 by Swati Lodha <swatilodha27 at gmail dot com>
12  *
13  * This program is free software; you can redistribute it
14  * and/or modify it under the terms of the GNU General
15  * Public License as published by the Free Software Foundation;
16  * either version 2, or (at your option)
17  * any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * ============================================================ */
25 
26 #ifndef DIGIKAM_DATABASE_SERVER_H
27 #define DIGIKAM_DATABASE_SERVER_H
28 
29 // QT includes
30 
31 #include <QProcess>
32 #include <QThread>
33 #include <QString>
34 
35 // Local includes
36 
37 #include "databaseservererror.h"
38 #include "databaseserverstarter.h"
39 #include "dbengineparameters.h"
40 #include "digikam_export.h"
41 
42 class QCoreApplication;
43 
44 namespace Digikam
45 {
46 
47 class DIGIKAM_EXPORT DatabaseServer : public QThread
48 {
49  Q_OBJECT
50 
51 public:
52 
54  {
58  stopped
59  };
61 
62 public:
63 
64  explicit DatabaseServer(const DbEngineParameters& params,
66  ~DatabaseServer() override;
67 
71  DatabaseServerError startDatabaseProcess();
72 
76  void stopDatabaseProcess();
77 
81  bool isRunning() const;
82 
83 Q_SIGNALS:
84 
85  void done();
86 
87 protected:
88 
89  void run() override;
90 
91 private:
92 
96  DatabaseServerError startMysqlDatabaseProcess();
97 
102  DatabaseServerError checkDatabaseDirs() const;
103 
108  DatabaseServerError initMysqlConfig() const;
109 
113  bool checkAndRemoveMysqlLogs() const;
114 
118  DatabaseServerError createMysqlFiles() const;
119 
123  DatabaseServerError startMysqlServer();
124 
128  DatabaseServerError initMysqlDatabase() const;
129 
133  DatabaseServerError upgradeMysqlDatabase();
134 
138  QString getcurrentAccountUserName() const;
139 
143  QString processErrorLog(QProcess* const process, const QString& msg) const;
144 
145 private:
146 
147  class Private;
148  Private* const d;
149 };
150 
151 } // namespace Digikam
152 
153 #endif // DIGIKAM_DATABASE_SERVER_H
Definition: databaseservererror.h:41
Definition: databaseserverstarter.h:42
static DatabaseServerStarter * instance()
Definition: databaseserverstarter.cpp:85
Definition: databaseserver.h:48
DatabaseServerStateEnum databaseServerStateEnum
Definition: databaseserver.h:60
DatabaseServerStateEnum
Definition: databaseserver.h:54
@ notRunning
Definition: databaseserver.h:57
@ running
Definition: databaseserver.h:56
@ started
Definition: databaseserver.h:55
Definition: dbengineparameters.h:49
Definition: datefolderview.cpp:43