mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
device: Expose supported features publicly as FpDeviceFeature
It can be convenient for device users to check what it supports, without having multiple functions to check each single feature. So expose this and add tests.
This commit is contained in:
@@ -1581,5 +1581,5 @@ fpi_device_goodixmoc_class_init (FpiDeviceGoodixMocClass *klass)
|
||||
dev_class->identify = gx_fp_verify_identify;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
dev_class->features |= FPI_DEVICE_FEATURE_DUPLICATES_CHECK;
|
||||
dev_class->features |= FP_DEVICE_FEATURE_DUPLICATES_CHECK;
|
||||
}
|
||||
|
||||
@@ -246,5 +246,5 @@ fpi_device_virtual_device_storage_class_init (FpDeviceVirtualDeviceStorageClass
|
||||
dev_class->delete = dev_delete;
|
||||
|
||||
fpi_device_class_auto_initialize_features (dev_class);
|
||||
dev_class->features |= FPI_DEVICE_FEATURE_DUPLICATES_CHECK;
|
||||
dev_class->features |= FP_DEVICE_FEATURE_DUPLICATES_CHECK;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ fp_device_constructed (GObject *object)
|
||||
FpDeviceClass *cls = FP_DEVICE_GET_CLASS (self);
|
||||
FpDevicePrivate *priv = fp_device_get_instance_private (self);
|
||||
|
||||
g_assert (cls->features != FPI_DEVICE_FEATURE_NONE);
|
||||
g_assert (cls->features != FP_DEVICE_FEATURE_NONE);
|
||||
|
||||
priv->type = cls->type;
|
||||
if (cls->nr_enroll_stages)
|
||||
@@ -629,7 +629,7 @@ fp_device_supports_identify (FpDevice *device)
|
||||
|
||||
g_return_val_if_fail (FP_IS_DEVICE (device), FALSE);
|
||||
|
||||
return cls->identify && !!(cls->features & FPI_DEVICE_FEATURE_IDENTIFY);
|
||||
return cls->identify && !!(cls->features & FP_DEVICE_FEATURE_IDENTIFY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -647,7 +647,7 @@ fp_device_supports_capture (FpDevice *device)
|
||||
|
||||
g_return_val_if_fail (FP_IS_DEVICE (device), FALSE);
|
||||
|
||||
return cls->capture && !!(cls->features & FPI_DEVICE_FEATURE_CAPTURE);
|
||||
return cls->capture && !!(cls->features & FP_DEVICE_FEATURE_CAPTURE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -666,7 +666,7 @@ fp_device_has_storage (FpDevice *device)
|
||||
|
||||
g_return_val_if_fail (FP_IS_DEVICE (device), FALSE);
|
||||
|
||||
return !!(cls->features & FPI_DEVICE_FEATURE_STORAGE);
|
||||
return !!(cls->features & FP_DEVICE_FEATURE_STORAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -976,7 +976,7 @@ fp_device_verify (FpDevice *device,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cls->verify || !(cls->features & FPI_DEVICE_FEATURE_VERIFY))
|
||||
if (!cls->verify || !(cls->features & FP_DEVICE_FEATURE_VERIFY))
|
||||
{
|
||||
g_task_return_error (task,
|
||||
fpi_device_error_new_msg (FP_DEVICE_ERROR_NOT_SUPPORTED,
|
||||
@@ -1211,7 +1211,7 @@ fp_device_capture (FpDevice *device,
|
||||
return;
|
||||
}
|
||||
|
||||
if (!cls->capture || !(cls->features & FPI_DEVICE_FEATURE_CAPTURE))
|
||||
if (!cls->capture || !(cls->features & FP_DEVICE_FEATURE_CAPTURE))
|
||||
{
|
||||
g_task_return_error (task,
|
||||
fpi_device_error_new_msg (FP_DEVICE_ERROR_NOT_SUPPORTED,
|
||||
@@ -1295,7 +1295,7 @@ fp_device_delete_print (FpDevice *device,
|
||||
}
|
||||
|
||||
/* Succeed immediately if delete is not implemented. */
|
||||
if (!cls->delete || !(cls->features & FPI_DEVICE_FEATURE_STORAGE_DELETE))
|
||||
if (!cls->delete || !(cls->features & FP_DEVICE_FEATURE_STORAGE_DELETE))
|
||||
{
|
||||
g_task_return_boolean (task, TRUE);
|
||||
return;
|
||||
@@ -1672,3 +1672,41 @@ fp_device_list_prints_sync (FpDevice *device,
|
||||
|
||||
return fp_device_list_prints_finish (device, task, error);
|
||||
}
|
||||
|
||||
/**
|
||||
* fp_device_get_features:
|
||||
* @device: a #FpDevice
|
||||
*
|
||||
* Gets the #FpDeviceFeature's supported by the @device.
|
||||
*
|
||||
* Returns: #FpDeviceFeature flags of supported features
|
||||
*/
|
||||
FpDeviceFeature
|
||||
fp_device_get_features (FpDevice *device)
|
||||
{
|
||||
g_return_val_if_fail (FP_IS_DEVICE (device), FP_DEVICE_FEATURE_NONE);
|
||||
|
||||
return FP_DEVICE_GET_CLASS (device)->features;
|
||||
}
|
||||
|
||||
/**
|
||||
* fp_device_has_feature:
|
||||
* @device: a #FpDevice
|
||||
* @feature: #FpDeviceFeature flags to check against device supported features
|
||||
*
|
||||
* Checks if @device supports the requested #FpDeviceFeature's.
|
||||
* See fp_device_get_features()
|
||||
*
|
||||
* Returns: %TRUE if supported, %FALSE otherwise
|
||||
*/
|
||||
gboolean
|
||||
fp_device_has_feature (FpDevice *device,
|
||||
FpDeviceFeature feature)
|
||||
{
|
||||
g_return_val_if_fail (FP_IS_DEVICE (device), FALSE);
|
||||
|
||||
if (feature == FP_DEVICE_FEATURE_NONE)
|
||||
return fp_device_get_features (device) == feature;
|
||||
|
||||
return (fp_device_get_features (device) & feature) == feature;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,30 @@ typedef enum {
|
||||
FP_DEVICE_TYPE_USB,
|
||||
} FpDeviceType;
|
||||
|
||||
/**
|
||||
* FpDeviceFeature:
|
||||
* @FP_DEVICE_FEATURE_NONE: Device does not support any feature
|
||||
* @FP_DEVICE_FEATURE_CAPTURE: Supports image capture
|
||||
* @FP_DEVICE_FEATURE_VERIFY: Supports finger verification
|
||||
* @FP_DEVICE_FEATURE_IDENTIFY: Supports finger identification
|
||||
* @FP_DEVICE_FEATURE_STORAGE: Device has a persistent storage
|
||||
* @FP_DEVICE_FEATURE_STORAGE_LIST: Supports listing the storage templates
|
||||
* @FP_DEVICE_FEATURE_STORAGE_DELETE: Supports deleting stored templates
|
||||
* @FP_DEVICE_FEATURE_STORAGE_CLEAR: Supports clearing the whole storage
|
||||
* @FP_DEVICE_FEATURE_DUPLICATES_CHECK: Natively supports duplicates detection
|
||||
*/
|
||||
typedef enum /*< flags >*/ {
|
||||
FP_DEVICE_FEATURE_NONE = 0,
|
||||
FP_DEVICE_FEATURE_CAPTURE = 1 << 0,
|
||||
FP_DEVICE_FEATURE_IDENTIFY = 1 << 1,
|
||||
FP_DEVICE_FEATURE_VERIFY = 1 << 2,
|
||||
FP_DEVICE_FEATURE_STORAGE = 1 << 3,
|
||||
FP_DEVICE_FEATURE_STORAGE_LIST = 1 << 4,
|
||||
FP_DEVICE_FEATURE_STORAGE_DELETE = 1 << 5,
|
||||
FP_DEVICE_FEATURE_STORAGE_CLEAR = 1 << 6,
|
||||
FP_DEVICE_FEATURE_DUPLICATES_CHECK = 1 << 7,
|
||||
} FpDeviceFeature;
|
||||
|
||||
/**
|
||||
* FpScanType:
|
||||
* @FP_SCAN_TYPE_SWIPE: Sensor requires swiping the finger.
|
||||
@@ -178,6 +202,10 @@ FpScanType fp_device_get_scan_type (FpDevice *device);
|
||||
FpFingerStatusFlags fp_device_get_finger_status (FpDevice *device);
|
||||
gint fp_device_get_nr_enroll_stages (FpDevice *device);
|
||||
|
||||
FpDeviceFeature fp_device_get_features (FpDevice *device);
|
||||
gboolean fp_device_has_feature (FpDevice *device,
|
||||
FpDeviceFeature feature);
|
||||
|
||||
gboolean fp_device_supports_identify (FpDevice *device);
|
||||
gboolean fp_device_supports_capture (FpDevice *device);
|
||||
gboolean fp_device_has_storage (FpDevice *device);
|
||||
|
||||
@@ -59,24 +59,24 @@ fpi_device_class_auto_initialize_features (FpDeviceClass *device_class)
|
||||
g_return_if_fail (FP_IS_DEVICE_CLASS (device_class));
|
||||
|
||||
if (device_class->capture)
|
||||
device_class->features |= FPI_DEVICE_FEATURE_CAPTURE;
|
||||
device_class->features |= FP_DEVICE_FEATURE_CAPTURE;
|
||||
|
||||
if (device_class->verify)
|
||||
device_class->features |= FPI_DEVICE_FEATURE_VERIFY;
|
||||
device_class->features |= FP_DEVICE_FEATURE_VERIFY;
|
||||
|
||||
if (device_class->identify)
|
||||
device_class->features |= FPI_DEVICE_FEATURE_IDENTIFY;
|
||||
device_class->features |= FP_DEVICE_FEATURE_IDENTIFY;
|
||||
|
||||
if (device_class->list)
|
||||
{
|
||||
device_class->features |= FPI_DEVICE_FEATURE_STORAGE;
|
||||
device_class->features |= FPI_DEVICE_FEATURE_STORAGE_LIST;
|
||||
device_class->features |= FP_DEVICE_FEATURE_STORAGE;
|
||||
device_class->features |= FP_DEVICE_FEATURE_STORAGE_LIST;
|
||||
}
|
||||
|
||||
if (device_class->delete)
|
||||
{
|
||||
device_class->features |= FPI_DEVICE_FEATURE_STORAGE;
|
||||
device_class->features |= FPI_DEVICE_FEATURE_STORAGE_DELETE;
|
||||
device_class->features |= FP_DEVICE_FEATURE_STORAGE;
|
||||
device_class->features |= FP_DEVICE_FEATURE_STORAGE_DELETE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,30 +69,6 @@ struct _FpIdEntry
|
||||
guint64 driver_data;
|
||||
};
|
||||
|
||||
/**
|
||||
* FpiDeviceFeature:
|
||||
* @FPI_DEVICE_FEATURE_NONE: Device does not support any feature
|
||||
* @FPI_DEVICE_FEATURE_CAPTURE: Supports image capture
|
||||
* @FPI_DEVICE_FEATURE_IDENTIFY: Supports finger identification
|
||||
* @FPI_DEVICE_FEATURE_VERIFY: Supports finger verification
|
||||
* @FPI_DEVICE_FEATURE_STORAGE: Device has a persistent storage
|
||||
* @FPI_DEVICE_FEATURE_STORAGE_LIST: Supports listing the storage templates
|
||||
* @FPI_DEVICE_FEATURE_STORAGE_DELETE: Supports deleting stored templates
|
||||
* @FPI_DEVICE_FEATURE_STORAGE_CLEAR: Supports clearing the whole storage
|
||||
* @FPI_DEVICE_FEATURE_DUPLICATES_CHECK: Natively supports duplicates detection
|
||||
*/
|
||||
typedef enum /*< flags >*/ {
|
||||
FPI_DEVICE_FEATURE_NONE = 0,
|
||||
FPI_DEVICE_FEATURE_CAPTURE = 1 << 0,
|
||||
FPI_DEVICE_FEATURE_IDENTIFY = 1 << 1,
|
||||
FPI_DEVICE_FEATURE_VERIFY = 1 << 2,
|
||||
FPI_DEVICE_FEATURE_STORAGE = 1 << 3,
|
||||
FPI_DEVICE_FEATURE_STORAGE_LIST = 1 << 4,
|
||||
FPI_DEVICE_FEATURE_STORAGE_DELETE = 1 << 5,
|
||||
FPI_DEVICE_FEATURE_STORAGE_CLEAR = 1 << 6,
|
||||
FPI_DEVICE_FEATURE_DUPLICATES_CHECK = 1 << 7,
|
||||
} FpiDeviceFeature;
|
||||
|
||||
/**
|
||||
* FpDeviceClass:
|
||||
* @id: ID string for the driver. Should be a valid C identifier and should
|
||||
@@ -159,7 +135,7 @@ struct _FpDeviceClass
|
||||
const gchar *full_name;
|
||||
FpDeviceType type;
|
||||
const FpIdEntry *id_table;
|
||||
FpiDeviceFeature features;
|
||||
FpDeviceFeature features;
|
||||
|
||||
/* Defaults for device properties */
|
||||
gint nr_enroll_stages;
|
||||
|
||||
Reference in New Issue
Block a user