Don't execute actions on devices that didn't complete the setup
This commit is contained in:
parent
40cbb9fe0a
commit
e049c3b2f5
@ -912,15 +912,24 @@ DeviceActionInfo *DeviceManagerImplementation::executeAction(const Action &actio
|
|||||||
Action finalAction = action;
|
Action finalAction = action;
|
||||||
Device *device = m_configuredDevices.value(action.deviceId());
|
Device *device = m_configuredDevices.value(action.deviceId());
|
||||||
if (!device) {
|
if (!device) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot execute action. No such device:" << action.deviceId();
|
||||||
DeviceActionInfo *info = new DeviceActionInfo(nullptr, action, this);
|
DeviceActionInfo *info = new DeviceActionInfo(nullptr, action, this);
|
||||||
info->finish(Device::DeviceErrorDeviceNotFound);
|
info->finish(Device::DeviceErrorDeviceNotFound);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!device->setupComplete()) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot execute action. Device" << device->name() << "hasn't completed setup.";
|
||||||
|
DeviceActionInfo *info = new DeviceActionInfo(nullptr, action, this);
|
||||||
|
info->finish(Device::DeviceErrorSetupFailed);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
// Make sure this device has an action type with this id
|
// Make sure this device has an action type with this id
|
||||||
DeviceClass deviceClass = findDeviceClass(device->deviceClassId());
|
DeviceClass deviceClass = findDeviceClass(device->deviceClassId());
|
||||||
ActionType actionType = deviceClass.actionTypes().findById(action.actionTypeId());
|
ActionType actionType = deviceClass.actionTypes().findById(action.actionTypeId());
|
||||||
if (actionType.id().isNull()) {
|
if (actionType.id().isNull()) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot execute action. No such action type" << action.actionTypeId();
|
||||||
DeviceActionInfo *info = new DeviceActionInfo(device, action, this);
|
DeviceActionInfo *info = new DeviceActionInfo(device, action, this);
|
||||||
info->finish(Device::DeviceErrorActionTypeNotFound);
|
info->finish(Device::DeviceErrorActionTypeNotFound);
|
||||||
return info;
|
return info;
|
||||||
@ -929,6 +938,7 @@ DeviceActionInfo *DeviceManagerImplementation::executeAction(const Action &actio
|
|||||||
ParamList finalParams = action.params();
|
ParamList finalParams = action.params();
|
||||||
Device::DeviceError paramCheck = DeviceUtils::verifyParams(actionType.paramTypes(), finalParams);
|
Device::DeviceError paramCheck = DeviceUtils::verifyParams(actionType.paramTypes(), finalParams);
|
||||||
if (paramCheck != Device::DeviceErrorNoError) {
|
if (paramCheck != Device::DeviceErrorNoError) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot execute action. Parameter verification failed.";
|
||||||
DeviceActionInfo *info = new DeviceActionInfo(device, action, this);
|
DeviceActionInfo *info = new DeviceActionInfo(device, action, this);
|
||||||
info->finish(paramCheck);
|
info->finish(paramCheck);
|
||||||
return info;
|
return info;
|
||||||
@ -939,6 +949,7 @@ DeviceActionInfo *DeviceManagerImplementation::executeAction(const Action &actio
|
|||||||
|
|
||||||
DevicePlugin *plugin = m_devicePlugins.value(device->pluginId());
|
DevicePlugin *plugin = m_devicePlugins.value(device->pluginId());
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
|
qCWarning(dcDeviceManager()) << "Cannot execute action. Plugin not found for device" << device->name();
|
||||||
info->finish(Device::DeviceErrorPluginNotFound);
|
info->finish(Device::DeviceErrorPluginNotFound);
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user