[gnome-keyring] gck: Cleanup gck API for consistency
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] gck: Cleanup gck API for consistency
- Date: Thu, 25 Aug 2011 10:43:43 +0000 (UTC)
commit 9bda5ed162eadecc6122e6a542ea2808e839ac78
Author: Stef Walter <stefw collabora co uk>
Date: Thu Aug 25 12:33:48 2011 +0200
gck: Cleanup gck API for consistency
* The GCK library is incrementing its major library version number
this release cycle. So take that advantage to cleanup the API
a little bit before stable releases.
daemon/gpg-agent/gkd-gpg-agent-standalone.c | 2 +-
daemon/ssh-agent/gkd-ssh-agent-standalone.c | 2 +-
gck/gck-module.c | 4 +++-
gck/gck-modules.c | 21 +++++++++++----------
gck/gck.h | 4 +++-
gck/gck.symbols | 9 +++++++--
gck/tests/test-gck-crypto.c | 2 +-
gck/tests/test-gck-enumerator.c | 2 +-
gck/tests/test-gck-module.c | 6 +++---
gck/tests/test-gck-modules.c | 2 +-
gck/tests/test-gck-object.c | 2 +-
gck/tests/test-gck-session.c | 2 +-
gck/tests/test-gck-slot.c | 2 +-
gcr/gcr-library.c | 9 +++++++--
14 files changed, 42 insertions(+), 27 deletions(-)
---
diff --git a/daemon/gpg-agent/gkd-gpg-agent-standalone.c b/daemon/gpg-agent/gkd-gpg-agent-standalone.c
index c0e7fe8..4b56dc2 100644
--- a/daemon/gpg-agent/gkd-gpg-agent-standalone.c
+++ b/daemon/gpg-agent/gkd-gpg-agent-standalone.c
@@ -87,7 +87,7 @@ main(int argc, char *argv[])
return 1;
}
- module = gck_module_initialize (argv[1], &error);
+ module = gck_module_initialize (argv[1], NULL, &error);
if (!module) {
g_message ("couldn't load pkcs11 module: %s", egg_error_message (error));
g_clear_error (&error);
diff --git a/daemon/ssh-agent/gkd-ssh-agent-standalone.c b/daemon/ssh-agent/gkd-ssh-agent-standalone.c
index 11e9472..e6920d1 100644
--- a/daemon/ssh-agent/gkd-ssh-agent-standalone.c
+++ b/daemon/ssh-agent/gkd-ssh-agent-standalone.c
@@ -88,7 +88,7 @@ main(int argc, char *argv[])
return 1;
}
- module = gck_module_initialize (argv[1], &error);
+ module = gck_module_initialize (argv[1], NULL, &error);
if (!module) {
g_message ("couldn't load pkcs11 module: %s", egg_error_message (error));
g_clear_error (&error);
diff --git a/gck/gck-module.c b/gck/gck-module.c
index fa2fd84..1b018ed 100644
--- a/gck/gck-module.c
+++ b/gck/gck-module.c
@@ -448,6 +448,7 @@ free_initialize (Initialize *args)
/**
* gck_module_initialize:
* @path: The file system path to the PKCS\#11 module to load.
+ * @cancellable: (allow-none): optional cancellation object
* @error: A location to store an error resulting from a failed load.
*
* Load and initialize a PKCS\#11 module represented by a GckModule object.
@@ -456,6 +457,7 @@ free_initialize (Initialize *args)
**/
GckModule*
gck_module_initialize (const gchar *path,
+ GCancellable *cancellable,
GError **error)
{
Initialize args = { GCK_ARGUMENTS_INIT, 0, };
@@ -465,7 +467,7 @@ gck_module_initialize (const gchar *path,
args.path = g_strdup (path);
- if (!_gck_call_sync (NULL, perform_initialize, NULL, &args, NULL, error)) {
+ if (!_gck_call_sync (NULL, perform_initialize, NULL, &args, cancellable, error)) {
/* A custom error from perform_initialize */
if (args.error) {
diff --git a/gck/gck-modules.c b/gck/gck-modules.c
index fd0d456..8d47ba7 100644
--- a/gck/gck-modules.c
+++ b/gck/gck-modules.c
@@ -88,6 +88,8 @@ free_initialize_registered (InitializeRegistered *args)
/**
* gck_modules_initialize_registered:
+ * @cancellable: (allow-none): optional cancellation object
+ * @error: (allow-none): location to place an error on failure
*
* Load and initialize all the registered modules.
*
@@ -95,21 +97,20 @@ free_initialize_registered (InitializeRegistered *args)
* be released with gck_list_unref_free().
*/
GList*
-gck_modules_initialize_registered (void)
+gck_modules_initialize_registered (GCancellable *cancellable,
+ GError **error)
{
InitializeRegistered args = { GCK_ARGUMENTS_INIT, 0, };
- GError *error = NULL;
-
- if (!_gck_call_sync (NULL, perform_initialize_registered, NULL, &args, NULL, &error)) {
- if (args.error)
- g_warning ("%s", args.error->message);
- else
- g_warning ("couldn't initialize registered PKCS#11 modules: %s",
- error->message);
+
+ if (!_gck_call_sync (NULL, perform_initialize_registered, NULL, &args, cancellable, error)) {
+ if (args.error) {
+ g_clear_error (error);
+ g_propagate_error (error, args.error);
+ args.error = NULL;
+ }
}
g_clear_error (&args.error);
- g_clear_error (&error);
return args.results;
}
diff --git a/gck/gck.h b/gck/gck.h
index cdf280f..13e6ac3 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -299,6 +299,7 @@ GType gck_module_get_type (void) G_GNUC_CONS
GckModule* gck_module_new (CK_FUNCTION_LIST_PTR funcs);
GckModule* gck_module_initialize (const gchar *path,
+ GCancellable *cancellable,
GError **error);
void gck_module_initialize_async (const gchar *path,
@@ -323,7 +324,8 @@ GckModuleInfo* gck_module_get_info (GckModule *self);
GList* gck_module_get_slots (GckModule *self,
gboolean token_present);
-GList* gck_modules_initialize_registered (void);
+GList* gck_modules_initialize_registered (GCancellable *cancellable,
+ GError **error);
void gck_modules_initialize_registered_async (GCancellable *cancellable,
GAsyncReadyCallback callback,
diff --git a/gck/gck.symbols b/gck/gck.symbols
index 2ab48d9..4b708a3 100644
--- a/gck/gck.symbols
+++ b/gck/gck.symbols
@@ -71,12 +71,15 @@ gck_module_get_type
gck_module_hash
gck_module_info_free
gck_module_initialize
+gck_module_initialize_async
+gck_module_initialize_finish
gck_module_new
gck_modules_enumerate_objects
gck_modules_enumerate_uri
gck_modules_get_slots
gck_modules_initialize_registered
-gck_modules_list_registered_paths
+gck_modules_initialize_registered_async
+gck_modules_initialize_registered_finish
gck_modules_object_for_uri
gck_modules_objects_for_uri
gck_modules_token_for_uri
@@ -186,10 +189,12 @@ gck_slot_open_session_full
gck_slot_open_session_full_async
gck_slots_enumerate_objects
gck_string_from_chars
+gck_string_to_chars
gck_token_info_free
gck_uri_build
+gck_uri_data_free
+gck_uri_data_new
gck_uri_get_error_quark
-gck_uri_info_free
gck_uri_parse
gck_value_to_boolean
gck_value_to_ulong
diff --git a/gck/tests/test-gck-crypto.c b/gck/tests/test-gck-crypto.c
index 18e9de6..7959a9d 100644
--- a/gck/tests/test-gck-crypto.c
+++ b/gck/tests/test-gck-crypto.c
@@ -57,7 +57,7 @@ setup (Test *test, gconstpointer unused)
GckSlot *slot;
/* Successful load */
- test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", &err);
+ test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
diff --git a/gck/tests/test-gck-enumerator.c b/gck/tests/test-gck-enumerator.c
index 8049ecd..9287b1b 100644
--- a/gck/tests/test-gck-enumerator.c
+++ b/gck/tests/test-gck-enumerator.c
@@ -48,7 +48,7 @@ setup (Test *test, gconstpointer unused)
GError *err = NULL;
/* Successful load */
- test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", &err);
+ test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
diff --git a/gck/tests/test-gck-module.c b/gck/tests/test-gck-module.c
index 72df360..b5db530 100644
--- a/gck/tests/test-gck-module.c
+++ b/gck/tests/test-gck-module.c
@@ -42,7 +42,7 @@ setup (Test *test, gconstpointer unused)
GError *err = NULL;
/* Successful load */
- test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", &err);
+ test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (test->module);
}
@@ -92,14 +92,14 @@ test_invalid_modules (Test *test, gconstpointer unused)
GError *error = NULL;
/* Shouldn't be able to load modules */
- invalid = gck_module_initialize ("blah-blah-non-existant", &error);
+ invalid = gck_module_initialize ("blah-blah-non-existant", NULL, &error);
g_assert_error (error, GCK_ERROR, (int)CKR_GCK_MODULE_PROBLEM);
g_assert (invalid == NULL);
g_clear_error (&error);
/* Shouldn't be able to load any file successfully */
- invalid = gck_module_initialize ("/usr/lib/libm.so", &error);
+ invalid = gck_module_initialize ("/usr/lib/libm.so", NULL, &error);
g_assert_error (error, GCK_ERROR, (int)CKR_GCK_MODULE_PROBLEM);
g_assert (invalid == NULL);
diff --git a/gck/tests/test-gck-modules.c b/gck/tests/test-gck-modules.c
index 27927c0..246c771 100644
--- a/gck/tests/test-gck-modules.c
+++ b/gck/tests/test-gck-modules.c
@@ -48,7 +48,7 @@ setup (Test *test, gconstpointer unused)
GError *err = NULL;
/* Successful load */
- module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", &err);
+ module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (module));
diff --git a/gck/tests/test-gck-object.c b/gck/tests/test-gck-object.c
index 76afa4c..21d2ea0 100644
--- a/gck/tests/test-gck-object.c
+++ b/gck/tests/test-gck-object.c
@@ -50,7 +50,7 @@ setup (Test *test, gconstpointer unused)
GList *slots;
/* Successful load */
- test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", &err);
+ test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
diff --git a/gck/tests/test-gck-session.c b/gck/tests/test-gck-session.c
index abdd877..e89ce54 100644
--- a/gck/tests/test-gck-session.c
+++ b/gck/tests/test-gck-session.c
@@ -48,7 +48,7 @@ setup (Test *test, gconstpointer unused)
GList *slots;
/* Successful load */
- test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", &err);
+ test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
diff --git a/gck/tests/test-gck-slot.c b/gck/tests/test-gck-slot.c
index 8f76492..175c140 100644
--- a/gck/tests/test-gck-slot.c
+++ b/gck/tests/test-gck-slot.c
@@ -43,7 +43,7 @@ setup (Test *test, gconstpointer unused)
GList *slots;
/* Successful load */
- test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", &err);
+ test->module = gck_module_initialize (BUILDDIR "/.libs/libmock-test-module.so", NULL, &err);
g_assert_no_error (err);
g_assert (GCK_IS_MODULE (test->module));
diff --git a/gcr/gcr-library.c b/gcr/gcr-library.c
index 7a44092..310d7f8 100644
--- a/gcr/gcr-library.c
+++ b/gcr/gcr-library.c
@@ -180,6 +180,7 @@ _gcr_initialize (void)
static volatile gsize gcr_initialized = 0;
CK_FUNCTION_LIST_PTR_PTR module_list;
GPtrArray *uris;
+ GError *error = NULL;
gchar *uri;
guint i;
@@ -189,7 +190,11 @@ _gcr_initialize (void)
if (g_once_init_enter (&gcr_initialized)) {
/* This calls p11_kit_initialize_registered */
- all_modules = gck_modules_initialize_registered ();
+ all_modules = gck_modules_initialize_registered (NULL, &error);
+ if (error != NULL) {
+ g_warning ("%s", error->message);
+ g_clear_error (&error);
+ }
module_list = p11_kit_registered_modules ();
@@ -308,7 +313,7 @@ gcr_pkcs11_add_module_from_file (const gchar *module_path, gpointer unused,
g_return_val_if_fail (module_path, FALSE);
g_return_val_if_fail (!error || !*error, FALSE);
- module = gck_module_initialize (module_path, error);
+ module = gck_module_initialize (module_path, NULL, error);
if (module == NULL)
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]