[seahorse] Update for changes in libgck
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [seahorse] Update for changes in libgck
- Date: Thu, 8 Dec 2011 20:50:21 +0000 (UTC)
commit d0458f05153837bf1f9ef298c8d13fdbeaa6b204
Author: Stef Walter <stefw collabora co uk>
Date: Thu Dec 8 21:37:48 2011 +0100
Update for changes in libgck
* In particular the GckBuilder change and GckObjectCache
* Depend on gck version 3.3.3
configure.ac | 4 +-
pkcs11/seahorse-certificate.c | 30 +++++++++++++++++----
pkcs11/seahorse-pkcs11-generate.c | 51 +++++++++++++++++++-----------------
pkcs11/seahorse-private-key.c | 28 ++++++++++++++++---
pkcs11/seahorse-token.c | 34 +++++++++++-------------
5 files changed, 91 insertions(+), 56 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 1aa5014..399a6a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,8 +3,8 @@ AC_INIT([seahorse], [3.3.2],
[http://bugzilla.gnome.org/enter_bug.cgi?product=seahorse],
[seahorse])
-GCK_REQUIRED=3.1.2
-GCR_REQUIRED=3.1.5
+GCK_REQUIRED=3.3.3
+GCR_REQUIRED=3.3.3
GTK_REQUIRED=2.90.0
GNUPG_ACCEPTED="1.2 1.4 2.0"
GPGME_REQUIRED=1.0.0
diff --git a/pkcs11/seahorse-certificate.c b/pkcs11/seahorse-certificate.c
index 2fc470c..e828d41 100644
--- a/pkcs11/seahorse-certificate.c
+++ b/pkcs11/seahorse-certificate.c
@@ -68,7 +68,7 @@ enum {
struct _SeahorseCertificatePrivate {
SeahorseToken *token;
GckAttributes *attributes;
- GckAttribute *value;
+ const GckAttribute *value;
GtkActionGroup *actions;
SeahorsePrivateKey *private_key;
GIcon *icon;
@@ -77,7 +77,7 @@ struct _SeahorseCertificatePrivate {
static void seahorse_certificate_certificate_iface (GcrCertificateIface *iface);
-static void seahorse_certificate_object_attributes_iface (GckObjectAttributesIface *iface);
+static void seahorse_certificate_object_cache_iface (GckObjectCacheIface *iface);
static void seahorse_certificate_deletable_iface (SeahorseDeletableIface *iface);
@@ -86,7 +86,7 @@ static void seahorse_certificate_exportable_iface (SeahorseExportab
G_DEFINE_TYPE_WITH_CODE (SeahorseCertificate, seahorse_certificate, GCK_TYPE_OBJECT,
GCR_CERTIFICATE_MIXIN_IMPLEMENT_COMPARABLE ();
G_IMPLEMENT_INTERFACE (GCR_TYPE_CERTIFICATE, seahorse_certificate_certificate_iface);
- G_IMPLEMENT_INTERFACE (GCK_TYPE_OBJECT_ATTRIBUTES, seahorse_certificate_object_attributes_iface);
+ G_IMPLEMENT_INTERFACE (GCK_TYPE_OBJECT_CACHE, seahorse_certificate_object_cache_iface);
G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_DELETABLE, seahorse_certificate_deletable_iface);
G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_EXPORTABLE, seahorse_certificate_exportable_iface);
);
@@ -329,10 +329,28 @@ seahorse_certificate_certificate_iface (GcrCertificateIface *iface)
}
static void
-seahorse_certificate_object_attributes_iface (GckObjectAttributesIface *iface)
+seahorse_certificate_fill (GckObjectCache *object,
+ GckAttributes *attributes)
{
- iface->attribute_types = REQUIRED_ATTRS;
- iface->n_attribute_types = G_N_ELEMENTS (REQUIRED_ATTRS);
+ SeahorseCertificate *self = SEAHORSE_CERTIFICATE (object);
+ GckBuilder builder = GCK_BUILDER_INIT;
+
+ if (self->pv->attributes)
+ gck_builder_add_all (&builder, self->pv->attributes);
+ gck_builder_set_all (&builder, attributes);
+ gck_attributes_unref (self->pv->attributes);
+ self->pv->attributes = gck_builder_steal (&builder);
+ gck_builder_clear (&builder);
+
+ g_object_notify (G_OBJECT (object), "attributes");
+}
+
+static void
+seahorse_certificate_object_cache_iface (GckObjectCacheIface *iface)
+{
+ iface->default_types = REQUIRED_ATTRS;
+ iface->n_default_types = G_N_ELEMENTS (REQUIRED_ATTRS);
+ iface->fill = seahorse_certificate_fill;
}
static GList *
diff --git a/pkcs11/seahorse-pkcs11-generate.c b/pkcs11/seahorse-pkcs11-generate.c
index f78abea..9e422e2 100644
--- a/pkcs11/seahorse-pkcs11-generate.c
+++ b/pkcs11/seahorse-pkcs11-generate.c
@@ -127,46 +127,49 @@ static void
prepare_generate (SeahorsePkcs11Generate *self)
{
CK_BYTE rsa_public_exponent[] = { 0x01, 0x00, 0x01 }; /* 65537 in bytes */
+ GckBuilder publi = GCK_BUILDER_INIT;
+ GckBuilder priva = GCK_BUILDER_INIT;
const gchar *label;
g_assert (self->cancellable == NULL);
- g_assert (self->mechanism);
+ g_assert (self->mechanism != NULL);
- self->cancellable = g_cancellable_new ();
+ gck_builder_add_ulong (&publi, CKA_CLASS, CKO_PUBLIC_KEY);
+ gck_builder_add_ulong (&priva, CKA_CLASS, CKO_PRIVATE_KEY);
- self->pub_attrs = gck_attributes_new ();
- self->prv_attrs = gck_attributes_new ();
+ gck_builder_add_boolean (&publi, CKA_TOKEN, TRUE);
+ gck_builder_add_boolean (&priva, CKA_TOKEN, TRUE);
- gck_attributes_add_ulong (self->pub_attrs, CKA_CLASS, CKO_PUBLIC_KEY);
- gck_attributes_add_ulong (self->prv_attrs, CKA_CLASS, CKO_PRIVATE_KEY);
-
- gck_attributes_add_boolean (self->pub_attrs, CKA_TOKEN, TRUE);
- gck_attributes_add_boolean (self->prv_attrs, CKA_TOKEN, TRUE);
-
- gck_attributes_add_boolean (self->prv_attrs, CKA_PRIVATE, TRUE);
- gck_attributes_add_boolean (self->prv_attrs, CKA_SENSITIVE, TRUE);
+ gck_builder_add_boolean (&priva, CKA_PRIVATE, TRUE);
+ gck_builder_add_boolean (&priva, CKA_SENSITIVE, TRUE);
label = gtk_entry_get_text (self->label_entry);
- gck_attributes_add_string (self->pub_attrs, CKA_LABEL, label);
- gck_attributes_add_string (self->prv_attrs, CKA_LABEL, label);
+ gck_builder_add_string (&publi, CKA_LABEL, label);
+ gck_builder_add_string (&priva, CKA_LABEL, label);
if (self->mechanism->type == CKM_RSA_PKCS_KEY_PAIR_GEN) {
- gck_attributes_add_boolean (self->pub_attrs, CKA_ENCRYPT, TRUE);
- gck_attributes_add_boolean (self->pub_attrs, CKA_VERIFY, TRUE);
- gck_attributes_add_boolean (self->pub_attrs, CKA_WRAP, TRUE);
+ gck_builder_add_boolean (&publi, CKA_ENCRYPT, TRUE);
+ gck_builder_add_boolean (&publi, CKA_VERIFY, TRUE);
+ gck_builder_add_boolean (&publi, CKA_WRAP, TRUE);
- gck_attributes_add_boolean (self->prv_attrs, CKA_DECRYPT, TRUE);
- gck_attributes_add_boolean (self->prv_attrs, CKA_SIGN, TRUE);
- gck_attributes_add_boolean (self->prv_attrs, CKA_UNWRAP, TRUE);
+ gck_builder_add_boolean (&priva, CKA_DECRYPT, TRUE);
+ gck_builder_add_boolean (&priva, CKA_SIGN, TRUE);
+ gck_builder_add_boolean (&priva, CKA_UNWRAP, TRUE);
- gck_attributes_add_data (self->pub_attrs, CKA_PUBLIC_EXPONENT,
- rsa_public_exponent, sizeof (rsa_public_exponent));
- gck_attributes_add_ulong (self->pub_attrs, CKA_MODULUS_BITS,
- gtk_spin_button_get_value_as_int (self->bits_entry));
+ gck_builder_add_data (&publi, CKA_PUBLIC_EXPONENT,
+ rsa_public_exponent, sizeof (rsa_public_exponent));
+ gck_builder_add_ulong (&publi, CKA_MODULUS_BITS,
+ gtk_spin_button_get_value_as_int (self->bits_entry));
} else {
g_warning ("currently no support for this mechanism");
}
+
+ self->prv_attrs = gck_builder_steal (&priva);
+ self->pub_attrs = gck_builder_steal (&publi);
+
+ gck_builder_clear (&publi);
+ gck_builder_clear (&priva);
}
static void
diff --git a/pkcs11/seahorse-private-key.c b/pkcs11/seahorse-private-key.c
index 04ceb5a..f3224c6 100644
--- a/pkcs11/seahorse-private-key.c
+++ b/pkcs11/seahorse-private-key.c
@@ -73,10 +73,10 @@ struct _SeahorsePrivateKeyPrivate {
static void seahorse_private_key_deletable_iface (SeahorseDeletableIface *iface);
-static void seahorse_private_key_object_attributes_iface (GckObjectAttributesIface *iface);
+static void seahorse_private_key_object_cache_iface (GckObjectCacheIface *iface);
G_DEFINE_TYPE_WITH_CODE (SeahorsePrivateKey, seahorse_private_key, GCK_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (GCK_TYPE_OBJECT_ATTRIBUTES, seahorse_private_key_object_attributes_iface);
+ G_IMPLEMENT_INTERFACE (GCK_TYPE_OBJECT_CACHE, seahorse_private_key_object_cache_iface);
G_IMPLEMENT_INTERFACE (SEAHORSE_TYPE_DELETABLE, seahorse_private_key_deletable_iface);
);
@@ -259,10 +259,28 @@ seahorse_private_key_class_init (SeahorsePrivateKeyClass *klass)
}
static void
-seahorse_private_key_object_attributes_iface (GckObjectAttributesIface *iface)
+seahorse_private_key_fill (GckObjectCache *object,
+ GckAttributes *attributes)
{
- iface->attribute_types = REQUIRED_ATTRS;
- iface->n_attribute_types = G_N_ELEMENTS (REQUIRED_ATTRS);
+ SeahorsePrivateKey *self = SEAHORSE_PRIVATE_KEY (object);
+ GckBuilder builder = GCK_BUILDER_INIT;
+
+ if (self->pv->attributes)
+ gck_builder_add_all (&builder, self->pv->attributes);
+ gck_builder_set_all (&builder, attributes);
+ gck_attributes_unref (self->pv->attributes);
+ self->pv->attributes = gck_builder_steal (&builder);
+ gck_builder_clear (&builder);
+
+ g_object_notify (G_OBJECT (object), "attributes");
+}
+
+static void
+seahorse_private_key_object_cache_iface (GckObjectCacheIface *iface)
+{
+ iface->default_types = REQUIRED_ATTRS;
+ iface->n_default_types = G_N_ELEMENTS (REQUIRED_ATTRS);
+ iface->fill = seahorse_private_key_fill;
}
static SeahorseDeleter *
diff --git a/pkcs11/seahorse-token.c b/pkcs11/seahorse-token.c
index a47775c..893671a 100644
--- a/pkcs11/seahorse-token.c
+++ b/pkcs11/seahorse-token.c
@@ -108,7 +108,7 @@ update_token_info (SeahorseToken *self)
static void
update_id_map (SeahorseToken *self,
gpointer object,
- GckAttribute *id)
+ const GckAttribute *id)
{
GPtrArray *objects;
GckAttribute *pid;
@@ -137,11 +137,11 @@ update_id_map (SeahorseToken *self,
if (!g_hash_table_lookup_extended (self->pv->objects_for_id, id,
(gpointer *)&id, (gpointer *)&objects)) {
objects = g_ptr_array_new ();
- id = gck_attribute_dup (id);
- g_hash_table_insert (self->pv->objects_for_id, id, objects);
+ g_hash_table_insert (self->pv->objects_for_id,
+ gck_attribute_dup (id), objects);
}
g_ptr_array_add (objects, object);
- g_hash_table_insert (self->pv->id_for_object, object, id);
+ g_hash_table_insert (self->pv->id_for_object, object, (GckAttribute *)id);
}
/* Remove this object from the map */
@@ -164,7 +164,7 @@ update_id_map (SeahorseToken *self,
static gpointer
lookup_id_map (SeahorseToken *self,
GType object_type,
- GckAttribute *id)
+ const GckAttribute *id)
{
GPtrArray *objects;
guint i;
@@ -247,7 +247,7 @@ receive_objects (SeahorseToken *self,
GList *objects)
{
GckAttributes *attrs;
- GckAttribute *id;
+ const GckAttribute *id;
gpointer object;
gpointer prev;
gpointer pair;
@@ -259,7 +259,7 @@ receive_objects (SeahorseToken *self,
for (l = objects; l != NULL; l = g_list_next (l)) {
object = l->data;
handle = gck_object_get_handle (object);
- attrs = gck_object_attributes_get_attributes (object);
+ attrs = gck_object_cache_get_attributes (object);
prev = g_hash_table_lookup (self->pv->object_for_handle, &handle);
if (prev == NULL) {
@@ -268,7 +268,7 @@ receive_objects (SeahorseToken *self,
g_object_ref (object));
g_object_set (object, "place", self, NULL);
} else if (prev != object) {
- gck_object_attributes_set_attributes (prev, attrs);
+ gck_object_cache_set_attributes (prev, attrs);
object = prev;
}
@@ -406,28 +406,24 @@ static void
refresh_enumerate (GSimpleAsyncResult *res)
{
RefreshClosure *closure = g_simple_async_result_get_op_res_gpointer (res);
+ GckBuilder builder = GCK_BUILDER_INIT;
GckSession *session;
GckEnumerator *enumerator;
- GckAttributes *attrs;
session = seahorse_token_get_session (closure->token);
- attrs = gck_attributes_new ();
- gck_attributes_add_boolean (attrs, CKA_TOKEN, TRUE);
- gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_CERTIFICATE);
- enumerator = gck_session_enumerate_objects (session, attrs);
+ gck_builder_add_boolean (&builder, CKA_TOKEN, TRUE);
+ gck_builder_add_ulong (&builder, CKA_CLASS, CKO_CERTIFICATE);
+ enumerator = gck_session_enumerate_objects (session, gck_builder_end (&builder));
gck_enumerator_set_object_type (enumerator, SEAHORSE_TYPE_CERTIFICATE);
closure->enumerator = enumerator;
- gck_attributes_unref (attrs);
- attrs = gck_attributes_new ();
- gck_attributes_add_boolean (attrs, CKA_TOKEN, TRUE);
- gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_PRIVATE_KEY);
- enumerator = gck_session_enumerate_objects (session, attrs);
+ gck_builder_add_boolean (&builder, CKA_TOKEN, TRUE);
+ gck_builder_add_ulong (&builder, CKA_CLASS, CKO_PRIVATE_KEY);
+ enumerator = gck_session_enumerate_objects (session, gck_builder_end (&builder));
gck_enumerator_set_object_type (enumerator, SEAHORSE_TYPE_PRIVATE_KEY);
gck_enumerator_set_chained (closure->enumerator, enumerator);
g_object_unref (enumerator);
- gck_attributes_unref (attrs);
gck_enumerator_next_async (closure->enumerator, 16, closure->cancellable,
on_refresh_next_objects, g_object_ref (res));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]