[gnome-keyring/dbus-api] [gp11] CK_NOTIFY accepted when opening a session.
- From: Stefan Walter <stefw src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-keyring/dbus-api] [gp11] CK_NOTIFY accepted when opening a session.
- Date: Sun, 23 Aug 2009 01:59:03 +0000 (UTC)
commit e0d1520333dd15c75658d09a228a66a28acab850
Author: Stef Walter <stef memberwebs com>
Date: Sat Aug 22 20:07:39 2009 +0000
[gp11] CK_NOTIFY accepted when opening a session.
The gp11_slot_open_session_full() and gp11_slot_open_session_async()
functions now accept CK_NOTIFY and app data parameters.
gcr/gcr-importer.c | 4 ++--
gp11/gp11-object.c | 3 ++-
gp11/gp11-slot.c | 20 ++++++++++++++++----
gp11/gp11.h | 4 ++++
gp11/tests/unit-test-gp11-session.c | 8 ++++----
5 files changed, 28 insertions(+), 11 deletions(-)
---
diff --git a/gcr/gcr-importer.c b/gcr/gcr-importer.c
index 07592df..8fcc3f6 100644
--- a/gcr/gcr-importer.c
+++ b/gcr/gcr-importer.c
@@ -258,10 +258,10 @@ state_open_session (GcrImporter *self, gboolean async)
} else {
if (async) {
- gp11_slot_open_session_async (self->pv->slot, CKF_RW_SESSION,
+ gp11_slot_open_session_async (self->pv->slot, CKF_RW_SESSION, NULL, NULL,
self->pv->cancel, on_open_session, self);
} else {
- session = gp11_slot_open_session_full (self->pv->slot, CKF_RW_SESSION,
+ session = gp11_slot_open_session_full (self->pv->slot, CKF_RW_SESSION, NULL, NULL,
self->pv->cancel, &error);
complete_open_session (self, session, error);
}
diff --git a/gp11/gp11-object.c b/gp11/gp11-object.c
index 9952e06..76cac86 100644
--- a/gp11/gp11-object.c
+++ b/gp11/gp11-object.c
@@ -129,7 +129,8 @@ require_session_async (GP11Object *self, GP11Call *call,
run_call_with_session (call, session);
g_object_unref (session);
} else {
- gp11_slot_open_session_async (data->slot, flags, cancellable, opened_session, call);
+ gp11_slot_open_session_async (data->slot, flags, NULL, NULL,
+ cancellable, opened_session, call);
}
}
diff --git a/gp11/gp11-slot.c b/gp11/gp11-slot.c
index ed44c48..7f4887c 100644
--- a/gp11/gp11-slot.c
+++ b/gp11/gp11-slot.c
@@ -822,6 +822,8 @@ typedef struct OpenSession {
GP11Arguments base;
GP11Slot *slot;
gulong flags;
+ gpointer app_data;
+ CK_NOTIFY notify;
gchar *password;
gboolean auto_login;
CK_SESSION_HANDLE session;
@@ -839,7 +841,7 @@ perform_open_session (OpenSession *args)
/* First step, open session */
if (!args->session) {
rv = (args->base.pkcs11->C_OpenSession) (args->base.handle, args->flags,
- NULL, NULL, &args->session);
+ args->app_data, args->notify, &args->session);
}
if (rv != CKR_OK || !args->auto_login)
@@ -910,13 +912,15 @@ free_open_session (OpenSession *args)
GP11Session*
gp11_slot_open_session (GP11Slot *self, gulong flags, GError **err)
{
- return gp11_slot_open_session_full (self, flags, NULL, err);
+ return gp11_slot_open_session_full (self, flags, NULL, NULL, NULL, err);
}
/**
* gp11_slot_open_session_full:
* @self: The slot to open a session on.
* @flags: The flags to open a session with.
+ * @app_data: Application data for notification callback.
+ * @notify: PKCS#11 notification callback.
* @cancellable: Optional cancellation object, or NULL.
* @err: A location to return an error, or NULL.
*
@@ -928,7 +932,8 @@ gp11_slot_open_session (GP11Slot *self, gulong flags, GError **err)
* Return value: A new session or NULL if an error occurs.
**/
GP11Session*
-gp11_slot_open_session_full (GP11Slot *self, gulong flags, GCancellable *cancellable, GError **err)
+gp11_slot_open_session_full (GP11Slot *self, gulong flags, gpointer app_data,
+ CK_NOTIFY notify, GCancellable *cancellable, GError **err)
{
GP11Session *session = NULL;
GP11Module *module = NULL;
@@ -952,6 +957,8 @@ gp11_slot_open_session_full (GP11Slot *self, gulong flags, GCancellable *cancell
args.slot = self;
args.flags = flags;
+ args.app_data = app_data;
+ args.notify = notify;
args.password = NULL;
args.auto_login = (gp11_module_get_auto_authenticate (module) & GP11_AUTHENTICATE_TOKENS) ? TRUE : FALSE;
args.session = 0;
@@ -970,6 +977,8 @@ gp11_slot_open_session_full (GP11Slot *self, gulong flags, GCancellable *cancell
* gp11_slot_open_session_async:
* @self: The slot to open a session on.
* @flags: The flags to open a session with.
+ * @app_data: Application data for notification callback.
+ * @notify: PKCS#11 notification callback.
* @cancellable: Optional cancellation object, or NULL.
* @callback: Called when the operation completes.
* @user_data: Data to pass to the callback.
@@ -980,7 +989,8 @@ gp11_slot_open_session_full (GP11Slot *self, gulong flags, GCancellable *cancell
* This call will return immediately and complete asynchronously.
**/
void
-gp11_slot_open_session_async (GP11Slot *self, gulong flags, GCancellable *cancellable,
+gp11_slot_open_session_async (GP11Slot *self, gulong flags, gpointer app_data,
+ CK_NOTIFY notify, GCancellable *cancellable,
GAsyncReadyCallback callback, gpointer user_data)
{
GP11Module *module = NULL;
@@ -996,6 +1006,8 @@ gp11_slot_open_session_async (GP11Slot *self, gulong flags, GCancellable *cancel
sizeof (*args), free_open_session);
args->flags = flags;
+ args->app_data = app_data;
+ args->notify = notify;
args->slot = g_object_ref (self);
/* Try to use a cached session */
diff --git a/gp11/gp11.h b/gp11/gp11.h
index 0ae1821..5d4ab4a 100644
--- a/gp11/gp11.h
+++ b/gp11/gp11.h
@@ -486,11 +486,15 @@ GP11Session* gp11_slot_open_session (GP11Slot *self,
GP11Session* gp11_slot_open_session_full (GP11Slot *self,
gulong flags,
+ gpointer app_data,
+ CK_NOTIFY notify,
GCancellable *cancellable,
GError **err);
void gp11_slot_open_session_async (GP11Slot *self,
gulong flags,
+ gpointer app_data,
+ CK_NOTIFY notify,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
diff --git a/gp11/tests/unit-test-gp11-session.c b/gp11/tests/unit-test-gp11-session.c
index 7a043f0..6141157 100644
--- a/gp11/tests/unit-test-gp11-session.c
+++ b/gp11/tests/unit-test-gp11-session.c
@@ -81,13 +81,13 @@ DEFINE_TEST(open_close_session)
GAsyncResult *result = NULL;
GError *err = NULL;
- sess = gp11_slot_open_session_full (slot, 0, NULL, &err);
+ sess = gp11_slot_open_session_full (slot, 0, NULL, NULL, NULL, &err);
SUCCESS_RES (sess, err);
g_object_unref (sess);
/* Test opening async */
- gp11_slot_open_session_async (slot, 0, NULL, fetch_async_result, &result);
+ gp11_slot_open_session_async (slot, 0, NULL, NULL, NULL, fetch_async_result, &result);
WAIT_UNTIL (result);
g_assert (result != NULL);
@@ -130,7 +130,7 @@ DEFINE_TEST(open_reused)
g_object_unref (sess);
/* Test opening async */
- gp11_slot_open_session_async (slot, 0, NULL, fetch_async_result, &result);
+ gp11_slot_open_session_async (slot, 0, NULL, NULL, NULL, fetch_async_result, &result);
WAIT_UNTIL (result);
g_assert (result != NULL);
sess = gp11_slot_open_session_finish (slot, result, &err);
@@ -262,7 +262,7 @@ DEFINE_TEST(auto_login)
SUCCESS_RES (ret, err);
/* Now try the same thing, but asyncronously */
- gp11_slot_open_session_async (slot, CKF_RW_SESSION, NULL, fetch_async_result, &result);
+ gp11_slot_open_session_async (slot, CKF_RW_SESSION, NULL, NULL, NULL, fetch_async_result, &result);
WAIT_UNTIL (result);
g_assert (result != NULL);
new_session = gp11_slot_open_session_finish (slot, result, &err);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]