DBusService::DBusService(QObject *parent) :
    QObject(parent)
{
    QDBusConnection connection = QDBusConnection::sessionBus();
    connection.registerService("org.marxoft.cutetube2");
    connection.registerObject("/", this, QDBusConnection::ExportAllSlots);
}
UDiskProvider::UDiskProvider(QObject *parent):
    RzMountProvider(parent)
{
    QDBusConnection system = QDBusConnection::systemBus();

    if (!system.isConnected())
    {
        return;
    }

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceAdded",
                    this,
                    SLOT(dbusDeviceAdded(QDBusObjectPath)));

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceRemoved",
                    this,
                    SLOT(dbusDeviceRemoved(QDBusObjectPath)));

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceChanged",
                    this,
                    SLOT(dbusDeviceChanged(QDBusObjectPath)));

    mIsValid = true;
}
Exemple #3
0
UdisksManager::UdisksManager(QObject *parent)
    : QObject(parent)
{
    QDBusConnection system = QDBusConnection::systemBus();

    if (!system.isConnected())
    {
        emit error(tr("Cannot connect to Udisks daemon"));
    }

    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceAdded",
                    this,
                    SLOT(onDeviceAdded(QDBusObjectPath)));
    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceRemoved",
                    this,
                    SLOT(onDeviceRemoved(QDBusObjectPath)));
    system.connect("org.freedesktop.UDisks",
                    "/org/freedesktop/UDisks",
                    "org.freedesktop.UDisks",
                    "DeviceChanged",
                    this,
                    SLOT(onDeviceChanged(QDBusObjectPath)));

    QDBusInterface devEnum("org.freedesktop.UDisks",
                           "/org/freedesktop/UDisks",
                           "org.freedesktop.UDisks",
                           QDBusConnection::systemBus());

    QDBusMessage enumRes = devEnum.call("EnumerateDevices");
    // TODO/FIXME: error checking
//    if (enumRes.type() == QDBusMessage::ErrorMessage)
//    {
//        fprintf(stderr, "ERROR: Can't call EnumerateDevices\n");
//        fprintf(stderr, "       %s : %s\n", qPrintable(enumRes.errorName()), qPrintable(enumRes.errorMessage()));
//    }
//
//    if (enumRes.type() != QDBusMessage::ReplyMessage || !enumRes.arguments().at(0).canConvert<QDBusArgument>())
//    {
//        fprintf(stderr, "ERROR: Unexpected result type of EnumerateDevices call\n");
//    }
//
    const QDBusArgument enumArg = enumRes.arguments().at(0).value<QDBusArgument>();
//    if (enumArg.currentType() != QDBusArgument::ArrayType)
//    {
//        fprintf(stderr, "ERROR: Unexpected argument type of EnumerateDevices call\n");
//    }

    enumArg.beginArray();
    while (!enumArg.atEnd())
    {
        addDevice(qdbus_cast<QDBusObjectPath>(enumArg));
    }
    enumArg.endArray();
}
void tst_QDBusPerformance::initTestCase()
{
    QDBusConnection con = QDBusConnection::sessionBus();
    QVERIFY(con.isConnected());

    QDBusServiceWatcher watcher(serviceName, con,
                                QDBusServiceWatcher::WatchForRegistration);
    connect(&watcher, SIGNAL(serviceRegistered(QString)),
            &QTestEventLoop::instance(), SLOT(exitLoop()));

#ifdef Q_OS_WIN
    proc.start("server");
#else
    proc.start("./server/server");
#endif
    QVERIFY(proc.waitForStarted());

    QTestEventLoop::instance().enterLoop(5);
    QVERIFY(con.interface()->isServiceRegistered(serviceName));

    remote = new QDBusInterface(serviceName, "/", "com.trolltech.autotests.Performance", con, this);
    QVERIFY(remote->isValid());

    new ServerObject("/", con, this);
    local = new QDBusInterface(con.baseService(), "/", "com.trolltech.autotests.Performance", con, this);
    QVERIFY(local->isValid());
}
Exemple #5
0
/* Remove uinput device, stop threads and unregister from dbus
 */
