EVCard

EVCard — Contact vCard representation

Synopsis

                    EVCard;
enum                EVCardFormat;
                    EVCardAttribute;
                    EVCardAttributeParam;
EVCard*             e_vcard_new                         (void);
EVCard*             e_vcard_new_from_string             (const char *str);
char*               e_vcard_to_string                   (EVCard *evc,
                                                         EVCardFormat format);
void                e_vcard_dump_structure              (EVCard *evc);
EVCardAttribute*    e_vcard_attribute_new               (const char *attr_group,
                                                         const char *attr_name);
void                e_vcard_attribute_free              (EVCardAttribute *attr);
EVCardAttribute*    e_vcard_attribute_copy              (EVCardAttribute *attr);
void                e_vcard_remove_attributes           (EVCard *evc,
                                                         const char *attr_group,
                                                         const char *attr_name);
void                e_vcard_remove_attribute            (EVCard *evc,
                                                         EVCardAttribute *attr);
void                e_vcard_add_attribute               (EVCard *evc,
                                                         EVCardAttribute *attr);
void                e_vcard_add_attribute_with_value    (EVCard *evcard,
                                                         EVCardAttribute *attr,
                                                         const char *value);
void                e_vcard_add_attribute_with_values   (EVCard *evcard,
                                                         EVCardAttribute *attr,
                                                         ...);
void                e_vcard_attribute_add_value         (EVCardAttribute *attr,
                                                         const char *value);
void                e_vcard_attribute_add_value_decoded (EVCardAttribute *attr,
                                                         const char *value,
                                                         int len);
void                e_vcard_attribute_add_values        (EVCardAttribute *attr,
                                                         ...);
void                e_vcard_attribute_remove_values     (EVCardAttribute *attr);
void                e_vcard_attribute_remove_params     (EVCardAttribute *attr);
EVCardAttributeParam* e_vcard_attribute_param_new       (const char *name);
void                e_vcard_attribute_param_free        (EVCardAttributeParam *param);
EVCardAttributeParam* e_vcard_attribute_param_copy      (EVCardAttributeParam *param);
void                e_vcard_attribute_add_param         (EVCardAttribute *attr,
                                                         EVCardAttributeParam *param);
void                e_vcard_attribute_add_param_with_value
                                                        (EVCardAttribute *attr,
                                                         EVCardAttributeParam *param,
                                                         const char *value);
void                e_vcard_attribute_add_param_with_values
                                                        (EVCardAttribute *attr,
                                                         EVCardAttributeParam *param,
                                                         ...);
void                e_vcard_attribute_param_add_value   (EVCardAttributeParam *param,
                                                         const char *value);
void                e_vcard_attribute_param_add_values  (EVCardAttributeParam *param,
                                                         ...);
void                e_vcard_attribute_param_remove_values
                                                        (EVCardAttributeParam *param);
GList*              e_vcard_get_attributes              (EVCard *evcard);
gboolean            e_vcard_attribute_equal             (EVCardAttribute *attr_a,
                                                         EVCardAttribute *attr_b);
gboolean            e_vcard_attribute_has_type          (EVCardAttribute *attr,
                                                         const char *typestr);
gboolean            e_vcard_attribute_is_single_valued  (EVCardAttribute *attr);
const char*         e_vcard_attribute_get_group         (EVCardAttribute *attr);
const char*         e_vcard_attribute_get_name          (EVCardAttribute *attr);
char*               e_vcard_attribute_get_value         (EVCardAttribute *attr);
GString*            e_vcard_attribute_get_value_decoded (EVCardAttribute *attr);
GList*              e_vcard_attribute_get_values        (EVCardAttribute *attr);
GList*              e_vcard_attribute_get_values_decoded
                                                        (EVCardAttribute *attr);
GList*              e_vcard_attribute_get_param         (EVCardAttribute *attr,
                                                         const char *name);
GList*              e_vcard_attribute_get_params        (EVCardAttribute *attr);
const char*         e_vcard_attribute_param_get_name    (EVCardAttributeParam *param);
GList*              e_vcard_attribute_param_get_values  (EVCardAttributeParam *param);
void                e_vcard_attribute_remove_param      (EVCardAttribute *attr,
                                                         const char *param_name);
