mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
Track current action
Track the current action happening in the device, so we can see what each device is doing. Refuse to launch a verification if there's already one in progress.
This commit is contained in:
committed by
Daniel Drake
parent
4bc8330d56
commit
5f3e1be27f
41
src/device.c
41
src/device.c
@ -56,6 +56,12 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev,
|
|||||||
|
|
||||||
#include "device-dbus-glue.h"
|
#include "device-dbus-glue.h"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
ACTION_NONE = 0,
|
||||||
|
ACTION_IDENTIFY,
|
||||||
|
ACTION_VERIFY
|
||||||
|
} FprintDeviceAction;
|
||||||
|
|
||||||
struct session_data {
|
struct session_data {
|
||||||
/* finger being enrolled */
|
/* finger being enrolled */
|
||||||
int enroll_finger;
|
int enroll_finger;
|
||||||
@ -67,11 +73,6 @@ struct session_data {
|
|||||||
DBusGMethodInvocation *context_release_device;
|
DBusGMethodInvocation *context_release_device;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct loaded_print {
|
|
||||||
guint32 id;
|
|
||||||
struct fp_print_data *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct FprintDevicePrivate {
|
struct FprintDevicePrivate {
|
||||||
guint32 id;
|
guint32 id;
|
||||||
struct fp_dscv_dev *ddev;
|
struct fp_dscv_dev *ddev;
|
||||||
@ -91,7 +92,7 @@ struct FprintDevicePrivate {
|
|||||||
int storage_type;
|
int storage_type;
|
||||||
|
|
||||||
/* whether we're running an identify, or a verify */
|
/* whether we're running an identify, or a verify */
|
||||||
gboolean is_identify;
|
FprintDeviceAction current_action;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct FprintDevicePrivate FprintDevicePrivate;
|
typedef struct FprintDevicePrivate FprintDevicePrivate;
|
||||||
@ -544,11 +545,21 @@ static void fprint_device_verify_start(FprintDevice *rdev,
|
|||||||
|
|
||||||
if (_fprint_device_check_claimed(rdev, context, &error) == FALSE) {
|
if (_fprint_device_check_claimed(rdev, context, &error) == FALSE) {
|
||||||
dbus_g_method_return_error (context, error);
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_fprint_device_check_polkit_for_action (rdev, context, "net.reactivated.fprint.device.verify", &error) == FALSE) {
|
if (_fprint_device_check_polkit_for_action (rdev, context, "net.reactivated.fprint.device.verify", &error) == FALSE) {
|
||||||
dbus_g_method_return_error (context, error);
|
dbus_g_method_return_error (context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (priv->current_action != ACTION_NONE) {
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,13 +606,13 @@ static void fprint_device_verify_start(FprintDevice *rdev,
|
|||||||
g_message ("NO GALLERY");
|
g_message ("NO GALLERY");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
priv->is_identify = TRUE;
|
priv->current_action = ACTION_IDENTIFY;
|
||||||
|
|
||||||
g_message ("start identification device %d", priv->id);
|
g_message ("start identification device %d", priv->id);
|
||||||
//FIXME we're supposed to free the gallery here?
|
//FIXME we're supposed to free the gallery here?
|
||||||
r = fp_async_identify_start (priv->dev, gallery, identify_cb, rdev);
|
r = fp_async_identify_start (priv->dev, gallery, identify_cb, rdev);
|
||||||
} else {
|
} else {
|
||||||
priv->is_identify = FALSE;
|
priv->current_action = ACTION_VERIFY;
|
||||||
|
|
||||||
g_message("start verification device %d finger %d", priv->id, finger_num);
|
g_message("start verification device %d finger %d", priv->id, finger_num);
|
||||||
|
|
||||||
@ -669,16 +680,26 @@ static void fprint_device_verify_stop(FprintDevice *rdev,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->is_identify == FALSE) {
|
if (priv->current_action == ACTION_VERIFY) {
|
||||||
r = fp_async_verify_stop(priv->dev, verify_stop_cb, context);
|
r = fp_async_verify_stop(priv->dev, verify_stop_cb, context);
|
||||||
} else {
|
} else if (priv->current_action == ACTION_IDENTIFY) {
|
||||||
r = fp_async_identify_stop(priv->dev, identify_stop_cb, context);
|
r = fp_async_identify_stop(priv->dev, identify_stop_cb, context);
|
||||||
|
} else {
|
||||||
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_VERIFY_STOP,
|
||||||
|
"No verification in progress");
|
||||||
|
dbus_g_method_return_error(context, error);
|
||||||
|
g_error_free (error);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
dbus_g_method_return_error(context, error);
|
dbus_g_method_return_error(context, error);
|
||||||
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
priv->current_action = ACTION_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void enroll_stage_cb(struct fp_dev *dev, int result,
|
static void enroll_stage_cb(struct fp_dev *dev, int result,
|
||||||
|
|||||||
Reference in New Issue
Block a user