コード例 #1
0
// We have the a11y registry on the session bus.
// Subscribe to updates about a11y enabled state.
// Find out the bus address
void DBusConnection::serviceRegistered()
{
    // listen to enabled changes
    QDBusConnection c = QDBusConnection::sessionBus();
    OrgA11yStatusInterface *a11yStatus = new OrgA11yStatusInterface(A11Y_SERVICE, A11Y_PATH, c, this);

    //The variable was introduced because on some embedded platforms there are custom accessibility
    //clients which don't set Status.ScreenReaderEnabled to true. The variable is also useful for
    //debugging.
    static const bool a11yAlwaysOn = qEnvironmentVariableIsSet("QT_LINUX_ACCESSIBILITY_ALWAYS_ON");

    // a11yStatus->isEnabled() returns always true (since Gnome 3.6)
    bool enabled = a11yAlwaysOn || a11yStatus->screenReaderEnabled();

    if (enabled != m_enabled) {
        m_enabled = enabled;
        if (m_a11yConnection.isConnected()) {
            emit enabledChanged(m_enabled);
        } else {
            QDBusConnection c = QDBusConnection::sessionBus();
            QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String("org.a11y.Bus"),
                             QLatin1String("/org/a11y/bus"),
                             QLatin1String("org.a11y.Bus"), QLatin1String("GetAddress"));
            c.callWithCallback(m, this, SLOT(connectA11yBus(QString)), SLOT(dbusError(QDBusError)));
        }
    }

    //    connect(a11yStatus, ); QtDbus doesn't support notifications for property changes yet
}
コード例 #2
0
bool UDiskMountDevice::eject()
{
    if (!mIsMounted)
        return false;

    QList<QVariant> args;
    args << QVariant(QStringList());

    return mDbus->callWithCallback("DriveEject", args, this,
                             SLOT(dbusSuccess(QDBusMessage)),
                             SLOT(dbusError(QDBusError, QDBusMessage)));
}
コード例 #3
0
bool UDiskMountDevice::unmount()
{
    if (!mIsMounted)
        return true;

    QList<QVariant> args;
    args << QVariant(QStringList());

    bool ret;
    ret = mDbus->callWithCallback("FilesystemUnmount", args, this,
//                             SLOT(dbusSuccess(QDBusMessage)),
                             SIGNAL(unmounted()),
                             SLOT(dbusError(QDBusError, QDBusMessage)));
    return ret;
}
コード例 #4
0
// We have the a11y registry on the session bus.
// Subscribe to updates about a11y enabled state.
// Find out the bus address
void DBusConnection::serviceRegistered()
{
    // listen to enabled changes
    QDBusConnection c = QDBusConnection::sessionBus();
    OrgA11yStatusInterface *a11yStatus = new OrgA11yStatusInterface(A11Y_SERVICE, A11Y_PATH, c, this);

    // a11yStatus->isEnabled() returns always true (since Gnome 3.6)
    bool enabled = a11yStatus->screenReaderEnabled();
    if (enabled != m_enabled) {
        m_enabled = enabled;
        if (m_a11yConnection.isConnected()) {
            emit enabledChanged(m_enabled);
        } else {
            QDBusConnection c = QDBusConnection::sessionBus();
            QDBusMessage m = QDBusMessage::createMethodCall(QLatin1String("org.a11y.Bus"),
                                                            QLatin1String("/org/a11y/bus"),
                                                            QLatin1String("org.a11y.Bus"), QLatin1String("GetAddress"));
            c.callWithCallback(m, this, SLOT(connectA11yBus(QString)), SLOT(dbusError(QDBusError)));
        }
    }

    //    connect(a11yStatus, ); QtDbus doesn't support notifications for property changes yet
}
コード例 #5
0
bool UDiskMountDevice::mount()
{
    if (mIsMounted)
        return true;

    QList<QVariant> args;
    args << QVariant(QString()) << QVariant(QStringList());

    bool ret;
    ret = mDbus->callWithCallback("FilesystemMount", args, this,
                             //SLOT(dbusSuccess(QDBusMessage)),
                             SIGNAL(mounted()),
                             SLOT(dbusError(QDBusError, QDBusMessage)));

    QStringList paths = mDbus->property("DeviceMountPaths").toStringList();

    if (!paths.empty())
        mMountPath = paths.at(0);
    else
        mMountPath = "";

    return ret;
}
コード例 #6
0
bool QDBusMenuConnection::registerTrayIcon(QDBusTrayIcon *item)
{
    bool success = connection().registerService(item->instanceId());
    if (!success) {
        qWarning() << "failed to register service" << item->instanceId();
        return false;
    }

    success = connection().registerObject(StatusNotifierItemPath, item);
    if (!success) {
        unregisterTrayIcon(item);
        qWarning() << "failed to register" << item->instanceId() << StatusNotifierItemPath;
        return false;
    }

    if (item->menu()) {
        success = connection().registerObject(MenuBarPath, item->menu());
        if (!success) {
            unregisterTrayIcon(item);
            qWarning() << "failed to register" << item->instanceId() << MenuBarPath;
            return false;
        }
    }

    QDBusMessage registerMethod = QDBusMessage::createMethodCall(
                StatusNotifierWatcherService, StatusNotifierWatcherPath, StatusNotifierWatcherService,
                QLatin1String("RegisterStatusNotifierItem"));
    registerMethod.setArguments(QVariantList() << item->instanceId());
    success = m_connection.callWithCallback(registerMethod, this, SIGNAL(trayIconRegistered()), SLOT(dbusError(QDBusError)));

    return success;
}