Compare commits

..

1 Commits

Author SHA1 Message Date
Benjamin Berg
e1fdc7b01b uru4000: Fix control transfer request type
During porting the request type was accidentally changed from VENDOR to
DEVICE. Change the type back to VENDOR.

Fixes: #205
2019-12-04 13:11:32 +01:00
39 changed files with 228 additions and 510 deletions

View File

@@ -1,46 +1,40 @@
variables: image: fedora:rawhide
FEDORA_TAG: rawhide
FEDORA_VERSION: rawhide
FEDORA_IMAGE: "$CI_REGISTRY/libfprint/$CI_PROJECT_NAME/fedora/$FEDORA_VERSION:$FEDORA_TAG"
BUNDLE: "org.freedesktop.libfprint.Demo.flatpak"
LAST_ABI_BREAK: "056ea541ddc97f5806cffbd99a12dc87e4da3546"
include:
- project: 'wayland/ci-templates'
ref: master
file: '/templates/fedora.yml'
stages: stages:
- check-source - check-source
- build - build
- test - test
- flatpack - flatpack
image: "$FEDORA_IMAGE" variables:
DEPENDENCIES: libgusb-devel glib2-devel nss-devel pixman-devel systemd meson gtk-doc
gcc gcc-c++ glibc-devel libX11-devel libXv-devel gtk3-devel flatpak-builder
gobject-introspection-devel python3-cairo python3-gobject umockdev
BUNDLE: "org.freedesktop.libfprint.Demo.flatpak"
LAST_ABI_BREAK: "056ea541ddc97f5806cffbd99a12dc87e4da3546"
.build_one_driver_template: &build_one_driver .build_one_driver_template: &build_one_driver
script: script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES
# Build with a driver that doesn't need imaging, or nss # Build with a driver that doesn't need imaging, or nss
- meson --werror -Ddrivers=$driver . _build - meson -Ddrivers=$driver . _build
- ninja -C _build - ninja -C _build
- rm -rf _build/ - rm -rf _build/
.build_template: &build .build_template: &build
script: script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES
# And build with everything # And build with everything
- meson --werror -Ddrivers=all . _build - meson -Ddrivers=all . _build
- ninja -C _build - ninja -C _build
- ninja -C _build install - ninja -C _build install
.build_template: &check_abi .build_template: &check_abi
script: script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES doxygen libabigail git
- ./.ci/check-abi ${LAST_ABI_BREAK} $(git rev-parse HEAD) - ./.ci/check-abi ${LAST_ABI_BREAK} $(git rev-parse HEAD)
build: build:
stage: build stage: build
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
variables: variables:
driver: virtual_image driver: virtual_image
<<: *build_one_driver <<: *build_one_driver
@@ -49,30 +43,24 @@ build:
test: test:
stage: test stage: test
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script: script:
- meson --werror -Ddrivers=all . _build - dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES
- meson -Ddrivers=all . _build
- ninja -C _build - ninja -C _build
- meson test -C _build --verbose --no-stdsplit - meson test -C _build --verbose --no-stdsplit
test_valgrind: test_valgrind:
stage: test stage: test
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script: script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck $DEPENDENCIES valgrind
- meson -Ddrivers=all . _build - meson -Ddrivers=all . _build
- ninja -C _build - ninja -C _build
- meson test -C _build --verbose --no-stdsplit --setup=valgrind - meson test -C _build --verbose --no-stdsplit --setup=valgrind
test_indent: test_indent:
stage: check-source stage: check-source
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
script: script:
- dnf update -y --nogpgcheck && dnf install -y --nogpgcheck git uncrustify
- scripts/uncrustify.sh --check - scripts/uncrustify.sh --check
.flatpak_script_template: &flatpak_script .flatpak_script_template: &flatpak_script
@@ -98,12 +86,9 @@ test_indent:
<<: *flatpak_script <<: *flatpak_script
<<: *flatpak_artifacts <<: *flatpak_artifacts
.flatpak_master_template: &flatpak_master flatpak master:
image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:3.32 image: registry.gitlab.gnome.org/gnome/gnome-runtime-images/gnome:3.32
stage: flatpack stage: flatpack
except:
variables:
- $CI_PIPELINE_SOURCE == "schedule"
variables: variables:
MANIFEST_PATH: "demo/org.freedesktop.libfprint.Demo.json" MANIFEST_PATH: "demo/org.freedesktop.libfprint.Demo.json"
# From demo/org.freedesktop.libfprint.Demo.json # From demo/org.freedesktop.libfprint.Demo.json
@@ -111,51 +96,3 @@ test_indent:
FLATPAK_MODULE: "libfprint" FLATPAK_MODULE: "libfprint"
DBUS_ID: "org.freedesktop.libfprint.Demo" DBUS_ID: "org.freedesktop.libfprint.Demo"
<<: *flatpak <<: *flatpak
flatpak-auto master:
<<: *flatpak_master
when: always
only:
- tags
- master
flatpak-manual master:
<<: *flatpak_master
when: manual
except:
- tags
- master
# CONTAINERS creation stage
container_fedora_build:
extends: .fedora@container-build
only:
variables:
- $CI_PIPELINE_SOURCE == "schedule" && $CRON_TASK == "BUILD_CI_IMAGES"
variables:
GIT_STRATEGY: none # no need to pull the whole tree for rebuilding the image
# a list of packages to install
FEDORA_RPMS:
doxygen
flatpak-builder
gcc
gcc-c++
git
glib2-devel
glibc-devel
gobject-introspection-devel
gtk-doc
gtk3-devel
libabigail
libgusb-devel
libX11-devel
libXv-devel
meson
nss-devel
pixman-devel
python3-cairo
python3-gobject
systemd
umockdev
uncrustify
valgrind

View File

