void IMQDBus::useSkype() { QDBusMessage msg = QDBusMessage::createMethodCall ( "com.Skype.API", "/com/Skype", "com.Skype.API", "Invoke" ); QList<QVariant> args; args.append ( QVariant ( QString ( "NAME Choqok" ) ) ); msg.setArguments ( args ); QDBusMessage rep = QDBusConnection::sessionBus().call ( msg ); if ( rep.type() == QDBusMessage::ErrorMessage ) { qDebug() << "ERROR" << rep.errorMessage(); return; } args.clear(); args.append ( QVariant ( QString ( "PROTOCOL 7" ) ) ); msg.setArguments ( args ); rep = QDBusConnection::sessionBus().call ( msg ); if ( rep.type() == QDBusMessage::ErrorMessage ) { qDebug() << "ERROR" << rep.errorMessage(); return; } args.clear(); args.append ( QVariant ( QString ( "SET PROFILE MOOD_TEXT %1" ).arg ( m_statusMsg ) ) ); msg.setArguments ( args ); rep = QDBusConnection::sessionBus().call ( msg ); if ( rep.type() == QDBusMessage::ErrorMessage ) { qDebug() << "ERROR" << rep.errorMessage(); return; } }
void MainWindow::triggerWarningAlarm() { clearAlarm(); m_belowAlarmTime = true; if (m_useLED) { qDebug() << "alarm time"; #ifdef IS_MAEMO QDBusMessage reply; // set the LED pattern reply = m_dbusInterface->call(MCE_ACTIVATE_LED_PATTERN, "PatternError"); if (reply.type() == QDBusMessage::ErrorMessage) qDebug() << reply.errorMessage(); // turn on the display too reply = m_dbusInterface->call(MCE_DISPLAY_ON_REQ, 1); if (reply.type() == QDBusMessage::ErrorMessage) qDebug() << reply.errorMessage(); #endif } if (m_useSounds) { qDebug() << "playing sound"; m_warningFile.setFileName(DATADIR "/agenda/sounds/KDE_NotifySm.wav"); m_warningFile.open(QIODevice::ReadOnly); m_audioOut->reset(); m_audioOut->start(&m_warningFile); } }
void Ut_CReporterNotification::testNotificationActivated() { notification = new CReporterNotification("crash-reporter", "test-summary", "test-body", "icon-test"); // Spy activated signal from notification. QSignalSpy activatedSpy(notification, SIGNAL(activated())); // Wait for notification. QTest::qWait(1000); QVERIFY(notification->isPublished() == true); QString objPath(CREPORTER_DBUS_NTF_OBJECT_PATH); objPath.append("00000000000000000000000000000000"); // Interact with the notification via D-Bus and block. QDBusMessage reply = QDBusConnection::sessionBus().call(QDBusMessage::createMethodCall( QDBusConnection::sessionBus().baseService(), objPath, CREPORTER_DBUS_NTF_INTERFACE, "activate")); if (reply.type() == QDBusMessage::ErrorMessage) { qDebug() << reply.errorMessage(); QFAIL("Error message received from D-Bus."); } QVERIFY(activatedSpy.count() == 1); }
/************************************************ Helper func ************************************************/ void printDBusMsg(const QDBusMessage &msg) { qWarning() << "** Dbus error **************************"; qWarning() << "Error name " << msg.errorName(); qWarning() << "Error msg " << msg.errorMessage(); qWarning() << "****************************************"; }
void NetworkDevice::disconnectDevice() { QDBusMessage query = m_networkDeviceInterface->call("Disconnect"); if(query.type() != QDBusMessage::ReplyMessage) qCWarning(dcNetworkManager()) << query.errorName() << query.errorMessage(); }
void SIMLockService::LockPhone() { //dbus-send --system --type=method_call //--dest=com.nokia.system_ui /com/nokia/system_ui/request com.nokia.system_ui.request.devlock_open //string:"com.nokia.mce" //string:"/com/nokia/mce/request" //string:"com.nokia.mce.request" //string:"devlock_callback" //uint32:'3' QDBusMessage reply = LockInterface->call("devlock_open", "com.nokia.mce", "/com/nokia/mce/request", "com.nokia.mce.request", "devlock_callback", (quint32)3); if(reply.type() == QDBusMessage::ErrorMessage) qDebug() << "Failed to lock phone:" << reply.errorName() << reply.errorMessage(); if(reply.arguments()[0].toBool() == true) qDebug() << "Phone locked"; else qDebug() << "Phone failed to lock"; }
bool DbusPopupHandler::initObjects() { if (!initNotifyInterface()) return false; FServerInfo = new ServerInfo; QDBusMessage replyCaps = FNotifyInterface->call(QDBus::Block, "GetCapabilities"); if (replyCaps.type() != QDBusMessage::ErrorMessage) { for (int i=0; i<replyCaps.arguments().at(0).toStringList().count(); i++) LOG_INFO(QString("Capabilities: %1").arg(replyCaps.arguments().at(0).toStringList().at(i))); FServerInfo->capabilities = replyCaps.arguments().at(0).toStringList(); FAllowActions = FServerInfo->capabilities.contains("actions"); } else LOG_WARNING(QString("Capabilities: DBus Error: %1").arg(replyCaps.errorMessage())); QDBusMessage replyInfo = FNotifyInterface->call(QDBus::Block, "GetServerInformation"); if (replyInfo.type() != QDBusMessage::ErrorMessage) { for (int i=0; i<replyInfo.arguments().count(); i++) LOG_INFO(QString("Server Information: %1").arg(replyInfo.arguments().at(i).toString())); FServerInfo->name = replyInfo.arguments().at(0).toString(); FServerInfo->vendor = replyInfo.arguments().at(1).toString(); FServerInfo->version = replyInfo.arguments().at(2).toString(); FServerInfo->spec_version = replyInfo.arguments().at(3).toString(); } else LOG_WARNING(QString("Server Information: DBus Error: %1").arg(replyInfo.errorMessage())); if (FAllowActions) { connect(FNotifyInterface,SIGNAL(ActionInvoked(uint,QString)),this,SLOT(onActionInvoked(uint,QString))); connect(FNotifyInterface,SIGNAL(NotificationClosed(uint,uint)),this,SLOT(onNotificationClosed(uint,uint))); LOG_INFO(QLatin1String("Actions supported.")); } else LOG_INFO(QLatin1String("Actions not supported.")); FNotifications->insertNotificationHandler(NHO_DBUSPOPUP, this); return true; }
/*! \internal Constructs a QDBusError from a QDBusMessage. */ QDBusError::QDBusError(const QDBusMessage &qdmsg) : code(NoError) { if (qdmsg.type() != QDBusMessage::ErrorMessage) return; code = ::get(qdmsg.errorName().toUtf8().constData()); nm = qdmsg.errorName(); msg = qdmsg.errorMessage(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow), m_timer(), m_totalNeededTime(0,0), m_spentTime(0,0), m_belowAlarmTime(false), m_belowEndTime(false), m_dbusInterface(0), m_alarmTime(60), m_useLED(true), m_useSounds(true) { ui->setupUi(this); m_topics.push_back(new AgendaTopic("topic #1", QTime(0,5))); m_topics.push_back(new AgendaTopic("topic #2", QTime(0,15))); calculateTotalTimes(); m_currentTopic = 1; mainWindowSetup(); setupMenus(); connect(ui->next, SIGNAL(clicked()), this, SLOT(switchToNextTopic())); connect(ui->previous, SIGNAL(clicked()), this, SLOT(switchToPreviousTopic())); connect(ui->start, SIGNAL(clicked()), this, SLOT(startOrStop())); connect(ui->plus15, SIGNAL(clicked()), this, SLOT(add15m())); connect(ui->plus5, SIGNAL(clicked()), this, SLOT(add5m())); connect(ui->plus1, SIGNAL(clicked()), this, SLOT(add1m())); connect(ui->minus15, SIGNAL(clicked()), this, SLOT(minus15m())); connect(ui->minus5, SIGNAL(clicked()), this, SLOT(minus5m())); connect(ui->minus1, SIGNAL(clicked()), this, SLOT(minus1m())); connect(&m_timer, SIGNAL(timeout()), this, SLOT(timeElapsed())); #ifdef IS_MAEMO m_dbusInterface = new QDBusInterface(MCE_SERVICE, MCE_REQUEST_PATH, MCE_REQUEST_IF, QDBusConnection::systemBus(), this); QDBusMessage reply = m_dbusInterface->call(MCE_ENABLE_LED); if (reply.type() == QDBusMessage::ErrorMessage) qDebug() << reply.errorMessage(); #endif // set up the output audio QAudioFormat format; // Set up the format, eg. format.setFrequency(44100); format.setChannels(1); format.setSampleSize(16); format.setCodec("audio/pcm"); format.setByteOrder(QAudioFormat::LittleEndian); format.setSampleType(QAudioFormat::SignedInt); QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice()); m_audioOut = new QAudioOutput(format); // connect(m_audioOut,SIGNAL(stateChanged(QAudio::State)),SLOT(finishedPlaying(QAudio::State))); }
QVariant ModeControlEntity::_call_ret(const QString req) const { if (!m_iface) { return QVariant(); } QDBusMessage m = m_iface->call(req); if (m.type() == QDBusMessage::ErrorMessage || m.arguments().count() == 0) { qWarning() << "Could not get activity state:" << m.errorMessage(); return QVariant(); } return m.arguments().first(); }
void IMQDBus::useKopete() { QDBusMessage msg = QDBusMessage::createMethodCall ( "org.kde.kopete", "/Kopete", "org.kde.Kopete", "setStatusMessage" ); QList<QVariant> args; args.append ( QVariant ( m_statusMsg ) ); msg.setArguments ( args ); QDBusMessage rep = QDBusConnection::sessionBus().call ( msg ); if ( rep.type() == QDBusMessage::ErrorMessage ) { qDebug() << "ERROR" << rep.errorMessage(); return; } }
int ThermaldInterface::getSensorTypeForZone(uint zone, uint index, QString &sensor_type) { QDBusMessage result; result = iface->call("GetZoneSensorAtIndex", zone, index); if (result.type() == QDBusMessage::ReplyMessage) { sensor_type = result.arguments().at(0).toString(); return 0; } else { qCritical() << "error from" << iface->interface() << result.errorMessage(); return -1; } }
void IMQDBus::usePsi() { QDBusMessage msg = QDBusMessage::createMethodCall ( "org.psi-im.Psi", "/Main", "org.psi_im.Psi.Main", "setStatus" ); QList<QVariant> args; args.append ( QVariant ( "online" ) ); args.append ( QVariant ( m_statusMsg ) ); msg.setArguments ( args ); QDBusMessage rep = QDBusConnection::sessionBus().call ( msg ); if ( rep.type() == QDBusMessage::ErrorMessage ) { qDebug() << "ERROR" << rep.errorMessage(); return; } }
// // Function to process the reply from a dbus call. QDBusMessage::MessageType shared::processReply(const QDBusMessage& reply) { if (reply.type() != QDBusMessage::ReplyMessage) { QMessageBox::warning(0, QString(TranslateStrings::cmtr("cmst") + qApp->translate("processReply", " Warning") ), qApp->translate("processReply", "<center><b>We received a DBUS reply message indicating an error.</b></center>" "<br><br>Error Name: %1<br><br>Error Message: %2") .arg(reply.errorName()) .arg(TranslateStrings::cmtr(reply.errorMessage())) ); } // if reply is something other than a normal reply message return reply.type(); }
int ThermaldInterface::getZoneInformation(uint index, zoneInformationType &info) { QDBusMessage result; result = iface->call("GetZoneInformation", index); if (result.type() == QDBusMessage::ReplyMessage) { info.name = result.arguments().at(0).toString(); info.sensor_count = result.arguments().at(1).toInt(); info.trip_count = result.arguments().at(2).toInt(); return 0; } else { qCritical() << "error from" << iface->interface() << result.errorMessage(); return -1; } }
void MainWindow::clearAlarm() { if (!m_belowAlarmTime) return; qDebug() << "clearing time"; m_belowAlarmTime = false; m_belowEndTime = false; #ifdef IS_MAEMO QDBusMessage reply; reply = m_dbusInterface->call(MCE_DEACTIVATE_LED_PATTERN, "PatternError"); if (reply.type() == QDBusMessage::ErrorMessage) qDebug() << reply.errorMessage(); #endif }
ActionReply Helper::dbusaction(const QVariantMap& args) { ActionReply reply; QDBusMessage dbusreply; // Get arguments to method call QString service = args["service"].toString(); QString path = args["path"].toString(); QString interface = args["interface"].toString(); QString method = args["method"].toString(); QList<QVariant> argsForCall = args["argsForCall"].toList(); QDBusConnection systembus = QDBusConnection::systemBus(); QDBusInterface *iface = new QDBusInterface (service, path, interface, systembus, this); if (iface->isValid()) dbusreply = iface->callWithArgumentList(QDBus::AutoDetect, method, argsForCall); delete iface; // Error handling if (method != "Reexecute") { if (dbusreply.type() == QDBusMessage::ErrorMessage) { reply.setErrorCode(ActionReply::DBusError); reply.setErrorDescription(dbusreply.errorMessage()); } } // Reload systemd daemon to update the enabled/disabled status if (method == "EnableUnitFiles" || method == "DisableUnitFiles" || method == "MaskUnitFiles" || method == "UnmaskUnitFiles") { // systemd does not update properties when these methods are called so we // need to reload the systemd daemon. iface = new QDBusInterface ("org.freedesktop.systemd1", "/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", systembus, this); dbusreply = iface->call(QDBus::AutoDetect, "Reload"); delete iface; } // return a reply return reply; }
/** * Handle the DBus reply triggered by FdoNotifyPlugin::nowPlaying */ void FdoNotifyPlugin::dbusPlayingReplyReceived( QDBusPendingCallWatcher* watcher ) { QDBusMessage reply = watcher->reply(); watcher->deleteLater(); if ( reply.type() == QDBusMessage::ErrorMessage ) { tLog(LOGVERBOSE) << "Failed to grab media keys" << reply.errorName() << reply.errorMessage(); return; } const QVariantList& list = reply.arguments(); if ( !list.isEmpty() ) m_nowPlayingId = list.first().toInt(); }
int ThermaldInterface::getCoolingDeviceInformation(uint index, coolingDeviceInformationType &info) { QDBusMessage result; result = iface->call("GetCdevInformation", index); if (result.type() == QDBusMessage::ReplyMessage) { info.name = result.arguments().at(0).toString(); info.min_state = result.arguments().at(1).toInt(); info.max_state = result.arguments().at(2).toInt(); info.current_state = result.arguments().at(3).toInt(); return 0; } else { qCritical() << "error from" << iface->interface() << result.errorMessage(); return -1; } }
void KWalletExecuter::pamRead(const QString &value) const { QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kwalletd", "/modules/kwalletd", "org.kde.KWallet", "readPassword"); QVariantList args; args << m_handler << QLatin1String("Passwords") << QLatin1String("foo") << QLatin1String("buh"); msg.setArguments(args); const QDBusMessage reply = QDBusConnection::sessionBus().call(msg); QVERIFY2(reply.type() != QDBusMessage::ErrorMessage, reply.errorMessage().toLocal8Bit()); const QString password = reply.arguments().first().toString(); QCOMPARE(password, value); }
void KWalletExecuter::pamOpen() { QDBusMessage msg = QDBusMessage::createMethodCall("org.kde.kwalletd", "/modules/kwalletd", "org.kde.KWallet", "open"); QVariantList args; qlonglong wid = 0; args << QLatin1String("kdewallet") << wid << QLatin1String("buh"); msg.setArguments(args); const QDBusMessage reply = QDBusConnection::sessionBus().call(msg); QVERIFY2(reply.type() != QDBusMessage::ErrorMessage, reply.errorMessage().toLocal8Bit()); m_handler = reply.arguments().first().toInt(); if (m_handler <= 0) { qFatal("Couldn't open the wallet via dbus");//We don't want the test to continue } }
/************************************************ Helper func Just like dbusCall(), except that systemd returns a string instead of a bool, and it takes an "interactivity boolean" as an argument. ************************************************/ static bool dbusCallSystemd(const QString &service, const QString &path, const QString &interface, const QDBusConnection &connection, const QString &method, bool needBoolArg, PowerProvider::DbusErrorCheck errorCheck = PowerProvider::CheckDBUS ) { QDBusInterface dbus(service, path, interface, connection); if (!dbus.isValid()) { qWarning() << "dbusCall: QDBusInterface is invalid" << service << path << interface << method; if (errorCheck == PowerProvider::CheckDBUS) { Notification::notify( QObject::tr("Power Manager Error"), QObject::tr("QDBusInterface is invalid")+ "\n\n" + service + " " + path + " " + interface + " " + method, "lxqt-logo.png"); } return false; } QDBusMessage msg = dbus.call(method, needBoolArg ? QVariant(true) : QVariant()); if (!msg.errorName().isEmpty()) { printDBusMsg(msg); if (errorCheck == PowerProvider::CheckDBUS) { Notification::notify( QObject::tr("Power Manager Error (D-BUS call)"), msg.errorName() + "\n\n" + msg.errorMessage(), "lxqt-logo.png"); } } // If the method no returns value, we believe that it was successful. if (msg.arguments().isEmpty() || msg.arguments().first().isNull()) return true; QString response = msg.arguments().first().toString(); qDebug() << "systemd:" << method << "=" << response; return response == "yes" || response == "challenge"; }
QDebug operator<<(QDebug dbg, const QDBusMessage &msg) { dbg.nospace() << "QDBusMessage(type=" << msg.type() << ", service=" << msg.service(); if (msg.type() == QDBusMessage::MethodCallMessage || msg.type() == QDBusMessage::SignalMessage) dbg.nospace() << ", path=" << msg.path() << ", interface=" << msg.interface() << ", member=" << msg.member(); if (msg.type() == QDBusMessage::ErrorMessage) dbg.nospace() << ", error name=" << msg.errorName() << ", error message=" << msg.errorMessage(); dbg.nospace() << ", signature=" << msg.signature() << ", contents=("; debugVariantList(dbg, msg.arguments()); dbg.nospace() << ") )"; return dbg.space(); }
void QuickDBusReply::callFinishedSlot(QDBusPendingCallWatcher *call) { Q_ASSERT(call); setWaiting(false); QDBusMessage msg = call->reply(); if (msg.type() == QDBusMessage::ReplyMessage) { setValues(msg.arguments()); } else { setValid(false); setErrorName(msg.errorName()); setErrorString(msg.errorMessage()); } call->deleteLater(); }
bool ANCSNotification::hide() { if (!shown) return true; QList<QVariant> argumentList; argumentList << dbusNotificationId; static QDBusInterface notifyApp(NOTIFICATIONS_SERVICE_NAME, NOTIFICATIONS_PATH_BASE, NOTIFICATIONS_MAIN_IFACE); QDBusMessage reply = notifyApp.callWithArgumentList(QDBus::AutoDetect, "CloseNotification", argumentList); if (reply.type() == QDBusMessage::ErrorMessage) { qWarning() << "CloseNotification D-Bus call returned error" << reply.errorMessage(); return false; } shown = false; return true; }
void Mp3tunesAmarokClient::harmonyDownloadReady( const Mp3tunesHarmonyDownload &download ) { qDebug() << "Got message about ready: " << download.trackTitle() << " by " << download.artistName() << " on " << download. albumTitle(); QString name = "org.kde.amarok"; QDBusMessage m = QDBusMessage::createMethodCall( name, "/Mp3tunesHarmonyHandler", "", "emitDownloadReady" ); QList<QVariant> args; args.append( download.serialize() ); m.setArguments(args); QDBusMessage response = QDBusConnection::sessionBus().call( m ); if( response.type() == QDBusMessage::ErrorMessage ) { qDebug() << "Got ERROR response harmonyDownloadReady"; qDebug() << response.errorName() << ": " << response.errorMessage(); } }
void GnomeGlobalShortcutBackend::RegisterFinished( QDBusPendingCallWatcher* watcher) { #ifdef QT_DBUS_LIB QDBusMessage reply = watcher->reply(); watcher->deleteLater(); if (reply.type() == QDBusMessage::ErrorMessage) { qLog(Warning) << "Failed to grab media keys" << reply.errorName() << reply.errorMessage(); return; } connect(interface_, SIGNAL(MediaPlayerKeyPressed(QString, QString)), this, SLOT(GnomeMediaKeyPressed(QString, QString))); is_connected_ = true; qLog(Debug) << "registered"; #endif // QT_DBUS_LIB }
QString SettingsUi::readUserDaemonVersion() { QDBusInterface getUserDaemonVersionCall("com.kimmoli.tohkbd2user", "/", "com.kimmoli.tohkbd2user", QDBusConnection::sessionBus()); getUserDaemonVersionCall.setTimeout(2000); QDBusMessage getUserDaemonVersionReply = getUserDaemonVersionCall.call(QDBus::AutoDetect, "getVersion"); if (getUserDaemonVersionReply.type() == QDBusMessage::ErrorMessage) { qDebug() << "Error reading daemon version:" << getUserDaemonVersionReply.errorMessage(); return QString("N/A"); } QString userDaemonVersion = getUserDaemonVersionReply.arguments().at(0).toString(); qDebug() << "User daemon version is" << userDaemonVersion; return userDaemonVersion; }
int PlatformUdisks2::open(DeviceItem* item) { int ret = -1; QDBusConnection connection = QDBusConnection::systemBus(); QList<QVariant> args; QVariantMap map; args << map; QString udi = QString("/org/freedesktop/UDisks2/block_devices/%1").arg(item->getUDI()); QDBusMessage message = QDBusMessage::createMethodCall("org.freedesktop.UDisks2", udi, "org.freedesktop.UDisks2.Block", "OpenForRestore"); message.setArguments(args); QDBusMessage reply = connection.call(message); if (reply.type() == QDBusMessage::ErrorMessage) { QMessageBox msgBox; msgBox.setText(QString("DBUS error (%1): %2").arg(item->getUDI()).arg(reply.errorMessage())); msgBox.exec(); ret = -1; } else if (reply.arguments().empty() || reply.arguments()[0].userType() != qMetaTypeId<QDBusUnixFileDescriptor>()) { QMessageBox msgBox; msgBox.setText(QString("got empty or invalid reply!?")); msgBox.exec(); errno = EINVAL; } else { QDBusUnixFileDescriptor fd(qvariant_cast<QDBusUnixFileDescriptor>(reply.arguments()[0])); if (fd.isValid()) { ret = ::dup(fd.fileDescriptor()); } } qDebug() << "ret" << ret; return ret; }
bool DBusComm::sendDBusRegister() { QDBusMessage reply = positioningdProxy->call("registerListener", myService.toAscii().constData(), myPath.toAscii().constData()); if (reply.type() == QDBusMessage::ReplyMessage) { QList<QVariant> values = reply.arguments(); clientId = values.takeFirst().toInt(); quint32 m = values.takeFirst().toUInt(); availablePositioningMethods = (QGeoPositionInfoSource::PositioningMethod) m; minimumUpdateInterval = values.takeFirst().toUInt(); } else { cerr << endl << "DBus error:\n"; cerr << reply.errorName().toAscii().constData() << endl; cerr << reply.errorMessage().toAscii().constData() << endl; return false; } return true; }