summaryrefslogtreecommitdiffstats
path: root/tdecore/tdehw
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2020-10-04 19:12:19 +0200
committerSlávek Banko <slavek.banko@axis.cz>2020-10-07 13:47:37 +0200
commitfb1316c785f2e026316a48b7cade322026490ee2 (patch)
treea47e10ed839a71205a66e1570b0fa02c4d39ab37 /tdecore/tdehw
parent056d9c5d0d438b28fd3a43fa7a15a26cc84644b5 (diff)
downloadtdelibs-fb1316c785f2e026316a48b7cade322026490ee2.tar.gz
tdelibs-fb1316c785f2e026316a48b7cade322026490ee2.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 <slavek.banko@axis.cz>
Diffstat (limited to 'tdecore/tdehw')
-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 b700ac3ab..f0069d38f 100644
--- a/tdecore/tdehw/tdehardwaredevices.cpp
+++ b/tdecore/tdehw/tdehardwaredevices.cpp
@@ -199,7 +199,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()) );
@@ -906,6 +906,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());
+ }
+ }
}
}