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);
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);
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)
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);
}
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);
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);
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);
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);
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);
}
}
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");
}
}
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));
}
}
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)
* @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)
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));
}
}
/**
+ * 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)
* @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,
* @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, ...)