Tohkbd::~Tohkbd()
{
    /* Restore orientation when shutting down */
    if (forceLandscapeOrientation)
    {
        QList<QVariant> args;
        args.append(currentOrientationLock);
        tohkbd2user->callWithArgumentList(QDBus::AutoDetect, "setOrientationLock", args);
    }

    uinputif->closeUinputDevice();

    worker->abort();
    thread->wait();
    delete thread;
    delete worker;

    if (dbusRegistered)
    {
        QDBusConnection connection = QDBusConnection::systemBus();
        connection.unregisterObject(PATH);
        connection.unregisterService(SERVICE);

        printf("tohkbd2: unregistered from dbus systemBus\n");
        tohkbd2user->call(QDBus::AutoDetect, "quit");
    }
}
/*!
    Destroy this QCop service handling object.
*/
QtopiaAbstractService::~QtopiaAbstractService()
{
#if defined(QTOPIA_DBUS_IPC)
    QDBusConnection dbc = QDBus::sessionBus();
    if (!dbc.isConnected()) {
        qWarning() << "Unable to connect to D-BUS:" << dbc.lastError();
        return;
    }

    qLog(Services) << "Unregistering service" << m_data->m_service;

    QString path = dbusPathBase;
    path.append(m_data->m_service);
    dbc.unregisterObject(path);

    QDBusConnectionInterface *iface = dbc.interface();
    QString service = dbusInterface;
    service.append(".");
    service.append(m_data->m_service);

    iface->unregisterService(service);
#endif

    if (m_data)
        delete m_data;
}
Mpris2Engine::Mpris2Engine(QObject *parent)
    : QObject(parent)
{
    const QDBusConnection bus = QDBusConnection::sessionBus();
    const QStringList services = bus.interface()->registeredServiceNames();

    for (const QString &name: services.filter(mprisInterface)) {
        qCDebug(MPRIS2) << "Found player" << name;
        m_players.append(new Mpris2Player(name));
        Q_EMIT playersChanged();
    }

    m_watcher = new QDBusServiceWatcher(this);
    connect(m_watcher, &QDBusServiceWatcher::serviceOwnerChanged, [=](const QString &name, const QString &oldOwner, const QString &newOwner) {
        if (oldOwner.isEmpty() && name.startsWith(mprisPrefix)) {
            qCDebug(MPRIS2) << "Found new player" << name;
            m_players.append(new Mpris2Player(name));
        } else if (newOwner.isEmpty() && name.startsWith(mprisPrefix)) {
            for (int i = 0; i < m_players.size(); i++) {
                if (m_players.at(i)->serviceName() == name) {
                    qCDebug(MPRIS2) << "Remove player" << name;
                    m_players.takeAt(i)->deleteLater();
                    Q_EMIT playersChanged();
                    break;
                }
            }
        }
    });
}
MprisManager::MprisManager(QObject *parent)
    : QObject(parent)
    , m_singleService(false)
    , m_playbackStatusMapper(new QSignalMapper(this))
{
    QDBusConnection connection = QDBusConnection::sessionBus();

    if (!connection.isConnected()) {
//        qmlInfo(this) << "Failed attempting to connect to DBus";
        return;
    }

    connection.connect(dBusService, dBusObjectPath, dBusInterface, dBusNameOwnerChangedSignal,
                       QStringList(), QString(),
                       this, SLOT(onNameOwnerChanged(QString, QString, QString)));

    QStringList serviceNames = connection.interface()->registeredServiceNames();
    QStringList::const_iterator i = serviceNames.constBegin();
    while (i != serviceNames.constEnd()) {
        QRegExp rx(mprisNameSpace);
        rx.setPatternSyntax(QRegExp::Wildcard);
        if (rx.exactMatch(*i)) {
            onServiceAppeared(*i);
        }

        ++i;
    }
}
Exemple #9
0
/* Remove uinput device, stop threads and unregister from dbus
 */
