mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-09 12:23:34 +02:00
device: Use a switch to check current action so we can be more selective
For example we were allowing to verify stop while doing other actions different from enrolling (such as delete or open/close).
This commit is contained in:
committed by
Benjamin Berg
parent
c5c81a2ea8
commit
2ca2d5e62c
113
src/device.c
113
src/device.c
@ -1101,15 +1101,19 @@ static gboolean fprint_device_verify_start (FprintDBusDevice *dbus_dev,
|
|||||||
|
|
||||||
session = session_data_get (priv);
|
session = session_data_get (priv);
|
||||||
|
|
||||||
if (priv->current_action != ACTION_NONE) {
|
switch (priv->current_action) {
|
||||||
if (priv->current_action == ACTION_ENROLL) {
|
case ACTION_NONE:
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
break;
|
||||||
"Enrollment in progress");
|
case ACTION_VERIFY:
|
||||||
} else {
|
case ACTION_IDENTIFY:
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
"Verification already in progress");
|
"Verification already in progress");
|
||||||
}
|
return TRUE;
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
default:
|
||||||
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
|
"Another operation is already in progress");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1202,17 +1206,21 @@ static gboolean fprint_device_verify_stop (FprintDBusDevice *dbus_dev,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->current_action == ACTION_NONE) {
|
switch (priv->current_action) {
|
||||||
g_dbus_method_invocation_return_error_literal (invocation,
|
case ACTION_VERIFY:
|
||||||
FPRINT_ERROR,
|
case ACTION_IDENTIFY:
|
||||||
|
break;
|
||||||
|
case ACTION_NONE:
|
||||||
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR,
|
||||||
FPRINT_ERROR_NO_ACTION_IN_PROGRESS,
|
FPRINT_ERROR_NO_ACTION_IN_PROGRESS,
|
||||||
"No verification in progress");
|
"No verification in progress");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else if (priv->current_action == ACTION_ENROLL) {
|
default:
|
||||||
g_dbus_method_invocation_return_error_literal (invocation,
|
g_dbus_method_invocation_return_error_literal (
|
||||||
FPRINT_ERROR,
|
invocation, FPRINT_ERROR,
|
||||||
FPRINT_ERROR_ALREADY_IN_USE,
|
FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
"Enrollment in progress");
|
"Another operation is already in progress");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1423,15 +1431,18 @@ static gboolean fprint_device_enroll_start (FprintDBusDevice *dbus_dev,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->current_action != ACTION_NONE) {
|
switch (priv->current_action) {
|
||||||
if (priv->current_action == ACTION_ENROLL) {
|
case ACTION_NONE:
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
break;
|
||||||
|
case ACTION_ENROLL:
|
||||||
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
"Enrollment already in progress");
|
"Enrollment already in progress");
|
||||||
} else {
|
return TRUE;
|
||||||
g_set_error(&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
default:
|
||||||
"Verification in progress");
|
g_dbus_method_invocation_return_error_literal (
|
||||||
}
|
invocation, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
"Another operation is already in progress");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1467,19 +1478,20 @@ static gboolean fprint_device_enroll_stop (FprintDBusDevice *dbus_dev,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->current_action != ACTION_ENROLL) {
|
switch (priv->current_action) {
|
||||||
if (priv->current_action == ACTION_NONE) {
|
case ACTION_ENROLL:
|
||||||
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_NO_ACTION_IN_PROGRESS,
|
break;
|
||||||
|
case ACTION_NONE:
|
||||||
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR,
|
||||||
|
FPRINT_ERROR_NO_ACTION_IN_PROGRESS,
|
||||||
"No enrollment in progress");
|
"No enrollment in progress");
|
||||||
} else if (priv->current_action == ACTION_VERIFY) {
|
return TRUE;
|
||||||
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
default:
|
||||||
"Verification in progress");
|
g_dbus_method_invocation_return_error_literal (
|
||||||
} else if (priv->current_action == ACTION_IDENTIFY) {
|
invocation, FPRINT_ERROR,
|
||||||
g_set_error (&error, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
"Identification in progress");
|
"Another operation is already in progress");
|
||||||
} else
|
|
||||||
g_assert_not_reached ();
|
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1632,10 +1644,17 @@ static gboolean fprint_device_delete_enrolled_fingers (FprintDBusDevice *dbus_de
|
|||||||
log_offending_client (invocation);
|
log_offending_client (invocation);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (priv->current_action != ACTION_NONE) {
|
switch (priv->current_action) {
|
||||||
g_dbus_method_invocation_return_error_literal (invocation,
|
case ACTION_NONE:
|
||||||
FPRINT_ERROR,
|
break;
|
||||||
FPRINT_ERROR_ALREADY_IN_USE,
|
case ACTION_DELETE:
|
||||||
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
|
"Deletion already in progress");
|
||||||
|
return TRUE;
|
||||||
|
default:
|
||||||
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
"Another operation is already in progress");
|
"Another operation is already in progress");
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1690,12 +1709,18 @@ static gboolean fprint_device_delete_enrolled_fingers2 (FprintDBusDevice *dbus_d
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->current_action != ACTION_NONE) {
|
switch (priv->current_action) {
|
||||||
g_dbus_method_invocation_return_error_literal (invocation,
|
case ACTION_NONE:
|
||||||
FPRINT_ERROR,
|
break;
|
||||||
FPRINT_ERROR_ALREADY_IN_USE,
|
case ACTION_DELETE:
|
||||||
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
|
"Deletion already in progress");
|
||||||
|
return TRUE;
|
||||||
|
default:
|
||||||
|
g_dbus_method_invocation_return_error_literal (
|
||||||
|
invocation, FPRINT_ERROR, FPRINT_ERROR_ALREADY_IN_USE,
|
||||||
"Another operation is already in progress");
|
"Another operation is already in progress");
|
||||||
g_dbus_method_invocation_return_gerror (invocation, error);
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user