Improve device removal
On device removal, we currently only emit a signal from FpContext
to inform the API user that a device has been removed. However, I am not sure that this is sufficient/correct.
The current situation probably works in principle. i.e. as the USB device is invalid, all access will just error out. At that point, any pending action will throw an error an the API user will likely decide to close the device (also resulting in an error).
However, that is suboptimal, because the API user would need to wait for the current action to complete, then try to close (which is pointless) and catch that error. In the case of fprintd
, it would make sense to wait for the current action and the close
to complete before emitting the device-removed
event on the context. i.e. only emit device-removed
once all operations are done and the device can be finalized safely.
I am now thinking:
- Add a new
FP_ERROR_DEVICE_REMOVED
- Adding
removed
property andremoved
signal on the device itself - Set
removed
- Cancel any current operation (optional)
- Wait for operation completion, return
FP_ERROR_DEVICE_REMOVED
- Emit
removed
signal - API user closes the device in response to
removed
(if it is still open) -
FpContext
is notified the device is closed and emitsdevice-removed
That should make fprintd code really simple. Because all we need to do is kick the current client when we get the removed
signal (which closes the device and will then cause the DBus Object to be removed).