examples: Move discover_device function to utilities
While there are various functions which similar usage in all the examples, I'd prefer to keep each example to be self-containing most of the things. However some clearly repeated action can be moved to a single codebase.
This commit is contained in:
parent
ab804f7f49
commit
39e3e2b794
5 changed files with 17 additions and 37 deletions
|
@ -40,18 +40,6 @@ enroll_data_free (EnrollData *enroll_data)
|
|||
}
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (EnrollData, enroll_data_free)
|
||||
|
||||
FpDevice *discover_device (GPtrArray * devices)
|
||||
{
|
||||
FpDevice *dev;
|
||||
|
||||
if (!devices->len)
|
||||
return NULL;
|
||||
|
||||
dev = g_ptr_array_index (devices, 0);
|
||||
printf ("Found device claimed by %s driver\n", fp_device_get_driver (dev));
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_closed (FpDevice *dev, GAsyncResult *res, void *user_data)
|
||||
{
|
||||
|
|
|
@ -40,18 +40,6 @@ list_data_free (ListData *list_data)
|
|||
}
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ListData, list_data_free)
|
||||
|
||||
FpDevice *discover_device (GPtrArray * devices)
|
||||
{
|
||||
FpDevice *dev;
|
||||
|
||||
if (!devices->len)
|
||||
return NULL;
|
||||
|
||||
dev = g_ptr_array_index (devices, 0);
|
||||
g_print ("Found device claimed by %s driver\n", fp_device_get_driver (dev));
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_closed (FpDevice *dev,
|
||||
GAsyncResult *res,
|
||||
|
|
|
@ -23,6 +23,21 @@
|
|||
|
||||
#include "utilities.h"
|
||||
|
||||
FpDevice *
|
||||
discover_device (GPtrArray * devices)
|
||||
{
|
||||
FpDevice *dev;
|
||||
|
||||
if (!devices->len)
|
||||
return NULL;
|
||||
|
||||
dev = g_ptr_array_index (devices, 0);
|
||||
g_print ("Found device %s (%s) claimed by %s driver\n",
|
||||
fp_device_get_device_id (dev), fp_device_get_name (dev),
|
||||
fp_device_get_driver (dev));
|
||||
return dev;
|
||||
}
|
||||
|
||||
const char *
|
||||
finger_to_string (FpFinger finger)
|
||||
{
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#ifndef __UTILITIES_H
|
||||
#define __UTILITIES_H
|
||||
|
||||
FpDevice * discover_device (GPtrArray *devices);
|
||||
FpFinger finger_chooser (void);
|
||||
const char * finger_to_string (FpFinger finger);
|
||||
|
||||
|
|
|
@ -40,18 +40,6 @@ verify_data_free (VerifyData *verify_data)
|
|||
}
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (VerifyData, verify_data_free)
|
||||
|
||||
FpDevice *discover_device (GPtrArray * devices)
|
||||
{
|
||||
FpDevice *dev;
|
||||
|
||||
if (!devices->len)
|
||||
return NULL;
|
||||
|
||||
dev = g_ptr_array_index (devices, 0);
|
||||
printf ("Found device claimed by %s driver\n", fp_device_get_driver (dev));
|
||||
return dev;
|
||||
}
|
||||
|
||||
static void
|
||||
on_device_closed (FpDevice *dev, GAsyncResult *res, void *user_data)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue