mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
Add an enrollment action
Return an error if an enrollment is already in progress.
This commit is contained in:
committed by
Daniel Drake
parent
5f3e1be27f
commit
f43ea8f095
35
src/device.c
35
src/device.c
@ -59,7 +59,8 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev,
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
ACTION_NONE = 0,
|
ACTION_NONE = 0,
|
||||||
ACTION_IDENTIFY,
|
ACTION_IDENTIFY,
|
||||||
ACTION_VERIFY
|
ACTION_VERIFY,
|
||||||
|
ACTION_ENROLL
|
||||||
} FprintDeviceAction;
|
} FprintDeviceAction;
|
||||||
|
|
||||||
struct session_data {
|
struct session_data {
|
||||||
@ -556,8 +557,13 @@ static void fprint_device_verify_start(FprintDevice *rdev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (priv->current_action != ACTION_NONE) {
|
if (priv->current_action != ACTION_NONE) {
|
||||||
|
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,
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
"Verification already in progress");
|
"Verification already in progress");
|
||||||
|
}
|
||||||
dbus_g_method_return_error(context, error);
|
dbus_g_method_return_error(context, error);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
return;
|
return;
|
||||||
@ -740,6 +746,19 @@ static void fprint_device_enroll_start(FprintDevice *rdev,
|
|||||||
return;
|
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);
|
g_message("start enrollment device %d finger %d", priv->id, finger_num);
|
||||||
session->enroll_finger = finger_num;
|
session->enroll_finger = finger_num;
|
||||||
|
|
||||||
@ -751,6 +770,8 @@ static void fprint_device_enroll_start(FprintDevice *rdev,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->current_action = ACTION_ENROLL;
|
||||||
|
|
||||||
dbus_g_method_return(context);
|
dbus_g_method_return(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -776,13 +797,23 @@ static void fprint_device_enroll_stop(FprintDevice *rdev,
|
|||||||
return;
|
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);
|
r = fp_async_enroll_stop(priv->dev, enroll_stop_cb, context);
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ENROLL_STOP,
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ENROLL_STOP,
|
||||||
"Enroll stop failed with error %d", r);
|
"Enroll stop failed with error %d", r);
|
||||||
dbus_g_method_return_error(context, error);
|
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,
|
static void fprint_device_list_enrolled_fingers(FprintDevice *rdev,
|
||||||
|
|||||||
Reference in New Issue
Block a user