diff options
author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2021-03-02 16:01:46 +0100 |
---|---|---|
committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2021-03-03 20:15:54 +0100 |
commit | b5b389a831845fa807c21c396ebf7f07403533c1 (patch) | |
tree | c75494d0687c5d93f6d25d0f73cd2a4d09d919f5 | |
parent | 3e0c69fec93000f63ba8e0caab32facad2f2b1f1 (diff) |
device: Add utility function to load all user prints
We may want to be able to load the user prints to check whether they
are usable, so add an utility function for this.
And use it also in load_all_prints().
-rw-r--r-- | src/device.c | 50 |
1 files changed, 31 insertions, 19 deletions
diff --git a/src/device.c b/src/device.c index cac3322..63c408d 100644 --- a/src/device.c +++ b/src/device.c @@ -1030,36 +1030,48 @@ fprint_device_release (FprintDBusDevice *dbus_dev, /* NOTE: This should probably be moved to the storage layer. */ static GPtrArray * -load_all_prints (FprintDevice *rdev) +load_user_prints (FprintDevice *rdev, + const char *username) { g_autoptr(GPtrArray) res = g_ptr_array_new_with_free_func (g_object_unref); + g_autoptr(GSList) fingers = NULL; FprintDevicePrivate *priv = fprint_device_get_instance_private (rdev); - GSList *user, *users = NULL; + GSList *l; - users = store.discover_users (); + fingers = store.discover_prints (priv->dev, username); - for (user = users; user; user = user->next) + for (l = fingers; l; l = l->next) { - const char *username = user->data; - g_autoptr(GSList) fingers = NULL; - GSList *finger; + g_autoptr(FpPrint) print = NULL; - fingers = store.discover_prints (priv->dev, username); + store.print_data_load (priv->dev, + GPOINTER_TO_UINT (l->data), + username, + &print); - for (finger = fingers; finger; finger = finger->next) - { - g_autoptr(FpPrint) print = NULL; + if (!print) + continue; - store.print_data_load (priv->dev, - GPOINTER_TO_UINT (finger->data), - username, - &print); + g_ptr_array_add (res, g_steal_pointer (&print)); + } - if (!print) - continue; + return g_steal_pointer (&res); +} - g_ptr_array_add (res, g_steal_pointer (&print)); - } +static GPtrArray * +load_all_prints (FprintDevice *rdev) +{ + g_autoptr(GPtrArray) res = g_ptr_array_new_with_free_func (g_object_unref); + GSList *user, *users = NULL; + + users = store.discover_users (); + + for (user = users; user; user = user->next) + { + const char *username = user->data; + g_autoptr(GPtrArray) prints = load_user_prints (rdev, username); + + g_ptr_array_extend_and_steal (res, g_steal_pointer (&prints)); } g_slist_free_full (users, g_free); |