From e6c46787ff5b8ac2bd700c35b6e04d7c835b1c23 Mon Sep 17 00:00:00 2001 From: "Daniele E. Domenichelli" Date: Mon, 18 Apr 2011 11:21:10 -0500 Subject: QtDBus: Add method QDBusConnection::disconnectFromPeer() Merge-request: 2343 Reviewed-by: Marius Storm-Olsen Reviewed-by: Thiago Macieira --- src/dbus/qdbusconnection.cpp | 21 +++++++++++++++++++++ src/dbus/qdbusconnection.h | 1 + 2 files changed, 22 insertions(+) diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 6df95ec..dea7cf9 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -466,6 +466,27 @@ void QDBusConnection::disconnectFromBus(const QString &name) } /*! + \since 4.8 + + Closes the peer connection of name \a name. + + Note that if there are still QDBusConnection objects associated + with the same connection, the connection will not be closed until + all references are dropped. However, no further references can be + created using the QDBusConnection constructor. +*/ +void QDBusConnection::disconnectFromPeer(const QString &name) +{ + if (_q_manager()) { + QMutexLocker locker(&_q_manager()->mutex); + QDBusConnectionPrivate *d = _q_manager()->connection(name); + if(d && d->mode != QDBusConnectionPrivate::PeerMode) + return; + _q_manager()->removeConnection(name); + } +} + +/*! Sends the \a message over this connection, without waiting for a reply. This is suitable for errors, signals, and return values as well as calls whose return values are not necessary. diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h index 8aa0726..15e08a7 100644 --- a/src/dbus/qdbusconnection.h +++ b/src/dbus/qdbusconnection.h @@ -174,6 +174,7 @@ public: static QDBusConnection connectToBus(const QString &address, const QString &name); static QDBusConnection connectToPeer(const QString &address, const QString &name); static void disconnectFromBus(const QString &name); + static void disconnectFromPeer(const QString &name); static QDBusConnection sessionBus(); static QDBusConnection systemBus(); -- cgit v0.12