mirror of
https://gitlab.freedesktop.org/libfprint/fprintd.git
synced 2026-01-05 11:30:16 +01:00
Add an enrollment action
Return an error if an enrollment is already in progress.
This commit is contained in:
parent
5f3e1be27f
commit
f43ea8f095
1 changed files with 35 additions and 4 deletions
39
src/device.c
39
src/device.c
|
|
@ -59,7 +59,8 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev,
|
|||
typedef enum {
|
||||
ACTION_NONE = 0,
|
||||
ACTION_IDENTIFY,
|
||||
ACTION_VERIFY
|
||||
ACTION_VERIFY,
|
||||
ACTION_ENROLL
|
||||
} FprintDeviceAction;
|
||||
|
||||
struct session_data {
|
||||
|
|
@ -556,8 +557,13 @@ static void fprint_device_verify_start(FprintDevice *rdev,
|
|||
}
|
||||
|
||||
if (priv->current_action != ACTION_NONE) {
|
||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||
"Verification already in progress");
|
||||
if (priv->current_action == ACTION_ENROLL) {
|
||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||
"Enrollment in progress");
|
||||
} else {
|
||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||
"Verification already in progress");
|
||||
}
|
||||
dbus_g_method_return_error(context, error);
|
||||
g_error_free (error);
|
||||
return;
|
||||
|
|
@ -740,6 +746,19 @@ static void fprint_device_enroll_start(FprintDevice *rdev,
|
|||
return;
|
||||
}
|
||||
|
||||
if (priv->current_action != ACTION_NONE) {
|
||||
if (priv->current_action == ACTION_ENROLL) {
|
||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||
"Enrollment already in progress");
|
||||
} else {
|
||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||
"Verification in progress");
|
||||
}
|
||||
dbus_g_method_return_error(context, error);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
g_message("start enrollment device %d finger %d", priv->id, finger_num);
|
||||
session->enroll_finger = finger_num;
|
||||
|
||||
|
|
@ -751,6 +770,8 @@ static void fprint_device_enroll_start(FprintDevice *rdev,
|
|||
return;
|
||||
}
|
||||
|
||||
priv->current_action = ACTION_ENROLL;
|
||||
|
||||
dbus_g_method_return(context);
|
||||
}
|
||||
|
||||
|
|
@ -776,13 +797,23 @@ static void fprint_device_enroll_stop(FprintDevice *rdev,
|
|||
return;
|
||||
}
|
||||
|
||||
if (priv->current_action != ACTION_ENROLL) {
|
||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ENROLL_STOP,
|
||||
"No enrollment in progress");
|
||||
dbus_g_method_return_error(context, error);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
r = fp_async_enroll_stop(priv->dev, enroll_stop_cb, context);
|
||||
if (r < 0) {
|
||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ENROLL_STOP,
|
||||
"Enroll stop failed with error %d", r);
|
||||
dbus_g_method_return_error(context, error);
|
||||
return;
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
priv->current_action = ACTION_NONE;
|
||||
}
|
||||
|
||||
static void fprint_device_list_enrolled_fingers(FprintDevice *rdev,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue