[evolution-data-server] Bug #556061 - EContact/EVCard can re-order phone and email attributes
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #556061 - EContact/EVCard can re-order phone and email attributes
- Date: Wed, 19 May 2010 09:05:30 +0000 (UTC)
commit a6700335d34475fa37b8f22f588631f3faa7e6c6
Author: Milan Crha <mcrha redhat com>
Date: Wed May 19 11:04:58 2010 +0200
Bug #556061 - EContact/EVCard can re-order phone and email attributes
addressbook/libebook/e-contact.c | 27 +++++++-------
addressbook/libebook/e-vcard.c | 72 ++++++++++++++++++++++++++++++++++++-
addressbook/libebook/e-vcard.h | 3 ++
3 files changed, 87 insertions(+), 15 deletions(-)
---
diff --git a/addressbook/libebook/e-contact.c b/addressbook/libebook/e-contact.c
index 96ff552..2a91493 100644
--- a/addressbook/libebook/e-contact.c
+++ b/addressbook/libebook/e-contact.c
@@ -532,7 +532,7 @@ fn_setter (EContact *contact, EVCardAttribute *attr, gpointer data)
EContactName *name = e_contact_name_from_string ((gchar *)data);
attr = e_vcard_attribute_new (NULL, EVC_N);
- e_vcard_add_attribute (E_VCARD (contact), attr);
+ e_vcard_append_attribute (E_VCARD (contact), attr);
/* call the setter directly */
n_setter (contact, attr, name);
@@ -563,7 +563,7 @@ n_getter (EContact *contact, EVCardAttribute *attr)
new_attr = e_contact_get_first_attr (contact, EVC_FN);
if (!new_attr) {
new_attr = e_vcard_attribute_new (NULL, EVC_FN);
- e_vcard_add_attribute (E_VCARD (contact), new_attr);
+ e_vcard_append_attribute (E_VCARD (contact), new_attr);
name_str = e_contact_name_to_string (name);
e_vcard_attribute_add_value (new_attr, name_str);
g_free (name_str);
@@ -589,7 +589,7 @@ n_setter (EContact *contact, EVCardAttribute *attr, gpointer data)
gchar *strings[3], **stringptr;
gchar *string;
attr = e_vcard_attribute_new (NULL, EVC_X_FILE_AS);
- e_vcard_add_attribute (E_VCARD (contact), attr);
+ e_vcard_append_attribute (E_VCARD (contact), attr);
stringptr = strings;
if (name->family && *name->family)
@@ -746,7 +746,7 @@ e_contact_set_property (GObject *object,
e_vcard_remove_attributes (E_VCARD (contact), NULL, info->vcard_field_name);
for (l = new_values; l; l = l->next)
- e_vcard_add_attribute_with_value (E_VCARD (contact),
+ e_vcard_append_attribute_with_value (E_VCARD (contact),
e_vcard_attribute_new (NULL, info->vcard_field_name),
(gchar *)l->data);
}
@@ -796,7 +796,7 @@ e_contact_set_property (GObject *object,
e_vcard_attribute_param_new (EVC_TYPE),
"OTHER");
}
- e_vcard_add_attribute (E_VCARD (contact), attr);
+ e_vcard_append_attribute (E_VCARD (contact), attr);
}
e_vcard_attribute_add_value (attr, sval);
@@ -884,7 +884,7 @@ e_contact_set_property (GObject *object,
else {
/* we didn't find it - add a new attribute */
attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
- e_vcard_add_attribute (E_VCARD (contact), attr);
+ e_vcard_append_attribute (E_VCARD (contact), attr);
if (info->attr_type1)
e_vcard_attribute_add_param_with_value (attr, e_vcard_attribute_param_new (EVC_TYPE),
info->attr_type1);
@@ -924,7 +924,7 @@ e_contact_set_property (GObject *object,
d(printf ("adding new %s\n", info->vcard_field_name));
attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
- e_vcard_add_attribute (E_VCARD (contact), attr);
+ e_vcard_append_attribute (E_VCARD (contact), attr);
}
values = e_vcard_attribute_get_values (attr);
@@ -956,7 +956,7 @@ e_contact_set_property (GObject *object,
else {
/* we didn't find it - add a new attribute */
attr = e_vcard_attribute_new (NULL, EVC_CATEGORIES);
- e_vcard_add_attribute (E_VCARD (contact), attr);
+ e_vcard_append_attribute (E_VCARD (contact), attr);
}
str = g_value_get_string (value);
@@ -1009,7 +1009,7 @@ e_contact_set_property (GObject *object,
d(printf ("adding new %s\n", info->vcard_field_name));
attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
- e_vcard_add_attribute (E_VCARD (contact), attr);
+ e_vcard_append_attribute (E_VCARD (contact), attr);
info->struct_setter (contact, attr, data);
}
@@ -1026,7 +1026,7 @@ e_contact_set_property (GObject *object,
}
else {
/* and if we don't find one we create a new attribute */
- e_vcard_add_attribute_with_value (E_VCARD (contact),
+ e_vcard_append_attribute_with_value (E_VCARD (contact),
e_vcard_attribute_new (NULL, info->vcard_field_name),
g_value_get_boolean (value) ? "TRUE" : "FALSE");
}
@@ -1052,7 +1052,7 @@ e_contact_set_property (GObject *object,
}
else if (sval) {
/* and if we don't find one we create a new attribute */
- e_vcard_add_attribute_with_value (E_VCARD (contact),
+ e_vcard_append_attribute_with_value (E_VCARD (contact),
e_vcard_attribute_new (NULL, info->vcard_field_name),
g_value_get_string (value));
}
@@ -1073,7 +1073,7 @@ e_contact_set_property (GObject *object,
}
else if (values) {
attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
- e_vcard_add_attribute (E_VCARD (contact), attr);
+ e_vcard_append_attribute (E_VCARD (contact), attr);
}
for (l = values; l != NULL; l = l->next)
@@ -1671,6 +1671,7 @@ e_contact_get_attributes (EContact *contact, EContactField field_id)
* @attributes: a #GList of pointers to #EVCardAttribute
*
* Sets the vcard attributes for @contact's @field_id.
+ * Attributes are added to the contact in the same order as they are in @attributes.
**/
void
e_contact_set_attributes (EContact *contact, EContactField field_id, GList *attributes)
@@ -1686,7 +1687,7 @@ e_contact_set_attributes (EContact *contact, EContactField field_id, GList *attr
e_vcard_remove_attributes (E_VCARD (contact), NULL, info->vcard_field_name);
for (l = attributes; l; l = l->next)
- e_vcard_add_attribute (E_VCARD (contact),
+ e_vcard_append_attribute (E_VCARD (contact),
e_vcard_attribute_copy ((EVCardAttribute*)l->data));
}
diff --git a/addressbook/libebook/e-vcard.c b/addressbook/libebook/e-vcard.c
index 110ef6c..2fb6244 100644
--- a/addressbook/libebook/e-vcard.c
+++ b/addressbook/libebook/e-vcard.c
@@ -1136,11 +1136,77 @@ e_vcard_remove_attribute (EVCard *evc, EVCardAttribute *attr)
}
/**
+ * e_vcard_append_attribute:
+ * @evc: an #EVCard
+ * @attr: an #EVCardAttribute to append
+ *
+ * Appends @attr to @evc to the end of a list of attributes.
+ **/
+void
+e_vcard_append_attribute (EVCard *evc, EVCardAttribute *attr)
+{
+ g_return_if_fail (E_IS_VCARD (evc));
+ g_return_if_fail (attr != NULL);
+
+ evc->priv->attributes = g_list_append (evc->priv->attributes, attr);
+}
+
+/**
+ * e_vcard_append_attribute_with_value:
+ * @evcard: an #EVCard
+ * @attr: an #EVCardAttribute to append
+ * @value: a value to assign to the attribute
+ *
+ * Appends @attr to @evcard, setting it to @value.
+ * For attribute addition is used e_vcard_append_attribute().
+ **/
+void
+e_vcard_append_attribute_with_value (EVCard *evcard,
+ EVCardAttribute *attr, const gchar *value)
+{
+ g_return_if_fail (E_IS_VCARD (evcard));
+ g_return_if_fail (attr != NULL);
+
+ e_vcard_attribute_add_value (attr, value);
+
+ e_vcard_append_attribute (evcard, attr);
+}
+
+/**
+ * e_vcard_append_attribute_with_values:
+ * @evcard: an @EVCard
+ * @attr: an #EVCardAttribute to append
+ * @Varargs: a %NULL-terminated list of values to assign to the attribute
+ *
+ * Appends @attr to @evcard, assigning the list of values to it.
+ * For attribute addition is used e_vcard_append_attribute().
+ **/
+void
+e_vcard_append_attribute_with_values (EVCard *evcard, EVCardAttribute *attr, ...)
+{
+ va_list ap;
+ gchar *v;
+
+ g_return_if_fail (E_IS_VCARD (evcard));
+ g_return_if_fail (attr != NULL);
+
+ va_start (ap, attr);
+
+ while ((v = va_arg (ap, gchar *))) {
+ e_vcard_attribute_add_value (attr, v);
+ }
+
+ va_end (ap);
+
+ e_vcard_append_attribute (evcard, attr);
+}
+
+/**
* e_vcard_add_attribute:
* @evc: an #EVCard
* @attr: an #EVCardAttribute to add
*
- * Adds @attr to @evc.
+ * Adds @attr to @evc. It's added to the beginning of a list of attributes.
**/
void
e_vcard_add_attribute (EVCard *evc, EVCardAttribute *attr)
@@ -1157,7 +1223,8 @@ e_vcard_add_attribute (EVCard *evc, EVCardAttribute *attr)
* @attr: an #EVCardAttribute to add
* @value: a value to assign to the attribute
*
- * Adds @attr to @evcard, setting it to @value.
+ * Adds @attr to @evcard, setting it to @value. For attribute addition
+ * is used e_vcard_add_attribute().
**/
void
e_vcard_add_attribute_with_value (EVCard *evcard,
@@ -1178,6 +1245,7 @@ e_vcard_add_attribute_with_value (EVCard *evcard,
* @Varargs: a %NULL-terminated list of values to assign to the attribute
*
* Adds @attr to @evcard, assigning the list of values to it.
+ * For attribute addition is used e_vcard_add_attribute().
**/
void
e_vcard_add_attribute_with_values (EVCard *evcard, EVCardAttribute *attr, ...)
diff --git a/addressbook/libebook/e-vcard.h b/addressbook/libebook/e-vcard.h
index 6bc54a4..4defa67 100644
--- a/addressbook/libebook/e-vcard.h
+++ b/addressbook/libebook/e-vcard.h
@@ -167,6 +167,9 @@ void e_vcard_attribute_free (EVCardAttribute *attr);
EVCardAttribute *e_vcard_attribute_copy (EVCardAttribute *attr);
void e_vcard_remove_attributes (EVCard *evc, const gchar *attr_group, const gchar *attr_name);
void e_vcard_remove_attribute (EVCard *evc, EVCardAttribute *attr);
+void e_vcard_append_attribute (EVCard *evc, EVCardAttribute *attr);
+void e_vcard_append_attribute_with_value (EVCard *evcard, EVCardAttribute *attr, const gchar *value);
+void e_vcard_append_attribute_with_values(EVCard *evcard, EVCardAttribute *attr, ...);
void e_vcard_add_attribute (EVCard *evc, EVCardAttribute *attr);
void e_vcard_add_attribute_with_value (EVCard *evcard, EVCardAttribute *attr, const gchar *value);
void e_vcard_add_attribute_with_values (EVCard *evcard, EVCardAttribute *attr, ...);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]