|
|
73b847 |
From be367988ae4fc4d91d5cad7c9f7d47f67a878540 Mon Sep 17 00:00:00 2001
|
|
|
73b847 |
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
|
|
|
73b847 |
Date: Fri, 22 Nov 2019 13:51:16 +0100
|
|
|
73b847 |
Subject: [PATCH 019/181] fp-image-device: Add private "fp-image-device-state"
|
|
|
73b847 |
property
|
|
|
73b847 |
|
|
|
73b847 |
In this way drivers may get this without having to keep a copy of it
|
|
|
73b847 |
---
|
|
|
73b847 |
libfprint/fp-image-device.c | 44 +++++++++++++++++++++++++++++++++++++
|
|
|
73b847 |
1 file changed, 44 insertions(+)
|
|
|
73b847 |
|
|
|
73b847 |
diff --git a/libfprint/fp-image-device.c b/libfprint/fp-image-device.c
|
|
|
73b847 |
index 84b1bb0..3565b90 100644
|
|
|
73b847 |
--- a/libfprint/fp-image-device.c
|
|
|
73b847 |
+++ b/libfprint/fp-image-device.c
|
|
|
73b847 |
@@ -21,6 +21,7 @@
|
|
|
73b847 |
#include "fpi-log.h"
|
|
|
73b847 |
|
|
|
73b847 |
#include "fpi-image-device.h"
|
|
|
73b847 |
+#include "fpi-enums.h"
|
|
|
73b847 |
#include "fpi-print.h"
|
|
|
73b847 |
#include "fpi-image.h"
|
|
|
73b847 |
|
|
|
73b847 |
@@ -60,6 +61,13 @@ typedef struct
|
|
|
73b847 |
|
|
|
73b847 |
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (FpImageDevice, fp_image_device, FP_TYPE_DEVICE)
|
|
|
73b847 |
|
|
|
73b847 |
+enum {
|
|
|
73b847 |
+ PROP_0,
|
|
|
73b847 |
+ PROP_FPI_STATE,
|
|
|
73b847 |
+ N_PROPS
|
|
|
73b847 |
+};
|
|
|
73b847 |
+
|
|
|
73b847 |
+static GParamSpec *properties[N_PROPS];
|
|
|
73b847 |
|
|
|
73b847 |
/*******************************************************/
|
|
|
73b847 |
|
|
|
73b847 |
@@ -85,6 +93,7 @@ fp_image_device_change_state (FpImageDevice *self, FpImageDeviceState state)
|
|
|
73b847 |
fp_dbg ("Image device internal state change from %d to %d\n", priv->state, state);
|
|
|
73b847 |
|
|
|
73b847 |
priv->state = state;
|
|
|
73b847 |
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
|
|
|
73b847 |
|
|
|
73b847 |
/* change_state is the only callback which is optional and does not
|
|
|
73b847 |
* have a default implementation. */
|
|
|
73b847 |
@@ -103,6 +112,7 @@ fp_image_device_activate (FpImageDevice *self)
|
|
|
73b847 |
/* We don't have a neutral ACTIVE state, but we always will
|
|
|
73b847 |
* go into WAIT_FINGER_ON afterwards. */
|
|
|
73b847 |
priv->state = FP_IMAGE_DEVICE_STATE_AWAIT_FINGER_ON;
|
|
|
73b847 |
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
|
|
|
73b847 |
|
|
|
73b847 |
/* We might have been waiting for deactivation to finish before
|
|
|
73b847 |
* starting the next operation. */
|
|
|
73b847 |
@@ -127,6 +137,7 @@ fp_image_device_deactivate (FpDevice *device)
|
|
|
73b847 |
return;
|
|
|
73b847 |
}
|
|
|
73b847 |
priv->state = FP_IMAGE_DEVICE_STATE_INACTIVE;
|
|
|
73b847 |
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
|
|
|
73b847 |
|
|
|
73b847 |
fp_dbg ("Deactivating image device\n");
|
|
|
73b847 |
cls->deactivate (self);
|
|
|
73b847 |
@@ -295,6 +306,26 @@ fp_image_device_default_deactivate (FpImageDevice *self)
|
|
|
73b847 |
fpi_image_device_deactivate_complete (self, NULL);
|
|
|
73b847 |
}
|
|
|
73b847 |
|
|
|
73b847 |
+static void
|
|
|
73b847 |
+fp_image_device_get_property (GObject *object,
|
|
|
73b847 |
+ guint prop_id,
|
|
|
73b847 |
+ GValue *value,
|
|
|
73b847 |
+ GParamSpec *pspec)
|
|
|
73b847 |
+{
|
|
|
73b847 |
+ FpImageDevice *self = FP_IMAGE_DEVICE (object);
|
|
|
73b847 |
+ FpImageDevicePrivate *priv = fp_image_device_get_instance_private (self);
|
|
|
73b847 |
+
|
|
|
73b847 |
+ switch (prop_id)
|
|
|
73b847 |
+ {
|
|
|
73b847 |
+ case PROP_FPI_STATE:
|
|
|
73b847 |
+ g_value_set_enum (value, priv->state);
|
|
|
73b847 |
+ break;
|
|
|
73b847 |
+
|
|
|
73b847 |
+ default:
|
|
|
73b847 |
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
73b847 |
+ }
|
|
|
73b847 |
+}
|
|
|
73b847 |
+
|
|
|
73b847 |
static void
|
|
|
73b847 |
fp_image_device_class_init (FpImageDeviceClass *klass)
|
|
|
73b847 |
{
|
|
|
73b847 |
@@ -302,6 +333,7 @@ fp_image_device_class_init (FpImageDeviceClass *klass)
|
|
|
73b847 |
FpDeviceClass *fp_device_class = FP_DEVICE_CLASS (klass);
|
|
|
73b847 |
|
|
|
73b847 |
object_class->finalize = fp_image_device_finalize;
|
|
|
73b847 |
+ object_class->get_property = fp_image_device_get_property;
|
|
|
73b847 |
|
|
|
73b847 |
fp_device_class->open = fp_image_device_open;
|
|
|
73b847 |
fp_device_class->close = fp_image_device_close;
|
|
|
73b847 |
@@ -315,6 +347,16 @@ fp_image_device_class_init (FpImageDeviceClass *klass)
|
|
|
73b847 |
/* Default implementations */
|
|
|
73b847 |
klass->activate = fp_image_device_default_activate;
|
|
|
73b847 |
klass->deactivate = fp_image_device_default_deactivate;
|
|
|
73b847 |
+
|
|
|
73b847 |
+ properties[PROP_FPI_STATE] =
|
|
|
73b847 |
+ g_param_spec_enum ("fp-image-device-state",
|
|
|
73b847 |
+ "Image Device State",
|
|
|
73b847 |
+ "Private: The state of the image device",
|
|
|
73b847 |
+ FP_TYPE_IMAGE_DEVICE_STATE,
|
|
|
73b847 |
+ FP_IMAGE_DEVICE_STATE_INACTIVE,
|
|
|
73b847 |
+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE);
|
|
|
73b847 |
+
|
|
|
73b847 |
+ g_object_class_install_properties (object_class, N_PROPS, properties);
|
|
|
73b847 |
}
|
|
|
73b847 |
|
|
|
73b847 |
static void
|
|
|
73b847 |
@@ -760,6 +802,7 @@ fpi_image_device_open_complete (FpImageDevice *self, GError *error)
|
|
|
73b847 |
g_debug ("Image device open completed");
|
|
|
73b847 |
|
|
|
73b847 |
priv->state = FP_IMAGE_DEVICE_STATE_INACTIVE;
|
|
|
73b847 |
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
|
|
|
73b847 |
|
|
|
73b847 |
fpi_device_open_complete (FP_DEVICE (self), error);
|
|
|
73b847 |
}
|
|
|
73b847 |
@@ -785,6 +828,7 @@ fpi_image_device_close_complete (FpImageDevice *self, GError *error)
|
|
|
73b847 |
g_return_if_fail (action == FP_DEVICE_ACTION_CLOSE);
|
|
|
73b847 |
|
|
|
73b847 |
priv->state = FP_IMAGE_DEVICE_STATE_INACTIVE;
|
|
|
73b847 |
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_FPI_STATE]);
|
|
|
73b847 |
|
|
|
73b847 |
fpi_device_close_complete (FP_DEVICE (self), error);
|
|
|
73b847 |
}
|
|
|
73b847 |
--
|
|
|
73b847 |
2.24.1
|
|
|
73b847 |
|