1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 /* e-contact.h 3 * 4 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) 5 * Copyright (C) 2012 Intel Corporation 6 * 7 * This library is free software: you can redistribute it and/or modify it 8 * under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation. 10 * 11 * This library is distributed in the hope that it will be useful, but 12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 14 * for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public License 17 * along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 * Authors: Chris Toshok <toshok@ximian.com> 20 * Tristan Van Berkom <tristanvb@openismus.com> 21 */ 22 23 #if !defined (__LIBEBOOK_CONTACTS_H_INSIDE__) && !defined (LIBEBOOK_CONTACTS_COMPILATION) 24 #error "Only <libebook-contacts/libebook-contacts.h> should be included directly." 25 #endif 26 27 #ifndef E_CONTACT_H 28 #define E_CONTACT_H 29 30 #include <time.h> 31 #include <stdio.h> 32 #include <libebook-contacts/e-vcard.h> 33 34 /* Standard GObject macros */ 35 #define E_TYPE_CONTACT \ 36 (e_contact_get_type ()) 37 #define E_CONTACT(obj) \ 38 (G_TYPE_CHECK_INSTANCE_CAST \ 39 ((obj), E_TYPE_CONTACT, EContact)) 40 #define E_CONTACT_CLASS(cls) \ 41 (G_TYPE_CHECK_CLASS_CAST \ 42 ((cls), E_TYPE_CONTACT, EContactClass)) 43 #define E_IS_CONTACT(obj) \ 44 (G_TYPE_CHECK_INSTANCE_TYPE \ 45 ((obj), E_TYPE_CONTACT)) 46 #define E_IS_CONTACT_CLASS(cls) \ 47 (G_TYPE_CHECK_CLASS_TYPE \ 48 ((cls), E_TYPE_CONTACT)) 49 #define E_CONTACT_GET_CLASS(obj) \ 50 (G_TYPE_INSTANCE_GET_CLASS \ 51 ((obj), E_TYPE_CONTACT, EContactClass)) 52 53 #define E_TYPE_CONTACT_DATE (e_contact_date_get_type ()) 54 #define E_TYPE_CONTACT_NAME (e_contact_name_get_type ()) 55 #define E_TYPE_CONTACT_PHOTO (e_contact_photo_get_type ()) 56 #define E_TYPE_CONTACT_CERT (e_contact_cert_get_type ()) 57 #define E_TYPE_CONTACT_ADDRESS (e_contact_address_get_type ()) 58 #define E_TYPE_CONTACT_ATTR_LIST (e_contact_attr_list_get_type ()) 59 60 G_BEGIN_DECLS 61 62 typedef struct _EContact EContact; 63 typedef struct _EContactClass EContactClass; 64 typedef struct _EContactPrivate EContactPrivate; 65 66 typedef enum { 67 68 E_CONTACT_UID = 1, /* string field */ 69 E_CONTACT_FILE_AS, /* string field */ 70 E_CONTACT_BOOK_UID, /* string field */ 71 72 /* Name fields */ 73 E_CONTACT_FULL_NAME, /* string field */ 74 E_CONTACT_GIVEN_NAME, /* synthetic string field */ 75 E_CONTACT_FAMILY_NAME, /* synthetic string field */ 76 E_CONTACT_NICKNAME, /* string field */ 77 78 /* Email fields */ 79 E_CONTACT_EMAIL_1, /* synthetic string field */ 80 E_CONTACT_EMAIL_2, /* synthetic string field */ 81 E_CONTACT_EMAIL_3, /* synthetic string field */ 82 E_CONTACT_EMAIL_4, /* synthetic string field */ 83 84 E_CONTACT_MAILER, /* string field */ 85 86 /* Address Labels */ 87 E_CONTACT_ADDRESS_LABEL_HOME, /* synthetic string field */ 88 E_CONTACT_ADDRESS_LABEL_WORK, /* synthetic string field */ 89 E_CONTACT_ADDRESS_LABEL_OTHER, /* synthetic string field */ 90 91 /* Phone fields */ 92 E_CONTACT_PHONE_ASSISTANT, 93 E_CONTACT_PHONE_BUSINESS, 94 E_CONTACT_PHONE_BUSINESS_2, 95 E_CONTACT_PHONE_BUSINESS_FAX, 96 E_CONTACT_PHONE_CALLBACK, 97 E_CONTACT_PHONE_CAR, 98 E_CONTACT_PHONE_COMPANY, 99 E_CONTACT_PHONE_HOME, 100 E_CONTACT_PHONE_HOME_2, 101 E_CONTACT_PHONE_HOME_FAX, 102 E_CONTACT_PHONE_ISDN, 103 E_CONTACT_PHONE_MOBILE, 104 E_CONTACT_PHONE_OTHER, 105 E_CONTACT_PHONE_OTHER_FAX, 106 E_CONTACT_PHONE_PAGER, 107 E_CONTACT_PHONE_PRIMARY, 108 E_CONTACT_PHONE_RADIO, 109 E_CONTACT_PHONE_TELEX, 110 E_CONTACT_PHONE_TTYTDD, 111 112 /* Organizational fields */ 113 E_CONTACT_ORG, /* string field */ 114 E_CONTACT_ORG_UNIT, /* string field */ 115 E_CONTACT_OFFICE, /* string field */ 116 E_CONTACT_TITLE, /* string field */ 117 E_CONTACT_ROLE, /* string field */ 118 E_CONTACT_MANAGER, /* string field */ 119 E_CONTACT_ASSISTANT, /* string field */ 120 121 /* Web fields */ 122 E_CONTACT_HOMEPAGE_URL, /* string field */ 123 E_CONTACT_BLOG_URL, /* string field */ 124 125 /* Contact categories */ 126 E_CONTACT_CATEGORIES, /* string field */ 127 128 /* Collaboration fields */ 129 E_CONTACT_CALENDAR_URI, /* string field */ 130 E_CONTACT_FREEBUSY_URL, /* string field */ 131 E_CONTACT_ICS_CALENDAR, /* string field */ 132 E_CONTACT_VIDEO_URL, /* string field */ 133 134 /* misc fields */ 135 E_CONTACT_SPOUSE, /* string field */ 136 E_CONTACT_NOTE, /* string field */ 137 138 E_CONTACT_IM_AIM_HOME_1, /* Synthetic string field */ 139 E_CONTACT_IM_AIM_HOME_2, /* Synthetic string field */ 140 E_CONTACT_IM_AIM_HOME_3, /* Synthetic string field */ 141 E_CONTACT_IM_AIM_WORK_1, /* Synthetic string field */ 142 E_CONTACT_IM_AIM_WORK_2, /* Synthetic string field */ 143 E_CONTACT_IM_AIM_WORK_3, /* Synthetic string field */ 144 E_CONTACT_IM_GROUPWISE_HOME_1, /* Synthetic string field */ 145 E_CONTACT_IM_GROUPWISE_HOME_2, /* Synthetic string field */ 146 E_CONTACT_IM_GROUPWISE_HOME_3, /* Synthetic string field */ 147 E_CONTACT_IM_GROUPWISE_WORK_1, /* Synthetic string field */ 148 E_CONTACT_IM_GROUPWISE_WORK_2, /* Synthetic string field */ 149 E_CONTACT_IM_GROUPWISE_WORK_3, /* Synthetic string field */ 150 E_CONTACT_IM_JABBER_HOME_1, /* Synthetic string field */ 151 E_CONTACT_IM_JABBER_HOME_2, /* Synthetic string field */ 152 E_CONTACT_IM_JABBER_HOME_3, /* Synthetic string field */ 153 E_CONTACT_IM_JABBER_WORK_1, /* Synthetic string field */ 154 E_CONTACT_IM_JABBER_WORK_2, /* Synthetic string field */ 155 E_CONTACT_IM_JABBER_WORK_3, /* Synthetic string field */ 156 E_CONTACT_IM_YAHOO_HOME_1, /* Synthetic string field */ 157 E_CONTACT_IM_YAHOO_HOME_2, /* Synthetic string field */ 158 E_CONTACT_IM_YAHOO_HOME_3, /* Synthetic string field */ 159 E_CONTACT_IM_YAHOO_WORK_1, /* Synthetic string field */ 160 E_CONTACT_IM_YAHOO_WORK_2, /* Synthetic string field */ 161 E_CONTACT_IM_YAHOO_WORK_3, /* Synthetic string field */ 162 E_CONTACT_IM_MSN_HOME_1, /* Synthetic string field */ 163 E_CONTACT_IM_MSN_HOME_2, /* Synthetic string field */ 164 E_CONTACT_IM_MSN_HOME_3, /* Synthetic string field */ 165 E_CONTACT_IM_MSN_WORK_1, /* Synthetic string field */ 166 E_CONTACT_IM_MSN_WORK_2, /* Synthetic string field */ 167 E_CONTACT_IM_MSN_WORK_3, /* Synthetic string field */ 168 E_CONTACT_IM_ICQ_HOME_1, /* Synthetic string field */ 169 E_CONTACT_IM_ICQ_HOME_2, /* Synthetic string field */ 170 E_CONTACT_IM_ICQ_HOME_3, /* Synthetic string field */ 171 E_CONTACT_IM_ICQ_WORK_1, /* Synthetic string field */ 172 E_CONTACT_IM_ICQ_WORK_2, /* Synthetic string field */ 173 E_CONTACT_IM_ICQ_WORK_3, /* Synthetic string field */ 174 175 /* Convenience field for getting a name from the contact. 176 * Returns the first one of[File-As, Full Name, Org, Email1] 177 * to be set */ 178 E_CONTACT_REV, /* string field to hold time of last update to this vcard */ 179 E_CONTACT_NAME_OR_ORG, 180 181 /* Address fields */ 182 E_CONTACT_ADDRESS, /* Multi-valued structured (EContactAddress) */ 183 E_CONTACT_ADDRESS_HOME, /* synthetic structured field (EContactAddress) */ 184 E_CONTACT_ADDRESS_WORK, /* synthetic structured field (EContactAddress) */ 185 E_CONTACT_ADDRESS_OTHER, /* synthetic structured field (EContactAddress) */ 186 187 E_CONTACT_CATEGORY_LIST, /* multi-valued */ 188 189 /* Photo/Logo */ 190 E_CONTACT_PHOTO, /* structured field (EContactPhoto) */ 191 E_CONTACT_LOGO, /* structured field (EContactPhoto) */ 192 193 E_CONTACT_NAME, /* structured field (EContactName) */ 194 E_CONTACT_EMAIL, /* Multi-valued */ 195 196 /* Instant Messaging fields */ 197 E_CONTACT_IM_AIM, /* Multi-valued */ 198 E_CONTACT_IM_GROUPWISE, /* Multi-valued */ 199 E_CONTACT_IM_JABBER, /* Multi-valued */ 200 E_CONTACT_IM_YAHOO, /* Multi-valued */ 201 E_CONTACT_IM_MSN, /* Multi-valued */ 202 E_CONTACT_IM_ICQ, /* Multi-valued */ 203 204 E_CONTACT_WANTS_HTML, /* boolean field */ 205 206 /* fields used for describing contact lists. a contact list 207 * is just a contact with _IS_LIST set to true. the members 208 * are listed in the _EMAIL field. */ 209 E_CONTACT_IS_LIST, /* boolean field */ 210 E_CONTACT_LIST_SHOW_ADDRESSES, /* boolean field */ 211 212 E_CONTACT_BIRTH_DATE, /* structured field (EContactDate) */ 213 E_CONTACT_ANNIVERSARY, /* structured field (EContactDate) */ 214 215 /* Security Fields */ 216 E_CONTACT_X509_CERT, /* structured field (EContactCert) */ 217 E_CONTACT_PGP_CERT, /* structured field (EContactCert) */ 218 219 E_CONTACT_IM_GADUGADU_HOME_1, /* Synthetic string field */ 220 E_CONTACT_IM_GADUGADU_HOME_2, /* Synthetic string field */ 221 E_CONTACT_IM_GADUGADU_HOME_3, /* Synthetic string field */ 222 E_CONTACT_IM_GADUGADU_WORK_1, /* Synthetic string field */ 223 E_CONTACT_IM_GADUGADU_WORK_2, /* Synthetic string field */ 224 E_CONTACT_IM_GADUGADU_WORK_3, /* Synthetic string field */ 225 226 E_CONTACT_IM_GADUGADU, /* Multi-valued */ 227 228 E_CONTACT_GEO, /* structured field (EContactGeo) */ 229 230 E_CONTACT_TEL, /* list of strings */ 231 232 E_CONTACT_IM_SKYPE_HOME_1, /* Synthetic string field */ 233 E_CONTACT_IM_SKYPE_HOME_2, /* Synthetic string field */ 234 E_CONTACT_IM_SKYPE_HOME_3, /* Synthetic string field */ 235 E_CONTACT_IM_SKYPE_WORK_1, /* Synthetic string field */ 236 E_CONTACT_IM_SKYPE_WORK_2, /* Synthetic string field */ 237 E_CONTACT_IM_SKYPE_WORK_3, /* Synthetic string field */ 238 E_CONTACT_IM_SKYPE, /* Multi-valued */ 239 240 E_CONTACT_SIP, 241 242 E_CONTACT_IM_GOOGLE_TALK_HOME_1, /* Synthetic string field */ 243 E_CONTACT_IM_GOOGLE_TALK_HOME_2, /* Synthetic string field */ 244 E_CONTACT_IM_GOOGLE_TALK_HOME_3, /* Synthetic string field */ 245 E_CONTACT_IM_GOOGLE_TALK_WORK_1, /* Synthetic string field */ 246 E_CONTACT_IM_GOOGLE_TALK_WORK_2, /* Synthetic string field */ 247 E_CONTACT_IM_GOOGLE_TALK_WORK_3, /* Synthetic string field */ 248 E_CONTACT_IM_GOOGLE_TALK, /* Multi-valued */ 249 250 E_CONTACT_IM_TWITTER, /* Multi-valued */ 251 252 E_CONTACT_IM_MATRIX_HOME_1, /* Synthetic string field */ 253 E_CONTACT_IM_MATRIX_HOME_2, /* Synthetic string field */ 254 E_CONTACT_IM_MATRIX_HOME_3, /* Synthetic string field */ 255 E_CONTACT_IM_MATRIX_WORK_1, /* Synthetic string field */ 256 E_CONTACT_IM_MATRIX_WORK_2, /* Synthetic string field */ 257 E_CONTACT_IM_MATRIX_WORK_3, /* Synthetic string field */ 258 E_CONTACT_IM_MATRIX, /* Multi-valued */ 259 260 E_CONTACT_FIELD_LAST, 261 E_CONTACT_FIELD_FIRST = E_CONTACT_UID, 262 263 /* useful constants */ 264 E_CONTACT_LAST_SIMPLE_STRING = E_CONTACT_NAME_OR_ORG, 265 E_CONTACT_FIRST_PHONE_ID = E_CONTACT_PHONE_ASSISTANT, 266 E_CONTACT_LAST_PHONE_ID = E_CONTACT_PHONE_TTYTDD, 267 E_CONTACT_FIRST_EMAIL_ID = E_CONTACT_EMAIL_1, 268 E_CONTACT_LAST_EMAIL_ID = E_CONTACT_EMAIL_4, 269 E_CONTACT_FIRST_ADDRESS_ID = E_CONTACT_ADDRESS_HOME, 270 E_CONTACT_LAST_ADDRESS_ID = E_CONTACT_ADDRESS_OTHER, 271 E_CONTACT_FIRST_LABEL_ID = E_CONTACT_ADDRESS_LABEL_HOME, 272 E_CONTACT_LAST_LABEL_ID = E_CONTACT_ADDRESS_LABEL_OTHER 273 274 } EContactField; 275 276 typedef struct { 277 gchar *family; 278 gchar *given; 279 gchar *additional; 280 gchar *prefixes; 281 gchar *suffixes; 282 } EContactName; 283 284 /** 285 * EContactGeo: 286 * @latitude: latitude 287 * @longitude: longitude 288 * 289 * Since: 1.12 290 **/ 291 typedef struct { 292 gdouble latitude; 293 gdouble longitude; 294 } EContactGeo; 295 296 typedef enum { 297 E_CONTACT_PHOTO_TYPE_INLINED, 298 E_CONTACT_PHOTO_TYPE_URI 299 } EContactPhotoType; 300 301 typedef struct { 302 EContactPhotoType type; 303 union { 304 struct { 305 gchar *mime_type; 306 gsize length; 307 guchar *data; 308 } inlined; 309 gchar *uri; 310 } data; 311 } EContactPhoto; 312 313 typedef struct { 314 gchar *address_format; /* the two letter country code that 315 * determines the format/meaning of the 316 * following fields */ 317 gchar *po; 318 gchar *ext; 319 gchar *street; 320 gchar *locality; 321 gchar *region; 322 gchar *code; 323 gchar *country; 324 } EContactAddress; 325 326 typedef struct { 327 guint year; 328 guint month; 329 guint day; 330 } EContactDate; 331 332 typedef struct { 333 gsize length; 334 gchar *data; 335 } EContactCert; 336 337 struct _EContact { 338 EVCard parent; 339 /*< private >*/ 340 EContactPrivate *priv; 341 }; 342 343 struct _EContactClass { 344 EVCardClass parent_class; 345 346 /* Padding for future expansion */ 347 void (*_ebook_reserved0) (void); 348 void (*_ebook_reserved1) (void); 349 void (*_ebook_reserved2) (void); 350 void (*_ebook_reserved3) (void); 351 void (*_ebook_reserved4) (void); 352 }; 353 354 GType e_contact_get_type (void) G_GNUC_CONST; 355 EContact * e_contact_new (void); 356 EContact * e_contact_new_from_vcard (const gchar *vcard); 357 EContact * e_contact_new_from_vcard_with_uid 358 (const gchar *vcard, 359 const gchar *uid); 360 EContact * e_contact_duplicate (EContact *contact); 361 gpointer e_contact_get (EContact *contact, 362 EContactField field_id); 363 gconstpointer e_contact_get_const (EContact *contact, 364 EContactField field_id); 365 void e_contact_set (EContact *contact, 366 EContactField field_id, 367 gconstpointer value); 368 369 /* the following three calls return and take a GList of 370 * EVCardAttribute*'s. */ 371 GList * e_contact_get_attributes (EContact *contact, 372 EContactField field_id); 373 GList * e_contact_get_attributes_set (EContact *contact, 374 const EContactField field_ids[], 375 gint size); 376 377 void e_contact_set_attributes (EContact *contact, 378 EContactField field_id, 379 GList *attributes); 380 381 /* misc functions for structured values */ 382 GType e_contact_date_get_type (void); 383 EContactDate * e_contact_date_new (void); 384 EContactDate * e_contact_date_from_string (const gchar *str); 385 gchar * e_contact_date_to_string (EContactDate *dt); 386 gboolean e_contact_date_equal (EContactDate *dt1, 387 EContactDate *dt2); 388 void e_contact_date_free (EContactDate *date); 389 390 GType e_contact_name_get_type (void); 391 EContactName * e_contact_name_new (void); 392 gchar * e_contact_name_to_string (const EContactName *name); 393 EContactName * e_contact_name_from_string (const gchar *name_str); 394 EContactName * e_contact_name_copy (EContactName *n); 395 void e_contact_name_free (EContactName *name); 396 397 GType e_contact_photo_get_type (void); 398 EContactPhoto * e_contact_photo_new (void); 399 void e_contact_photo_free (EContactPhoto *photo); 400 EContactPhoto * e_contact_photo_copy (EContactPhoto *photo); 401 const guchar * e_contact_photo_get_inlined (EContactPhoto *photo, 402 gsize *len); 403 void e_contact_photo_set_inlined (EContactPhoto *photo, 404 const guchar *data, 405 gsize len); 406 const gchar * e_contact_photo_get_mime_type (EContactPhoto *photo); 407 void e_contact_photo_set_mime_type (EContactPhoto *photo, 408 const gchar *mime_type); 409 const gchar * e_contact_photo_get_uri (EContactPhoto *photo); 410 void e_contact_photo_set_uri (EContactPhoto *photo, 411 const gchar *uri); 412 gboolean e_contact_inline_local_photos (EContact *contact, 413 GError **error); 414 415 EContactGeo * e_contact_geo_new (void); 416 GType e_contact_geo_get_type (void); 417 void e_contact_geo_free (EContactGeo *geo); 418 419 EContactCert * e_contact_cert_new (void); 420 GType e_contact_cert_get_type (void); 421 void e_contact_cert_free (EContactCert *cert); 422 423 GType e_contact_address_get_type (void); 424 EContactAddress * 425 e_contact_address_new (void); 426 void e_contact_address_free (EContactAddress *address); 427 428 GType e_contact_attr_list_get_type (void); 429 GList * e_contact_attr_list_copy (GList *list); 430 void e_contact_attr_list_free (GList *list); 431 432 GType e_contact_field_type (EContactField field_id); 433 const gchar * e_contact_field_name (EContactField field_id); 434 const gchar * e_contact_pretty_name (EContactField field_id); 435 const gchar * e_contact_vcard_attribute (EContactField field_id); 436 gboolean e_contact_field_is_string (EContactField field_id); 437 EContactField e_contact_field_id (const gchar *field_name); 438 EContactField e_contact_field_id_from_vcard (const gchar *vcard_field); 439 440 G_END_DECLS 441 442 #endif /* E_CONTACT_H */ 443 444