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

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