[gcr] gcr: Add uris to GcrImporter
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcr] gcr: Add uris to GcrImporter
- Date: Tue, 13 Dec 2011 19:06:06 +0000 (UTC)
commit 4ed60e05c20a644a794bf5b6de62f2899ce8d0ec
Author: Stef Walter <stefw collabora co uk>
Date: Tue Dec 13 20:05:43 2011 +0100
gcr: Add uris to GcrImporter
* This allows us to refresh the appropriate place in seahorse
gcr/gcr-gnupg-importer.c | 21 ++++++++++++++++++---
gcr/gcr-importer.c | 9 +++++++++
gcr/gcr-pkcs11-importer.c | 24 +++++++++++++++++++++---
3 files changed, 48 insertions(+), 6 deletions(-)
---
diff --git a/gcr/gcr-gnupg-importer.c b/gcr/gcr-gnupg-importer.c
index 9e78b2a..ef1c9ec 100644
--- a/gcr/gcr-gnupg-importer.c
+++ b/gcr/gcr-gnupg-importer.c
@@ -35,7 +35,8 @@ enum {
PROP_ICON,
PROP_IMPORTED,
PROP_DIRECTORY,
- PROP_INTERACTION
+ PROP_INTERACTION,
+ PROP_URI
};
struct _GcrGnupgImporterPrivate {
@@ -109,6 +110,18 @@ calculate_icon (GcrGnupgImporter *self)
return g_themed_icon_new ("folder");
}
+static gchar *
+calculate_uri (GcrGnupgImporter *self)
+{
+ const gchar *directory;
+
+ directory = _gcr_gnupg_process_get_directory (self->pv->process);
+ if (directory == NULL)
+ return g_strdup ("gnupg://");
+ else
+ return g_strdup_printf ("gnupg://%s", directory);
+}
+
static gboolean
on_process_error_line (GcrGnupgProcess *process,
const gchar *line,
@@ -203,6 +216,9 @@ _gcr_gnupg_importer_get_property (GObject *obj,
case PROP_INTERACTION:
g_value_set_object (value, self->pv->interaction);
break;
+ case PROP_URI:
+ g_value_take_string (value, calculate_uri (self));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -223,10 +239,9 @@ _gcr_gnupg_importer_class_init (GcrGnupgImporterClass *klass)
g_type_class_add_private (gobject_class, sizeof (GcrGnupgImporterPrivate));
g_object_class_override_property (gobject_class, PROP_LABEL, "label");
-
g_object_class_override_property (gobject_class, PROP_ICON, "icon");
-
g_object_class_override_property (gobject_class, PROP_INTERACTION, "interaction");
+ g_object_class_override_property (gobject_class, PROP_URI, "uri");
g_object_class_install_property (gobject_class, PROP_IMPORTED,
g_param_spec_boxed ("imported", "Imported", "Fingerprints of imported keys",
diff --git a/gcr/gcr-importer.c b/gcr/gcr-importer.c
index 0e4a784..4060065 100644
--- a/gcr/gcr-importer.c
+++ b/gcr/gcr-importer.c
@@ -121,6 +121,15 @@ gcr_importer_default_init (GcrImporterIface *iface)
"Interaction for prompts",
G_TYPE_TLS_INTERACTION, G_PARAM_READWRITE));
+ /**
+ * GcrImporter:uri:
+ *
+ * The URI of the location imported to.
+ */
+ g_object_interface_install_property (iface,
+ g_param_spec_string ("uri", "URI", "URI of location",
+ NULL, G_PARAM_READABLE));
+
g_once_init_leave (&initialized, 1);
}
}
diff --git a/gcr/gcr-pkcs11-importer.c b/gcr/gcr-pkcs11-importer.c
index 6a9a53a..5c5367e 100644
--- a/gcr/gcr-pkcs11-importer.c
+++ b/gcr/gcr-pkcs11-importer.c
@@ -50,7 +50,8 @@ enum {
PROP_INTERACTION,
PROP_SLOT,
PROP_IMPORTED,
- PROP_QUEUED
+ PROP_QUEUED,
+ PROP_URI
};
typedef struct _GcrPkcs11ImporterClass GcrPkcs11ImporterClass;
@@ -647,6 +648,21 @@ calculate_icon (GcrPkcs11Importer *self,
return result;
}
+static gchar *
+calculate_uri (GcrPkcs11Importer *self)
+{
+ GckUriData *data;
+ gchar *uri;
+
+ data = gck_uri_data_new ();
+ data->token_info = gck_slot_get_token_info (self->slot);
+ uri = gck_uri_build (data, GCK_URI_FOR_TOKEN);
+ data->token_info = NULL;
+ gck_uri_data_free (data);
+
+ return uri;
+}
+
static void
_gcr_pkcs11_importer_get_property (GObject *obj,
guint prop_id,
@@ -674,6 +690,9 @@ _gcr_pkcs11_importer_get_property (GObject *obj,
case PROP_INTERACTION:
g_value_set_object (value, self->interaction);
break;
+ case PROP_URI:
+ g_value_take_string (value, calculate_uri (self));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, prop_id, pspec);
break;
@@ -692,10 +711,9 @@ _gcr_pkcs11_importer_class_init (GcrPkcs11ImporterClass *klass)
gobject_class->get_property = _gcr_pkcs11_importer_get_property;
g_object_class_override_property (gobject_class, PROP_LABEL, "label");
-
g_object_class_override_property (gobject_class, PROP_ICON, "icon");
-
g_object_class_override_property (gobject_class, PROP_INTERACTION, "interaction");
+ g_object_class_override_property (gobject_class, PROP_URI, "uri");
g_object_class_install_property (gobject_class, PROP_SLOT,
g_param_spec_object ("slot", "Slot", "PKCS#11 slot to import data into",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]