Implement suspend/resume handling

This commit is contained in:
Benjamin Berg
2021-05-05 18:10:39 +02:00
parent 66e7df1105
commit 70182083a1
4 changed files with 372 additions and 1 deletions

View File

@ -475,6 +475,81 @@ _fprint_device_get_id (FprintDevice *rdev)
return priv->id;
}
static void
suspend_cb (GObject *source_obj,
GAsyncResult *res,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
GError *error = NULL;
fp_device_suspend_finish (FP_DEVICE (source_obj), res, &error);
if (error)
g_task_return_error (task, error);
else
g_task_return_boolean (task, TRUE);
}
static void
resume_cb (GObject *source_obj,
GAsyncResult *res,
gpointer user_data)
{
g_autoptr(GTask) task = user_data;
GError *error = NULL;
fp_device_resume_finish (FP_DEVICE (source_obj), res, &error);
if (error)
g_task_return_error (task, error);
else
g_task_return_boolean (task, TRUE);
}
void
fprint_device_suspend (FprintDevice *rdev,
GAsyncReadyCallback callback,
void *user_data)
{
GTask *task = NULL;
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
/* Just forward to libfprint. */
task = g_task_new (rdev, NULL, callback, user_data);
fp_device_suspend (priv->dev, NULL, suspend_cb, task);
}
void
fprint_device_resume (FprintDevice *rdev,
GAsyncReadyCallback callback,
void *user_data)
{
GTask *task = NULL;
FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev);
/* Just forward to libfprint. */
task = g_task_new (rdev, NULL, callback, user_data);
fp_device_resume (priv->dev, NULL, resume_cb, task);
}
void
fprint_device_suspend_finish (FprintDevice *rdev,
GAsyncResult *res,
GError **error)
{
g_task_propagate_boolean (G_TASK (res), error);
}
void
fprint_device_resume_finish (FprintDevice *rdev,
GAsyncResult *res,
GError **error)
{
g_task_propagate_boolean (G_TASK (res), error);
}
static const char *
fp_finger_to_name (FpFinger finger)
{