mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
Introduce an early reporting mechanism for verify and match
It is a good idea to report match results early, to e.g. log in a user
immediately even if more device interaction is needed. Add new _full
variants for the verify/identify functions, with a corresponding
callback. Also move driver result reporting into new
fpi_device_{identify,verify}_report functions and remove the reporting
from the fpi_device_{identify,verify}_complete calls.
Basic updates to code is done in places. Only the upekts driver is
actually modified from a behaviour point of view. The image driver code
should be restructured quite a bit to split the reporting and only
report completion after device deactivation. This should simplifiy the
code quite a bit again.
This commit is contained in:
@@ -809,10 +809,13 @@ fp_device_enroll_finish (FpDevice *device,
|
||||
* @device: a #FpDevice
|
||||
* @enrolled_print: a #FpPrint to verify
|
||||
* @cancellable: (nullable): a #GCancellable, or %NULL
|
||||
* @match_cb: (nullable) (scope notified): match reporting callback
|
||||
* @match_data: (closure match_cb): user data for @match_cb
|
||||
* @match_destroy: (destroy match_data): Destroy notify for @match_data
|
||||
* @callback: the function to call on completion
|
||||
* @user_data: the data to pass to @callback
|
||||
*
|
||||
* Start an asynchronous operation to close the device. The callback will
|
||||
* Start an asynchronous operation to verify a print. The callback will
|
||||
* be called once the operation has finished. Retrieve the result with
|
||||
* fp_device_verify_finish().
|
||||
*/
|
||||
@@ -820,11 +823,15 @@ void
|
||||
fp_device_verify (FpDevice *device,
|
||||
FpPrint *enrolled_print,
|
||||
GCancellable *cancellable,
|
||||
FpMatchCb match_cb,
|
||||
gpointer match_data,
|
||||
GDestroyNotify match_destroy,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
FpDevicePrivate *priv = fp_device_get_instance_private (device);
|
||||
FpMatchData *data;
|
||||
|
||||
task = g_task_new (device, cancellable, callback, user_data);
|
||||
if (g_task_return_error_if_cancelled (task))
|
||||
@@ -848,9 +855,14 @@ fp_device_verify (FpDevice *device,
|
||||
priv->current_task = g_steal_pointer (&task);
|
||||
maybe_cancel_on_cancelled (device, cancellable);
|
||||
|
||||
g_task_set_task_data (priv->current_task,
|
||||
g_object_ref (enrolled_print),
|
||||
g_object_unref);
|
||||
data = g_new0 (FpMatchData, 1);
|
||||
data->enrolled_print = g_object_ref (enrolled_print);
|
||||
data->match_cb = match_cb;
|
||||
data->match_data = match_data;
|
||||
data->match_destroy = match_destroy;
|
||||
|
||||
// Attach the match data as task data so that it is destroyed
|
||||
g_task_set_task_data (priv->current_task, data, (GDestroyNotify) match_data_free);
|
||||
|
||||
FP_DEVICE_GET_CLASS (device)->verify (device);
|
||||
}
|
||||
@@ -886,7 +898,11 @@ fp_device_verify_finish (FpDevice *device,
|
||||
|
||||
if (print)
|
||||
{
|
||||
*print = g_object_get_data (G_OBJECT (result), "print");
|
||||
FpMatchData *data;
|
||||
|
||||
data = g_task_get_task_data (G_TASK (result));
|
||||
|
||||
*print = data->print;
|
||||
if (*print)
|
||||
g_object_ref (*print);
|
||||
}
|
||||
@@ -902,6 +918,9 @@ fp_device_verify_finish (FpDevice *device,
|
||||
* @device: a #FpDevice
|
||||
* @prints: (element-type FpPrint) (transfer none): #GPtrArray of #FpPrint
|
||||
* @cancellable: (nullable): a #GCancellable, or %NULL
|
||||
* @match_cb: (nullable) (scope notified): match reporting callback
|
||||
* @match_data: (closure match_cb): user data for @match_cb
|
||||
* @match_destroy: (destroy match_data): Destroy notify for @match_data
|
||||
* @callback: the function to call on completion
|
||||
* @user_data: the data to pass to @callback
|
||||
*
|
||||
@@ -913,11 +932,15 @@ void
|
||||
fp_device_identify (FpDevice *device,
|
||||
GPtrArray *prints,
|
||||
GCancellable *cancellable,
|
||||
FpMatchCb match_cb,
|
||||
gpointer match_data,
|
||||
GDestroyNotify match_destroy,
|
||||
GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_autoptr(GTask) task = NULL;
|
||||
FpDevicePrivate *priv = fp_device_get_instance_private (device);
|
||||
FpMatchData *data;
|
||||
|
||||
task = g_task_new (device, cancellable, callback, user_data);
|
||||
if (g_task_return_error_if_cancelled (task))
|
||||
@@ -941,9 +964,14 @@ fp_device_identify (FpDevice *device,
|
||||
priv->current_task = g_steal_pointer (&task);
|
||||
maybe_cancel_on_cancelled (device, cancellable);
|
||||
|
||||
g_task_set_task_data (priv->current_task,
|
||||
g_ptr_array_ref (prints),
|
||||
(GDestroyNotify) g_ptr_array_unref);
|
||||
data = g_new0 (FpMatchData, 1);
|
||||
data->gallery = g_ptr_array_ref (prints);
|
||||
data->match_cb = match_cb;
|
||||
data->match_data = match_data;
|
||||
data->match_destroy = match_destroy;
|
||||
|
||||
// Attach the match data as task data so that it is destroyed
|
||||
g_task_set_task_data (priv->current_task, data, (GDestroyNotify) match_data_free);
|
||||
|
||||
FP_DEVICE_GET_CLASS (device)->identify (device);
|
||||
}
|
||||
@@ -974,15 +1002,19 @@ fp_device_identify_finish (FpDevice *device,
|
||||
FpPrint **print,
|
||||
GError **error)
|
||||
{
|
||||
FpMatchData *data;
|
||||
|
||||
data = g_task_get_task_data (G_TASK (result));
|
||||
|
||||
if (print)
|
||||
{
|
||||
*print = g_object_get_data (G_OBJECT (result), "print");
|
||||
*print = data->print;
|
||||
if (*print)
|
||||
g_object_ref (*print);
|
||||
}
|
||||
if (match)
|
||||
{
|
||||
*match = g_object_get_data (G_OBJECT (result), "match");
|
||||
*match = data->match;
|
||||
if (*match)
|
||||
g_object_ref (*match);
|
||||
}
|
||||
@@ -1332,6 +1364,7 @@ fp_device_verify_sync (FpDevice *device,
|
||||
fp_device_verify (device,
|
||||
enrolled_print,
|
||||
cancellable,
|
||||
NULL, NULL, NULL,
|
||||
async_result_ready, &task);
|
||||
while (!task)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
@@ -1367,6 +1400,7 @@ fp_device_identify_sync (FpDevice *device,
|
||||
fp_device_identify (device,
|
||||
prints,
|
||||
cancellable,
|
||||
NULL, NULL, NULL,
|
||||
async_result_ready, &task);
|
||||
while (!task)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
Reference in New Issue
Block a user