File indexing completed on 2024-11-10 04:57:17
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2013 Martin Gräßlin <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #include "dbuscall.h" 0010 #include "scriptingutils.h" 0011 0012 #include <QDBusConnection> 0013 #include <QDBusMessage> 0014 #include <QDBusPendingCall> 0015 0016 namespace KWin 0017 { 0018 0019 DBusCall::DBusCall(QObject *parent) 0020 : QObject(parent) 0021 { 0022 } 0023 0024 DBusCall::~DBusCall() 0025 { 0026 } 0027 0028 void DBusCall::call() 0029 { 0030 QDBusMessage msg = QDBusMessage::createMethodCall(m_service, m_path, m_interface, m_method); 0031 msg.setArguments(m_arguments); 0032 0033 QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(QDBusConnection::sessionBus().asyncCall(msg), this); 0034 connect(watcher, &QDBusPendingCallWatcher::finished, this, [this, watcher]() { 0035 watcher->deleteLater(); 0036 if (watcher->isError()) { 0037 Q_EMIT failed(); 0038 return; 0039 } 0040 QVariantList reply = watcher->reply().arguments(); 0041 std::for_each(reply.begin(), reply.end(), [](QVariant &variant) { 0042 variant = dbusToVariant(variant); 0043 }); 0044 Q_EMIT finished(reply); 0045 }); 0046 } 0047 0048 } // KWin 0049 0050 #include "moc_dbuscall.cpp"