void KMixVolumeConfigurationPlugin::refreshMasterVolume()
{
    QDBusMessage message = QDBusMessage::createMethodCall("org.kde.kmix", "/Mixer0", "org.kde.KMix", "masterVolume");
    QDBusMessage reply = dbus.call(message, QDBus::Block);
    int newVolume = reply.arguments().at(0).toInt();
    if(newVolume != masterVolume.getValue().toInt())
    {
        masterVolume.setValue(newVolume);
    }
}
Example #2
0
bool ProcessRunner::launchCommand(const QString &command)
{
    const QDBusConnection bus = QDBusConnection::sessionBus();
    QDBusInterface interface(QStringLiteral("io.liri.Session"),
                             QStringLiteral("/ProcessLauncher"),
                             QStringLiteral("io.liri.ProcessLauncher"),
                             bus);
    QDBusMessage msg = interface.call(QStringLiteral("launchCommand"), command);
    return msg.arguments().at(0).toBool();
}
/*!
    Releases the claim on the bus service name \a serviceName, that
    had been previously registered with registerService(). If this
    application had ownership of the name, it will be released for
    other applications to claim. If it only had the name queued, it
    gives up its position in the queue.
*/
QDBusReply<bool>
QDBusConnectionInterface::unregisterService(const QString &serviceName)
{
    QDBusMessage reply = call(QLatin1String("ReleaseName"), serviceName);
    if (reply.type() == QDBusMessage::ReplyMessage) {
        bool success = reply.arguments().at(0).toUInt() == DBUS_RELEASE_NAME_REPLY_RELEASED;
        reply.setArguments(QVariantList() << success);
    }
    return reply;
}
bool DeclarativeDBusAdaptor::handleMessage(const QDBusMessage &message, const QDBusConnection &connection)
{
    QVariant variants[10];
    QGenericArgument arguments[10];

    const QMetaObject * const meta = metaObject();
    const QVariantList dbusArguments = message.arguments();

    QString member = message.member();
    QString interface = message.interface();

    // Don't try to handle introspect call. It will be handled
    // internally for QDBusVirtualObject derived classes.
    if (interface == QLatin1String("org.freedesktop.DBus.Introspectable")) {
        return false;
    } else if (interface == QLatin1String("org.freedesktop.DBus.Properties")) {
        if (member == QLatin1String("Get")) {
            interface = dbusArguments.value(0).toString();
            member = dbusArguments.value(1).toString();

            const QMetaObject * const meta = metaObject();
            if (!member.isEmpty() && member.at(0).isUpper())
                member = "rc" + member;

            for (int propertyIndex = meta->propertyOffset();
                    propertyIndex < meta->propertyCount();
                    ++propertyIndex) {
                QMetaProperty property = meta->property(propertyIndex);

                if (QLatin1String(property.name()) != member)
                    continue;

                QVariant value = property.read(this);
                if (value.userType() == qMetaTypeId<QJSValue>())
                    value = value.value<QJSValue>().toVariant();

                if (value.userType() == QVariant::List) {
                    QVariantList variantList = value.toList();
                    if (variantList.count() > 0) {

                        QDBusArgument list;
                        list.beginArray(variantList.first().userType());
                        foreach (const QVariant &listValue, variantList) {
                            list << listValue;
                        }
                        list.endArray();
                        value = QVariant::fromValue(list);
                    }
                }

                QDBusMessage reply = message.createReply(QVariantList() << value);
                connection.call(reply, QDBus::NoBlock);

                return true;
            }
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;
}
Example #6
0
QList<QVariant> TestNetctlAuto::sendDBusRequest(const QString path, const QString cmd, const QList<QVariant> args)
{
    QDBusConnection bus = QDBusConnection::systemBus();
    QDBusMessage request = QDBusMessage::createMethodCall(DBUS_HELPER_SERVICE, path,
                                                          DBUS_HELPER_INTERFACE, cmd);
    if (!args.isEmpty()) request.setArguments(args);
    QDBusMessage response = bus.call(request);
    QList<QVariant> arguments = response.arguments();

    return arguments;
}
Example #7
0
	//Callback (slot) used to retrieve subscribed event information
	void DBusInterface::dispatchEvent(const QDBusMessage& message)
	{
		// unpack event
		QString eventReceivedName= message.arguments().at(1).value<QString>();
		Values eventReceivedValues = dBusMessagetoValues(message,2);
		// find and trigger matching callback
		if( callbacks.count(eventReceivedName) > 0)
		{
			callbacks[eventReceivedName](eventReceivedValues);
		}
	}
Example #8
0
bool restoreExistSession()
{
    QDBusConnection bus = QDBusConnection::sessionBus();
    QDBusMessage request = QDBusMessage::createMethodCall(QString(DBUS_SERVICE),
                                                          QString(DBUS_OBJECT_PATH),
                                                          QString(DBUS_INTERFACE),
                                                          QString("Restore"));
    QDBusMessage response = bus.call(request);
    QList<QVariant> arguments = response.arguments();
    return ((arguments.size() == 1) && arguments[0].toBool());
}
QVariant DBusResponseWaiter::waitForReply(QVariant variant) const
{
    if (QDBusPendingCall* call = const_cast<QDBusPendingCall*>(extractPendingCall(variant)))
    {
        call->waitForFinished();
        
        if (call->isError())
        {
            return QVariant("error");
        }
        
        QDBusMessage reply = call->reply();

        if (reply.arguments().count() > 0)
        {
            return reply.arguments().first();
        }
    }
    return QVariant();
}
Example #10
0
QVariant DBusHandler::call(QDBusInterface *interface,
                           const QString &query,
                           const QVariant &arg1,
                           const QVariant &arg2,
                           const QVariant &arg3,
                           const QVariant &arg4,
                           const QVariant &arg5,
                           const QVariant &arg6,
                           const QVariant &arg7,
                           const QVariant &arg8) const
{
    QDBusMessage reply = interface->call(query, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
    if (reply.arguments().length() > 1) {
        return QVariant(reply.arguments());
    } else if (reply.arguments().length() > 0) {
        return reply.arguments().at(0);
    } else {
        return QVariant();
    }
}
/// Returns the name of the current implementor of an interface. If an error
/// occurs (e.g., we cannot connect to the Meego service mapper), returns an
/// empty string.
QString ServiceResolver::implementorName(const QString& interface)
{
    if (resolved.contains(interface))
        return resolved[interface];

    if (!mapperProxy->isValid()) {
        LCA_WARNING << "cannot connect to service mapper";
        return "";
    }

    // A blocking call
    QDBusMessage reply = mapperProxy->call("serviceName", interface);
    if (reply.type() != QDBusMessage::ReplyMessage || reply.arguments().size() == 0) {
        LCA_WARNING << "invalid reply from service mapper" << reply.errorName();
        return "";
    }
    QString service = reply.arguments()[0].toString();
    resolved.insert(interface, service);
    return service;
}
Example #12
0
/*!
    Requests to register the service name \a serviceName on the
    bus. The \a qoption flag specifies how the D-Bus server should behave
    if \a serviceName is already registered. The \a roption flag
    specifies if the server should allow another application to
    replace our registered name.

    If the service registration succeeds, the serviceRegistered()
    signal will be emitted. If we are placed in queue, the signal will
    be emitted when we obtain the name. If \a roption is
    AllowReplacement, the serviceUnregistered() signal will be emitted
    if another application replaces this one.

    \sa unregisterService()
*/
QDBusReply<QDBusConnectionInterface::RegisterServiceReply>
QDBusConnectionInterface::registerService(const QString &serviceName,
                                          ServiceQueueOptions qoption,
                                          ServiceReplacementOptions roption)
{
    // reconstruct the low-level flags
    uint flags = 0;
    switch (qoption) {
    case DontQueueService:
        flags = DBUS_NAME_FLAG_DO_NOT_QUEUE;
        break;
    case QueueService:
        flags = 0;
        break;
    case ReplaceExistingService:
        flags = DBUS_NAME_FLAG_DO_NOT_QUEUE | DBUS_NAME_FLAG_REPLACE_EXISTING;
        break;
    }

    switch (roption) {
    case DontAllowReplacement:
        break;
    case AllowReplacement:
        flags |= DBUS_NAME_FLAG_ALLOW_REPLACEMENT;
        break;
    }

    QDBusMessage reply = call(QLatin1String("RequestName"), serviceName, flags);
//    qDebug() << "QDBusConnectionInterface::registerService" << serviceName << "Reply:" << reply;

    // convert the low-level flags to something that we can use
    if (reply.type() == QDBusMessage::ReplyMessage) {
        uint code = 0;

        switch (reply.arguments().at(0).toUInt()) {
        case DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER:
        case DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER:
            code = uint(ServiceRegistered);
            break;

        case DBUS_REQUEST_NAME_REPLY_EXISTS:
            code = uint(ServiceNotRegistered);
            break;

        case DBUS_REQUEST_NAME_REPLY_IN_QUEUE:
            code = uint(ServiceQueued);
            break;
        }

        reply.setArguments(QVariantList() << code);
    }

    return reply;
}
/************************************************
 Helper func
 ************************************************/
static bool dbusCall(const QString &service,
              const QString &path,
              const QString &interface,
              const QDBusConnection &connection,
              const QString & method,
              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);

    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.
    return msg.arguments().isEmpty() ||
           msg.arguments().first().isNull() ||
           msg.arguments().first().toBool();
}
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;
}
Example #15
0
void MissionControl::onHeadsetButtonPressed(QDBusMessage msg)
{
    if (msg.arguments()[0] == "ButtonPressed") {
        if (msg.arguments()[1] == "play-cd" || msg.arguments()[1] == "pause-cd")
            togglePlayback();
        else if (msg.arguments()[1] == "stop-cd")
            mafwRenderer->stop();
        else if (msg.arguments()[1] == "next-song")
            mafwRenderer->next();
        else if (msg.arguments()[1] == "previous-song")
            mafwRenderer->previous();
        else if (msg.arguments()[1] == "fast-forward")
            mafwRenderer->setPosition(SeekRelative, 3);
        else if (msg.arguments()[1] == "rewind")
            mafwRenderer->setPosition(SeekRelative, -3);
        else if (msg.arguments()[1] == "phone")
            handlePhoneButton();
        else if (msg.arguments()[1] == "jack_insert" && msg.path() == HAL_PATH_RX51_JACK) // wired headset was connected or disconnected
            updateWiredHeadset();
    }
}
Example #16
0
void DbusAdapter::_mitakuuluuMessageReceived(QDBusMessage msg) {
    qDebug() << "Mitakuuluu messageReceived:" << msg;

    QDBusArgument *arg = (QDBusArgument *) msg.arguments().at(0).data();

    if (arg->currentType() == QDBusArgument::MapType) {
        QMap<QString, QString> argMap = unpackMessage(*arg);

        qDebug() << "Extracted argument map:" << argMap;
        emit commhistoryd(argMap.value("author"), argMap.value("message"));
    }
}
Example #17
0
/*!
    Places a call to the remote method specified by \a method on this interface, using \a args as
    arguments. This function returns the message that was received as a reply, which can be a normal
    QDBusMessage::ReplyMessage (indicating success) or QDBusMessage::ErrorMessage (if the call
    failed). The \a mode parameter specifies how this call should be placed.

    If the call succeeds, lastError() will be cleared; otherwise, it will contain the error this
    call produced.

    Normally, you should place calls using call().

    \warning If you use \c UseEventLoop, your code must be prepared to deal with any reentrancy:
             other method calls and signals may be delivered before this function returns, as well
             as other Qt queued signals and events.

    \threadsafe
*/
QDBusMessage QDBusAbstractInterface::callWithArgumentList(QDBus::CallMode mode,
        const QString& method,
        const QList<QVariant>& args)
{
    Q_D(QDBusAbstractInterface);

    if (!d->isValid || !d->canMakeCalls())
        return QDBusMessage::createError(d->lastError);

    QString m = method;
    // split out the signature from the method
    int pos = method.indexOf(QLatin1Char('.'));
    if (pos != -1)
        m.truncate(pos);

    if (mode == QDBus::AutoDetect) {
        // determine if this a sync or async call
        mode = QDBus::Block;
        const QMetaObject *mo = metaObject();
        QByteArray match = m.toLatin1();

        for (int i = staticMetaObject.methodCount(); i < mo->methodCount(); ++i) {
            QMetaMethod mm = mo->method(i);
            if (mm.name() == match) {
                // found a method with the same name as what we're looking for
                // hopefully, nobody is overloading asynchronous and synchronous methods with
                // the same name

                QList<QByteArray> tags = QByteArray(mm.tag()).split(' ');
                if (tags.contains("Q_NOREPLY"))
                    mode = QDBus::NoBlock;

                break;
            }
        }
    }

//    qDebug() << "QDBusAbstractInterface" << "Service" << service() << "Path:" << path();
    QDBusMessage msg = QDBusMessage::createMethodCall(service(), path(), interface(), m);
    QDBusMessagePrivate::setParametersValidated(msg, true);
    msg.setArguments(args);

    QDBusMessage reply = d->connection.call(msg, mode, d->timeout);
    if (thread() == QThread::currentThread())
        d->lastError = QDBusError(reply);       // will clear if reply isn't an error

    // ensure that there is at least one element
    if (reply.arguments().isEmpty())
        reply << QVariant();

    return reply;
}
void UDiskProvider::update()
{

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

    QDBusMessage enumRes = devEnum.call("EnumerateDevices");
    if (enumRes.type() != QDBusMessage::ReplyMessage || !enumRes.arguments().at(0).canConvert<QDBusArgument>())
    {
        if (enumRes.type() == QDBusMessage::ErrorMessage)
            qWarning() << "ERROR: Can't call EnumerateDevices"
                       <<  qPrintable(enumRes.errorName()) << qPrintable(enumRes.errorMessage());
        else
            qWarning() << "ERROR: Unexpected result type of EnumerateDevices call";
        return;
    }

    const QDBusArgument enumArg = enumRes.arguments().at(0).value<QDBusArgument>();
    if (enumArg.currentType() != QDBusArgument::ArrayType)
    {
        qWarning() << "ERROR: Unexpected argument type of EnumerateDevices call";
        return;
    }

    enumArg.beginArray();
    while (!enumArg.atEnd())
    {
        QDBusObjectPath path = qdbus_cast<QDBusObjectPath>(enumArg);

        if (mDevicesByPath.contains(path.path()))
            dbusDeviceChanged(path);
        else
            dbusDeviceAdded(path);
    }
    enumArg.endArray();

}
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;
    }
}
Example #20
0
void SHALDeviceNotifier::dumpAddedMessage( const QDBusMessage & dmsg )
{
    if( dmsg.type() != QDBusMessage::SignalMessage )
        return ;

    QList<QVariant> list = dmsg.arguments();
    if( list.isEmpty() )
        return ;

    QString path = list.at(0).toString();

    this->detect( path );
}
Example #21
0
/** ***************************************************************************/
bool MPRIS::Command::isApplicable(Player &p) const {
    // Check the applicable-option if given
    if (!applicableCheck_)
        return true;

    // split DBus interface and property into seperate strings
    int splitAt = property_.lastIndexOf('.');
    QString ifaceName = property_.left(splitAt);
    QString propertyName = property_.right(property_.length() - splitAt -1);

    // Compose Get-Property-Message
    QDBusMessage mesg = QDBusMessage::createMethodCall(
                p.getBusId(), //"org.mpris.MediaPlayer2.rhythmbox",
                path_, //"/org/mpris/MediaPlayer2",
                "org.freedesktop.DBus.Properties",
                "Get");
    QList<QVariant> args;
    // Specify DBus interface to get the property from and the property-name
    args.append(ifaceName); //"org.mpris.MediaPlayer2.Player");
    args.append(propertyName); //"CanGoNext");
    mesg.setArguments(args);

    // Query the property
    QDBusMessage reply = QDBusConnection::sessionBus().call(mesg);

    // Check if the result is as expected
    if ( reply.type() != QDBusMessage::ReplyMessage ){
        qWarning() << "Error while querying the property 'PlaybackStatus'";
        return true;
    }

    if ( reply.arguments().empty() ) {
        qWarning() << "Reply query 'PlaybackStatus' is empty";
        return true;
    }

    return (reply.arguments().at(0).value<QDBusVariant>().variant() == expectedValue_) == positivity_;
}
uint ANCSNotification::notify(uint replaces, QString title, QString message, QString icon,
                              bool feedback)
{
    QString appName = "";
    QVariantMap hints;

    if (feedback) {
        hints.insert("x-nemo-preview-body", message);
        hints.insert("x-nemo-preview-summary", title);
        hints.insert("x-nemo-feedback", "notif_strong");
    } else {
        hints.insert("x-nemo-feedback-suppressed", true);
    }
    hints.insert("urgency", 3);

    QList<QVariant> argumentList;
    argumentList << appName;
    argumentList << replaces;
    argumentList << icon;
    argumentList << title;
    argumentList << message;
    argumentList << QStringList();
    argumentList << hints;
    argumentList << (int) 0;

    static QDBusInterface notifyApp(NOTIFICATIONS_SERVICE_NAME, NOTIFICATIONS_PATH_BASE,
                                    NOTIFICATIONS_MAIN_IFACE);
    QDBusMessage reply = notifyApp.callWithArgumentList(QDBus::AutoDetect, "Notify", argumentList);
    if (reply.type() == QDBusMessage::ErrorMessage) {
        qWarning() << "Notify D-Bus call returned error:" << reply.errorMessage();
        return 0;
    }
    if (reply.arguments().size() < 1) {
        qWarning() << "Notify D-Bus call successful but no reply arguments";
        return 0;
    }
    return reply.arguments()[0].toUInt();
}
Example #23
0
bool NDBusDevice::update()
{
	if (NDBusStateTools::getInstance()->isSystemBusConnected() == false)
		return false;

	QDBusInterface iface(NM_DBUS_SERVICE, _path.path(), NM_DBUS_INTERFACE_DEVICES,
						 QDBusConnection::systemBus());

	if (iface.isValid()) {
		QDBusMessage msg = iface.call("getProperties");

		QDBusReply< QDBusObjectPath > reply = msg;
		if (reply.isValid())
			this->setObjectPath (reply.value().path());

		QList<QVariant> args = msg.arguments();

		if (args.count() < 21)
			return false;

		this->setInterface (args.at(1).toString());
        this->setType (args.at(2).toUInt());
        this->setUdi (args.at(3).toString());
		this->setActive (args.at(4).toBool());
		this->setActivationStage (args.at(5).toInt());
		this->setIPv4Address (args.at(6).toString());
		this->setSubnetmask (args.at(7).toString());
		this->setBroadcast (args.at(8).toString());
		this->setHardwareAddress (args.at(9).toString());
		this->setRoute (args.at(10).toString());
		this->setPrimaryDNS (args.at(11).toString());
		this->setSecondaryDNS (args.at(12).toString());
		this->setMode (args.at(13).toInt());
		this->setStrength (args.at(14).toInt());
		this->setLinkActive (args.at(15).toBool());
		this->setSpeed (args.at(16).toInt());
		this->setCapabilities (args.at(17).toUInt());
		this->setCapabilitiesType (args.at(18).toUInt());
		this->setActiveNetworkPath(args.at(19).toString());
		if (this->isWireless())
			this->setupNetworks(args.at(20).toStringList());
	}

	fprintf(stderr, "%s\n",
            qPrintable(QDBusConnection::systemBus().lastError().message()));

	return false;


}
int ThermaldInterface::getTripInformation(uint zone_index,
                                          uint trip_index, tripInformationType &info)
{
    QDBusMessage result;

    result = iface->call("GetZoneTripAtIndex", zone_index, trip_index);

    if (result.type() == QDBusMessage::ReplyMessage) {
        info.temp = result.arguments().at(0).toInt() / 1000;
        info.trip_type = result.arguments().at(1).toInt();
        info.sensor_id = result.arguments().at(2).toInt();
        info.cdev_size = result.arguments().at(3).toInt();
        //        info.cdev_ids = result.arguments().at(4).toList();
        return 0;
    } else if (result.signature().isEmpty()){
        // If we get and empty response, then ignore it, but return error code
        return -1;
    } else {
        qCritical() << "error from" << iface->interface() <<  result.errorMessage()
                    << zone_index << trip_index;
        return -1;
    }
}
void
FdoNotifyPlugin::dbusCapabilitiesReplyReceived( QDBusPendingCallWatcher* watcher )
{
    QDBusMessage reply = watcher->reply();
    watcher->deleteLater();

    if ( reply.type() == QDBusMessage::ErrorMessage )
    {
        tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Failed to request capabilities of notifications";
    }

    const QStringList& capability_list = reply.arguments().first().toStringList();
    m_wmSupportsBodyMarkup = capability_list.contains( "body-markup" );
}
Example #26
0
static QScriptValue do_dbus_call(QScriptContext *context, QScriptEngine *engine)
{
    int firstArgument = 0;
    QString functionName = context->callee().property(QLatin1String("functionName")).toString();
    if (functionName.isEmpty()) {
        functionName = context->argument(0).toString();
        ++firstArgument;
    }

    QScriptValue thisObject = context->thisObject();
    QDBusAbstractInterface *iface = qobject_cast<QDBusAbstractInterface *>(thisObject.toQObject());
    if (!iface)
        return QScriptValue();

    QDBusMessage msg = QDBusMessage::createMethodCall(iface->service(),
                                                      iface->path(),
                                                      iface->interface(),
                                                      functionName);

    QList<QVariant> args;
    for (int i = firstArgument; i < context->argumentCount(); ++i) {
        args.append(context->argument(i).toVariant());
    }
    msg.setArguments(args);

    msg = iface->connection().call(msg);

    QScriptValue returnValue = engine->nullValue();
    args = msg.arguments();
    if (args.count() != 1)
        return returnValue;

    QVariant variant = args.first();
    if (variant.type() == QVariant::UserType
        && variant.userType() == qMetaTypeId<QDBusObjectPath>()) {
        QDBusObjectPath path = qvariant_cast<QDBusObjectPath>(variant);

        QDBusInterface *returnedIface = new QDBusInterface(iface->service(),
                                                           path.path(),
                                                           /*interface*/QString(),
                                                           iface->connection(),
                                                           engine);
        returnValue = setupDBusInterface(engine, returnedIface);
    } else {
        returnValue = engine->newVariant(variant);
    }

    return returnValue;
}
Example #27
0
void DbusAdapter::_phoneCall(QDBusMessage msg) {
    qDebug() << "Got phone call dbus message:" << msg;

    QDBusArgument *arg = (QDBusArgument *) msg.arguments().at(1).data();

    if (arg->currentType() == QDBusArgument::MapType) {
        QMap<QString, QString> argMap = unpackMessage(*arg);

        qDebug() << "Extracted argument map:" << argMap;

        if (argMap.value("State") == "incoming") {
            emit phoneCall(argMap.value("LineIdentification"), argMap.value("Name"));
        }
    }
}
Example #28
0
void HalSuspendJob::resumeDone(const QDBusMessage &reply)
{
    if (reply.type() == QDBusMessage::ErrorMessage)
    {
        // We ignore the NoReply error, since we can timeout anyway
        // if the computer is suspended for too long.
        if (reply.errorName() != "org.freedesktop.DBus.Error.NoReply")
        {
            setError(1);
            setErrorText(reply.errorName()+": "+reply.arguments().at(0).toString());
        }
    }

    emitResult();
}
void device::parseRemovableMessage(const QDBusMessage &message)
{

    QDBusVariant dbusVariant= qvariant_cast<QDBusVariant>(message.arguments().at(0));
    if (dbusVariant.variant().toBool())
    {
        m_isRemovable=removable;
    }
    else
    {
        m_isRemovable=notRemovable;
    }

    maybeEmitLoaded();
}
Example #30
0
bool ProcessRunner::launchApplication(const QString &name)
{
    const QString fileName = QStandardPaths::locate(QStandardPaths::ApplicationsLocation,
                                                    name + QStringLiteral(".desktop"));
    if (fileName.isEmpty())
        return false;

    const QDBusConnection bus = QDBusConnection::sessionBus();
    QDBusInterface interface(QStringLiteral("org.hawaiios.Session"),
                             QStringLiteral("/ProcessLauncher"),
                             QStringLiteral("org.hawaiios.ProcessLauncher"),
                             bus);
    QDBusMessage msg = interface.call("launchDesktopFile", fileName);
    return msg.arguments().at(0).toBool();
}