| 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 Q_DBUS_EXPORT QDBusPendingCallWatcher: public QObject, public QDBusPendingCall |
| 61 | { |
| 62 | Q_OBJECT |
| 63 | public: |
| 64 | explicit QDBusPendingCallWatcher(const QDBusPendingCall &call, QObject *parent = nullptr); |
| 65 | ~QDBusPendingCallWatcher(); |
| 66 | |
| 67 | #ifdef Q_QDOC |
| 68 | // trick qdoc into thinking this method is here |
| 69 | bool isFinished() const; |
| 70 | #endif |
| 71 | void waitForFinished(); // non-virtual override |
| 72 | |
| 73 | Q_SIGNALS: |
| 74 | void finished(QDBusPendingCallWatcher *self = nullptr); |
| 75 | }; |
| 76 | |
| 77 | QT_END_NAMESPACE |
| 78 | |
| 79 | #endif // QT_NO_DBUS |
| 80 | #endif |
| 81 |