@@ -22,11 +22,9 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <libfprint/fprint.h> #include <libfprint/fprint.h>
struct _LibfprintDemo typedef GtkApplication LibfprintDemo;
{ typedef GtkApplicationClass LibfprintDemoClass;
GtkApplication parent;
};
G_DECLARE_FINAL_TYPE (LibfprintDemo, libfprint_demo, FP, DEMO, GtkApplication)
G_DEFINE_TYPE (LibfprintDemo, libfprint_demo, GTK_TYPE_APPLICATION) G_DEFINE_TYPE (LibfprintDemo, libfprint_demo, GTK_TYPE_APPLICATION)
typedef enum { typedef enum {
@@ -35,7 +33,7 @@ typedef enum {
IMAGE_DISPLAY_BINARY = 1 << 1 IMAGE_DISPLAY_BINARY = 1 << 1
} ImageDisplayFlags; } ImageDisplayFlags;
struct _LibfprintDemoWindow typedef struct
{ {
GtkApplicationWindow parent_instance; GtkApplicationWindow parent_instance;
@@ -54,9 +52,10 @@ struct _LibfprintDemoWindow
FpImage *img; FpImage *img;
ImageDisplayFlags img_flags; ImageDisplayFlags img_flags;
}; } LibfprintDemoWindow;
typedef GtkApplicationWindowClass LibfprintDemoWindowClass;
G_DECLARE_FINAL_TYPE (LibfprintDemoWindow, libfprint_demo_window, FP, DEMO_WINDOW, GtkApplicationWindow)
G_DEFINE_TYPE (LibfprintDemoWindow, libfprint_demo_window, GTK_TYPE_APPLICATION_WINDOW) G_DEFINE_TYPE (LibfprintDemoWindow, libfprint_demo_window, GTK_TYPE_APPLICATION_WINDOW)
typedef enum { typedef enum {

View File

@@ -13,7 +13,10 @@ executable('gtk-libfprint-test',
include_directories: [ include_directories: [
root_inc, root_inc,
], ],
c_args: '-DPACKAGE_VERSION="' + meson.project_version() + '"', c_args: [
common_cflags,
'-DPACKAGE_VERSION="' + meson.project_version() + '"'
],
install: true, install: true,
install_dir: bindir) install_dir: bindir)

View File

@@ -211,7 +211,6 @@ fpi_print_bz3_match
FpiSsmCompletedCallback FpiSsmCompletedCallback
FpiSsmHandlerCallback FpiSsmHandlerCallback
fpi_ssm_new fpi_ssm_new
fpi_ssm_new_full
fpi_ssm_free fpi_ssm_free
fpi_ssm_start fpi_ssm_start
fpi_ssm_start_subsm fpi_ssm_start_subsm

View File

@@ -6,7 +6,8 @@ foreach example: examples
dependencies: [ libfprint_dep, glib_dep ], dependencies: [ libfprint_dep, glib_dep ],
include_directories: [ include_directories: [
root_inc, root_inc,
]) ],
c_args: common_cflags)
endforeach endforeach
executable('cpp-test', executable('cpp-test',
@@ -14,4 +15,5 @@ executable('cpp-test',
dependencies: libfprint_dep, dependencies: libfprint_dep,
include_directories: [ include_directories: [
root_inc, root_inc,
]) ],
c_args: common_cflags)

View File

@@ -20,7 +20,6 @@
*/ */
#include <libfprint/fprint.h> #include <libfprint/fprint.h>
#include "storage.h"
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
@@ -58,7 +57,7 @@ load_data (void)
GVariantDict *res; GVariantDict *res;
GVariant *var; GVariant *var;
g_autofree gchar *contents = NULL; g_autofree gchar *contents = NULL;
gsize length = 0; gssize length = 0;
if (!g_file_get_contents (STORAGE_FILE, &contents, &length, NULL)) if (!g_file_get_contents (STORAGE_FILE, &contents, &length, NULL))
{ {

View File

@@ -686,7 +686,7 @@ enum activate_states {
ACTIVATE_NUM_STATES, ACTIVATE_NUM_STATES,
}; };
static void void
activate_read_regs_cb (FpImageDevice *dev, GError *error, activate_read_regs_cb (FpImageDevice *dev, GError *error,
unsigned char *regs, void *user_data) unsigned char *regs, void *user_data)
{ {

View File

@@ -41,7 +41,7 @@
#include "drivers_api.h" #include "drivers_api.h"
#include "elan.h" #include "elan.h"
static unsigned char unsigned char
elan_get_pixel (struct fpi_frame_asmbl_ctx *ctx, elan_get_pixel (struct fpi_frame_asmbl_ctx *ctx,
struct fpi_frame *frame, unsigned int x, struct fpi_frame *frame, unsigned int x,
unsigned int y) unsigned int y)
@@ -91,7 +91,7 @@ G_DECLARE_FINAL_TYPE (FpiDeviceElan, fpi_device_elan, FPI, DEVICE_ELAN,
FpImageDevice); FpImageDevice);
G_DEFINE_TYPE (FpiDeviceElan, fpi_device_elan, FP_TYPE_IMAGE_DEVICE); G_DEFINE_TYPE (FpiDeviceElan, fpi_device_elan, FP_TYPE_IMAGE_DEVICE);
static int int
cmp_short (const void *a, const void *b) cmp_short (const void *a, const void *b)
{ {
return (int) (*(short *) a - *(short *) b); return (int) (*(short *) a - *(short *) b);
@@ -320,7 +320,6 @@ elan_submit_image (FpImageDevice *dev)
g_slist_foreach (raw_frames, (GFunc) self->process_frame, &frames); g_slist_foreach (raw_frames, (GFunc) self->process_frame, &frames);
fpi_do_movement_estimation (&assembling_ctx, frames); fpi_do_movement_estimation (&assembling_ctx, frames);
img = fpi_assemble_frames (&assembling_ctx, frames); img = fpi_assemble_frames (&assembling_ctx, frames);
g_slist_free_full (frames, g_free);
fpi_image_device_image_captured (dev, img); fpi_image_device_image_captured (dev, img);
} }
@@ -777,6 +776,7 @@ calibrate_complete (FpiSsm *ssm, FpDevice *dev, GError *error)
} }
else else
{ {
self->dev_state = FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON;
elan_capture (dev); elan_capture (dev);
} }
@@ -966,7 +966,6 @@ elan_change_state (FpImageDevice *idev)
{ {
case FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON: case FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON:
/* activation completed or another enroll stage started */ /* activation completed or another enroll stage started */
self->dev_state = FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON;
elan_calibrate (dev); elan_calibrate (dev);
break; break;

View File

@@ -407,7 +407,7 @@ static gboolean
parse_print_data (GVariant *data, parse_print_data (GVariant *data,
guint8 *finger, guint8 *finger,
const guint8 **user_id, const guint8 **user_id,
gsize *user_id_len) gssize *user_id_len)
{ {
g_autoptr(GVariant) user_id_var = NULL; g_autoptr(GVariant) user_id_var = NULL;
@@ -506,7 +506,7 @@ list_msg_cb (FpiDeviceSynaptics *self,
get_enroll_templates_resp->templates[n].user_id, get_enroll_templates_resp->templates[n].user_id,
get_enroll_templates_resp->templates[n].finger_id); get_enroll_templates_resp->templates[n].finger_id);
userid = (gchar *) get_enroll_templates_resp->templates[n].user_id; userid = get_enroll_templates_resp->templates[n].user_id;
print = fp_print_new (FP_DEVICE (self)); print = fp_print_new (FP_DEVICE (self));
uid = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE, uid = g_variant_new_fixed_array (G_VARIANT_TYPE_BYTE,

View File

@@ -375,7 +375,7 @@ read_msg_cb (FpiUsbTransfer *transfer, FpDevice *device,
goto err; goto err;
} }
if (strncmp ((char *) udata->buffer, "Ciao", 4) != 0) if (strncmp (udata->buffer, "Ciao", 4) != 0)
{ {
fp_err ("no Ciao for you!!"); fp_err ("no Ciao for you!!");
error = fpi_device_error_new_msg (FP_DEVICE_ERROR_PROTO, error = fpi_device_error_new_msg (FP_DEVICE_ERROR_PROTO,

View File

@@ -332,8 +332,6 @@ irq_handler (FpiUsbTransfer *transfer,
return; return;
} }
start_irq_handler (imgdev);
type = GUINT16_FROM_BE (*((uint16_t *) data)); type = GUINT16_FROM_BE (*((uint16_t *) data));
fp_dbg ("recv irq type %04x", type); fp_dbg ("recv irq type %04x", type);
@@ -346,6 +344,8 @@ irq_handler (FpiUsbTransfer *transfer,
urudev->irq_cb (imgdev, NULL, type, urudev->irq_cb_data); urudev->irq_cb (imgdev, NULL, type, urudev->irq_cb_data);
else else
fp_dbg ("ignoring interrupt"); fp_dbg ("ignoring interrupt");
start_irq_handler (imgdev);
} }
static void static void

View File

@@ -399,7 +399,7 @@ interrupt_callback (FpiUsbTransfer *transfer, FpDevice *device,
gpointer user_data, GError *error) gpointer user_data, GError *error)
{ {
FpDeviceVfs0050 *self = FPI_DEVICE_VFS0050 (device); FpDeviceVfs0050 *self = FPI_DEVICE_VFS0050 (device);
unsigned char *interrupt = transfer->buffer; char *interrupt = transfer->buffer;
/* we expect a cancellation error when the device is deactivating /* we expect a cancellation error when the device is deactivating
* go into the SSM_CLEAR_EP2 state in that case. */ * go into the SSM_CLEAR_EP2 state in that case. */
@@ -595,8 +595,7 @@ activate_ssm (FpiSsm *ssm, FpDevice *dev)
/* Receive chunk of data */ /* Receive chunk of data */
transfer = fpi_usb_transfer_new (dev); transfer = fpi_usb_transfer_new (dev);
fpi_usb_transfer_fill_bulk_full (transfer, 0x82, fpi_usb_transfer_fill_bulk_full (transfer, 0x82,
(guint8 *) (void *) self->lines_buffer + self->bytes,
(self->lines_buffer + self->bytes),
VFS_USB_BUFFER_SIZE, NULL); VFS_USB_BUFFER_SIZE, NULL);
transfer->ssm = ssm; transfer->ssm = ssm;
fpi_usb_transfer_submit (transfer, VFS_USB_TIMEOUT, NULL, fpi_usb_transfer_submit (transfer, VFS_USB_TIMEOUT, NULL,

View File

@@ -190,13 +190,11 @@ usbexchange_loop (FpiSsm *ssm, FpDevice *_dev)
static void static void
usb_exchange_async (FpiSsm *ssm, usb_exchange_async (FpiSsm *ssm,
struct usbexchange_data *data, struct usbexchange_data *data)
const char *exchange_name)
{ {
FpiSsm *subsm = fpi_ssm_new_full (FP_DEVICE (data->device), FpiSsm *subsm = fpi_ssm_new (FP_DEVICE (data->device),
usbexchange_loop, usbexchange_loop,
data->stepcount, data->stepcount);
exchange_name);
fpi_ssm_set_data (subsm, data, NULL); fpi_ssm_set_data (subsm, data, NULL);
fpi_ssm_start_subsm (ssm, subsm); fpi_ssm_start_subsm (ssm, subsm);
@@ -212,8 +210,8 @@ vfs5011_get_deviation2 (struct fpi_line_asmbl_ctx *ctx, GSList *row1, GSList *ro
int res = 0, mean = 0, i; int res = 0, mean = 0, i;
const int size = 64; const int size = 64;
buf1 = (unsigned char *) row1->data + 56; buf1 = row1->data + 56;
buf2 = (unsigned char *) row2->data + 168; buf2 = row2->data + 168;
for (i = 0; i < size; i++) for (i = 0; i < size; i++)
mean += (int) buf1[i] + (int) buf2[i]; mean += (int) buf1[i] + (int) buf2[i];
@@ -234,7 +232,7 @@ vfs5011_get_pixel (struct fpi_line_asmbl_ctx *ctx,
GSList *row, GSList *row,
unsigned x) unsigned x)
{ {
unsigned char *data = (unsigned char *) row->data + 8; unsigned char *data = row->data + 8;
return data[x]; return data[x];
} }
@@ -686,7 +684,7 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev)
self->init_sequence.receive_buf = self->init_sequence.receive_buf =
g_malloc0 (VFS5011_RECEIVE_BUF_SIZE); g_malloc0 (VFS5011_RECEIVE_BUF_SIZE);
self->init_sequence.timeout = 1000; self->init_sequence.timeout = 1000;
usb_exchange_async (ssm, &self->init_sequence, "ACTIVATE REQUEST"); usb_exchange_async (ssm, &self->init_sequence);
break; break;
case DEV_ACTIVATE_INIT_COMPLETE: case DEV_ACTIVATE_INIT_COMPLETE:
@@ -718,7 +716,7 @@ activate_loop (FpiSsm *ssm, FpDevice *_dev)
self->init_sequence.receive_buf = self->init_sequence.receive_buf =
g_malloc0 (VFS5011_RECEIVE_BUF_SIZE); g_malloc0 (VFS5011_RECEIVE_BUF_SIZE);
self->init_sequence.timeout = VFS5011_DEFAULT_WAIT_TIMEOUT; self->init_sequence.timeout = VFS5011_DEFAULT_WAIT_TIMEOUT;
usb_exchange_async (ssm, &self->init_sequence, "PREPARE CAPTURE"); usb_exchange_async (ssm, &self->init_sequence);
break; break;
} }
@@ -771,7 +769,7 @@ open_loop (FpiSsm *ssm, FpDevice *_dev)
self->init_sequence.receive_buf = self->init_sequence.receive_buf =
g_malloc0 (VFS5011_RECEIVE_BUF_SIZE); g_malloc0 (VFS5011_RECEIVE_BUF_SIZE);
self->init_sequence.timeout = VFS5011_DEFAULT_WAIT_TIMEOUT; self->init_sequence.timeout = VFS5011_DEFAULT_WAIT_TIMEOUT;
usb_exchange_async (ssm, &self->init_sequence, "DEVICE OPEN"); usb_exchange_async (ssm, &self->init_sequence);
break; break;
} }
; ;

View File

@@ -47,7 +47,6 @@ struct _FpDeviceVirtualImage
gint socket_fd; gint socket_fd;
gint client_fd; gint client_fd;
gboolean automatic_finger;
FpImage *recv_img; FpImage *recv_img;
gint recv_img_hdr[2]; gint recv_img_hdr[2];
}; };
@@ -76,9 +75,9 @@ recv_image_img_recv_cb (GObject *source_object,
{ {
if (!success) if (!success)
{ {
g_warning ("Error receiving header for image data: %s", error->message);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
return; return;
g_warning ("Error receiving header for image data: %s", error->message);
} }
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data); self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
@@ -90,10 +89,8 @@ recv_image_img_recv_cb (GObject *source_object,
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data); self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
device = FP_IMAGE_DEVICE (self); device = FP_IMAGE_DEVICE (self);
if (self->automatic_finger)
fpi_image_device_report_finger_status (device, TRUE); fpi_image_device_report_finger_status (device, TRUE);
fpi_image_device_image_captured (device, g_steal_pointer (&self->recv_img)); fpi_image_device_image_captured (device, g_steal_pointer (&self->recv_img));
if (self->automatic_finger)
fpi_image_device_report_finger_status (device, FALSE); fpi_image_device_report_finger_status (device, FALSE);
/* And, listen for more images from the same client. */ /* And, listen for more images from the same client. */
@@ -116,10 +113,9 @@ recv_image_hdr_recv_cb (GObject *source_object,
{ {
if (!success) if (!success)
{ {
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CLOSED))
return;
g_warning ("Error receiving header for image data: %s", error->message); g_warning ("Error receiving header for image data: %s", error->message);
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
return;
} }
self = FPI_DEVICE_VIRTUAL_IMAGE (user_data); self = FPI_DEVICE_VIRTUAL_IMAGE (user_data);
@@ -151,17 +147,6 @@ recv_image_hdr_recv_cb (GObject *source_object,
fpi_device_error_new (self->recv_img_hdr[1])); fpi_device_error_new (self->recv_img_hdr[1]));
break; break;
case -3:
/* -3 sets/clears automatic finger detection for images */
self->automatic_finger = !!self->recv_img_hdr[1];
break;
case -4:
/* -4 submits a finger detection report */
fpi_image_device_report_finger_status (FP_IMAGE_DEVICE (self),
!!self->recv_img_hdr[1]);
break;
default: default:
/* disconnect client, it didn't play fair */ /* disconnect client, it didn't play fair */
g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL); g_io_stream_close (G_IO_STREAM (self->connection), NULL, NULL);
@@ -228,7 +213,6 @@ new_connection_cb (GObject *source_object, GAsyncResult *res, gpointer user_data
} }
dev->connection = connection; dev->connection = connection;
dev->automatic_finger = TRUE;
stream = g_io_stream_get_input_stream (G_IO_STREAM (connection)); stream = g_io_stream_get_input_stream (G_IO_STREAM (connection));
recv_image (dev, stream); recv_image (dev, stream);

View File

@@ -1384,9 +1384,21 @@ typedef struct
{ {
GSource source; GSource source;
FpDevice *device; FpDevice *device;
FpTimeoutFunc callback;
gpointer user_data;
} FpDeviceTimeoutSource; } FpDeviceTimeoutSource;
static void gboolean
device_timeout_cb (gpointer user_data)
{
FpDeviceTimeoutSource *source = user_data;
source->callback (source->device, source->user_data);
return G_SOURCE_REMOVE;
}
void
timeout_finalize (GSource *source) timeout_finalize (GSource *source)
{ {
FpDeviceTimeoutSource *timeout_source = (FpDeviceTimeoutSource *) source; FpDeviceTimeoutSource *timeout_source = (FpDeviceTimeoutSource *) source;
@@ -1397,12 +1409,11 @@ timeout_finalize (GSource *source)
} }
static gboolean static gboolean
timeout_dispatch (GSource *source, GSourceFunc gsource_func, gpointer user_data) timeout_dispatch (GSource *source, GSourceFunc callback, gpointer user_data)
{ {
FpDeviceTimeoutSource *timeout_source = (FpDeviceTimeoutSource *) source; FpDeviceTimeoutSource *timeout_source = (FpDeviceTimeoutSource *) source;
FpTimeoutFunc callback = (FpTimeoutFunc) gsource_func;
callback (timeout_source->device, user_data); ((FpTimeoutFunc) callback)(timeout_source->device, user_data);
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
@@ -1485,6 +1496,7 @@ fpi_device_add_timeout (FpDevice *device,
source = (FpDeviceTimeoutSource *) g_source_new (&timeout_funcs, source = (FpDeviceTimeoutSource *) g_source_new (&timeout_funcs,
sizeof (FpDeviceTimeoutSource)); sizeof (FpDeviceTimeoutSource));
source->device = device; source->device = device;
source->user_data = user_data;
g_source_attach (&source->source, NULL); g_source_attach (&source->source, NULL);
g_source_set_callback (&source->source, (GSourceFunc) func, user_data, destroy_notify); g_source_set_callback (&source->source, (GSourceFunc) func, user_data, destroy_notify);

View File

@@ -50,9 +50,7 @@ typedef struct
{ {
FpImageDeviceState state; FpImageDeviceState state;
gboolean active; gboolean active;
gboolean cancelling;
gboolean enroll_await_on_pending;
gint enroll_stage; gint enroll_stage;
guint pending_activation_timeout_id; guint pending_activation_timeout_id;
@@ -141,9 +139,6 @@ fp_image_device_deactivate (FpDevice *device)
fp_dbg ("Already deactivated, ignoring request."); fp_dbg ("Already deactivated, ignoring request.");
return; return;
} }
if (!priv->cancelling && priv->state == FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON)
g_warning ("Deactivating image device while waiting for finger, this should not happen.");
priv->state = FP_IMAGE_DEVICE_STATE_INACTIVE; priv->state = FP_IMAGE_DEVICE_STATE_INACTIVE;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]); g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
@@ -207,7 +202,6 @@ static void
fp_image_device_cancel_action (FpDevice *device) fp_image_device_cancel_action (FpDevice *device)
{ {
FpImageDevice *self = FP_IMAGE_DEVICE (device); FpImageDevice *self = FP_IMAGE_DEVICE (device);
FpImageDevicePrivate *priv = fp_image_device_get_instance_private (self);
FpDeviceAction action; FpDeviceAction action;
action = fpi_device_get_current_action (device); action = fpi_device_get_current_action (device);
@@ -219,9 +213,7 @@ fp_image_device_cancel_action (FpDevice *device)
action == FP_DEVICE_ACTION_IDENTIFY || action == FP_DEVICE_ACTION_IDENTIFY ||
action == FP_DEVICE_ACTION_CAPTURE) action == FP_DEVICE_ACTION_CAPTURE)
{ {
priv->cancelling = TRUE;
fp_image_device_deactivate (FP_DEVICE (self)); fp_image_device_deactivate (FP_DEVICE (self));
priv->cancelling = FALSE;
/* XXX: Some nicer way of doing this would be good. */ /* XXX: Some nicer way of doing this would be good. */
fpi_device_action_error (FP_DEVICE (self), fpi_device_action_error (FP_DEVICE (self),
@@ -264,7 +256,6 @@ fp_image_device_start_capture_action (FpDevice *device)
} }
priv->enroll_stage = 0; priv->enroll_stage = 0;
priv->enroll_await_on_pending = FALSE;
/* The device might still be deactivating from a previous call. /* The device might still be deactivating from a previous call.
* In that situation, try to wait for a bit before reporting back an * In that situation, try to wait for a bit before reporting back an
@@ -394,22 +385,6 @@ fp_image_device_init (FpImageDevice *self)
} }
static void
fp_image_device_enroll_maybe_await_finger_on (FpImageDevice *self)
{
FpImageDevicePrivate *priv = fp_image_device_get_instance_private (self);
if (priv->enroll_await_on_pending)
{
priv->enroll_await_on_pending = FALSE;
fp_image_device_change_state (self, FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON);
}
else
{
priv->enroll_await_on_pending = TRUE;
}
}
static void static void
fpi_image_device_minutiae_detected (GObject *source_object, GAsyncResult *res, gpointer user_data) fpi_image_device_minutiae_detected (GObject *source_object, GAsyncResult *res, gpointer user_data)
{ {
@@ -471,16 +446,11 @@ fpi_image_device_minutiae_detected (GObject *source_object, GAsyncResult *res, g
fpi_device_enroll_progress (device, priv->enroll_stage, fpi_device_enroll_progress (device, priv->enroll_stage,
g_steal_pointer (&print), error); g_steal_pointer (&print), error);
/* Start another scan or deactivate. */
if (priv->enroll_stage == IMG_ENROLL_STAGES) if (priv->enroll_stage == IMG_ENROLL_STAGES)
{ {
fpi_device_enroll_complete (device, g_object_ref (enroll_print), NULL); fpi_device_enroll_complete (device, g_object_ref (enroll_print), NULL);
fp_image_device_deactivate (device); fp_image_device_deactivate (device);
} }
else
{
fp_image_device_enroll_maybe_await_finger_on (FP_IMAGE_DEVICE (device));
}
} }
else if (action == FP_DEVICE_ACTION_VERIFY) else if (action == FP_DEVICE_ACTION_VERIFY)
{ {
@@ -602,15 +572,13 @@ fpi_image_device_report_finger_status (FpImageDevice *self,
* 2. We are still deactivating the device after an action completed * 2. We are still deactivating the device after an action completed
* 3. We were waiting for finger removal to start the new action * 3. We were waiting for finger removal to start the new action
* Either way, we always end up deactivating except for the enroll case. * Either way, we always end up deactivating except for the enroll case.
* * XXX: This is not quite correct though, as we assume we need another finger
* The enroll case is special as AWAIT_FINGER_ON should only happen after * scan even though we might be processing the last one (successfully).
* minutiae detection to prevent deactivation (without cancellation)
* from the AWAIT_FINGER_ON state.
*/ */
if (action != FP_DEVICE_ACTION_ENROLL) if (action != FP_DEVICE_ACTION_ENROLL)
fp_image_device_deactivate (device); fp_image_device_deactivate (device);
else else
fp_image_device_enroll_maybe_await_finger_on (self); fp_image_device_change_state (self, FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON);
} }
} }

View File

@@ -19,9 +19,8 @@
*/ */
#include "fpi-image.h" #include "fpi-image.h"
#include "fpi-log.h"
#include <nbis.h> #include "nbis/include/lfs.h"
#if HAVE_PIXMAN #if HAVE_PIXMAN
#include <pixman.h> #include <pixman.h>

View File

@@ -20,10 +20,10 @@
#include "fpi-print.h" #include "fpi-print.h"
#include "fpi-image.h" #include "fpi-image.h"
#include "fpi-log.h"
#include "fpi-device.h" #include "fpi-device.h"
#include <nbis.h> #include "nbis/include/bozorth.h"
#include "nbis/include/lfs.h"
/** /**
* SECTION: fp-print * SECTION: fp-print
@@ -207,7 +207,7 @@ fp_print_set_property (GObject *object,
break; break;
case PROP_FPI_DATA: case PROP_FPI_DATA:
g_clear_pointer (&self->data, g_variant_unref); g_clear_pointer (&self->description, g_variant_unref);
self->data = g_value_dup_variant (value); self->data = g_value_dup_variant (value);
break; break;

View File

@@ -1,6 +1,6 @@
/* /*
* Internal/private definitions for libfprint * Internal/private definitions for libfprint
* Copyright (C) 2019 Marco Trevisan <marco.trevisan@canonical.com> * Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@@ -17,9 +17,38 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#pragma once #ifndef __FPRINT_INTERNAL_H__
#define __FPRINT_INTERNAL_H__
#include "fpi-log.h" #include "fpi-log.h"
#include "nbis-helpers.h"
#include "fpi-image.h" #include "fpi-image.h"
#include "fpi-image-device.h" #include "fpi-image-device.h"
#include "fpi-minutiae.h"
/* fp_minutia structure definition */
struct fp_minutia
{
int x;
int y;
int ex;
int ey;
int direction;
double reliability;
int type;
int appearing;
int feature_id;
int *nbrs;
int *ridge_counts;
int num_nbrs;
};
/* fp_minutiae structure definition */
struct fp_minutiae
{
int alloc;
int num;
struct fp_minutia **list;
};
#endif

View File

@@ -1,45 +0,0 @@
/*
* Internal/private definitions for libfprint
* Copyright (C) 2007-2008 Daniel Drake <dsd@gentoo.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
/* fp_minutia structure definition */
struct fp_minutia
{
int x;
int y;
int ex;
int ey;
int direction;
double reliability;
int type;
int appearing;
int feature_id;
int *nbrs;
int *ridge_counts;
int num_nbrs;
};
/* fp_minutiae structure definition */
struct fp_minutiae
{
int alloc;
int num;
struct fp_minutia **list;
};

View File

@@ -21,13 +21,13 @@ typedef enum {
/** /**
* FpiMatchResult: * FpiMatchResult:
* @FPI_MATCH_ERROR: An error occured during matching * @FPI_MATCH_ERROR: An error occured during matching
* @FPI_MATCH_FAIL: The prints did not match
* @FPI_MATCH_SUCCESS: The prints matched * @FPI_MATCH_SUCCESS: The prints matched
* @FPI_MATCH_FAIL: The prints did not match
*/ */
typedef enum { typedef enum {
FPI_MATCH_ERROR = -1, /* -1 for g_task_propagate_int */ FPI_MATCH_ERROR = 0,
FPI_MATCH_FAIL,
FPI_MATCH_SUCCESS, FPI_MATCH_SUCCESS,
FPI_MATCH_FAIL,
} FpiMatchResult; } FpiMatchResult;
void fpi_print_add_print (FpPrint *print, void fpi_print_add_print (FpPrint *print,

View File

@@ -81,7 +81,6 @@
struct _FpiSsm struct _FpiSsm
{ {
FpDevice *dev; FpDevice *dev;
const char *name;
FpiSsm *parentsm; FpiSsm *parentsm;
gpointer ssm_data; gpointer ssm_data;
GDestroyNotify ssm_data_destroy; GDestroyNotify ssm_data_destroy;
@@ -104,29 +103,13 @@ struct _FpiSsm
* *
* Allocate a new ssm, with @nr_states states. The @handler callback * Allocate a new ssm, with @nr_states states. The @handler callback
* will be called after each state transition. * will be called after each state transition.
* This is a macro that calls fpi_ssm_new_full() using the stringified
* version of @nr_states, so will work better with named parameters.
*
* Returns: a new #FpiSsm state machine
*/
/**
* fpi_ssm_new_full:
* @dev: a #fp_dev fingerprint device
* @handler: the callback function
* @nr_states: the number of states
* @name: the name of the state machine (for debug purposes)
*
* Allocate a new ssm, with @nr_states states. The @handler callback
* will be called after each state transition.
* *
* Returns: a new #FpiSsm state machine * Returns: a new #FpiSsm state machine
*/ */
FpiSsm * FpiSsm *
fpi_ssm_new_full (FpDevice *dev, fpi_ssm_new (FpDevice *dev,
FpiSsmHandlerCallback handler, FpiSsmHandlerCallback handler,
int nr_states, int nr_states)
const char *name)
{ {
FpiSsm *machine; FpiSsm *machine;
@@ -137,7 +120,6 @@ fpi_ssm_new_full (FpDevice *dev,
machine->handler = handler; machine->handler = handler;
machine->nr_states = nr_states; machine->nr_states = nr_states;
machine->dev = dev; machine->dev = dev;
machine->name = g_strdup (name);
machine->completed = TRUE; machine->completed = TRUE;
return machine; return machine;
} }
@@ -269,7 +251,6 @@ fpi_ssm_free (FpiSsm *machine)
if (machine->ssm_data_destroy) if (machine->ssm_data_destroy)
g_clear_pointer (&machine->ssm_data, machine->ssm_data_destroy); g_clear_pointer (&machine->ssm_data, machine->ssm_data_destroy);
g_clear_pointer (&machine->error, g_error_free); g_clear_pointer (&machine->error, g_error_free);
g_clear_pointer (&machine->name, g_free);
fpi_ssm_clear_delayed_action (machine); fpi_ssm_clear_delayed_action (machine);
g_free (machine); g_free (machine);
} }
@@ -278,8 +259,7 @@ fpi_ssm_free (FpiSsm *machine)
static void static void
__ssm_call_handler (FpiSsm *machine) __ssm_call_handler (FpiSsm *machine)
{ {
fp_dbg ("[%s] %s entering state %d", fp_device_get_driver (machine->dev), fp_dbg ("%p entering state %d", machine, machine->cur_state);
machine->name, machine->cur_state);
machine->handler (machine, machine->dev); machine->handler (machine, machine->dev);
} }
@@ -357,11 +337,9 @@ fpi_ssm_mark_completed (FpiSsm *machine)
machine->completed = TRUE; machine->completed = TRUE;
if (machine->error) if (machine->error)
fp_dbg ("[%s] %s completed with error: %s", fp_device_get_driver (machine->dev), fp_dbg ("%p completed with error: %s", machine, machine->error->message);
machine->name, machine->error->message);
else else
fp_dbg ("[%s] %s completed successfully", fp_device_get_driver (machine->dev), fp_dbg ("%p completed successfully", machine);
machine->name);
if (machine->callback) if (machine->callback)
{ {
GError *error = machine->error ? g_error_copy (machine->error) : NULL; GError *error = machine->error ? g_error_copy (machine->error) : NULL;
@@ -405,9 +383,9 @@ fpi_ssm_mark_completed_delayed (FpiSsm *machine,
on_device_timeout_complete, cancellable, on_device_timeout_complete, cancellable,
machine, NULL); machine, NULL);
source_name = g_strdup_printf ("[%s] ssm %s complete %d", source_name = g_strdup_printf ("[%s] ssm %p complete %d",
fp_device_get_device_id (machine->dev), fp_device_get_device_id (machine->dev),
machine->name, machine->cur_state + 1); machine, machine->cur_state + 1);
g_source_set_name (machine->timeout, source_name); g_source_set_name (machine->timeout, source_name);
} }
@@ -424,15 +402,12 @@ fpi_ssm_mark_failed (FpiSsm *machine, GError *error)
g_assert (error); g_assert (error);
if (machine->error) if (machine->error)
{ {
fp_warn ("[%s] SSM %s already has an error set, ignoring new error %s", fp_warn ("SSM already has an error set, ignoring new error %s", error->message);
fp_device_get_driver (machine->dev), machine->name, error->message);
g_error_free (error); g_error_free (error);
return; return;
} }
fp_dbg ("[%s] SSM %s failed in state %d with error: %s", fp_dbg ("SSM failed in state %d with error: %s", machine->cur_state, error->message);
fp_device_get_driver (machine->dev), machine->name,
machine->cur_state, error->message);
machine->error = g_steal_pointer (&error); machine->error = g_steal_pointer (&error);
fpi_ssm_mark_completed (machine); fpi_ssm_mark_completed (machine);
} }
@@ -507,9 +482,9 @@ fpi_ssm_next_state_delayed (FpiSsm *machine,
on_device_timeout_next_state, cancellable, on_device_timeout_next_state, cancellable,
machine, NULL); machine, NULL);
source_name = g_strdup_printf ("[%s] ssm %s jump to next state %d", source_name = g_strdup_printf ("[%s] ssm %p jump to next state %d",
fp_device_get_device_id (machine->dev), fp_device_get_device_id (machine->dev),
machine->name, machine->cur_state + 1); machine, machine->cur_state + 1);
g_source_set_name (machine->timeout, source_name); g_source_set_name (machine->timeout, source_name);
} }
@@ -584,9 +559,9 @@ fpi_ssm_jump_to_state_delayed (FpiSsm *machine,
on_device_timeout_jump_to_state, on_device_timeout_jump_to_state,
cancellable, data, g_free); cancellable, data, g_free);
source_name = g_strdup_printf ("[%s] ssm %s jump to state %d", source_name = g_strdup_printf ("[%s] ssm %p jump to state %d",
fp_device_get_device_id (machine->dev), fp_device_get_device_id (machine->dev),
machine->name, state); machine, state);
g_source_set_name (machine->timeout, source_name); g_source_set_name (machine->timeout, source_name);
} }