Tohkbd::~Tohkbd()
{
    /* Restore orientation when shutting down */
    if (forceLandscapeOrientation)
    {
        tohkbd2user->setOrientationLock(currentOrientationLock);
    }

    uinputif->closeUinputDevice();

    worker->abort();
    thread->wait();
    delete thread;
    delete worker;

    if (dbusRegistered)
    {
        QDBusConnection connection = QDBusConnection::systemBus();
        connection.unregisterObject(PATH);
        connection.unregisterService(SERVICE);

        printf("tohkbd2: unregistered from dbus systemBus\n");
        tohkbd2user->quit();
    }
}
Exemple #10
0
void quitApplicationsOverDBus()
{
    QDBusConnection connection = QDBusConnection::sessionBus();
    QDBusConnectionInterface *bus = connection.interface();
    const QStringList services = bus->registeredServiceNames();
    foreach (const QString &service, services) {
        if (service.startsWith(QLatin1String("org.freedesktop.DBus")) || service.startsWith(QLatin1Char(':'))) {
            continue;
        }
        QDBusInterface *iface = new QDBusInterface(service,
                QLatin1String("/MainApplication"),
                QLatin1String("org.kde.KApplication"),
                connection);
        if (!iface->isValid()) {
            if (verbose) {
                fprintf(stderr, "invalid interface of service %s\n", service.toLatin1().data());
            }
            continue;
        }
        iface->call("quit");
        if (iface->lastError().isValid()) {
            if (verbose) {
                fprintf(stderr, "killing %s with result\n", iface->lastError().message().toLatin1().data());
            }
        }
        delete iface;
    }
}
// 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
}
bool QNetworkManagerInterface::setConnections()
{
    if(!isValid() )
        return false;

    QDBusConnection dbusConnection = QDBusConnection::systemBus();

    bool allOk = false;
    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
                                  QLatin1String(NM_DBUS_PATH),
                                  QLatin1String(NM_DBUS_INTERFACE),
                                  QLatin1String("PropertiesChanged"),
                                nmDBusHelper,SLOT(slotPropertiesChanged(QMap<QString,QVariant>)))) {
        allOk = true;
    }
    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
                                  QLatin1String(NM_DBUS_PATH),
                                  QLatin1String(NM_DBUS_INTERFACE),
                                  QLatin1String("DeviceAdded"),
                                this,SIGNAL(deviceAdded(QDBusObjectPath)))) {
        allOk = true;
    }
    if (!dbusConnection.connect(QLatin1String(NM_DBUS_SERVICE),
                                  QLatin1String(NM_DBUS_PATH),
                                  QLatin1String(NM_DBUS_INTERFACE),
                                  QLatin1String("DeviceRemoved"),
                                  this,SIGNAL(deviceRemoved(QDBusObjectPath)))) {
        allOk = true;
    }

    return allOk;
}
bool QNetworkManagerSettingsConnection::setConnections()
{
    if(!isValid() )
        return false;

    QDBusConnection dbusConnection = QDBusConnection::systemBus();
    bool allOk = false;
    if(!dbusConnection.connect(d->service, d->path,
                           QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Updated"),
                           this, SIGNAL(updated(QNmSettingsMap)))) {
        allOk = true;
    } else {
        QDBusError error = dbusConnection.lastError();
    }

    delete nmDBusHelper;
    nmDBusHelper = new QNmDBusHelper(this);
    connect(nmDBusHelper, SIGNAL(pathForSettingsRemoved(QString)),
            this,SIGNAL(removed(QString)));

    if (!dbusConnection.connect(d->service, d->path,
                           QLatin1String(NM_DBUS_IFACE_SETTINGS_CONNECTION), QLatin1String("Removed"),
                           nmDBusHelper, SIGNAL(slotSettingsRemoved()))) {
        allOk = true;
    }

    return allOk;
}
Exemple #14
0
void processSession(QString arg)
{
	QDBusConnection conn = QDBusConnection::sessionBus();
	QDBusConnectionInterface* bus = conn.interface();
	
	if(bus->isServiceRegistered("info.dolezel.fatrat"))
	{
		qDebug() << "FatRat is already running";
		
		if(!arg.isEmpty())
		{
			qDebug() << "Passing arguments to an existing instance.";
			QDBusInterface iface("info.dolezel.fatrat", "/", "info.dolezel.fatrat", conn);
			
			iface.call("addTransfers", arg);
		}
		else
		{
			QMessageBox::critical(0, "FatRat", QObject::tr("There is already a running instance.\n"
					"If you want to start FatRat anyway, pass --force among arguments."));
		}
		
		exit(0);
	}
}
Exemple #15
0
/**
 * \brief Constructor
 *
 * \todo Will set up the backends to the configured values
 */
