[seahorse] pkcs11: Show errors for unlock/lock failures
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] pkcs11: Show errors for unlock/lock failures
- Date: Fri, 9 Dec 2011 14:39:05 +0000 (UTC)
commit 0b2b7da7b1b767ef12d63785f8dbade459734716
Author: Stef Walter <stefw collabora co uk>
Date: Fri Dec 9 15:38:42 2011 +0100
pkcs11: Show errors for unlock/lock failures
* And ignore some relevant errors
pkcs11/seahorse-pkcs11-actions.c | 32 +++++++++++++++++++++++---------
1 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/pkcs11/seahorse-pkcs11-actions.c b/pkcs11/seahorse-pkcs11-actions.c
index dcabea4..ebbc152 100644
--- a/pkcs11/seahorse-pkcs11-actions.c
+++ b/pkcs11/seahorse-pkcs11-actions.c
@@ -58,14 +58,18 @@ on_token_locked (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
+ GtkWindow *window = GTK_WINDOW (user_data);
GError *error = NULL;
seahorse_token_lock_finish (SEAHORSE_TOKEN (source), result, &error);
if (error != NULL) {
- if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
- g_warning ("couldn't unlock token: %s", error->message);
- g_error_free (error);
+ if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
+ !g_error_matches (error, GCK_ERROR, CKR_USER_NOT_LOGGED_IN))
+ seahorse_util_handle_error (&error, window, _("Couldn't unlock"));
+ g_clear_error (&error);
}
+
+ g_object_unref (window);
}
static void
@@ -73,10 +77,14 @@ on_token_lock (GtkAction *action,
gpointer user_data)
{
GTlsInteraction *interaction;
+ GtkWindow *window;
+
+ window = seahorse_action_get_window (action);
+ interaction = seahorse_interaction_new (window);
- interaction = seahorse_interaction_new (seahorse_action_get_window (action));
seahorse_token_lock_async (SEAHORSE_TOKEN (user_data), interaction, NULL,
- on_token_locked, NULL);
+ on_token_locked, g_object_ref (window));
+
g_object_unref (interaction);
}
@@ -86,14 +94,20 @@ on_token_unlocked (GObject *source,
GAsyncResult *result,
gpointer user_data)
{
+ GtkWindow *window = GTK_WINDOW (user_data);
GError *error = NULL;
seahorse_token_unlock_finish (SEAHORSE_TOKEN (source), result, &error);
if (error != NULL) {
- if (!g_error_matches (error, GCK_ERROR, CKR_FUNCTION_CANCELED))
- g_warning ("couldn't unlock token: %s", error->message);
- g_error_free (error);
+ if (!g_error_matches (error, GCK_ERROR, CKR_FUNCTION_CANCELED) ||
+ !g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED) ||
+ !g_error_matches (error, GCK_ERROR, CKR_USER_NOT_LOGGED_IN) ||
+ !g_error_matches (error, GCK_ERROR, CKR_USER_ALREADY_LOGGED_IN))
+ seahorse_util_handle_error (&error, window, _("Couldn't unlock"));
+ g_clear_error (&error);
}
+
+ g_object_unref (window);
}
static void
@@ -107,7 +121,7 @@ on_token_unlock (GtkAction *action,
interaction = seahorse_interaction_new (window);
seahorse_token_unlock_async (SEAHORSE_TOKEN (user_data), interaction, NULL,
- on_token_unlocked, NULL);
+ on_token_unlocked, g_object_ref (window));
g_object_unref (interaction);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]