13#include <QtCore/private/qlocking_p.h>
37static void preventDllUnload();
54 const auto locker = qt_scoped_lock(defaultBusMutex);
55 if (defaultBuses[
type])
56 return defaultBuses[
type];
61 return defaultBuses[
type] = connectToBus(
type,
name, suspendedDelivery);
66 return connectionHash.
value(
name,
nullptr);
73 if (
d && !
d->ref.deref())
95 defaultBuses[0] = defaultBuses[1] =
nullptr;
117 connectionHash[
name] =
c;
126 const auto locker = qt_scoped_lock(
mutex);
128 if (!
d->ref.deref()) {
131 d->closeConnection();
132 d->moveToThread(
nullptr);
135 connectionHash.
clear();
142 bool suspendedDelivery)
148 data.suspendedDelivery = suspendedDelivery;
151 if (suspendedDelivery &&
data.result->connection)
152 data.result->enableDispatchDelayed(
qApp);
163 data.suspendedDelivery =
false;
175 data.suspendedDelivery =
false;
183 const auto locker = qt_scoped_lock(
mutex);
189 if (
d ||
name.isEmpty())
195 switch (
data->type) {
197 switch (
data->busType) {
212 c = q_dbus_connection_open_private(
data->busAddress->toUtf8().constData(),
error);
215 if (!q_dbus_bus_register(
c,
error)) {
216 q_dbus_connection_unref(
c);
230 d->createBusService();
231 if (
c &&
data->suspendedDelivery)
232 d->setDispatchEnabled(
false);
368 if (
name.isEmpty() || _q_manager.isDestroyed()) {
371 const auto locker = qt_scoped_lock(_q_manager()->
mutex);
372 d = _q_manager()->connection(
name);
405 if (
d && !
d->ref.deref())
420 if (
d && !
d->ref.deref())
480 const auto locker = qt_scoped_lock(_q_manager()->
mutex);
484 _q_manager()->removeConnection(
name);
501 const auto locker = qt_scoped_lock(_q_manager()->
mutex);
505 _q_manager()->removeConnection(
name);
518 if (!
d || !
d->connection) {
548 const char *returnMethod,
const char *errorMethod,
551 if (!
d || !
d->connection) {
558 return d->sendWithReplyAsync(
message, receiver, returnMethod, errorMethod,
timeout) !=
nullptr;
579 const char *returnMethod,
int timeout)
const
609 if (!
d || !
d->connection) {
646 if (!
d || !
d->connection) {
690 QObject *receiver,
const char *slot)
720 QObject *receiver,
const char *slot)
723 if (!receiver || !slot || !
d || !
d->connection)
729 qWarning(
"QDBusConnection::connect: interface name '%s' is not valid",
interface.toLatin1().constData());
735 qWarning(
"QDBusConnection::connect: service name '%s' is not valid", service.toLatin1().constData());
741 qWarning(
"QDBusConnection::connect: object path '%s' is not valid",
path.toLatin1().constData());
746 return d->connectSignal(service,
path,
interface,
name, argumentMatch, signature, receiver, slot);
774 QObject *receiver,
const char *slot)
792 QObject *receiver,
const char *slot)
794 if (!receiver || !slot || !
d || !
d->connection)
801 return d->disconnectSignal(service,
path,
interface,
name, argumentMatch, signature, receiver, slot);
847 "Invalid object path given");
852 if (pathComponents.constLast().isEmpty())
860 if (pathComponents.size() ==
i) {
876 node->
flags = options;
879 d->registerObject(node);
915 Q_ASSERT_X(
false,
"QDBusConnection::registerObject",
"The impossible happened");
956 "Invalid object path given");
961 if (pathComponents.constLast().isEmpty())
970 if (pathComponents.size() ==
i)
996 return d->busService;
1011 return d ?
d->connection :
nullptr;
1019 return d &&
d->connection && q_dbus_connection_get_is_connected(
d->connection);
1082 return d ?
d->connectionCapabilities() : ConnectionCapabilities();
1095 if (
d)
d->registerService(serviceName);
1111 if (
d)
d->unregisterService(serviceName);
1126 if (_q_manager.isDestroyed())
1140 if (_q_manager.isDestroyed())
1176 char *dbus_machine_id = q_dbus_get_local_machine_id();
1178 q_dbus_free(dbus_machine_id);
1217#include "moc_qdbusconnection_p.cpp"
1218#include "moc_qdbusconnection.cpp"
1219#include "moc_qdbusconnectionmanager_p.cpp"
1225static void preventDllUnload()
1240 GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
1241 GET_MODULE_HANDLE_EX_FLAG_PIN,
1242 reinterpret_cast<const wchar_t *
>(&self),
Connects to the accessibility dbus.
void callWithCallbackFailed(const QDBusError &error, const QDBusMessage &call)
This signal is emitted when there is an error during a QDBusConnection::callWithCallback().
QDBusConnectionPrivate * connection(const QString &name) const
static QDBusConnectionManager * instance()
void serverRequested(const QString &address, void *server)
void connectionRequested(ConnectionRequestData *)
void removeConnection(const QString &name)
void setConnection(const QString &name, QDBusConnectionPrivate *c)
QDBusConnectionPrivate * connectToPeer(const QString &address, const QString &name)
~QDBusConnectionManager()
QDBusConnectionPrivate * connectToBus(QDBusConnection::BusType type, const QString &name, bool suspendedDelivery)
QDBusConnectionInterface * busService
DBusConnection * connection
void callWithCallbackFailed(const QDBusError &error, const QDBusMessage &message)
bool send(const QDBusMessage &message) const
Sends the message over this connection, without waiting for a reply.
static QDBusConnection systemBus()
Returns a QDBusConnection object opened with the system bus.
bool disconnect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
Disconnects the signal specified by the service, path, interface and name parameters from the slot sl...
void * internalPointer() const
bool registerVirtualObject(const QString &path, QDBusVirtualObject *object, VirtualObjectRegisterOption options=SingleNode)
static QByteArray localMachineId()
static QDBusConnection connectToPeer(const QString &address, const QString &name)
QDBusConnection(const QString &name)
Creates a QDBusConnection object attached to the connection with name name.
bool callWithCallback(const QDBusMessage &message, QObject *receiver, const char *returnMethod, const char *errorMethod, int timeout=-1) const
Sends the message over this connection and returns immediately.
BusType
Specifies the type of the bus connection.
QDBusConnectionInterface * interface() const
Returns a QDBusConnectionInterface object that represents the D-Bus server interface on this connecti...
bool unregisterService(const QString &serviceName)
Unregisters the service serviceName that was previously registered with registerService() and returns...
VirtualObjectRegisterOption
bool isConnected() const
Returns true if this QDBusConnection object is connected.
static QDBusConnection connectToBus(BusType type, const QString &name)
Opens a connection of type type to one of the known buses and associate with it the connection name n...
ConnectionCapabilities connectionCapabilities() const
QDBusMessage call(const QDBusMessage &message, QDBus::CallMode mode=QDBus::Block, int timeout=-1) const
Sends the message over this connection and blocks, waiting for a reply, for at most timeout milliseco...
bool connect(const QString &service, const QString &path, const QString &interface, const QString &name, QObject *receiver, const char *slot)
Connects the signal specified by the service, path, interface and name parameters to the slot slot in...
static QDBusConnection sessionBus()
Returns a QDBusConnection object opened with the session bus.
static void disconnectFromPeer(const QString &name)
static void disconnectFromBus(const QString &name)
Closes the bus connection of name name.
~QDBusConnection()
Disposes of this object.
UnregisterMode
The mode for unregistering an object path:
bool registerService(const QString &serviceName)
Attempts to register the serviceName on the D-Bus server and returns true if the registration succeed...
QObject * objectRegisteredAt(const QString &path) const
Return the object that was registered with the registerObject() at the object path given by path.
void unregisterObject(const QString &path, UnregisterMode mode=UnregisterNode)
Unregisters an object that was registered with the registerObject() at the object path given by path ...
QString baseService() const
Returns the unique connection name for this connection, if this QDBusConnection object is connected,...
QDBusPendingCall asyncCall(const QDBusMessage &message, int timeout=-1) const
bool registerObject(const QString &path, QObject *object, RegisterOptions options=ExportAdaptors)
Registers the object object at path path and returns true if the registration was successful.
QDBusError lastError() const
Returns the last error that happened in this connection.
QDBusConnection & operator=(QDBusConnection &&other) noexcept
static QDBusMessage createError(const QString &name, const QString &msg)
Constructs a new DBus message representing an error, with the given name and msg.
T take(const Key &key)
Removes the item with the key from the hash and returns the value associated with it.
T value(const Key &key) const noexcept
void clear() noexcept(std::is_nothrow_destructible< Node >::value)
Removes all items from the hash and frees up all memory used by it.
bool isEmpty() const noexcept
iterator insert(qsizetype i, parameter_type t)
const_iterator constBegin() const noexcept
void removeLast() noexcept
const_iterator constEnd() const noexcept
const_iterator ConstIterator
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Q_CORE_EXPORT QList< QStringView > split(QStringView sep, Qt::SplitBehavior behavior=Qt::KeepEmptyParts, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Splits the view into substring views wherever sep occurs, and returns the list of those string views.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QThread * currentThread()
QSet< QString >::iterator it
bool isValidInterfaceName(const QString &ifaceName)
Returns true if this is ifaceName is a valid interface name.
bool isValidBusName(const QString &busName)
Returns true if busName is a valid bus name.
bool isValidObjectPath(const QString &path)
Returns true if path is valid object path.
QString disconnectedErrorMessage()
CallMode
This enum describes the various ways of placing a function call.
Combined button and popup list for selecting options.
@ BlockingQueuedConnection
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 const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage return DBusPendingCall DBusPendingCall return DBusPendingCall return dbus_int32_t return DBusServer * server
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
DBusConnection const char DBusError * error
DBusConnection * connection
Q_DBUS_EXPORT void qDBusBindToApplication()
@ ObjectRegisteredAtAction
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
GLbitfield GLuint64 timeout
[4]
GLuint GLsizei const GLchar * message
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLuint GLuint64EXT address
GLsizei const GLchar *const * path
#define Q_ASSERT_X(cond, x, msg)
#define QStringLiteral(str)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
myObject moveToThread(QApplication::instance() ->thread())
[6]