[seahorse] [pkcs11] Use new libgck library instead of gp11



commit 16e8b3edbfccaeedbce475856f8b4e48cdaf4712
Author: Stef Walter <stef memberwebs com>
Date:   Wed Oct 6 17:36:39 2010 +0000

    [pkcs11] Use new libgck library instead of gp11
    
    Migrate to libgck from libgp11, now that gck is in gnome-keyring.

 configure.in                         |   22 ++++----
 pkcs11/Makefile.am                   |    1 +
 pkcs11/seahorse-pkcs11-certificate.c |   40 +++++++-------
 pkcs11/seahorse-pkcs11-certificate.h |    4 +-
 pkcs11/seahorse-pkcs11-helpers.c     |   16 +++---
 pkcs11/seahorse-pkcs11-helpers.h     |    6 +-
 pkcs11/seahorse-pkcs11-module.c      |   15 ++---
 pkcs11/seahorse-pkcs11-object.c      |  105 ++++++++++++++++++----------------
 pkcs11/seahorse-pkcs11-object.h      |   14 ++--
 pkcs11/seahorse-pkcs11-operations.c  |   44 +++++++-------
 pkcs11/seahorse-pkcs11-source.c      |   14 ++--
 pkcs11/seahorse-pkcs11-source.h      |    8 +-
 12 files changed, 148 insertions(+), 141 deletions(-)
