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 QDBUSPENDINGCALL_H |
5 | #define QDBUSPENDINGCALL_H |
6 | |
7 | #include <QtDBus/qtdbusglobal.h> |
8 | #include <QtDBus/qdbusmessage.h> |
9 | #include <QtCore/qobject.h> |
10 | #include <QtCore/qshareddata.h> |
11 | |
12 | #ifndef QT_NO_DBUS |
13 | |
14 | QT_BEGIN_NAMESPACE |
15 | |
16 | |
17 | class QDBusConnection; |
18 | class QDBusError; |
19 | class QDBusPendingCallWatcher; |
20 | |
21 | class QDBusPendingCallPrivate; |
22 | class Q_DBUS_EXPORT QDBusPendingCall |
23 | { |
24 | public: |
25 | QDBusPendingCall(const QDBusPendingCall &other); |
26 | ~QDBusPendingCall(); |
27 | QDBusPendingCall &operator=(QDBusPendingCall &&other) noexcept { swap(other); return *this; } |
28 | QDBusPendingCall &operator=(const QDBusPendingCall &other); |
29 | |
30 | void swap(QDBusPendingCall &other) noexcept { d.swap(other&: other.d); } |
31 | |
32 | #ifndef Q_QDOC |
33 | // pretend that they aren't here |
34 | bool isFinished() const; |
35 | void waitForFinished(); |
36 | |
37 | bool isError() const; |
38 | bool isValid() const; |
39 | QDBusError error() const; |
40 | QDBusMessage reply() const; |
41 | #endif |
42 | |
43 | static QDBusPendingCall fromError(const QDBusError &error); |
44 | static QDBusPendingCall fromCompletedCall(const QDBusMessage &message); |
45 | |
46 | protected: |
47 | QExplicitlySharedDataPointer<QDBusPendingCallPrivate> d; |
48 | friend class QDBusPendingCallPrivate; |
49 | friend class QDBusPendingCallWatcher; |
50 | friend class QDBusConnection; |
51 | |
52 | QDBusPendingCall(QDBusPendingCallPrivate *dd); |
53 | |
54 | private: |
55 | QDBusPendingCall(); // not defined |
56 | }; |
57 | |
58 | Q_DECLARE_SHARED(QDBusPendingCall) |
59 | |
60 | class QDBusPendingCallWatcherPrivate; |
61 | class Q_DBUS_EXPORT QDBusPendingCallWatcher: public QObject, public QDBusPendingCall |
62 | { |
63 | Q_OBJECT |
64 | public: |
65 | explicit QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent = nullptr); |
66 | ~QDBusPendingCallWatcher(); |
67 | |
68 | #ifdef Q_QDOC |
69 | // trick qdoc into thinking this method is here |
70 | bool isFinished() const; |
71 | #endif |
72 | void waitForFinished(); // non-virtual override |
73 | |
74 | Q_SIGNALS: |
75 | void finished(QDBusPendingCallWatcher *self = nullptr); |
76 | |
77 | private: |
78 | Q_DECLARE_PRIVATE(QDBusPendingCallWatcher) |
79 | Q_PRIVATE_SLOT(d_func(), void _q_finished()) |
80 | }; |
81 | |
82 | QT_END_NAMESPACE |
83 | |
84 | #endif // QT_NO_DBUS |
85 | #endif |
86 |