diff --git a/src/file_storage.c b/src/file_storage.c index 90c001d..c7278fb 100644 --- a/src/file_storage.c +++ b/src/file_storage.c @@ -254,6 +254,29 @@ GSList *file_storage_discover_prints(FpDevice *dev, const char *username) return list; } +GSList *file_storage_discover_users() +{ + g_autoptr(GError) err = NULL; + GSList *list = NULL; + const gchar *ent; + GDir *dir = g_dir_open(FILE_STORAGE_PATH, 0, &err); + + if (!dir) { + return list; + } + + while ((ent = g_dir_read_name(dir))) { + /* ent is a username */ + if (*ent == 0) + continue; + + list = g_slist_prepend(list, g_strdup (ent)); + } + + g_dir_close(dir); + return list; +} + int file_storage_init(void) { /* Nothing to do */ diff --git a/src/file_storage.h b/src/file_storage.h index 4d276fa..2209410 100644 --- a/src/file_storage.h +++ b/src/file_storage.h @@ -38,5 +38,6 @@ int file_storage_init(void); int file_storage_deinit(void); GSList *file_storage_discover_prints(FpDevice *dev, const char *username); +GSList *file_storage_discover_users(void); #endif diff --git a/src/main.c b/src/main.c index bd25a70..05184ea 100644 --- a/src/main.c +++ b/src/main.c @@ -46,6 +46,7 @@ set_storage_file (void) store.print_data_load = &file_storage_print_data_load; store.print_data_delete = &file_storage_print_data_delete; store.discover_prints = &file_storage_discover_prints; + store.discover_users = &file_storage_discover_users; } static gboolean diff --git a/src/storage.h b/src/storage.h index 6b8afc1..3819b87 100644 --- a/src/storage.h +++ b/src/storage.h @@ -31,6 +31,7 @@ typedef int (*storage_print_data_delete)(FpDevice *dev, FpFinger finger, const char *username); typedef GSList *(*storage_discover_prints)(FpDevice *dev, const char *username); +typedef GSList *(*storage_discover_users)(); typedef int (*storage_init)(void); typedef int (*storage_deinit)(void); @@ -41,6 +42,7 @@ struct storage { storage_print_data_load print_data_load; storage_print_data_delete print_data_delete; storage_discover_prints discover_prints; + storage_discover_users discover_users; }; typedef struct storage fp_storage;