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