Commit 27f14270 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Link Sensors lib to SystemStats lib and use the interface from systemstats

SystemStats now exposes a dbus interface class for the system stats
interface, so let's make use of it here.
parent 85bd163d
......@@ -50,6 +50,7 @@ target_link_libraries(Sensors
Qt::Core
Qt::DBus
KF5::I18n
KSysGuard::SystemStats
)
set_target_properties(Sensors PROPERTIES
......
......@@ -20,12 +20,13 @@
#include <QEvent>
#include "formatter/Formatter.h"
#include "systemstats/SensorInfo.h"
#include "Sensor.h"
#include "SensorDaemonInterface_p.h"
#include "formatter/Formatter.h"
#include "SensorQuery.h"
#include "../systemstats/SensorInfo.h"
using namespace KSysGuard;
......
......@@ -21,23 +21,18 @@
#include <QDBusPendingCallWatcher>
#include "ksysguarddaemon.h"
#include "systemstats/DBusInterface.h"
using namespace KSysGuard;
class SensorDaemonInterface::Private
{
public:
std::unique_ptr<org::kde::KSysGuardDaemon> dbusInterface;
std::unique_ptr<SystemStats::DBusInterface> dbusInterface;
std::unique_ptr<QDBusServiceWatcher> serviceWatcher;
QStringList subscribedSensors;
static const QString SensorServiceName;
static const QString SensorPath;
};
const QString SensorDaemonInterface::Private::SensorServiceName = QStringLiteral("org.kde.ksystemstats");
const QString SensorDaemonInterface::Private::SensorPath = QStringLiteral("/");
SensorDaemonInterface::SensorDaemonInterface(QObject *parent)
: QObject(parent)
, d(new Private)
......@@ -47,18 +42,18 @@ SensorDaemonInterface::SensorDaemonInterface(QObject *parent)
qDBusRegisterMetaType<SensorDataList>();
qDBusRegisterMetaType<SensorInfoMap>();
d->serviceWatcher = std::make_unique<QDBusServiceWatcher>(d->SensorServiceName, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForUnregistration);
d->serviceWatcher = std::make_unique<QDBusServiceWatcher>(SystemStats::ServiceName, QDBusConnection::sessionBus(), QDBusServiceWatcher::WatchForUnregistration);
connect(d->serviceWatcher.get(), &QDBusServiceWatcher::serviceUnregistered, this, &SensorDaemonInterface::reconnect);
reconnect();
}
void KSysGuard::SensorDaemonInterface::reconnect()
{
d->dbusInterface = std::make_unique<org::kde::KSysGuardDaemon>(Private::SensorServiceName, Private::SensorPath, QDBusConnection::sessionBus());
connect(d->dbusInterface.get(), &org::kde::KSysGuardDaemon::sensorMetaDataChanged, this, &SensorDaemonInterface::onMetaDataChanged);
connect(d->dbusInterface.get(), &org::kde::KSysGuardDaemon::newSensorData, this, &SensorDaemonInterface::onValueChanged);
connect(d->dbusInterface.get(), &org::kde::KSysGuardDaemon::sensorAdded, this, &SensorDaemonInterface::sensorAdded);
connect(d->dbusInterface.get(), &org::kde::KSysGuardDaemon::sensorRemoved, this, &SensorDaemonInterface::sensorRemoved);
d->dbusInterface = std::make_unique<SystemStats::DBusInterface>();
connect(d->dbusInterface.get(), &SystemStats::DBusInterface::sensorMetaDataChanged, this, &SensorDaemonInterface::onMetaDataChanged);
connect(d->dbusInterface.get(), &SystemStats::DBusInterface::newSensorData, this, &SensorDaemonInterface::onValueChanged);
connect(d->dbusInterface.get(), &SystemStats::DBusInterface::sensorAdded, this, &SensorDaemonInterface::sensorAdded);
connect(d->dbusInterface.get(), &SystemStats::DBusInterface::sensorRemoved, this, &SensorDaemonInterface::sensorRemoved);
subscribe(d->subscribedSensors);
}
......
......@@ -22,7 +22,7 @@
#include <memory>
#include <QObject>
#include "../systemstats/SensorInfo.h"
#include "systemstats/SensorInfo.h"
class QDBusPendingCallWatcher;
......
......@@ -24,12 +24,12 @@
#include <QMetaEnum>
#include "Formatter.h"
#include "formatter/Formatter.h"
#include "systemstats/SensorInfo.h"
#include "SensorDaemonInterface_p.h"
#include "sensors_logging.h"
#include "../systemstats/SensorInfo.h"
using namespace KSysGuard;
class Q_DECL_HIDDEN SensorDataModel::Private
......
......@@ -27,14 +27,13 @@
#include <QRegularExpression>
#include "formatter/Formatter.h"
#include "systemstats/SensorInfo.h"
#include "Sensor.h"
#include "SensorDaemonInterface_p.h"
#include "SensorQuery.h"
#include "SensorGroup_p.h"
#include "../systemstats/SensorInfo.h"
using namespace KSysGuard;
struct Q_DECL_HIDDEN SensorTreeItem
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment