From 9a838b7f9f56c2bd92a0aba72bcd37ec1f3d9f89 Mon Sep 17 00:00:00 2001 From: Arseniy-Movshev Date: Sun, 28 May 2023 12:49:41 +0100 Subject: Add a dbus interface to allow reinitialising the logger This is to allow the logger to be reinitialised form qml --- daemon/logger.cpp | 10 ++++++++++ daemon/logger.h | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/daemon/logger.cpp b/daemon/logger.cpp index ff62ff6..56d1c3c 100644 --- a/daemon/logger.cpp +++ b/daemon/logger.cpp @@ -26,6 +26,12 @@ Logger::Logger(QObject *parent) : QObject(parent){ + if(!QDBusConnection::sessionBus().registerService("org.asteroid.sensorlogd.logger")) qDebug() << "failed to register service"; + if(!QDBusConnection::sessionBus().registerObject("/org/asteroid/sensorlogd/logger", this, QDBusConnection::ExportAllContents)) qDebug() << "failed to register object"; + this->setup(); +} + +void Logger::setup() { m_iface = new QDBusInterface("com.nokia.mce","/com/nokia/mce/signal", "com.nokia.mce.signal", QDBusConnection::systemBus()); settings = new QSettings; @@ -52,6 +58,10 @@ Logger::Logger(QObject *parent) : qDebug() << "healthd sensors logger initialised"; } +void Logger::resetup() { + this->setup(); +} + void Logger::displayOn(QString displayState) { if (displayState == "off") return; diff --git a/daemon/logger.h b/daemon/logger.h index d9b418d..6047a04 100644 --- a/daemon/logger.h +++ b/daemon/logger.h @@ -18,6 +18,7 @@ #include #include #include +#include #include "sensorPlugins/stepCounter.h" #include "sensorPlugins/heartrateSensor.h" @@ -28,6 +29,9 @@ class Logger : public QObject public: explicit Logger(QObject *parent = 0); virtual ~Logger() {}; +public slots: + void setup(); + void resetup(); private slots: void displayOn(QString displayState); -- cgit v1.2.3-54-g00ecf