void                e_vcard_attribute_remove_param_value
                                                        (EVCardAttribute *attr,
                                                         const char *param_name,
                                                         const char *s);
void                e_vcard_attribute_remove_value      (EVCardAttribute *attr,
                                                         const char *s);
char*               e_vcard_escape_string               (const char *s);
EVCardAttribute*    e_vcard_get_attribute               (EVCard *evc,
                                                         const char *name);
gboolean            e_vcard_is_parsed                   (EVCard *evc);
gboolean            e_vcard_is_parsing                  (EVCard *evc);
char*               e_vcard_unescape_string             (const char *s);
#define             EVC_ADR
#define             EVC_BDAY
#define             EVC_CALURI
#define             EVC_CATEGORIES
#define             EVC_EMAIL
#define             EVC_ENCODING
#define             EVC_FBURL
#define             EVC_FN
#define             EVC_GEO
#define             EVC_ICSCALENDAR
#define             EVC_KEY
#define             EVC_LABEL
#define             EVC_LOGO
#define             EVC_MAILER
#define             EVC_NICKNAME
#define             EVC_N
#define             EVC_NOTE
#define             EVC_ORG
#define             EVC_PHOTO
#define             EVC_PRODID
#define             EVC_QUOTEDPRINTABLE
#define             EVC_REV
#define             EVC_ROLE
#define             EVC_TEL
#define             EVC_TITLE
#define             EVC_TYPE
#define             EVC_UID
#define             EVC_URL
#define             EVC_VALUE
#define             EVC_VERSION
#define             EVC_X_AIM
#define             EVC_X_BLOG_URL
#define             EVC_X_BOOK_URI
#define             EVC_X_GADUGADU
#define             EVC_X_GROUPWISE
#define             EVC_X_ICQ
#define             EVC_X_JABBER
#define             EVC_X_MSN
#define             EVC_X_SIP
#define             EVC_X_SKYPE
#define             EVC_X_VIDEO_URL
#define             EVC_X_YAHOO

Object Hierarchy

  GObject
   +----EVCard
         +----EContact

Description

EVCard is an object representation of a contact's vCard and includes extensive support for manipulating vCards and their attributes and their parameters.

Typically, you will only use EContact contacts, and not "plain" EVCard objects.

Example for adding an XMPP username to a contact:

void
add_xmpp_username (EContact *contact, const char *username)
{
     EVCardAttribute *attr;
     EVCardAttributeParam *param;

     attr = e_vcard_attribute_new (NULL, EVC_X_JABBER);

     /* Optionally specifying the real-life context for this username
     ("work"); see RFC 2426 for valid values */
     param = e_vcard_attribute_param_new (EVC_TYPE);
     e_vcard_attribute_add_param_with_value (attr, param, "WORK");

     e_vcard_add_attribute_with_value (E_VCARD (contact), attr, username);
}

Details

EVCard

typedef struct _EVCard EVCard;

All the fields of this structure are private to the object's implementation and should never be accessed directly.


enum EVCardFormat

typedef enum {
	EVC_FORMAT_VCARD_21,
	EVC_FORMAT_VCARD_30
} EVCardFormat;

The specific vCard format version that the vCard complies with.

EVC_FORMAT_VCARD_21 the vCard is formatted for version 2.1 of the specification
EVC_FORMAT_VCARD_30 the vCard is formatted for version 3.0 of the specification (RFC 2426)

EVCardAttribute

typedef struct _EVCardAttribute EVCardAttribute;

All the fields of this structure are private to the object's implementation and should never be accessed directly.


EVCardAttributeParam

typedef struct _EVCardAttributeParam EVCardAttributeParam;

All the fields of this structure are private to the object's implementation and should never be accessed directly.


e_vcard_new ()

EVCard*             e_vcard_new                         (void);

Creates a new, blank EVCard.

Returns : A new, blank EVCard.

e_vcard_new_from_string ()

EVCard*             e_vcard_new_from_string             (const char *str);

Creates a new EVCard from the passed-in string representation.

The contents of the vCard will be lazily parsed into EVCardAttributes, so non-trivial errors in the vCard will not be resolved by the time this function returns.

str : a string representation of the vcard to create
Returns : A new EVCard.

e_vcard_to_string ()

