Update datetime plugin
parent
7d0a6f9912
commit
fe7dd62fa8
|
|
@ -48,19 +48,23 @@ DevicePluginDateTime::DevicePluginDateTime() :
|
|||
connect(m_timer, &QTimer::timeout, this, &DevicePluginDateTime::onSecondChanged);
|
||||
}
|
||||
|
||||
Device::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *device)
|
||||
void DevicePluginDateTime::setupDevice(DeviceSetupInfo *info)
|
||||
{
|
||||
Device *device = info->device();
|
||||
|
||||
// check timezone
|
||||
if(!m_timeZone.isValid()){
|
||||
qCWarning(dcDateTime) << "Invalid time zone.";
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
info->finish(Device::DeviceErrorInvalidParameter);
|
||||
return;
|
||||
}
|
||||
|
||||
// date
|
||||
if (device->deviceClassId() == todayDeviceClassId) {
|
||||
if (m_todayDevice != 0) {
|
||||
qCWarning(dcDateTime) << "There is already a date device or not deleted correctly! this should never happen!!";
|
||||
return Device::DeviceSetupStatusFailure;
|
||||
info->finish(Device::DeviceErrorHardwareNotAvailable);
|
||||
return;
|
||||
}
|
||||
m_todayDevice = device;
|
||||
qCDebug(dcDateTime) << "Create today device: current time" << m_currentDateTime.currentDateTime().toString();
|
||||
|
|
@ -108,7 +112,7 @@ Device::DeviceSetupStatus DevicePluginDateTime::setupDevice(Device *device)
|
|||
|
||||
m_timer->start();
|
||||
|
||||
return Device::DeviceSetupStatusSuccess;
|
||||
info->finish(Device::DeviceErrorNoError);
|
||||
}
|
||||
|
||||
void DevicePluginDateTime::postSetupDevice(Device *device)
|
||||
|
|
@ -149,23 +153,23 @@ void DevicePluginDateTime::deviceRemoved(Device *device)
|
|||
//startMonitoringAutoDevices();
|
||||
}
|
||||
|
||||
Device::DeviceError DevicePluginDateTime::executeAction(Device *device, const Action &action)
|
||||
void DevicePluginDateTime::executeAction(DeviceActionInfo *info)
|
||||
{
|
||||
if (device->deviceClassId() == countdownDeviceClassId) {
|
||||
Countdown *countdown = m_countdowns.value(device);
|
||||
if (action.actionTypeId() == countdownStartActionTypeId) {
|
||||
if (info->device()->deviceClassId() != countdownDeviceClassId) {
|
||||
info->finish(Device::DeviceErrorDeviceClassNotFound);
|
||||
return;
|
||||
}
|
||||
|
||||
Countdown *countdown = m_countdowns.value(info->device());
|
||||
if (info->action().actionTypeId() == countdownStartActionTypeId) {
|
||||
countdown->start();
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == countdownRestartActionTypeId) {
|
||||
} else if (info->action().actionTypeId() == countdownRestartActionTypeId) {
|
||||
countdown->restart();
|
||||
return Device::DeviceErrorNoError;
|
||||
} else if (action.actionTypeId() == countdownStopActionTypeId) {
|
||||
} else if (info->action().actionTypeId() == countdownStopActionTypeId) {
|
||||
countdown->stop();
|
||||
return Device::DeviceErrorNoError;
|
||||
}
|
||||
return Device::DeviceErrorActionTypeNotFound;
|
||||
}
|
||||
return Device::DeviceErrorNoError;
|
||||
|
||||
info->finish(Device::DeviceErrorNoError);
|
||||
}
|
||||
|
||||
void DevicePluginDateTime::startMonitoringAutoDevices()
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@ class DevicePluginDateTime : public DevicePlugin
|
|||
public:
|
||||
explicit DevicePluginDateTime();
|
||||
|
||||
Device::DeviceSetupStatus setupDevice(Device *device) override;
|
||||
void setupDevice(DeviceSetupInfo *info) override;
|
||||
void postSetupDevice(Device *device) override;
|
||||
void deviceRemoved(Device *device) override;
|
||||
|
||||
Device::DeviceError executeAction(Device *device, const Action &action) override;
|
||||
void executeAction(DeviceActionInfo *info) override;
|
||||
|
||||
void startMonitoringAutoDevices() override;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue