1717 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818 */
1919
20+ #include "fpi-print.h"
2021#define FP_COMPONENT "image_device"
2122#include "fpi-log.h"
2223
3233 * This is a helper class for the commonly found image based devices.
3334 */
3435
35- G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (FpImageDevice , fp_image_device , FP_TYPE_DEVICE )
36+ G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (FpImageDevice , fp_image_device ,
37+ FP_TYPE_DEVICE )
3638
37- enum {
38- PROP_0 ,
39- PROP_FPI_STATE ,
40- N_PROPS
41- };
39+ enum { PROP_0 , PROP_FPI_STATE , N_PROPS };
4240
43- static GParamSpec * properties [N_PROPS ];
41+ static GParamSpec * properties [N_PROPS ];
4442
4543enum {
4644 FPI_STATE_CHANGED ,
4745
4846 LAST_SIGNAL
4947};
5048
51- static guint signals [LAST_SIGNAL ] = { 0 };
49+ static guint signals [LAST_SIGNAL ] = {0 };
5250
5351/*******************************************************/
5452
@@ -58,30 +56,30 @@ static guint signals[LAST_SIGNAL] = { 0 };
5856
5957/* Callbacks/vfuncs */
6058static void
61- fp_image_device_open (FpDevice * device )
59+ fp_image_device_open (FpDevice * device )
6260{
63- FpImageDeviceClass * cls = FP_IMAGE_DEVICE_GET_CLASS (device );
61+ FpImageDeviceClass * cls = FP_IMAGE_DEVICE_GET_CLASS (device );
6462
6563 /* Nothing special about opening an image device, just
6664 * forward the request. */
6765 cls -> img_open (FP_IMAGE_DEVICE (device ));
6866}
6967
7068static void
71- fp_image_device_close (FpDevice * device )
69+ fp_image_device_close (FpDevice * device )
7270{
73- FpImageDevice * self = FP_IMAGE_DEVICE (device );
74- FpImageDeviceClass * cls = FP_IMAGE_DEVICE_GET_CLASS (self );
75- FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
71+ FpImageDevice * self = FP_IMAGE_DEVICE (device );
72+ FpImageDeviceClass * cls = FP_IMAGE_DEVICE_GET_CLASS (self );
73+ FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
7674
7775 g_assert (priv -> active == FALSE);
7876 cls -> img_close (self );
7977}
8078
8179static void
82- fp_image_device_cancel_action (FpDevice * device )
80+ fp_image_device_cancel_action (FpDevice * device )
8381{
84- FpImageDevice * self = FP_IMAGE_DEVICE (device );
82+ FpImageDevice * self = FP_IMAGE_DEVICE (device );
8583 FpiDeviceAction action ;
8684
8785 action = fpi_device_get_current_action (device );
@@ -96,10 +94,10 @@ fp_image_device_cancel_action (FpDevice *device)
9694}
9795
9896static void
99- fp_image_device_start_capture_action (FpDevice * device )
97+ fp_image_device_start_capture_action (FpDevice * device )
10098{
101- FpImageDevice * self = FP_IMAGE_DEVICE (device );
102- FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
99+ FpImageDevice * self = FP_IMAGE_DEVICE (device );
100+ FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
103101 FpiDeviceAction action ;
104102 FpiPrintType print_type ;
105103
@@ -116,18 +114,17 @@ fp_image_device_start_capture_action (FpDevice *device)
116114
117115 if (!wait_for_finger )
118116 {
119- fpi_device_action_error (device , fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED ));
117+ fpi_device_action_error (
118+ device , fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED ));
120119 return ;
121120 }
122121 }
123122 else if (action == FPI_DEVICE_ACTION_ENROLL )
124123 {
125- FpPrint * enroll_print = NULL ;
124+ FpPrint * enroll_print = NULL ;
126125
127126 fpi_device_get_enroll_data (device , & enroll_print );
128- g_object_get (enroll_print , "fpi-type" , & print_type , NULL );
129- if (print_type != FPI_PRINT_NBIS )
130- fpi_print_set_type (enroll_print , FPI_PRINT_NBIS );
127+ fpi_print_set_type (enroll_print , priv -> algorithm );
131128 }
132129
133130 priv -> enroll_stage = 0 ;
@@ -140,40 +137,37 @@ fp_image_device_start_capture_action (FpDevice *device)
140137 fpi_image_device_activate (self );
141138}
142139
143-
144140/*********************************************************/
145141
146142static void
147- fp_image_device_finalize (GObject * object )
143+ fp_image_device_finalize (GObject * object )
148144{
149- FpImageDevice * self = (FpImageDevice * ) object ;
150- FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
145+ FpImageDevice * self = (FpImageDevice * ) object ;
146+ FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
151147
152148 g_assert (priv -> active == FALSE);
153149
154150 G_OBJECT_CLASS (fp_image_device_parent_class )-> finalize (object );
155151}
156152
157153static void
158- fp_image_device_default_activate (FpImageDevice * self )
154+ fp_image_device_default_activate (FpImageDevice * self )
159155{
160156 fpi_image_device_activate_complete (self , NULL );
161157}
162158
163159static void
164- fp_image_device_default_deactivate (FpImageDevice * self )
160+ fp_image_device_default_deactivate (FpImageDevice * self )
165161{
166162 fpi_image_device_deactivate_complete (self , NULL );
167163}
168164
169165static void
170- fp_image_device_get_property (GObject * object ,
171- guint prop_id ,
172- GValue * value ,
173- GParamSpec * pspec )
166+ fp_image_device_get_property (GObject * object , guint prop_id ,
167+ GValue * value , GParamSpec * pspec )
174168{
175- FpImageDevice * self = FP_IMAGE_DEVICE (object );
176- FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
169+ FpImageDevice * self = FP_IMAGE_DEVICE (object );
170+ FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
177171
178172 switch (prop_id )
179173 {
@@ -187,25 +181,28 @@ fp_image_device_get_property (GObject *object,
187181}
188182
189183static void
190- fp_image_device_constructed (GObject * obj )
184+ fp_image_device_constructed (GObject * obj )
191185{
192- FpImageDevice * self = FP_IMAGE_DEVICE (obj );
193- FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
194- FpImageDeviceClass * cls = FP_IMAGE_DEVICE_GET_CLASS (self );
186+ FpImageDevice * self = FP_IMAGE_DEVICE (obj );
187+ FpImageDevicePrivate * priv = fp_image_device_get_instance_private (self );
188+ FpImageDeviceClass * cls = FP_IMAGE_DEVICE_GET_CLASS (self );
195189
196190 /* Set default threshold. */
197191 priv -> bz3_threshold = BOZORTH3_DEFAULT_THRESHOLD ;
198192 if (cls -> bz3_threshold > 0 )
199193 priv -> bz3_threshold = cls -> bz3_threshold ;
194+ priv -> algorithm = FPI_PRINT_NBIS ;
195+ if (cls -> algorithm > 0 )
196+ priv -> algorithm = cls -> algorithm ;
200197
201198 G_OBJECT_CLASS (fp_image_device_parent_class )-> constructed (obj );
202199}
203200
204201static void
205- fp_image_device_class_init (FpImageDeviceClass * klass )
202+ fp_image_device_class_init (FpImageDeviceClass * klass )
206203{
207- GObjectClass * object_class = G_OBJECT_CLASS (klass );
208- FpDeviceClass * fp_device_class = FP_DEVICE_CLASS (klass );
204+ GObjectClass * object_class = G_OBJECT_CLASS (klass );
205+ FpDeviceClass * fp_device_class = FP_DEVICE_CLASS (klass );
209206
210207 object_class -> finalize = fp_image_device_finalize ;
211208 object_class -> get_property = fp_image_device_get_property ;
@@ -237,13 +234,11 @@ fp_image_device_class_init (FpImageDeviceClass *klass)
237234 *
238235 * Stability: private
239236 */
240- properties [PROP_FPI_STATE ] =
241- g_param_spec_enum ("fpi-image-device-state" ,
242- "Image Device State" ,
243- "Private: The state of the image device" ,
244- FPI_TYPE_IMAGE_DEVICE_STATE ,
245- FPI_IMAGE_DEVICE_STATE_INACTIVE ,
246- G_PARAM_STATIC_STRINGS | G_PARAM_READABLE );
237+ properties [PROP_FPI_STATE ] = g_param_spec_enum (
238+ "fpi-image-device-state" , "Image Device State" ,
239+ "Private: The state of the image device" , FPI_TYPE_IMAGE_DEVICE_STATE ,
240+ FPI_IMAGE_DEVICE_STATE_INACTIVE ,
241+ G_PARAM_STATIC_STRINGS | G_PARAM_READABLE );
247242
248243 /**
249244 * FpImageDevice::fpi-image-device-state-changed: (skip)
@@ -254,18 +249,15 @@ fp_image_device_class_init (FpImageDeviceClass *klass)
254249 *
255250 * Stability: private
256251 */
257- signals [FPI_STATE_CHANGED ] =
258- g_signal_new ("fpi-image-device-state-changed" ,
259- G_TYPE_FROM_CLASS (object_class ),
260- G_SIGNAL_RUN_FIRST ,
261- G_STRUCT_OFFSET (FpImageDeviceClass , change_state ),
262- NULL , NULL , NULL ,
263- G_TYPE_NONE , 1 , FPI_TYPE_IMAGE_DEVICE_STATE );
252+ signals [FPI_STATE_CHANGED ] = g_signal_new (
253+ "fpi-image-device-state-changed" , G_TYPE_FROM_CLASS (object_class ),
254+ G_SIGNAL_RUN_FIRST , G_STRUCT_OFFSET (FpImageDeviceClass , change_state ),
255+ NULL , NULL , NULL , G_TYPE_NONE , 1 , FPI_TYPE_IMAGE_DEVICE_STATE );
264256
265257 g_object_class_install_properties (object_class , N_PROPS , properties );
266258}
267259
268260static void
269- fp_image_device_init (FpImageDevice * self )
261+ fp_image_device_init (FpImageDevice * self )
270262{
271263}
0 commit comments