char*               e_vcard_to_string                   (EVCard *evc,
                                                         EVCardFormat format);

Exports evc to a string representation, specified by the format argument.

evc : the EVCard to export
format : the format to export to
Returns : A newly allocated string representing the vcard.

e_vcard_dump_structure ()

void                e_vcard_dump_structure              (EVCard *evc);

Prints a dump of evc's structure to stdout. Used for debugging.

evc : the EVCard to dump

e_vcard_attribute_new ()

EVCardAttribute*    e_vcard_attribute_new               (const char *attr_group,
                                                         const char *attr_name);

Creates a new EVCardAttribute with the specified group and attribute names.

attr_group : a group name
attr_name : an attribute name
Returns : A new EVCardAttribute.

e_vcard_attribute_free ()

void                e_vcard_attribute_free              (EVCardAttribute *attr);

Frees an attribute, its values and its parameters.

attr : attribute to free

e_vcard_attribute_copy ()

EVCardAttribute*    e_vcard_attribute_copy              (EVCardAttribute *attr);

Makes a copy of attr.

attr : attribute to copy
Returns : A new EVCardAttribute identical to attr.

e_vcard_remove_attributes ()

void                e_vcard_remove_attributes           (EVCard *evc,
                                                         const char *attr_group,
                                                         const char *attr_name);

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.

evc : vcard object
attr_group : group name of attributes to be removed
attr_name : name of the arributes to be removed

e_vcard_remove_attribute ()

void                e_vcard_remove_attribute            (EVCard *evc,
                                                         EVCardAttribute *attr);

Removes attr from evc and frees it.

evc : an EVCard
attr : an EVCardAttribute to remove

e_vcard_add_attribute ()

void                e_vcard_add_attribute               (EVCard *evc,
                                                         EVCardAttribute *attr);

Adds attr to evc.

This also transfers ownership of attr to evc.

evc : an EVCard
attr : an EVCardAttribute to add

e_vcard_add_attribute_with_value ()

void                e_vcard_add_attribute_with_value    (EVCard *evcard,
                                                         EVCardAttribute *attr,
                                                         const char *value);

Adds attr to evcard, setting it to value.

This also transfers ownership of attr to evc.

evcard : an EVCard
attr : an EVCardAttribute to add
value : a value to assign to the attribute

e_vcard_add_attribute_with_values ()

void                e_vcard_add_attribute_with_values   (EVCard *evcard,
                                                         EVCardAttribute *attr,
                                                         ...);

Adds attr to evcard, assigning the list of values to it.

This also transfers ownership of attr to evc.

evcard : an EVCard
attr : an EVCardAttribute to add
... : a NULL-terminated list of values to assign to the attribute

e_vcard_attribute_add_value ()

void                e_vcard_attribute_add_value         (EVCardAttribute *attr,
                                                         const char *value);

Adds value to attr's list of values.

attr : an EVCardAttribute
value : a string value

e_vcard_attribute_add_value_decoded ()

void                e_vcard_attribute_add_value_decoded (EVCardAttribute *attr,
                                                         const char *value,
                                                         int len);

Decodes value according to the encoding used for attr, and adds it to attr's list of values.

attr : an EVCardAttribute
value : an encoded value
len : the length of the encoded value, in bytes

e_vcard_attribute_add_values ()

void                e_vcard_attribute_add_values        (EVCardAttribute *attr,
                                                         ...);

Adds a list of values to attr.

attr : an EVCardAttribute
... : a NULL-terminated list of strings

e_vcard_attribute_remove_values ()

void                e_vcard_attribute_remove_values     (EVCardAttribute *attr);

Removes all values from attr.

attr : an EVCardAttribute

e_vcard_attribute_remove_params ()

void                e_vcard_attribute_remove_params     (EVCardAttribute *attr);

Removes all parameters from attr.

attr : an EVCardAttribute

e_vcard_attribute_param_new ()

EVCardAttributeParam* e_vcard_attribute_param_new       (const char *name);

Creates a new parameter named name.

name : the name of the new parameter
Returns : A new EVCardAttributeParam.

e_vcard_attribute_param_free ()

void                e_vcard_attribute_param_free        (EVCardAttributeParam *param);

Frees param and its values.

param : an EVCardAttributeParam

