| 1 | /* |
| 2 | SPDX-FileCopyrightText: 2017 David Edmundson <davidedmundson@kde.org> |
| 3 | |
| 4 | SPDX-License-Identifier: LGPL-2.0-or-later |
| 5 | */ |
| 6 | |
| 7 | #pragma once |
| 8 | |
| 9 | #include <KRunner/AbstractRunner> |
| 10 | |
| 11 | #include "dbusutils_p.h" |
| 12 | #include <QHash> |
| 13 | #include <QImage> |
| 14 | #include <QList> |
| 15 | #include <QSet> |
| 16 | |
| 17 | namespace KRunner |
| 18 | { |
| 19 | class DBusRunner : public KRunner::AbstractRunner |
| 20 | { |
| 21 | Q_OBJECT |
| 22 | |
| 23 | public: |
| 24 | explicit DBusRunner(QObject *parent, const KPluginMetaData &data); |
| 25 | |
| 26 | // matchInternal is overwritten. Meaning we do not need the original match |
| 27 | void match(KRunner::RunnerContext &) override |
| 28 | { |
| 29 | } |
| 30 | void reloadConfiguration() override; |
| 31 | void run(const KRunner::RunnerContext &context, const KRunner::QueryMatch &match) override; |
| 32 | |
| 33 | Q_INVOKABLE void matchInternal(KRunner::RunnerContext context); |
| 34 | |
| 35 | private: |
| 36 | // Returns RemoteActions with service name as key |
| 37 | void requestActions(); |
| 38 | void requestActionsForService(const QString &service, const std::function<void()> &finishedCallback); |
| 39 | QList<QueryMatch> convertMatches(const QString &service, const RemoteMatches &remoteMatches); |
| 40 | void requestConfig(); |
| 41 | static QImage decodeImage(const RemoteImage &remoteImage); |
| 42 | QSet<QString> m_matchingServices; |
| 43 | QHash<QString, QList<KRunner::Action>> m_actions; |
| 44 | const QString m_path; |
| 45 | const bool m_hasUniqueResults; |
| 46 | const bool m_requestActionsOnce; |
| 47 | bool m_actionsForSessionRequested = false; |
| 48 | bool m_matchWasCalled = false; |
| 49 | bool m_callLifecycleMethods = false; |
| 50 | const QString m_ifaceName; |
| 51 | QSet<QString> m_requestedActionServices; |
| 52 | }; |
| 53 | } |
| 54 | |