/* SPDX-FileCopyrightText: 2015 Marco Martin SPDX-FileCopyrightText: 2020 Konrad Materka SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include #include #include #include #include class KPluginMetaData; class SystemTraySettings; class QDBusServiceWatcher; /** * @brief Loading and unloading Plasmoids when DBus services come and go. */ class DBusServiceObserver : public QObject { Q_OBJECT public: explicit DBusServiceObserver(const QPointer &settings, QObject *parent = nullptr); void registerPlugin(const KPluginMetaData &pluginMetaData); void unregisterPlugin(const QString &pluginId); bool isDBusActivable(const QString &pluginId); Q_SIGNALS: void serviceStarted(const QString &pluginId); void serviceStopped(const QString &pluginId); public Q_SLOTS: void initDBusActivatables(); private Q_SLOTS: void sessionBusNameFetchFinished(const QStringList &list); void systemBusNameFetchFinished(const QStringList &list); void sessionBusNameFetchError(const QDBusError &error); void systemBusNameFetchError(const QDBusError &error); private: void serviceRegistered(const QString &service); void serviceUnregistered(const QString &service); QPointer m_settings; QDBusServiceWatcher *m_sessionServiceWatcher; QDBusServiceWatcher *m_systemServiceWatcher; QHash m_dbusActivatableTasks; QHash m_dbusServiceCounts; bool m_dbusSessionServiceNamesFetched = false; bool m_dbusSystemServiceNamesFetched = false; };