mirror of
https://gitlab.freedesktop.org/libfprint/fprintd.git
synced 2026-01-28 01:20:30 +01:00
device: Move duplicated code for stopping a stoppable action into a function
We can handle this in a generic way for all the cancellable cases.
This commit is contained in:
parent
56436fb8b1
commit
ff798edc51
1 changed files with 20 additions and 12 deletions
32
src/device.c
32
src/device.c
|
|
@ -1198,6 +1198,23 @@ stoppable_action_completed (FprintDevice *rdev)
|
|||
g_clear_object (&priv->current_cancellable);
|
||||
}
|
||||
|
||||
static void
|
||||
stoppable_action_stop (FprintDevice *rdev,
|
||||
GDBusMethodInvocation *invocation)
|
||||
{
|
||||
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
|
||||
|
||||
g_assert (priv->current_cancel_invocation == NULL);
|
||||
|
||||
priv->current_cancel_invocation = invocation;
|
||||
|
||||
/* We return only when the action was cancelled */
|
||||
if (priv->current_cancellable)
|
||||
g_cancellable_cancel (priv->current_cancellable);
|
||||
else
|
||||
stoppable_action_completed (rdev);
|
||||
}
|
||||
|
||||
static void
|
||||
match_cb (FpDevice *device,
|
||||
FpPrint *match,
|
||||
|
|
@ -1457,12 +1474,7 @@ fprint_device_verify_stop (FprintDBusDevice *dbus_dev,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
priv->current_cancel_invocation = invocation;
|
||||
if (priv->current_cancellable)
|
||||
/* We return only when the action was cancelled */
|
||||
g_cancellable_cancel (priv->current_cancellable);
|
||||
else
|
||||
stoppable_action_completed (rdev);
|
||||
stoppable_action_stop (rdev, invocation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
@ -1774,15 +1786,11 @@ fprint_device_enroll_stop (FprintDBusDevice *dbus_dev,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
priv->current_cancel_invocation = invocation;
|
||||
if (priv->current_cancellable)
|
||||
/* We return only when the action was cancelled */
|
||||
g_cancellable_cancel (priv->current_cancellable);
|
||||
else
|
||||
stoppable_action_completed (rdev);
|
||||
stoppable_action_stop (rdev, invocation);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
fprint_device_list_enrolled_fingers (FprintDBusDevice *dbus_dev,
|
||||
GDBusMethodInvocation *invocation,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue