[gnome-keyring] gcr: Properly get labels from the parser into the importer
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] gcr: Properly get labels from the parser into the importer
- Date: Wed, 5 Oct 2011 09:04:17 +0000 (UTC)
commit d675e4836fe0fd79f08f6f0bee9d64c1c1786fb9
Author: Stef Walter <stefw collabora co uk>
Date: Wed Oct 5 11:03:18 2011 +0200
gcr: Properly get labels from the parser into the importer
* Pull in the labels seen by the parser, but not in the attributes
* Fix issues supplementing when no login is required
gcr/gcr-pkcs11-import-interaction.c | 25 +++++++++++++------------
gcr/gcr-pkcs11-importer.c | 8 +++++++-
gcr/gcr-pkcs11-importer.h | 1 +
3 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/gcr/gcr-pkcs11-import-interaction.c b/gcr/gcr-pkcs11-import-interaction.c
index ee592e1..e9a1833 100644
--- a/gcr/gcr-pkcs11-import-interaction.c
+++ b/gcr/gcr-pkcs11-import-interaction.c
@@ -161,6 +161,16 @@ on_dialog_run_async (GObject *source,
gpointer user_data)
{
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
+ GckAttributes *attributes = g_simple_async_result_get_op_res_gpointer (res);
+
+ if (_gcr_pkcs11_import_dialog_run_finish (GCR_PKCS11_IMPORT_DIALOG (source), result)) {
+ _gcr_pkcs11_import_dialog_get_supplements (GCR_PKCS11_IMPORT_DIALOG (source), attributes);
+
+ } else {
+ g_simple_async_result_set_error (res, G_IO_ERROR, G_IO_ERROR_CANCELLED,
+ _("The user cancelled the operation"));
+ }
+
g_simple_async_result_complete (res);
g_object_unref (res);
}
@@ -201,25 +211,16 @@ _gcr_pkcs11_import_interaction_supplement_finish (GcrImportInteraction *interact
GError **error)
{
GcrPkcs11ImportInteraction *self = GCR_PKCS11_IMPORT_INTERACTION (interaction);
- GckAttributes *attributes;
g_return_val_if_fail (self->dialog != NULL, G_TLS_INTERACTION_UNHANDLED);
g_return_val_if_fail (g_simple_async_result_is_valid (result, G_OBJECT (interaction),
_gcr_pkcs11_import_interaction_supplement_async), G_TLS_INTERACTION_UNHANDLED);
- attributes = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (result));
+ if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (result), error))
+ return G_TLS_INTERACTION_FAILED;
- /* Didn't show the dialog */
- if (attributes == NULL)
- return G_TLS_INTERACTION_HANDLED;
+ return G_TLS_INTERACTION_HANDLED;
- if (_gcr_pkcs11_import_dialog_run_finish (self->dialog, result)) {
- _gcr_pkcs11_import_dialog_get_supplements (self->dialog, attributes);
- return G_TLS_INTERACTION_HANDLED;
- } else {
- g_set_error (error, G_IO_ERROR, G_IO_ERROR_CANCELLED, _("The user cancelled the operation"));
- return G_TLS_INTERACTION_FAILED;
- }
}
static void
diff --git a/gcr/gcr-pkcs11-importer.c b/gcr/gcr-pkcs11-importer.c
index 15ea88f..fbe537c 100644
--- a/gcr/gcr-pkcs11-importer.c
+++ b/gcr/gcr-pkcs11-importer.c
@@ -801,9 +801,11 @@ _gcr_pkcs11_importer_queue_for_parsed (GcrImporter *importer,
{
GcrPkcs11Importer *self = GCR_PKCS11_IMPORTER (importer);
GckAttributes *attrs;
+ const gchar *label;
attrs = gcr_parsed_get_attributes (parsed);
- _gcr_pkcs11_importer_queue (self, attrs);
+ label = gcr_parsed_get_label (parsed);
+ _gcr_pkcs11_importer_queue (self, label, attrs);
return TRUE;
}
@@ -894,10 +896,14 @@ _gcr_pkcs11_importer_get_queued (GcrPkcs11Importer *self)
void
_gcr_pkcs11_importer_queue (GcrPkcs11Importer *self,
+ const gchar *label,
GckAttributes *attrs)
{
g_return_if_fail (GCR_IS_PKCS11_IMPORTER (self));
g_return_if_fail (attrs != NULL);
+ if (label != NULL && !gck_attributes_find (attrs, CKA_LABEL))
+ gck_attributes_add_string (attrs, CKA_LABEL, label);
+
g_queue_push_tail (self->queue, gck_attributes_ref (attrs));
}
diff --git a/gcr/gcr-pkcs11-importer.h b/gcr/gcr-pkcs11-importer.h
index a1e47f2..5f66f7b 100644
--- a/gcr/gcr-pkcs11-importer.h
+++ b/gcr/gcr-pkcs11-importer.h
@@ -48,6 +48,7 @@ GType _gcr_pkcs11_importer_get_type (void);
GcrImporter * _gcr_pkcs11_importer_new (GckSlot *slot);
void _gcr_pkcs11_importer_queue (GcrPkcs11Importer *self,
+ const gchar *label,
GckAttributes *attrs);
GckSlot * _gcr_pkcs11_importer_get_slot (GcrPkcs11Importer *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]