View File

@@ -60,12 +60,9 @@ typedef void (*FpiSsmHandlerCallback)(FpiSsm *ssm,
FpDevice *dev); FpDevice *dev);
/* for library and drivers */ /* for library and drivers */
#define fpi_ssm_new(dev, handler, nr_states) \ FpiSsm *fpi_ssm_new (FpDevice *dev,
fpi_ssm_new_full (dev, handler, nr_states, #nr_states)
FpiSsm *fpi_ssm_new_full (FpDevice *dev,
FpiSsmHandlerCallback handler, FpiSsmHandlerCallback handler,
int nr_states, int nr_states);
const char *machine_name);
void fpi_ssm_free (FpiSsm *machine); void fpi_ssm_free (FpiSsm *machine);
void fpi_ssm_start (FpiSsm *ssm, void fpi_ssm_start (FpiSsm *ssm,
FpiSsmCompletedCallback callback); FpiSsmCompletedCallback callback);

View File

@@ -298,7 +298,7 @@ fpi_usb_transfer_fill_interrupt_full (FpiUsbTransfer *transfer,
transfer->free_buffer = free_func; transfer->free_buffer = free_func;
} }
static void void
transfer_finish_cb (GObject *source_object, GAsyncResult *res, gpointer user_data) transfer_finish_cb (GObject *source_object, GAsyncResult *res, gpointer user_data)
{ {
GError *error = NULL; GError *error = NULL;
@@ -454,7 +454,6 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
GError **error) GError **error)
{ {
gboolean res; gboolean res;
gsize actual_length;
g_return_val_if_fail (transfer, FALSE); g_return_val_if_fail (transfer, FALSE);
@@ -470,7 +469,7 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
transfer->endpoint, transfer->endpoint,
transfer->buffer, transfer->buffer,
transfer->length, transfer->length,
&actual_length, &transfer->actual_length,
timeout_ms, timeout_ms,
NULL, NULL,
error); error);
@@ -486,7 +485,7 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
transfer->idx, transfer->idx,
transfer->buffer, transfer->buffer,
transfer->length, transfer->length,
&actual_length, &transfer->actual_length,
timeout_ms, timeout_ms,
NULL, NULL,
error); error);
@@ -497,7 +496,7 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
transfer->endpoint, transfer->endpoint,
transfer->buffer, transfer->buffer,
transfer->length, transfer->length,
&actual_length, &transfer->actual_length,
timeout_ms, timeout_ms,
NULL, NULL,
error); error);
@@ -512,8 +511,6 @@ fpi_usb_transfer_submit_sync (FpiUsbTransfer *transfer,
if (!res) if (!res)
transfer->actual_length = -1; transfer->actual_length = -1;
else
transfer->actual_length = actual_length;
return res; return res;
} }

