1 | /* |
2 | This file is part of the KDE libraries |
3 | |
4 | SPDX-FileCopyrightText: 2001 Waldo Bastian <bastian@kde.org> |
5 | |
6 | SPDX-License-Identifier: LGPL-2.0-or-later |
7 | |
8 | */ |
9 | #ifndef __KDEDMODULE_H__ |
10 | #define __KDEDMODULE_H__ |
11 | |
12 | #include <kdbusaddons_export.h> |
13 | |
14 | #include <QObject> |
15 | #include <memory> |
16 | |
17 | class KDEDModulePrivate; |
18 | class Kded; |
19 | |
20 | class QDBusObjectPath; |
21 | class QDBusMessage; |
22 | |
23 | /*! |
24 | * \class KDEDModule |
25 | * \inmodule KDBusAddons |
26 | * \brief The base class for KDED modules. |
27 | * |
28 | * KDED modules are constructed as shared libraries that are loaded on-demand |
29 | * into the kded daemon at runtime. |
30 | * |
31 | * See https://invent.kde.org/frameworks/kded/-/blob/master/docs/HOWTO |
32 | * for documentation about writing kded modules. |
33 | */ |
34 | class KDBUSADDONS_EXPORT KDEDModule : public QObject |
35 | { |
36 | Q_OBJECT |
37 | Q_CLASSINFO("D-Bus Interface" , "org.kde.KDEDModule" ) |
38 | |
39 | friend class Kded; |
40 | |
41 | public: |
42 | /*! |
43 | * \brief Creates a new kded module with the given \a parent. |
44 | */ |
45 | explicit KDEDModule(QObject *parent = nullptr); |
46 | |
47 | ~KDEDModule() override; |
48 | |
49 | /*! |
50 | * Sets the \a name of the module, and uses it to register the module to D-Bus. |
51 | * |
52 | * For modules loaded as plugins by a daemon, this is called automatically |
53 | * by the daemon after loading the module. Module authors should NOT call this. |
54 | */ |
55 | void setModuleName(const QString &name); |
56 | |
57 | /*! |
58 | * The name of the module used to register to D-Bus. |
59 | */ |
60 | QString moduleName() const; |
61 | |
62 | /*! |
63 | * Returns the module being called by this D-Bus \a message. |
64 | * |
65 | * Useful for autoloading modules in kded and similar daemons. |
66 | * \since 5.7 |
67 | */ |
68 | static QString moduleForMessage(const QDBusMessage &message); |
69 | |
70 | Q_SIGNALS: |
71 | /*! |
72 | * Emitted when a mainwindow with the specified \a windowId registers itself. |
73 | */ |
74 | void windowRegistered(qlonglong windowId); |
75 | |
76 | /*! |
77 | * Emitted when a mainwindow with the specified \a windowId unregisters itself. |
78 | */ |
79 | void windowUnregistered(qlonglong windowId); |
80 | |
81 | /*! |
82 | * Emitted after the module is registered successfully with D-Bus under the specified D-Bus object \a path. |
83 | * \since 4.2 |
84 | */ |
85 | void moduleRegistered(const QDBusObjectPath &path); |
86 | |
87 | private: |
88 | std::unique_ptr<KDEDModulePrivate> const d; |
89 | }; |
90 | |
91 | #endif |
92 | |