From c212210e41487e88f62d5f8f51c57e63b534c38f Mon Sep 17 00:00:00 2001 From: Arseniy-Movshev Date: Sun, 28 May 2023 12:35:47 +0100 Subject: Fix up the settings implementation add interval and enabled settings for all sensors get rid of some bad duplicates make sure that application properties are set up before settings are accessed --- daemon/logger.cpp | 13 ++++++++----- daemon/logger.h | 7 ++++--- daemon/sensorlogd.cpp | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/daemon/logger.cpp b/daemon/logger.cpp index 93f764f..ff62ff6 100644 --- a/daemon/logger.cpp +++ b/daemon/logger.cpp @@ -27,16 +27,19 @@ Logger::Logger(QObject *parent) : QObject(parent){ m_iface = new QDBusInterface("com.nokia.mce","/com/nokia/mce/signal", "com.nokia.mce.signal", QDBusConnection::systemBus()); - QSettings settings; + settings = new QSettings; + + heartrateSensorEnabled = this->settings->value("heartrateSensor/enabled",true).toBool(); + stepCounterEnabled = this->settings->value("stepCounter/enabled",true).toBool(); //intialise HRM - if (heartrateSensorEnabled) { //add check for HRM - m_heartrateSensor = new HeartrateSensorPlugin(this,settings.value("stepsInterval",600000).toInt()); + if (heartrateSensorEnabled) { + m_heartrateSensor = new HeartrateSensorPlugin(this,settings->value("heartrateSensor/interval",600000).toInt()); } //initialise step counter - if (stepCounterEnabled) { //add check for step sensor - m_stepCounter = new StepCounterPlugin(this,settings.value("stepsInterval",600000).toInt()); + if (stepCounterEnabled) { + m_stepCounter = new StepCounterPlugin(this,settings->value("stepCounter/interval",600000).toInt()); } if(!m_iface->isValid()) { diff --git a/daemon/logger.h b/daemon/logger.h index 14d097f..d9b418d 100644 --- a/daemon/logger.h +++ b/daemon/logger.h @@ -17,6 +17,7 @@ #include #include #include +#include #include "sensorPlugins/stepCounter.h" #include "sensorPlugins/heartrateSensor.h" @@ -27,16 +28,16 @@ class Logger : public QObject public: explicit Logger(QObject *parent = 0); virtual ~Logger() {}; - private slots: void displayOn(QString displayState); private: QDBusInterface *m_iface; - bool heartrateSensorEnabled = true; + bool heartrateSensorEnabled = false; HeartrateSensorPlugin *m_heartrateSensor; - bool stepCounterEnabled = true; + bool stepCounterEnabled = false; StepCounterPlugin *m_stepCounter; + QSettings *settings; }; void fileAddRecord(QString sensorPrefix, QString logdata, QDateTime recordTime = QDateTime::currentDateTime()); //adds a record to today's log file for the given sensor diff --git a/daemon/sensorlogd.cpp b/daemon/sensorlogd.cpp index 8b7395a..095ebd9 100644 --- a/daemon/sensorlogd.cpp +++ b/daemon/sensorlogd.cpp @@ -24,10 +24,10 @@ int main(int argc, char **argv) fprintf(stderr, "Cannot connect to the D-Bus session bus.\n"); return 2; } - Logger sensorsLogger; QCoreApplication::setOrganizationName("asteroid"); QCoreApplication::setOrganizationDomain("asteroidos.org"); QCoreApplication::setApplicationName("healthd"); + Logger sensorsLogger; qDebug() << "healthd started"; qcoreapp.exec(); return 0; -- cgit v1.2.3-70-g09d2