virtual-device: Refactor command handling and add CONT command

This command is useful to immediately continue rather than waiting for
input. It is only useful for non-scanning device actions and can be
important when steps need to be explicitly skipped (e.g. to inject an
error in the second command without a way to wait in between).
This commit is contained in:
Benjamin Berg
2021-04-29 17:48:55 +02:00
committed by Benjamin Berg
parent ae6be6837b
commit 992a207ede
3 changed files with 100 additions and 110 deletions
+7 -11
View File
@@ -42,8 +42,7 @@ dev_identify (FpDevice *dev)
FpDeviceVirtualDevice *self = FP_DEVICE_VIRTUAL_DEVICE (dev);
g_autofree char *scan_id = NULL;
scan_id = start_scan_command (self, &error);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_PENDING))
if (!start_scan_command (self, &scan_id, &error))
return;
if (scan_id)
@@ -147,11 +146,10 @@ dev_list (FpDevice *dev)
g_autoptr(GError) error = NULL;
FpDeviceVirtualDevice *vdev = FP_DEVICE_VIRTUAL_DEVICE (dev);
process_cmds (vdev, FALSE, &error);
if (should_wait_for_command (vdev, error))
if (!process_cmds (vdev, FALSE, NULL, &error))
return;
if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
if (error)
{
fpi_device_list_complete (dev, NULL, g_steal_pointer (&error));
return;
@@ -167,11 +165,10 @@ dev_clear_storage (FpDevice *dev)
g_autoptr(GError) error = NULL;
FpDeviceVirtualDevice *vdev = FP_DEVICE_VIRTUAL_DEVICE (dev);
process_cmds (vdev, FALSE, &error);
if (should_wait_for_command (vdev, error))
if (!process_cmds (vdev, FALSE, NULL, &error))
return;
if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
if (error)
{
fpi_device_clear_storage_complete (dev, g_steal_pointer (&error));
return;
@@ -189,11 +186,10 @@ dev_delete (FpDevice *dev)
FpPrint *print = NULL;
const char *id = NULL;
process_cmds (vdev, FALSE, &error);
if (should_wait_for_command (vdev, error))
if (!process_cmds (vdev, FALSE, NULL, &error))
return;
if (error && !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
if (error)
{
fpi_device_delete_complete (dev, g_steal_pointer (&error));
return;