e_vcard_attribute_param_copy ()

EVCardAttributeParam* e_vcard_attribute_param_copy      (EVCardAttributeParam *param);

Makes a copy of param.

param : an EVCardAttributeParam
Returns : a new EVCardAttributeParam identical to param.

e_vcard_attribute_add_param ()

void                e_vcard_attribute_add_param         (EVCardAttribute *attr,
                                                         EVCardAttributeParam *param);

Adds param to attr's list of parameters.

This also transfers ownership of param to attr.

attr : an EVCardAttribute
param : an EVCardAttributeParam to add

e_vcard_attribute_add_param_with_value ()

void                e_vcard_attribute_add_param_with_value
                                                        (EVCardAttribute *attr,
                                                         EVCardAttributeParam *param,
                                                         const char *value);

Adds value to param, then adds param to attr.

attr : an EVCardAttribute
param : an EVCardAttributeParam
value : a string value

e_vcard_attribute_add_param_with_values ()

void                e_vcard_attribute_add_param_with_values
                                                        (EVCardAttribute *attr,
                                                         EVCardAttributeParam *param,
                                                         ...);

Adds the list of values to param, then adds param to attr.

attr : an EVCardAttribute
param : an EVCardAttributeParam
... : a NULL-terminated list of strings

e_vcard_attribute_param_add_value ()

void                e_vcard_attribute_param_add_value   (EVCardAttributeParam *param,
                                                         const char *value);

Adds value to param's list of values.

param : an EVCardAttributeParam
value : a string value to add

e_vcard_attribute_param_add_values ()

void                e_vcard_attribute_param_add_values  (EVCardAttributeParam *param,
                                                         ...);

Adds a list of values to param.

param : an EVCardAttributeParam
... : a NULL-terminated list of strings

e_vcard_attribute_param_remove_values ()

void                e_vcard_attribute_param_remove_values
                                                        (EVCardAttributeParam *param);

Removes and frees all values from param.

param : an EVCardAttributeParam

e_vcard_get_attributes ()

GList*              e_vcard_get_attributes              (EVCard *evcard);

Gets the list of attributes from evcard. The list and its contents are owned by evcard, and must not be freed.

evcard : an EVCard
Returns : A list of attributes of type EVCardAttribute.

e_vcard_attribute_equal ()

gboolean            e_vcard_attribute_equal             (EVCardAttribute *attr_a,
                                                         EVCardAttribute *attr_b);

Checks if attr_a and attr_b are equal by value. This function considers attibute names, values and parameters. It is save to pass NULL to its arguments.

attr_a : first EVCardAttribute
attr_b : second EVCardAttribute
Returns : TRUE when both attributes are equal, and FALSE otherwise.

e_vcard_attribute_has_type ()

gboolean            e_vcard_attribute_has_type          (EVCardAttribute *attr,
                                                         const char *typestr);

Checks if attr has an EVCardAttributeParam of the specified type.

attr : an EVCardAttribute
typestr : a string representing the type
Returns : TRUE if such a parameter exists, FALSE otherwise.

e_vcard_attribute_is_single_valued ()

gboolean            e_vcard_attribute_is_single_valued  (EVCardAttribute *attr);

Checks if attr has a single value.

attr : an EVCardAttribute
Returns : TRUE if the attribute has exactly one value, FALSE otherwise.

e_vcard_attribute_get_group ()

const char*         e_vcard_attribute_get_group         (EVCardAttribute *attr);

Gets the group name of attr.

attr : an EVCardAttribute
Returns : The attribute's group name.

e_vcard_attribute_get_name ()

const char*         e_vcard_attribute_get_name          (EVCardAttribute *attr);

Gets the name of attr.

attr : an EVCardAttribute
Returns : The attribute's name.

e_vcard_attribute_get_value ()

char*               e_vcard_attribute_get_value         (EVCardAttribute *attr);

Gets the value of a single-valued EVCardAttribute, attr.

attr : an EVCardAttribute
Returns : A newly allocated string representing the value.

e_vcard_attribute_get_value_decoded ()

GString*            e_vcard_attribute_get_value_decoded (EVCardAttribute *attr);

Gets the value of a single-valued EVCardAttribute, attr, decoding it if necessary.

