mirror of
https://gitlab.com/mishakmak/pam-fprint-grosshack.git
synced 2026-04-08 20:03:34 +02: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:
32
src/device.c
32
src/device.c
@ -1198,6 +1198,23 @@ stoppable_action_completed (FprintDevice *rdev)
|
|||||||
g_clear_object (&priv->current_cancellable);
|
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
|
static void
|
||||||
match_cb (FpDevice *device,
|
match_cb (FpDevice *device,
|
||||||
FpPrint *match,
|
FpPrint *match,
|
||||||
@ -1457,12 +1474,7 @@ fprint_device_verify_stop (FprintDBusDevice *dbus_dev,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->current_cancel_invocation = invocation;
|
stoppable_action_stop (rdev, invocation);
|
||||||
if (priv->current_cancellable)
|
|
||||||
/* We return only when the action was cancelled */
|
|
||||||
g_cancellable_cancel (priv->current_cancellable);
|
|
||||||
else
|
|
||||||
stoppable_action_completed (rdev);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
@ -1774,15 +1786,11 @@ fprint_device_enroll_stop (FprintDBusDevice *dbus_dev,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->current_cancel_invocation = invocation;
|
stoppable_action_stop (rdev, invocation);
|
||||||
if (priv->current_cancellable)
|
|
||||||
/* We return only when the action was cancelled */
|
|
||||||
g_cancellable_cancel (priv->current_cancellable);
|
|
||||||
else
|
|
||||||
stoppable_action_completed (rdev);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
fprint_device_list_enrolled_fingers (FprintDBusDevice *dbus_dev,
|
fprint_device_list_enrolled_fingers (FprintDBusDevice *dbus_dev,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
|
|||||||
Reference in New Issue
Block a user