Logo Search packages:      
Sourcecode: kdbus version File versions  Download package

QDBusConnection QDBusConnection::addConnection ( const QString &  address,
const QString &  name = default_connection_name 
) [static]

Add a connection to a bus at a specific address.

This is a factory method as it will create a connection for the given name if its not available yet, but return a previously created connection for that name if available.

Note:
this requires to know the address of a DBus daemon to connect to
Parameters:
address the address of the DBus daemon. Usually a Unix domain socket address
name the name to use for QDBusConnection's connection sharing
Returns:
a connection handle. Check isConnected() to find out if the connection attempt has been successfull
See also:
closeConnection()

Definition at line 210 of file qdbusconnection.cpp.

References QDBusConnection().

{
//    Q_ASSERT_X(QCoreApplication::instance(), "QDBusConnection::addConnection",
//               "Cannot create connection without a Q[Core]Application instance");

    QDBusConnectionPrivate *d = manager()->connection(name);
    if (d)
        return QDBusConnection(name);

    d = new QDBusConnectionPrivate;
    // setConnection does the error handling for us
    d->setConnection(dbus_connection_open(address.utf8().data(), &d->error));

    manager()->setConnection(name, d);

    return QDBusConnection(name);
}


Generated by  Doxygen 1.6.0   Back to index