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.
This commit is contained in:
parent
f2ae3fb8c5
commit
b0c546164e
2 changed files with 13 additions and 0 deletions
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue