File indexing completed on 2024-05-05 09:51:32
0001 /* 0002 SPDX-FileCopyrightText: 2020 Arjen Hiemstra <ahiemstra@heimr.nl> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include <QObject> 0010 #include <memory> 0011 0012 #include "systemstats/SensorInfo.h" 0013 0014 class QDBusPendingCallWatcher; 0015 0016 namespace KSysGuard 0017 { 0018 /** 0019 * Internal helper class to communicate with the daemon. 0020 * 0021 * This is mostly for convenience on top of the auto-generated KSysGuardDaemon 0022 * D-Bus interface. 0023 */ 0024 class SensorDaemonInterface : public QObject 0025 { 0026 Q_OBJECT 0027 0028 public: 0029 SensorDaemonInterface(QObject *parent = nullptr); 0030 ~SensorDaemonInterface() override; 0031 0032 void requestMetaData(const QString &sensorId); 0033 void requestMetaData(const QStringList &sensorIds); 0034 Q_SIGNAL void metaDataChanged(const QString &sensorId, const SensorInfo &info); 0035 void requestValue(const QString &sensorId); 0036 Q_SIGNAL void valueChanged(const QString &sensorId, const QVariant &value); 0037 0038 QDBusPendingCallWatcher *allSensors() const; 0039 0040 void subscribe(const QString &sensorId); 0041 void subscribe(const QStringList &sensorIds); 0042 void unsubscribe(const QString &sensorId); 0043 void unsubscribe(const QStringList &sensorIds); 0044 0045 Q_SIGNAL void sensorAdded(const QString &sensorId); 0046 Q_SIGNAL void sensorRemoved(const QString &sensorId); 0047 0048 static SensorDaemonInterface *instance(); 0049 0050 private: 0051 void onMetaDataChanged(const QHash<QString, SensorInfo> &metaData); 0052 void onValueChanged(const SensorDataList &values); 0053 void reconnect(); 0054 0055 class Private; 0056 const std::unique_ptr<Private> d; 0057 }; 0058 0059 }