---
diff --git a/configure.in b/configure.in
index 3d95cc1..c42bb5a 100644
--- a/configure.in
+++ b/configure.in
@@ -436,23 +436,23 @@ dnl ****************************************************************************
 AC_ARG_ENABLE(pkcs11,
 	AC_HELP_STRING([--disable-pkcs11],
 		[Support keys and certificates via PKCS#11]))
-	
+
 if test "$enable_pkcs11" = "no"; then
 	echo "disabling pkcs11 support"
 	enable_pkcs11="no"
 else
 	PKG_CHECK_MODULES(GCR, gcr-0 >= 2.25.5, gcr_is_present="yes", gcr_is_present="no")
-    if test "$gcr_is_present" = "no"; then
-	    echo "disabling pkcs11 support"
-    fi
-	PKG_CHECK_MODULES(GP11, gp11-0 >= 2.29.4, enable_pkcs11="yes", enable_pkcs11="no")
+	if test "$gcr_is_present" = "no"; then
+		echo "disabling pkcs11 support"
+	fi
+	PKG_CHECK_MODULES(GCK, gck-0 >= 2.91.0, enable_pkcs11="yes", enable_pkcs11="no")
 	if test "$enable_pkcs11" = "yes" && test "$gcr_is_present" = "yes"; then
-	    AC_DEFINE(WITH_PKCS11, 1, [gp11 library available])
-		SEAHORSE_CFLAGS="$SEAHORSE_CFLAGS $GP11_CFLAGS $GCR_CFLAGS"
-		SEAHORSE_LIBS="$SEAHORSE_LIBS $GP11_LIBS $GCR_LIBS"
-    else
-        enable_pkcs11="no"
-    fi
+		AC_DEFINE(WITH_PKCS11, 1, [gck library available])
+		SEAHORSE_CFLAGS="$SEAHORSE_CFLAGS $GCK_CFLAGS $GCR_CFLAGS"
+		SEAHORSE_LIBS="$SEAHORSE_LIBS $GCK_LIBS $GCR_LIBS"
+	else
+		enable_pkcs11="no"
+	fi
 fi
 
 AM_CONDITIONAL(WITH_PKCS11, test "$enable_pkcs11" = "yes")
diff --git a/pkcs11/Makefile.am b/pkcs11/Makefile.am
index 6dc0457..c82cbe4 100644
--- a/pkcs11/Makefile.am
+++ b/pkcs11/Makefile.am
@@ -14,6 +14,7 @@ INCLUDES = -I$(top_builddir) \
 	-DEXECDIR=\""$(seahorselibexecbindir)"\" \
 	-DLIBCRYPTUI_API_SUBJECT_TO_CHANGE \
 	-DGCR_API_SUBJECT_TO_CHANGE \
+	-DGCK_API_SUBJECT_TO_CHANGE \
 	-DGETTEXT_PACKAGE=\""seahorse\""
 
 noinst_LTLIBRARIES = libseahorse-pkcs11.la
diff --git a/pkcs11/seahorse-pkcs11-certificate.c b/pkcs11/seahorse-pkcs11-certificate.c
index 1eb3eb1..e208ba9 100644
--- a/pkcs11/seahorse-pkcs11-certificate.c
+++ b/pkcs11/seahorse-pkcs11-certificate.c
@@ -55,7 +55,7 @@ enum {
 };
 
 struct _SeahorsePkcs11CertificatePrivate {
-	GP11Attribute der_value;
+	GckAttribute der_value;
 };
 
 static void seahorse_pkcs11_certificate_iface (GcrCertificateIface *iface);
@@ -138,7 +138,7 @@ static void
 seahorse_pkcs11_certificate_init (SeahorsePkcs11Certificate *self)
 {
 	self->pv = (G_TYPE_INSTANCE_GET_PRIVATE (self, SEAHORSE_PKCS11_TYPE_CERTIFICATE, SeahorsePkcs11CertificatePrivate));
-	gp11_attribute_init_invalid (&self->pv->der_value, CKA_VALUE);
+	gck_attribute_init_invalid (&self->pv->der_value, CKA_VALUE);
 }
 
 static void
@@ -165,8 +165,8 @@ seahorse_pkcs11_certificate_finalize (GObject *obj)
 {
 	SeahorsePkcs11Certificate *self = SEAHORSE_PKCS11_CERTIFICATE (obj);
 
-	gp11_attribute_clear (&self->pv->der_value);
-	
+	gck_attribute_clear (&self->pv->der_value);
+
 	G_OBJECT_CLASS (seahorse_pkcs11_certificate_parent_class)->finalize (obj);
 }
 
@@ -266,9 +266,9 @@ seahorse_pkcs11_certificate_get_der_data (GcrCertificate *cert, gsize *n_length)
 {
 	SeahorsePkcs11Object *obj = SEAHORSE_PKCS11_OBJECT (cert);
 	SeahorsePkcs11Certificate *self = SEAHORSE_PKCS11_CERTIFICATE (cert);
-	GP11Attributes *attrs;
-	GP11Attribute *attr;
-	
+	GckAttributes *attrs;
+	GckAttribute *attr;
+
 	g_return_val_if_fail (SEAHORSE_PKCS11_IS_CERTIFICATE (cert), NULL);
 	
 	if (!seahorse_pkcs11_object_require_attributes (obj, REQUIRED_ATTRS, 
@@ -277,16 +277,16 @@ seahorse_pkcs11_certificate_get_der_data (GcrCertificate *cert, gsize *n_length)
 	
 	/* TODO: This whole copying and possibly freeing memory in use is risky */
 
-	if (gp11_attribute_is_invalid (&self->pv->der_value)) {
+	if (gck_attribute_is_invalid (&self->pv->der_value)) {
 		attrs = seahorse_pkcs11_object_get_pkcs11_attributes (obj);
 		g_return_val_if_fail (attrs, NULL);
-		attr = gp11_attributes_find (attrs, CKA_VALUE);
+		attr = gck_attributes_find (attrs, CKA_VALUE);
 		g_return_val_if_fail (attr, NULL);
-		gp11_attribute_clear (&self->pv->der_value);
-		gp11_attribute_init_copy (&self->pv->der_value, attr);
+		gck_attribute_clear (&self->pv->der_value);
+		gck_attribute_init_copy (&self->pv->der_value, attr);
 	}
 	
-	g_return_val_if_fail (!gp11_attribute_is_invalid (&self->pv->der_value), NULL);
+	g_return_val_if_fail (!gck_attribute_is_invalid (&self->pv->der_value), NULL);
 	*n_length = self->pv->der_value.length;
 	return self->pv->der_value.value;
 }
@@ -302,7 +302,7 @@ seahorse_pkcs11_certificate_iface (GcrCertificateIface *iface)
  */
 
 SeahorsePkcs11Certificate*
-seahorse_pkcs11_certificate_new (GP11Object* object)
+seahorse_pkcs11_certificate_new (GckObject* object)
 {
 	return g_object_new (SEAHORSE_PKCS11_TYPE_CERTIFICATE, 
 	                     "pkcs11-object", object, NULL);
@@ -311,8 +311,8 @@ seahorse_pkcs11_certificate_new (GP11Object* object)
 gchar* 
 seahorse_pkcs11_certificate_get_fingerprint (SeahorsePkcs11Certificate* self) 
 {
-	GP11Attribute* attr;
-	
+	GckAttribute* attr;
+
 	/* TODO: We should be using the fingerprint off the DER */
 	attr = seahorse_pkcs11_object_require_attribute (SEAHORSE_PKCS11_OBJECT (self), CKA_ID);
 	if (attr == NULL)
@@ -340,12 +340,12 @@ seahorse_pkcs11_certificate_get_validity_str (SeahorsePkcs11Certificate* self)
 guint 
 seahorse_pkcs11_certificate_get_trust (SeahorsePkcs11Certificate* self) 
 {
-	GP11Attribute *attr;
+	GckAttribute *attr;
 
 	g_return_val_if_fail (SEAHORSE_PKCS11_IS_CERTIFICATE (self), 0);
 
 	attr = seahorse_pkcs11_object_require_attribute (SEAHORSE_PKCS11_OBJECT (self), CKA_TRUSTED);
-	if (attr && gp11_attribute_get_boolean (attr))
+	if (attr && gck_attribute_get_boolean (attr))
 		return SEAHORSE_VALIDITY_FULL;
 
 	return SEAHORSE_VALIDITY_UNKNOWN;
@@ -362,7 +362,7 @@ seahorse_pkcs11_certificate_get_trust_str (SeahorsePkcs11Certificate* self)
 gulong
 seahorse_pkcs11_certificate_get_expires (SeahorsePkcs11Certificate* self) 
 {
-	GP11Attribute *attr;
+	GckAttribute *attr;
 	GDate date = { 0 };
 	struct tm time = { 0 };
 
@@ -371,8 +371,8 @@ seahorse_pkcs11_certificate_get_expires (SeahorsePkcs11Certificate* self)
 	attr = seahorse_pkcs11_object_require_attribute (SEAHORSE_PKCS11_OBJECT (self), CKA_END_DATE);
 	if (attr == NULL)
 		return 0;
-	
-	gp11_attribute_get_date (attr, &date);
+
+	gck_attribute_get_date (attr, &date);
 	g_date_to_struct_tm (&date, &time);
 	return (gulong)(mktime (&time));
 }
diff --git a/pkcs11/seahorse-pkcs11-certificate.h b/pkcs11/seahorse-pkcs11-certificate.h
index 64d5614..bcc301a 100644
--- a/pkcs11/seahorse-pkcs11-certificate.h
+++ b/pkcs11/seahorse-pkcs11-certificate.h
@@ -22,7 +22,7 @@
 #ifndef __SEAHORSE_PKCS11_CERTIFICATE_H__
 #define __SEAHORSE_PKCS11_CERTIFICATE_H__
 
-#include <gp11.h>
+#include <gck/gck.h>
 
 #include <glib-object.h>
 
@@ -50,7 +50,7 @@ struct _SeahorsePkcs11CertificateClass {
 
 GType                       seahorse_pkcs11_certificate_get_type               (void);
 
-SeahorsePkcs11Certificate*  seahorse_pkcs11_certificate_new                    (GP11Object* object);
+SeahorsePkcs11Certificate*  seahorse_pkcs11_certificate_new                    (GckObject* object);
 
 gchar*                      seahorse_pkcs11_certificate_get_fingerprint        (SeahorsePkcs11Certificate* self);
 
diff --git a/pkcs11/seahorse-pkcs11-helpers.c b/pkcs11/seahorse-pkcs11-helpers.c
index f10ee81..4c06019 100644
--- a/pkcs11/seahorse-pkcs11-helpers.c
+++ b/pkcs11/seahorse-pkcs11-helpers.c
@@ -72,10 +72,10 @@ seahorse_pkcs11_string_to_klass (const char* str)
 }
 
 GQuark 
-seahorse_pkcs11_id_from_attributes (GP11Attributes* attrs) 
+seahorse_pkcs11_id_from_attributes (GckAttributes* attrs)
 {
 	gulong klass;
-	GP11Attribute* attr;
+	GckAttribute* attr;
 	gchar *id, *encoded, *klass_str;
 	GQuark quark;
 	
@@ -84,12 +84,12 @@ seahorse_pkcs11_id_from_attributes (GP11Attributes* attrs)
 	/* These cases should have been covered by the programmer */
 
 	klass = 0;
-	if (!gp11_attributes_find_ulong (attrs, CKA_CLASS, &klass)) {
+	if (!gck_attributes_find_ulong (attrs, CKA_CLASS, &klass)) {
 		g_warning ("Cannot create object id. PKCS#11 attribute set did not contain CKA_CLASS.");
 		return 0;
 	}
 	
-	attr = gp11_attributes_find (attrs, CKA_ID);
+	attr = gck_attributes_find (attrs, CKA_ID);
 	if (attr == NULL) {
 		g_warning ("Cannot create object id. PKCS#11 attribute set did not contain CKA_ID");
 		return 0;
@@ -109,7 +109,7 @@ seahorse_pkcs11_id_from_attributes (GP11Attributes* attrs)
 
 
 gboolean 
-seahorse_pkcs11_id_to_attributes (GQuark id, GP11Attributes* attrs) 
+seahorse_pkcs11_id_to_attributes (GQuark id, GckAttributes* attrs)
 {
 	const gchar* value;
 	guchar *ckid;
@@ -143,10 +143,10 @@ seahorse_pkcs11_id_to_attributes (GQuark id, GP11Attributes* attrs)
 	if (!id) 
 		return FALSE;
 		
-	gp11_attributes_add_ulong (attrs, CKA_CLASS, klass);
-	gp11_attributes_add_data (attrs, CKA_ID, ckid, n_ckid);
+	gck_attributes_add_ulong (attrs, CKA_CLASS, klass);
+	gck_attributes_add_data (attrs, CKA_ID, ckid, n_ckid);
 	g_free (ckid);
-	
+
 	return TRUE;
 }
 
diff --git a/pkcs11/seahorse-pkcs11-helpers.h b/pkcs11/seahorse-pkcs11-helpers.h
index f746d82..f967409 100644
--- a/pkcs11/seahorse-pkcs11-helpers.h
+++ b/pkcs11/seahorse-pkcs11-helpers.h
@@ -23,10 +23,10 @@
 #define __SEAHORSE_PKCS11_HELPERS_H__
 
 #include <glib.h>
-#include <gp11.h>
+#include <gck/gck.h>
 
-GQuark seahorse_pkcs11_id_from_attributes (GP11Attributes* attrs);
-gboolean seahorse_pkcs11_id_to_attributes (GQuark id, GP11Attributes* attrs);
+GQuark seahorse_pkcs11_id_from_attributes (GckAttributes* attrs);
+gboolean seahorse_pkcs11_id_to_attributes (GQuark id, GckAttributes* attrs);
 
 
 #endif
diff --git a/pkcs11/seahorse-pkcs11-module.c b/pkcs11/seahorse-pkcs11-module.c
index 2f4ff6a..8862128 100644
--- a/pkcs11/seahorse-pkcs11-module.c
+++ b/pkcs11/seahorse-pkcs11-module.c
@@ -29,13 +29,13 @@
 #include "seahorse-gconf.h"
 #include "seahorse-util.h"
 
-#include <gp11.h>
+#include <gck/gck.h>
 
 void
 seahorse_pkcs11_module_init (void)
 {
 	SeahorseSource *source;
-	GP11Module *module;
+	GckModule *module;
 	GSList *l, *module_paths;
 	GList *slots, *s;
 	GError *err = NULL;
@@ -43,24 +43,23 @@ seahorse_pkcs11_module_init (void)
 	/* Load each module in turn, and each slot for each module */
 	module_paths = seahorse_gconf_get_string_list ("/system/pkcs11/modules");
 	for (l = module_paths; l; l = g_slist_next (l)) {
-		
-		module = gp11_module_initialize (l->data, NULL, &err);
+
+		module = gck_module_initialize (l->data, NULL, 0, &err);
 		if (!module) {
 			g_warning ("couldn't initialize %s pkcs11 module: %s", 
 			           (gchar*)l->data, err ? err->message : NULL);
 			g_clear_error (&err);
 			continue;
 		}
-		
-		gp11_module_set_pool_sessions (module, TRUE);
-		slots = gp11_module_get_slots (module, FALSE);
+
+		slots = gck_module_get_slots (module, FALSE);
 		for (s = slots; s; s = g_list_next (s)) {
 			source = SEAHORSE_SOURCE (seahorse_pkcs11_source_new (s->data));
 			seahorse_context_take_source (NULL, source);
 		}
 
 		/* These will have been refed by the source above */
-		gp11_list_unref_free (slots);
+		gck_list_unref_free (slots);
 		g_object_unref (module);
 	}
 
diff --git a/pkcs11/seahorse-pkcs11-object.c b/pkcs11/seahorse-pkcs11-object.c
index ad217d8..602244b 100644
--- a/pkcs11/seahorse-pkcs11-object.c
+++ b/pkcs11/seahorse-pkcs11-object.c
@@ -46,10 +46,9 @@ enum {
 };
 
 struct _SeahorsePkcs11ObjectPrivate {
-	GP11Object *pkcs11_object;
-	GP11Attributes* pkcs11_attributes;
+	GckObject *pkcs11_object;
+	GckAttributes* pkcs11_attributes;
 	GCancellable *request_attributes;
-	
 };
 
 G_DEFINE_TYPE (SeahorsePkcs11Object, seahorse_pkcs11_object, SEAHORSE_TYPE_OBJECT);
@@ -62,10 +61,10 @@ static void
 received_object_attributes (GObject *object, GAsyncResult *result, gpointer user_data)
 {
 	SeahorsePkcs11Object *self = SEAHORSE_PKCS11_OBJECT (user_data);
-	GP11Attributes *attrs;
+	GckAttributes *attrs;
 	GError *err = NULL;
 	
-	attrs = gp11_object_get_finish (GP11_OBJECT (object), result, &err);
+	attrs = gck_object_get_finish (GCK_OBJECT (object), result, &err);
 	if (err && err->code == CKR_FUNCTION_CANCELED)
 		return;
 
@@ -86,19 +85,19 @@ load_object_attributes (SeahorsePkcs11Object *self, const gulong *attr_types,
                         gsize n_attr_types)
 {
 	gboolean added = FALSE;
-	GP11Attributes *attrs;
-	GP11Attribute *attr;
+	GckAttribute *attr;
+	GArray *types;
 	gsize i;
-	
+
 	g_assert (SEAHORSE_PKCS11_IS_OBJECT (self));
 	g_assert (self->pv->pkcs11_attributes);
 	g_assert (self->pv->pkcs11_object);
 
 	/* Add in any attirbutes not found, as invalid */
 	for (i = 0; i < n_attr_types; ++i) {
-		attr = gp11_attributes_find (self->pv->pkcs11_attributes, attr_types[i]);
+		attr = gck_attributes_find (self->pv->pkcs11_attributes, attr_types[i]);
 		if (attr == NULL) {
-			gp11_attributes_add_invalid (self->pv->pkcs11_attributes, attr_types[i]);
+			gck_attributes_add_invalid (self->pv->pkcs11_attributes, attr_types[i]);
 			added = TRUE;
 		}
 			
@@ -121,20 +120,20 @@ load_object_attributes (SeahorsePkcs11Object *self, const gulong *attr_types,
 	 * Build up an array of attribute types to load, from the 
 	 * ones that we alrady have plus the ones that are requested.
 	 */
-	
-	attrs = gp11_attributes_new ();
-	for (i = 0; i < gp11_attributes_count (self->pv->pkcs11_attributes); ++i) {
-		attr = gp11_attributes_at (self->pv->pkcs11_attributes, i);
+
+	types = g_array_new (FALSE, TRUE, sizeof (gulong));
+	for (i = 0; i < gck_attributes_count (self->pv->pkcs11_attributes); ++i) {
+		attr = gck_attributes_at (self->pv->pkcs11_attributes, i);
 		g_return_if_fail (attr);
-		gp11_attributes_add_empty (attrs, attr->type);
+		g_array_append_val (types, attr->type);
 	}
 
 	/* Off we go to load them all */
 	self->pv->request_attributes = g_cancellable_new ();
-	gp11_object_get_async (self->pv->pkcs11_object, attrs, self->pv->request_attributes, 
-	                       received_object_attributes, g_object_ref (self));
-	
-	gp11_attributes_unref (attrs);
+	gck_object_get_async (self->pv->pkcs11_object, (gulong*)types->data, types->len,
+	                      self->pv->request_attributes, received_object_attributes, g_object_ref (self));
+
+	g_array_free (types, TRUE);
 }
 
 /* -----------------------------------------------------------------------------
@@ -156,10 +155,10 @@ seahorse_pkcs11_object_realize (SeahorseObject *obj)
 	g_assert (SEAHORSE_PKCS11_IS_OBJECT (obj));
 
 	flags = 0;
-	if (gp11_attributes_find_boolean (self->pv->pkcs11_attributes, CKA_EXTRACTABLE, &exportable) && exportable)
+	if (gck_attributes_find_boolean (self->pv->pkcs11_attributes, CKA_EXTRACTABLE, &exportable) && exportable)
 		flags |= SEAHORSE_FLAG_EXPORTABLE;
 
-	gp11_attributes_find_string (self->pv->pkcs11_attributes, CKA_LABEL, &label);
+	gck_attributes_find_string (self->pv->pkcs11_attributes, CKA_LABEL, &label);
 	g_object_set (self,
 		      "label", label,
 		      "location", SEAHORSE_LOCATION_LOCAL,
@@ -200,14 +199,14 @@ static void
 seahorse_pkcs11_object_init (SeahorsePkcs11Object *self)
 {
 	self->pv = (G_TYPE_INSTANCE_GET_PRIVATE (self, SEAHORSE_PKCS11_TYPE_OBJECT, SeahorsePkcs11ObjectPrivate));
-	self->pv->pkcs11_attributes = gp11_attributes_new ();
+	self->pv->pkcs11_attributes = gck_attributes_new ();
 }
 
 static void
 seahorse_pkcs11_object_dispose (GObject *obj)
 {
 	SeahorsePkcs11Object *self = SEAHORSE_PKCS11_OBJECT (obj);
-    
+
 	if (self->pv->pkcs11_object)
 		g_object_unref (self->pv->pkcs11_object);
 	self->pv->pkcs11_object = NULL;
@@ -223,7 +222,7 @@ seahorse_pkcs11_object_finalize (GObject *obj)
 	g_assert (self->pv->pkcs11_object == NULL);
 	
 	if (self->pv->pkcs11_attributes)
-		gp11_attributes_unref (self->pv->pkcs11_attributes);
+		gck_attributes_unref (self->pv->pkcs11_attributes);
 	self->pv->pkcs11_attributes = NULL;
 	
 	G_OBJECT_CLASS (seahorse_pkcs11_object_parent_class)->finalize (obj);
@@ -293,11 +292,11 @@ seahorse_pkcs11_object_class_init (SeahorsePkcs11ObjectClass *klass)
 	seahorse_class->delete = seahorse_pkcs11_object_delete;
 	
 	g_object_class_install_property (gobject_class, PROP_PKCS11_OBJECT, 
-	         g_param_spec_object ("pkcs11-object", "pkcs11-object", "pkcs11-object", GP11_TYPE_OBJECT, 
+	         g_param_spec_object ("pkcs11-object", "pkcs11-object", "pkcs11-object", GCK_TYPE_OBJECT,
 	                              G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
 	
 	g_object_class_install_property (gobject_class, PROP_PKCS11_ATTRIBUTES, 
-	         g_param_spec_boxed ("pkcs11-attributes", "pkcs11-attributes", "pkcs11-attributes", GP11_TYPE_ATTRIBUTES, 
+	         g_param_spec_boxed ("pkcs11-attributes", "pkcs11-attributes", "pkcs11-attributes", GCK_TYPE_ATTRIBUTES,
 	                             G_PARAM_READABLE | G_PARAM_WRITABLE));
 	
 	g_object_class_install_property (gobject_class, PROP_PKCS11_HANDLE, 
@@ -310,20 +309,20 @@ seahorse_pkcs11_object_class_init (SeahorsePkcs11ObjectClass *klass)
  */
 
 SeahorsePkcs11Object*
-seahorse_pkcs11_object_new (GP11Object* object)
+seahorse_pkcs11_object_new (GckObject* object)
 {
 	return g_object_new (SEAHORSE_PKCS11_TYPE_OBJECT, 
 	                     "pkcs11-object", object, NULL);
 }
 
-GP11Object* 
+GckObject*
 seahorse_pkcs11_object_get_pkcs11_object (SeahorsePkcs11Object* self) 
 {
 	g_return_val_if_fail (SEAHORSE_PKCS11_IS_OBJECT (self), NULL);
 	return self->pv->pkcs11_object;
 }
 
-GP11Attributes* 
+GckAttributes*
 seahorse_pkcs11_object_get_pkcs11_attributes (SeahorsePkcs11Object* self) 
 {
 	g_return_val_if_fail (SEAHORSE_PKCS11_IS_OBJECT (self), NULL);
@@ -332,7 +331,7 @@ seahorse_pkcs11_object_get_pkcs11_attributes (SeahorsePkcs11Object* self)
 
 
 void 
-seahorse_pkcs11_object_set_pkcs11_attributes (SeahorsePkcs11Object* self, GP11Attributes* value) 
+seahorse_pkcs11_object_set_pkcs11_attributes (SeahorsePkcs11Object* self, GckAttributes* value)
 {
 	GObject *obj;
 	
@@ -340,9 +339,9 @@ seahorse_pkcs11_object_set_pkcs11_attributes (SeahorsePkcs11Object* self, GP11At
 	g_return_if_fail (value);
 	
 	if (value)
-		gp11_attributes_ref (value);
+		gck_attributes_ref (value);
 	if (self->pv->pkcs11_attributes)
-		gp11_attributes_unref (self->pv->pkcs11_attributes);
+		gck_attributes_unref (self->pv->pkcs11_attributes);
 	self->pv->pkcs11_attributes = value;
 	
 	obj = G_OBJECT (self);
@@ -350,8 +349,8 @@ seahorse_pkcs11_object_set_pkcs11_attributes (SeahorsePkcs11Object* self, GP11At
 	seahorse_pkcs11_object_realize (SEAHORSE_OBJECT (obj));
 	g_object_notify (obj, "pkcs11-attributes");
 	g_object_thaw_notify (obj);
-	
-	gp11_attributes_find (self->pv->pkcs11_attributes, CKA_LABEL);
+
+	gck_attributes_find (self->pv->pkcs11_attributes, CKA_LABEL);
 }
 
 gulong
@@ -359,21 +358,21 @@ seahorse_pkcs11_object_get_pkcs11_handle (SeahorsePkcs11Object* self)
 {
 	g_return_val_if_fail (SEAHORSE_PKCS11_IS_OBJECT (self), 0);
 	if (self->pv->pkcs11_object)
-		return gp11_object_get_handle (self->pv->pkcs11_object);
-	return GP11_INVALID;
+		return gck_object_get_handle (self->pv->pkcs11_object);
+	return GCK_INVALID;
 }
 
-GP11Attribute*
+GckAttribute*
 seahorse_pkcs11_object_require_attribute (SeahorsePkcs11Object *self, gulong attr_type)
 {
-	GP11Attribute* attr;
-	
+	GckAttribute* attr;
+
 	g_return_val_if_fail (SEAHORSE_PKCS11_IS_OBJECT (self), NULL);
-	
-	attr = gp11_attributes_find (self->pv->pkcs11_attributes, attr_type);
+
+	attr = gck_attributes_find (self->pv->pkcs11_attributes, attr_type);
 	if (attr == NULL)
 		load_object_attributes (self, &attr_type, 1);
-	if (gp11_attribute_is_invalid (attr))
+	if (gck_attribute_is_invalid (attr))
 		attr = NULL;
 	
 	return attr;
@@ -389,7 +388,7 @@ seahorse_pkcs11_object_require_attributes (SeahorsePkcs11Object *self, const gul
 	
 	/* See if we have these attributes loaded */
 	for (i = 0; i < n_attr_types; ++i) {
-		if (!gp11_attributes_find (self->pv->pkcs11_attributes, attr_types[i]))
+		if (!gck_attributes_find (self->pv->pkcs11_attributes, attr_types[i]))
 			break;
 	}
 		
@@ -402,17 +401,25 @@ seahorse_pkcs11_object_require_attributes (SeahorsePkcs11Object *self, const gul
 }
 
 GQuark
-seahorse_pkcs11_object_cannonical_id (GP11Object *object)
+seahorse_pkcs11_object_cannonical_id (GckObject *object)
 {
+	GckSession *session;
+	GckSlot *slot;
 	GQuark quark;
 	gchar *text;
-	
+
 	/* TODO: This whole ID thing needs rethinking */
-	
+
+	session = gck_object_get_session (object);
+	slot = gck_session_get_slot (session);
+
 	text = g_strdup_printf("%s:%lu/%lu", SEAHORSE_PKCS11_TYPE_STR, 
-                                         gp11_slot_get_handle (gp11_object_get_slot (object)),
-                                         gp11_object_get_handle (object));
-	
+	                       gck_slot_get_handle (slot),
+	                       gck_object_get_handle (object));
+
+	g_object_unref (session);
+	g_object_unref (slot);
+
 	quark = g_quark_from_string (text);
 	g_free (text);
 	return quark;	
diff --git a/pkcs11/seahorse-pkcs11-object.h b/pkcs11/seahorse-pkcs11-object.h
index f99eb13..4b8cac9 100644
--- a/pkcs11/seahorse-pkcs11-object.h
+++ b/pkcs11/seahorse-pkcs11-object.h
@@ -22,7 +22,7 @@
 #ifndef __SEAHORSE_PKCS11_OBJECT_H__
 #define __SEAHORSE_PKCS11_OBJECT_H__
 
-#include <gp11.h>
+#include <gck/gck.h>
 
 #include <glib-object.h>
 
@@ -50,24 +50,24 @@ struct _SeahorsePkcs11ObjectClass {
 
 GType                       seahorse_pkcs11_object_get_type               (void);
 
-SeahorsePkcs11Object*       seahorse_pkcs11_object_new                    (GP11Object* object);
+SeahorsePkcs11Object*       seahorse_pkcs11_object_new                    (GckObject* object);
 
 gulong                      seahorse_pkcs11_object_get_pkcs11_handle      (SeahorsePkcs11Object* self);
 
-GP11Object*                 seahorse_pkcs11_object_get_pkcs11_object      (SeahorsePkcs11Object* self);
+GckObject*                  seahorse_pkcs11_object_get_pkcs11_object      (SeahorsePkcs11Object* self);
 
-GP11Attributes*             seahorse_pkcs11_object_get_pkcs11_attributes  (SeahorsePkcs11Object* self);
+GckAttributes*              seahorse_pkcs11_object_get_pkcs11_attributes  (SeahorsePkcs11Object* self);
 
 void                        seahorse_pkcs11_object_set_pkcs11_attributes  (SeahorsePkcs11Object* self, 
-                                                                           GP11Attributes* value);
+                                                                           GckAttributes* value);
 
-GP11Attribute*              seahorse_pkcs11_object_require_attribute      (SeahorsePkcs11Object *self,
+GckAttribute*               seahorse_pkcs11_object_require_attribute      (SeahorsePkcs11Object *self,
                                                                            gulong attr_type);
 
 gboolean                    seahorse_pkcs11_object_require_attributes     (SeahorsePkcs11Object *self,
                                                                            const gulong *attr_types,
                                                                            gsize n_attr_types);
 
-GQuark                      seahorse_pkcs11_object_cannonical_id          (GP11Object *object);
+GQuark                      seahorse_pkcs11_object_cannonical_id          (GckObject *object);
 
 #endif /* __SEAHORSE_PKCS11_OBJECT_H__ */
diff --git a/pkcs11/seahorse-pkcs11-operations.c b/pkcs11/seahorse-pkcs11-operations.c
index f500a75..76bb339 100644
--- a/pkcs11/seahorse-pkcs11-operations.c
+++ b/pkcs11/seahorse-pkcs11-operations.c
@@ -29,7 +29,7 @@
 
 #include <pkcs11.h>
 #include <pkcs11g.h>
-#include <gp11.h>
+#include <gck/gck.h>
 
 #include <glib/gi18n.h>
 
@@ -64,7 +64,7 @@ struct _SeahorsePkcs11Refresher {
 	SeahorseOperation parent;
 	GCancellable *cancellable;
 	SeahorsePkcs11Source *source;
-	GP11Session *session;
+	GckSession *session;
 	GHashTable *checks;
 };
 
@@ -99,7 +99,7 @@ remove_each_object (gpointer key, gpointer value, gpointer data)
 }
 
 static void 
-on_find_objects(GP11Session *session, GAsyncResult *result, SeahorsePkcs11Refresher *self)
+on_find_objects(GckSession *session, GAsyncResult *result, SeahorsePkcs11Refresher *self)
 {
 	GList *objects, *l;
 	GError *err = NULL;
@@ -107,7 +107,7 @@ on_find_objects(GP11Session *session, GAsyncResult *result, SeahorsePkcs11Refres
 	
 	g_assert (SEAHORSE_IS_PKCS11_REFRESHER (self));
 	
-	objects = gp11_session_find_objects_finish (session, result, &err);
+	objects = gck_session_find_objects_finish (session, result, &err);
 	if (err != NULL) {
 		seahorse_pkcs11_mark_complete (SEAHORSE_OPERATION (self), err);
 		return;
@@ -116,7 +116,7 @@ on_find_objects(GP11Session *session, GAsyncResult *result, SeahorsePkcs11Refres
 	/* Remove all objects that were found, from the check table */
 	for (l = objects; l; l = g_list_next (l)) {
 		seahorse_pkcs11_source_receive_object (self->source, l->data);
-		handle = gp11_object_get_handle (l->data);
+		handle = gck_object_get_handle (l->data);
 		g_hash_table_remove (self->checks, &handle);
 	}
 
@@ -127,26 +127,26 @@ on_find_objects(GP11Session *session, GAsyncResult *result, SeahorsePkcs11Refres
 }
 
 static void 
-on_open_session(GP11Slot *slot, GAsyncResult *result, SeahorsePkcs11Refresher *self) 
+on_open_session(GckSlot *slot, GAsyncResult *result, SeahorsePkcs11Refresher *self)
 {
 	GError *err = NULL;
-	GP11Attributes *attrs;
-	
+	GckAttributes *attrs;
+
 	g_return_if_fail (SEAHORSE_IS_PKCS11_REFRESHER (self));
-	
-	self->session = gp11_slot_open_session_finish (slot, result, &err);
+
+	self->session = gck_slot_open_session_finish (slot, result, &err);
 	if (!self->session) {
 		seahorse_pkcs11_mark_complete (SEAHORSE_OPERATION (self), err);
 		return;
 	}
 	
 	/* Step 2. Load all the objects that we want */
-	attrs = gp11_attributes_new ();
-	gp11_attributes_add_boolean (attrs, CKA_TOKEN, TRUE);
-	gp11_attributes_add_ulong (attrs, CKA_CLASS, CKO_CERTIFICATE);
-	gp11_session_find_objects_async (self->session, attrs, self->cancellable, 
-	                                 (GAsyncReadyCallback)on_find_objects, self);
-	gp11_attributes_unref (attrs);
+	attrs = gck_attributes_new ();
+	gck_attributes_add_boolean (attrs, CKA_TOKEN, TRUE);
+	gck_attributes_add_ulong (attrs, CKA_CLASS, CKO_CERTIFICATE);
+	gck_session_find_objects_async (self->session, attrs, self->cancellable,
+	                                (GAsyncReadyCallback)on_find_objects, self);
+	gck_attributes_unref (attrs);
 }
 
 static void
@@ -161,7 +161,7 @@ static GObject*
 seahorse_pkcs11_refresher_constructor (GType type, guint n_props, GObjectConstructParam *props) 
 {
 	SeahorsePkcs11Refresher *self = SEAHORSE_PKCS11_REFRESHER (G_OBJECT_CLASS (seahorse_pkcs11_refresher_parent_class)->constructor(type, n_props, props));
-	GP11Slot *slot;
+	GckSlot *slot;
 	GList *objects, *l;
 	gulong handle;
 
@@ -181,7 +181,7 @@ seahorse_pkcs11_refresher_constructor (GType type, guint n_props, GObjectConstru
 
 	/* Step 1. Load the session */
 	slot = seahorse_pkcs11_source_get_slot (self->source);
-	gp11_slot_open_session_async (slot, CKF_RW_SESSION, NULL, NULL, self->cancellable,
+	gck_slot_open_session_async (slot, GCK_SESSION_READ_WRITE, self->cancellable,
 	                              (GAsyncReadyCallback)on_open_session, self);
 	seahorse_operation_mark_start (SEAHORSE_OPERATION (self));
 	
@@ -312,13 +312,13 @@ enum {
 G_DEFINE_TYPE (SeahorsePkcs11Deleter, seahorse_pkcs11_deleter, SEAHORSE_TYPE_OPERATION);
 
 static void 
-on_deleted (GP11Object *object, GAsyncResult *result, SeahorsePkcs11Deleter *self) 
+on_deleted (GckObject *object, GAsyncResult *result, SeahorsePkcs11Deleter *self)
 {
 	GError *err = NULL;
 	
 	g_return_if_fail (SEAHORSE_IS_PKCS11_DELETER (self));
 	
-	if (!gp11_object_destroy_finish (object, result, &err)) {
+	if (!gck_object_destroy_finish (object, result, &err)) {
 
 		/* Ignore objects that have gone away */
 		if (err->code != CKR_OBJECT_HANDLE_INVALID) { 
@@ -350,8 +350,8 @@ seahorse_pkcs11_deleter_constructor (GType type, guint n_props, GObjectConstruct
 	g_return_val_if_fail (self->object, NULL);
 
 	/* Start the delete */
-	gp11_object_destroy_async (seahorse_pkcs11_object_get_pkcs11_object (self->object),
-	                           self->cancellable, (GAsyncReadyCallback)on_deleted, self);
+	gck_object_destroy_async (seahorse_pkcs11_object_get_pkcs11_object (self->object),
+	                          self->cancellable, (GAsyncReadyCallback)on_deleted, self);
 	seahorse_operation_mark_start (SEAHORSE_OPERATION (self));
 	
 	return G_OBJECT (self);
diff --git a/pkcs11/seahorse-pkcs11-source.c b/pkcs11/seahorse-pkcs11-source.c
index 0a5d99f..27e789b 100644
--- a/pkcs11/seahorse-pkcs11-source.c
+++ b/pkcs11/seahorse-pkcs11-source.c
@@ -49,7 +49,7 @@ enum {
 };
 
 struct _SeahorsePkcs11SourcePrivate {
-	GP11Slot *slot;    
+	GckSlot *slot;
 };
 
 static void seahorse_source_iface (SeahorseSourceIface *iface);
@@ -165,8 +165,8 @@ seahorse_pkcs11_source_class_init (SeahorsePkcs11SourceClass *klass)
     
 	g_object_class_install_property (gobject_class, PROP_SLOT,
 	         g_param_spec_object ("slot", "Slot", "Pkcs#11 SLOT",
-	                              GP11_TYPE_SLOT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
-    
+	                              GCK_TYPE_SLOT, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+
 	g_object_class_install_property (gobject_class, PROP_FLAGS,
 	         g_param_spec_uint ("flags", "Flags", "Object Source flags.", 
 	                            0, G_MAXUINT, 0, G_PARAM_READABLE));
@@ -188,12 +188,12 @@ seahorse_source_iface (SeahorseSourceIface *iface)
  */
 
 SeahorsePkcs11Source*
-seahorse_pkcs11_source_new (GP11Slot *slot)
+seahorse_pkcs11_source_new (GckSlot *slot)
 {
 	return g_object_new (SEAHORSE_TYPE_PKCS11_SOURCE, "slot", slot, NULL);
-}   
+}
 
-GP11Slot*
+GckSlot*
 seahorse_pkcs11_source_get_slot (SeahorsePkcs11Source *self)
 {
 	g_return_val_if_fail (SEAHORSE_IS_PKCS11_SOURCE (self), NULL);
@@ -201,7 +201,7 @@ seahorse_pkcs11_source_get_slot (SeahorsePkcs11Source *self)
 }
 
 void
-seahorse_pkcs11_source_receive_object (SeahorsePkcs11Source *self, GP11Object *obj)
+seahorse_pkcs11_source_receive_object (SeahorsePkcs11Source *self, GckObject *obj)
 {
 	GQuark id = seahorse_pkcs11_object_cannonical_id (obj);
 	SeahorsePkcs11Certificate *cert;
diff --git a/pkcs11/seahorse-pkcs11-source.h b/pkcs11/seahorse-pkcs11-source.h
index 8e9171b..e3102cf 100644
--- a/pkcs11/seahorse-pkcs11-source.h
+++ b/pkcs11/seahorse-pkcs11-source.h
@@ -25,7 +25,7 @@
 
 #include "seahorse-source.h"
 
-#include <gp11.h>
+#include <gck/gck.h>
 
 #define SEAHORSE_TYPE_PKCS11_SOURCE            (seahorse_pkcs11_source_get_type ())
 #define SEAHORSE_PKCS11_SOURCE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), SEAHORSE_TYPE_PKCS11_SOURCE, SeahorsePkcs11Source))
@@ -49,10 +49,10 @@ struct _SeahorsePkcs11SourceClass {
 
 GType                  seahorse_pkcs11_source_get_type          (void);
 
-SeahorsePkcs11Source*  seahorse_pkcs11_source_new               (GP11Slot *slot);
+SeahorsePkcs11Source*  seahorse_pkcs11_source_new               (GckSlot *slot);
 
-GP11Slot*              seahorse_pkcs11_source_get_slot          (SeahorsePkcs11Source *self);
+GckSlot*               seahorse_pkcs11_source_get_slot          (SeahorsePkcs11Source *self);
 
-void                   seahorse_pkcs11_source_receive_object    (SeahorsePkcs11Source *self, GP11Object *obj);
+void                   seahorse_pkcs11_source_receive_object    (SeahorsePkcs11Source *self, GckObject *obj);
 
 #endif /* __SEAHORSE_PKCS11_SOURCE_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]