libfprint/SOURCES/0103-fp-device-Add-a-open-property-and-method-to-check-it.patch

106 lines
3.2 KiB
Diff
Raw Normal View History

2020-04-23 23:55:43 +00:00
From 5d29acf713a925bc3c97a2359ca5220f50a0c0be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
Date: Thu, 5 Dec 2019 15:05:59 +0100
Subject: [PATCH 103/181] fp-device: Add a "open" property and method to check
its state
---
libfprint/fp-device.c | 33 ++++++++++++++++++++++++++++++++-
libfprint/fp-device.h | 1 +
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/libfprint/fp-device.c b/libfprint/fp-device.c
index 08023f2..91a3aae 100644
--- a/libfprint/fp-device.c
+++ b/libfprint/fp-device.c
@@ -88,6 +88,7 @@ enum {
PROP_DRIVER,
PROP_DEVICE_ID,
PROP_NAME,
+ PROP_OPEN,
PROP_NR_ENROLL_STAGES,
PROP_SCAN_TYPE,
PROP_FPI_ENVIRON,
@@ -417,6 +418,10 @@ fp_device_get_property (GObject *object,
g_value_set_string (value, priv->device_name);
break;
+ case PROP_OPEN:
+ g_value_set_boolean (value, priv->is_open);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
@@ -551,6 +556,12 @@ fp_device_class_init (FpDeviceClass *klass)
NULL,
G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
+ properties[PROP_OPEN] =
+ g_param_spec_boolean ("open",
+ "Opened",
+ "Wether the device is open or not", FALSE,
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
+
properties[PROP_FPI_ENVIRON] =
g_param_spec_string ("fp-environ",
"Virtual Environment",
@@ -628,6 +639,22 @@ fp_device_get_name (FpDevice *device)
return priv->device_name;
}
+/**
+ * fp_device_is_open:
+ * @device: A #FpDevice
+ *
+ * Returns: Whether the device is open or not
+ */
+gboolean
+fp_device_is_open (FpDevice *device)
+{
+ FpDevicePrivate *priv = fp_device_get_instance_private (device);
+
+ g_return_val_if_fail (FP_IS_DEVICE (device), FALSE);
+
+ return priv->is_open;
+}
+
/**
* fp_device_get_scan_type:
* @device: A #FpDevice
@@ -1959,7 +1986,10 @@ fpi_device_open_complete (FpDevice *device, GError *error)
clear_device_cancel_action (device);
if (!error)
- priv->is_open = TRUE;
+ {
+ priv->is_open = TRUE;
+ g_object_notify_by_pspec (G_OBJECT (device), properties[PROP_OPEN]);
+ }
if (!error)
fp_device_return_task_in_idle (device, FP_DEVICE_TASK_RETURN_BOOL,
@@ -1988,6 +2018,7 @@ fpi_device_close_complete (FpDevice *device, GError *error)
clear_device_cancel_action (device);
priv->is_open = FALSE;
+ g_object_notify_by_pspec (G_OBJECT (device), properties[PROP_OPEN]);
switch (priv->type)
{
diff --git a/libfprint/fp-device.h b/libfprint/fp-device.h
index a15fc30..4f7acac 100644
--- a/libfprint/fp-device.h
+++ b/libfprint/fp-device.h
@@ -129,6 +129,7 @@ typedef void (*FpEnrollProgress) (FpDevice *device,
const gchar *fp_device_get_driver (FpDevice *device);
const gchar *fp_device_get_device_id (FpDevice *device);
const gchar *fp_device_get_name (FpDevice *device);
+gboolean fp_device_is_open (FpDevice *device);
FpScanType fp_device_get_scan_type (FpDevice *device);
gint fp_device_get_nr_enroll_stages (FpDevice *device);
--
2.24.1