mafpmoc: Ignore prints not enrolled by FPrint when listing them

This commit is contained in:
Marco Trevisan (Treviño) 2025-02-20 14:06:45 +01:00
parent b25cbff9be
commit 893003799d

View file

@ -492,7 +492,7 @@ mafp_template_from_print (FpPrint *print)
}
static FpPrint *
mafp_print_from_template (FpiDeviceMafpmoc *self, mafp_template_t template)
mafp_print_from_template (FpiDeviceMafpmoc *self, mafp_template_t *template)
{
FpPrint *print;
GVariant *data;
@ -503,22 +503,22 @@ mafp_print_from_template (FpiDeviceMafpmoc *self, mafp_template_t template)
print = fp_print_new (FP_DEVICE (self));
user_id_len = strlen (template.uid);
user_id_len = strlen (template->uid);
user_id_len = MIN (TEMPLATE_UID_SIZE, user_id_len);
uid = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, template.uid, user_id_len, 1);
uid = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, template->uid, user_id_len, 1);
serial_num_len = strlen (self->serial_number);
dev_sn = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, self->serial_number, serial_num_len, 1);
fp_dbg ("print: %d/%s/%s", template.id, template.uid, self->serial_number);
fp_dbg ("print: %d/%s/%s", template->id, template->uid, self->serial_number);
data = g_variant_new ("(q@ay@ay)", template.id, uid, dev_sn);
data = g_variant_new ("(q@ay@ay)", template->id, uid, dev_sn);
fpi_print_set_type (print, FPI_PRINT_RAW);
fpi_print_set_device_stored (print, true);
g_object_set (print, "description", template.uid, NULL);
g_object_set (print, "description", template->uid, NULL);
g_object_set (print, "fpi-data", data, NULL);
fpi_print_fill_from_user_id (print, template.uid);
fpi_print_fill_from_user_id (print, template->uid);
return print;
}
@ -844,8 +844,6 @@ fp_enroll_get_tpl_info_cb (FpiDeviceMafpmoc *self,
GError *error)
{
FpDevice *dev = FP_DEVICE (self);
mafp_template_t tpl;
FpPrint *print;
if (error)
{
@ -858,9 +856,13 @@ fp_enroll_get_tpl_info_cb (FpiDeviceMafpmoc *self,
{
if (resp->tpl_info.uid[0] == 'F' && resp->tpl_info.uid[1] == 'P')
{
g_autoptr(FpPrint) print = NULL;
mafp_template_t tpl;
tpl.id = self->search_id;
memcpy (tpl.uid, resp->tpl_info.uid, sizeof (resp->tpl_info.uid));
print = mafp_print_from_template (self, tpl);
print = mafp_print_from_template (self, &tpl);
mafp_mark_failed (dev, self->task_ssm, FP_DEVICE_ERROR_DATA_DUPLICATE,
"Finger was already enrolled as '%s'",
fp_print_get_description (print));
@ -1499,7 +1501,6 @@ fp_verify_get_tpl_info_cb (FpiDeviceMafpmoc *self,
FpDevice *dev = FP_DEVICE (self);
FpPrint *new_scan = NULL;
FpPrint *matching = NULL;
mafp_template_t tpl;
if (error)
{
@ -1523,9 +1524,11 @@ fp_verify_get_tpl_info_cb (FpiDeviceMafpmoc *self,
{
if (resp->tpl_info.uid[0] == 'F' && resp->tpl_info.uid[1] == 'P')
{
mafp_template_t tpl;
tpl.id = self->search_id;
memcpy (tpl.uid, resp->tpl_info.uid, sizeof (resp->tpl_info.uid));
new_scan = mafp_print_from_template (self, tpl);
new_scan = mafp_print_from_template (self, &tpl);
}
if (new_scan != NULL)
{
@ -1929,13 +1932,17 @@ fp_list_get_tpl_info_cb (FpiDeviceMafpmoc *self,
if (resp->result == MAFP_SUCCESS)
{
memcpy (self->templates->total_list[self->templates->index].uid,
resp->tpl_info.uid, sizeof (resp->tpl_info.uid));
fp_dbg ("tpl_info: %s", resp->tpl_info.uid);
FpPrint *print = mafp_print_from_template (self,
self->templates->total_list[self->templates->index]);
if (resp->tpl_info.uid[0] == 'F' && resp->tpl_info.uid[1] == 'P')
{
FpPrint *print;
mafp_template_t *template = &self->templates->total_list[self->templates->index];
g_ptr_array_add (self->templates->list, g_object_ref_sink (print));
memcpy (template->uid, resp->tpl_info.uid, sizeof (resp->tpl_info.uid));
print = mafp_print_from_template (self, template);
g_ptr_array_add (self->templates->list, g_object_ref_sink (print));
}
}
if (++self->templates->index < self->templates->total_num)
{
@ -2003,6 +2010,7 @@ fp_delete_tpl_table_cb (FpiDeviceMafpmoc *self,
mafp_load_enrolled_ids (self, resp);
fpi_device_get_delete_data (dev, &print);
mafp_template_t tpl = mafp_template_from_print (print);
for (int i = 0; i < self->templates->total_num; i++)
{
if (self->templates->total_list[i].id == tpl.id)