Commit 0a118e27 authored by Arjen Hiemstra's avatar Arjen Hiemstra
Browse files

Rename ksysguarddaemon to daemon

Gets rid of one more reference to ksysguard
parent c6467c6a
......@@ -6,7 +6,7 @@
#include <QtTest>
#include "../src/ksysguarddaemon.h"
#include "../src/daemon.h"
#include <systemstats/SensorContainer.h>
#include <systemstats/SensorObject.h>
......@@ -52,7 +52,7 @@ public:
int m_updateCount = 0;
};
class KStatsTest : public KSysGuardDaemon
class KStatsTest : public Daemon
{
Q_OBJECT
public:
......
......@@ -4,11 +4,11 @@
set(SOURCES
client.cpp
ksysguarddaemon.cpp
daemon.cpp
)
find_file(SYSTEMSTATS_DBUS_INTERFACE NAMES dbus-1/interfaces/org.kde.ksystemstats.xml HINTS ${KDE_INSTALL_FULL_DATADIR})
qt5_add_dbus_adaptor(SOURCES ${SYSTEMSTATS_DBUS_INTERFACE} ksysguarddaemon.h KSysGuardDaemon)
qt5_add_dbus_adaptor(SOURCES ${SYSTEMSTATS_DBUS_INTERFACE} daemon.h Daemon)
add_library(ksystemstats_core STATIC ${SOURCES})
target_link_libraries(ksystemstats_core PUBLIC Qt::Core Qt::DBus KF5::CoreAddons KF5::DBusAddons KSysGuard::SystemStats)
......
......@@ -12,18 +12,19 @@
#include <algorithm>
#include <systemstats/SensorPlugin.h>
#include <systemstats/DBusInterface.h>
#include <systemstats/SensorObject.h>
#include <systemstats/SensorPlugin.h>
#include <systemstats/SensorProperty.h>
#include "ksysguarddaemon.h"
#include "daemon.h"
Client::Client(KSysGuardDaemon *parent, const QString &serviceName)
Client::Client(Daemon *parent, const QString &serviceName)
: QObject(parent)
, m_serviceName(serviceName)
, m_daemon(parent)
{
connect(m_daemon, &KSysGuardDaemon::sensorRemoved, this, [this](const QString &sensor) {
connect(m_daemon, &Daemon::sensorRemoved, this, [this](const QString &sensor) {
m_subscribedSensors.remove(sensor);
});
}
......
......@@ -14,7 +14,7 @@ namespace KSysGuard
{
class SensorProperty;
}
class KSysGuardDaemon;
class Daemon;
/**
* This class represents an individual connection to the daemon
......@@ -23,7 +23,7 @@ class Client : public QObject
{
Q_OBJECT
public:
Client(KSysGuardDaemon *parent, const QString &serviceName);
Client(Daemon *parent, const QString &serviceName);
~Client() override;
void subscribeSensors(const QStringList &sensorIds);
void unsubscribeSensors(const QStringList &sensorIds);
......@@ -34,7 +34,7 @@ private:
void sendMetaDataChanged(const KSysGuard::SensorInfoMap &sensors);
const QString m_serviceName;
KSysGuardDaemon *m_daemon;
Daemon *m_daemon;
QHash<QString, KSysGuard::SensorProperty *> m_subscribedSensors;
QMultiHash<KSysGuard::SensorProperty *, QMetaObject::Connection> m_connections;
KSysGuard::SensorDataList m_pendingUpdates;
......
......@@ -5,7 +5,7 @@
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "ksysguarddaemon.h"
#include "daemon.h"
#include <chrono>
......@@ -33,7 +33,7 @@
constexpr auto UpdateRate = std::chrono::milliseconds{500};
KSysGuardDaemon::KSysGuardDaemon()
Daemon::Daemon()
: m_serviceWatcher(new QDBusServiceWatcher(this))
{
qDBusRegisterMetaType<KSysGuard::SensorData>();
......@@ -46,22 +46,22 @@ KSysGuardDaemon::KSysGuardDaemon()
new KsystemstatsAdaptor(this);
m_serviceWatcher->setConnection(QDBusConnection::sessionBus());
connect(m_serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, &KSysGuardDaemon::onServiceDisconnected);
connect(m_serviceWatcher, &QDBusServiceWatcher::serviceUnregistered, this, &Daemon::onServiceDisconnected);
auto timer = new QTimer(this);
timer->setInterval(UpdateRate);
connect(timer, &QTimer::timeout, this, &KSysGuardDaemon::sendFrame);
connect(timer, &QTimer::timeout, this, &Daemon::sendFrame);
timer->start();
}
KSysGuardDaemon::~KSysGuardDaemon()
Daemon::~Daemon()
{
for (Client* c : m_clients) {
delete c;
}
}
void KSysGuardDaemon::init(ReplaceIfRunning replaceIfRunning)
void Daemon::init(ReplaceIfRunning replaceIfRunning)
{
loadProviders();
KDBusService::StartupOptions options = KDBusService::Unique;
......@@ -73,12 +73,12 @@ void KSysGuardDaemon::init(ReplaceIfRunning replaceIfRunning)
service->setExitValue(1);
}
void KSysGuardDaemon::setQuitOnLastClientDisconnect(bool quit)
void Daemon::setQuitOnLastClientDisconnect(bool quit)
{
m_quitOnLastClientDisconnect = quit;
}
void KSysGuardDaemon::loadProviders()
void Daemon::loadProviders()
{
//instantiate all plugins
QSet<QString> knownPlugins;
......@@ -113,7 +113,7 @@ void KSysGuardDaemon::loadProviders()
}
}
void KSysGuardDaemon::registerProvider(KSysGuard::SensorPlugin *provider) {
void Daemon::registerProvider(KSysGuard::SensorPlugin *provider) {
m_providers.append(provider);
const auto containers = provider->containers();
for (auto container : containers) {
......@@ -131,7 +131,7 @@ void KSysGuardDaemon::registerProvider(KSysGuard::SensorPlugin *provider) {
}
}
KSysGuard::SensorInfoMap KSysGuardDaemon::allSensors() const
KSysGuard::SensorInfoMap Daemon::allSensors() const
{
KSysGuard::SensorInfoMap infoMap;
for (auto c : qAsConst(m_containers)) {
......@@ -154,7 +154,7 @@ KSysGuard::SensorInfoMap KSysGuardDaemon::allSensors() const
return infoMap;
}
KSysGuard::SensorInfoMap KSysGuardDaemon::sensors(const QStringList &sensorPaths) const
KSysGuard::SensorInfoMap Daemon::sensors(const QStringList &sensorPaths) const
{
KSysGuard::SensorInfoMap si;
for (const QString &path : sensorPaths) {
......@@ -165,7 +165,7 @@ KSysGuard::SensorInfoMap KSysGuardDaemon::sensors(const QStringList &sensorPaths
return si;
}
void KSysGuardDaemon::subscribe(const QStringList &sensorIds)
void Daemon::subscribe(const QStringList &sensorIds)
{
const QString sender = QDBusContext::message().service();
m_serviceWatcher->addWatchedService(sender);
......@@ -178,7 +178,7 @@ void KSysGuardDaemon::subscribe(const QStringList &sensorIds)
client->subscribeSensors(sensorIds);
}
void KSysGuardDaemon::unsubscribe(const QStringList &sensorIds)
void Daemon::unsubscribe(const QStringList &sensorIds)
{
const QString sender = QDBusContext::message().service();
Client *client = m_clients.value(sender);
......@@ -188,7 +188,7 @@ void KSysGuardDaemon::unsubscribe(const QStringList &sensorIds)
client->unsubscribeSensors(sensorIds);
}
KSysGuard::SensorDataList KSysGuardDaemon::sensorData(const QStringList &sensorIds)
KSysGuard::SensorDataList Daemon::sensorData(const QStringList &sensorIds)
{
KSysGuard::SensorDataList sensorData;
for (const QString &sensorId: sensorIds) {
......@@ -202,7 +202,7 @@ KSysGuard::SensorDataList KSysGuardDaemon::sensorData(const QStringList &sensorI
return sensorData;
}
KSysGuard::SensorProperty *KSysGuardDaemon::findSensor(const QString &path) const
KSysGuard::SensorProperty *Daemon::findSensor(const QString &path) const
{
int subsystemIndex = path.indexOf('/');
int propertyIndex = path.lastIndexOf('/');
......@@ -222,7 +222,7 @@ KSysGuard::SensorProperty *KSysGuardDaemon::findSensor(const QString &path) cons
return o->sensor(property);
}
void KSysGuardDaemon::onServiceDisconnected(const QString &service)
void Daemon::onServiceDisconnected(const QString &service)
{
delete m_clients.take(service);
if (m_clients.isEmpty() && m_quitOnLastClientDisconnect) {
......@@ -230,7 +230,7 @@ void KSysGuardDaemon::onServiceDisconnected(const QString &service)
};
}
void KSysGuardDaemon::sendFrame()
void Daemon::sendFrame()
{
for (auto provider : qAsConst(m_providers)) {
provider->update();
......
......@@ -24,7 +24,7 @@ class QDBusServiceWatcher;
/**
* The main central application
*/
class KSysGuardDaemon : public QObject, public QDBusContext
class Daemon : public QObject, public QDBusContext
{
Q_OBJECT
public:
......@@ -33,8 +33,8 @@ public:
DoNotReplace
};
KSysGuardDaemon();
~KSysGuardDaemon();
Daemon();
~Daemon();
void init(ReplaceIfRunning replaceIfRunning);
KSysGuard::SensorProperty *findSensor(const QString &path) const;
......
......@@ -9,7 +9,7 @@
#include <QCommandLineParser>
#include <QDebug>
#include "ksysguarddaemon.h"
#include "daemon.h"
int main(int argc, char **argv)
{
......@@ -23,8 +23,8 @@ int main(int argc, char **argv)
parser.addHelpOption();
parser.process(app);
KSysGuardDaemon d;
d.init(parser.isSet(QStringLiteral("replace")) ? KSysGuardDaemon::ReplaceIfRunning::Replace : KSysGuardDaemon::ReplaceIfRunning::DoNotReplace);
Daemon d;
d.init(parser.isSet(QStringLiteral("replace")) ? Daemon::ReplaceIfRunning::Replace : Daemon::ReplaceIfRunning::DoNotReplace);
d.setQuitOnLastClientDisconnect(!parser.isSet(QStringLiteral("remain")));
app.exec();
}
Markdown is supported
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