digiKam
coredbwatch.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 : 2007-03-23
7  * Description : Core database image properties synchronizer
8  *
9  * Copyright (C) 2007-2009 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de>
10  * Copyright (C) 2009-2022 by Gilles Caulier <caulier dot gilles at gmail dot com>
11  *
12  * This program is free software; you can redistribute it
13  * and/or modify it under the terms of the GNU General
14  * Public License as published by the Free Software Foundation;
15  * either version 2, or (at your option)
16  * any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * ============================================================ */
24 
25 #ifndef DIGIKAM_CORE_DB_WATCH_H
26 #define DIGIKAM_CORE_DB_WATCH_H
27 
28 #include "digikam_config.h"
29 
30 // Qt includes
31 
32 #include <QObject>
33 #include <QThread>
34 
35 // Local includes
36 
37 #include "digikam_export.h"
38 #include "coredbchangesets.h"
39 
40 namespace Digikam
41 {
42 
43 class DIGIKAM_DATABASE_EXPORT CoreDbWatch : public QObject
44 {
45  Q_OBJECT
46 
47 public:
48 
50  {
52  DatabaseSlave
53  };
54 
55 public:
56 
57  CoreDbWatch();
58 
59  void initializeRemote(DatabaseMode mode);
60  void doAnyProcessing();
61  void setDatabaseIdentifier(const QString& identifier);
62  void setApplicationIdentifier(const QString& identifier);
63 
65 
66  void sendDatabaseChanged();
67 
68  void sendImageChange(const ImageChangeset& changeset);
69  void sendImageTagChange(const ImageTagChangeset& changeset);
70  void sendCollectionImageChange(const CollectionImageChangeset& changeset);
71  void sendAlbumChange(const AlbumChangeset& changeset);
72  void sendTagChange(const TagChangeset& changeset);
73  void sendAlbumRootChange(const AlbumRootChangeset& changeset);
74  void sendSearchChange(const SearchChangeset& changeset);
75 
76 Q_SIGNALS:
77 
88 
93  void imageChange(const ImageChangeset& changeset);
94  void imageTagChange(const ImageTagChangeset& changeset);
96  void albumChange(const AlbumChangeset& changeset);
97  void tagChange(const TagChangeset& changeset);
98  void albumRootChange(const AlbumRootChangeset& changeset);
99  void searchChange(const SearchChangeset& changeset);
100 
101 protected:
102 
103  ~CoreDbWatch() override;
104 
105 #ifdef HAVE_DBUS
106 
107 protected Q_SLOTS:
108 
109  // NOTE: The full qualification with "Digikam::" for the changeset types in the following
110  // signals and slots are required to make moc pick them up.
111  // If moc does not get the namespace in its literal, DBus connections will silently break.
112 
114  void slotImageChangeDBus(const QString& databaseIdentifier,
115  const QString& applicationIdentifier,
116  const Digikam::ImageChangeset& changeset);
117  void slotImageTagChangeDBus(const QString& databaseIdentifier,
118  const QString& applicationIdentifier,
119  const Digikam::ImageTagChangeset& changeset);
120  void slotCollectionImageChangeDBus(const QString& databaseIdentifier,
121  const QString& applicationIdentifier,
122  const Digikam::CollectionImageChangeset& changeset);
123  void slotAlbumChangeDBus(const QString& databaseIdentifier,
124  const QString& applicationIdentifier,
125  const Digikam::AlbumChangeset& changeset);
126  void slotTagChangeDBus(const QString& databaseIdentifier,
127  const QString& applicationIdentifier,
128  const Digikam::TagChangeset& changeset);
129  void slotAlbumRootChangeDBus(const QString& databaseIdentifier,
130  const QString& applicationIdentifier,
131  const Digikam::AlbumRootChangeset& changeset);
132  void slotSearchChangeDBus(const QString& databaseIdentifier,
133  const QString& applicationIdentifier,
134  const Digikam::SearchChangeset& changeset);
135 
136 Q_SIGNALS:
137 
139  void signalImageChangeDBus(const QString& databaseIdentifier,
140  const QString& applicationIdentifier,
141  const Digikam::ImageChangeset& changeset);
142  void signalImageTagChangeDBus(const QString& databaseIdentifier,
143  const QString& applicationIdentifier,
144  const Digikam::ImageTagChangeset& changeset);
145  void signalCollectionImageChangeDBus(const QString& databaseIdentifier,
146  const QString& applicationIdentifier,
147  const Digikam::CollectionImageChangeset& changeset);
148  void signalAlbumChangeDBus(const QString& databaseIdentifier,
149  const QString& applicationIdentifier,
150  const Digikam::AlbumChangeset& changeset);
151  void signalTagChangeDBus(const QString& databaseIdentifier,
152  const QString& applicationIdentifier,
153  const Digikam::TagChangeset& changeset);
154  void signalAlbumRootChangeDBus(const QString& databaseIdentifier,
155  const QString& applicationIdentifier,
156  const Digikam::AlbumRootChangeset& changeset);
157  void signalSearchChangeDBus(const QString& databaseIdentifier,
158  const QString& applicationIdentifier,
159  const Digikam::SearchChangeset& changeset);
160 #endif
161 
162 public:
163 
164  class Private;
165 
166 private:
167 
168  // Disabled
169  explicit CoreDbWatch(QObject*) = delete;
170 
171  Private* const d;
172 };
173 
174 #ifdef HAVE_DBUS
175 
176 // ------------------------------------------------------------------------------------
177 
178 class DBusSignalListenerThread : public QThread
179 {
180  Q_OBJECT
181 
182 public:
183 
184  explicit DBusSignalListenerThread(CoreDbWatch* const qq, CoreDbWatch::Private* const dd);
185  ~DBusSignalListenerThread() override;
186 
187  void run() override;
188 
189 private:
190 
191  CoreDbWatch* q;
192  CoreDbWatch::Private* d;
193 };
194 
195 #endif
196 
197 } // namespace Digikam
198 
199 #endif // DIGIKAM_CORE_DB_WATCH_H
Definition: coredbchangesets.h:262
Definition: coredbchangesets.h:337
Definition: coredbchangesets.h:152
Definition: coredbwatch.h:44
void searchChange(const SearchChangeset &changeset)
void albumChange(const AlbumChangeset &changeset)
void collectionImageChange(const CollectionImageChangeset &changeset)
void tagChange(const TagChangeset &changeset)
void albumRootChange(const AlbumRootChangeset &changeset)
DatabaseMode
Definition: coredbwatch.h:50
@ DatabaseMaster
Definition: coredbwatch.h:51
void imageChange(const ImageChangeset &changeset)
void imageTagChange(const ImageTagChangeset &changeset)
Definition: coredbchangesets.h:48
Definition: coredbchangesets.h:80
Definition: coredbchangesets.h:372
Definition: coredbchangesets.h:298
Definition: datefolderview.cpp:43