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>
(cherry picked from commit fb1316c785)
r14.0.x
Slávek Banko 4 years ago
parent 9f03b32225
commit cb796c51ca
Signed by: SlavekB
GPG Key ID: 608F5293A04BE668

@ -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());
}
}
}
}

Loading…
Cancel
Save