From f71045b7431140f2ab069388e438fd3410711ea5 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Mon, 20 Apr 2020 16:39:56 +0200 Subject: [PATCH] synaptics: Use the FpPrint ID generation functionality As the functionality is now part of the internal FpPrint API, it makes sene to use it. --- libfprint/drivers/synaptics/synaptics.c | 69 +------------------------ 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/libfprint/drivers/synaptics/synaptics.c b/libfprint/drivers/synaptics/synaptics.c index 9007d22..25ae162 100644 --- a/libfprint/drivers/synaptics/synaptics.c +++ b/libfprint/drivers/synaptics/synaptics.c @@ -515,39 +515,7 @@ list_msg_cb (FpiDeviceSynaptics *self, g_object_set (print, "fpi-data", data, NULL); g_object_set (print, "description", get_enroll_templates_resp->templates[n].user_id, NULL); - /* The format has 24 bytes at the start and some dashes in the right places */ - if (g_str_has_prefix (userid, "FP1-") && strlen (userid) >= 24 && - userid[12] == '-' && userid[14] == '-' && userid[23] == '-') - { - g_autofree gchar *copy = g_strdup (userid); - g_autoptr(GDate) date = NULL; - gint32 date_ymd; - gint32 finger; - gchar *username; - /* Try to parse information from the string. */ - - copy[12] = '\0'; - date_ymd = g_ascii_strtod (copy + 4, NULL); - if (date_ymd > 0) - date = g_date_new_dmy (date_ymd % 100, - (date_ymd / 100) % 100, - date_ymd / 10000); - else - date = g_date_new (); - - fp_print_set_enroll_date (print, date); - - copy[14] = '\0'; - finger = g_ascii_strtoll (copy + 13, NULL, 16); - fp_print_set_finger (print, finger); - - /* We ignore the next chunk, it is just random data. - * Then comes the username; nobody is the default if the metadata - * is unknown */ - username = copy + 24; - if (strlen (username) > 0 && g_strcmp0 (username, "nobody") != 0) - fp_print_set_username (print, username); - } + fpi_print_fill_from_user_id (print, userid); g_ptr_array_add (self->list_result, g_object_ref_sink (print)); } @@ -795,8 +763,6 @@ enroll_msg_cb (FpiDeviceSynaptics *self, } } -#define TEMPLATE_ID_SIZE 20 - static void enroll (FpDevice *device) { @@ -804,47 +770,16 @@ enroll (FpDevice *device) FpPrint *print = NULL; GVariant *data = NULL; GVariant *uid = NULL; - const gchar *username; guint finger; g_autofree gchar *user_id = NULL; gssize user_id_len; g_autofree guint8 *payload = NULL; - const GDate *date; - gint y, m, d; - gint32 rand_id = 0; fpi_device_get_enroll_data (device, &print); G_DEBUG_HERE (); - date = fp_print_get_enroll_date (print); - if (date && g_date_valid (date)) - { - y = g_date_get_year (date); - m = g_date_get_month (date); - d = g_date_get_day (date); - } - else - { - y = 0; - m = 0; - d = 0; - } - - username = fp_print_get_username (print); - if (!username) - username = "nobody"; - - if (g_strcmp0 (g_getenv ("FP_DEVICE_EMULATION"), "1") == 0) - rand_id = 0; - else - rand_id = g_random_int (); - - user_id = g_strdup_printf ("FP1-%04d%02d%02d-%X-%08X-%s", - y, m, d, - fp_print_get_finger (print), - rand_id, - username); + user_id = fpi_print_generate_user_id (print); user_id_len = strlen (user_id); user_id_len = MIN (BMKT_MAX_USER_ID_LEN, user_id_len);