| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /* | ||
| 2 | * Virtual driver for "simple" device debugging | ||
| 3 | * | ||
| 4 | * Copyright (C) 2019 Benjamin Berg <bberg@redhat.com> | ||
| 5 | * Copyright (C) 2020 Bastien Nocera <hadess@hadess.net> | ||
| 6 | * | ||
| 7 | * This library is free software; you can redistribute it and/or | ||
| 8 | * modify it under the terms of the GNU Lesser General Public | ||
| 9 | * License as published by the Free Software Foundation; either | ||
| 10 | * version 2.1 of the License, or (at your option) any later version. | ||
| 11 | * | ||
| 12 | * This library is distributed in the hope that it will be useful, | ||
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * Lesser General Public License for more details. | ||
| 16 | * | ||
| 17 | * You should have received a copy of the GNU Lesser General Public | ||
| 18 | * License along with this library; if not, write to the Free Software | ||
| 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 20 | */ | ||
| 21 | |||
| 22 | /* | ||
| 23 | * This is a virtual driver to debug the non-image based drivers. A small | ||
| 24 | * python script is provided to connect to it via a socket, allowing | ||
| 25 | * prints to registered programmatically. | ||
| 26 | * Using this, it is possible to test libfprint and fprintd. | ||
| 27 | */ | ||
| 28 | |||
| 29 | #include <gio/gio.h> | ||
| 30 | |||
| 31 | #include "fpi-device.h" | ||
| 32 | |||
| 33 | #define MAX_LINE_LEN 1024 | ||
| 34 | |||
| 35 |
4/6✓ Branch 0 (3→4) taken 1275 times.
✗ Branch 1 (3→7) not taken.
✓ Branch 2 (4→5) taken 1275 times.
✓ Branch 3 (4→6) taken 88 times.
✗ Branch 4 (5→6) not taken.
✓ Branch 5 (5→7) taken 1317 times.
|
1421 | G_DECLARE_FINAL_TYPE (FpiDeviceVirtualListener, fpi_device_virtual_listener, FPI, DEVICE_VIRTUAL_LISTENER, GSocketListener) |
| 36 | |||
| 37 | typedef void (*FpiDeviceVirtualListenerConnectionCb) (FpiDeviceVirtualListener *listener, | ||
| 38 | gpointer user_data); | ||
| 39 | |||
| 40 | FpiDeviceVirtualListener * fpi_device_virtual_listener_new (void); | ||
| 41 | |||
| 42 | gboolean fpi_device_virtual_listener_start (FpiDeviceVirtualListener *listener, | ||
| 43 | const char *address, | ||
| 44 | GCancellable *cancellable, | ||
| 45 | FpiDeviceVirtualListenerConnectionCb cb, | ||
| 46 | gpointer user_data, | ||
| 47 | GError **error); | ||
| 48 | |||
| 49 | gboolean fpi_device_virtual_listener_connection_close (FpiDeviceVirtualListener *listener); | ||
| 50 | |||
| 51 | void fpi_device_virtual_listener_read (FpiDeviceVirtualListener *listener, | ||
| 52 | gboolean all, | ||
| 53 | void *buffer, | ||
| 54 | gsize count, | ||
| 55 | GAsyncReadyCallback callback, | ||
| 56 | gpointer user_data); | ||
| 57 | gsize fpi_device_virtual_listener_read_finish (FpiDeviceVirtualListener *listener, | ||
| 58 | GAsyncResult *result, | ||
| 59 | GError **error); | ||
| 60 | |||
| 61 | gboolean fpi_device_virtual_listener_write_sync (FpiDeviceVirtualListener *self, | ||
| 62 | const char *buffer, | ||
| 63 | gsize count, | ||
| 64 | GError **error); | ||
| 65 | |||
| 66 | |||
| 67 | struct _FpDeviceVirtualDevice | ||
| 68 | { | ||
| 69 | FpDevice parent; | ||
| 70 | |||
| 71 | FpiDeviceVirtualListener *listener; | ||
| 72 | GCancellable *cancellable; | ||
| 73 | |||
| 74 | char recv_buf[MAX_LINE_LEN]; | ||
| 75 | |||
| 76 | GPtrArray *pending_commands; | ||
| 77 | |||
| 78 | GHashTable *prints_storage; | ||
| 79 | |||
| 80 | guint wait_command_id; | ||
| 81 | guint sleep_timeout_id; | ||
| 82 | guint enroll_stages_passed; | ||
| 83 | gboolean match_reported; | ||
| 84 | gboolean supports_cancellation; | ||
| 85 | gboolean injected_synthetic_cmd; | ||
| 86 | gboolean ignore_wait; | ||
| 87 | gboolean keep_alive; | ||
| 88 | }; | ||
| 89 | |||
| 90 | /* Not really final here, but we can do this to share the FpDeviceVirtualDevice | ||
| 91 | * contents without having to use a shared private struct instead. */ | ||
| 92 | G_DECLARE_FINAL_TYPE (FpDeviceVirtualDevice, fpi_device_virtual_device, FP, DEVICE_VIRTUAL_DEVICE, FpDevice) | ||
| 93 | |||
| 94 | struct _FpDeviceVirtualDeviceStorage | ||
| 95 | { | ||
| 96 | FpDeviceVirtualDevice parent; | ||
| 97 | }; | ||
| 98 | |||
| 99 | G_DECLARE_FINAL_TYPE (FpDeviceVirtualDeviceStorage, fpi_device_virtual_device_storage, FP, DEVICE_VIRTUAL_DEVICE_STORAGE, FpDeviceVirtualDevice) | ||
| 100 | |||
| 101 | |||
| 102 | gboolean process_cmds (FpDeviceVirtualDevice * self, | ||
| 103 | gboolean scan, | ||
| 104 | char **scan_id, | ||
| 105 | GError **error); | ||
| 106 | gboolean start_scan_command (FpDeviceVirtualDevice *self, | ||
| 107 | char **scan_id, | ||
| 108 | GError **error); | ||
| 109 | gboolean should_wait_to_sleep (FpDeviceVirtualDevice *self, | ||
| 110 | const char *scan_id, | ||
| 111 | GError *error); | ||
| 112 |