/** * e_vcard_get_attributes: * @evcard: an #EVCard * * Gets the list of attributes from @evcard. The list and its * contents are owned by @evcard, and must not be freed. * * Return value: A list of attributes of type #EVCardAttribute. **/ GList* e_vcard_get_attributes (EVCard *evcard) { g_return_val_if_fail (E_IS_VCARD (evcard), NULL); return evcard->priv->attributes; }
/** * e_vcard_remove_attributes: * @evc: vcard object * @attr_group: group name of attributes to be removed * @attr_name: name of the arributes to be removed * * Removes all the attributes with group name and attribute name equal to * passed in values. If @attr_group is %NULL or an empty string, * it removes all the attributes with passed in name irrespective of * their group names. **/ void e_vcard_remove_attributes (EVCard *evc, const char *attr_group, const char *attr_name) { GList *attr; g_return_if_fail (E_IS_VCARD (evc)); g_return_if_fail (attr_name != NULL); attr = evc->priv->attributes; while (attr) { GList *next_attr; EVCardAttribute *a = attr->data; next_attr = attr->next; if (((!attr_group || *attr_group == '\0') || (attr_group && !g_ascii_strcasecmp (attr_group, a->group))) && ((!attr_name && !a->name) || !g_ascii_strcasecmp (attr_name, a->name))) { /* matches, remove/delete the attribute */ evc->priv->attributes = g_list_delete_link (evc->priv->attributes, attr); e_vcard_attribute_free (a); } attr = next_attr; } }
/** * e_vcard_add_attribute: * @evc: an #EVCard * @attr: an #EVCardAttribute to add * * Adds @attr to @evc. **/ void e_vcard_add_attribute (EVCard *evc, EVCardAttribute *attr) { g_return_if_fail (E_IS_VCARD (evc)); g_return_if_fail (attr != NULL); evc->priv->attributes = g_list_prepend (evc->priv->attributes, attr); }
void e_vcard_construct (EVCard *evc, const char *str) { g_return_if_fail (E_IS_VCARD (evc)); g_return_if_fail (str != NULL); if (*str) parse (evc, str); }
/** * e_vcard_remove_attribute: * @evc: an #EVCard * @attr: an #EVCardAttribute to remove * * Removes @attr from @evc and frees it. **/ void e_vcard_remove_attribute (EVCard *evc, EVCardAttribute *attr) { g_return_if_fail (E_IS_VCARD (evc)); g_return_if_fail (attr != NULL); evc->priv->attributes = g_list_remove (evc->priv->attributes, attr); e_vcard_attribute_free (attr); }
/** * e_vcard_add_attribute_with_value: * @evcard: an #EVCard * @attr: an #EVCardAttribute to add * @value: a value to assign to the attribute * * Adds @attr to @evcard, setting it to @value. **/ void e_vcard_add_attribute_with_value (EVCard *evcard, EVCardAttribute *attr, const char *value) { g_return_if_fail (E_IS_VCARD (evcard)); g_return_if_fail (attr != NULL); e_vcard_attribute_add_value (attr, value); e_vcard_add_attribute (evcard, attr); }
/** * e_vcard_to_string: * @evc: the #EVCard to export * @format: the format to export to * * Exports @evc to a string representation, specified * by the @format argument. * * Return value: A newly allocated string representing the vcard. **/ char* e_vcard_to_string (EVCard *evc, EVCardFormat format) { g_return_val_if_fail (E_IS_VCARD (evc), NULL); switch (format) { case EVC_FORMAT_VCARD_21: return e_vcard_to_string_vcard_21 (evc); case EVC_FORMAT_VCARD_30: return e_vcard_to_string_vcard_30 (evc); default: g_warning ("invalid format specifier passed to e_vcard_to_string"); return g_strdup (""); } }
/** * e_vcard_add_attribute_with_values: * @evcard: an @EVCard * @attr: an #EVCardAttribute to add * @Varargs: a %NULL-terminated list of values to assign to the attribute * * Adds @attr to @evcard, assigning the list of values to it. **/ void e_vcard_add_attribute_with_values (EVCard *evcard, EVCardAttribute *attr, ...) { va_list ap; char *v; g_return_if_fail (E_IS_VCARD (evcard)); g_return_if_fail (attr != NULL); va_start (ap, attr); while ((v = va_arg (ap, char*))) { e_vcard_attribute_add_value (attr, v); } va_end (ap); e_vcard_add_attribute (evcard, attr); }
/** * e_vcard_get_attribute: * @evc: an #EVCard * @name: the name of the attribute to get * * Get the attribute @name from @evc. The #EVCardAttribute is owned by * @evcard and should not be freed. If the attribute does not exist, #NULL is * returned. * * Return value: An #EVCardAttribute if found, or #NULL. **/ EVCardAttribute * e_vcard_get_attribute (EVCard *evc, const char *name) { GList *attrs, *l; g_return_val_if_fail (E_IS_VCARD (evc), NULL); g_return_val_if_fail (name != NULL, NULL); attrs = e_vcard_get_attributes (evc); for (l = attrs; l; l = l->next) { EVCardAttribute *attr; attr = (EVCardAttribute *) l->data; if (g_ascii_strcasecmp (attr->name, name) == 0) return attr; } return NULL; }
/* Get a list of the specified attributes from a contact */ GList * hito_vcard_get_named_attributes (EVCard *contact, const char *name) { GList *attrs = NULL, *l; g_return_val_if_fail (E_IS_VCARD (contact), NULL); g_return_val_if_fail (name != NULL, NULL); for (l = e_vcard_get_attributes (E_VCARD (contact)); l; l = l->next) { EVCardAttribute *attr; const char *n; attr = (EVCardAttribute *) l->data; n = e_vcard_attribute_get_name (attr); if (strcmp (n, name) == 0) attrs = g_list_prepend (attrs, attr); } return g_list_reverse (attrs); }
/** * e_vcard_dump_structure: * @evc: the #EVCard to dump * * Prints a dump of @evc's structure to stdout. Used for * debugging. **/ void e_vcard_dump_structure (EVCard *evc) { GList *a; GList *v; int i; g_return_if_fail (E_IS_VCARD (evc)); printf ("vCard\n"); for (a = evc->priv->attributes; a; a = a->next) { GList *p; EVCardAttribute *attr = a->data; printf ("+-- %s\n", attr->name); if (attr->params) { printf (" +- params=\n"); for (p = attr->params, i = 0; p; p = p->next, i++) { EVCardAttributeParam *param = p->data; printf (" | [%d] = %s", i,param->name); printf ("("); for (v = param->values; v; v = v->next) { char *value = e_vcard_escape_string ((char*)v->data); printf ("%s", value); if (v->next) printf (","); g_free (value); } printf (")\n"); } } printf (" +- values=\n"); for (v = attr->values, i = 0; v; v = v->next, i++) { printf (" [%d] = `%s'\n", i, (char*)v->data); } } }
static EBookBackendSyncStatus e_book_backend_scalix_get_contact (EBookBackendSync * backend, EDataBook * book, guint32 opid, const char *uid, char **vcard) { EBookBackendScalix *bs; EBookBackendScalixPrivate *priv; ScalixObject *object; bs = E_BOOK_BACKEND_SCALIX (backend); priv = E_BOOK_BACKEND_SCALIX_GET_PRIVATE (bs); object = scalix_container_get_object (priv->container, uid); if (object == NULL || !E_IS_VCARD (object)) { return GNOME_Evolution_Addressbook_ContactNotFound; } *vcard = e_vcard_to_string (E_VCARD (object), EVC_FORMAT_VCARD_30); g_object_unref (object); return GNOME_Evolution_Addressbook_Success; }