KWin
Loading...
Searching...
No Matches
dbuscall.cpp
Go to the documentation of this file.
1/*
2 KWin - the KDE window manager
3 This file is part of the KDE project.
4
5 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org>
6
7 SPDX-License-Identifier: GPL-2.0-or-later
8*/
9#include "dbuscall.h"
10#include "scriptingutils.h"
11
12#include <QDBusConnection>
13#include <QDBusMessage>
14#include <QDBusPendingCall>
15
16namespace KWin
17{
18
19DBusCall::DBusCall(QObject *parent)
20 : QObject(parent)
21{
22}
23
27
29{
30 QDBusMessage msg = QDBusMessage::createMethodCall(m_service, m_path, m_interface, m_method);
31 msg.setArguments(m_arguments);
32
33 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(msg), this);
34 connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher]() {
35 watcher->deleteLater();
36 if (watcher->isError()) {
37 Q_EMIT failed();
38 return;
39 }
40 QVariantList reply = watcher->reply().arguments();
41 std::for_each(reply.begin(), reply.end(), [](QVariant &variant) {
42 variant = dbusToVariant(variant);
43 });
44 Q_EMIT finished(reply);
45 });
46}
47
48} // KWin
49
50#include "moc_dbuscall.cpp"
void finished(QVariantList returnValue)
~DBusCall() override
Definition dbuscall.cpp:24
DBusCall(QObject *parent=nullptr)
Definition dbuscall.cpp:19