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 QDBUSSERVICEWATCHER_H |
5 | #define QDBUSSERVICEWATCHER_H |
6 | |
7 | #include <QtCore/QObject> |
8 | #include <QtCore/qcontainerfwd.h> // Q(String)List |
9 | #include <QtDBus/qtdbusglobal.h> |
10 | |
11 | #if !defined(QT_NO_DBUS) && !defined(QT_NO_QOBJECT) |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QString; |
16 | template<typename T> |
17 | class QBindable; |
18 | |
19 | class QDBusConnection; |
20 | |
21 | class QDBusServiceWatcherPrivate; |
22 | class Q_DBUS_EXPORT QDBusServiceWatcher: public QObject |
23 | { |
24 | Q_OBJECT |
25 | Q_PROPERTY(QStringList watchedServices READ watchedServices WRITE setWatchedServices |
26 | BINDABLE bindableWatchedServices) |
27 | Q_PROPERTY(WatchMode watchMode READ watchMode WRITE setWatchMode BINDABLE bindableWatchMode) |
28 | public: |
29 | enum WatchModeFlag { |
30 | WatchForRegistration = 0x01, |
31 | WatchForUnregistration = 0x02, |
32 | WatchForOwnerChange = 0x03 |
33 | }; |
34 | Q_DECLARE_FLAGS(WatchMode, WatchModeFlag) |
35 | Q_FLAG(WatchMode) |
36 | |
37 | explicit QDBusServiceWatcher(QObject *parent = nullptr); |
38 | QDBusServiceWatcher(const QString &service, const QDBusConnection &connection, |
39 | WatchMode watchMode = WatchForOwnerChange, QObject *parent = nullptr); |
40 | ~QDBusServiceWatcher(); |
41 | |
42 | QStringList watchedServices() const; |
43 | void setWatchedServices(const QStringList &services); |
44 | void addWatchedService(const QString &newService); |
45 | bool removeWatchedService(const QString &service); |
46 | QBindable<QStringList> bindableWatchedServices(); |
47 | |
48 | WatchMode watchMode() const; |
49 | void setWatchMode(WatchMode mode); |
50 | QBindable<WatchMode> bindableWatchMode(); |
51 | |
52 | QDBusConnection connection() const; |
53 | void setConnection(const QDBusConnection &connection); |
54 | |
55 | Q_SIGNALS: |
56 | void serviceRegistered(const QString &service); |
57 | void serviceUnregistered(const QString &service); |
58 | void serviceOwnerChanged(const QString &service, const QString &oldOwner, const QString &newOwner); |
59 | |
60 | private: |
61 | Q_PRIVATE_SLOT(d_func(), void _q_serviceOwnerChanged(QString,QString,QString)) |
62 | Q_DISABLE_COPY(QDBusServiceWatcher) |
63 | Q_DECLARE_PRIVATE(QDBusServiceWatcher) |
64 | }; |
65 | |
66 | Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusServiceWatcher::WatchMode) |
67 | |
68 | QT_END_NAMESPACE |
69 | |
70 | #endif // QT_NO_DBUS || QT_NO_QOBJECT |
71 | #endif // QDBUSSERVICEWATCHER_H |
72 | |