void request_watcher_t::call_returned(QDBusPendingCallWatcher *w) { log_debug() ; log_assert(w==this->w, "oops, somethig is really wrong with qdbus...") ; QDBusPendingReply<bool> reply = *w ; bool ok = reply.isValid() and reply.value() ; abstract_io_state_t *next = machine->state_dlg_user ; if (ok) log_notice("Voland acknowledge received, moving %d event(s) to DLG_USER", events.size()) ; else { string err = reply.isValid() ? "false returned" : reply.error().message().toStdString() ; log_error("Voland call 'create' failed, message: '%s'", err.c_str()) ; log_notice("moving %d event(s) to DLG_WAIT", events.size()) ; next = machine->state_dlg_wait ; } for(set<event_t*>::const_iterator it=events.begin(); it!=events.end(); ++it) next->go_to(*it) ; if (events.size()>0) machine->process_transition_queue() ; // Don't need the watcher any more delete this ; }
void LogTest::findEventsTest() { QZeitgeist::DataModel::Event event; QZeitgeist::DataModel::EventList events; // Set the template to search for. event.setActor("app://firefox.desktop"); event.setSubjects(QZeitgeist::DataModel::SubjectList()); // Add to the event list. events << event; // Query for all events since Epoch. QZeitgeist::DataModel::TimeRange timeRange = QZeitgeist::DataModel::TimeRange::timeRangeToNow(); // Search on Zeitgeist. QDBusPendingReply<QZeitgeist::DataModel::EventList> reply = m_log->findEvents(timeRange, events, QZeitgeist::Log::Any, 10, QZeitgeist::Log::MostRecentEvents); // Block and wait for reply. reply.waitForFinished(); // Check if the return is valid. QVERIFY (reply.isValid() == true); // Check if the return is not empty QVERIFY (reply.value().size() > 0); // Check if the id is 0; for (uint i = 0; i < reply.value().size(); ++i) QVERIFY(reply.value()[i].id() != 0); }
void CReporterNotificationPrivate::retrieveNotificationId() { if (callWatcher == 0) return; callWatcher->waitForFinished(); QDBusPendingReply<quint32> reply = *callWatcher; callWatcher->deleteLater(); callWatcher = 0; if (reply.isValid()) { id = reply.argumentAt<0>(); if (id == 0) { // Notification didn't exist, create a new one. sendDBusNotify(); retrieveNotificationId(); return; } qDebug() << __PRETTY_FUNCTION__ << "Create notification with id: " << id; } else if (reply.isError()) { QDBusError error = reply.error(); qDebug() << __PRETTY_FUNCTION__ << "Failed to create notification: " << error.name() << " - " << error.message(); } }
void PowerDevilRunner::updateStatus() { // Profiles and their icons { KSharedConfigPtr profilesConfig = KSharedConfig::openConfig("powerdevil2profilesrc", KConfig::SimpleConfig); // Request profiles to the daemon QDBusMessage call = QDBusMessage::createMethodCall("org.kde.Solid.PowerManagement", "/org/kde/Solid/PowerManagement", "org.kde.Solid.PowerManagement", "availableProfiles"); QDBusPendingReply< StringStringMap > reply = QDBusConnection::sessionBus().asyncCall(call); reply.waitForFinished(); if (!reply.isValid()) { kDebug() << "Error contacting the daemon!"; return; } m_availableProfiles = reply.value(); if (m_availableProfiles.isEmpty()) { kDebug() << "No available profiles!"; return; } for (StringStringMap::const_iterator i = m_availableProfiles.constBegin(); i != m_availableProfiles.constEnd(); ++i) { KConfigGroup settings(profilesConfig, i.key()); if (settings.readEntry< QString >("icon", QString()).isEmpty()) { m_profileIcon[i.key()] = "preferences-system-power-management"; } else { m_profileIcon[i.key()] = settings.readEntry< QString >("icon", QString()); } } } updateSyntaxes(); }
void OOPClientPlugin::abortSync( Sync::SyncStatus aStatus ) { FUNCTION_CALL_TRACE; QDBusPendingReply<void> reply = iOopPluginIface->abortSync( (uchar)aStatus ); reply.waitForFinished(); if( !reply.isValid() ) LOG_WARNING( "Invalid reply for connectivityStateChanged from plugin" ); }
void OOPServerPlugin::resume() { FUNCTION_CALL_TRACE; QDBusPendingReply<bool> reply = iOopPluginIface->resume(); reply.waitForFinished(); if( !reply.isValid() ) LOG_WARNING( "Invalid reply for resume from plugin" ); }
void OOPClientPlugin::connectivityStateChanged( Sync::ConnectivityType aType, bool aState ) { FUNCTION_CALL_TRACE; QDBusPendingReply<void> reply = iOopPluginIface->connectivityStateChanged( aType, aState ); reply.waitForFinished(); if( !reply.isValid() ) LOG_WARNING( "Invalid reply for connectivityStateChanged from plugin" ); }
Daemon::Authorize Daemon::canAuthorize(const QString &actionId) { Q_D(Daemon); QDBusPendingReply<uint> reply = d->daemon->CanAuthorize(actionId); reply.waitForFinished(); d->lastError = reply.error(); if (reply.isValid()) { return static_cast<Daemon::Authorize>(reply.value()); } return Daemon::AuthorizeUnknown; }
QDBusObjectPath Daemon::getTid() { Q_D(Daemon); QDBusPendingReply<QDBusObjectPath> reply = d->daemon->CreateTransaction(); reply.waitForFinished(); d->lastError = reply.error(); if (reply.isValid()) { return reply.value(); } return QDBusObjectPath(); }
uint Daemon::getTimeSinceAction(Transaction::Role role) { Q_D(Daemon); QDBusPendingReply<uint> reply = d->daemon->GetTimeSinceAction(role); reply.waitForFinished(); d->lastError = reply.error(); if (reply.isValid()) { return reply.value(); } return 0u; }
QList<QDBusObjectPath> Daemon::getTransactionList() { Q_D(Daemon); QDBusPendingReply<QList<QDBusObjectPath> > reply = d->daemon->GetTransactionList(); reply.waitForFinished(); d->lastError = reply.error(); if (reply.isValid()) { return reply.value(); } return QList<QDBusObjectPath>(); }
bool OOPClientPlugin::init() { FUNCTION_CALL_TRACE; QDBusPendingReply<bool> reply = iOopPluginIface->init(); reply.waitForFinished(); if( !reply.isValid() ) { LOG_WARNING( "Invalid reply for init from plugin" ); return false; } return reply.value(); }
void KGetRunner::callFinished(QDBusPendingCallWatcher* call) { QDBusPendingReply<> reply = *call; // TODO Remove the check for QDBusError::NoReply when NewTransferDialog is fixed to show asynchronously. if(!reply.isValid() && (reply.error().type() != QDBusError::NoReply)) { // Send a notification about the error to the user. KNotification::event(KNotification::Error, i18n("<p>KGet Runner could not communicate with KGet.</p><p style=\"font-size: small;\">Response from DBus:<br/>%1</p>", reply.error().message()), KIcon("dialog-warning").pixmap(KIconLoader::SizeSmall)/*, 0, KNotification::Persistant*/); } }
bool OOPServerPlugin::cleanUp() { FUNCTION_CALL_TRACE; QDBusPendingReply<bool> reply = iOopPluginIface->cleanUp(); reply.waitForFinished(); if( !reply.isValid() ) { LOG_WARNING( "Invalid reply for cleanUp from plugin" ); return false; } return reply.value(); }
void ConferenceAuthOp::onPasswordProvided(QDBusPendingCallWatcher *watcher) { QDBusPendingReply<bool> reply = *watcher; if (!reply.isValid() || reply.count() < 1) { return; } if (reply.argumentAt<0>()) { m_walletInterface->setEntry(m_account,m_channel->targetId(), m_password); setFinished(); } else { qDebug() << "Password was incorrect, enter again"; passwordDialog(); } }
void A2DPTest::connectResult(QDBusPendingCallWatcher *watcher) { watcher->deleteLater(); QDBusPendingReply<> reply = *watcher; if (!reply.isValid()) { if (reply.isError() && reply.error().name() == A2DP_CONNECTED) { emit deviceReady(true); return; } delete audioSink; audioSink = NULL; emit deviceReady(false); } else emit deviceReady(true); }
void DeviceKitLister::Init() { interface_.reset(new OrgFreedesktopUDisksInterface( OrgFreedesktopUDisksInterface::staticInterfaceName(), "/org/freedesktop/UDisks", QDBusConnection::systemBus())); // Get all the devices currently attached QDBusPendingReply<QList<QDBusObjectPath> > reply = interface_->EnumerateDevices(); reply.waitForFinished(); if (!reply.isValid()) { qLog(Warning) << "Error enumerating DeviceKit-disks devices:" << reply.error().name() << reply.error().message(); interface_.reset(); return; } // Listen for changes connect(interface_.get(), SIGNAL(DeviceAdded(QDBusObjectPath)), SLOT(DBusDeviceAdded(QDBusObjectPath))); connect(interface_.get(), SIGNAL(DeviceRemoved(QDBusObjectPath)), SLOT(DBusDeviceRemoved(QDBusObjectPath))); connect(interface_.get(), SIGNAL(DeviceChanged(QDBusObjectPath)), SLOT(DBusDeviceChanged(QDBusObjectPath))); // Get information about each one QMap<QString, DeviceData> device_data; for (const QDBusObjectPath& path : reply.value()) { DeviceData data = ReadDeviceData(path); if (data.suitable) device_data[data.unique_id()] = data; } // Update the internal cache { QMutexLocker l(&mutex_); device_data_ = device_data; } // Notify about the changes for (const QString& id : device_data.keys()) { emit DeviceAdded(id); } }
void NetworkManager::Connection::onSecretsArrived(QDBusPendingCallWatcher *watcher) { Q_D(Connection); if (!watcher) return; QDBusPendingReply<NMVariantMapMap> reply = *watcher; QString id = watcher->property("libNetworkManagerQt_id").value<QString>(); bool success = true; NMVariantMapMap set; QString message; if (!reply.isValid()) { success = false; message = reply.error().message(); } else { set = reply.argumentAt<0>(); } emit gotSecrets(id, success, set, message); watcher->deleteLater(); }
void GnomeSessionClient::slotRegisterClientFinished(QDBusPendingCallWatcher* watcher) { QDBusPendingReply<QDBusObjectPath> reply = *watcher; watcher->deleteLater(); if (!reply.isValid()) { UQ_WARNING << "Failed to register with GnomeSession:" << reply.error().message(); return; } d->m_waitingForEndSession = true; QDBusConnection bus = QDBusConnection::sessionBus(); d->m_clientPath = reply.value().path(); bus.connect(SM_DBUS_SERVICE, d->m_clientPath, SM_CLIENT_DBUS_INTERFACE, "Stop", "", this, SLOT(stop())); bus.connect(SM_DBUS_SERVICE, d->m_clientPath, SM_CLIENT_DBUS_INTERFACE, "QueryEndSession", "u", this, SLOT(queryEndSession())); bus.connect(SM_DBUS_SERVICE, d->m_clientPath, SM_CLIENT_DBUS_INTERFACE, "EndSession", "u", this, SLOT(endSession())); }
void LogTest::getEventsTest() { QVERIFY(m_ids.size() > 0); // Get events from Zeitgeist. QDBusPendingReply<QZeitgeist::DataModel::EventList> reply = m_log->getEvents(m_ids); // Block and wait for reply. reply.waitForFinished(); // Check if the return is valid. QVERIFY (reply.isValid() == true); // Check if the return is not empty QVERIFY (reply.value().size() > 0); // Check if the id is not 0; for (uint i = 0; i < reply.value().size(); ++i) QVERIFY(reply.value()[i].id() != 0); };
void DockItem::showMenu(const QPoint &menuPos) { if (getMenuContent().isEmpty()) return; hidePreview(true); if (m_dbusMenuManager == nullptr) { m_dbusMenuManager = new DBusMenuManager(this); } QDBusPendingReply<QDBusObjectPath> pr = m_dbusMenuManager->RegisterMenu(); pr.waitForFinished(); if (pr.isValid()) { QDBusObjectPath op = pr.value(); if (m_dbusMenu != nullptr) { m_dbusMenu->deleteLater(); } m_dbusMenu = new DBusMenu(op.path(), this); connect(m_dbusMenu, &DBusMenu::ItemInvoked, this, &DockItem::invokeMenuItem); connect(m_dbusMenu, &DBusMenu::MenuUnregistered, [=] { setHoverable(true); }); QPoint pos = menuPos.isNull() ? QPoint(globalX() + width() / 2, globalY()) : menuPos; QJsonObject targetObj; targetObj.insert("x", QJsonValue(pos.x())); targetObj.insert("y", QJsonValue(pos.y())); targetObj.insert("isDockMenu", QJsonValue(true)); targetObj.insert("menuJsonContent", QJsonValue(getMenuContent())); m_dbusMenu->ShowMenu(QString(QJsonDocument(targetObj).toJson())); setHoverable(false); } }
void Udisks2Lister::Init() { udisks2_interface_.reset(new OrgFreedesktopDBusObjectManagerInterface( udisks2_service_, "/org/freedesktop/UDisks2", QDBusConnection::systemBus())); QDBusPendingReply<ManagedObjectList> reply = udisks2_interface_->GetManagedObjects(); reply.waitForFinished(); if (!reply.isValid()) { qLog(Warning) << "Error enumerating udisks2 devices:" << reply.error().name() << reply.error().message(); udisks2_interface_.reset(); return; } for (const QDBusObjectPath& path : reply.value().keys()) { auto partition_data = ReadPartitionData(path); if (!partition_data.dbus_path.isEmpty()) { QWriteLocker locker(&device_data_lock_); device_data_[partition_data.unique_id()] = partition_data; } } for (const auto& id : device_data_.keys()) { emit DeviceAdded(id); } connect(udisks2_interface_.get(), SIGNAL(InterfacesAdded(QDBusObjectPath, InterfacesAndProperties)), SLOT(DBusInterfaceAdded(QDBusObjectPath, InterfacesAndProperties))); connect(udisks2_interface_.get(), SIGNAL(InterfacesRemoved(QDBusObjectPath, QStringList)), SLOT(DBusInterfaceRemoved(QDBusObjectPath, QStringList))); }
SyncResults OOPClientPlugin::getSyncResults() const { FUNCTION_CALL_TRACE; SyncResults errorSyncResult( QDateTime(), SyncResults::SYNC_RESULT_INVALID, SyncResults::SYNC_RESULT_INVALID ); QDBusPendingReply<QString> reply = iOopPluginIface->getSyncResults(); reply.waitForFinished(); if( !reply.isValid() ) { LOG_WARNING( "Invalid reply for getSyncResults from plugin" ); return errorSyncResult; } QString resultAsXml = reply.value(); QDomDocument doc; if( doc.setContent(resultAsXml, true) ) { SyncResults syncResult( doc.documentElement() ); return syncResult; } else { LOG_CRITICAL( "Invalid sync results returned from plugin" ); return errorSyncResult; } }
QVariantMap TweetSupplier::getPublications(QString pluginMethod) { //connecting the QDBus with the widget QDBusMessage busMsg = QDBusMessage::createMethodCall("org.plexydesk.social", "/services","local.socioplexy.Configuration","getPluginsList"); //creating the QDBus connection with the sessionBus. QDBusConnection bus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "socioplexy"); /*Bus connection Checking.. if(bus.isConnected()) qDebug() << "QDBusConnection is successfull"; else qDebug()<<"QDBusConnection is unsuccessfull";*/ //listening for the reply from the QDBus QDBusPendingReply<QStringList> msgRep = bus.asyncCall(busMsg,10000); msgRep.waitForFinished(); //if reply is valid only proceed the QDBus connection method calling if (msgRep.isValid()) { QStringList plugins = msgRep.value(); if (!plugins.isEmpty()) { int i=0,j; //checking for the twitterplugin in the plugins list loaded. for (j=0;j<plugins.count();j++) { if (plugins.value(j)=="weatherplugin"){ i = 1; //Flag for plugin found break; } } //if plugin twitterplugin is found then request data from the plugin if (i == 1) { QString pluginName = plugins.value(j); QDBusMessage pluginBusMsg; pluginBusMsg = QDBusMessage::createMethodCall("org.plexydesk.social", "/services","local.socioplexy.Configuration","supportedMethods"); QList<QVariant> argsSuppMethods; argsSuppMethods << QVariant(pluginName); pluginBusMsg.setArguments(argsSuppMethods); qDebug()<<pluginBusMsg.arguments(); QDBusPendingReply<QStringList> supportMsgRep = bus.asyncCall(pluginBusMsg,1000); supportMsgRep.waitForFinished(); if (supportMsgRep.isValid()) { QStringList supportedMethodsList = supportMsgRep.value(); if(supportedMethodsList.contains(pluginMethod)) { QDBusMessage getDataMsg; QVariantMap args; QList<QVariant> argsData; getDataMsg = QDBusMessage::createMethodCall("org.plexydesk.social", "/services", "local.socioplexy.Configuration", "data"); argsData << QVariant("weatherplugin") << QVariant(pluginMethod) << QVariant(args); getDataMsg.setArguments(argsData); QDBusPendingReply<QVariantMap> recvData = bus.asyncCall(getDataMsg,10000); recvData.waitForFinished(); if(recvData.isValid()) return recvData.value(); else { QVariantMap dummy; dummy["Network Error"] = "Data not recieved"; return dummy; } } else qDebug() << "supportedMethods doesn't contain getPublicTimeline"; } else { qDebug()<<"Error reply "<<supportMsgRep.error(); } } else { qDebug()<<"No matching plugin loaded..."; } } else { qDebug()<<"No plugin name was retireved."; } } else { qDebug()<<"error reply"<<msgRep.error(); } }
void LogTest::insertEventsTest() { // Event list to be inserted. QZeitgeist::DataModel::EventList events; // Event item 1. QZeitgeist::DataModel::Event event1; event1.setInterpretation("foo://Interp"); event1.setManifestation("foo://Manif"); event1.setActor("app://firefox.desktop"); QZeitgeist::DataModel::Subject subject1; subject1.setUri("file:///tmp/bar.txt"); subject1.setInterpretation("foo://TextDoc"); subject1.setManifestation("foo://File"); subject1.setOrigin("file:///tmp"); subject1.setMimeType("text/plain"); subject1.setText("bar.txt"); subject1.setStorage("bfb486f6-f5f8-4296-8871-0cc749cf8ef7"); QZeitgeist::DataModel::SubjectList subjects1; subjects1 << subject1; event1.setSubjects(subjects1); events.append(event1); // Event item 2. QZeitgeist::DataModel::Event event2; event2.setInterpretation("foo://Interp2"); event2.setManifestation("foo://Manif2"); event2.setActor("app://firefox.desktop"); QZeitgeist::DataModel::Subject subject2; subject2.setUri("file:///tmp/bar.txt2"); subject2.setInterpretation("foo://TextDoc"); subject2.setManifestation("foo://File"); subject2.setOrigin("file:///tmp"); subject2.setMimeType("text/plain"); subject2.setText("bar.txt"); subject2.setStorage("bfb486f6-f5f8-4296-8871-0cc749cf8ef7"); QZeitgeist::DataModel::SubjectList subjects2; subjects2 << subject2; event2.setSubjects(subjects2); events.append(event2); // Insert events into Zeitgeist. QDBusPendingReply<QZeitgeist::DataModel::EventIdList> reply = m_log->insertEvents(events); // Block and wait for reply. reply.waitForFinished(); // Check if the return is valid. QVERIFY (reply.isValid() == true); // Check if the return is not empty QVERIFY (reply.value().size() > 0); // Check if the id is not 0; for (uint i = 0; i < reply.value().size(); ++i) QVERIFY(reply.value()[i] != 0); // Assign to our id list. m_ids = reply.value(); };