From 0cb9551c3a1894d001bf907b72595ddb636881d7 Mon Sep 17 00:00:00 2001 From: Matti Viljanen Date: Fri, 12 Jun 2020 14:26:00 +0300 Subject: [PATCH] Return success writing new charger state --- service/src/battery.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/service/src/battery.cpp b/service/src/battery.cpp index 8d31d7d..7f28eb7 100644 --- a/service/src/battery.cpp +++ b/service/src/battery.cpp @@ -174,12 +174,14 @@ QString Battery::getState() { return state; } bool Battery::getChargingEnabled() { return chargingEnabled; } -void Battery::setChargingEnabled(bool isEnabled) { +bool Battery::setChargingEnabled(bool isEnabled) { + bool success = false; if(chargingEnabledFile) { if(chargingEnabledFile->open(QIODevice::WriteOnly)) { if(chargingEnabledFile->write(QString("%1").arg(isEnabled ? enableChargingValue : disableChargingValue).toLatin1())) { chargingEnabled = isEnabled; emit chargingEnabledChanged(chargingEnabled); + success = true; if(isEnabled) { qInfo() << "Charging resumed"; @@ -197,6 +199,7 @@ void Battery::setChargingEnabled(bool isEnabled) { qWarning() << "Could not open charger control file"; } } + return success; } bool Battery::getChargerConnected() {