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

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