[gnome-keyring] gck: Add support for setting attributes in an array
- From: Stefan Walter <stefw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-keyring] gck: Add support for setting attributes in an array
- Date: Wed, 5 Oct 2011 08:20:00 +0000 (UTC)
commit f680420c4cf35d04d0095c9f1ebe242b5d5dae7b
Author: Stef Walter <stefw collabora co uk>
Date: Tue Oct 4 12:47:07 2011 +0200
gck: Add support for setting attributes in an array
* Either change the attribute to the new value, or add an
attribute if one doesn't exist.
docs/reference/gck/gck-sections.txt | 4 +
gck/gck-attributes.c | 112 +++++++++++++++++++++++++++++++++++
gck/gck.h | 16 +++++
gck/gck.symbols | 4 +
4 files changed, 136 insertions(+), 0 deletions(-)
---
diff --git a/docs/reference/gck/gck-sections.txt b/docs/reference/gck/gck-sections.txt
index 0c9ea15..f6b2c7c 100644
--- a/docs/reference/gck/gck-sections.txt
+++ b/docs/reference/gck/gck-sections.txt
@@ -46,6 +46,10 @@ gck_attributes_add_string
gck_attributes_add_date
gck_attributes_add_ulong
gck_attributes_add_all
+gck_attributes_set_boolean
+gck_attributes_set_string
+gck_attributes_set_date
+gck_attributes_set_ulong
gck_attributes_find
gck_attributes_find_boolean
gck_attributes_find_ulong
diff --git a/gck/gck-attributes.c b/gck/gck-attributes.c
index de64d3f..d2fd6da 100644
--- a/gck/gck-attributes.c
+++ b/gck/gck-attributes.c
@@ -958,6 +958,34 @@ gck_attributes_add_boolean (GckAttributes *attrs, gulong attr_type, gboolean val
}
/**
+ * gck_attributes_set_boolean:
+ * @attrs: the attributes
+ * @attr_type: the type of attribute to set
+ * @value: boolean value to set
+ *
+ * Set the attribute of attr_type in the attribute array to the given value.
+ * If no such value exists, then add one.
+ */
+void
+gck_attributes_set_boolean (GckAttributes *attrs,
+ gulong attr_type,
+ gboolean value)
+{
+ GckAttribute *attr;
+
+ g_return_if_fail (attrs != NULL);
+ g_return_if_fail (!attrs->locked);
+
+ attr = gck_attributes_find (attrs, attr_type);
+ if (attr == NULL) {
+ gck_attributes_add_boolean (attrs, attr_type, value);
+ } else {
+ attribute_clear (attr, attrs->allocator);
+ attribute_init_boolean (attr, attr_type, value, attrs->allocator);
+ }
+}
+
+/**
* gck_attributes_add_string:
* @attrs: The attributes array to add to.
* @attr_type: The type of attribute to add.
@@ -981,6 +1009,34 @@ gck_attributes_add_string (GckAttributes *attrs, gulong attr_type, const gchar *
}
/**
+ * gck_attributes_set_string:
+ * @attrs: the attributes
+ * @attr_type: the type of attribute to set
+ * @value: null terminated string value to set
+ *
+ * Set the attribute of attr_type in the attribute array to the given value.
+ * If no such value exists, then add one.
+ */
+void
+gck_attributes_set_string (GckAttributes *attrs,
+ gulong attr_type,
+ const gchar *value)
+{
+ GckAttribute *attr;
+
+ g_return_if_fail (attrs != NULL);
+ g_return_if_fail (!attrs->locked);
+
+ attr = gck_attributes_find (attrs, attr_type);
+ if (attr == NULL) {
+ gck_attributes_add_string (attrs, attr_type, value);
+ } else {
+ attribute_clear (attr, attrs->allocator);
+ attribute_init_string (attr, attr_type, value, attrs->allocator);
+ }
+}
+
+/**
* gck_attributes_add_date:
* @attrs: The attributes array to add to.
* @attr_type: The type of attribute to add.
@@ -1004,6 +1060,34 @@ gck_attributes_add_date (GckAttributes *attrs, gulong attr_type, const GDate *va
}
/**
+ * gck_attributes_set_date:
+ * @attrs: the attributes
+ * @attr_type: the type of attribute to set
+ * @value: date value to set
+ *
+ * Set the attribute of attr_type in the attribute array to the given value.
+ * If no such value exists, then add one.
+ */
+void
+gck_attributes_set_date (GckAttributes *attrs,
+ gulong attr_type,
+ const GDate *value)
+{
+ GckAttribute *attr;
+
+ g_return_if_fail (attrs != NULL);
+ g_return_if_fail (!attrs->locked);
+
+ attr = gck_attributes_find (attrs, attr_type);
+ if (attr == NULL) {
+ gck_attributes_add_date (attrs, attr_type, value);
+ } else {
+ attribute_clear (attr, attrs->allocator);
+ attribute_init_date (attr, attr_type, value, attrs->allocator);
+ }
+}
+
+/**
* gck_attributes_add_ulong:
* @attrs: The attributes array to add to.
* @attr_type: The type of attribute to add.
@@ -1027,6 +1111,34 @@ gck_attributes_add_ulong (GckAttributes *attrs, gulong attr_type, gulong value)
}
/**
+ * gck_attributes_set_ulong:
+ * @attrs: the attributes
+ * @attr_type: the type of attribute to set
+ * @value: gulong value to set
+ *
+ * Set the attribute of attr_type in the attribute array to the given value.
+ * If no such value exists, then add one.
+ */
+void
+gck_attributes_set_ulong (GckAttributes *attrs,
+ gulong attr_type,
+ gulong value)
+{
+ GckAttribute *attr;
+
+ g_return_if_fail (attrs != NULL);
+ g_return_if_fail (!attrs->locked);
+
+ attr = gck_attributes_find (attrs, attr_type);
+ if (attr == NULL) {
+ gck_attributes_add_ulong (attrs, attr_type, value);
+ } else {
+ attribute_clear (attr, attrs->allocator);
+ attribute_init_ulong (attr, attr_type, value, attrs->allocator);
+ }
+}
+
+/**
* gck_attributes_add_all:
* @attrs: A set of attributes
* @from: Attributes to add
diff --git a/gck/gck.h b/gck/gck.h
index cb2992c..588a09f 100644
--- a/gck/gck.h
+++ b/gck/gck.h
@@ -253,6 +253,22 @@ gboolean gck_attributes_find_date (GckAttributes *attr
gulong attr_type,
GDate *value);
+void gck_attributes_set_boolean (GckAttributes *attrs,
+ gulong attr_type,
+ gboolean value);
+
+void gck_attributes_set_ulong (GckAttributes *attrs,
+ gulong attr_type,
+ gulong value);
+
+void gck_attributes_set_string (GckAttributes *attrs,
+ gulong attr_type,
+ const gchar *value);
+
+void gck_attributes_set_date (GckAttributes *attrs,
+ gulong attr_type,
+ const GDate *value);
+
gulong gck_attributes_count (GckAttributes *attrs);
GckAttributes* gck_attributes_ref (GckAttributes *attrs);
diff --git a/gck/gck.symbols b/gck/gck.symbols
index d5afd66..e5cb403 100644
--- a/gck/gck.symbols
+++ b/gck/gck.symbols
@@ -52,6 +52,10 @@ gck_attributes_new
gck_attributes_new_empty
gck_attributes_new_full
gck_attributes_ref
+gck_attributes_set_boolean
+gck_attributes_set_date
+gck_attributes_set_string
+gck_attributes_set_ulong
gck_attributes_unref
gck_enumerator_get_interaction
gck_enumerator_get_type
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]