From e4a297887b7febd116c493a83090c32dfb9bbf4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Mon, 22 Feb 2021 19:09:11 +0100 Subject: [PATCH] virtual-image: Use explicit list of cases in which we want to listen Depending on the enum order is ok, but not really maintainable so better to explicitly list the states we want to listen. --- libfprint/drivers/virtual-image.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/libfprint/drivers/virtual-image.c b/libfprint/drivers/virtual-image.c index 6b0043f..222f022 100644 --- a/libfprint/drivers/virtual-image.c +++ b/libfprint/drivers/virtual-image.c @@ -188,11 +188,18 @@ on_listener_connected (FpDeviceVirtualListener *listener, g_object_get (self, "fpi-image-device-state", &state, NULL); - /* Only read if we are in AWAIT_FINGER_* or CAPTURE states */ - if (state <= FPI_IMAGE_DEVICE_STATE_DEACTIVATING) - return; - recv_image (self); + switch (state) + { + case FPI_IMAGE_DEVICE_STATE_IDLE: + case FPI_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON: + case FPI_IMAGE_DEVICE_STATE_CAPTURE: + case FPI_IMAGE_DEVICE_STATE_AWAIT_FINGER_OFF: + recv_image (self); + + default: + break; + } } static void