diff --git a/server/guhcore.cpp b/server/guhcore.cpp index bee35864..addf96de 100644 --- a/server/guhcore.cpp +++ b/server/guhcore.cpp @@ -184,6 +184,10 @@ QPair > GuhCore::removeConfiguredDevic { // Check if this is a child device Device *device = findConfiguredDevice(deviceId); + + if (!device) + return QPair > (DeviceManager::DeviceErrorDeviceNotFound, QList()); + if (!device->parentId().isNull()) { qCWarning(dcDeviceManager) << "The device is a child of" << device->parentId().toString() << ". Please remove the parent device."; return QPair > (DeviceManager::DeviceErrorDeviceIsChild, QList()); @@ -268,6 +272,10 @@ DeviceManager::DeviceError GuhCore::removeConfiguredDevice(const DeviceId &devic { // Check if this is a child device Device *device = findConfiguredDevice(deviceId); + + if (!device) + return DeviceManager::DeviceErrorDeviceNotFound; + if (!device->parentId().isNull()) { qCWarning(dcDeviceManager) << "The device is a child of" << device->parentId().toString() << ". Please remove the parent device."; return DeviceManager::DeviceErrorDeviceIsChild; diff --git a/tests/auto/api.json b/tests/auto/api.json index 6d9f70ba..d35cae77 100644 --- a/tests/auto/api.json +++ b/tests/auto/api.json @@ -196,7 +196,7 @@ } }, "Devices.PairDevice": { - "description": "Pair a device. Use this for DeviceClasses with a setupMethod different than SetupMethodJustAdd.Use deviceDescriptorId or deviceParams, depending on the createMethod of the device class. CreateMethodJustAdd takes the parameters you want to have with that device. CreateMethodDiscovery requires the use of a deviceDescriptorId. If success is true, the return values will contain a pairingTransactionId, a displayMessage and the setupMethod. Depending on the setupMethod you should either proceed with AddConfiguredDevice or PairDevice.", + "description": "Pair a device. Use this for DeviceClasses with a setupMethod different than SetupMethodJustAdd. Use deviceDescriptorId or deviceParams, depending on the createMethod of the device class. CreateMethodJustAdd takes the parameters you want to have with that device. CreateMethodDiscovery requires the use of a deviceDescriptorId. If success is true, the return values will contain a pairingTransactionId, a displayMessage and the setupMethod. Depending on the setupMethod you should either proceed with AddConfiguredDevice or PairDevice.", "params": { "deviceClassId": "Uuid", "o:deviceDescriptorId": "Uuid", @@ -215,6 +215,7 @@ "description": "Remove a device from the system.", "params": { "deviceId": "Uuid", + "o:removePolicy": "$ref:RemovePolicy", "o:removePolicyList": [ { "policy": "$ref:RemovePolicy", @@ -223,7 +224,10 @@ ] }, "returns": { - "deviceError": "$ref:DeviceError" + "deviceError": "$ref:DeviceError", + "o:ruleIds": [ + "Uuid" + ] } }, "Devices.SetPluginConfiguration": { @@ -549,6 +553,7 @@ "deviceClassId": "Uuid", "id": "Uuid", "name": "String", + "o:parentId": "Uuid", "params": [ "$ref:Param" ], @@ -604,6 +609,8 @@ "DeviceErrorAuthentificationFailure", "DeviceErrorAsync", "DeviceErrorDeviceInUse", + "DeviceErrorDeviceInRule", + "DeviceErrorDeviceIsChild", "DeviceErrorPairingTransactionIdNotFound", "DeviceErrorParameterNotWritable" ],