[libgnome-keyring] Add GnomeKeyringAttribute union accessor methods



commit 594faaddbb465708f35ff016e834abf3e9af016c
Author: Martin Pitt <martin pitt ubuntu com>
Date:   Sun Jan 15 10:57:13 2012 +0100

    Add GnomeKeyringAttribute union accessor methods
    
    Add accessor methods for the GnomeKeyringAttribute.value union, for GI bindings
    which cannot directly access the union struct member.

 library/gnome-keyring-utils.c |   37 +++++++++++++++++++++++++++++++++++++
 library/gnome-keyring.h       |    2 ++
 2 files changed, 39 insertions(+), 0 deletions(-)
---
diff --git a/library/gnome-keyring-utils.c b/library/gnome-keyring-utils.c
index d44f6a7..ed5c692 100644
--- a/library/gnome-keyring-utils.c
+++ b/library/gnome-keyring-utils.c
@@ -279,6 +279,43 @@ gnome_keyring_found_list_free (GList *found_list)
  **/
 
 /**
+ * gnome_keyring_attribute_get_string:
+ * @attribute: a #GnomeKeyringAttribute
+ *
+ * Return the string value. It is an error to call this method if
+ * @attribute.type is not #GNOME_KEYRING_ATTRIBUTE_TYPE_STRING. This method is
+ * mostly useful for language bindings which do not provide union access. In C
+ * you should just use attribute->value.string.
+ *
+ * Returns: (transfer none): The value.string pointer of @attribute. This is
+ * not a copy, do not free.
+ **/
+const gchar*
+gnome_keyring_attribute_get_string (GnomeKeyringAttribute *attribute)
+{
+	g_return_val_if_fail (attribute->type == GNOME_KEYRING_ATTRIBUTE_TYPE_STRING, NULL);
+	return attribute->value.string;
+}
+
+/**
+ * gnome_keyring_attribute_get_uint32:
+ * @attribute: a #GnomeKeyringAttribute
+ *
+ * Return the uint32 value. It is an error to call this method if
+ * @attribute.type is not #GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32. This method is
+ * mostly useful for language bindings which do not provide union access. In C
+ * you should just use attribute->value.integer.
+ *
+ * Returns: The value.integer of @attribute.
+ **/
+guint32
+gnome_keyring_attribute_get_uint32 (GnomeKeyringAttribute *attribute)
+{
+	g_return_val_if_fail (attribute->type == GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32, 0);
+	return attribute->value.integer;
+}
+
+/**
  * gnome_keyring_attribute_free:
  * @attribute: a #GnomeKeyringAttribute.
  *
diff --git a/library/gnome-keyring.h b/library/gnome-keyring.h
index 13165bc..f085a42 100644
--- a/library/gnome-keyring.h
+++ b/library/gnome-keyring.h
@@ -113,6 +113,8 @@ typedef void (*GnomeKeyringOperationGetAttributesCallback)  (GnomeKeyringResult
                                                              gpointer             data);
 
 GType                      gnome_keyring_attribute_get_type           (void) G_GNUC_CONST;
+const gchar*               gnome_keyring_attribute_get_string         (GnomeKeyringAttribute *attribute);
+guint32                    gnome_keyring_attribute_get_uint32         (GnomeKeyringAttribute *attribute);
 
 #define GNOME_KEYRING_TYPE_ATTRIBUTE (gnome_keyring_attribute_get_type ())
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]