KDED

kded.h
1 /*
2  This file is part of the KDE libraries
3  SPDX-FileCopyrightText: 1999 David Faure <[email protected]>
4  SPDX-FileCopyrightText: 1999 Waldo Bastian <[email protected]>
5 
6  SPDX-License-Identifier: LGPL-2.0-only
7 */
8 
9 #ifndef KDED_H
10 #define KDED_H
11 
12 #include <QHash>
13 #include <QObject>
14 #include <QSet>
15 #include <QString>
16 #include <QTimer>
17 
18 #include <QDBusAbstractAdaptor>
19 
20 #include <KDEDModule>
21 #include <ksycoca.h>
22 
23 class QDBusMessage;
25 class KPluginMetaData;
26 class KDirWatch;
27 
28 class Kded : public QObject
29 {
30  Q_OBJECT
31 public:
32  Kded();
33  virtual ~Kded();
34 
35  static Kded *self()
36  {
37  return _self;
38  }
39  static void messageFilter(const QDBusMessage &);
40 
41  void noDemandLoad(const QString &obj); // Don't load obj on demand
42 
43  QStringList loadedModules();
44  bool unloadModule(const QString &obj);
45  // bool isWindowRegistered(qlonglong windowId) const;
46  /**
47  * Applications can register/unregister their windows with kded modules.
48  * This allows kpasswdserver and kcookiejar to delete authentication
49  * and cookies that are local to a particular window when closing it.
50  */
51  //@{
52  /**
53  * Register a window with KDED
54  */
55  void registerWindowId(qlonglong windowId, const QString &sender);
56  /**
57  * Unregister a window previously registered with KDED
58  */
59  void unregisterWindowId(qlonglong windowId, const QString &sender);
60  //@}
61  void recreate(bool initial);
62  // TODO KF6 remove
63  void loadSecondPhase();
64 
65  //@{
66  /**
67  * Check if a module should be loaded on startup.
68  *
69  * @param module the name of the desktop file for the module, without the .desktop extension
70  * @return @c true if the module will be loaded at startup, @c false otherwise
71  */
72  bool isModuleAutoloaded(const QString &module) const;
73  //@}
74 
75  //@{
76  /**
77  * Check if a module is supported on the current QPA
78  */
79  bool platformSupportsModule(const KPluginMetaData &module) const;
80  //@}
81 
82  //@{
83  /**
84  * Check if a module should be loaded on demand
85  *
86  * @param module the name of the desktop file for the module, without the .desktop extension
87  * @return @c true if the module will be loaded when its D-Bus interface
88  * is requested, @c false otherwise
89  */
90  bool isModuleLoadedOnDemand(const QString &module) const;
91  //@}
92 
93  /**
94  * Configure whether a module should be loaded on startup
95  *
96  * If a module is set to be auto-loaded, it will be loaded at the start of a KDE
97  * session. Depending on the phase it is set to load in, it may also be loaded
98  * when the first KDE application is run outside of a KDE session.
99  *
100  * @param module the name of the desktop file for the module, without the .desktop extension
101  * @param autoload if @c true, the module will be loaded at startup,
102  * otherwise it will not
103  */
104  void setModuleAutoloading(const QString &module, bool autoload);
105 
106 public Q_SLOTS:
107  KDEDModule *loadModule(const QString &obj, bool onDemand);
108 
109  /**
110  * Loads / unloads modules according to config
111  */
112  void initModules();
113 
114  /**
115  * Recreate the database file
116  */
117  void recreate();
118 
119  /**
120  * Recreating finished
121  */
122  void recreateDone();
123 
124  /**
125  * Collect all directories to watch
126  */
127  void updateDirWatch();
128 
129  /**
130  * Update directories to watch
131  */
132  void updateResourceList();
133 
134  /**
135  * An application unregistered itself from DBus
136  */
137  void slotApplicationRemoved(const QString &);
138 
139  /**
140  * A KDEDModule is about to get destroyed.
141  */
142  void slotKDEDModuleRemoved(KDEDModule *);
143 
144 protected Q_SLOTS:
145 
146  /**
147  * @internal Triggers rebuilding
148  */
149  void dirDeleted(const QString &path);
150 
151  /**
152  * @internal Triggers rebuilding
153  */
154  void update(const QString &dir);
155 
156  void runDelayedCheck();
157 
158 protected:
159  /**
160  * Scans dir for new files and new subdirectories.
161  */
162  void readDirectory(const QString &dir);
163  /**
164  * Check if a module should be loaded on demand
165  *
166  * @param module a service description for the module
167  * @return @c true if the module will be loaded when its D-Bus interface
168  * is requested, @c false otherwise
169  */
170  bool isModuleLoadedOnDemand(const KPluginMetaData &module) const;
171 
172  /**
173  * Check if a module should be loaded on startup.
174  *
175  * @param module a service description for the module
176  * @return @c true if the module will be loaded at startup, @c false otherwise
177  */
178  bool isModuleAutoloaded(const KPluginMetaData &module) const;
179 
180  KDEDModule *loadModule(const KPluginMetaData &module, bool onDemand);
181 
182  QVector<KPluginMetaData> availableModules() const;
183  /**
184  * Pointer to the dirwatch class which tells us, when some directories
185  * changed.
186  * Slower polling for remote file systems is now done in KDirWatch (JW).
187  */
188  KDirWatch *m_pDirWatch;
189 
190  /**
191  * When a desktop file is updated, a timer is started (5 sec)
192  * before rebuilding the binary - so that multiple updates result
193  * in only one rebuilding.
194  */
195  QTimer *m_pTimer;
196 
198  // QHash<QString,KLibrary *> m_libs;
199  QHash<QString, QObject *> m_dontLoad;
200 
201  // window id tracking, with a QDBusServiceWatcher to remove them as needed
202  QDBusServiceWatcher *m_serviceWatcher;
203  QHash<QString, QList<qlonglong>> m_windowIdList;
204  QSet<long> m_globalWindowIdList;
205 
206  QStringList m_allResourceDirs;
207  bool m_needDelayedCheck;
208 
209  static Kded *_self;
210 };
211 
212 class KBuildsycocaAdaptor : public QDBusAbstractAdaptor
213 {
214  Q_OBJECT
215  Q_CLASSINFO("D-Bus Interface", "org.kde.kbuildsycoca")
216 public:
217  KBuildsycocaAdaptor(QObject *parent);
218 
219 public Q_SLOTS:
220  void recreate();
221  bool isTestModeEnabled();
222  void setTestModeEnabled();
223 };
224 
225 class KUpdateD : public QObject
226 {
227  Q_OBJECT
228 public:
229  KUpdateD();
230  ~KUpdateD();
231 
232 public Q_SLOTS:
233  void runKonfUpdate();
234  void slotNewUpdateFile(const QString &);
235 
236 private:
237  /**
238  * Pointer to the dirwatch class which tells us, when some directories
239  * changed.
240  * Slower polling for remote file systems is now done in KDirWatch (JW).
241  */
242  KDirWatch *m_pDirWatch;
243 
244  /**
245  * When a desktop file is updated, a timer is started (5 sec)
246  * before rebuilding the binary - so that multiple updates result
247  * in only one rebuilding.
248  */
249  QTimer *m_pTimer;
250 };
251 
252 #endif
KCMUTILS_EXPORT void unloadModule(const KCModuleInfo &mod)
KCMUTILS_EXPORT KCModule * loadModule(const KCModuleInfo &module, ErrorReporting report, QWidget *parent=nullptr, const QStringList &args=QStringList())
Q_OBJECTQ_OBJECT
void update(Part *part, const QByteArray &data, qint64 dataSize)
Q_SLOTSQ_SLOTS
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue May 11 2021 22:50:53 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.