View File

@@ -172,43 +172,29 @@ fpi_enums = gnome.mkenums_simple('fpi-enums',
fpi_enums_h = fpi_enums[1] fpi_enums_h = fpi_enums[1]
drivers_sources += configure_file(input: 'empty_file', drivers_sources += configure_file(input: 'empty_file',
output: 'fpi-drivers.c', output: 'fp-drivers.c',
capture: true, capture: true,
command: [ command: [
'echo', 'echo',
'\n'.join(drivers_type_list + [] + drivers_type_func) drivers_type_list + '\n\n' + drivers_type_func
]) ])
mapfile = 'libfprint.ver' mapfile = 'libfprint.ver'
vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
deps = [ mathlib_dep, glib_dep, gusb_dep, nss_dep, imaging_dep, gio_dep ] deps = [ mathlib_dep, glib_dep, gusb_dep, nss_dep, imaging_dep, gio_dep ]
deps += declare_dependency(include_directories: [
root_inc,
include_directories('nbis/include'),
include_directories('nbis/libfprint-include'),
])
libnbis = static_library('nbis',
nbis_sources,
dependencies: deps,
c_args: cc.get_supported_arguments([
'-Wno-error=redundant-decls',
'-Wno-redundant-decls',
'-Wno-discarded-qualifiers',
]),
install: false)
libfprint = library('fprint', libfprint = library('fprint',
libfprint_sources + fp_enums + fpi_enums + libfprint_sources + fp_enums + fpi_enums +
drivers_sources + other_sources, drivers_sources + nbis_sources + other_sources,
soversion: soversion, soversion: soversion,
version: libversion, version: libversion,
c_args: drivers_cflags, c_args: common_cflags + drivers_cflags,
include_directories: [
root_inc,
include_directories('nbis/include'),
],
link_args : vflag, link_args : vflag,
link_depends : mapfile, link_depends : mapfile,
link_with: libnbis,
dependencies: deps, dependencies: deps,
install: true) install: true)
@@ -221,6 +207,9 @@ install_headers(['fprint.h'] + libfprint_public_headers, subdir: 'libfprint')
udev_rules = executable('fprint-list-udev-rules', udev_rules = executable('fprint-list-udev-rules',
'fprint-list-udev-rules.c', 'fprint-list-udev-rules.c',
include_directories: [
root_inc,
],
dependencies: [ deps, libfprint_dep ], dependencies: [ deps, libfprint_dep ],
install: false) install: false)
@@ -235,6 +224,9 @@ endif
supported_devices = executable('fprint-list-supported-devices', supported_devices = executable('fprint-list-supported-devices',
'fprint-list-supported-devices.c', 'fprint-list-supported-devices.c',
include_directories: [
root_inc,
],
dependencies: [ deps, libfprint_dep ], dependencies: [ deps, libfprint_dep ],
install: false) install: false)

View File

@@ -896,7 +896,7 @@ for ( k = 0; k < np - 1; k++ ) {
for ( i = 0; i < tot; i++ ) { for ( i = 0; i < tot; i++ ) {
int colp_value = colp[ bz_y[i]-1 ][0]; int colp_value = colp[ y[i]-1 ][0];
if ( colp_value < 0 ) { if ( colp_value < 0 ) {
kk += colp_value; kk += colp_value;
n++; n++;
@@ -933,7 +933,7 @@ for ( k = 0; k < np - 1; k++ ) {
kk = 0; kk = 0;
for ( i = 0; i < tot; i++ ) { for ( i = 0; i < tot; i++ ) {
int diff = colp[ bz_y[i]-1 ][0] - jj; int diff = colp[ y[i]-1 ][0] - jj;
j = SQUARED( diff ); j = SQUARED( diff );
@@ -942,7 +942,7 @@ for ( k = 0; k < np - 1; k++ ) {
if ( j > TXS && j < CTXS ) if ( j > TXS && j < CTXS )
kk++; kk++;
else else
bz_y[i-kk] = bz_y[i]; y[i-kk] = y[i];
} /* END FOR i */ } /* END FOR i */
tot -= kk; /* Adjust the total edge pairs TOT based on # of edge pairs skipped */ tot -= kk; /* Adjust the total edge pairs TOT based on # of edge pairs skipped */
@@ -958,7 +958,7 @@ for ( k = 0; k < np - 1; k++ ) {
for ( i = tot-1 ; i >= 0; i-- ) { for ( i = tot-1 ; i >= 0; i-- ) {
int idx = bz_y[i] - 1; int idx = y[i] - 1;
if ( rk[idx] == 0 ) { if ( rk[idx] == 0 ) {
sc[idx] = -1; sc[idx] = -1;
} else { } else {
@@ -976,7 +976,7 @@ for ( k = 0; k < np - 1; k++ ) {
int pd = 0; int pd = 0;
for ( i = 0; i < tot; i++ ) { for ( i = 0; i < tot; i++ ) {
int idx = bz_y[i] - 1; int idx = y[i] - 1;
for ( ii = 1; ii < 4; ii++ ) { for ( ii = 1; ii < 4; ii++ ) {
@@ -1476,7 +1476,7 @@ return match_score;
/* extern int rk[ RK_SIZE ]; */ /* extern int rk[ RK_SIZE ]; */
/* extern int cp[ CP_SIZE ]; */ /* extern int cp[ CP_SIZE ]; */
/* extern int rp[ RP_SIZE ]; */ /* extern int rp[ RP_SIZE ]; */
/* extern int bz_y[ Y_SIZE ]; */ /* extern int y[ Y_SIZE ]; */
void bz_sift( void bz_sift(
int * ww, /* INPUT and OUTPUT; endpoint groups index; *ww may be bumped by one or by two */ int * ww, /* INPUT and OUTPUT; endpoint groups index; *ww may be bumped by one or by two */
@@ -1507,7 +1507,7 @@ if ( n == 0 && t == 0 ) {
if ( sc[kx-1] != ftt ) { if ( sc[kx-1] != ftt ) {
bz_y[ (*tot)++ ] = kx; y[ (*tot)++ ] = kx;
rk[kx-1] = sc[kx-1]; rk[kx-1] = sc[kx-1];
sc[kx-1] = ftt; sc[kx-1] = ftt;
} }
@@ -1553,7 +1553,7 @@ if ( n == l ) {
qq[*qh] = kz; qq[*qh] = kz;
zz[kz-1] = (*qh)++; zz[kz-1] = (*qh)++;
} }
bz_y[(*tot)++] = kx; y[(*tot)++] = kx;
rk[kx-1] = sc[kx-1]; rk[kx-1] = sc[kx-1];
sc[kx-1] = ftt; sc[kx-1] = ftt;
} }
@@ -1697,12 +1697,12 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
} }
t = 0; t = 0;
bz_y[0] = lim; y[0] = lim;
cp[0] = 1; cp[0] = 1;
b = 0; b = 0;
n = 1; n = 1;
do { /* looping until T < 0 ... */ do { /* looping until T < 0 ... */
if (bz_y[t] - cp[t] > 1 ) { if ( y[t] - cp[t] > 1 ) {
k = sct[cp[t]][t]; k = sct[cp[t]][t];
j = ctt[k] + 1; j = ctt[k] + 1;
for ( i = 0; i < j; i++ ) { for ( i = 0; i < j; i++ ) {
@@ -1715,25 +1715,25 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
do { do {
while ( rp[jj] < sct[kk][t] && jj < j ) while ( rp[jj] < sct[kk][t] && jj < j )
jj++; jj++;
while ( rp[jj] > sct[kk][t] && kk < bz_y[t] ) while ( rp[jj] > sct[kk][t] && kk < y[t] )
kk++; kk++;
while ( rp[jj] == sct[kk][t] && kk < bz_y[t] && jj < j ) { while ( rp[jj] == sct[kk][t] && kk < y[t] && jj < j ) {
sct[k][t+1] = sct[kk][t]; sct[k][t+1] = sct[kk][t];
k++; k++;
kk++; kk++;
jj++; jj++;
} }
} while ( kk < bz_y[t] && jj < j ); } while ( kk < y[t] && jj < j );
t++; t++;
cp[t] = 1; cp[t] = 1;
bz_y[t] = k; y[t] = k;
b = t; b = t;
n = 1; n = 1;
} else { } else {
int tot = 0; int tot = 0;
lim = bz_y[t]; lim = y[t];
for ( i = n-1; i < lim; i++ ) { for ( i = n-1; i < lim; i++ ) {
tot += ct[ sct[i][t] ]; tot += ct[ sct[i][t] ];
} }
@@ -1750,7 +1750,7 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
{ {
int rk_index = b; int rk_index = b;
lim = bz_y[t]; lim = y[t];
for ( i = n-1; i < lim; ) { for ( i = n-1; i < lim; ) {
rk[ rk_index++ ] = sct[ i++ ][ t ]; rk[ rk_index++ ] = sct[ i++ ][ t ];
} }
@@ -1760,7 +1760,7 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
t--; t--;
if ( t >= 0 ) { if ( t >= 0 ) {
++cp[t]; ++cp[t];
n = bz_y[t]; n = y[t];
} }
} /* END IF */ } /* END IF */

View File

@@ -102,7 +102,7 @@ int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
int rf[RF_SIZE_1][RF_SIZE_2]; int rf[RF_SIZE_1][RF_SIZE_2];
int cf[CF_SIZE_1][CF_SIZE_2]; int cf[CF_SIZE_1][CF_SIZE_2];
int bz_y[20000]; int y[20000];
#else #else
int rq[ RQ_SIZE ] = {}; int rq[ RQ_SIZE ] = {};
int tq[ TQ_SIZE ] = {}; int tq[ TQ_SIZE ] = {};
@@ -122,6 +122,6 @@ int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
int rf[RF_SIZE_1][RF_SIZE_2] = {}; int rf[RF_SIZE_1][RF_SIZE_2] = {};
int cf[CF_SIZE_1][CF_SIZE_2] = {}; int cf[CF_SIZE_1][CF_SIZE_2] = {};
int bz_y[20000] = {}; int y[20000] = {};
#endif #endif

View File

@@ -245,7 +245,7 @@ extern int cp[ CP_SIZE ];
extern int rp[ RP_SIZE ]; extern int rp[ RP_SIZE ];
extern int rf[RF_SIZE_1][RF_SIZE_2]; extern int rf[RF_SIZE_1][RF_SIZE_2];
extern int cf[CF_SIZE_1][CF_SIZE_2]; extern int cf[CF_SIZE_1][CF_SIZE_2];
extern int bz_y[20000]; extern int y[20000];
/**************************************************************************/ /**************************************************************************/
/**************************************************************************/ /**************************************************************************/

View File

@@ -66,8 +66,7 @@ of the software.
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
#include <nbis-helpers.h> #include <fp_internal.h>
#include <fpi-minutiae.h>
/*************************************************************************/ /*************************************************************************/
/* OUTPUT FILE EXTENSIONS */ /* OUTPUT FILE EXTENSIONS */

View File

@@ -1,16 +1,15 @@
--- include/lfs.h --- include/lfs.h 2018-08-24 15:31:54.535579623 +0200
+++ include/lfs.h +++ include/lfs.h.orig 2018-08-24 15:31:48.781587933 +0200
@@ -66,7 +66,8 @@ of the software. @@ -66,7 +43,7 @@ of the software.
#include <math.h> #include <math.h>
#include <stdio.h> #include <stdio.h>
-#include <an2k.h> /* Needed by to_type9.c */ -#include <an2k.h> /* Needed by to_type9.c */
+#include <nbis-helpers.h> +#include <fp_internal.h>
+#include <fpi-minutiae.h>
/*************************************************************************/ /*************************************************************************/
/* OUTPUT FILE EXTENSIONS */ /* OUTPUT FILE EXTENSIONS */
@@ -154,26 +155,8 @@ typedef struct rotgrids{ @@ -154,26 +131,8 @@ typedef struct rotgrids{
#define DISAPPEARING 0 #define DISAPPEARING 0
#define APPEARING 1 #define APPEARING 1
@@ -39,7 +38,7 @@
typedef struct feature_pattern{ typedef struct feature_pattern{
int type; int type;
@@ -1203,17 +1186,6 @@ extern void bubble_sort_double_inc_2(double *, int *, const int); @@ -1185,17 +1185,6 @@ extern void bubble_sort_double_inc_2(double *, int *, const int);
extern void bubble_sort_double_dec_2(double *, int *, const int); extern void bubble_sort_double_dec_2(double *, int *, const int);
extern void bubble_sort_int_inc(int *, const int); extern void bubble_sort_int_inc(int *, const int);

View File

@@ -1,35 +0,0 @@
/*
* Example fingerprint device prints listing and deletion
* Enrolls your right index finger and saves the print to disk
* Copyright (C) 2019 Marco Trevisan <marco.trevisan@canonical.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#pragma once
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wredundant-decls"
#include <bozorth.h>
#include <bz_array.h>
#include <defs.h>
#include <lfs.h>
#include <log.h>
#include <morph.h>
#include <mytime.h>
#include <sunrast.h>
#pragma GCC diagnostic pop

View File

@@ -66,7 +66,7 @@ of the software.
/***************************************************************************/ /***************************************************************************/
/***************************************************************************/ /***************************************************************************/
int open_logfile(void) int open_logfile()
{ {
#ifdef LOG_REPORT #ifdef LOG_REPORT
fprintf(stderr, "ERROR : open_logfile : fopen : %s\n", LOG_FILE); fprintf(stderr, "ERROR : open_logfile : fopen : %s\n", LOG_FILE);
@@ -91,7 +91,7 @@ void print2log(char *fmt, ...)
/***************************************************************************/ /***************************************************************************/
/***************************************************************************/ /***************************************************************************/
int close_logfile(void) int close_logfile()
{ {
#ifdef LOG_REPORT #ifdef LOG_REPORT
fprintf(stderr, "ERROR : close_logfile : fclose : %s\n", LOG_FILE); fprintf(stderr, "ERROR : close_logfile : fclose : %s\n", LOG_FILE);

View File

@@ -1,21 +0,0 @@
@ global_y @
identifier y;
@@
int
- y
+ bz_y
[20000];
@@
identifier global_y.y;
@@
- y
+ bz_y
[...]
@@
@@
int
- y
+ bz_y
[20000] = {};

View File

@@ -179,16 +179,9 @@ sed -i 's/[ \t]*$//' `find -name "*.[ch]"`
# Remove usebsd.h # Remove usebsd.h
sed -i '/usebsd.h/d' `find -name "*.[ch]"` sed -i '/usebsd.h/d' `find -name "*.[ch]"`
# Replace functions with empty parameters using (void)
sed -i 's/^\([[:space:]]*[[:alnum:]_]\+[\*[:space:]]\+'\
'[[:alnum:]_]\+[[:space:]]*\)([[:space:]]*)/\1(void)/g' `find -name "*.[ch]"`
# Use GLib memory management # Use GLib memory management
spatch --sp-file glib-memory.cocci --dir . --in-place spatch --sp-file glib-memory.cocci --dir . --in-place
# Rename global "y" variable in "bz_y"
spatch --sp-file remove-global-y.cocci bozorth3/* include/bozorth.h --in-place
# The above leaves an unused variable around, triggering a warning # The above leaves an unused variable around, triggering a warning
# remove it. # remove it.
patch -p0 < glib-mem-warning.patch patch -p0 < glib-mem-warning.patch

View File

@@ -10,6 +10,9 @@ project('libfprint', [ 'c', 'cpp' ],
gnome = import('gnome') gnome = import('gnome')
add_project_arguments([ '-D_GNU_SOURCE' ], language: 'c')
add_project_arguments([ '-DG_LOG_DOMAIN="libfprint"' ], language: 'c')
libfprint_conf = configuration_data() libfprint_conf = configuration_data()
cc = meson.get_compiler('c') cc = meson.get_compiler('c')
@@ -20,53 +23,19 @@ glib_min_version = '2.56'
glib_version_def = 'GLIB_VERSION_@0@_@1@'.format( glib_version_def = 'GLIB_VERSION_@0@_@1@'.format(
glib_min_version.split('.')[0], glib_min_version.split('.')[1]) glib_min_version.split('.')[0], glib_min_version.split('.')[1])
common_cflags = cc.get_supported_arguments([ common_cflags = cc.get_supported_arguments([
'-fgnu89-inline',
'-std=gnu99',
'-Wall', '-Wall',
'-Wcast-align',
'-Wformat-nonliteral',
'-Wformat-security',
'-Wformat=2',
'-Wignored-qualifiers',
'-Wlogical-op',
'-Wmissing-declarations',
'-Wmissing-format-attribute',
'-Wmissing-include-dirs',
'-Wmissing-noreturn',
'-Wpointer-arith',
'-Wshadow',
'-Wtype-limits', '-Wtype-limits',
'-Wundef', '-Wundef',
'-Wunused', '-Wunused',
'-Werror=address', '-Wstrict-prototypes',
'-Werror=array-bounds', '-Werror-implicit-function-declaration',
'-Werror=empty-body', '-Wno-pointer-sign',
'-Werror=init-self', '-Wshadow',
'-Werror=int-to-pointer-cast',
'-Werror=main',
'-Werror=missing-braces',
'-Werror=nonnull',
'-Werror=redundant-decls',
'-Werror=return-type',
'-Werror=sequence-point',
'-Werror=trigraphs',
'-Werror=write-strings',
'-fno-strict-aliasing',
'-DGLIB_VERSION_MIN_REQUIRED=' + glib_version_def, '-DGLIB_VERSION_MIN_REQUIRED=' + glib_version_def,
'-DGLIB_VERSION_MAX_ALLOWED=' + glib_version_def, '-DGLIB_VERSION_MAX_ALLOWED=' + glib_version_def,
'-D_GNU_SOURCE',
'-DG_LOG_DOMAIN="libfprint"',
]) ])
c_cflags = cc.get_supported_arguments([
'-std=gnu99',
'-Wimplicit-function-declaration',
'-Wmissing-prototypes',
'-Wnested-externs',
'-Wold-style-definition',
'-Wstrict-prototypes',
'-Werror=implicit',
'-Werror=pointer-to-int-cast',
])
add_project_arguments(common_cflags + c_cflags, language: 'c')
add_project_arguments(common_cflags, language: 'cpp')
# maintaining compatibility with the previous libtool versioning # maintaining compatibility with the previous libtool versioning
# current = binary - interface # current = binary - interface
@@ -146,22 +115,14 @@ foreach driver: drivers
endforeach endforeach
# Export the drivers' types to the core code # Export the drivers' types to the core code
drivers_type_list = [] drivers_type_list = '#include <glib-object.h>\n'
drivers_type_func = [] drivers_type_func = 'void fpi_get_driver_types(GArray *drivers)\n{\n\tGType t;\n'
drivers_type_list += '#include <glib-object.h>'
drivers_type_list += '#include "fpi-context.h"'
drivers_type_list += ''
drivers_type_func += 'void fpi_get_driver_types (GArray *drivers)'
drivers_type_func += ' {'
drivers_type_func += ' GType t;'
drivers_type_func += ''
foreach driver: drivers foreach driver: drivers
drivers_type_list += 'extern GType (fpi_device_' + driver + '_get_type) (void);' drivers_type_list += 'extern GType (fpi_device_' + driver + '_get_type) (void);\n'
drivers_type_func += ' t = fpi_device_' + driver + '_get_type ();' drivers_type_func += ' t = fpi_device_' + driver + '_get_type(); g_array_append_val (drivers, t);\n'
drivers_type_func += ' g_array_append_val (drivers, t);\n'
endforeach endforeach
drivers_type_list += '' drivers_type_list += ''
drivers_type_func += '}' drivers_type_func += '};'
root_inc = include_directories('.') root_inc = include_directories('.')

View File

@@ -36,12 +36,10 @@ c_buf = c_img.get_data()
for x in range(width): for x in range(width):
for y in range(height): for y in range(height):
# The upper byte is don't care, but the location depends on endianness,
# so just set all of them.
c_buf[y * c_rowstride + x * 4 + 0] = buf[y * width + x] c_buf[y * c_rowstride + x * 4 + 0] = buf[y * width + x]
c_buf[y * c_rowstride + x * 4 + 1] = buf[y * width + x] c_buf[y * c_rowstride + x * 4 + 1] = buf[y * width + x]
c_buf[y * c_rowstride + x * 4 + 2] = buf[y * width + x] c_buf[y * c_rowstride + x * 4 + 2] = buf[y * width + x]
c_buf[y * c_rowstride + x * 4 + 3] = buf[y * width + x] # Byte 4 is don't care
c_img.mark_dirty() c_img.mark_dirty()
c_img.write_to_png(sys.argv[1]) c_img.write_to_png(sys.argv[1])

View File

@@ -24,6 +24,20 @@ if wrapper:
os.unsetenv('LIBFPRINT_TEST_WRAPPER') os.unsetenv('LIBFPRINT_TEST_WRAPPER')
sys.exit(subprocess.check_call(wrap_cmd)) sys.exit(subprocess.check_call(wrap_cmd))
class Connection:
def __init__(self, addr):
self.addr = addr
def __enter__(self):
self.con = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.con.connect(self.addr)
return self.con
def __exit__(self, exc_type, exc_val, exc_tb):
self.con.close()
del self.con
def load_image(img): def load_image(img):
png = cairo.ImageSurface.create_from_png(img) png = cairo.ImageSurface.create_from_png(img)
@@ -87,41 +101,16 @@ class VirtualImage(unittest.TestCase):
def setUp(self): def setUp(self):
self.dev.open_sync() self.dev.open_sync()
self.con = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.con.connect(self.sockaddr)
def tearDown(self): def tearDown(self):
self.con.close()
del self.con
self.dev.close_sync() self.dev.close_sync()
def send_retry(self, retry_error=1, iterate=True): def report_finger(self, state):
# The default (1) is too-short with Connection(self.sockaddr) as con:
self.sendall(struct.pack('ii', -1, retry_error)) con.write(struct.pack('ii', -1, 1 if state else 0))
while iterate and ctx.pending():
ctx.iteration(False)
def send_error(self, device_error=0, iterate=True): def send_image(self, image):
# The default (0) is a generic error
self.sendall(struct.pack('ii', -1, retry_error))
while iterate and ctx.pending():
ctx.iteration(False)
def send_finger_automatic(self, automatic, iterate=True):
# Set whether finger on/off is reported around images
self.con.sendall(struct.pack('ii', -3, 1 if automatic else 0))
while iterate and ctx.pending():
ctx.iteration(False)
def send_finger_report(self, has_finger, iterate=True):
# Send finger on/off
self.con.sendall(struct.pack('ii', -4, 1 if has_finger else 0))
while iterate and ctx.pending():
ctx.iteration(False)
def send_image(self, image, iterate=True):
img = self.prints[image] img = self.prints[image]
with Connection(self.sockaddr) as con:
mem = img.get_data() mem = img.get_data()
mem = mem.tobytes() mem = mem.tobytes()
assert len(mem) == img.get_width() * img.get_height() assert len(mem) == img.get_width() * img.get_height()
@@ -129,9 +118,7 @@ class VirtualImage(unittest.TestCase):
encoded_img = struct.pack('ii', img.get_width(), img.get_height()) encoded_img = struct.pack('ii', img.get_width(), img.get_height())
encoded_img += mem encoded_img += mem
self.con.sendall(encoded_img) con.sendall(encoded_img)
while iterate and ctx.pending():
ctx.iteration(False)
def test_capture_prevents_close(self): def test_capture_prevents_close(self):
cancel = Gio.Cancellable() cancel = Gio.Cancellable()
@@ -182,16 +169,10 @@ class VirtualImage(unittest.TestCase):
while self._step < 1: while self._step < 1:
ctx.iteration(True) ctx.iteration(True)
# Test the image-device path where the finger is removed after
# the minutiae scan is completed.
self.send_finger_automatic(False)
self.send_finger_report(True)
self.send_image(image) self.send_image(image)
while self._step < 2: while self._step < 2:
ctx.iteration(True) ctx.iteration(True)
self.send_finger_report(False)
self.send_finger_automatic(True)
self.send_image(image) self.send_image(image)
while self._step < 3: while self._step < 3:
ctx.iteration(True) ctx.iteration(True)