virtual-device: Add support for reporting device Retry "errors"
This commit is contained in:
parent
546f35132c
commit
f0443ba2f3
3 changed files with 27 additions and 2 deletions
|
@ -72,6 +72,10 @@ dev_identify (FpDevice *dev)
|
|||
new_scan,
|
||||
NULL);
|
||||
}
|
||||
else if (error && error->domain == FP_DEVICE_RETRY)
|
||||
{
|
||||
fpi_device_identify_report (dev, NULL, NULL, g_steal_pointer (&error));
|
||||
}
|
||||
|
||||
fpi_device_identify_complete (dev, g_steal_pointer (&error));
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ G_DEFINE_TYPE (FpDeviceVirtualDevice, fpi_device_virtual_device, FP_TYPE_DEVICE)
|
|||
#define REMOVE_CMD_PREFIX "REMOVE "
|
||||
#define SCAN_CMD_PREFIX "SCAN "
|
||||
#define ERROR_CMD_PREFIX "ERROR "
|
||||
#define RETRY_CMD_PREFIX "RETRY "
|
||||
|
||||
#define LIST_CMD "LIST"
|
||||
|
||||
|
@ -111,6 +112,14 @@ process_cmds (FpDeviceVirtualDevice * self,
|
|||
g_propagate_error (error,
|
||||
fpi_device_error_new (g_ascii_strtoull (cmd + strlen (ERROR_CMD_PREFIX), NULL, 10)));
|
||||
|
||||
g_ptr_array_remove_index (self->pending_commands, 0);
|
||||
return NULL;
|
||||
}
|
||||
else if (g_str_has_prefix (cmd, RETRY_CMD_PREFIX))
|
||||
{
|
||||
g_propagate_error (error,
|
||||
fpi_device_retry_new (g_ascii_strtoull (cmd + strlen (RETRY_CMD_PREFIX), NULL, 10)));
|
||||
|
||||
g_ptr_array_remove_index (self->pending_commands, 0);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -302,6 +311,9 @@ dev_verify (FpDevice *dev)
|
|||
g_debug ("Virtual device scan failed with error: %s", error->message);
|
||||
}
|
||||
|
||||
if (error && error->domain == FP_DEVICE_RETRY)
|
||||
fpi_device_verify_report (dev, FPI_MATCH_ERROR, NULL, g_steal_pointer (&error));
|
||||
|
||||
fpi_device_verify_complete (dev, g_steal_pointer (&error));
|
||||
}
|
||||
|
||||
|
@ -337,6 +349,9 @@ dev_enroll (FpDevice *dev)
|
|||
}
|
||||
else
|
||||
{
|
||||
if (error && error->domain == FP_DEVICE_RETRY)
|
||||
fpi_device_enroll_progress (dev, 0, NULL, g_steal_pointer (&error));
|
||||
else
|
||||
fpi_device_enroll_complete (dev, NULL, g_steal_pointer (&error));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,7 +93,7 @@ class VirtualDevice(unittest.TestCase):
|
|||
super().tearDown()
|
||||
|
||||
def send_command(self, command, *args):
|
||||
self.assertIn(command, ['INSERT', 'REMOVE', 'SCAN', 'ERROR'])
|
||||
self.assertIn(command, ['INSERT', 'REMOVE', 'SCAN', 'ERROR', 'RETRY'])
|
||||
|
||||
with Connection(self.sockaddr) as con:
|
||||
params = ' '.join(str(p) for p in args)
|
||||
|
@ -133,6 +133,8 @@ class VirtualDevice(unittest.TestCase):
|
|||
self.send_command('SCAN', scan_nick)
|
||||
elif isinstance(scan_nick, FPrint.DeviceError):
|
||||
self.send_command('ERROR', int(scan_nick))
|
||||
elif isinstance(scan_nick, FPrint.DeviceRetry):
|
||||
self.send_command('RETRY', int(scan_nick))
|
||||
|
||||
def verify_cb(dev, res):
|
||||
try:
|
||||
|
@ -186,6 +188,10 @@ class VirtualDevice(unittest.TestCase):
|
|||
with self.assertRaisesRegex(GLib.Error, r"An unspecified error occurred"):
|
||||
self.check_verify(matching, FPrint.DeviceError.GENERAL, match=False)
|
||||
|
||||
def test_enroll_verify_retry(self):
|
||||
with self.assertRaisesRegex(GLib.GError, 'too short'):
|
||||
self.check_verify(FPrint.Print.new(self.dev),
|
||||
FPrint.DeviceRetry.TOO_SHORT, match=False)
|
||||
|
||||
class VirtualDeviceStorage(VirtualDevice):
|
||||
|
||||
|
|
Loading…
Reference in a new issue