From b0c546164ea6d60d9994d8d007f13e8e6ca79b25 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 10 Apr 2020 16:35:11 +0200 Subject: [PATCH] fpi-device: Allow driver to handle identify for certain variants Rather than requiring a driver to implement a variant with identify support, and another one without, ask the driver whether a particular device supports identification. --- libfprint/fp-device.c | 10 ++++++++++ libfprint/fpi-device.h | 3 +++ 2 files changed, 13 insertions(+) diff --git a/libfprint/fp-device.c b/libfprint/fp-device.c index cde720c..4dd488c 100644 --- a/libfprint/fp-device.c +++ b/libfprint/fp-device.c @@ -507,6 +507,9 @@ fp_device_supports_identify (FpDevice *device) g_return_val_if_fail (FP_IS_DEVICE (device), FALSE); + if (cls->supports_identify != NULL) + return cls->supports_identify (device); + return cls->identify != NULL; } @@ -946,6 +949,13 @@ fp_device_identify (FpDevice *device, if (g_task_return_error_if_cancelled (task)) return; + if (!fp_device_supports_identify (device)) + { + g_task_return_error (task, + fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED)); + return; + } + if (!priv->is_open) { g_task_return_error (task, diff --git a/libfprint/fpi-device.h b/libfprint/fpi-device.h index 94cdb35..730e8d9 100644 --- a/libfprint/fpi-device.h +++ b/libfprint/fpi-device.h @@ -79,6 +79,7 @@ struct _FpIdEntry * @delete: Delete a print from the device * @cancel: Called on cancellation, this is a convenience to not need to handle * the #GCancellable directly by using fpi_device_get_cancellable(). + * @supports_identify: Whether identify operations are supported. * * NOTE: If your driver is image based, then you should subclass #FpImageDevice * instead. #FpImageDevice based drivers use a different way of interacting @@ -129,6 +130,8 @@ struct _FpDeviceClass void (*delete) (FpDevice * device); void (*cancel) (FpDevice *device); + + gboolean (*supports_identify) (FpDevice *device); }; /**