[libgnome-keyring] Box structs to make them introspectable
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgnome-keyring] Box structs to make them introspectable
- Date: Wed, 18 Jan 2012 09:14:48 +0000 (UTC)
commit b5ad592e92f294855cdb4ccd95dd9dfd51c58fb5
Author: Martin Pitt <martin pitt ubuntu com>
Date: Sat Jan 14 10:18:44 2012 +0100
Box structs to make them introspectable
Add boxing for our structs so that introspection bindings can handle them.
Note that we cannot use the standard G_DEFINE_BOXED_TYPE for
GnomeKeyringItemInfo, as gnome_keyring_item_info_get_type() already exists.
Manually define the GType construction for this.
Check for and link to gobject-2.0 to get g_boxed_type_register_static().
Bump library version info as this adds some new API.
configure.ac | 4 +-
.../gnome-keyring/gnome-keyring-sections.txt | 30 +++++
library/gnome-keyring-utils.c | 121 ++++++++++++++++++++
library/gnome-keyring.h | 28 ++++-
4 files changed, 178 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6738407..0addf28 100644
--- a/configure.ac
+++ b/configure.ac
@@ -20,7 +20,7 @@ AM_PROG_LIBTOOL
IT_PROG_INTLTOOL([0.35.0])
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
-LIB_GNOME_KEYRING_LT_VERSION=1:1:1
+LIB_GNOME_KEYRING_LT_VERSION=2:0:2
AC_SUBST(LIB_GNOME_KEYRING_LT_VERSION)
version_bits=`echo $VERSION | tr '.' ' '`
@@ -36,7 +36,7 @@ GTK_DOC_CHECK(1.9)
DISTCHECK_CONFIGURE_FLAGS="--enable-gtk-doc"
AC_SUBST(DISTCHECK_CONFIGURE_FLAGS)
-PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16.0)
+PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.16.0 gobject-2.0)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
diff --git a/docs/reference/gnome-keyring/gnome-keyring-sections.txt b/docs/reference/gnome-keyring/gnome-keyring-sections.txt
index 3c70508..aea2ec3 100644
--- a/docs/reference/gnome-keyring/gnome-keyring-sections.txt
+++ b/docs/reference/gnome-keyring/gnome-keyring-sections.txt
@@ -40,6 +40,7 @@ gnome_keyring_change_password_sync
gnome_keyring_list_item_ids
gnome_keyring_list_item_ids_sync
</SECTION>
+
<SECTION>
<FILE>gnome-keyring-keyring-info</FILE>
GnomeKeyringInfo
@@ -52,7 +53,11 @@ gnome_keyring_info_get_lock_timeout
gnome_keyring_info_get_mtime
gnome_keyring_info_get_ctime
gnome_keyring_info_get_is_locked
+<SUBSECTION Standard>
+gnome_keyring_info_get_type
+GNOME_KEYRING_TYPE_INFO
</SECTION>
+
<SECTION>
<FILE>gnome-keyring-items</FILE>
GnomeKeyringItemInfoFlags
@@ -83,6 +88,7 @@ GNOME_KEYRING_ITEM_INFO_ALL
GNOME_KEYRING_ITEM_NO_TYPE
GNOME_KEYRING_ITEM_TYPE_MASK
</SECTION>
+
<SECTION>
<FILE>gnome-keyring-item-info</FILE>
GnomeKeyringItemType
@@ -98,17 +104,26 @@ gnome_keyring_item_info_get_display_name
gnome_keyring_item_info_set_display_name
gnome_keyring_item_info_get_mtime
gnome_keyring_item_info_get_ctime
+<SUBSECTION Standard>
+gnome_keyring_item_info_get_gtype
+GNOME_KEYRING_TYPE_ITEM_INFO
</SECTION>
+
<SECTION>
<FILE>gnome-keyring-find</FILE>
GnomeKeyringFound
+gnome_keyring_found_copy
gnome_keyring_found_free
gnome_keyring_found_list_free
gnome_keyring_find_items
gnome_keyring_find_itemsv
gnome_keyring_find_items_sync
gnome_keyring_find_itemsv_sync
+<SUBSECTION Standard>
+gnome_keyring_found_get_type
+GNOME_KEYRING_TYPE_FOUND
</SECTION>
+
<SECTION>
<FILE>gnome-keyring-attributes</FILE>
GnomeKeyringAttributeType
@@ -120,7 +135,16 @@ gnome_keyring_attribute_list_append_string
gnome_keyring_attribute_list_append_uint32
gnome_keyring_attribute_list_free
gnome_keyring_attribute_list_copy
+gnome_keyring_attribute_get_string
+gnome_keyring_attribute_get_uint32
+<SUBSECTION Standard>
+gnome_keyring_attribute_get_type
+GNOME_KEYRING_TYPE_ATTRIBUTE
+gnome_keyring_attribute_list_get_type
+GNOME_KEYRING_TYPE_ATTRIBUTE_LIST
+gnome_keyring_attribute_list_to_glist
</SECTION>
+
<SECTION>
<FILE>gnome-keyring-acl</FILE>
GnomeKeyringAccessControl
@@ -141,7 +165,13 @@ gnome_keyring_item_ac_get_path_name
gnome_keyring_item_ac_set_path_name
gnome_keyring_item_ac_get_access_type
gnome_keyring_item_ac_set_access_type
+<SUBSECTION Standard>
+gnome_keyring_access_control_get_type
+GNOME_KEYRING_TYPE_ACCESS_CONTROL
+gnome_keyring_application_ref_get_type
+GNOME_KEYRING_TYPE_APPLICATION_REF
</SECTION>
+
<SECTION>
<FILE>gnome-keyring-network</FILE>
GnomeKeyringNetworkPasswordData
diff --git a/library/gnome-keyring-utils.c b/library/gnome-keyring-utils.c
index f787e70..56a7547 100644
--- a/library/gnome-keyring-utils.c
+++ b/library/gnome-keyring-utils.c
@@ -224,6 +224,36 @@ gnome_keyring_found_free (GnomeKeyringFound *found)
}
/**
+ * gnome_keyring_found_copy:
+ * @found: a #GnomeKeyringFound
+ *
+ * Copy a #GnomeKeyringFound item.
+ *
+ * Return value: (transfer full): The new #GnomeKeyringFound
+ */
+GnomeKeyringFound*
+gnome_keyring_found_copy (GnomeKeyringFound *found)
+{
+ GnomeKeyringFound *copy;
+
+ if (found == NULL)
+ return NULL;
+
+ copy = g_new (GnomeKeyringFound, 1);
+ copy->keyring = g_strdup (found->keyring);
+ copy->item_id = found->item_id;
+ copy->attributes = gnome_keyring_attribute_list_copy (found->attributes);
+ copy->secret = egg_secure_strdup (found->secret);
+
+ return copy;
+}
+
+G_DEFINE_BOXED_TYPE (GnomeKeyringFound,
+ gnome_keyring_found,
+ gnome_keyring_found_copy,
+ gnome_keyring_found_free);
+
+/**
* gnome_keyring_found_list_free:
* @found_list: (element-type GnomeKeyringFound): a #GList of #GnomeKeyringFound
*
@@ -249,6 +279,59 @@ gnome_keyring_found_list_free (GList *found_list)
**/
/**
+ * gnome_keyring_attribute_free:
+ * @attribute: a #GnomeKeyringAttribute.
+ *
+ * Free the memory used by the #GnomeKeyringAttribute @attribute.
+ **/
+static void
+gnome_keyring_attribute_free (GnomeKeyringAttribute *attribute)
+{
+ if (attribute == NULL)
+ return;
+
+ g_free (attribute->name);
+ if (attribute->type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING) {
+ g_free (attribute->value.string);
+ }
+ g_free (attribute);
+}
+
+/**
+ * gnome_keyring_attribute_copy:
+ * @attribute: a #GnomeKeyringAttribute to copy.
+ *
+ * Copy a #GnomeKeyringAttribute.
+ *
+ * Return value: (transfer full): The new #GnomeKeyringAttribute
+ **/
+static GnomeKeyringAttribute*
+gnome_keyring_attribute_copy (GnomeKeyringAttribute *attribute)
+{
+ GnomeKeyringAttribute *copy;
+
+ if (attribute == NULL)
+ return NULL;
+
+ copy = g_new (GnomeKeyringAttribute, 1);
+ copy->name = g_strdup (attribute->name);
+ copy->type = attribute->type;
+ if (attribute->type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING) {
+ copy->value.string = g_strdup (attribute->value.string);
+ } else {
+ copy->value.integer = attribute->value.integer;
+ }
+
+ return copy;
+}
+
+G_DEFINE_BOXED_TYPE (GnomeKeyringAttribute,
+ gnome_keyring_attribute,
+ gnome_keyring_attribute_copy,
+ gnome_keyring_attribute_free);
+
+
+/**
* gnome_keyring_attribute_list_append_string:
* @attributes: A #GnomeKeyringAttributeList
* @name: The name of the new attribute
@@ -356,6 +439,11 @@ gnome_keyring_attribute_list_copy (GnomeKeyringAttributeList *attributes)
return copy;
}
+G_DEFINE_BOXED_TYPE (GnomeKeyringAttributeList,
+ gnome_keyring_attribute_list,
+ gnome_keyring_attribute_list_copy,
+ gnome_keyring_attribute_list_free);
+
/**
* SECTION:gnome-keyring-keyring-info
* @title: Keyring Info
@@ -410,6 +498,11 @@ gnome_keyring_info_copy (GnomeKeyringInfo *keyring_info)
return copy;
}
+G_DEFINE_BOXED_TYPE (GnomeKeyringInfo,
+ gnome_keyring_info,
+ gnome_keyring_info_copy,
+ gnome_keyring_info_free);
+
/**
* gnome_keyring_item_info_free:
* @item_info: The keyring item info pointer.
@@ -473,6 +566,24 @@ gnome_keyring_item_info_copy (GnomeKeyringItemInfo *item_info)
return copy;
}
+/* gnome_keyring_item_info_get_type() is already part of the API, cannot use
+ * G_DEFINE_BOXED_TYPE here */
+GType
+gnome_keyring_item_info_get_gtype (void)
+{
+ static volatile gsize initialized = 0;
+ static GType type = 0;
+
+ if (g_once_init_enter (&initialized)) {
+ type = g_boxed_type_register_static ("GnomeKeyringItemInfo",
+ (GBoxedCopyFunc) gnome_keyring_item_info_copy,
+ (GBoxedFreeFunc) gnome_keyring_item_info_free);
+ g_once_init_leave (&initialized, 1);
+ }
+
+ return type;
+}
+
/**
* gnome_keyring_application_ref_new:
*
@@ -529,6 +640,11 @@ gnome_keyring_application_ref_copy (const GnomeKeyringApplicationRef *app)
return copy;
}
+G_DEFINE_BOXED_TYPE (GnomeKeyringApplicationRef,
+ gnome_keyring_application_ref,
+ gnome_keyring_application_ref_copy,
+ gnome_keyring_application_ref_free);
+
/**
* gnome_keyring_access_control_new:
* @application: A #GnomeKeyringApplicationRef pointer
@@ -590,6 +706,11 @@ gnome_keyring_access_control_copy (GnomeKeyringAccessControl *ac)
return ret;
}
+G_DEFINE_BOXED_TYPE (GnomeKeyringAccessControl,
+ gnome_keyring_access_control,
+ gnome_keyring_access_control_copy,
+ gnome_keyring_access_control_free);
+
/**
* gnome_keyring_acl_copy:
* @list: (element-type GnomeKeyringAccessControl): A list of
diff --git a/library/gnome-keyring.h b/library/gnome-keyring.h
index 4190289..f279f09 100644
--- a/library/gnome-keyring.h
+++ b/library/gnome-keyring.h
@@ -25,6 +25,7 @@
#define GNOME_KEYRING_H
#include <glib.h>
+#include <glib-object.h>
#include <time.h>
#include "gnome-keyring-result.h"
@@ -111,6 +112,10 @@ typedef void (*GnomeKeyringOperationGetAttributesCallback) (GnomeKeyringResult
GnomeKeyringAttributeList *attributes,
gpointer data);
+GType gnome_keyring_attribute_get_type (void) G_GNUC_CONST;
+
+#define GNOME_KEYRING_TYPE_ATTRIBUTE (gnome_keyring_attribute_get_type ())
+
#define gnome_keyring_attribute_list_index(a, i) g_array_index ((a), GnomeKeyringAttribute, (i))
#define gnome_keyring_attribute_list_new() (g_array_new (FALSE, FALSE, sizeof (GnomeKeyringAttribute)))
void gnome_keyring_attribute_list_append_string (GnomeKeyringAttributeList *attributes,
@@ -121,14 +126,20 @@ void gnome_keyring_attribute_list_append_uint32 (GnomeKeyr
guint32 value);
void gnome_keyring_attribute_list_free (GnomeKeyringAttributeList *attributes);
GnomeKeyringAttributeList *gnome_keyring_attribute_list_copy (GnomeKeyringAttributeList *attributes);
+GType gnome_keyring_attribute_list_get_type (void) G_GNUC_CONST;
+#define GNOME_KEYRING_TYPE_ATTRIBUTE_LIST (gnome_keyring_attribute_list_get_type ())
const gchar* gnome_keyring_result_to_message (GnomeKeyringResult res);
gboolean gnome_keyring_is_available (void);
-void gnome_keyring_found_free (GnomeKeyringFound *found);
-void gnome_keyring_found_list_free (GList *found_list);
+void gnome_keyring_found_free (GnomeKeyringFound *found);
+void gnome_keyring_found_list_free (GList *found_list);
+GnomeKeyringFound* gnome_keyring_found_copy (GnomeKeyringFound *found);
+GType gnome_keyring_found_get_type (void) G_GNUC_CONST;
+
+#define GNOME_KEYRING_TYPE_FOUND (gnome_keyring_found_get_type ())
void gnome_keyring_cancel_request (gpointer request);
@@ -207,6 +218,7 @@ GnomeKeyringResult gnome_keyring_list_item_ids_sync (const char
void gnome_keyring_info_free (GnomeKeyringInfo *keyring_info);
GnomeKeyringInfo *gnome_keyring_info_copy (GnomeKeyringInfo *keyring_info);
+GType gnome_keyring_info_get_type (void) G_GNUC_CONST;
void gnome_keyring_info_set_lock_on_idle (GnomeKeyringInfo *keyring_info,
gboolean value);
gboolean gnome_keyring_info_get_lock_on_idle (GnomeKeyringInfo *keyring_info);
@@ -217,6 +229,8 @@ time_t gnome_keyring_info_get_mtime (GnomeKeyringInfo *keyring
time_t gnome_keyring_info_get_ctime (GnomeKeyringInfo *keyring_info);
gboolean gnome_keyring_info_get_is_locked (GnomeKeyringInfo *keyring_info);
+#define GNOME_KEYRING_TYPE_INFO (gnome_keyring_info_get_type ())
+
gpointer gnome_keyring_find_items (GnomeKeyringItemType type,
GnomeKeyringAttributeList *attributes,
GnomeKeyringOperationGetListCallback callback,
@@ -306,6 +320,7 @@ GnomeKeyringResult gnome_keyring_item_set_attributes_sync (const char
void gnome_keyring_item_info_free (GnomeKeyringItemInfo *item_info);
GnomeKeyringItemInfo *gnome_keyring_item_info_new (void);
GnomeKeyringItemInfo *gnome_keyring_item_info_copy (GnomeKeyringItemInfo *item_info);
+GType gnome_keyring_item_info_get_gtype (void) G_GNUC_CONST;
GnomeKeyringItemType gnome_keyring_item_info_get_type (GnomeKeyringItemInfo *item_info);
void gnome_keyring_item_info_set_type (GnomeKeyringItemInfo *item_info,
GnomeKeyringItemType type);
@@ -318,6 +333,8 @@ void gnome_keyring_item_info_set_display_name (GnomeKeyringItem
time_t gnome_keyring_item_info_get_mtime (GnomeKeyringItemInfo *item_info);
time_t gnome_keyring_item_info_get_ctime (GnomeKeyringItemInfo *item_info);
+#define GNOME_KEYRING_TYPE_ITEM_INFO (gnome_keyring_item_info_get_gtype ())
+
/* ------------------------------------------------------------------------------
* A Simpler API
*/
@@ -480,13 +497,18 @@ GnomeKeyringResult gnome_keyring_item_grant_access_rights_sync (const char
GnomeKeyringApplicationRef * gnome_keyring_application_ref_new (void);
GnomeKeyringApplicationRef * gnome_keyring_application_ref_copy (const GnomeKeyringApplicationRef *app);
void gnome_keyring_application_ref_free (GnomeKeyringApplicationRef *app);
+GType gnome_keyring_application_ref_get_type (void) G_GNUC_CONST;
+
+#define GNOME_KEYRING_TYPE_APPLICATION_REF (gnome_keyring_application_ref_get_type ())
GnomeKeyringAccessControl * gnome_keyring_access_control_new (const GnomeKeyringApplicationRef *application,
GnomeKeyringAccessType types_allowed);
GnomeKeyringAccessControl * gnome_keyring_access_control_copy (GnomeKeyringAccessControl *ac);
+GType gnome_keyring_access_control_get_type (void) G_GNUC_CONST;
+void gnome_keyring_access_control_free (GnomeKeyringAccessControl *ac);
+#define GNOME_KEYRING_TYPE_ACCESS_CONTROL (gnome_keyring_access_control_get_type ())
-void gnome_keyring_access_control_free (GnomeKeyringAccessControl *ac);
GList * gnome_keyring_acl_copy (GList *list);
void gnome_keyring_acl_free (GList *acl);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]