diff --git a/src/device.c b/src/device.c
index 53668d6..e3f4cd8 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1944,6 +1944,8 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
const char *finger_name)
{
g_autoptr(GError) error = NULL;
+ g_autoptr(FpPrint) existing_print = NULL;
+ g_autoptr(SessionData) session = NULL;
FprintDevice *rdev = FPRINT_DEVICE (dbus_dev);
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
FpFinger finger = finger_name_to_fp_finger (finger_name);
@@ -1962,6 +1964,20 @@ fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
return TRUE;
}
+ session = session_data_get (priv);
+ store.print_data_load (priv->dev, finger,
+ session->username, &existing_print);
+
+ if (existing_print)
+ {
+ g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_FINGER_ALREADY_ENROLLED,
+ "Finger %d has already been enrolled for user %s", finger, session->username);
+ g_dbus_method_invocation_return_gerror (invocation,
+ error);
+ return TRUE;
+ }
+
+
if (!can_start_action (rdev, &error))
{
g_dbus_method_invocation_return_gerror (invocation, error);
diff --git a/src/device.xml b/src/device.xml
index 362ee97..a3c1dbe 100644
--- a/src/device.xml
+++ b/src/device.xml
@@ -525,6 +525,7 @@
if the device was not claimed
if the device was already being used
if the finger name passed is invalid
+ if the finger has been already enrolled by the user
if there was an internal error
diff --git a/src/fprintd.h b/src/fprintd.h
index 1fd6d70..d6233a9 100644
--- a/src/fprintd.h
+++ b/src/fprintd.h
@@ -45,6 +45,8 @@ typedef enum {
FPRINT_ERROR_PERMISSION_DENIED, /*< nick=net.reactivated.Fprint.Error.PermissionDenied >*/
/* No prints are enrolled */
FPRINT_ERROR_NO_ENROLLED_PRINTS, /*< nick=net.reactivated.Fprint.Error.NoEnrolledPrints >*/
+ /* Prints has already been enrolled */
+ FPRINT_ERROR_FINGER_ALREADY_ENROLLED, /*< nick=net.reactivated.Fprint.Error.FingerAlreadyEnrolled >*/
/* No actions currently in progress */
FPRINT_ERROR_NO_ACTION_IN_PROGRESS, /*< nick=net.reactivated.Fprint.Error.NoActionInProgress >*/
/* the finger name passed was invalid */