Note: this function seems currently to be unused. Could be removed.

attr : an EVCardAttribute
Returns : A newly allocated GString representing the value.

e_vcard_attribute_get_values ()

GList*              e_vcard_attribute_get_values        (EVCardAttribute *attr);

Gets the list of values from attr. The list and its contents are owned by attr, and must not be freed.

attr : an EVCardAttribute
Returns : A list of string values.

e_vcard_attribute_get_values_decoded ()

GList*              e_vcard_attribute_get_values_decoded
                                                        (EVCardAttribute *attr);

Gets the list of values from attr, decoding them if necessary. The list and its contents are owned by attr, and must not be freed.

attr : an EVCardAttribute
Returns : A list of values of type GString.

e_vcard_attribute_get_param ()

GList*              e_vcard_attribute_get_param         (EVCardAttribute *attr,
                                                         const char *name);

Gets the list of values for the paramater name from attr. The list and its contents are owned by attr, and must not be freed.

attr : an EVCardAttribute
name : a parameter name
Returns : A list of string elements representing the parameter's values.

e_vcard_attribute_get_params ()

GList*              e_vcard_attribute_get_params        (EVCardAttribute *attr);

Gets the list of parameters from attr. The list and its contents are owned by attr, and must not be freed.

attr : an EVCardAttribute
Returns : A list of elements of type EVCardAttributeParam.

e_vcard_attribute_param_get_name ()

const char*         e_vcard_attribute_param_get_name    (EVCardAttributeParam *param);

Gets the name of param.

param : an EVCardAttributeParam
Returns : The name of the parameter.

e_vcard_attribute_param_get_values ()

GList*              e_vcard_attribute_param_get_values  (EVCardAttributeParam *param);

Gets the list of values from param. The list and its contents are owned by param, and must not be freed.

param : an EVCardAttributeParam
Returns : A list of string elements representing the parameter's values.

e_vcard_attribute_remove_param ()

void                e_vcard_attribute_remove_param      (EVCardAttribute *attr,
                                                         const char *param_name);

Removes the parameter param_name from the attribute attr.

attr : an EVCardAttribute
param_name : a parameter name

e_vcard_attribute_remove_param_value ()

void                e_vcard_attribute_remove_param_value
                                                        (EVCardAttribute *attr,
                                                         const char *param_name,
                                                         const char *s);

Removes the value s from the parameter param_name on the attribute attr.

attr : an EVCardAttribute
param_name : a parameter name
s : a value

e_vcard_attribute_remove_value ()

void                e_vcard_attribute_remove_value      (EVCardAttribute *attr,
                                                         const char *s);

Removes from the value list in attr the value s.

attr : an EVCardAttribute
s : an value to remove

e_vcard_escape_string ()

char*               e_vcard_escape_string               (const char *s);

Escapes a string according to RFC2426, section 5.

s : the string to escape
Returns : A newly allocated, escaped string.

e_vcard_get_attribute ()

EVCardAttribute*    e_vcard_get_attribute               (EVCard *evc,
                                                         const char *name);

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.

evc : an EVCard
name : the name of the attribute to get
Returns : An EVCardAttribute if found, or NULL.

e_vcard_is_parsed ()

gboolean            e_vcard_is_parsed                   (EVCard *evc);

Check if the evc has been parsed already. Used for debugging.

evc : an EVCard
Returns : TRUE if evc has been parsed, FALSE otherwise.

e_vcard_is_parsing ()

gboolean            e_vcard_is_parsing                  (EVCard *evc);

Check if the evc is currently beening parsed. Used in derived classes to distinguish between parser caused attribute additions and real attribute additions.

evc : an EVCard
Returns : TRUE if evc is currently beening parsed, FALSE otherwise.

e_vcard_unescape_string ()

char*               e_vcard_unescape_string             (const char *s);

Unescapes a string according to RFC2426, section 5.

s : the string to unescape
Returns : A newly allocated, unescaped string.

EVC_ADR

#define EVC_ADR             "ADR"

Postal/mailing address


EVC_BDAY

#define EVC_BDAY            "BDAY"

Birthdate in ISO 8601 date or combined-date-and-time (in UTC or UTC-with-offset) format.


EVC_CALURI

#define EVC_CALURI          "CALURI"


