File indexing completed on 2024-04-21 03:56:47

0001 /*
0002     SPDX-FileCopyrightText: 2017 David Edmundson <davidedmundson@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <KRunner/AbstractRunner>
0010 
0011 #include "dbusutils_p.h"
0012 #include <QHash>
0013 #include <QImage>
0014 #include <QList>
0015 #include <QSet>
0016 
0017 namespace KRunner
0018 {
0019 class DBusRunner : public KRunner::AbstractRunner
0020 {
0021     Q_OBJECT
0022 
0023 public:
0024     explicit DBusRunner(QObject *parent, const KPluginMetaData &data);
0025 
0026     // matchInternal is overwritten. Meaning we do not need the original match
0027     void match(KRunner::RunnerContext &) override
0028     {
0029     }
0030     void reloadConfiguration() override;
0031     void run(const KRunner::RunnerContext &context, const KRunner::QueryMatch &action) override;
0032 
0033     Q_INVOKABLE void matchInternal(KRunner::RunnerContext context);
0034 
0035 private:
0036     void teardown();
0037 
0038     // Returns RemoteActions with service name as key
0039     void requestActions();
0040     void requestActionsForService(const QString &service, const std::function<void()> &finishedCallback);
0041     QList<QueryMatch> convertMatches(const QString &service, const RemoteMatches &remoteMatches);
0042     void requestConfig();
0043     static QImage decodeImage(const RemoteImage &remoteImage);
0044     QSet<QString> m_matchingServices;
0045     QHash<QString, QList<KRunner::Action>> m_actions;
0046     const QString m_path;
0047     const bool m_hasUniqueResults;
0048     const bool m_requestActionsOnce;
0049     bool m_actionsForSessionRequested = false;
0050     bool m_matchWasCalled = false;
0051     bool m_callLifecycleMethods = false;
0052     const QString m_ifaceName;
0053     QSet<QString> m_requestedActionServices;
0054 };
0055 }