gnome-keyring r1432 - in trunk: . gp11 gp11/tests
- From: nnielsen svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-keyring r1432 - in trunk: . gp11 gp11/tests
- Date: Mon, 5 Jan 2009 04:29:23 +0000 (UTC)
Author: nnielsen
Date: Mon Jan 5 04:29:23 2009
New Revision: 1432
URL: http://svn.gnome.org/viewvc/gnome-keyring?rev=1432&view=rev
Log:
* gp11/gp11.h:
* gp11/gp11-module.c:
* gp11/tests/unit-test-gp11-module.c: Fine tune function signatures.
Modified:
trunk/ChangeLog
trunk/gp11/gp11-module.c
trunk/gp11/gp11.h
trunk/gp11/tests/unit-test-gp11-module.c
Modified: trunk/gp11/gp11-module.c
==============================================================================
--- trunk/gp11/gp11-module.c (original)
+++ trunk/gp11/gp11-module.c Mon Jan 5 04:29:23 2009
@@ -966,20 +966,31 @@
* gp11_object_get_session() function on the resulting objects.
*
* The function can return FALSE to stop the enumeration.
+ *
+ * Return value: If FALSE then an error prevented all matching objects from being enumerated.
**/
-void
+gboolean
gp11_module_enumerate_objects (GP11Module *self, GP11ObjectForeachFunc func,
gpointer user_data, ...)
{
GP11Attributes *attrs;
+ GError *error = NULL;
va_list va;
va_start (va, user_data);
attrs = gp11_attributes_new_valist (g_realloc, va);
va_end (va);
- gp11_module_enumerate_objects_full (self, attrs, NULL, func, user_data);
+ gp11_module_enumerate_objects_full (self, attrs, NULL, func, user_data, &error);
gp11_attributes_unref (attrs);
+
+ if (error != NULL) {
+ g_warning ("enumerating objects failed: %s", error->message);
+ g_clear_error (&error);
+ return FALSE;
+ }
+
+ return TRUE;
}
/**
@@ -989,6 +1000,7 @@
* @cancellable: Optional cancellation object, or NULL.
* @func: Function to call for each object.
* @user_data: Data to pass to the function.
+ * @error: Location to return error information.
*
* Call a function for every matching object on the module. This call may
* block for an indefinite period.
@@ -1001,16 +1013,18 @@
* gp11_object_get_session() function on the resulting objects.
*
* The function can return FALSE to stop the enumeration.
+ *
+ * Return value: If FALSE then an error prevented all matching objects from being enumerated.
**/
-void
+gboolean
gp11_module_enumerate_objects_full (GP11Module *self, GP11Attributes *attrs,
GCancellable *cancellable, GP11ObjectForeachFunc func,
- gpointer user_data)
+ gpointer user_data, GError **error)
{
gboolean stop = FALSE;
+ gboolean ret = TRUE;
GList *objects, *o;
GList *slots, *l;
- GError *error = NULL;
GP11Session *session;
g_return_if_fail (GP11_IS_MODULE (self));
@@ -1020,17 +1034,18 @@
gp11_attributes_ref (attrs);
slots = gp11_module_get_slots (self, TRUE);
- for (l = slots; !stop && l; l = g_list_next (l)) {
- session = gp11_slot_open_session (l->data, CKF_SERIAL_SESSION, &error);
- if (error) {
- g_warning ("couldn't open session on slot: %s", error->message);
- g_clear_error (&error);
+ for (l = slots; ret && !stop && l; l = g_list_next (l)) {
+ session = gp11_slot_open_session (l->data, CKF_SERIAL_SESSION, error);
+ if (!session) {
+ ret = FALSE;
+ continue;
}
- objects = gp11_session_find_objects_full (session, attrs, cancellable, &error);
- if (error) {
- g_warning ("couldn't find objects on slot: %s", error->message);
- g_clear_error (&error);
+ objects = gp11_session_find_objects_full (session, attrs, cancellable, error);
+ if (*error) {
+ ret = FALSE;
+ g_object_unref (session);
+ continue;
}
for (o = objects; !stop && o; o = g_list_next (o)) {
@@ -1047,5 +1062,7 @@
gp11_list_unref_free (slots);
gp11_attributes_unref (attrs);
+
+ return ret;
}
Modified: trunk/gp11/gp11.h
==============================================================================
--- trunk/gp11/gp11.h (original)
+++ trunk/gp11/gp11.h Mon Jan 5 04:29:23 2009
@@ -295,16 +295,17 @@
void gp11_module_set_auto_authenticate (GP11Module *self,
gboolean auto_authenticate);
-void gp11_module_enumerate_objects (GP11Module *self,
+gboolean gp11_module_enumerate_objects (GP11Module *self,
GP11ObjectForeachFunc func,
gpointer user_data,
...);
-void gp11_module_enumerate_objects_full (GP11Module *self,
+gboolean gp11_module_enumerate_objects_full (GP11Module *self,
GP11Attributes *attrs,
GCancellable *cancellable,
GP11ObjectForeachFunc func,
- gpointer user_data);
+ gpointer user_data,
+ GError **error);
#ifdef UNIMPLEMENTED
void gp11_module_enumerate_objects_async (GP11Module *self,
Modified: trunk/gp11/tests/unit-test-gp11-module.c
==============================================================================
--- trunk/gp11/tests/unit-test-gp11-module.c (original)
+++ trunk/gp11/tests/unit-test-gp11-module.c Mon Jan 5 04:29:23 2009
@@ -103,9 +103,11 @@
{
GP11Session *session;
GP11Attributes *attrs;
+ gboolean ret;
attrs = gp11_attributes_new ();
- gp11_module_enumerate_objects_full (module, attrs, NULL, for_first_object, "first");
+ ret = gp11_module_enumerate_objects_full (module, attrs, NULL, for_first_object, "first", NULL);
+ g_assert (ret);
g_assert_cmpint (n_objects, ==, 1);
g_assert (GP11_IS_OBJECT (last_object));
gp11_attributes_unref (attrs);
@@ -118,9 +120,10 @@
last_object = NULL;
n_objects = 0;
- gp11_module_enumerate_objects (module, for_each_object, "blah",
- CKA_CLASS, GP11_ULONG, CKO_PRIVATE_KEY,
- GP11_INVALID);
+ ret = gp11_module_enumerate_objects (module, for_each_object, "blah",
+ CKA_CLASS, GP11_ULONG, CKO_PRIVATE_KEY,
+ GP11_INVALID);
+ g_assert (ret);
g_assert_cmpint (n_objects, ==, 2);
g_assert (GP11_IS_OBJECT (last_object));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]