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:
Bastien Nocera
2008-10-29 14:36:43 +00:00
committed by Daniel Drake
parent f7ae545dc9
commit bb1210981b
3 changed files with 16 additions and 176 deletions

View File

@ -41,8 +41,6 @@ static void fprint_device_claim(FprintDevice *rdev,
DBusGMethodInvocation *context);
static void fprint_device_release(FprintDevice *rdev,
DBusGMethodInvocation *context);
static void fprint_device_unload_print_data(FprintDevice *rdev,
guint32 print_id, DBusGMethodInvocation *context);
static void fprint_device_verify_start(FprintDevice *rdev,
guint32 print_id, DBusGMethodInvocation *context);
static void fprint_device_verify_stop(FprintDevice *rdev,
@ -55,8 +53,6 @@ static gboolean fprint_device_set_storage_type(FprintDevice *rdev,
gint type);
static void fprint_device_list_enrolled_fingers(FprintDevice *rdev,
DBusGMethodInvocation *context);
static void fprint_device_load_print_data(FprintDevice *rdev,
guint32 finger_num, DBusGMethodInvocation *context);
#include "device-dbus-glue.h"
@ -69,10 +65,6 @@ struct session_data {
/* method invocation for async ReleaseDevice() */
DBusGMethodInvocation *context_release_device;
/* a list of loaded prints */
GSList *loaded_prints;
};
struct loaded_print {
@ -327,8 +319,6 @@ fprint_device_set_username (FprintDevice *rdev,
{
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
GError *error = NULL;
struct session_data *session = priv->session;
GSList *elem = session->loaded_prints;
if (_fprint_device_check_claimed(rdev, context, &error) == FALSE) {
dbus_g_method_return_error (context, error);
@ -345,31 +335,9 @@ fprint_device_set_username (FprintDevice *rdev,
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);
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);
}
@ -494,7 +462,6 @@ static void fprint_device_release(FprintDevice *rdev,
{
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) {
@ -511,61 +478,10 @@ static void fprint_device_release(FprintDevice *rdev,
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;
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,
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,
guint32 print_id, DBusGMethodInvocation *context)
guint32 finger_num, DBusGMethodInvocation *context)
{
FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev);
struct session_data *session = priv->session;
GSList *elem = session->loaded_prints;
struct fp_print_data *data = NULL;
GError *error = NULL;
int r;
@ -596,32 +510,22 @@ static void fprint_device_verify_start(FprintDevice *rdev,
return;
}
g_message("start verification device %d print %d", priv->id, print_id);
if (!elem) {
g_message("start verification device %d finger %d", priv->id, finger_num);
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,
"No such loaded print %d", print_id);
"No such print %d", finger_num);
dbus_g_method_return_error(context, error);
return;
}
do {
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 */
/* FIXME fp_async_verify_start should copy the fp_print_data */
r = fp_async_verify_start(priv->dev, data, verify_cb, rdev);
if (r < 0) {
fp_print_data_free (data);
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_VERIFY_START,
"Verify start failed with error %d", r);
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);
}
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);
}

View File

@ -17,18 +17,6 @@
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />
</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">
<arg type="u" name="print_id" direction="in" />
<annotation name="org.freedesktop.DBus.GLib.Async" value="" />

View File

@ -152,7 +152,6 @@ static guint32 find_finger(DBusGProxy *dev)
GArray *fingers;
guint i;
int fingernum;
guint32 print_id;
if (!net_reactivated_Fprint_Device_list_enrolled_fingers(dev, &fingers, &error))
g_error("ListEnrolledFingers failed: %s", error->message);
@ -172,10 +171,8 @@ static guint32 find_finger(DBusGProxy *dev)
g_array_free(fingers, TRUE);
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)
@ -186,7 +183,7 @@ static void verify_result(GObject *object, int result, void *user_data)
*verify_completed = TRUE;
}
static void do_verify(DBusGProxy *dev, guint32 print_id)
static void do_verify(DBusGProxy *dev, guint32 finger_num)
{
GError *error;
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),
&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);
while (!verify_completed)
@ -207,13 +204,6 @@ static void do_verify(DBusGProxy *dev, guint32 print_id)
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)
{
GError *error = NULL;
@ -225,16 +215,15 @@ int main(int argc, char **argv)
{
GMainLoop *loop;
DBusGProxy *dev;
guint32 print_id;
guint32 finger_num;
g_type_init();
loop = g_main_loop_new(NULL, FALSE);
create_manager();
dev = open_device();
print_id = find_finger(dev);
do_verify(dev, print_id);
unload_print(dev, print_id);
finger_num = find_finger(dev);
do_verify(dev, finger_num);
release_device(dev);
return 0;
}