SimonTTSPrivate::SimonTTSPrivate() : forceReinitialization(true)
{
  new SimonTTSAdaptor(this);
  QDBusConnection dbus = QDBusConnection::sessionBus();
  dbus.registerObject("/SimonTTS", this);
  dbus.registerService("org.simon-listens.SimonTTS");
}
Exemple #16
0
Config::Config(const QString &organization,
        const QString &application, QObject *parent):
    QSettings(organization, application, parent)
{
    proxyOn = false;
    proxyURL = "";
    proxyUser = "";
    proxyPasswd = "";
    proxyPort = 3128;
    read();

    if (value("CurrentWallpaper").toString().isNull()) {
        CurrentWallpaper =  DesktopWidget::applicationDirPath() + "/share/plexy/skins/default/default.png";
    }

    if (value("iconTheme").toString().isNull()) {
        iconTheme = "default";
    }

    collitionOn = false;

    if (widgetList.count() < 0) {
        writeToFile();
    }
#ifdef Q_WS_X11
    // register  with dbus
    new ConfigAdaptor(this);
    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.registerObject("/Configuration", this);
    dbus.registerService("org.PlexyDesk.Config");
#endif
}
Exemple #17
0
void
BTAdaptor::searchBtDevices ()
{
    // Connect to the signal DeviceFound to obtain the list of devices
    QDBusConnection bus = QDBusConnection::systemBus ();
    bool success = bus.connect ("org.bluez",
                                mAdapterPath,
                                "org.bluez.Adapter",
                                "DeviceFound",
                                this,
                                SLOT (deviceFound(QString,QMap<QString,QVariant>)));

    if (!success)
    {
        qDebug() << "Failure in connecting dbus signal";
        return;
    }
    
    QDBusMessage msg = QDBusMessage::createMethodCall ("org.bluez",
                                                       mAdapterPath,
                                                       "org.bluez.Adapter",
                                                       "StartDiscovery");

    QDBusMessage reply = bus.call (msg);
    if (reply.type () == QDBusMessage::ErrorMessage)
    {
        qWarning() << "Error in dbus call to search for devices";
        return ;
    }
}
Exemple #18
0
SplashApp::SplashApp(int &argc, char ** argv)
    : QApplication(argc, argv),
      m_stage(0),
      m_testing(false)
{
    m_testing = arguments().contains(QStringLiteral("--test"));

    m_desktop = QApplication::desktop();
    screenGeometryChanged(m_desktop->screenCount());

    setStage(1);

    QPixmap cursor(32, 32);
    cursor.fill(QColor(0, 0, 0, 0));
    setOverrideCursor(QCursor(cursor));

    if (m_testing) {
        m_timer.start(TEST_STEP_INTERVAL, this);
    }

    connect(m_desktop, SIGNAL(screenCountChanged(int)), this, SLOT(screenGeometryChanged(int)));
    connect(m_desktop, SIGNAL(workAreaResized(int)), this, SLOT(screenGeometryChanged(int)));

    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.registerObject(QStringLiteral("/KSplash"), this, QDBusConnection::ExportScriptableSlots);
    dbus.registerService(QStringLiteral("org.kde.KSplash"));
}
Exemple #19
0
DBusAdaptor::DBusAdaptor(MainWindow *mainWindow)
    : QDBusAbstractAdaptor(mainWindow), m_mainWindow(mainWindow)
{
    QDBusConnection connection = QDBusConnection::sessionBus();
    connection.registerService("org.qstardict.dbus");
    connection.registerObject("/qstardict", mainWindow);
}
Exemple #20
0
Knazar::Knazar(KAboutData *aboutData)
    : KSystemTrayIcon("knazar")
{
    new KnazarAdaptor(this);
    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.registerObject("/KNazar", this);

    aboutApplicationDialog = new KAboutApplicationDialog(aboutData);

    //Initialize actions
    actionAbout = new KAction(KIcon("help-about"), i18n("About KNazar"), this);
    actionProtect = new KAction(KIcon("flag-blue"), i18n("Protect"), this);
    actionRelease = new KAction(KIcon("flag-red"), i18n("Release"), this);

    // Connect actions
    connect(actionAbout, SIGNAL(triggered(bool)), aboutApplicationDialog, SLOT(show()));
    connect(actionProtect, SIGNAL(triggered(bool)), this, SLOT(protect_from_harmful_looks()));
    connect(actionRelease, SIGNAL(triggered(bool)), this, SLOT(release_the_protection()));

    // Add them to menu
    contextMenu()->addAction(actionProtect);
    contextMenu()->addAction(actionRelease);
    contextMenu()->addSeparator();
    contextMenu()->addAction(actionAbout);

    // Initialize variables
    protection_working = true;
    number_of_attacks = defated_attacks = 0;
    setToolTip(i18n("KNazar - No harmful look allowed!" ));
    normalIcon = icon();
    grayIcon.addPixmap(icon().pixmap(22, 22, QIcon::Disabled));
}
Exemple #21
0
KeyboardApplet::KeyboardApplet(QObject *parent, const QVariantList &args):
    Plasma::Applet(parent, args),
    xEventNotifier(),
    rules(Rules::readRules(Rules::READ_EXTRAS)),
    keyboardConfig(new KeyboardConfig()),
    layoutsMenu(new LayoutsMenu(*keyboardConfig, *rules, flags))
{
    if( ! X11Helper::xkbSupported(NULL) ) {
        setFailedToLaunch(true, i18n("XKB extension failed to initialize"));
        return;
    }

    m_svg = new Plasma::Svg(this);
    m_svg->setImagePath("widgets/labeltexture");
    m_svg->setContainsMultipleImages(true);
    resize(48,48);

    setHasConfigurationInterface(false);

    setAspectRatioMode(Plasma::KeepAspectRatio);
    //setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
    setBackgroundHints(DefaultBackground);
    connect(Plasma::Theme::defaultTheme(), SIGNAL(themeChanged()), this, SLOT(themeChanged()));

    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.connect(QString(), KEYBOARD_DBUS_OBJECT_PATH, KEYBOARD_DBUS_SERVICE_NAME, KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE, this, SLOT(configChanged()));
}
Exemple #22
0
int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QGraphicsScene scene;
    scene.setSceneRect(-500, -500, 1000, 1000);
    scene.setItemIndexMethod(QGraphicsScene::NoIndex);

    Car *car = new Car();
    scene.addItem(car);

    QGraphicsView view(&scene);
    view.setRenderHint(QPainter::Antialiasing);
    view.setBackgroundBrush(Qt::darkGray);
    view.setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Qt DBus Controlled Car"));
    view.resize(400, 300);
    view.show();

    new CarInterfaceAdaptor(car);
    QDBusConnection connection = QDBusConnection::sessionBus();
    connection.registerObject("/Car", car);
    connection.registerService("org.example.CarExample");

    return app.exec();
}
Exemple #23
0
DBusSignals::DBusSignals(QObject *parent) : QObject(parent)
{
    new TheshellAdaptor(this);
    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.registerObject("/org/thesuite/theshell", this);
    dbus.registerService("org.thesuite.theshell");
}
Exemple #24
0
void runGUI(const QString &dbusAddr, const QStringList &files, const QString &title, const QString &options, uint count)
{
    QDBusConnection dbus = QDBusConnection::connectToBus(dbusAddr, "boomaga");
    if (!dbus.isConnected())
    {
        error("Can't connect to org.boomaga DBus");
    }

    QDBusMessage msg = QDBusMessage::createMethodCall(
                "org.boomaga",
                "/boomaga",
                "org.boomaga",
                "add");

    foreach (QString file, files)
    {
        QList<QVariant> args;
        args << file;
        args << title;
        args << true;
        args << options;
        args << count;
        msg.setArguments(args);

        QStringList sl;
        foreach (const QVariant &arg, args)
        {
            sl << "'" + arg.toString() +"'";
        }
 Pinger getPingerPeer(const QString &path = "/")
 {
     QDBusConnection con = QDBusConnection("peer");
     if (!con.isConnected())
         return Pinger();
     return Pinger(new com::trolltech::QtDBus::Pinger("", path, con));
 }
bool TransportTracker::btConnectivityStatus()
{
    FUNCTION_CALL_TRACE;

    bool btOn = false;
    QDBusConnection *systemBus = new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SystemBus,
                                                                                    QStringLiteral("buteo_system_bus2")));
    QDBusMessage methodCallMsg = QDBusMessage::createMethodCall("org.bluez",
                                                                "/",
                                                                "org.bluez.Manager",
                                                                "DefaultAdapter");

    QDBusMessage reply = systemBus->call(methodCallMsg);
    if (reply.type() == QDBusMessage::ErrorMessage)
    {
        LOG_WARNING("This device does not have a BT adapter");
        delete systemBus;
        return btOn;
    }

    QList<QVariant> adapterList = reply.arguments();
    // We will take the first adapter in the list
    QString adapterPath = qdbus_cast<QDBusObjectPath>(adapterList.at(0)).path();

    if (!adapterPath.isEmpty() || !adapterPath.isNull())
    {
        // Retrive the properties of the adapter and check for "Powered" key
        methodCallMsg = QDBusMessage::createMethodCall("org.bluez",
                                                       adapterPath,
                                                       "org.bluez.Adapter",
                                                       "GetProperties");
        reply = systemBus->call(methodCallMsg);
        if (reply.type() == QDBusMessage::ErrorMessage)
        {
            LOG_WARNING("Error in retrieving bluetooth properties");
            delete systemBus;
            return btOn;
        }

        QDBusArgument arg = reply.arguments().at(0).value<QDBusArgument>();
        if (arg.currentType() == QDBusArgument::MapType)
        {
            // Scan through the dict returned and check for "Powered" entry
            QMap<QString,QVariant> dict = qdbus_cast<QMap<QString,QVariant> >(arg);
            QMap<QString,QVariant>::iterator iter;
            for(iter = dict.begin(); iter != dict.end(); ++iter)
            {
                if (iter.key() == "Powered")
                {
                    btOn = iter.value().toBool();
                    LOG_DEBUG ("Bluetooth powered on? " << btOn);
                    break;
                }
            }
        }
    }
    delete systemBus;
    return btOn;
}
Exemple #27
0
BTClient::BTClient(QObject *parent) : QObject (parent)
{
    QDBusConnection bus = QDBusConnection::systemBus ();
    bool success = bus.connect ("org.bluez", "", "org.bluez.Adapter", "PropertyChanged", this, SLOT (btStateChanged (QString, QDBusVariant)));
    qDebug () << success;
    if (success == false)
        qWarning("Cannot connect to org.bluez.Adapter::PropertyChanged signal.");
}
void TrackerDocumentProvider::componentComplete()
{
    QDBusConnection sessionBus = QDBusConnection::sessionBus();
    sessionBus.connect(dbusService, dbusPath, dbusInterface, dbusSignal, this, SLOT(trackerGraphChanged(QString,QVariantList,QVariantList)));

    d->connection = new QSparqlConnection(trackerDriver);
    startSearch();
}
Exemple #29
0
IMPanel::IMPanel(QObject* parent)
        : QObject(parent)
{
    new IMPanelAdaptor(this);
    QDBusConnection connection = QDBusConnection::sessionBus();
    connection.registerService("org.kde.impanel");
    connection.registerObject("/org/kde/impanel", this);
}
Exemple #30
0
KeyboardApplet::~KeyboardApplet()
{
    QDBusConnection dbus = QDBusConnection::sessionBus();
    dbus.disconnect(QString(), KEYBOARD_DBUS_OBJECT_PATH, KEYBOARD_DBUS_SERVICE_NAME, KEYBOARD_DBUS_CONFIG_RELOAD_MESSAGE, this, SLOT(configChanged()));

    delete layoutsMenu;
    delete rules;
}