From b861500a9ff0c7632aec3856e7b38be6067c4e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= Date: Tue, 11 Feb 2020 02:09:47 +0100 Subject: [PATCH] device: Throw AlreadyInUse error if stopping an enroll during verification When starting an enroll when verification is in progress (and vice-versa) we emit an AlreadyInUse error, however when calling VerifyStop() during an enrollment (and vice-versa) we just return a NoActionInProgress error, which is not the case. So let's be consistent and change the error type. --- src/device.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/device.c b/src/device.c index 780948b..33f5ac8 100644 --- a/src/device.c +++ b/src/device.c @@ -960,6 +960,12 @@ static void fprint_device_verify_stop(FprintDevice *rdev, dbus_g_method_return_error(context, error); g_error_free (error); return; + } else if (priv->current_action == ACTION_ENROLL) { + g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE, + "Enrollment in progress"); + dbus_g_method_return_error(context, error); + g_error_free (error); + return; } if (priv->current_cancellable) { @@ -1213,8 +1219,17 @@ static void fprint_device_enroll_stop(FprintDevice *rdev, } if (priv->current_action != ACTION_ENROLL) { - g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_NO_ACTION_IN_PROGRESS, - "No enrollment in progress"); + if (priv->current_action == ACTION_NONE) { + g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_NO_ACTION_IN_PROGRESS, + "No enrollment in progress"); + } else if (priv->current_action == ACTION_VERIFY) { + g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE, + "Verification in progress"); + } else if (priv->current_action == ACTION_IDENTIFY) { + g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE, + "Identification in progress"); + } else + g_assert_not_reached (); dbus_g_method_return_error(context, error); g_error_free (error); return;