1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QDBUSCONNECTIONINTERFACE_H |
5 | #define QDBUSCONNECTIONINTERFACE_H |
6 | |
7 | #include <QtDBus/qtdbusglobal.h> |
8 | #include <QtCore/qstringlist.h> |
9 | |
10 | #include <QtDBus/qdbusabstractinterface.h> |
11 | #include <QtDBus/qdbusreply.h> |
12 | |
13 | #ifndef QT_NO_DBUS |
14 | |
15 | QT_BEGIN_NAMESPACE |
16 | |
17 | |
18 | class QDBusConnection; |
19 | class QString; |
20 | class QByteArray; |
21 | |
22 | /* |
23 | * Proxy class for interface org.freedesktop.DBus |
24 | */ |
25 | class Q_DBUS_EXPORT QDBusConnectionInterface: public QDBusAbstractInterface |
26 | { |
27 | Q_OBJECT |
28 | friend class QDBusConnectionPrivate; |
29 | static inline const char *staticInterfaceName(); |
30 | |
31 | explicit QDBusConnectionInterface(const QDBusConnection &connection, QObject *parent); |
32 | ~QDBusConnectionInterface(); |
33 | |
34 | Q_PROPERTY(QDBusReply<QStringList> registeredServiceNames READ registeredServiceNames) |
35 | Q_PROPERTY(QDBusReply<QStringList> activatableServiceNames READ activatableServiceNames) |
36 | |
37 | public: |
38 | enum ServiceQueueOptions { |
39 | DontQueueService, |
40 | QueueService, |
41 | ReplaceExistingService |
42 | }; |
43 | Q_ENUM(ServiceQueueOptions) |
44 | enum ServiceReplacementOptions { |
45 | DontAllowReplacement, |
46 | AllowReplacement |
47 | }; |
48 | Q_ENUM(ServiceReplacementOptions) |
49 | enum RegisterServiceReply { |
50 | ServiceNotRegistered = 0, |
51 | ServiceRegistered, |
52 | ServiceQueued |
53 | }; |
54 | Q_ENUM(RegisterServiceReply) |
55 | |
56 | public Q_SLOTS: |
57 | QDBusReply<QStringList> registeredServiceNames() const; |
58 | QDBusReply<QStringList> activatableServiceNames() const; |
59 | QDBusReply<bool> isServiceRegistered(const QString &serviceName) const; |
60 | QDBusReply<QString> serviceOwner(const QString &name) const; |
61 | QDBusReply<bool> unregisterService(const QString &serviceName); |
62 | QDBusReply<QDBusConnectionInterface::RegisterServiceReply> registerService(const QString &serviceName, |
63 | ServiceQueueOptions qoption = DontQueueService, |
64 | ServiceReplacementOptions roption = DontAllowReplacement); |
65 | |
66 | QDBusReply<uint> servicePid(const QString &serviceName) const; |
67 | QDBusReply<uint> serviceUid(const QString &serviceName) const; |
68 | |
69 | QDBusReply<void> startService(const QString &name); |
70 | |
71 | Q_SIGNALS: |
72 | void serviceRegistered(const QString &service); |
73 | void serviceUnregistered(const QString &service); |
74 | void serviceOwnerChanged(const QString &name, const QString &oldOwner, const QString &newOwner); |
75 | void callWithCallbackFailed(const QDBusError &error, const QDBusMessage &call); |
76 | |
77 | #ifndef Q_QDOC |
78 | // internal signals |
79 | // do not use |
80 | void NameAcquired(const QString &); |
81 | void NameLost(const QString &); |
82 | void NameOwnerChanged(const QString &, const QString &, const QString &); |
83 | protected: |
84 | void connectNotify(const QMetaMethod &) override; |
85 | void disconnectNotify(const QMetaMethod &) override; |
86 | #endif |
87 | }; |
88 | |
89 | QT_END_NAMESPACE |
90 | |
91 | Q_DECLARE_BUILTIN_METATYPE(UInt, QMetaType::UInt, QDBusConnectionInterface::RegisterServiceReply) |
92 | |
93 | #endif // QT_NO_DBUS |
94 | #endif |
95 | |