summaryrefslogtreecommitdiffstats
path: root/tdecore
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2020-10-04 19:12:19 +0200
committerSlávek Banko <[email protected]>2020-10-07 19:21:31 +0200
commitcb796c51ca0127b4efb89ef411f2a5b9cc12ca65 (patch)
tree9b998ce7b6c87c26f2deecd83bd179a7c884cc61 /tdecore
parent9f03b32225e2f92e5955b8284e361a69c3b605cb (diff)
downloadtdelibs-cb796c51ca0127b4efb89ef411f2a5b9cc12ca65.tar.gz
tdelibs-cb796c51ca0127b4efb89ef411f2a5b9cc12ca65.zip
tdehwlib: Add regular monitoring of power supply device status,
to be able to generate a signal when the power state changes, if the signal is not generated from udev. This resolves issue TDE/tde#30. Signed-off-by: Slávek Banko <[email protected]> (cherry picked from commit fb1316c785f2e026316a48b7cade322026490ee2)
Diffstat (limited to 'tdecore')
-rw-r--r--tdecore/tdehw/tdehardwaredevices.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/tdecore/tdehw/tdehardwaredevices.cpp b/tdecore/tdehw/tdehardwaredevices.cpp
index 8ee62ca8f..4ca1678bf 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -212,7 +212,7 @@ TDEHardwareDevices::TDEHardwareDevices() {
m_deviceWatchTimer = new TQTimer(this);
connect( m_deviceWatchTimer, SIGNAL(timeout()), this, SLOT(processStatelessDevices()) );
- // Special case for battery polling (longer delay, 5 seconds)
+ // Special case for battery and power supply polling (longer delay, 5 seconds)
m_batteryWatchTimer = new TQTimer(this);
connect( m_batteryWatchTimer, SIGNAL(timeout()), this, SLOT(processBatteryDevices()) );
@@ -919,6 +919,15 @@ void TDEHardwareDevices::processBatteryDevices() {
emit hardwareUpdated(hwdevice);
emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
}
+ else if (hwdevice->type() == TDEGenericDeviceType::PowerSupply) {
+ TDEMainsPowerDevice *pdevice = dynamic_cast<TDEMainsPowerDevice*>(hwdevice);
+ int previousOnlineState = pdevice->online();
+ rescanDeviceInformation(hwdevice, false);
+ if (pdevice->online() != previousOnlineState) {
+ emit hardwareUpdated(hwdevice);
+ emit hardwareEvent(TDEHardwareEvent::HardwareUpdated, hwdevice->uniqueID());
+ }
+ }
}
}