mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2025-11-15 07:38:12 +00:00
examples/clear-storage: Cleanup code and use better error handling
This commit is contained in:
@@ -87,10 +87,10 @@ on_clear_storage_completed (FpDevice *dev, GAsyncResult *res, void *user_data)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int r = clear_saved_prints ();
|
if (!clear_saved_prints (&error))
|
||||||
if (r < 0)
|
|
||||||
{
|
{
|
||||||
g_warning ("Clear saved prints from local storage failed, code %d", r);
|
g_warning ("Clear saved prints from local storage failed: %s",
|
||||||
|
error->message);
|
||||||
clear_storage_data->ret_value = EXIT_FAILURE;
|
clear_storage_data->ret_value = EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -110,9 +110,11 @@ start_clear_storage (FpDevice *dev, ClearStorageData *clear_storage_data)
|
|||||||
|
|
||||||
g_print ("Clear device storage? [Y/n]? ");
|
g_print ("Clear device storage? [Y/n]? ");
|
||||||
if (fgets (buffer, sizeof (buffer), stdin) &&
|
if (fgets (buffer, sizeof (buffer), stdin) &&
|
||||||
(buffer[0] == 'Y' || buffer[0] == 'y' || buffer[0] == '\n'))
|
(buffer[0] == 'Y' || buffer[0] == 'y'))
|
||||||
{
|
{
|
||||||
fp_device_clear_storage (dev, clear_storage_data->cancellable, (GAsyncReadyCallback) on_clear_storage_completed, clear_storage_data);
|
fp_device_clear_storage (dev, clear_storage_data->cancellable,
|
||||||
|
(GAsyncReadyCallback) on_clear_storage_completed,
|
||||||
|
clear_storage_data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -209,10 +209,24 @@ gallery_data_load (FpDevice *dev)
|
|||||||
return gallery;
|
return gallery;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
gboolean
|
||||||
clear_saved_prints (void)
|
clear_saved_prints (GError **error)
|
||||||
{
|
{
|
||||||
return g_remove (STORAGE_FILE);
|
if (g_remove (STORAGE_FILE) < 0)
|
||||||
|
{
|
||||||
|
int errsv = errno;
|
||||||
|
|
||||||
|
g_set_error (error,
|
||||||
|
G_IO_ERROR,
|
||||||
|
g_io_error_from_errno (errsv),
|
||||||
|
"Error clearing storage file “%s”: %s",
|
||||||
|
STORAGE_FILE,
|
||||||
|
g_strerror (errsv));
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
FpPrint *
|
FpPrint *
|
||||||
|
|||||||
@@ -20,13 +20,16 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
#include <libfprint/fprint.h>
|
||||||
|
|
||||||
int print_data_save (FpPrint *print,
|
int print_data_save (FpPrint *print,
|
||||||
FpFinger finger,
|
FpFinger finger,
|
||||||
gboolean update_fingerprint);
|
gboolean update_fingerprint);
|
||||||
FpPrint * print_data_load (FpDevice *dev,
|
FpPrint * print_data_load (FpDevice *dev,
|
||||||
FpFinger finger);
|
FpFinger finger);
|
||||||
GPtrArray * gallery_data_load (FpDevice *dev);
|
GPtrArray * gallery_data_load (FpDevice *dev);
|
||||||
int clear_saved_prints (void);
|
gboolean clear_saved_prints (GError **error);
|
||||||
FpPrint * print_create_template (FpDevice *dev,
|
FpPrint * print_create_template (FpDevice *dev,
|
||||||
FpFinger finger,
|
FpFinger finger,
|
||||||
const gboolean load_existing);
|
const gboolean load_existing);
|
||||||
|
|||||||
Reference in New Issue
Block a user