mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 04:13:33 +02:00
Add identify support
Passing -1 to the VerifyStart function will either accept any fingers scanned, if the driver supports identification, or select the first enrolled fingerprint for scanning if it doesn't.
This commit is contained in:
committed by
Daniel Drake
parent
b4bfdcd55d
commit
ee874bb1d4
80
src/device.c
80
src/device.c
@ -83,12 +83,15 @@ struct FprintDevicePrivate {
|
|||||||
/* The current user of the device, if claimed */
|
/* The current user of the device, if claimed */
|
||||||
char *sender;
|
char *sender;
|
||||||
|
|
||||||
/* Either the current user of the device, or if allowed,
|
/* The current user of the device, or if allowed,
|
||||||
* what was set using SetUsername */
|
* what was passed as a username argument */
|
||||||
char *username;
|
char *username;
|
||||||
|
|
||||||
/* type of storage */
|
/* type of storage */
|
||||||
int storage_type;
|
int storage_type;
|
||||||
|
|
||||||
|
/* whether we're running an identify, or a verify */
|
||||||
|
gboolean is_identify;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct FprintDevicePrivate FprintDevicePrivate;
|
typedef struct FprintDevicePrivate FprintDevicePrivate;
|
||||||
@ -441,7 +444,7 @@ static void fprint_device_claim(FprintDevice *rdev,
|
|||||||
priv->username = user;
|
priv->username = user;
|
||||||
priv->sender = sender;
|
priv->sender = sender;
|
||||||
|
|
||||||
g_message ("user '%s' claiming the device: %s", priv->username, priv->id);
|
g_message ("user '%s' claiming the device: %d", priv->username, priv->id);
|
||||||
|
|
||||||
priv->session = g_slice_new0(struct session_data);
|
priv->session = g_slice_new0(struct session_data);
|
||||||
priv->session->context_claim_device = context;
|
priv->session->context_claim_device = context;
|
||||||
@ -516,10 +519,21 @@ static void verify_cb(struct fp_dev *dev, int r, struct fp_img *img,
|
|||||||
fp_img_free(img);
|
fp_img_free(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void identify_cb(struct fp_dev *dev, int r,
|
||||||
|
size_t match_offset, struct fp_img *img, void *user_data)
|
||||||
|
{
|
||||||
|
struct FprintDevice *rdev = user_data;
|
||||||
|
g_message("verify_cb: result %d", r);
|
||||||
|
|
||||||
|
g_signal_emit(rdev, signals[SIGNAL_VERIFY_STATUS], 0, r);
|
||||||
|
fp_img_free(img);
|
||||||
|
}
|
||||||
|
|
||||||
static void fprint_device_verify_start(FprintDevice *rdev,
|
static void fprint_device_verify_start(FprintDevice *rdev,
|
||||||
guint32 finger_num, DBusGMethodInvocation *context)
|
guint32 finger_num, DBusGMethodInvocation *context)
|
||||||
{
|
{
|
||||||
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
||||||
|
struct fp_print_data **gallery = NULL;
|
||||||
struct fp_print_data *data = NULL;
|
struct fp_print_data *data = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
int r;
|
int r;
|
||||||
@ -534,6 +548,48 @@ static void fprint_device_verify_start(FprintDevice *rdev,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (finger_num == -1) {
|
||||||
|
GSList *prints;
|
||||||
|
|
||||||
|
prints = store.discover_prints(priv->ddev, priv->username);
|
||||||
|
if (prints == NULL) {
|
||||||
|
//FIXME exit
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (fp_dev_supports_identification(priv->dev)) {
|
||||||
|
GSList *l;
|
||||||
|
GPtrArray *array;
|
||||||
|
|
||||||
|
array = g_ptr_array_new ();
|
||||||
|
|
||||||
|
for (l = prints; l != NULL; l = l->next) {
|
||||||
|
r = store.print_data_load(priv->dev, (enum fp_finger) l->data,
|
||||||
|
&data, priv->username);
|
||||||
|
//FIXME r < 0 ?
|
||||||
|
g_ptr_array_add (array, data);
|
||||||
|
}
|
||||||
|
g_slist_free (l);
|
||||||
|
gallery = (struct fp_print_data **) g_ptr_array_free (array, FALSE);
|
||||||
|
data = NULL;
|
||||||
|
} else {
|
||||||
|
finger_num = (enum fp_finger) prints->data;
|
||||||
|
}
|
||||||
|
g_slist_free(prints);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fp_dev_supports_identification(priv->dev)) {
|
||||||
|
if (gallery == NULL) {
|
||||||
|
//FIXME exit
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
priv->is_identify = TRUE;
|
||||||
|
|
||||||
|
g_message ("start identification device %d", priv->id);
|
||||||
|
//FIXME we're supposed to free the gallery here?
|
||||||
|
r = fp_async_identify_start (priv->dev, gallery, identify_cb, rdev);
|
||||||
|
} else {
|
||||||
|
priv->is_identify = FALSE;
|
||||||
|
|
||||||
g_message("start verification device %d finger %d", priv->id, finger_num);
|
g_message("start verification device %d finger %d", priv->id, finger_num);
|
||||||
|
|
||||||
r = store.print_data_load(priv->dev, (enum fp_finger)finger_num,
|
r = store.print_data_load(priv->dev, (enum fp_finger)finger_num,
|
||||||
@ -548,8 +604,17 @@ static void fprint_device_verify_start(FprintDevice *rdev,
|
|||||||
|
|
||||||
/* FIXME fp_async_verify_start should copy the fp_print_data */
|
/* FIXME fp_async_verify_start should copy the fp_print_data */
|
||||||
r = fp_async_verify_start(priv->dev, data, verify_cb, rdev);
|
r = fp_async_verify_start(priv->dev, data, verify_cb, rdev);
|
||||||
|
}
|
||||||
|
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
|
if (data != NULL) {
|
||||||
fp_print_data_free (data);
|
fp_print_data_free (data);
|
||||||
|
} else if (gallery != NULL) {
|
||||||
|
guint i;
|
||||||
|
for (i = 0; gallery[i] != NULL; i++)
|
||||||
|
fp_print_data_free(gallery[i]);
|
||||||
|
g_free (gallery);
|
||||||
|
}
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_VERIFY_START,
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_VERIFY_START,
|
||||||
"Verify start failed with error %d", r);
|
"Verify start failed with error %d", r);
|
||||||
dbus_g_method_return_error(context, error);
|
dbus_g_method_return_error(context, error);
|
||||||
@ -564,6 +629,11 @@ static void verify_stop_cb(struct fp_dev *dev, void *user_data)
|
|||||||
dbus_g_method_return((DBusGMethodInvocation *) user_data);
|
dbus_g_method_return((DBusGMethodInvocation *) user_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void identify_stop_cb(struct fp_dev *dev, void *user_data)
|
||||||
|
{
|
||||||
|
dbus_g_method_return((DBusGMethodInvocation *) user_data);
|
||||||
|
}
|
||||||
|
|
||||||
static void fprint_device_verify_stop(FprintDevice *rdev,
|
static void fprint_device_verify_stop(FprintDevice *rdev,
|
||||||
DBusGMethodInvocation *context)
|
DBusGMethodInvocation *context)
|
||||||
{
|
{
|
||||||
@ -581,7 +651,11 @@ static void fprint_device_verify_stop(FprintDevice *rdev,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (priv->is_identify == FALSE) {
|
||||||
r = fp_async_verify_stop(priv->dev, verify_stop_cb, context);
|
r = fp_async_verify_stop(priv->dev, verify_stop_cb, context);
|
||||||
|
} else {
|
||||||
|
r = fp_async_identify_stop(priv->dev, identify_stop_cb, context);
|
||||||
|
}
|
||||||
if (r < 0) {
|
if (r < 0) {
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_VERIFY_STOP,
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_VERIFY_STOP,
|
||||||
"Verify stop failed with error %d", r);
|
"Verify stop failed with error %d", r);
|
||||||
|
|||||||
Reference in New Issue
Block a user