summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDaniele E. Domenichelli <daniele.domenichelli@gmail.com>2011-04-18 16:21:10 (GMT)
committerMarius Storm-Olsen <marius.storm-olsen@nokia.com>2011-04-18 16:25:36 (GMT)
commit0792182c396c531d8b9d660df97849ef094c1023 (patch)
tree4767df9948a3d022137f611cab51287c2ae56862 /src
parent9ac6b01ec67ead91143f7c722dbfab38f94dc8c3 (diff)
downloadQt-0792182c396c531d8b9d660df97849ef094c1023.zip
Qt-0792182c396c531d8b9d660df97849ef094c1023.tar.gz
Qt-0792182c396c531d8b9d660df97849ef094c1023.tar.bz2
QtDBus: Add method QDBusConnection::connectToPeer()
Merge-request: 2343 Reviewed-by: Marius Storm-Olsen <marius.storm-olsen@nokia.com> Reviewed-by: Thiago Macieira <thiago.macieira@nokia.com>
Diffstat (limited to 'src')
-rw-r--r--src/dbus/qdbusconnection.cpp34
-rw-r--r--src/dbus/qdbusconnection.h1
2 files changed, 35 insertions, 0 deletions
diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp
index 0d28c30..6df95ec 100644
--- a/src/dbus/qdbusconnection.cpp
+++ b/src/dbus/qdbusconnection.cpp
@@ -411,6 +411,40 @@ QDBusConnection QDBusConnection::connectToBus(const QString &address,
return retval;
}
+/*!
+ \since 4.8
+
+ Opens a peer-to-peer connection on address \a address and associate with it the
+ connection name \a name. Returns a QDBusConnection object associated with that connection.
+*/
+QDBusConnection QDBusConnection::connectToPeer(const QString &address,
+ const QString &name)
+{
+// Q_ASSERT_X(QCoreApplication::instance(), "QDBusConnection::addConnection",
+// "Cannot create connection without a Q[Core]Application instance");
+ if (!qdbus_loadLibDBus()){
+ QDBusConnectionPrivate *d = 0;
+ return QDBusConnection(d);
+ }
+
+ QMutexLocker locker(&_q_manager()->mutex);
+
+ QDBusConnectionPrivate *d = _q_manager()->connection(name);
+ if (d || name.isEmpty())
+ return QDBusConnection(d);
+
+ d = new QDBusConnectionPrivate;
+ // setPeer does the error handling for us
+ QDBusErrorInternal error;
+ DBusConnection *c = q_dbus_connection_open_private(address.toUtf8().constData(), error);
+
+ d->setPeer(c, error);
+ _q_manager()->setConnection(name, d);
+
+ QDBusConnection retval(d);
+
+ return retval;
+}
/*!
Closes the bus connection of name \a name.
diff --git a/src/dbus/qdbusconnection.h b/src/dbus/qdbusconnection.h
index 6ab0ea2..8aa0726 100644
--- a/src/dbus/qdbusconnection.h
+++ b/src/dbus/qdbusconnection.h
@@ -172,6 +172,7 @@ public:
static QDBusConnection connectToBus(BusType type, const QString &name);
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 QDBusConnection sessionBus();