Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdbusconnection.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// Copyright (C) 2016 Intel Corporation.
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#ifndef QDBUSCONNECTION_H
6#define QDBUSCONNECTION_H
7
8#include <QtDBus/qtdbusglobal.h>
9#include <QtCore/qobjectdefs.h>
10#include <QtCore/qstring.h>
11
12#ifndef QT_NO_DBUS
13
14#ifdef interface
15# undef interface
16#endif
17
19
20
21namespace QDBus
22{
29}
30
32class QDBusInterface;
33class QDBusError;
34class QDBusMessage;
38class QObject;
39
41class Q_DBUS_EXPORT QDBusConnection
42{
44 Q_MOC_INCLUDE(<QtDBus/qdbuspendingcall.h>)
45
46public:
47 enum BusType { SessionBus, SystemBus, ActivationBus };
48 Q_ENUM(BusType)
50 ExportAdaptors = 0x01,
51
52 ExportScriptableSlots = 0x10,
53 ExportScriptableSignals = 0x20,
54 ExportScriptableProperties = 0x40,
55 ExportScriptableInvokables = 0x80,
56 ExportScriptableContents = 0xf0,
57
58 ExportNonScriptableSlots = 0x100,
59 ExportNonScriptableSignals = 0x200,
60 ExportNonScriptableProperties = 0x400,
61 ExportNonScriptableInvokables = 0x800,
62 ExportNonScriptableContents = 0xf00,
63
64 ExportAllSlots = ExportScriptableSlots|ExportNonScriptableSlots,
65 ExportAllSignals = ExportScriptableSignals|ExportNonScriptableSignals,
66 ExportAllProperties = ExportScriptableProperties|ExportNonScriptableProperties,
67 ExportAllInvokables = ExportScriptableInvokables|ExportNonScriptableInvokables,
68 ExportAllContents = ExportScriptableContents|ExportNonScriptableContents,
69
70#ifndef Q_QDOC
71 // Qt 4.2 had a misspelling here
72 ExportAllSignal = ExportAllSignals,
73#endif
74 ExportChildObjects = 0x1000
75 // Reserved = 0xff000000
76 };
77 Q_DECLARE_FLAGS(RegisterOptions, RegisterOption)
78 Q_FLAG(RegisterOptions)
79
82 UnregisterTree
83 };
84 Q_ENUM(UnregisterMode)
85
87 SingleNode = 0x0,
88 SubPath = 0x1
89 // Reserved = 0xff000000
90 };
91 Q_DECLARE_FLAGS(VirtualObjectRegisterOptions, VirtualObjectRegisterOption)
92
94 UnixFileDescriptorPassing = 0x0001
95 };
96 Q_DECLARE_FLAGS(ConnectionCapabilities, ConnectionCapability)
97
98 explicit QDBusConnection(const QString &name);
100 QDBusConnection(QDBusConnection &&other) noexcept : d(other.d) { other.d = nullptr; }
101 QDBusConnection &operator=(QDBusConnection &&other) noexcept { swap(other); return *this; }
102 QDBusConnection &operator=(const QDBusConnection &other);
104
105 void swap(QDBusConnection &other) noexcept { qt_ptr_swap(d, other.d); }
106
107 bool isConnected() const;
108 QString baseService() const;
109 QDBusError lastError() const;
110 QString name() const;
111 ConnectionCapabilities connectionCapabilities() const;
112
113 bool send(const QDBusMessage &message) const;
114 bool callWithCallback(const QDBusMessage &message, QObject *receiver,
115 const char *returnMethod, const char *errorMethod,
116 int timeout = -1) const;
117 bool callWithCallback(const QDBusMessage &message, QObject *receiver,
118 const char *slot, int timeout = -1) const;
120 int timeout = -1) const;
121 QDBusPendingCall asyncCall(const QDBusMessage &message, int timeout = -1) const;
122
123 bool connect(const QString &service, const QString &path, const QString &interface,
124 const QString &name, QObject *receiver, const char *slot);
125 bool connect(const QString &service, const QString &path, const QString &interface,
126 const QString &name, const QString& signature,
127 QObject *receiver, const char *slot);
128 bool connect(const QString &service, const QString &path, const QString &interface,
129 const QString &name, const QStringList &argumentMatch, const QString& signature,
130 QObject *receiver, const char *slot);
131
132 bool disconnect(const QString &service, const QString &path, const QString &interface,
133 const QString &name, QObject *receiver, const char *slot);
134 bool disconnect(const QString &service, const QString &path, const QString &interface,
135 const QString &name, const QString& signature,
136 QObject *receiver, const char *slot);
137 bool disconnect(const QString &service, const QString &path, const QString &interface,
138 const QString &name, const QStringList &argumentMatch, const QString& signature,
139 QObject *receiver, const char *slot);
140
141 bool registerObject(const QString &path, QObject *object,
142 RegisterOptions options = ExportAdaptors);
143 bool registerObject(const QString &path, const QString &interface, QObject *object,
144 RegisterOptions options = ExportAdaptors);
145 void unregisterObject(const QString &path, UnregisterMode mode = UnregisterNode);
146 QObject *objectRegisteredAt(const QString &path) const;
147
148 bool registerVirtualObject(const QString &path, QDBusVirtualObject *object,
149 VirtualObjectRegisterOption options = SingleNode);
150
151 bool registerService(const QString &serviceName);
152 bool unregisterService(const QString &serviceName);
153
155
156 void *internalPointer() const;
157
158 static QDBusConnection connectToBus(BusType type, const QString &name);
159 static QDBusConnection connectToBus(const QString &address, const QString &name);
160 static QDBusConnection connectToPeer(const QString &address, const QString &name);
161 static void disconnectFromBus(const QString &name);
162 static void disconnectFromPeer(const QString &name);
163
164 static QByteArray localMachineId();
165
166 static QDBusConnection sessionBus();
167 static QDBusConnection systemBus();
168
169protected:
171
172private:
175};
176Q_DECLARE_SHARED(QDBusConnection)
177
178Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::RegisterOptions)
179Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::VirtualObjectRegisterOptions)
180Q_DECLARE_OPERATORS_FOR_FLAGS(QDBusConnection::ConnectionCapabilities)
181
183
184#endif // QT_NO_DBUS
185#endif
\inmodule QtCore
Definition qbytearray.h:57
\inmodule QtDBus
BusType
Specifies the type of the bus connection.
RegisterOption
Specifies the options for registering objects with the connection.
QDBusConnection(QDBusConnection &&other) noexcept
UnregisterMode
The mode for unregistering an object path:
void swap(QDBusConnection &other) noexcept
Swaps this QDBusConnection instance with other.
QDBusConnection & operator=(QDBusConnection &&other) noexcept
\inmodule QtDBus
Definition qdbuserror.h:21
\inmodule QtDBus
\inmodule QtDBus
\inmodule QtDBus
\inmodule QtCore
Definition qobject.h:103
\inmodule QtCore
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
\inmodule QtDBus
CallMode
This enum describes the various ways of placing a function call.
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char * interface
static QDBusConnection::ConnectionCapabilities connectionCapabilities(DBusConnection *connection)
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
GLenum mode
GLbitfield GLuint64 timeout
[4]
GLenum type
GLuint GLsizei const GLchar * message
GLuint name
GLuint GLuint64EXT address
GLsizei const GLchar *const * path
constexpr void qt_ptr_swap(T *&lhs, T *&rhs) noexcept
Definition qswap.h:29
#define Q_ENUM(x)
#define Q_FLAG(x)
#define Q_GADGET
#define Q_MOC_INCLUDE(...)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
QSharedPointer< T > other(t)
[5]
this swap(other)