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
14QT_BEGIN_NAMESPACE
15
16
17class QDBusConnection;
18class QDBusError;
19class QDBusPendingCallWatcher;
20
21class QDBusPendingCallPrivate;
22class Q_DBUS_EXPORT QDBusPendingCall
23{
24public:
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
46protected:
47 QExplicitlySharedDataPointer<QDBusPendingCallPrivate> d;
48 friend class QDBusPendingCallPrivate;
49 friend class QDBusPendingCallWatcher;
50 friend class QDBusConnection;
51
52 QDBusPendingCall(QDBusPendingCallPrivate *dd);
53
54private:
55 QDBusPendingCall(); // not defined
56};
57
58Q_DECLARE_SHARED(QDBusPendingCall)
59
60class QDBusPendingCallWatcherPrivate;
61class Q_DBUS_EXPORT QDBusPendingCallWatcher: public QObject, public QDBusPendingCall
62{
63 Q_OBJECT
64public:
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
74Q_SIGNALS:
75 void finished(QDBusPendingCallWatcher *self = nullptr);
76
77private:
78 Q_DECLARE_PRIVATE(QDBusPendingCallWatcher)
79 Q_PRIVATE_SLOT(d_func(), void _q_finished())
80};
81
82QT_END_NAMESPACE
83
84#endif // QT_NO_DBUS
85#endif
86

source code of qtbase/src/dbus/qdbuspendingcall.h