1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 2 /* e-vcard.h 3 * 4 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) 5 * 6 * This library is free software: you can redistribute it and/or modify it 7 * under the terms of the GNU Lesser General Public License as published by 8 * the Free Software Foundation. 9 * 10 * This library is distributed in the hope that it will be useful, but 11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License 13 * for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with this library. If not, see <http://www.gnu.org/licenses/>. 17 * 18 * Authors: Chris Toshok (toshok@ximian.com) 19 */ 20 21 #if !defined (__LIBEBOOK_CONTACTS_H_INSIDE__) && !defined (LIBEBOOK_CONTACTS_COMPILATION) 22 #error "Only <libebook-contacts/libebook-contacts.h> should be included directly." 23 #endif 24 25 #ifndef _EVCARD_H 26 #define _EVCARD_H 27 28 #include <glib-object.h> 29 30 G_BEGIN_DECLS 31 32 #define EVC_ADR "ADR" 33 #define EVC_BDAY "BDAY" 34 #define EVC_CALURI "CALURI" 35 #define EVC_CATEGORIES "CATEGORIES" 36 #define EVC_EMAIL "EMAIL" 37 #define EVC_ENCODING "ENCODING" 38 #define EVC_FBURL "FBURL" 39 #define EVC_FN "FN" 40 41 /** 42 * EVC_GEO: 43 * 44 * Since: 1.12 45 **/ 46 #define EVC_GEO "GEO" 47 48 /* XXX should this be X-EVOLUTION-ICSCALENDAR? */ 49 #define EVC_ICSCALENDAR "ICSCALENDAR" 50 #define EVC_KEY "KEY" 51 #define EVC_LABEL "LABEL" 52 #define EVC_LOGO "LOGO" 53 #define EVC_MAILER "MAILER" 54 #define EVC_NICKNAME "NICKNAME" 55 #define EVC_N "N" 56 #define EVC_NOTE "NOTE" 57 #define EVC_ORG "ORG" 58 #define EVC_PHOTO "PHOTO" 59 #define EVC_PRODID "PRODID" 60 #define EVC_QUOTEDPRINTABLE "QUOTED-PRINTABLE" 61 #define EVC_REV "REV" 62 #define EVC_ROLE "ROLE" 63 #define EVC_TEL "TEL" 64 #define EVC_TITLE "TITLE" 65 #define EVC_TYPE "TYPE" 66 #define EVC_UID "UID" 67 #define EVC_URL "URL" 68 #define EVC_VALUE "VALUE" 69 #define EVC_VERSION "VERSION" 70 71 #define EVC_X_AIM "X-AIM" 72 #define EVC_X_ANNIVERSARY "X-EVOLUTION-ANNIVERSARY" 73 #define EVC_X_ASSISTANT "X-EVOLUTION-ASSISTANT" 74 #define EVC_X_BIRTHDAY "X-EVOLUTION-BIRTHDAY" 75 #define EVC_X_BLOG_URL "X-EVOLUTION-BLOG-URL" 76 #define EVC_X_CALLBACK "X-EVOLUTION-CALLBACK" 77 #define EVC_X_COMPANY "X-EVOLUTION-COMPANY" 78 #define EVC_X_DEST_CONTACT_UID "X-EVOLUTION-DEST-CONTACT-UID" 79 #define EVC_X_DEST_EMAIL_NUM "X-EVOLUTION-DEST-EMAIL-NUM" 80 #define EVC_X_DEST_HTML_MAIL "X-EVOLUTION-DEST-HTML-MAIL" 81 #define EVC_X_DEST_SOURCE_UID "X-EVOLUTION-DEST-SOURCE-UID" 82 #define EVC_X_E164 "X-EVOLUTION-E164" 83 #define EVC_X_FILE_AS "X-EVOLUTION-FILE-AS" 84 #define EVC_X_GADUGADU "X-GADUGADU" 85 #define EVC_X_GROUPWISE "X-GROUPWISE" 86 #define EVC_X_ICQ "X-ICQ" 87 #define EVC_X_JABBER "X-JABBER" 88 #define EVC_X_LIST_SHOW_ADDRESSES "X-EVOLUTION-LIST-SHOW-ADDRESSES" 89 #define EVC_X_LIST "X-EVOLUTION-LIST" 90 91 /** 92 * EVC_X_LIST_NAME: 93 * 94 * Since: 3.2 95 **/ 96 #define EVC_X_LIST_NAME "X-EVOLUTION-LIST-NAME" 97 98 #define EVC_X_MANAGER "X-EVOLUTION-MANAGER" 99 #define EVC_X_MSN "X-MSN" 100 #define EVC_X_RADIO "X-EVOLUTION-RADIO" 101 102 /** 103 * EVC_X_SKYPE: 104 * 105 * Since: 2.26 106 **/ 107 #define EVC_X_SKYPE "X-SKYPE" 108 109 /** 110 * EVC_X_GOOGLE_TALK: 111 * 112 * Since: 3.2 113 **/ 114 #define EVC_X_GOOGLE_TALK "X-GOOGLE-TALK" 115 116 /** 117 * EVC_X_TWITTER: 118 * 119 * Twitter name(s). 120 * 121 * Since: 3.6 122 **/ 123 #define EVC_X_TWITTER "X-TWITTER" 124 125 /** 126 * EVC_X_SIP: 127 * 128 * Since: 2.26 129 **/ 130 #define EVC_X_SIP "X-SIP" 131 132 #define EVC_X_SPOUSE "X-EVOLUTION-SPOUSE" 133 #define EVC_X_TELEX "X-EVOLUTION-TELEX" 134 #define EVC_X_TTYTDD "X-EVOLUTION-TTYTDD" 135 #define EVC_X_VIDEO_URL "X-EVOLUTION-VIDEO-URL" 136 #define EVC_X_WANTS_HTML "X-MOZILLA-HTML" 137 #define EVC_X_YAHOO "X-YAHOO" 138 139 /** 140 * EVC_X_BOOK_UID: 141 * 142 * Since: 3.6 143 **/ 144 #define EVC_X_BOOK_UID "X-EVOLUTION-BOOK-UID" 145 146 /* Constants for Evo contact lists only */ 147 148 /** 149 * EVC_CONTACT_LIST: 150 * 151 * Since: 3.2 152 **/ 153 #define EVC_CONTACT_LIST "X-EVOLUTION-CONTACT-LIST-INFO" 154 155 /** 156 * EVC_PARENT_CL: 157 * 158 * Since: 3.2 159 **/ 160 #define EVC_PARENT_CL "X-EVOLUTION-PARENT-UID" 161 162 /** 163 * EVC_CL_UID: 164 * 165 * Since: 3.2 166 **/ 167 #define EVC_CL_UID "X-EVOLUTION-CONTACT-LIST-UID" 168 169 #define EVC_X_MATRIX "X-MATRIX" 170 171 #ifndef EDS_DISABLE_DEPRECATED 172 #define EVC_X_DEST_EMAIL "X-EVOLUTION-DEST-EMAIL" 173 #define EVC_X_DEST_NAME "X-EVOLUTION-DEST-NAME" 174 #endif /* EDS_DISABLE_DEPRECATED */ 175 176 typedef enum { 177 EVC_FORMAT_VCARD_21, 178 EVC_FORMAT_VCARD_30 179 } EVCardFormat; 180 181 #define E_TYPE_VCARD (e_vcard_get_type ()) 182 #define E_VCARD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_VCARD, EVCard)) 183 #define E_VCARD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_VCARD, EVCardClass)) 184 #define E_IS_VCARD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_VCARD)) 185 #define E_IS_VCARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_VCARD)) 186 #define E_VCARD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_VCARD, EVCardClass)) 187 188 #define E_TYPE_VCARD_ATTRIBUTE (e_vcard_attribute_get_type ()) 189 190 #define E_TYPE_VCARD_PARAM_ATTRIBUTE (e_vcard_attribute_param_get_type ()) 191 192 /** 193 * E_VCARD_21_VALID_PROPERTIES: 194 * 195 * FIXME: Document me! 196 * 197 * Since: 3.4 198 **/ 199 #define E_VCARD_21_VALID_PROPERTIES \ 200 "ADR,ORG,N,AGENT,LOGO,PHOTO,LABEL,FN,TITLE,SOUND,VERSION,TEL," \ 201 "EMAIL,TZ,GEO,NOTE,URL,BDAY,ROLE,REV,UID,KEY,MAILER" 202 203 /** 204 * E_VCARD_21_VALID_PARAMETERS: 205 * 206 * FIXME: Document me! 207 * 208 * Since: 3.4 209 **/ 210 #define E_VCARD_21_VALID_PARAMETERS \ 211 "TYPE,VALUE,ENCODING,CHARSET,LANGUAGE,DOM,INTL,POSTAL,PARCEL," \ 212 "HOME,WORK,PREF,VOICE,FAX,MSG,CELL,PAGER,BBS,MODEM,CAR,ISDN,VIDEO," \ 213 "AOL,APPLELINK,ATTMAIL,CIS,EWORLD,INTERNET,IBMMAIL,MCIMAIL," \ 214 "POWERSHARE,PRODIGY,TLX,X400,GIF,CGM,WMF,BMP,MET,PMB,DIB,PICT,TIFF," \ 215 "PDF,PS,JPEG,QTIME,MPEG,MPEG2,AVI,WAVE,AIFF,PCM,X509,PGP" 216 217 typedef struct _EVCard EVCard; 218 typedef struct _EVCardClass EVCardClass; 219 typedef struct _EVCardPrivate EVCardPrivate; 220 typedef struct _EVCardAttribute EVCardAttribute; 221 typedef struct _EVCardAttributeParam EVCardAttributeParam; 222 223 struct _EVCard { 224 GObject parent; 225 /*< private >*/ 226 EVCardPrivate *priv; 227 }; 228 229 struct _EVCardClass { 230 GObjectClass parent_class; 231 232 /* Padding for future expansion */ 233 void (*_ebook_reserved0) (void); 234 void (*_ebook_reserved1) (void); 235 void (*_ebook_reserved2) (void); 236 void (*_ebook_reserved3) (void); 237 void (*_ebook_reserved4) (void); 238 }; 239 240 GType e_vcard_get_type (void); 241 242 void e_vcard_construct (EVCard *evc, const gchar *str); 243 void e_vcard_construct_with_uid (EVCard *evc, const gchar *str, const gchar *uid); 244 void e_vcard_construct_full (EVCard *evc, const gchar *str, gssize len, const gchar *uid); 245 EVCard * e_vcard_new (void); 246 EVCard * e_vcard_new_from_string (const gchar *str); 247 248 gboolean e_vcard_is_parsed (EVCard *evc); 249 250 gchar * e_vcard_to_string (EVCard *evc, EVCardFormat format); 251 252 /* mostly for debugging */ 253 void e_vcard_dump_structure (EVCard *evc); 254 255 /* attributes */ 256 GType e_vcard_attribute_get_type (void); 257 EVCardAttribute *e_vcard_attribute_new (const gchar *attr_group, const gchar *attr_name); 258 void e_vcard_attribute_free (EVCardAttribute *attr); 259 EVCardAttribute *e_vcard_attribute_copy (EVCardAttribute *attr); 260 void e_vcard_remove_attributes (EVCard *evc, const gchar *attr_group, const gchar *attr_name); 261 void e_vcard_remove_attribute (EVCard *evc, EVCardAttribute *attr); 262 void e_vcard_append_attribute (EVCard *evc, EVCardAttribute *attr); 263 void e_vcard_append_attribute_with_value (EVCard *evcard, EVCardAttribute *attr, const gchar *value); 264 void e_vcard_append_attribute_with_values (EVCard *evcard, EVCardAttribute *attr, ...); 265 void e_vcard_add_attribute (EVCard *evc, EVCardAttribute *attr); 266 void e_vcard_add_attribute_with_value (EVCard *evcard, EVCardAttribute *attr, const gchar *value); 267 void e_vcard_add_attribute_with_values (EVCard *evcard, EVCardAttribute *attr, ...); 268 void e_vcard_attribute_add_value (EVCardAttribute *attr, const gchar *value); 269 void e_vcard_attribute_add_value_decoded (EVCardAttribute *attr, const gchar *value, gint len); 270 void e_vcard_attribute_add_values (EVCardAttribute *attr, ...); 271 void e_vcard_attribute_remove_value (EVCardAttribute *attr, const gchar *s); 272 void e_vcard_attribute_remove_values (EVCardAttribute *attr); 273 void e_vcard_attribute_remove_params (EVCardAttribute *attr); 274 void e_vcard_attribute_remove_param (EVCardAttribute *attr, const gchar *param_name); 275 void e_vcard_attribute_remove_param_value (EVCardAttribute *attr, const gchar *param_name, const gchar *s); 276 277 /* attribute parameters */ 278 GType e_vcard_attribute_param_get_type (void); 279 EVCardAttributeParam * e_vcard_attribute_param_new (const gchar *name); 280 void e_vcard_attribute_param_free (EVCardAttributeParam *param); 281 EVCardAttributeParam * e_vcard_attribute_param_copy (EVCardAttributeParam *param); 282 void e_vcard_attribute_add_param (EVCardAttribute *attr, EVCardAttributeParam *param); 283 void e_vcard_attribute_add_param_with_value (EVCardAttribute *attr, 284 EVCardAttributeParam *param, const gchar *value); 285 void e_vcard_attribute_add_param_with_values (EVCardAttribute *attr, 286 EVCardAttributeParam *param, ...); 287 288 void e_vcard_attribute_param_add_value (EVCardAttributeParam *param, 289 const gchar *value); 290 void e_vcard_attribute_param_add_values (EVCardAttributeParam *param, 291 ...); 292 void e_vcard_attribute_param_remove_values (EVCardAttributeParam *param); 293 294 /* EVCard* accessors. nothing returned from these functions should be 295 * freed by the caller. */ 296 EVCardAttribute *e_vcard_get_attribute (EVCard *evc, const gchar *name); 297 EVCardAttribute *e_vcard_get_attribute_if_parsed (EVCard *evc, const gchar *name); 298 GList * e_vcard_get_attributes (EVCard *evcard); 299 const gchar * e_vcard_attribute_get_group (EVCardAttribute *attr); 300 const gchar * e_vcard_attribute_get_name (EVCardAttribute *attr); 301 GList * e_vcard_attribute_get_values (EVCardAttribute *attr); /* GList elements are of type gchar * */ 302 GList * e_vcard_attribute_get_values_decoded (EVCardAttribute *attr); /* GList elements are of type GString * */ 303 304 /* special accessors for single valued attributes */ 305 gboolean e_vcard_attribute_is_single_valued (EVCardAttribute *attr); 306 gchar * e_vcard_attribute_get_value (EVCardAttribute *attr); 307 GString * e_vcard_attribute_get_value_decoded (EVCardAttribute *attr); 308 309 GList * e_vcard_attribute_get_params (EVCardAttribute *attr); 310 GList * e_vcard_attribute_get_param (EVCardAttribute *attr, const gchar *name); 311 const gchar * e_vcard_attribute_param_get_name (EVCardAttributeParam *param); 312 GList * e_vcard_attribute_param_get_values (EVCardAttributeParam *param); 313 314 /* special TYPE= parameter predicate (checks for TYPE=@typestr */ 315 gboolean e_vcard_attribute_has_type (EVCardAttribute *attr, const gchar *typestr); 316 317 /* Utility functions. */ 318 gchar * e_vcard_escape_string (const gchar *s); 319 gchar * e_vcard_unescape_string (const gchar *s); 320 321 void e_vcard_util_set_x_attribute (EVCard *vcard, 322 const gchar *x_name, 323 const gchar *value); 324 gchar * e_vcard_util_dup_x_attribute (EVCard *vcard, 325 const gchar *x_name); 326 327 G_END_DECLS 328 329 #endif /* _EVCARD_H */ 330