mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
lib: Major rewrite of the libfprint core and API
This is a rewrite of the core based on GObject and Gio. This commit breaks the build in a lot of ways, but basic functionality will start working again with the next commits.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
* Copyright (C) 2009 Red Hat <mjg@redhat.com>
|
||||
* Copyright (C) 2008 Bastien Nocera <hadess@hadess.net>
|
||||
* Copyright (C) 2008 Timo Hoenig <thoenig@suse.de>, <thoenig@nouse.net>
|
||||
* Coypright (C) 2019 Benjamin Berg <bberg@redhat.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
@@ -19,54 +20,55 @@
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "fp_internal.h"
|
||||
#include "fpi-context.h"
|
||||
#include "fpi-device.h"
|
||||
|
||||
static const struct usb_id whitelist_id_table[] = {
|
||||
static const FpIdEntry whitelist_id_table[] = {
|
||||
/* Unsupported (for now) Validity Sensors finger print readers */
|
||||
{ .vendor = 0x138a, .product = 0x0090 }, /* Found on e.g. Lenovo T460s */
|
||||
{ .vendor = 0x138a, .product = 0x0091 },
|
||||
{ .vendor = 0x138a, .product = 0x0094 },
|
||||
{ .vendor = 0x138a, .product = 0x0097 }, /* Found on e.g. Lenovo T470s */
|
||||
{ 0, 0, 0, },
|
||||
{ .vid = 0x138a, .pid = 0x0090 }, /* Found on e.g. Lenovo T460s */
|
||||
{ .vid = 0x138a, .pid = 0x0091 },
|
||||
{ .vid = 0x138a, .pid = 0x0094 },
|
||||
{ .vid = 0x138a, .pid = 0x0097 }, /* Found on e.g. Lenovo T470s */
|
||||
{ .vid = 0 },
|
||||
};
|
||||
|
||||
static const struct usb_id blacklist_id_table[] = {
|
||||
{ .vendor = 0x0483, .product = 0x2016 },
|
||||
static const FpIdEntry blacklist_id_table[] = {
|
||||
{ .vid = 0x0483, .pid = 0x2016 },
|
||||
/* https://bugs.freedesktop.org/show_bug.cgi?id=66659 */
|
||||
{ .vendor = 0x045e, .product = 0x00bb },
|
||||
{ 0, 0, 0 },
|
||||
{ .vid = 0x045e, .pid = 0x00bb },
|
||||
{ .vid = 0 },
|
||||
};
|
||||
|
||||
struct fp_driver whitelist = {
|
||||
static const FpDeviceClass whitelist = {
|
||||
.type = FP_DEVICE_TYPE_USB,
|
||||
.id_table = whitelist_id_table,
|
||||
.full_name = "Hardcoded whitelist"
|
||||
};
|
||||
|
||||
GHashTable *printed = NULL;
|
||||
|
||||
static void print_driver (struct fp_driver *driver)
|
||||
static void print_driver (const FpDeviceClass *cls)
|
||||
{
|
||||
int i, j, blacklist, num_printed;
|
||||
const FpIdEntry *entry;
|
||||
gint num_printed = 0;
|
||||
|
||||
num_printed = 0;
|
||||
if (cls->type != FP_DEVICE_TYPE_USB)
|
||||
return;
|
||||
|
||||
for (i = 0; driver->id_table[i].vendor != 0; i++) {
|
||||
for (entry = cls->id_table; entry->vid != 0; entry++) {
|
||||
const FpIdEntry *bl_entry;
|
||||
char *key;
|
||||
|
||||
blacklist = 0;
|
||||
for (j = 0; blacklist_id_table[j].vendor != 0; j++) {
|
||||
if (driver->id_table[i].vendor == blacklist_id_table[j].vendor &&
|
||||
driver->id_table[i].product == blacklist_id_table[j].product) {
|
||||
blacklist = 1;
|
||||
for (bl_entry = blacklist_id_table; bl_entry->vid != 0; bl_entry++) {
|
||||
if (entry->vid == bl_entry->vid && entry->pid == bl_entry->pid) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (blacklist)
|
||||
if (bl_entry->vid != 0)
|
||||
continue;
|
||||
|
||||
key = g_strdup_printf ("%04x:%04x", driver->id_table[i].vendor, driver->id_table[i].product);
|
||||
key = g_strdup_printf ("%04x:%04x", entry->vid, entry->pid);
|
||||
|
||||
if (g_hash_table_lookup (printed, key) != NULL) {
|
||||
g_free (key);
|
||||
@@ -76,28 +78,42 @@ static void print_driver (struct fp_driver *driver)
|
||||
g_hash_table_insert (printed, key, GINT_TO_POINTER (1));
|
||||
|
||||
if (num_printed == 0)
|
||||
printf ("# %s\n", driver->full_name);
|
||||
g_print ("# %s\n", cls->full_name);
|
||||
|
||||
printf ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ATTRS{dev}==\"*\", TEST==\"power/control\", ATTR{power/control}=\"auto\"\n", driver->id_table[i].vendor, driver->id_table[i].product);
|
||||
printf ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ENV{LIBFPRINT_DRIVER}=\"%s\"\n", driver->id_table[i].vendor, driver->id_table[i].product, driver->full_name);
|
||||
g_print ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ATTRS{dev}==\"*\", TEST==\"power/control\", ATTR{power/control}=\"auto\"\n",
|
||||
entry->vid, entry->pid);
|
||||
g_print ("SUBSYSTEM==\"usb\", ATTRS{idVendor}==\"%04x\", ATTRS{idProduct}==\"%04x\", ENV{LIBFPRINT_DRIVER}=\"%s\"\n",
|
||||
entry->vid, entry->pid, cls->full_name);
|
||||
num_printed++;
|
||||
}
|
||||
|
||||
if (num_printed > 0)
|
||||
printf ("\n");
|
||||
g_print ("\n");
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
struct fp_driver **list;
|
||||
g_autoptr(GArray) drivers = g_array_new (FALSE, FALSE, sizeof(GType));
|
||||
guint i;
|
||||
|
||||
list = fprint_get_drivers ();
|
||||
g_print ("%p\n", drivers);
|
||||
g_print ("%p\n", fpi_get_driver_types);
|
||||
fpi_get_driver_types (drivers);
|
||||
|
||||
printed = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
|
||||
|
||||
for (i = 0; list[i] != NULL; i++) {
|
||||
print_driver (list[i]);
|
||||
for (i = 0; i < drivers->len; i++) {
|
||||
GType driver = g_array_index (drivers, GType, i);
|
||||
FpDeviceClass *cls = FP_DEVICE_CLASS (g_type_class_ref (driver));
|
||||
|
||||
if (cls->type != FP_DEVICE_TYPE_USB) {
|
||||
g_type_class_unref (cls);
|
||||
continue;
|
||||
}
|
||||
|
||||
print_driver (cls);
|
||||
|
||||
g_type_class_unref (cls);
|
||||
}
|
||||
|
||||
print_driver (&whitelist);
|
||||
|
||||
Reference in New Issue
Block a user