diff --git a/TODO b/TODO index ac4a5b3..05a482b 100644 --- a/TODO +++ b/TODO @@ -10,9 +10,6 @@ Enforce command sequences: only allow VerifyStop during a verification etc -Add Device Properties: -- device name - Rethink enums and results passed, should be strings and D-Bus errors Verify PAM messages fit with GDM/gnome-screensaver diff --git a/pam/pam_fprintd.c b/pam/pam_fprintd.c index c77d8fc..4cb30c6 100644 --- a/pam/pam_fprintd.c +++ b/pam/pam_fprintd.c @@ -236,6 +236,8 @@ typedef struct { gboolean timed_out; pam_handle_t *pamh; GMainLoop *loop; + + char *driver; } verify_data; static void verify_result(GObject *object, int result, gpointer user_data) @@ -255,13 +257,11 @@ static void verify_finger_selected(GObject *object, int finger, gpointer user_da { verify_data *data = user_data; char *msg; - //FIXME - const char *driver_name = "Fingerprint reader"; if (finger == -1) { - msg = g_strdup_printf ("Scan finger on %s", driver_name); + msg = g_strdup_printf ("Scan finger on %s", data->driver); } else { - msg = g_strdup_printf ("Scan %s finger on %s", fingerstr(finger), driver_name); + msg = g_strdup_printf ("Scan %s finger on %s", fingerstr(finger), data->driver); } D(g_message ("verify_finger_selected %s", msg)); send_info_msg (data->pamh, msg); @@ -285,6 +285,7 @@ static gboolean verify_timeout_cb (gpointer user_data) static int do_verify(DBusGConnection *connection, GMainLoop *loop, pam_handle_t *pamh, DBusGProxy *dev) { GError *error; + GHashTable *props; verify_data *data; int ret; @@ -293,6 +294,14 @@ static int do_verify(DBusGConnection *connection, GMainLoop *loop, pam_handle_t data->pamh = pamh; data->loop = loop; + if (dbus_g_proxy_call (dev, "GetProperties", &error, G_TYPE_INVALID, + dbus_g_type_get_map ("GHashTable", G_TYPE_STRING, G_TYPE_STRING), &props, G_TYPE_INVALID)) { + data->driver = g_strdup (g_hash_table_lookup (props, "Name")); + g_hash_table_destroy (props); + } + if (!data->driver) + data->driver = g_strdup ("Fingerprint reader"); + dbus_g_proxy_add_signal(dev, "VerifyStatus", G_TYPE_INT, NULL); dbus_g_proxy_add_signal(dev, "VerifyFingerSelected", G_TYPE_INT, NULL); dbus_g_proxy_connect_signal(dev, "VerifyStatus", G_CALLBACK(verify_result), @@ -355,6 +364,7 @@ static int do_verify(DBusGConnection *connection, GMainLoop *loop, pam_handle_t dbus_g_proxy_disconnect_signal(dev, "VerifyStatus", G_CALLBACK(verify_result), data); dbus_g_proxy_disconnect_signal(dev, "VerifyFingerSelected", G_CALLBACK(verify_finger_selected), data); + g_free (data->driver); g_free (data); return ret; diff --git a/src/device.c b/src/device.c index 032a7e7..65a4630 100644 --- a/src/device.c +++ b/src/device.c @@ -54,6 +54,9 @@ static void fprint_device_list_enrolled_fingers(FprintDevice *rdev, static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev, const char *username, DBusGMethodInvocation *context); +static void fprint_device_get_properties (FprintDevice *rdev, + GHashTable **props, + DBusGMethodInvocation *context); #include "device-dbus-glue.h" @@ -1034,3 +1037,22 @@ static void fprint_device_delete_enrolled_fingers(FprintDevice *rdev, dbus_g_method_return(context); } +static void +fprint_device_get_properties (FprintDevice *rdev, + GHashTable **props, + DBusGMethodInvocation *context) +{ + FprintDevicePrivate *priv = DEVICE_GET_PRIVATE(rdev); + GHashTable *table; + struct fp_driver *driver; + const char *driver_name; + + table = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, g_free); + + driver = fp_dscv_dev_get_driver (priv->ddev); + driver_name = fp_driver_get_full_name (driver); + g_hash_table_insert (table, "Name", g_strdup (driver_name)); + + *props = table; +} + diff --git a/src/device.xml b/src/device.xml index acc14fa..31decd9 100644 --- a/src/device.xml +++ b/src/device.xml @@ -54,6 +54,10 @@ + + + + diff --git a/tests/list.c b/tests/list.c index b916b4f..e49e137 100644 --- a/tests/list.c +++ b/tests/list.c @@ -119,6 +119,7 @@ static void list_fingerprints(DBusGProxy *dev, const char *username) { GError *error = NULL; GArray *fingers; + GHashTable *props; guint i; int fingernum; @@ -130,7 +131,10 @@ static void list_fingerprints(DBusGProxy *dev, const char *username) return; } - g_print("Fingerprints for user %s:\n", username); + if (!net_reactivated_Fprint_Device_get_properties(dev, &props, &error)) + g_error("GetProperties failed: %s", error->message); + + g_print("Fingerprints for user %s on %s:\n", username, (char *) g_hash_table_lookup (props, "Name")); for (i = 0; i < fingers->len; i++) { fingernum = g_array_index(fingers, guint32, i); g_print(" - #%d: %s\n", fingernum, fingerstr(fingernum)); @@ -138,6 +142,7 @@ static void list_fingerprints(DBusGProxy *dev, const char *username) fingernum = g_array_index(fingers, guint32, 0); g_array_free(fingers, TRUE); + g_hash_table_destroy (props); } int main(int argc, char **argv)