2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2013-08-12 12:58:05 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
|
2013-08-12 12:58:05 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2013-08-12 12:58:05 +00:00
|
|
|
#include "dbuscall.h"
|
2021-01-24 11:56:42 +00:00
|
|
|
#include "scriptingutils.h"
|
2013-08-12 12:58:05 +00:00
|
|
|
|
|
|
|
#include <QDBusConnection>
|
|
|
|
#include <QDBusMessage>
|
|
|
|
#include <QDBusPendingCall>
|
|
|
|
|
|
|
|
namespace KWin {
|
|
|
|
|
|
|
|
DBusCall::DBusCall(QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
DBusCall::~DBusCall()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void DBusCall::call()
|
|
|
|
{
|
|
|
|
QDBusMessage msg = QDBusMessage::createMethodCall(m_service, m_path, m_interface, m_method);
|
|
|
|
msg.setArguments(m_arguments);
|
|
|
|
|
|
|
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(msg), this);
|
2021-08-22 12:51:36 +00:00
|
|
|
connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher]() {
|
2013-08-12 12:58:05 +00:00
|
|
|
watcher->deleteLater();
|
|
|
|
if (watcher->isError()) {
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT failed();
|
2013-08-12 12:58:05 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-01-24 11:56:42 +00:00
|
|
|
QVariantList reply = watcher->reply().arguments();
|
|
|
|
std::for_each(reply.begin(), reply.end(), [](QVariant &variant) {
|
|
|
|
variant = dbusToVariant(variant);
|
|
|
|
});
|
2021-06-08 07:02:14 +00:00
|
|
|
Q_EMIT finished(reply);
|
2013-08-12 12:58:05 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
} // KWin
|