mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02:00
Kill LoadPrintData and UnloadPrintData
They were just doing nothing interesting for us, and might cause problems if data changes under us (say, remote storage).
This commit is contained in:
committed by
Daniel Drake
parent
f7ae545dc9
commit
bb1210981b
157
src/device.c
157
src/device.c
@ -41,8 +41,6 @@ static void fprint_device_claim(FprintDevice *rdev,
|
|||||||
DBusGMethodInvocation *context);
|
DBusGMethodInvocation *context);
|
||||||
static void fprint_device_release(FprintDevice *rdev,
|
static void fprint_device_release(FprintDevice *rdev,
|
||||||
DBusGMethodInvocation *context);
|
DBusGMethodInvocation *context);
|
||||||
static void fprint_device_unload_print_data(FprintDevice *rdev,
|
|
||||||
guint32 print_id, DBusGMethodInvocation *context);
|
|
||||||
static void fprint_device_verify_start(FprintDevice *rdev,
|
static void fprint_device_verify_start(FprintDevice *rdev,
|
||||||
guint32 print_id, DBusGMethodInvocation *context);
|
guint32 print_id, DBusGMethodInvocation *context);
|
||||||
static void fprint_device_verify_stop(FprintDevice *rdev,
|
static void fprint_device_verify_stop(FprintDevice *rdev,
|
||||||
@ -55,8 +53,6 @@ static gboolean fprint_device_set_storage_type(FprintDevice *rdev,
|
|||||||
gint type);
|
gint type);
|
||||||
static void fprint_device_list_enrolled_fingers(FprintDevice *rdev,
|
static void fprint_device_list_enrolled_fingers(FprintDevice *rdev,
|
||||||
DBusGMethodInvocation *context);
|
DBusGMethodInvocation *context);
|
||||||
static void fprint_device_load_print_data(FprintDevice *rdev,
|
|
||||||
guint32 finger_num, DBusGMethodInvocation *context);
|
|
||||||
|
|
||||||
#include "device-dbus-glue.h"
|
#include "device-dbus-glue.h"
|
||||||
|
|
||||||
@ -69,10 +65,6 @@ struct session_data {
|
|||||||
|
|
||||||
/* method invocation for async ReleaseDevice() */
|
/* method invocation for async ReleaseDevice() */
|
||||||
DBusGMethodInvocation *context_release_device;
|
DBusGMethodInvocation *context_release_device;
|
||||||
|
|
||||||
/* a list of loaded prints */
|
|
||||||
GSList *loaded_prints;
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct loaded_print {
|
struct loaded_print {
|
||||||
@ -327,8 +319,6 @@ fprint_device_set_username (FprintDevice *rdev,
|
|||||||
{
|
{
|
||||||
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
struct session_data *session = priv->session;
|
|
||||||
GSList *elem = session->loaded_prints;
|
|
||||||
|
|
||||||
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);
|
||||||
@ -345,31 +335,9 @@ fprint_device_set_username (FprintDevice *rdev,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We already have a username, check if the one we're
|
|
||||||
* setting is the same */
|
|
||||||
if (g_str_equal (username, priv->username) != FALSE) {
|
|
||||||
dbus_g_method_return (context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (priv->username);
|
g_free (priv->username);
|
||||||
priv->username = g_strdup (username);
|
priv->username = g_strdup (username);
|
||||||
|
|
||||||
/* Any fingerprints to unload? */
|
|
||||||
if (!elem) {
|
|
||||||
dbus_g_method_return (context);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Empty the fingerprints, as we have a different user */
|
|
||||||
do {
|
|
||||||
struct loaded_print *print = elem->data;
|
|
||||||
|
|
||||||
session->loaded_prints = g_slist_delete_link(session->loaded_prints,
|
|
||||||
elem);
|
|
||||||
g_slice_free(struct loaded_print, print);
|
|
||||||
} while ((elem = g_slist_next(elem)) != NULL);
|
|
||||||
|
|
||||||
dbus_g_method_return (context);
|
dbus_g_method_return (context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -494,7 +462,6 @@ static void fprint_device_release(FprintDevice *rdev,
|
|||||||
{
|
{
|
||||||
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
||||||
struct session_data *session = priv->session;
|
struct session_data *session = priv->session;
|
||||||
GSList *elem = session->loaded_prints;
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (_fprint_device_check_claimed(rdev, context, &error) == FALSE) {
|
if (_fprint_device_check_claimed(rdev, context, &error) == FALSE) {
|
||||||
@ -511,61 +478,10 @@ static void fprint_device_release(FprintDevice *rdev,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unload any loaded prints */
|
|
||||||
if (elem) {
|
|
||||||
do
|
|
||||||
g_slice_free(struct loaded_print, elem->data);
|
|
||||||
while ((elem = g_slist_next(elem)) != NULL);
|
|
||||||
g_slist_free(session->loaded_prints);
|
|
||||||
}
|
|
||||||
|
|
||||||
session->context_release_device = context;
|
session->context_release_device = context;
|
||||||
fp_async_dev_close(priv->dev, dev_close_cb, rdev);
|
fp_async_dev_close(priv->dev, dev_close_cb, rdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fprint_device_unload_print_data(FprintDevice *rdev,
|
|
||||||
guint32 print_id, DBusGMethodInvocation *context)
|
|
||||||
{
|
|
||||||
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
|
||||||
struct session_data *session = priv->session;
|
|
||||||
GSList *elem = session->loaded_prints;
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
if (_fprint_device_check_claimed(rdev, context, &error) == FALSE) {
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_fprint_device_check_polkit_for_action (rdev, context, "net.reactivated.fprint.device.verify", &error) == FALSE) {
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_message("unload print data %d for device %d", print_id, priv->id);
|
|
||||||
if (!elem) {
|
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_SUCH_LOADED_PRINT,
|
|
||||||
"No such loaded print %d", print_id);
|
|
||||||
dbus_g_method_return_error(context, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
|
||||||
struct loaded_print *print = elem->data;
|
|
||||||
if (print->id != print_id)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
session->loaded_prints = g_slist_delete_link(session->loaded_prints,
|
|
||||||
elem);
|
|
||||||
g_slice_free(struct loaded_print, print);
|
|
||||||
dbus_g_method_return(context);
|
|
||||||
return;
|
|
||||||
} while ((elem = g_slist_next(elem)) != NULL);
|
|
||||||
|
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_SUCH_LOADED_PRINT,
|
|
||||||
"No such loaded print %d", print_id);
|
|
||||||
dbus_g_method_return_error(context, error);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void verify_cb(struct fp_dev *dev, int r, struct fp_img *img,
|
static void verify_cb(struct fp_dev *dev, int r, struct fp_img *img,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
{
|
{
|
||||||
@ -577,11 +493,9 @@ static void verify_cb(struct fp_dev *dev, int r, struct fp_img *img,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void fprint_device_verify_start(FprintDevice *rdev,
|
static void fprint_device_verify_start(FprintDevice *rdev,
|
||||||
guint32 print_id, DBusGMethodInvocation *context)
|
guint32 finger_num, DBusGMethodInvocation *context)
|
||||||
{
|
{
|
||||||
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
||||||
struct session_data *session = priv->session;
|
|
||||||
GSList *elem = session->loaded_prints;
|
|
||||||
struct fp_print_data *data = NULL;
|
struct fp_print_data *data = NULL;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
int r;
|
int r;
|
||||||
@ -596,32 +510,22 @@ static void fprint_device_verify_start(FprintDevice *rdev,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_message("start verification device %d print %d", priv->id, print_id);
|
g_message("start verification device %d finger %d", priv->id, finger_num);
|
||||||
if (!elem) {
|
|
||||||
|
r = storages[priv->storage_type].print_data_load(priv->dev, (enum fp_finger)finger_num,
|
||||||
|
&data, priv->username);
|
||||||
|
|
||||||
|
if (r < 0 || !data) {
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_SUCH_LOADED_PRINT,
|
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_SUCH_LOADED_PRINT,
|
||||||
"No such loaded print %d", print_id);
|
"No such print %d", finger_num);
|
||||||
dbus_g_method_return_error(context, error);
|
dbus_g_method_return_error(context, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
/* FIXME fp_async_verify_start should copy the fp_print_data */
|
||||||
struct loaded_print *print = elem->data;
|
|
||||||
if (print->id == print_id) {
|
|
||||||
data = print->data;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} while ((elem = g_slist_next(elem)) != NULL);
|
|
||||||
|
|
||||||
if (!data) {
|
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_SUCH_LOADED_PRINT,
|
|
||||||
"No such loaded print %d", print_id);
|
|
||||||
dbus_g_method_return_error(context, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* FIXME check freeing/copying of 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) {
|
||||||
|
fp_print_data_free (data);
|
||||||
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);
|
||||||
@ -796,44 +700,3 @@ static void fprint_device_list_enrolled_fingers(FprintDevice *rdev,
|
|||||||
dbus_g_method_return(context, ret);
|
dbus_g_method_return(context, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fprint_device_load_print_data(FprintDevice *rdev,
|
|
||||||
guint32 finger_num, DBusGMethodInvocation *context)
|
|
||||||
{
|
|
||||||
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
|
|
||||||
struct session_data *session = priv->session;
|
|
||||||
struct loaded_print *lprint;
|
|
||||||
struct fp_print_data *data;
|
|
||||||
GError *error = NULL;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (_fprint_device_check_claimed(rdev, context, &error) == FALSE) {
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_fprint_device_check_polkit_for_action (rdev, context, "net.reactivated.fprint.device.verify", &error) == FALSE) {
|
|
||||||
dbus_g_method_return_error (context, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = storages[priv->storage_type].print_data_load(priv->dev, (enum fp_finger)finger_num,
|
|
||||||
&data, priv->username);
|
|
||||||
|
|
||||||
if (r < 0) {
|
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_PRINT_LOAD,
|
|
||||||
"Print load failed with error %d", r);
|
|
||||||
dbus_g_method_return_error(context, error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
lprint = g_slice_new(struct loaded_print);
|
|
||||||
lprint->data = data;
|
|
||||||
lprint->id = ++last_id;
|
|
||||||
session->loaded_prints = g_slist_prepend(session->loaded_prints, lprint);
|
|
||||||
|
|
||||||
g_message("load print data finger %d for device %d = %d",
|
|
||||||
finger_num, priv->id, lprint->id);
|
|
||||||
|
|
||||||
dbus_g_method_return(context, lprint->id);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@ -17,18 +17,6 @@
|
|||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
||||||
</method>
|
</method>
|
||||||
|
|
||||||
<!-- FIXME make OO -->
|
|
||||||
<method name="LoadPrintData">
|
|
||||||
<arg type="u" name="finger_num" direction="in" />
|
|
||||||
<arg type="u" name="print_id" direction="out" />
|
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="UnloadPrintData">
|
|
||||||
<arg type="u" name="print_id" direction="in" />
|
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
|
||||||
</method>
|
|
||||||
|
|
||||||
<method name="VerifyStart">
|
<method name="VerifyStart">
|
||||||
<arg type="u" name="print_id" direction="in" />
|
<arg type="u" name="print_id" direction="in" />
|
||||||
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
|
||||||
|
|||||||
@ -152,7 +152,6 @@ static guint32 find_finger(DBusGProxy *dev)
|
|||||||
GArray *fingers;
|
GArray *fingers;
|
||||||
guint i;
|
guint i;
|
||||||
int fingernum;
|
int fingernum;
|
||||||
guint32 print_id;
|
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_list_enrolled_fingers(dev, &fingers, &error))
|
if (!net_reactivated_Fprint_Device_list_enrolled_fingers(dev, &fingers, &error))
|
||||||
g_error("ListEnrolledFingers failed: %s", error->message);
|
g_error("ListEnrolledFingers failed: %s", error->message);
|
||||||
@ -172,10 +171,8 @@ static guint32 find_finger(DBusGProxy *dev)
|
|||||||
g_array_free(fingers, TRUE);
|
g_array_free(fingers, TRUE);
|
||||||
|
|
||||||
g_print("Verifying: %s\n", fingerstr(fingernum));
|
g_print("Verifying: %s\n", fingerstr(fingernum));
|
||||||
if (!net_reactivated_Fprint_Device_load_print_data(dev, fingernum, &print_id, &error))
|
|
||||||
g_error("LoadPrintData failed: %s", error->message);
|
|
||||||
|
|
||||||
return print_id;
|
return fingernum;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify_result(GObject *object, int result, void *user_data)
|
static void verify_result(GObject *object, int result, void *user_data)
|
||||||
@ -186,7 +183,7 @@ static void verify_result(GObject *object, int result, void *user_data)
|
|||||||
*verify_completed = TRUE;
|
*verify_completed = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_verify(DBusGProxy *dev, guint32 print_id)
|
static void do_verify(DBusGProxy *dev, guint32 finger_num)
|
||||||
{
|
{
|
||||||
GError *error;
|
GError *error;
|
||||||
gboolean verify_completed = FALSE;
|
gboolean verify_completed = FALSE;
|
||||||
@ -195,7 +192,7 @@ static void do_verify(DBusGProxy *dev, guint32 print_id)
|
|||||||
dbus_g_proxy_connect_signal(dev, "VerifyStatus", G_CALLBACK(verify_result),
|
dbus_g_proxy_connect_signal(dev, "VerifyStatus", G_CALLBACK(verify_result),
|
||||||
&verify_completed, NULL);
|
&verify_completed, NULL);
|
||||||
|
|
||||||
if (!net_reactivated_Fprint_Device_verify_start(dev, print_id, &error))
|
if (!net_reactivated_Fprint_Device_verify_start(dev, finger_num, &error))
|
||||||
g_error("VerifyStart failed: %s", error->message);
|
g_error("VerifyStart failed: %s", error->message);
|
||||||
|
|
||||||
while (!verify_completed)
|
while (!verify_completed)
|
||||||
@ -207,13 +204,6 @@ static void do_verify(DBusGProxy *dev, guint32 print_id)
|
|||||||
g_error("VerifyStop failed: %s", error->message);
|
g_error("VerifyStop failed: %s", error->message);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void unload_print(DBusGProxy *dev, guint32 print_id)
|
|
||||||
{
|
|
||||||
GError *error = NULL;
|
|
||||||
if (!net_reactivated_Fprint_Device_unload_print_data(dev, print_id, &error))
|
|
||||||
g_error("UnloadPrint failed: %s", error->message);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_device(DBusGProxy *dev)
|
static void release_device(DBusGProxy *dev)
|
||||||
{
|
{
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
@ -225,16 +215,15 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
GMainLoop *loop;
|
GMainLoop *loop;
|
||||||
DBusGProxy *dev;
|
DBusGProxy *dev;
|
||||||
guint32 print_id;
|
guint32 finger_num;
|
||||||
|
|
||||||
g_type_init();
|
g_type_init();
|
||||||
loop = g_main_loop_new(NULL, FALSE);
|
loop = g_main_loop_new(NULL, FALSE);
|
||||||
create_manager();
|
create_manager();
|
||||||
|
|
||||||
dev = open_device();
|
dev = open_device();
|
||||||
print_id = find_finger(dev);
|
finger_num = find_finger(dev);
|
||||||
do_verify(dev, print_id);
|
do_verify(dev, finger_num);
|
||||||
unload_print(dev, print_id);
|
|
||||||
release_device(dev);
|
release_device(dev);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user