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 Q_DBUS_EXPORT QDBusPendingCallWatcher: public QObject, public QDBusPendingCall
61{
62 Q_OBJECT
63public:
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
73Q_SIGNALS:
74 void finished(QDBusPendingCallWatcher *self = nullptr);
75};
76
77QT_END_NAMESPACE
78
79#endif // QT_NO_DBUS
80#endif
81

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

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