Example #1
0
/*!
    \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;
}
Example #2
0
QDBusConnection QDBusConnection::addConnection(BusType type, const QString &name)
{
//    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;
    DBusConnection *c = 0;
    switch (type) {
        case SystemBus:
            c = dbus_bus_get(DBUS_BUS_SYSTEM, &d->error);
            break;
        case SessionBus:
            c = dbus_bus_get(DBUS_BUS_SESSION, &d->error);
            break;
        case ActivationBus:
            c = dbus_bus_get(DBUS_BUS_STARTER, &d->error);
            break;
    }
    d->setConnection(c); //setConnection does the error handling for us

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

    return QDBusConnection(name);
}
 Pinger getPingerPeer(const QString &path = "/", const QString &service = "")
 {
     QDBusConnection con = QDBusConnection("peer");
     if (!con.isConnected())
         return Pinger();
     return Pinger(new com::trolltech::QtDBus::Pinger(service, path, con));
 }
Example #4
0
QDBusConnection QDBusConnection::addConnection(const QString &address,
                    const QString &name)
{
//    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);
}
Example #5
0
void DBusConnection::connectA11yBus(const QString &address)
{
    if (address.isEmpty()) {
        qWarning("Could not find Accessibility DBus address.");
        return;
    }
    m_a11yConnection = QDBusConnection(QDBusConnection::connectToBus(address, QStringLiteral("a11y")));

    if (m_enabled)
        emit enabledChanged(true);
}
Example #6
0
/*!
    Opens a connection of type \a type to one of the known busses and
    associate with it the connection name \a name. Returns a
    QDBusConnection object associated with that connection.
*/
QDBusConnection QDBusConnection::connectToBus(BusType type, 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;
    DBusConnection *c = 0;
    QDBusErrorInternal error;
    switch (type) {
        case SystemBus:
            c = q_dbus_bus_get_private(DBUS_BUS_SYSTEM, error);
            break;
        case SessionBus:
            c = q_dbus_bus_get_private(DBUS_BUS_SESSION, error);
            break;
        case ActivationBus:
            c = q_dbus_bus_get_private(DBUS_BUS_STARTER, error);
            break;
    }
    d->setConnection(c, error); //setConnection does the error handling for us

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

    QDBusConnection retval(d);

    // create the bus service
    // will lock in QDBusConnectionPrivate::connectRelay()
    d->setBusService(retval);

    return retval;
}
void
DBusInputContextConnection::invokeAction(const QString &action,
                                         const QKeySequence &sequence)
{
    if (activeConnection) {
        QDBusMessage message = QDBusMessage::createSignal(DBusPath, DBusInterface, "invokeAction");
        QList<QVariant> arguments;
        arguments << action << sequence.toString();
        message.setArguments(arguments);
        QDBusConnection(mConnections.value(activeConnection)).send(message);
    }
}
Example #8
0
QObject *QDBusConnectionConstructor::qscript_call(const QString &name)
{
    return new QScriptDBusConnection(QDBusConnection(name), this);
}
Example #9
0
/*!
  \nonreentrant

  Returns the connection that sent the signal, if called in a slot activated
  by QDBus; otherwise it returns 0.

  \note Please avoid this function. This function is not thread-safe, so if
  there's any other thread delivering a D-Bus call, this function may return
  the wrong connection. In new code, please use QDBusContext::connection()
  (see that class for a description on how to use it).
*/
QDBusConnection QDBusConnection::sender()
{
    return QDBusConnection(_q_manager()->sender());
}