EVC_CATEGORIES

#define EVC_CATEGORIES      "CATEGORIES"


EVC_EMAIL

#define EVC_EMAIL           "EMAIL"

Email address


EVC_ENCODING

#define EVC_ENCODING        "ENCODING"

The encoding format of the vCard


EVC_FBURL

#define EVC_FBURL           "FBURL"


EVC_FN

#define EVC_FN              "FN"

Full name; this is a single-string representation of the N field.


EVC_GEO

#define EVC_GEO		    "GEO"

Geographical location field


EVC_ICSCALENDAR

#define EVC_ICSCALENDAR     "ICSCALENDAR" /* XXX should this be X-EVOLUTION-ICSCALENDAR? */


EVC_KEY

#define EVC_KEY             "KEY"


EVC_LABEL

#define EVC_LABEL           "LABEL"


EVC_LOGO

#define EVC_LOGO            "LOGO"


EVC_MAILER

#define EVC_MAILER          "MAILER"


EVC_NICKNAME

#define EVC_NICKNAME        "NICKNAME"

A contact's nickname


EVC_N

#define EVC_N               "N"

Structured name field. The values for this field are, in order, as follows: <family name>;<given name>;<middle name(s)>;<honorific prefix(es()>;<honorific suffix(es)>

Example from RFC 2426: N:Stevenson;John;Philip,Paul;Dr.;Jr.,M.D.,A.C.P.


EVC_NOTE

#define EVC_NOTE            "NOTE"

An arbitrary user-set note about the contact


EVC_ORG

#define EVC_ORG             "ORG"

Organization/Company


EVC_PHOTO

#define EVC_PHOTO           "PHOTO"

Structured Photo/avatar. See RFC 2426 for more details.


EVC_PRODID

#define EVC_PRODID          "PRODID"


EVC_QUOTEDPRINTABLE

#define EVC_QUOTEDPRINTABLE "QUOTED-PRINTABLE"


EVC_REV

#define EVC_REV             "REV"


EVC_ROLE

#define EVC_ROLE            "ROLE"


EVC_TEL

#define EVC_TEL             "TEL"

Telephone or fax number.


EVC_TITLE

#define EVC_TITLE           "TITLE"

Professional title (e.g., "Director, Standards and Practices Dept.")


EVC_TYPE

#define EVC_TYPE            "TYPE"

The vCard "TYPE" attribute parameter. Usually omitted, "HOME", "WORK", or "OTHER".


EVC_UID

#define EVC_UID             "UID"

Unique ID


EVC_URL

#define EVC_URL             "URL"

A Web URL


EVC_VALUE

#define EVC_VALUE           "VALUE"


EVC_VERSION

#define EVC_VERSION         "VERSION"


EVC_X_AIM

#define EVC_X_AIM              "X-AIM"

An AOL Instant Messenger username


EVC_X_BLOG_URL

#define EVC_X_BLOG_URL         "X-EVOLUTION-BLOG-URL"


EVC_X_BOOK_URI

#define EVC_X_BOOK_URI     	"X-EVOLUTION-BOOK-URI"

The URI of the contact's EBook store. Do not set this manually.


EVC_X_GADUGADU

#define EVC_X_GADUGADU        "X-GADUGADU"

A Gadu Gadu messenger username


EVC_X_GROUPWISE

#define EVC_X_GROUPWISE     	"X-GROUPWISE"

A Novell Groupwise username


EVC_X_ICQ

#define EVC_X_ICQ              "X-ICQ"

An ICQ messenger username


EVC_X_JABBER

#define EVC_X_JABBER           "X-JABBER"

A Jabber/XMPP username


EVC_X_MSN

#define EVC_X_MSN           	"X-MSN"

A Microsoft Network/MSN Messenger username


EVC_X_SIP

#define EVC_X_SIP           	"X-SIP"

A SIP VoIP username


EVC_X_SKYPE

#define EVC_X_SKYPE           "X-SKYPE"

A Skype username


EVC_X_VIDEO_URL

#define EVC_X_VIDEO_URL     	"X-EVOLUTION-VIDEO-URL"


EVC_X_YAHOO

#define EVC_X_YAHOO         	"X-YAHOO"

A Yahoo! Messenger username

See Also

EContact