374
376
ec->priv = g_new0 (EContactPrivate, 1);
378
e_contact_get_type (void)
380
static GType contact_type = 0;
383
static const GTypeInfo contact_info = {
384
sizeof (EContactClass),
385
NULL, /* base_init */
386
NULL, /* base_finalize */
387
(GClassInitFunc) e_contact_class_init,
388
NULL, /* class_finalize */
389
NULL, /* class_data */
392
(GInstanceInitFunc) e_contact_init,
395
contact_type = g_type_register_static (E_TYPE_VCARD, "EContact", &contact_info, 0);
401
379
static EVCardAttribute*
402
380
e_contact_get_first_attr (EContact *contact, const gchar *attr_name)
1313
1291
* Gets the string representation of @field_id.
1315
* Return value: The string representation of @field_id, or %NULL if it doesn't exist.
1293
* Returns: The string representation of @field_id, or %NULL if it doesn't exist.
1318
1296
e_contact_field_name (EContactField field_id)
1329
1307
* Gets a human-readable, translated string representation
1330
1308
* of @field_id.
1332
* Return value: The human-readable representation of @field_id, or %NULL if it doesn't exist.
1310
* Returns: The human-readable representation of @field_id, or %NULL if it doesn't exist.
1335
1313
e_contact_pretty_name (EContactField field_id)
1351
1329
* Gets the vcard attribute corresponding to @field_id, as a string.
1353
* Return value: The vcard attribute corresponding to @field_id, or %NULL if it doesn't exist.
1331
* Returns: The vcard attribute corresponding to @field_id, or %NULL if it doesn't exist.
1356
1334
e_contact_vcard_attribute (EContactField field_id)
1367
1345
* Gets the #EContactField corresponding to the @field_name.
1369
* Return value: An #EContactField corresponding to @field_name, or %0 if it doesn't exist.
1347
* Returns: An #EContactField corresponding to @field_name, or %0 if it doesn't exist.
1372
1350
e_contact_field_id (const gchar *field_name)
1388
1366
* Gets the #EContactField corresponding to the @vcard_field.
1390
* Return value: An #EContactField corresponding to @vcard_field, or %0 if it doesn't exist.
1368
* Returns: An #EContactField corresponding to @vcard_field, or %0 if it doesn't exist.
1393
1373
e_contact_field_id_from_vcard (const gchar *vcard_field)
1415
1395
* Gets the value of @contact's field specified by @field_id.
1417
* Return value: Depends on the field's type, owned by the caller.
1397
* Returns: Depends on the field's type, owned by the caller.
1420
1400
e_contact_get (EContact *contact, EContactField field_id)
1457
1437
v = e_vcard_attribute_get_values (attr);
1458
1438
v = g_list_nth (v, info->list_elem);
1460
return v ? g_strdup (v->data) : NULL;
1440
return v ? g_strstrip (g_strdup (v->data)) : NULL;
1516
1496
if (info->t & E_CONTACT_FIELD_TYPE_STRUCT)
1517
1497
return (gpointer)info->boxed_type_getter();
1519
return g_strdup (rv);
1499
return g_strstrip (g_strdup (rv));
1521
1501
else if (info->t & E_CONTACT_FIELD_TYPE_SYNTHETIC) {
1522
1502
switch (info->field_id) {
1537
1517
str = e_contact_get_const (contact, E_CONTACT_EMAIL_1);
1540
return g_strdup (str);
1520
return g_strstrip (g_strdup (str));
1542
1522
case E_CONTACT_CATEGORIES: {
1543
1523
EVCardAttribute *attr = e_contact_get_first_attr (contact, EVC_CATEGORIES);
1580
1560
v = e_vcard_attribute_get_values (attr);
1582
1562
if (info->t & E_CONTACT_FIELD_TYPE_STRING) {
1583
return v ? g_strdup (v->data) : NULL;
1563
return v ? g_strstrip (g_strdup (v->data)) : NULL;
1586
rv = g_list_append (rv, v ? g_strdup (v->data) : NULL);
1566
rv = g_list_append (rv, v ? g_strstrip (g_strdup (v->data)) : NULL);
1600
1580
* Gets the value of @contact's field specified by @field_id, caching
1601
1581
* the result so it can be freed later.
1603
* Return value: Depends on the field's type, owned by the #EContact.
1583
* Returns: Depends on the field's type, owned by the #EContact.
1606
1586
e_contact_get_const (EContact *contact, EContactField field_id)
1654
1634
* Gets a list of the vcard attributes for @contact's @field_id.
1656
* Return value: A #GList of pointers to #EVCardAttribute, owned by the caller.
1636
* Returns: A #GList of pointers to #EVCardAttribute, owned by the caller.
1659
1639
e_contact_get_attributes (EContact *contact, EContactField field_id)
1831
e_contact_name_get_type (void)
1833
static GType type_id = 0;
1836
type_id = g_boxed_type_register_static ("EContactName",
1837
(GBoxedCopyFunc) e_contact_name_copy,
1838
(GBoxedFreeFunc) e_contact_name_free);
1810
#define E_CONTACT_DEFINE_BOXED_TYPE(_tp,_nm) \
1812
_tp ## _get_type (void) \
1814
static volatile gsize type_id__volatile = 0; \
1816
if (g_once_init_enter (&type_id__volatile)) { \
1819
type_id = g_boxed_type_register_static (_nm, \
1820
(GBoxedCopyFunc) _tp ## _copy, \
1821
(GBoxedFreeFunc) _tp ## _free); \
1823
g_once_init_leave (&type_id__volatile, type_id);\
1826
return type_id__volatile; \
1829
E_CONTACT_DEFINE_BOXED_TYPE (e_contact_name, "EContactName")
1843
1832
* e_contact_date_from_string:
1844
1833
* @str: a date string in the format YYYY-MM-DD or YYYYMMDD
1846
1835
* Creates a new #EContactDate based on @str.
1848
* Return value: A new #EContactDate struct.
1837
* Returns: A new #EContactDate struct.
1851
1840
e_contact_date_from_string (const gchar *str)
1867
1856
date->year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111;
1868
1857
date->month = str[5] * 10 + str[6] - '0' * 11;
1869
1858
date->day = str[8] * 10 + str[9] - '0' * 11;
1870
} else if ( length == 8 ) {
1859
} else if (length == 8) {
1871
1860
date->year = str[0] * 1000 + str[1] * 100 + str[2] * 10 + str[3] - '0' * 1111;
1872
1861
date->month = str[4] * 10 + str[5] - '0' * 11;
1873
1862
date->day = str[6] * 10 + str[7] - '0' * 11;
1883
1872
* Generates a date string in the format YYYY-MM-DD based
1884
1873
* on the values of @dt.
1886
* Return value: A date string, owned by the caller.
1875
* Returns: A date string, owned by the caller.
1889
1878
e_contact_date_to_string (EContactDate *dt)
1905
1894
* Checks if @dt1 and @dt2 are the same date.
1907
* Return value: %TRUE if @dt1 and @dt2 are equal, %FALSE otherwise.
1896
* Returns: %TRUE if @dt1 and @dt2 are equal, %FALSE otherwise.
1910
1899
e_contact_date_equal (EContactDate *dt1, EContactDate *dt2)
1952
e_contact_date_get_type (void)
1954
static GType type_id = 0;
1957
type_id = g_boxed_type_register_static ("EContactDate",
1958
(GBoxedCopyFunc) e_contact_date_copy,
1959
(GBoxedFreeFunc) e_contact_date_free);
1940
E_CONTACT_DEFINE_BOXED_TYPE (e_contact_date, "EContactDate")
1964
1943
* e_contact_date_new:
1966
1945
* Creates a new #EContactDate struct.
1968
* Return value: A new #EContactDate struct.
1947
* Returns: A new #EContactDate struct.
1971
1950
e_contact_date_new (void)
2036
e_contact_photo_get_type (void)
2038
static GType type_id = 0;
2041
type_id = g_boxed_type_register_static ("EContactPhoto",
2042
(GBoxedCopyFunc) e_contact_photo_copy,
2043
(GBoxedFreeFunc) e_contact_photo_free);
2014
E_CONTACT_DEFINE_BOXED_TYPE (e_contact_photo, "EContactPhoto")
2048
2017
* e_contact_geo_free:
2049
2018
* @geo: an #EContactGeo
2051
2020
* Frees the @geo struct and its contents.
2054
2025
e_contact_geo_free (EContactGeo *geo)
2070
e_contact_geo_get_type (void)
2072
static GType type_id = 0;
2075
type_id = g_boxed_type_register_static ("EContactGeo",
2076
(GBoxedCopyFunc) e_contact_geo_copy,
2077
(GBoxedFreeFunc) e_contact_geo_free);
2040
E_CONTACT_DEFINE_BOXED_TYPE (e_contact_geo, "EContactGeo")
2082
2043
* e_contact_address_free:
2119
2080
return address2;
2123
e_contact_address_get_type (void)
2125
static GType type_id = 0;
2128
type_id = g_boxed_type_register_static ("EContactAddress",
2129
(GBoxedCopyFunc) e_contact_address_copy,
2130
(GBoxedFreeFunc) e_contact_address_free);
2083
E_CONTACT_DEFINE_BOXED_TYPE (e_contact_address, "EContactAddress")
2135
2086
* e_contact_cert_free:
2162
e_contact_cert_get_type (void)
2164
static GType type_id = 0;
2167
type_id = g_boxed_type_register_static ("EContactCert",
2168
(GBoxedCopyFunc) e_contact_cert_copy,
2169
(GBoxedFreeFunc) e_contact_cert_free);
2112
E_CONTACT_DEFINE_BOXED_TYPE (e_contact_cert, "EContactCert")