Blame SOURCES/0030-fpi-ssm-Add-a-usb-transfer-callback-with-data-as-wea.patch

73b847
From 9902e2c4224914dc611eb2326db7322aa57ec2a2 Mon Sep 17 00:00:00 2001
73b847
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
73b847
Date: Wed, 27 Nov 2019 19:36:24 +0100
73b847
Subject: [PATCH 030/181] fpi-ssm: Add a usb transfer callback with data as
73b847
 weak pointer
73b847
73b847
Allow to pass a double-pointer to be nullified as the transfer data in order
73b847
to mark it as NULL when the transfer is done.
73b847
73b847
This is useful if we're keeping the transfer around in order to check that
73b847
no one is currently running.
73b847
---
73b847
 libfprint/fpi-ssm.c | 29 +++++++++++++++++++++++++++++
73b847
 libfprint/fpi-ssm.h |  6 +++++-
73b847
 2 files changed, 34 insertions(+), 1 deletion(-)
73b847
73b847
diff --git a/libfprint/fpi-ssm.c b/libfprint/fpi-ssm.c
73b847
index a614860..6a02a2c 100644
73b847
--- a/libfprint/fpi-ssm.c
73b847
+++ b/libfprint/fpi-ssm.c
73b847
@@ -413,3 +413,32 @@ fpi_ssm_usb_transfer_cb (FpiUsbTransfer *transfer, FpDevice *device,
73b847
   else
73b847
     fpi_ssm_next_state (transfer->ssm);
73b847
 }
73b847
+
73b847
+/**
73b847
+ * fpi_ssm_usb_transfer_with_weak_pointer_cb:
73b847
+ * @transfer: a #FpiUsbTransfer
73b847
+ * @device: a #FpDevice
73b847
+ * @weak_ptr: A #gpointer pointer to nullify. You can pass a pointer to any
73b847
+ *            #gpointer to nullify when the callback is completed. I.e a
73b847
+ *            pointer to the current #FpiUsbTransfer.
73b847
+ * @error: The #GError or %NULL
73b847
+ *
73b847
+ * Can be used in as a #FpiUsbTransfer callback handler to automatically
73b847
+ * advance or fail a statemachine on transfer completion.
73b847
+ * Passing a #gpointer* as @weak_ptr permits to nullify it once we're done
73b847
+ * with the transfer.
73b847
+ *
73b847
+ * Make sure to set the #FpiSsm on the transfer.
73b847
+ */
73b847
+void
73b847
+fpi_ssm_usb_transfer_with_weak_pointer_cb (FpiUsbTransfer *transfer,
73b847
+                                           FpDevice *device, gpointer weak_ptr,
73b847
+                                           GError *error)
73b847
+{
73b847
+  g_return_if_fail (transfer->ssm);
73b847
+
73b847
+  if (weak_ptr)
73b847
+    g_nullify_pointer ((gpointer *) weak_ptr);
73b847
+
73b847
+  fpi_ssm_usb_transfer_cb (transfer, device, weak_ptr, error);
73b847
+}
73b847
diff --git a/libfprint/fpi-ssm.h b/libfprint/fpi-ssm.h
73b847
index 8d45162..704271d 100644
73b847
--- a/libfprint/fpi-ssm.h
73b847
+++ b/libfprint/fpi-ssm.h
73b847
@@ -91,5 +91,9 @@ void fpi_ssm_next_state_timeout_cb (FpDevice *dev,
73b847
                                     void     *data);
73b847
 void fpi_ssm_usb_transfer_cb (FpiUsbTransfer *transfer,
73b847
                               FpDevice       *device,
73b847
-                              gpointer        user_data,
73b847
+                              gpointer        user_date,
73b847
                               GError         *error);
73b847
+void fpi_ssm_usb_transfer_with_weak_pointer_cb (FpiUsbTransfer *transfer,
73b847
+                                                FpDevice       *device,
73b847
+                                                gpointer        weak_ptr,
73b847
+                                                GError         *error);
73b847
-- 
73b847
2.24.1
73b847