[gnome-keyring/introspection: 4/5] gck: Fix introspection warnings and complete introspection annotations
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring/introspection: 4/5] gck: Fix introspection warnings and complete introspection annotations
- Date: Wed, 28 Sep 2011 13:16:57 +0000 (UTC)
commit 573515295e6616b3a0187f04ce634d7d11962e7e
Author: Stef Walter <stefw collabora co uk>
Date: Wed Sep 28 14:24:43 2011 +0200
gck: Fix introspection warnings and complete introspection annotations
https://bugzilla.gnome.org/show_bug.cgi?id=655651
.gitignore | 2 +
configure.ac | 3 +
gck/Makefile.am | 53 ++++++++++++++++--
gck/gck-attributes.c | 51 ++++++++++++------
gck/gck-deprecated.h | 51 +++++++++++++++++
gck/gck-enumerator.c | 10 ++--
gck/gck-misc.c | 14 ++++-
gck/gck-module.c | 47 ++++++++++++++---
gck/gck-modules.c | 56 ++++++++++++-------
gck/gck-object.c | 81 +++++++++++++++++-----------
gck/gck-session.c | 110 +++++++++++++++++++++++++-------------
gck/gck-slot.c | 127 +++++++++++++++++++++++++++++++++++--------
gck/gck-uri.c | 42 ++++++++++++++
gck/gck.h | 105 ++++++++++++++++++++++++------------
gck/tests/test-gck-crypto.c | 3 +-
gck/tests/test-gck-object.c | 6 +-
gck/tests/test-gck-slot.c | 2 +-
17 files changed, 574 insertions(+), 189 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 6f93373..d76ebbf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,8 @@ run-tests
*.valid
*.abi
*.pc
+*.gir
+*.typelib
/compile
/ABOUT-NLS
diff --git a/configure.ac b/configure.ac
index 6af8c88..77b7113 100644
--- a/configure.ac
+++ b/configure.ac
@@ -601,14 +601,17 @@ if test "$enable_strict" = "yes"; then
-DG_DISABLE_DEPRECATED \
-DGDK_PIXBUF_DISABLE_DEPRECATED"
TEST_MODE="thorough"
+ INTROSPECTION_FLAGS="--warn-error"
AC_DEFINE_UNQUOTED(WITH_STRICT, 1, [More strict checks])
strict_status="yes (-Werror, thorough tests, fatals, no deprecations)"
else
TEST_MODE="quick"
+ INTROSPECTION_FLAGS=""
strict_status="no (quick tests, non-fatal warnings)"
fi
AC_MSG_RESULT($strict_status)
+AC_SUBST(INTROSPECTION_FLAGS)
AC_SUBST(TEST_MODE)
AC_MSG_CHECKING([whether to build with gcov testing])
diff --git a/gck/Makefile.am b/gck/Makefile.am
index 04807ee..6c4c7a4 100644
--- a/gck/Makefile.am
+++ b/gck/Makefile.am
@@ -4,7 +4,8 @@ SUBDIRS = . tests
incdir = $(includedir)/gck- GCK_MAJOR@/gck
inc_HEADERS = \
- gck.h
+ gck.h \
+ gck-deprecated.h
INCLUDES = \
-I$(top_builddir) \
@@ -23,11 +24,9 @@ BUILT_SOURCES = \
lib_LTLIBRARIES = libgck- GCK_MAJOR@.la
-libgck_ GCK_MAJOR@_la_SOURCES = \
- gck.h gck-private.h pkcs11.h \
+PUBLIC_FILES = \
+ gck.h \
gck-attributes.c \
- gck-call.c \
- gck-debug.c gck-debug.h \
gck-dump.c \
gck-enumerator.c \
gck-misc.c \
@@ -36,7 +35,18 @@ libgck_ GCK_MAJOR@_la_SOURCES = \
gck-object.c \
gck-session.c \
gck-slot.c \
- gck-uri.c \
+ gck-uri.c
+
+INTERNAL_FILES = \
+ gck-call.c \
+ gck-debug.c gck-debug.h \
+ gck-deprecated.h \
+ gck-private.h \
+ pkcs11.h
+
+libgck_ GCK_MAJOR@_la_SOURCES = \
+ $(PUBLIC_FILES) \
+ $(INTERNAL_FILES) \
$(BUILT_SOURCES)
libgck_ GCK_MAJOR@_la_LDFLAGS = \
@@ -69,6 +79,37 @@ gck-marshal.c: gck-marshal.list $(GLIB_GENMARSHAL)
echo "#include \"gck-marshal.h\"" > $@ && \
$(GLIB_GENMARSHAL) $< --body --prefix=_gck_marshal >> $@
+# ------------------------------------------------------------------
+# INTROSPECTION
+
+if HAVE_INTROSPECTION
+
+include $(INTROSPECTION_MAKEFILE)
+
+INTROSPECTION_GIRS = Gck- GCK_MAJOR@.gir
+INTROSPECTION_SCANNER_ARGS = $(INTROSPECTION_FLAGS) --warn-all --add-include-path=$(srcdir) --add-include-path=.
+INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) --includedir=.
+
+Gck- GCK_MAJOR@.gir: libgck- GCK_MAJOR@.la
+
+Gck_ GCK_MAJOR@_gir_PACKAGES = gobject-2.0 gtk+-3.0 p11-kit-1
+Gck_ GCK_MAJOR@_gir_EXPORT_PACKAGES = gck- GCK_MAJOR@
+Gck_ GCK_MAJOR@_gir_INCLUDES = GObject-2.0 Gtk-3.0
+Gck_ GCK_MAJOR@_gir_LIBS = libgck- GCK_MAJOR@.la
+Gck_ GCK_MAJOR@_gir_CFLAGS = -I$(top_srcdir) -I$(top_builddir) -DGCK_COMPILATION -DGCK_API_SUBJECT_TO_CHANGE
+Gck_ GCK_MAJOR@_gir_FILES = $(PUBLIC_FILES)
+Gck_ GCK_MAJOR@_gir_SCANNERFLAGS = --c-include "gck.h"
+
+girdir = $(datadir)/gir-1.0
+gir_DATA = $(INTROSPECTION_GIRS)
+
+typelibsdir = $(libdir)/girepository-1.0
+typelibs_DATA = $(INTROSPECTION_GIRS:.gir=.typelib)
+
+endif
+
+# ----------------------------------------------------------------
+
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = gck-$(GCK_MAJOR).pc
diff --git a/gck/gck-attributes.c b/gck/gck-attributes.c
index 8adb05c..777d816 100644
--- a/gck/gck-attributes.c
+++ b/gck/gck-attributes.c
@@ -74,7 +74,7 @@ attribute_init (GckAttribute *attr, gulong attr_type,
}
/**
- * gck_attribute_init:
+ * gck_attribute_init: (skip):
* @attr: An uninitialized attribute.
* @attr_type: The PKCS\#11 attribute type to set on the attribute.
* @value: The raw value of the attribute.
@@ -95,7 +95,7 @@ gck_attribute_init (GckAttribute *attr, gulong attr_type,
}
/**
- * gck_attribute_init_invalid:
+ * gck_attribute_init_invalid: (skip):
* @attr: An uninitialized attribute.
* @attr_type: The PKCS\#11 attribute type to set on the attribute.
*
@@ -117,7 +117,7 @@ gck_attribute_init_invalid (GckAttribute *attr, gulong attr_type)
}
/**
- * gck_attribute_init_empty:
+ * gck_attribute_init_empty: (skip):
* @attr: An uninitialized attribute.
* @attr_type: The PKCS\#11 attribute type to set on the attribute.
*
@@ -147,7 +147,7 @@ attribute_init_boolean (GckAttribute *attr, gulong attr_type,
}
/**
- * gck_attribute_init_boolean:
+ * gck_attribute_init_boolean: (skip):
* @attr: An uninitialized attribute.
* @attr_type: The PKCS\#11 attribute type to set on the attribute.
* @value: The boolean value of the attribute.
@@ -184,7 +184,7 @@ attribute_init_date (GckAttribute *attr, gulong attr_type,
}
/**
- * gck_attribute_init_date:
+ * gck_attribute_init_date: (skip):
* @attr: An uninitialized attribute.
* @attr_type: The PKCS\#11 attribute type to set on the attribute.
* @value: The date value of the attribute.
@@ -213,7 +213,7 @@ attribute_init_ulong (GckAttribute *attr, gulong attr_type,
}
/**
- * gck_attribute_init_ulong:
+ * gck_attribute_init_ulong: (skip):
* @attr: An uninitialized attribute.
* @attr_type: The PKCS\#11 attribute type to set on the attribute.
* @value: The ulong value of the attribute.
@@ -241,7 +241,7 @@ attribute_init_string (GckAttribute *attr, gulong attr_type,
}
/**
- * gck_attribute_init_string:
+ * gck_attribute_init_string: (skip):
* @attr: An uninitialized attribute.
* @attr_type: The PKCS\#11 attribute type to set on the attribute.
* @value: The null terminated string value of the attribute.
@@ -262,6 +262,20 @@ gck_attribute_init_string (GckAttribute *attr, gulong attr_type,
attribute_init_string (attr, attr_type, value, g_realloc);
}
+GType
+gck_attribute_get_type (void)
+{
+ static volatile gsize initialized = 0;
+ static GType type = 0;
+ if (g_once_init_enter (&initialized)) {
+ type = g_boxed_type_register_static ("GckAttribute",
+ (GBoxedCopyFunc)gck_attribute_dup,
+ (GBoxedFreeFunc)gck_attribute_free);
+ g_once_init_leave (&initialized, 1);
+ }
+ return type;
+}
+
/**
* gck_attribute_new:
* @attr_type: The PKCS\#11 attribute type to set on the attribute.
@@ -743,24 +757,27 @@ struct _GckAttributes {
* Returns: The allocated memory, or NULL when freeing.
**/
-/**
- * gck_attributes_get_boxed_type:
- *
- * Get the boxed type representing a GckAttributes array.
- *
- * Return value: The boxed type.
- **/
GType
-gck_attributes_get_boxed_type (void)
+gck_attributes_get_type (void)
{
+ static volatile gsize initialized = 0;
static GType type = 0;
- if (!type)
+ if (g_once_init_enter (&initialized)) {
type = g_boxed_type_register_static ("GckAttributes",
(GBoxedCopyFunc)gck_attributes_ref,
(GBoxedFreeFunc)gck_attributes_unref);
+ g_once_init_leave (&initialized, 1);
+ }
return type;
}
+GType
+gck_attributes_get_boxed_type (void)
+{
+ /* Deprecated version */
+ return gck_attributes_get_type ();
+}
+
/**
* gck_attributes_new:
*
@@ -776,7 +793,7 @@ gck_attributes_new (void)
}
/**
- * gck_attributes_new_full:
+ * gck_attributes_new_full: (skip):
* @allocator: Memory allocator for attribute data, or NULL for default.
*
* Create a new GckAttributes array.
diff --git a/gck/gck-deprecated.h b/gck/gck-deprecated.h
new file mode 100644
index 0000000..3121a9d
--- /dev/null
+++ b/gck/gck-deprecated.h
@@ -0,0 +1,51 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/* gck-deprecated.h - the GObject PKCS#11 wrapper library
+
+ Copyright (C) 2011 Stefan Walter
+
+ The Gnome Keyring Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public License as
+ published by the Free Software Foundation; either version 2 of the
+ License, or (at your option) any later version.
+
+ The Gnome Keyring Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public
+ License along with the Gnome Library; see the file COPYING.LIB. If not,
+ write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+
+ Author: Stef Walter <stefw collabora co uk>
+*/
+
+#ifndef GCK_DEPRECATED_H
+#define GCK_DEPRECATED_H
+
+#include "gck.h"
+
+G_BEGIN_DECLS
+
+#ifndef GCK_DISABLE_DEPRECATED
+
+typedef GArray GckMechanisms;
+
+#define gck_mechanisms_free(a) (g_array_free (a, TRUE))
+
+#define CKR_GCK_MODULE_PROBLEM GCK_ERROR_MODULE_PROBLEM
+
+GQuark gck_get_error_quark (void);
+
+GQuark gck_uri_get_error_quark (void);
+
+#define GCK_URI_BAD_PREFIX GCK_URI_BAD_SCHEME
+
+GType gck_attributes_get_boxed_type (void) G_GNUC_CONST;
+
+#endif /* GCK_DISABLE_DEPRECATED */
+
+G_END_DECLS
+
+#endif /* GCK_H */
diff --git a/gck/gck-enumerator.c b/gck/gck-enumerator.c
index 4b50580..dfb5bf4 100644
--- a/gck/gck-enumerator.c
+++ b/gck/gck-enumerator.c
@@ -660,8 +660,8 @@ free_enumerate_next (EnumerateNext *args)
* %NULL is also returned if the function fails. Use the @error to determine
* whether a failure occurred or not.
*
- * Returns: The next object, which must be released using g_object_unref,
- * or %NULL.
+ * Returns: (transfer full) (allow-none): The next object, which must be released
+ * using g_object_unref, or %NULL.
*/
GckObject*
gck_enumerator_next (GckEnumerator *self, GCancellable *cancellable, GError **error)
@@ -718,7 +718,8 @@ gck_enumerator_next (GckEnumerator *self, GCancellable *cancellable, GError **er
* %NULL is also returned if the function fails. Use the @error to determine
* whether a failure occurred or not.
*
- * Returns: A list of objects, which should be freed using gck_list_unref_free().
+ * Returns: (transfer full) (element-type Gck.Object): A list of objects, which
+ * should be freed using gck_list_unref_free().
*/
GList*
gck_enumerator_next_n (GckEnumerator *self, gint max_objects, GCancellable *cancellable,
@@ -807,7 +808,8 @@ gck_enumerator_next_async (GckEnumerator *self, gint max_objects, GCancellable *
* %NULL is also returned if the function fails. Use the @error to determine
* whether a failure occurred or not.
*
- * Returns: The list of objects, which should be freed with gck_list_unref_free()
+ * Returns: (element-type Gck.Module) (transfer full): The list of objects, which
+ * should be freed with gck_list_unref_free()
*/
GList*
gck_enumerator_next_finish (GckEnumerator *self, GAsyncResult *result, GError **error)
diff --git a/gck/gck-misc.c b/gck/gck-misc.c
index 563f40d..bcdeebb 100644
--- a/gck/gck-misc.c
+++ b/gck/gck-misc.c
@@ -66,9 +66,17 @@
*
* The error domain for gck library errors.
*/
+
GQuark
gck_get_error_quark (void)
{
+ /* This is the deprecated version */
+ return gck_error_get_quark ();
+}
+
+GQuark
+gck_error_get_quark (void)
+{
static GQuark domain = 0;
static volatile gsize quark_inited = 0;
@@ -90,7 +98,7 @@ gck_get_error_quark (void)
* Return value: The user readable message.
**/
const gchar*
-gck_message_from_rv (CK_RV rv)
+gck_message_from_rv (gulong rv)
{
switch (rv) {
@@ -225,7 +233,7 @@ gck_list_get_boxed_type (void)
}
/**
- * gck_list_unref_free:
+ * gck_list_unref_free: (skip):
* @reflist: List of Gobject reference counted pointers.
*
* Free a list of GObject based pointers. All objects in the list
@@ -243,7 +251,7 @@ gck_list_unref_free (GList *reflist)
}
/**
- * gck_list_ref_copy:
+ * gck_list_ref_copy: (skip):
* @reflist: List of GObject reference counted objects.
*
* Copy a list of GObject based pointers. All objects
diff --git a/gck/gck-module.c b/gck/gck-module.c
index 0015a88..725b12f 100644
--- a/gck/gck-module.c
+++ b/gck/gck-module.c
@@ -353,9 +353,32 @@ gck_module_class_init (GckModuleClass *klass)
g_type_class_add_private (gobject_class, sizeof (GckModulePrivate));
}
-/* ----------------------------------------------------------------------------
- * PUBLIC
- */
+GType
+gck_module_info_get_type (void)
+{
+ static volatile gsize initialized = 0;
+ static GType type = 0;
+ if (g_once_init_enter (&initialized)) {
+ type = g_boxed_type_register_static ("GckModuleInfo",
+ (GBoxedCopyFunc)gck_module_info_copy,
+ (GBoxedFreeFunc)gck_module_info_free);
+ g_once_init_leave (&initialized, 1);
+ }
+ return type;
+}
+
+GckModuleInfo *
+gck_module_info_copy (GckModuleInfo *module_info)
+{
+ if (module_info == NULL)
+ return NULL;
+
+ module_info = g_memdup (module_info, sizeof (GckModuleInfo));
+ module_info->manufacturer_id = g_strdup (module_info->manufacturer_id);
+ module_info->library_description = g_strdup (module_info->library_description);
+ return module_info;
+
+}
/**
* gck_module_info_free:
@@ -453,7 +476,7 @@ free_initialize (Initialize *args)
*
* Load and initialize a PKCS\#11 module represented by a GckModule object.
*
- * Return value: The loaded PKCS\#11 module or NULL if failed.
+ * Return value: (transfer full): The loaded PKCS\#11 module or %NULL if failed.
**/
GckModule*
gck_module_initialize (const gchar *path,
@@ -497,6 +520,15 @@ gck_module_initialize_async (const gchar *path,
_gck_call_async_ready_go (args, cancellable, callback, user_data);
}
+/**
+ * gck_module_initialize_finish:
+ * @result: the asynchronous result
+ * @error: location to place an error on failure
+ *
+ * Finishes the asynchronous initialize operation.
+ *
+ * Returns: (transfer full) (allow-none): The initialized module, or NULL
+ */
GckModule *
gck_module_initialize_finish (GAsyncResult *result,
GError **error)
@@ -522,7 +554,7 @@ gck_module_initialize_finish (GAsyncResult *result,
}
/**
- * gck_module_new:
+ * gck_module_new: (skip):
* @funcs: Initialized PKCS\#11 function list pointer
*
* Create a GckModule representing a PKCS\#11 module. It is assumed that
@@ -665,7 +697,8 @@ gck_module_get_info (GckModule *self)
*
* Get the GckSlot objects for a given module.
*
- * Return value: The possibly empty list of slots. Release this with gck_list_unref_free().
+ * Return value: (element-type Gck.Slot) (transfer full): The possibly empty
+ * list of slots. Release this with gck_list_unref_free().
*/
GList*
gck_module_get_slots (GckModule *self, gboolean token_present)
@@ -723,7 +756,7 @@ gck_module_get_path (GckModule *self)
}
/**
- * gck_module_get_functions:
+ * gck_module_get_functions: (skip):
* @self: The module for which to get the function list.
*
* Get the PKCS\#11 function list for the module.
diff --git a/gck/gck-modules.c b/gck/gck-modules.c
index 4b78ba9..43b52a3 100644
--- a/gck/gck-modules.c
+++ b/gck/gck-modules.c
@@ -93,8 +93,8 @@ free_initialize_registered (InitializeRegistered *args)
*
* Load and initialize all the registered modules.
*
- * Returns: A newly allocated list of GckModule objects, which should
- * be released with gck_list_unref_free().
+ * Returns: (transfer full) (element-type Gck.Module): A newly allocated list
+ * of #GckModule objects, which should be released with gck_list_unref_free().
*/
GList*
gck_modules_initialize_registered (GCancellable *cancellable,
@@ -127,6 +127,17 @@ gck_modules_initialize_registered_async (GCancellable *cancellable,
_gck_call_async_ready_go (args, cancellable, callback, user_data);
}
+/**
+ * gck_modules_initialize_registered_finish:
+ * @result: the asynchronous result
+ * @error: location to place an error on failure
+ *
+ * Finishes the asynchronous operation to initialize the registered
+ * PKCS\#11 modules.
+ *
+ * Returns: (transfer full) (element-type Gck.Module): a list of newly
+ * initialized #GckModule objects
+ */
GList *
gck_modules_initialize_registered_finish (GAsyncResult *result,
GError **error)
@@ -153,13 +164,13 @@ gck_modules_initialize_registered_finish (GAsyncResult *result,
/**
* gck_modules_get_slots:
- * @modules: The modules
+ * @modules: (element-type Gck.Module): The modules
* @token_present: Whether to only list slots with token present
*
* Get a list of slots for across all of the modules.
*
- * Returns: A list of #GckSlot objects, which should be freed with
- * gck_list_unref_free().
+ * Returns: (transfer full) (element-type Gck.Slot): A list of #GckSlot
+ * objects, which should be freed with gck_list_unref_free().
*/
GList*
gck_modules_get_slots (GList *modules, gboolean token_present)
@@ -176,7 +187,7 @@ gck_modules_get_slots (GList *modules, gboolean token_present)
/**
* gck_modules_enumerate_objects:
- * @modules: The modules
+ * @modules: (element-type Gck.Module): The modules
* @attrs: Attributes that the objects must have, or empty for all objects
* @session_options: Options from GckSessionOptions
*
@@ -184,7 +195,8 @@ gck_modules_get_slots (GList *modules, gboolean token_present)
*
* This call will not block but will return an enumerator immediately.
- * Return value: A new enumerator, which should be released with g_object_unref().
+ * Return value: (transfer full): A new enumerator, which should be released
+ * with g_object_unref().
**/
GckEnumerator*
gck_modules_enumerate_objects (GList *modules, GckAttributes *attrs, guint session_options)
@@ -254,14 +266,14 @@ tokens_for_uri (GList *modules,
/**
* gck_modules_token_for_uri:
- * @modules: The modules
+ * @modules: (element-type Gck.Module): The modules
* @uri: The URI that the token must match
* @error: A location to raise an error on failure
*
* Lookup a token that matches the URI.
*
- * Returns: A newly allocated #GckSlot or %NULL if no such token was
- * found.
+ * Returns: (transfer full): A newly allocated #GckSlot or %NULL if no such
+ * token was found.
*/
GckSlot*
gck_modules_token_for_uri (GList *modules,
@@ -281,14 +293,15 @@ gck_modules_token_for_uri (GList *modules,
/**
* gck_modules_tokens_for_uri:
- * @modules: The modules
+ * @modules: (element-type Gck.Module): The modules
* @uri: The URI that the token must match
* @error: A location to raise an error on failure
*
* Lookup a token that matches the URI.
*
- * Returns: (transfer full): A list of newly allocated #GckSlot objects. Use
- * gck_list_unref_free() to release the list once you're done with it.
+ * Returns: (transfer full) (element-type Gck.Slot): A list of newly allocated
+ * #GckSlot objects. Use gck_list_unref_free() to release the list once you're
+ * done with it.
*/
GList *
gck_modules_tokens_for_uri (GList *modules,
@@ -300,7 +313,7 @@ gck_modules_tokens_for_uri (GList *modules,
/**
* gck_modules_object_for_uri:
- * @modules: The modules
+ * @modules: (element-type Gck.Module): The modules
* @uri: The URI the objects must match
* @session_options: Options from GckSessionOptions
* @error: A location to raise an error on failure.
@@ -310,8 +323,8 @@ gck_modules_tokens_for_uri (GList *modules,
* This call can block. Use gck_modules_enumerate_uri() for a non-blocking
* version.
*
- * Returns: A new #GckObject which should be released with g_object_unref(),
- * or %NULL if no matching object was found.
+ * Returns: (transfer full) (allow-none): A new #GckObject which should be released with
+ * g_object_unref(), or %NULL if no matching object was found.
*/
GckObject*
gck_modules_object_for_uri (GList *modules, const gchar *uri, guint session_options,
@@ -335,7 +348,7 @@ gck_modules_object_for_uri (GList *modules, const gchar *uri, guint session_opti
/**
* gck_modules_objects_for_uri:
- * @modules: The modules
+ * @modules: (element-type Gck.Module): The modules
* @uri: The URI the objects must match
* @session_options: Options from GckSessionOptions
* @error: A location to raise an error on failure.
@@ -345,8 +358,9 @@ gck_modules_object_for_uri (GList *modules, const gchar *uri, guint session_opti
* This call can block. Use gck_modules_enumerate_uri() for a non-blocking
* version.
*
- * Returns: A list of #GckObject which should be released with gck_list_unref_free(),
- * or %NULL if no matching object was found.
+ * Returns: (transfer full) (element-type Gck.Object): A list of #GckObject which
+ * should be released with gck_list_unref_free(), or %NULL if no matching object
+ * was found.
*/
GList*
gck_modules_objects_for_uri (GList *modules, const gchar *uri, guint session_options,
@@ -370,7 +384,7 @@ gck_modules_objects_for_uri (GList *modules, const gchar *uri, guint session_opt
/**
* gck_modules_enumerate_uri:
- * @modules: The modules
+ * @modules: (element-type Gck.Module): The modules
* @uri: The URI that the enumerator will match
* @session_options: Options from GckSessionOptions
* @error: A location to raise an error on failure.
@@ -380,7 +394,7 @@ gck_modules_objects_for_uri (GList *modules, const gchar *uri, guint session_opt
* This call will not block. Use the #GckEnumerator functions in order to
* get at the actual objects that match.
*
- * Returns: A new #GckEnumerator, or %NULL if an error occurs.
+ * Returns: (transfer full): A new #GckEnumerator, or %NULL if an error occurs.
*/
GckEnumerator*
gck_modules_enumerate_uri (GList *modules, const gchar *uri, guint session_options,
diff --git a/gck/gck-object.c b/gck/gck-object.c
index 0067188..11ba3b6 100644
--- a/gck/gck-object.c
+++ b/gck/gck-object.c
@@ -192,15 +192,17 @@ gck_object_class_init (GckObjectClass *klass)
/**
* gck_object_from_handle:
* @session: The session through which this object is accessed or created.
- * @handle: The raw handle of the object.
+ * @object_handle: The raw CK_OBJECT_HANDLE of the object.
*
* Initialize a GckObject from a raw PKCS\#11 handle. Normally you would use
* gck_session_create_object() or gck_session_find_objects() to access objects.
*
- * Return value: The new GckObject. You should use g_object_unref() when done with this object.
+ * Return value: (transfer full): The new GckObject. You should use
+ * g_object_unref() when done with this object.
**/
-GckObject*
-gck_object_from_handle (GckSession *session, CK_OBJECT_HANDLE handle)
+GckObject *
+gck_object_from_handle (GckSession *session,
+ gulong object_handle)
{
GckModule *module = NULL;
GckObject *object;
@@ -208,7 +210,11 @@ gck_object_from_handle (GckSession *session, CK_OBJECT_HANDLE handle)
g_return_val_if_fail (GCK_IS_SESSION (session), NULL);
module = gck_session_get_module (session);
- object = g_object_new (GCK_TYPE_OBJECT, "module", module, "handle", handle, "session", session, NULL);
+ object = g_object_new (GCK_TYPE_OBJECT,
+ "module", module,
+ "handle", object_handle,
+ "session", session,
+ NULL);
g_object_unref (module);
return object;
@@ -217,26 +223,29 @@ gck_object_from_handle (GckSession *session, CK_OBJECT_HANDLE handle)
/**
* gck_objects_from_handle_array:
* @session: The session for these objects
- * @handles: The raw object handles.
- * @n_handles: The number of raw object handles.
+ * @object_handles: (array length=n_object_handles): The raw object handles.
+ * @n_object_handles: The number of raw object handles.
*
* Initialize a list of GckObject from raw PKCS\#11 handles. The handles argument must contain
* contiguous CK_OBJECT_HANDLE handles in an array.
*
- * Return value: The list of GckObject. You should use gck_list_unref_free() when done with
- * this list.
+ * Returns: (transfer full) (element-type Gck.Object): The list of #GckObject
+ * objects. You should use gck_list_unref_free() when done with this
+ * list.
**/
-GList*
-gck_objects_from_handle_array (GckSession *session, CK_OBJECT_HANDLE_PTR handles, CK_ULONG n_handles)
+GList *
+gck_objects_from_handle_array (GckSession *session,
+ gulong *object_handles,
+ gulong n_object_handles)
{
GList *results = NULL;
CK_ULONG i;
g_return_val_if_fail (GCK_IS_SESSION (session), NULL);
- g_return_val_if_fail (handles || !n_handles, NULL);
+ g_return_val_if_fail (object_handles == NULL || n_object_handles == 0, NULL);
- for (i = 0; i < n_handles; ++i)
- results = g_list_prepend (results, gck_object_from_handle (session, handles[i]));
+ for (i = 0; i < n_object_handles; ++i)
+ results = g_list_prepend (results, gck_object_from_handle (session, object_handles[i]));
return g_list_reverse (results);
}
@@ -315,9 +324,9 @@ gck_object_hash (gconstpointer object)
*
* Get the raw PKCS\#11 handle of a GckObject.
*
- * Return value: The raw object handle.
+ * Return value: the raw CK_OBJECT_HANDLE object handle
**/
-CK_OBJECT_HANDLE
+gulong
gck_object_get_handle (GckObject *self)
{
g_return_val_if_fail (GCK_IS_OBJECT (self), (CK_OBJECT_HANDLE)-1);
@@ -330,9 +339,9 @@ gck_object_get_handle (GckObject *self)
*
* Get the PKCS\#11 module to which this object belongs.
*
- * Return value: The module, which should be unreffed after use.
+ * Returns: (transfer full): the module, which should be unreffed after use
**/
-GckModule*
+GckModule *
gck_object_get_module (GckObject *self)
{
g_return_val_if_fail (GCK_IS_OBJECT (self), NULL);
@@ -352,9 +361,9 @@ gck_object_get_module (GckObject *self)
* object. By default an object will open and close sessions
* appropriate for its calls.
*
- * Return value: The assigned session, which must be unreffed after use.
+ * Returns: (transfer full): the assigned session, which must be unreffed after use
**/
-GckSession*
+GckSession *
gck_object_get_session (GckObject *self)
{
g_return_val_if_fail (GCK_IS_OBJECT (self), NULL);
@@ -877,11 +886,15 @@ free_get_attribute_data (GetAttributeData *args)
*
* This call may block for an indefinite period.
*
- * Return value: The resulting PKCS\#11 attribute data, or NULL if an error occurred.
+ * Return: (transfer full) (array length=n_data): the resulting PKCS\#11
+ * attribute data, or %NULL if an error occurred
**/
-gpointer
-gck_object_get_data (GckObject *self, gulong attr_type, GCancellable *cancellable,
- gsize *n_data, GError **error)
+guchar *
+gck_object_get_data (GckObject *self,
+ gulong attr_type,
+ GCancellable *cancellable,
+ gsize *n_data,
+ GError **error)
{
g_return_val_if_fail (GCK_IS_OBJECT (self), NULL);
g_return_val_if_fail (n_data, NULL);
@@ -891,7 +904,7 @@ gck_object_get_data (GckObject *self, gulong attr_type, GCancellable *cancellabl
}
/**
- * gck_object_get_data_full:
+ * gck_object_get_data_full: (skip):
* @self: The object to get attribute data from.
* @attr_type: The attribute to get data for.
* @allocator: An allocator with which to allocate memory for the data, or NULL for default.
@@ -904,9 +917,10 @@ gck_object_get_data (GckObject *self, gulong attr_type, GCancellable *cancellabl
*
* This call may block for an indefinite period.
*
- * Return value: The resulting PKCS\#11 attribute data, or NULL if an error occurred.
+ * Returns: (transfer full) (array length=n_data): The resulting PKCS\#11
+ * attribute data, or %NULL if an error occurred.
**/
-gpointer
+guchar *
gck_object_get_data_full (GckObject *self, gulong attr_type, GckAllocator allocator,
GCancellable *cancellable, gsize *n_data, GError **error)
{
@@ -942,7 +956,7 @@ gck_object_get_data_full (GckObject *self, gulong attr_type, GckAllocator alloca
* gck_object_get_data_async:
* @self: The object to get attribute data from.
* @attr_type: The attribute to get data for.
- * @allocator: An allocator with which to allocate memory for the data, or NULL for default.
+ * @allocator: (skip): An allocator with which to allocate memory for the data, or NULL for default.
* @cancellable: Optional cancellation object, or NULL.
* @callback: Called when the operation completes.
* @user_data: Data to be passed to the callback.
@@ -984,11 +998,14 @@ gck_object_get_data_async (GckObject *self, gulong attr_type, GckAllocator alloc
* an object. For convenience the returned data has an extra null terminator,
* not included in the returned length.
*
- * Return value: The PKCS\#11 attribute data or NULL if an error occurred.
+ * Returns: (transfer full) (array length=n_data): The PKCS\#11 attribute data
+ * or %NULL if an error occurred.
**/
-gpointer
-gck_object_get_data_finish (GckObject *self, GAsyncResult *result,
- gsize *n_data, GError **error)
+guchar *
+gck_object_get_data_finish (GckObject *self,
+ GAsyncResult *result,
+ gsize *n_data,
+ GError **error)
{
GetAttributeData *args;
guchar *data;
diff --git a/gck/gck-session.c b/gck/gck-session.c
index 0e9a50c..da22f06 100644
--- a/gck/gck-session.c
+++ b/gck/gck-session.c
@@ -306,6 +306,26 @@ gck_session_class_init (GckSessionClass *klass)
* When done with this structure, release it using gck_session_info_free().
*/
+GType
+gck_session_info_get_type (void)
+{
+ static volatile gsize initialized = 0;
+ static GType type = 0;
+ if (g_once_init_enter (&initialized)) {
+ type = g_boxed_type_register_static ("GckSessionInfo",
+ (GBoxedCopyFunc)gck_session_info_copy,
+ (GBoxedFreeFunc)gck_session_info_free);
+ g_once_init_leave (&initialized, 1);
+ }
+ return type;
+}
+
+GckSessionInfo *
+gck_session_info_copy (GckSessionInfo *session_info)
+{
+ return g_memdup (session_info, sizeof (GckSessionInfo));
+}
+
/**
* gck_session_info_free:
* @session_info: Session info to free.
@@ -323,17 +343,19 @@ gck_session_info_free (GckSessionInfo *session_info)
/**
* gck_session_from_handle:
* @slot: The slot which the session belongs to.
- * @handle: The raw PKCS\#11 handle of the session.
+ * @session_handle: the raw PKCS\#11 handle of the session
* @options: Session options. Those which are used during opening a session have no effect.
*
* Initialize a GckSession object from a raw PKCS\#11 session handle.
* Usually one would use the gck_slot_open_session() function to
* create a session.
*
- * Return value: The new GckSession object.
+ * Returns: (transfer full): the new GckSession object
**/
-GckSession*
-gck_session_from_handle (GckSlot *slot, CK_SESSION_HANDLE handle, guint options)
+GckSession *
+gck_session_from_handle (GckSlot *slot,
+ gulong session_handle,
+ guint options)
{
GckModule *module;
GckSession *session;
@@ -341,9 +363,12 @@ gck_session_from_handle (GckSlot *slot, CK_SESSION_HANDLE handle, guint options)
g_return_val_if_fail (GCK_IS_SLOT (slot), NULL);
module = gck_slot_get_module (slot);
- session = g_object_new (GCK_TYPE_SESSION, "module", module,
- "handle", handle, "slot", slot,
- "options", options, NULL);
+ session = g_object_new (GCK_TYPE_SESSION,
+ "module", module,
+ "handle", session_handle,
+ "slot", slot,
+ "options", options,
+ NULL);
g_object_unref (module);
return session;
@@ -357,7 +382,7 @@ gck_session_from_handle (GckSlot *slot, CK_SESSION_HANDLE handle, guint options)
*
* Return value: The raw session handle.
**/
-CK_SESSION_HANDLE
+gulong
gck_session_get_handle (GckSession *self)
{
g_return_val_if_fail (GCK_IS_SESSION (self), (CK_SESSION_HANDLE)-1);
@@ -370,9 +395,9 @@ gck_session_get_handle (GckSession *self)
*
* Get the PKCS\#11 module to which this session belongs.
*
- * Return value: The module, which should be unreffed after use.
+ * Return: (transfer full): The module, which should be unreffed after use.
**/
-GckModule*
+GckModule *
gck_session_get_module (GckSession *self)
{
g_return_val_if_fail (GCK_IS_SESSION (self), NULL);
@@ -386,9 +411,9 @@ gck_session_get_module (GckSession *self)
*
* Get the PKCS\#11 slot to which this session belongs.
*
- * Return value: The slot, which should be unreffed after use.
+ * Return value: (transfer full): The slot, which should be unreffed after use.
**/
-GckSlot*
+GckSlot *
gck_session_get_slot (GckSession *self)
{
g_return_val_if_fail (GCK_IS_SESSION (self), NULL);
@@ -885,9 +910,9 @@ perform_create_object (CreateObject *args)
* Create a new PKCS\#11 object. This call may block for an
* indefinite period.
*
- * Return value: The newly created object or NULL if an error occurred.
+ * Returns: (transfer full): the newly created object or %NULL if an error occurred
**/
-GckObject*
+GckObject *
gck_session_create_object (GckSession *self, GckAttributes *attrs,
GCancellable *cancellable, GError **error)
{
@@ -942,9 +967,9 @@ gck_session_create_object_async (GckSession *self, GckAttributes *attrs,
*
* Get the result of creating a new PKCS\#11 object.
*
- * Return value: The newly created object or NULL if an error occurred.
+ * Return value: (transfer full): the newly created object or NULL if an error occurred
**/
-GckObject*
+GckObject *
gck_session_create_object_finish (GckSession *self, GAsyncResult *result, GError **error)
{
CreateObject *args;
@@ -1062,9 +1087,10 @@ objlist_from_handles (GckSession *self, CK_OBJECT_HANDLE_PTR objects,
* Find the objects matching the passed attributes. This call may
* block for an indefinite period.
*
- * Return value: A list of the matching objects, which may be empty.
+ * Returns: (transfer full) (element-type Gck.Object): a list of the matching
+ * objects, which may be empty
**/
-GList*
+GList *
gck_session_find_objects (GckSession *self, GckAttributes *attrs,
GCancellable *cancellable, GError **error)
{
@@ -1113,9 +1139,10 @@ gck_session_find_objects_async (GckSession *self, GckAttributes *attrs,
*
* Get the result of a find operation.
*
- * Return value: A list of the matching objects, which may be empty.
+ * Return: (transfer full) (element-type Gck.Object): a list of the matching
+ * objects, which may be empty
**/
-GList*
+GList *
gck_session_find_objects_finish (GckSession *self, GAsyncResult *result, GError **error)
{
FindObjects *args;
@@ -1376,9 +1403,10 @@ perform_wrap_key (WrapKey *args)
* Wrap a key into a byte stream. This call may block for an
* indefinite period.
*
- * Return value: The wrapped data or NULL if the operation failed.
+ * Returns: (transfer full) (array length=n_result): the wrapped data or %NULL
+ * if the operation failed
**/
-gpointer
+guchar *
gck_session_wrap_key (GckSession *self, GckObject *key, gulong mech_type,
GckObject *wrapped, gsize *n_result, GCancellable *cancellable, GError **error)
{
@@ -1399,9 +1427,10 @@ gck_session_wrap_key (GckSession *self, GckObject *key, gulong mech_type,
* Wrap a key into a byte stream. This call may block for an
* indefinite period.
*
- * Return value: The wrapped data or NULL if the operation failed.
+ * Returns: (transfer full) (array length=n_result): the wrapped data or %NULL
+ * if the operation failed
**/
-gpointer
+guchar *
gck_session_wrap_key_full (GckSession *self, GckObject *wrapper, GckMechanism *mechanism,
GckObject *wrapped, gsize *n_result, GCancellable *cancellable,
GError **error)
@@ -1478,9 +1507,10 @@ gck_session_wrap_key_async (GckSession *self, GckObject *key, GckMechanism *mech
*
* Get the result of a wrap key operation.
*
- * Return value: The wrapped data or NULL if the operation failed.
+ * Returns: (transfer full) (array length=n_result): the wrapped data or %NULL
+ * if the operation failed
**/
-gpointer
+guchar *
gck_session_wrap_key_finish (GckSession *self, GAsyncResult *result,
gsize *n_result, GError **error)
{
@@ -1555,9 +1585,10 @@ perform_unwrap_key (UnwrapKey *args)
* Unwrap a key from a byte stream. This call may block for an
* indefinite period.
*
- * Return value: The new unwrapped key or NULL if the operation failed.
+ * Returns: (transfer full): the new unwrapped key or NULL if the
+ * operation failed
**/
-GckObject*
+GckObject *
gck_session_unwrap_key (GckSession *self, GckObject *wrapper, gulong mech_type,
gconstpointer input, gsize n_input, GckAttributes *attrs,
GCancellable *cancellable, GError **error)
@@ -1580,9 +1611,10 @@ gck_session_unwrap_key (GckSession *self, GckObject *wrapper, gulong mech_type,
* Unwrap a key from a byte stream. This call may block for an
* indefinite period.
*
- * Return value: The new unwrapped key or NULL if the operation failed.
+ * Returns: (transfer full): the new unwrapped key or NULL if the operation
+ * failed
**/
-GckObject*
+GckObject *
gck_session_unwrap_key_full (GckSession *self, GckObject *wrapper, GckMechanism *mechanism,
gconstpointer input, gsize n_input, GckAttributes *attrs,
GCancellable *cancellable, GError **error)
@@ -1661,9 +1693,10 @@ gck_session_unwrap_key_async (GckSession *self, GckObject *wrapper, GckMechanism
*
* Get the result of a unwrap key operation.
*
- * Return value: The new unwrapped key or NULL if the operation failed.
+ * Returns: (transfer full): the new unwrapped key or %NULL if the operation
+ * failed.
**/
-GckObject*
+GckObject *
gck_session_unwrap_key_finish (GckSession *self, GAsyncResult *result, GError **error)
{
UnwrapKey *args;
@@ -1725,9 +1758,10 @@ perform_derive_key (DeriveKey *args)
* Derive a key from another key. This call may block for an
* indefinite period.
*
- * Return value: The new derived key or NULL if the operation failed.
+ * Returns: (transfer full): the new derived key or NULL if the operation
+ * failed
**/
-GckObject*
+GckObject *
gck_session_derive_key (GckSession *self, GckObject *base, gulong mech_type,
GckAttributes *attrs, GCancellable *cancellable, GError **error)
{
@@ -1747,7 +1781,8 @@ gck_session_derive_key (GckSession *self, GckObject *base, gulong mech_type,
* Derive a key from another key. This call may block for an
* indefinite period.
*
- * Return value: The new derived key or NULL if the operation failed.
+ * Returns: (transfer full): the new derived key or NULL if the operation
+ * failed
**/
GckObject*
gck_session_derive_key_full (GckSession *self, GckObject *base, GckMechanism *mechanism,
@@ -1822,9 +1857,10 @@ gck_session_derive_key_async (GckSession *self, GckObject *base, GckMechanism *m
*
* Get the result of a derive key operation.
*
- * Return value: The new derived key or NULL if the operation failed.
+ * Returns: (transfer full): the new derived key or %NULL if the operation
+ * failed
**/
-GckObject*
+GckObject *
gck_session_derive_key_finish (GckSession *self, GAsyncResult *result, GError **error)
{
DeriveKey *args;
diff --git a/gck/gck-slot.c b/gck/gck-slot.c
index 3705b39..91671f3 100644
--- a/gck/gck-slot.c
+++ b/gck/gck-slot.c
@@ -204,6 +204,34 @@ gck_slot_class_init (GckSlotClass *klass)
* gck_slot_info_free().
*/
+GType
+gck_slot_info_get_type (void)
+{
+ static volatile gsize initialized = 0;
+ static GType type = 0;
+ if (g_once_init_enter (&initialized)) {
+ type = g_boxed_type_register_static ("GckSlotInfo",
+ (GBoxedCopyFunc)gck_slot_info_copy,
+ (GBoxedFreeFunc)gck_slot_info_free);
+ g_once_init_leave (&initialized, 1);
+ }
+ return type;
+}
+
+GckSlotInfo *
+gck_slot_info_copy (GckSlotInfo *slot_info)
+{
+ if (slot_info == NULL)
+ return NULL;
+
+ slot_info = g_memdup (slot_info, sizeof (GckSlotInfo));
+ slot_info->manufacturer_id = g_strdup (slot_info->manufacturer_id);
+ slot_info->slot_description = g_strdup (slot_info->slot_description);
+
+ return slot_info;
+}
+
+
/**
* gck_slot_info_free:
* @slot_info: The slot info to free, or NULL.
@@ -252,6 +280,34 @@ gck_slot_info_free (GckSlotInfo *slot_info)
* gck_token_info_free().
*/
+GType
+gck_token_info_get_type (void)
+{
+ static volatile gsize initialized = 0;
+ static GType type = 0;
+ if (g_once_init_enter (&initialized)) {
+ type = g_boxed_type_register_static ("GckTokenInfo",
+ (GBoxedCopyFunc)gck_token_info_copy,
+ (GBoxedFreeFunc)gck_token_info_free);
+ g_once_init_leave (&initialized, 1);
+ }
+ return type;
+}
+
+GckTokenInfo *
+gck_token_info_copy (GckTokenInfo *token_info)
+{
+ if (token_info == NULL)
+ return NULL;
+
+ token_info = g_memdup (token_info, sizeof (GckTokenInfo));
+ token_info->label = g_strdup (token_info->label);
+ token_info->manufacturer_id = g_strdup (token_info->manufacturer_id);
+ token_info->model = g_strdup (token_info->model);
+ token_info->serial_number = g_strdup (token_info->serial_number);
+ return token_info;
+}
+
/**
* gck_token_info_free:
* @token_info: The token info to free, or NULL.
@@ -284,6 +340,26 @@ gck_token_info_free (GckTokenInfo *token_info)
* gck_mechanism_info_free().
*/
+GType
+gck_mechanism_info_get_type (void)
+{
+ static volatile gsize initialized = 0;
+ static GType type = 0;
+ if (g_once_init_enter (&initialized)) {
+ type = g_boxed_type_register_static ("GckMechanismInfo",
+ (GBoxedCopyFunc)gck_mechanism_info_copy,
+ (GBoxedFreeFunc)gck_mechanism_info_free);
+ g_once_init_leave (&initialized, 1);
+ }
+ return type;
+}
+
+GckMechanismInfo *
+gck_mechanism_info_copy (GckMechanismInfo *mech_info)
+{
+ return g_memdup (mech_info, sizeof (GckMechanismInfo));
+}
+
/**
* gck_mechanism_info_free:
* @mech_info: The mechanism info to free, or NULL.
@@ -343,14 +419,14 @@ gck_mechanism_info_free (GckMechanismInfo *mech_info)
* Return value: Whether the mechanism is in the list or not.
**/
gboolean
-gck_mechanisms_check (GckMechanisms *mechanisms, ...)
+gck_mechanisms_check (GArray *mechanisms, ...)
{
gboolean found = TRUE;
va_list va;
gulong mech;
gsize i;
- g_return_val_if_fail (mechanisms, FALSE);
+ g_return_val_if_fail (mechanisms != NULL, FALSE);
va_start (va, mechanisms);
for (;;) {
@@ -433,12 +509,16 @@ gck_slot_hash (gconstpointer slot)
*
* Create a new GckSlot object for a raw PKCS\#11 handle.
*
- * Return value: The new GckSlot object.
+ * Returns: (transfer full): The new GckSlot object.
**/
-GckSlot*
-gck_slot_from_handle (GckModule *module, CK_SLOT_ID slot_id)
+GckSlot *
+gck_slot_from_handle (GckModule *module,
+ gulong slot_id)
{
- return g_object_new (GCK_TYPE_SLOT, "module", module, "handle", slot_id, NULL);
+ return g_object_new (GCK_TYPE_SLOT,
+ "module", module,
+ "handle", slot_id,
+ NULL);
}
/**
@@ -447,9 +527,9 @@ gck_slot_from_handle (GckModule *module, CK_SLOT_ID slot_id)
*
* Get the raw PKCS\#11 handle of a slot.
*
- * Return value: The raw handle.
+ * Return value: the raw CK_SLOT_ID handle
**/
-CK_SLOT_ID
+gulong
gck_slot_get_handle (GckSlot *self)
{
g_return_val_if_fail (GCK_IS_SLOT (self), (CK_SLOT_ID)-1);
@@ -462,9 +542,10 @@ gck_slot_get_handle (GckSlot *self)
*
* Get the module that this slot is on.
*
- * Return value: The module, you must unreference this after you're done with it.
+ * Returns: (transfer full): The module, you must unreference this after
+ * you're done with it.
*/
-GckModule*
+GckModule *
gck_slot_get_module (GckSlot *self)
{
g_return_val_if_fail (GCK_IS_SLOT (self), NULL);
@@ -667,10 +748,10 @@ gck_slot_get_token_info (GckSlot *self)
*
* Get the available mechanisms for this slot.
*
- * Return value: A list of the mechanisms for this slot. Use
- * gck_mechanisms_free() when done with this.
+ * Returns: (transfer full): a list of the mechanisms for this slot, which should
+ * be freed with g_array_free ()
**/
-GckMechanisms*
+GArray *
gck_slot_get_mechanisms (GckSlot *self)
{
CK_SLOT_ID handle = (CK_SLOT_ID)-1;
@@ -678,7 +759,7 @@ gck_slot_get_mechanisms (GckSlot *self)
GckModule *module = NULL;
CK_MECHANISM_TYPE_PTR mech_list = NULL;
CK_ULONG count, i;
- GckMechanisms *result;
+ GArray *result;
CK_RV rv;
g_return_val_if_fail (GCK_IS_SLOT (self), NULL);
@@ -805,7 +886,7 @@ gck_slot_has_flags (GckSlot *self, gulong flags)
/**
* gck_slots_enumerate_objects:
- * @slots: a list of #GckSlot to enumerate objects on.
+ * @slots: (element-type Gck.Slot): a list of #GckSlot to enumerate objects on.
* @attrs: Attributes that the objects must have, or empty for all objects.
* @session_options: Options for opening a session.
*
@@ -813,7 +894,7 @@ gck_slot_has_flags (GckSlot *self, gulong flags)
*
* This call will not block but will return an enumerator immediately.
*
- * Return value: a new enumerator
+ * Returns: (transfer full): a new enumerator
**/
GckEnumerator*
gck_slots_enumerate_objects (GList *slots, GckAttributes *attrs, guint session_options)
@@ -919,9 +1000,9 @@ free_open_session (OpenSession *args)
*
* This call may block for an indefinite period.
*
- * Return value: A new session or NULL if an error occurs.
+ * Return value: (transfer full): a new session or %NULL if an error occurs
**/
-GckSession*
+GckSession *
gck_slot_open_session (GckSlot *self, guint options, GCancellable *cancellable,
GError **error)
{
@@ -929,7 +1010,7 @@ gck_slot_open_session (GckSlot *self, guint options, GCancellable *cancellable,
}
/**
- * gck_slot_open_session_full:
+ * gck_slot_open_session_full: (skip):
* @self: The slot to open a session on.
* @options: The options to open the new session with.
* @pkcs11_flags: Additional raw PKCS\#11 flags.
@@ -943,9 +1024,9 @@ gck_slot_open_session (GckSlot *self, guint options, GCancellable *cancellable,
*
* This call may block for an indefinite period.
*
- * Return value: A new session or NULL if an error occurs.
+ * Return value: (transfer full): a new session or %NULL if an error occurs
**/
-GckSession*
+GckSession *
gck_slot_open_session_full (GckSlot *self, guint options, gulong pkcs11_flags, gpointer app_data,
CK_NOTIFY notify, GCancellable *cancellable, GError **error)
{
@@ -1000,7 +1081,7 @@ gck_slot_open_session_async (GckSlot *self, guint options, GCancellable *cancell
}
/**
- * gck_slot_open_session_full_async:
+ * gck_slot_open_session_full_async: (skip):
* @self: The slot to open a session on.
* @options: Options to open the new session with.
* @pkcs11_flags: Additional raw PKCS\#11 flags.
@@ -1050,7 +1131,7 @@ gck_slot_open_session_full_async (GckSlot *self, guint options, gulong pkcs11_fl
* Get the result of an open session operation. If the 'auto reuse' setting is set,
* then this may be a recycled session with the same flags.
*
- * Return value: The new session or NULL if an error occurs.
+ * Return: (transfer full): the new session or %NULL if an error occurs.
*/
GckSession*
gck_slot_open_session_finish (GckSlot *self, GAsyncResult *result, GError **err)
diff --git a/gck/gck-uri.c b/gck/gck-uri.c
index 35cbe6b..c083529 100644
--- a/gck/gck-uri.c
+++ b/gck/gck-uri.c
@@ -105,6 +105,13 @@ struct _GckUri {
GQuark
gck_uri_get_error_quark (void)
{
+ /* This is deprecated version */
+ return gck_uri_get_error_quark ();
+}
+
+GQuark
+gck_uri_error_get_quark (void)
+{
static GQuark domain = 0;
static volatile gsize quark_inited = 0;
@@ -259,6 +266,41 @@ gck_uri_build (GckUriData *uri_data, GckUriFlags flags)
return string;
}
+GType
+gck_uri_data_get_type (void)
+{
+ static volatile gsize initialized = 0;
+ static GType type = 0;
+ if (g_once_init_enter (&initialized)) {
+ type = g_boxed_type_register_static ("GckUriData",
+ (GBoxedCopyFunc)gck_uri_data_copy,
+ (GBoxedFreeFunc)gck_uri_data_free);
+ g_once_init_leave (&initialized, 1);
+ }
+ return type;
+}
+
+/**
+ * gck_uri_data_copy:
+ * @uri_data: URI data to copy
+ *
+ * Copy a #GckUriData
+ *
+ * Returns: (transfer full): newly allocated copy of the uri data
+ */
+GckUriData *
+gck_uri_data_copy (GckUriData *uri_data)
+{
+ GckUriData *copy;
+
+ copy = g_memdup (uri_data, sizeof (GckUriData));
+ copy->attributes = gck_attributes_new ();
+ gck_attributes_add_all (copy->attributes, uri_data->attributes);
+ copy->module_info = gck_module_info_copy (copy->module_info);
+ copy->token_info = gck_token_info_copy (copy->token_info);
+ return copy;
+}
+
/**
* gck_uri_data_free:
* @uri_data: URI data to free.
diff --git a/gck/gck.h b/gck/gck.h
index 42064e3..6eae4e7 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -29,6 +29,7 @@
#include <gio/gio.h>
#include "pkcs11.h"
+#include "gck-deprecated.h"
G_BEGIN_DECLS
@@ -44,11 +45,13 @@ G_BEGIN_DECLS
#define GCK_VENDOR_CODE 0x47434B00 /* GCK */
/* An error code which results from a failure to load the PKCS11 module */
-#define CKR_GCK_MODULE_PROBLEM (CKR_VENDOR_DEFINED | (GCK_VENDOR_CODE + 1))
+typedef enum {
+ GCK_ERROR_MODULE_PROBLEM = (CKR_VENDOR_DEFINED | (GCK_VENDOR_CODE + 1))
+} GckError;
-#define GCK_ERROR (gck_get_error_quark ())
+#define GCK_ERROR (gck_error_get_quark ())
-GQuark gck_get_error_quark (void);
+GQuark gck_error_get_quark (void) G_GNUC_CONST;
#define GCK_TYPE_LIST (gck_list_get_boxed_type ())
@@ -58,7 +61,7 @@ GList* gck_list_ref_copy (GList *reflist);
void gck_list_unref_free (GList *reflist);
-const gchar* gck_message_from_rv (CK_RV rv);
+const gchar* gck_message_from_rv (gulong rv);
gboolean gck_string_to_chars (guchar *data,
gsize max,
@@ -121,6 +124,10 @@ void gck_attribute_init_string (GckAttribute *attr,
void gck_attribute_init_copy (GckAttribute *dest,
const GckAttribute *src);
+#define GCK_TYPE_ATTRIBUTE (gck_attribute_get_type ())
+
+GType gck_attribute_get_type (void) G_GNUC_CONST;
+
GckAttribute* gck_attribute_new (gulong attr_type,
gpointer value,
gsize length);
@@ -167,7 +174,7 @@ typedef struct _GckAttributes GckAttributes;
#define GCK_TYPE_ATTRIBUTES (gck_attributes_get_boxed_type ())
-GType gck_attributes_get_boxed_type (void) G_GNUC_CONST;
+GType gck_attributes_get_type (void) G_GNUC_CONST;
GckAttributes* gck_attributes_new (void);
@@ -268,6 +275,12 @@ typedef struct _GckModuleInfo {
guint8 library_version_minor;
} GckModuleInfo;
+#define GCK_TYPE_MODULE_INFO (gck_module_info_get_type ())
+
+GType gck_module_info_get_type (void) G_GNUC_CONST;
+
+GckModuleInfo * gck_module_info_copy (GckModuleInfo *module_info);
+
void gck_module_info_free (GckModuleInfo *module_info);
#define GCK_TYPE_MODULE (gck_module_get_type())
@@ -437,6 +450,12 @@ typedef struct _GckSlotInfo {
guint8 firmware_version_minor;
} GckSlotInfo;
+#define GCK_TYPE_SLOT_INFO (gck_slot_info_get_type ())
+
+GType gck_slot_info_get_type (void) G_GNUC_CONST;
+
+GckSlotInfo * gck_slot_info_copy (GckSlotInfo *slot_info);
+
void gck_slot_info_free (GckSlotInfo *slot_info);
typedef struct _GckTokenInfo {
@@ -465,6 +484,12 @@ typedef struct _GckTokenInfo {
gboolean gck_token_info_match (GckTokenInfo *match,
GckTokenInfo *info);
+#define GCK_TYPE_TOKEN_INFO (gck_token_info_get_type ())
+
+GType gck_token_info_get_type (void) G_GNUC_CONST;
+
+GckTokenInfo * gck_token_info_copy (GckTokenInfo *token_info);
+
void gck_token_info_free (GckTokenInfo *token_info);
typedef struct _GckMechanismInfo {
@@ -473,17 +498,19 @@ typedef struct _GckMechanismInfo {
gulong flags;
} GckMechanismInfo;
-void gck_mechanism_info_free (GckMechanismInfo *mech_info);
+#define GCK_TYPE_MECHANISM_INFO (gck_mechanism_info_get_type ())
-typedef GArray GckMechanisms;
+GType gck_mechanism_info_get_type (void) G_GNUC_CONST;
-#define gck_mechanisms_length(a) ((a)->len)
+GckMechanismInfo * gck_mechanism_info_copy (GckMechanismInfo *mech_info);
+
+void gck_mechanism_info_free (GckMechanismInfo *mech_info);
-#define gck_mechanisms_at(a, i) (g_array_index(a, CK_MECHANISM_TYPE, i))
+#define gck_mechanisms_length(a) ((a)->len)
-#define gck_mechanisms_free(a) (g_array_free(a, TRUE))
+#define gck_mechanisms_at(a, i) (g_array_index (a, CK_MECHANISM_TYPE, i))
-gboolean gck_mechanisms_check (GckMechanisms *mechanisms,
+gboolean gck_mechanisms_check (GArray *mechanisms,
...);
#define GCK_TYPE_SLOT (gck_slot_get_type())
@@ -522,17 +549,17 @@ gboolean gck_slot_match (GckSlot *self,
GckUriData *uri);
GckSlot* gck_slot_from_handle (GckModule *module,
- CK_SLOT_ID slot_id);
+ gulong slot_id);
GckModule* gck_slot_get_module (GckSlot *self);
-CK_SLOT_ID gck_slot_get_handle (GckSlot *self);
+gulong gck_slot_get_handle (GckSlot *self);
GckSlotInfo* gck_slot_get_info (GckSlot *self);
GckTokenInfo* gck_slot_get_token_info (GckSlot *self);
-GckMechanisms* gck_slot_get_mechanisms (GckSlot *self);
+GArray * gck_slot_get_mechanisms (GckSlot *self);
GckMechanismInfo* gck_slot_get_mechanism_info (GckSlot *self,
gulong mech_type);
@@ -593,6 +620,12 @@ typedef struct _GckSessionInfo {
gulong device_error;
} GckSessionInfo;
+#define GCK_TYPE_SESSION_INFO (gck_session_info_get_type ())
+
+GType gck_session_info_get_type (void) G_GNUC_CONST;
+
+GckSessionInfo * gck_session_info_copy (GckSessionInfo *session_info);
+
void gck_session_info_free (GckSessionInfo *session_info);
#define GCK_TYPE_SESSION (gck_session_get_type())
@@ -624,15 +657,15 @@ struct _GckSessionClass {
GType gck_session_get_type (void) G_GNUC_CONST;
-GckSession* gck_session_from_handle (GckSlot *slot,
- CK_SESSION_HANDLE handle,
+GckSession * gck_session_from_handle (GckSlot *slot,
+ gulong session_handle,
guint options);
GckModule* gck_session_get_module (GckSession *self);
GckSlot* gck_session_get_slot (GckSession *self);
-CK_SESSION_HANDLE gck_session_get_handle (GckSession *self);
+gulong gck_session_get_handle (GckSession *self);
GckSessionInfo* gck_session_get_info (GckSession *self);
@@ -903,7 +936,7 @@ gboolean gck_session_verify_finish (GckSession *self,
GAsyncResult *result,
GError **error);
-gpointer gck_session_wrap_key (GckSession *self,
+guchar * gck_session_wrap_key (GckSession *self,
GckObject *wrapper,
gulong mech_type,
GckObject *wrapped,
@@ -911,7 +944,7 @@ gpointer gck_session_wrap_key (GckSession *self,
GCancellable *cancellable,
GError **error);
-gpointer gck_session_wrap_key_full (GckSession *self,
+guchar * gck_session_wrap_key_full (GckSession *self,
GckObject *wrapper,
GckMechanism *mechanism,
GckObject *wrapped,
@@ -927,7 +960,7 @@ void gck_session_wrap_key_async (GckSession *self,
GAsyncReadyCallback callback,
gpointer user_data);
-gpointer gck_session_wrap_key_finish (GckSession *self,
+guchar * gck_session_wrap_key_finish (GckSession *self,
GAsyncResult *result,
gsize *n_result,
GError **error);
@@ -1019,12 +1052,12 @@ struct _GckObjectClass {
GType gck_object_get_type (void) G_GNUC_CONST;
-GckObject* gck_object_from_handle (GckSession *session,
- CK_OBJECT_HANDLE handle);
+GckObject * gck_object_from_handle (GckSession *session,
+ gulong object_handle);
GList* gck_objects_from_handle_array (GckSession *session,
- CK_OBJECT_HANDLE_PTR handles,
- CK_ULONG n_handles);
+ gulong *object_handles,
+ gulong n_object_handles);
gboolean gck_object_equal (gconstpointer object1,
gconstpointer object2);
@@ -1033,7 +1066,7 @@ guint gck_object_hash (gconstpointer objec
GckModule* gck_object_get_module (GckObject *self);
-CK_OBJECT_HANDLE gck_object_get_handle (GckObject *self);
+gulong gck_object_get_handle (GckObject *self);
GckSession* gck_object_get_session (GckObject *self);
@@ -1087,13 +1120,13 @@ GckAttributes* gck_object_get_finish (GckObject *self,
GAsyncResult *result,
GError **error);
-gpointer gck_object_get_data (GckObject *self,
+guchar * gck_object_get_data (GckObject *self,
gulong attr_type,
GCancellable *cancellable,
gsize *n_data,
GError **error);
-gpointer gck_object_get_data_full (GckObject *self,
+guchar * gck_object_get_data_full (GckObject *self,
gulong attr_type,
GckAllocator allocator,
GCancellable *cancellable,
@@ -1107,7 +1140,7 @@ void gck_object_get_data_async (GckObject *self,
GAsyncReadyCallback callback,
gpointer user_data);
-gpointer gck_object_get_data_finish (GckObject *self,
+guchar * gck_object_get_data_finish (GckObject *self,
GAsyncResult *result,
gsize *n_data,
GError **error);
@@ -1148,15 +1181,13 @@ GckAttributes* gck_object_get_template_finish (GckObject *self,
* URI
*/
-enum {
+typedef enum {
GCK_URI_BAD_SCHEME = 1,
GCK_URI_BAD_ENCODING,
GCK_URI_BAD_SYNTAX,
GCK_URI_BAD_VERSION,
GCK_URI_NOT_FOUND
-};
-
-#define GCK_URI_BAD_PREFIX GCK_URI_BAD_SCHEME
+} GckUriError;
/* WARNING: Don't modify these without syncing with p11-kit */
typedef enum {
@@ -1186,9 +1217,9 @@ struct _GckUriData {
gpointer dummy[4];
};
-#define GCK_URI_ERROR (gck_uri_get_error_quark ())
+#define GCK_URI_ERROR (gck_uri_error_get_quark ())
-GQuark gck_uri_get_error_quark (void);
+GQuark gck_uri_error_get_quark (void) G_GNUC_CONST;
GckUriData* gck_uri_data_new (void);
@@ -1199,6 +1230,12 @@ GckUriData* gck_uri_parse (const gchar *string
GckUriFlags flags,
GError **error);
+#define GCK_URI_DATA_TYPE (gck_uri_data_get_type ())
+
+GType gck_uri_data_get_type (void) G_GNUC_CONST;
+
+GckUriData * gck_uri_data_copy (GckUriData *uri_data);
+
void gck_uri_data_free (GckUriData *uri_data);
G_END_DECLS
diff --git a/gck/tests/test-gck-crypto.c b/gck/tests/test-gck-crypto.c
index 7959a9d..d778541 100644
--- a/gck/tests/test-gck-crypto.c
+++ b/gck/tests/test-gck-crypto.c
@@ -112,7 +112,8 @@ find_key (GckSession *session, CK_ATTRIBUTE_TYPE method, CK_MECHANISM_TYPE mech)
for (l = objects; l; l = g_list_next (l)) {
if (mech) {
- mechs = gck_object_get_data (l->data, CKA_ALLOWED_MECHANISMS, NULL, &n_mechs, NULL);
+ mechs = (gulong *)gck_object_get_data (l->data, CKA_ALLOWED_MECHANISMS,
+ NULL, &n_mechs, NULL);
g_assert (mechs);
g_assert (n_mechs == sizeof (CK_MECHANISM_TYPE));
/* We know all of them only have one allowed mech */
diff --git a/gck/tests/test-gck-object.c b/gck/tests/test-gck-object.c
index 21d2ea0..46e883b 100644
--- a/gck/tests/test-gck-object.c
+++ b/gck/tests/test-gck-object.c
@@ -274,7 +274,7 @@ test_get_data_attribute (Test *test, gconstpointer unused)
GError *err = NULL;
/* Simple */
- klass = gck_object_get_data (test->object, CKA_CLASS, NULL, &n_data, &err);
+ klass = (gulong *)gck_object_get_data (test->object, CKA_CLASS, NULL, &n_data, &err);
g_assert_no_error (err);
g_assert (klass);
g_assert (n_data == sizeof (CK_OBJECT_CLASS));
@@ -282,7 +282,7 @@ test_get_data_attribute (Test *test, gconstpointer unused)
g_free (klass);
/* Full */
- klass = gck_object_get_data_full (test->object, CKA_CLASS, NULL, NULL, &n_data, &err);
+ klass = (gulong *)gck_object_get_data_full (test->object, CKA_CLASS, NULL, NULL, &n_data, &err);
g_assert_no_error (err);
g_assert (klass);
g_assert (n_data == sizeof (CK_OBJECT_CLASS));
@@ -294,7 +294,7 @@ test_get_data_attribute (Test *test, gconstpointer unused)
egg_test_wait_until (500);
g_assert (result != NULL);
- klass = gck_object_get_data_finish (test->object, result, &n_data, &err);
+ klass = (gulong *)gck_object_get_data_finish (test->object, result, &n_data, &err);
g_object_unref (result);
g_assert_no_error (err);
g_assert (klass);
diff --git a/gck/tests/test-gck-slot.c b/gck/tests/test-gck-slot.c
index 175c140..affc3b2 100644
--- a/gck/tests/test-gck-slot.c
+++ b/gck/tests/test-gck-slot.c
@@ -163,7 +163,7 @@ test_slot_equals_hash (Test *test, gconstpointer unused)
static void
test_slot_mechanisms (Test *test, gconstpointer unused)
{
- GckMechanisms *mechs;
+ GArray *mechs;
GckMechanismInfo *info;
guint i;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]