Blame SOURCES/0064-fpi-ssm-Mark-a-fpi-ssm-completed-on-delay.patch

73b847
From 370137b97f53cec46750d2c984a3861d306bcb9d Mon Sep 17 00:00:00 2001
73b847
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
73b847
Date: Tue, 3 Dec 2019 17:22:20 +0100
73b847
Subject: [PATCH 064/181] fpi-ssm: Mark a fpi-ssm completed on delay
73b847
73b847
---
73b847
 libfprint/fpi-ssm.c | 40 ++++++++++++++++++++++++++++++++++++++++
73b847
 libfprint/fpi-ssm.h |  3 +++
73b847
 2 files changed, 43 insertions(+)
73b847
73b847
diff --git a/libfprint/fpi-ssm.c b/libfprint/fpi-ssm.c
73b847
index 4498ce9..09a31e3 100644
73b847
--- a/libfprint/fpi-ssm.c
73b847
+++ b/libfprint/fpi-ssm.c
73b847
@@ -349,6 +349,46 @@ fpi_ssm_mark_completed (FpiSsm *machine)
73b847
   fpi_ssm_free (machine);
73b847
 }
73b847
 
73b847
+static void
73b847
+on_device_timeout_complete (FpDevice *dev,
73b847
+                            gpointer  user_data)
73b847
+{
73b847
+  FpiSsm *machine = user_data;
73b847
+
73b847
+  machine->timeout = NULL;
73b847
+  fpi_ssm_mark_completed (machine);
73b847
+}
73b847
+
73b847
+/**
73b847
+ * fpi_ssm_mark_completed_delayed:
73b847
+ * @machine: an #FpiSsm state machine
73b847
+ * @delay: the milliseconds to wait before switching to the next state
73b847
+ * @cancellable: (nullable): a #GCancellable to cancel the delayed operation
73b847
+ *
73b847
+ * Mark a ssm as completed successfully with a delay of @delay ms.
73b847
+ * The callback set when creating the state machine with fpi_ssm_new () will be
73b847
+ * called when the timeout is over.
73b847
+ * The request can be cancelled passing a #GCancellable as @cancellable.
73b847
+ */
73b847
+void
73b847
+fpi_ssm_mark_completed_delayed (FpiSsm       *machine,
73b847
+                                int           delay,
73b847
+                                GCancellable *cancellable)
73b847
+{
73b847
+  g_autofree char *source_name = NULL;
73b847
+
73b847
+  g_return_if_fail (machine != NULL);
73b847
+
73b847
+  fpi_ssm_set_delayed_action_timeout (machine, delay,
73b847
+                                      on_device_timeout_complete, cancellable,
73b847
+                                      machine, NULL);
73b847
+
73b847
+  source_name = g_strdup_printf ("[%s] ssm %p complete %d",
73b847
+                                 fp_device_get_device_id (machine->dev),
73b847
+                                 machine, machine->cur_state + 1);
73b847
+  g_source_set_name (machine->timeout, source_name);
73b847
+}
73b847
+
73b847
 /**
73b847
  * fpi_ssm_mark_failed:
73b847
  * @machine: an #FpiSsm state machine
73b847
diff --git a/libfprint/fpi-ssm.h b/libfprint/fpi-ssm.h
73b847
index 8dff27d..3ef653e 100644
73b847
--- a/libfprint/fpi-ssm.h
73b847
+++ b/libfprint/fpi-ssm.h
73b847
@@ -82,6 +82,9 @@ void fpi_ssm_jump_to_state_delayed (FpiSsm       *machine,
73b847
                                     GCancellable *cancellable);
73b847
 void fpi_ssm_cancel_delayed_state_change (FpiSsm *machine);
73b847
 void fpi_ssm_mark_completed (FpiSsm *machine);
73b847
+void fpi_ssm_mark_completed_delayed (FpiSsm       *machine,
73b847
+                                     int           delay,
73b847
+                                     GCancellable *cancellable);
73b847
 void fpi_ssm_mark_failed (FpiSsm *machine,
73b847
                           GError *error);
73b847
 void fpi_ssm_set_data (FpiSsm        *machine,
73b847
-- 
73b847
2.24.1
73b847