Fix FSF address (Tobias Mueller, #470445)
[platform/upstream/evolution-data-server.git] / addressbook / libebook / e-vcard.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* e-vcard.h
3  *
4  * Copyright (C) 2003 Ximian, Inc.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of version 2 of the GNU Lesser General Public
8  * License as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this program; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * Author: Chris Toshok (toshok@ximian.com)
21  */
22
23 #ifndef _EVCARD_H
24 #define _EVCARD_H
25
26 #include <glib.h>
27 #include <glib-object.h>
28
29 G_BEGIN_DECLS
30
31 #define EVC_ADR             "ADR"
32 #define EVC_BDAY            "BDAY"
33 #define EVC_CALURI          "CALURI"
34 #define EVC_CATEGORIES      "CATEGORIES"
35 #define EVC_EMAIL           "EMAIL"
36 #define EVC_ENCODING        "ENCODING"
37 #define EVC_FBURL           "FBURL"
38 #define EVC_FN              "FN"
39 #define EVC_GEO             "GEO"
40 #define EVC_ICSCALENDAR     "ICSCALENDAR" /* XXX should this be X-EVOLUTION-ICSCALENDAR? */
41 #define EVC_KEY             "KEY"
42 #define EVC_LABEL           "LABEL"
43 #define EVC_LOGO            "LOGO"
44 #define EVC_MAILER          "MAILER"
45 #define EVC_NICKNAME        "NICKNAME"
46 #define EVC_N               "N"
47 #define EVC_NOTE            "NOTE"
48 #define EVC_ORG             "ORG"
49 #define EVC_PHOTO           "PHOTO"
50 #define EVC_PRODID          "PRODID"
51 #define EVC_QUOTEDPRINTABLE "QUOTED-PRINTABLE"
52 #define EVC_REV             "REV"
53 #define EVC_ROLE            "ROLE"
54 #define EVC_TEL             "TEL"
55 #define EVC_TITLE           "TITLE"
56 #define EVC_TYPE            "TYPE"
57 #define EVC_UID             "UID"
58 #define EVC_URL             "URL"
59 #define EVC_VALUE           "VALUE"
60 #define EVC_VERSION         "VERSION"
61
62 #define EVC_X_AIM              "X-AIM"
63 #define EVC_X_ANNIVERSARY      "X-EVOLUTION-ANNIVERSARY"
64 #define EVC_X_ASSISTANT        "X-EVOLUTION-ASSISTANT"
65 #define EVC_X_BIRTHDAY         "X-EVOLUTION-BIRTHDAY"
66 #define EVC_X_BLOG_URL         "X-EVOLUTION-BLOG-URL"
67 #define EVC_X_CALLBACK         "X-EVOLUTION-CALLBACK"
68 #define EVC_X_COMPANY          "X-EVOLUTION-COMPANY"
69 #define EVC_X_DEST_CONTACT_UID "X-EVOLUTION-DEST-CONTACT-UID"
70 #define EVC_X_DEST_EMAIL       "X-EVOLUTION-DEST-EMAIL"
71 #define EVC_X_DEST_EMAIL_NUM   "X-EVOLUTION-DEST-EMAIL-NUM"
72 #define EVC_X_DEST_HTML_MAIL   "X-EVOLUTION-DEST-HTML-MAIL"
73 #define EVC_X_DEST_NAME        "X-EVOLUTION-DEST-NAME"
74 #define EVC_X_DEST_SOURCE_UID  "X-EVOLUTION-DEST-SOURCE-UID"
75 #define EVC_X_FILE_AS          "X-EVOLUTION-FILE-AS"
76 #define EVC_X_ICQ              "X-ICQ"
77 #define EVC_X_JABBER           "X-JABBER"
78 #define EVC_X_LIST_SHOW_ADDRESSES "X-EVOLUTION-LIST-SHOW_ADDRESSES"
79 #define EVC_X_LIST              "X-EVOLUTION-LIST"
80 #define EVC_X_MANAGER           "X-EVOLUTION-MANAGER"
81 #define EVC_X_MSN               "X-MSN"
82 #define EVC_X_RADIO             "X-EVOLUTION-RADIO"
83 #define EVC_X_SPOUSE            "X-EVOLUTION-SPOUSE"
84 #define EVC_X_TELEX             "X-EVOLUTION-TELEX"
85 #define EVC_X_TTYTDD            "X-EVOLUTION-TTYTDD"
86 #define EVC_X_VIDEO_URL         "X-EVOLUTION-VIDEO-URL"
87 #define EVC_X_WANTS_HTML        "X-MOZILLA-HTML"
88 #define EVC_X_YAHOO             "X-YAHOO"
89 #define EVC_X_GADUGADU        "X-GADUGADU"
90 #define EVC_X_GROUPWISE         "X-GROUPWISE"
91 #define EVC_X_BOOK_URI          "X-EVOLUTION-BOOK-URI"
92
93 typedef enum {
94         EVC_FORMAT_VCARD_21,
95         EVC_FORMAT_VCARD_30
96 } EVCardFormat;
97
98 #define E_TYPE_VCARD            (e_vcard_get_type ())
99 #define E_VCARD(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_VCARD, EVCard))
100 #define E_VCARD_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_VCARD, EVCardClass))
101 #define E_IS_VCARD(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_VCARD))
102 #define E_IS_VCARD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_VCARD))
103 #define E_VCARD_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_VCARD, EVCardClass))
104
105 typedef struct _EVCard EVCard;
106 typedef struct _EVCardClass EVCardClass;
107 typedef struct _EVCardPrivate EVCardPrivate;
108 typedef struct _EVCardAttribute EVCardAttribute;
109 typedef struct _EVCardAttributeParam EVCardAttributeParam;
110
111 struct _EVCard {
112         GObject parent;
113         /*< private >*/
114         EVCardPrivate *priv;
115 };
116
117 struct _EVCardClass {
118         GObjectClass parent_class;
119
120         /* Padding for future expansion */
121         void (*_ebook_reserved0) (void);
122         void (*_ebook_reserved1) (void);
123         void (*_ebook_reserved2) (void);
124         void (*_ebook_reserved3) (void);
125         void (*_ebook_reserved4) (void);
126 };
127
128 GType   e_vcard_get_type                     (void);
129
130 void    e_vcard_construct                    (EVCard *evc, const char *str);
131 EVCard* e_vcard_new                          (void);
132 EVCard* e_vcard_new_from_string              (const char *str);
133
134 char*   e_vcard_to_string                    (EVCard *evc, EVCardFormat format);
135
136 /* mostly for debugging */
137 void    e_vcard_dump_structure               (EVCard *evc);
138
139
140 /* attributes */
141 EVCardAttribute *e_vcard_attribute_new               (const char *attr_group, const char *attr_name);
142 void             e_vcard_attribute_free              (EVCardAttribute *attr);
143 EVCardAttribute *e_vcard_attribute_copy              (EVCardAttribute *attr);
144 void             e_vcard_remove_attributes           (EVCard *evc, const char *attr_group, const char *attr_name);
145 void             e_vcard_remove_attribute            (EVCard *evc, EVCardAttribute *attr);
146 void             e_vcard_add_attribute               (EVCard *evc, EVCardAttribute *attr);
147 void             e_vcard_add_attribute_with_value    (EVCard *evcard, EVCardAttribute *attr, const char *value);
148 void             e_vcard_add_attribute_with_values   (EVCard *evcard, EVCardAttribute *attr, ...);
149 void             e_vcard_attribute_add_value         (EVCardAttribute *attr, const char *value);
150 void             e_vcard_attribute_add_value_decoded (EVCardAttribute *attr, const char *value, int len);
151 void             e_vcard_attribute_add_values        (EVCardAttribute *attr, ...);
152 void             e_vcard_attribute_remove_value      (EVCardAttribute *attr, const char *s);
153 void             e_vcard_attribute_remove_values     (EVCardAttribute *attr);
154 void             e_vcard_attribute_remove_params     (EVCardAttribute *attr);
155 void             e_vcard_attribute_remove_param      (EVCardAttribute *attr, const char *param_name);
156 void             e_vcard_attribute_remove_param_value (EVCardAttribute *attr, const char *param_name, const char *s);
157
158 /* attribute parameters */
159 EVCardAttributeParam* e_vcard_attribute_param_new             (const char *name);
160 void                  e_vcard_attribute_param_free            (EVCardAttributeParam *param);
161 EVCardAttributeParam* e_vcard_attribute_param_copy            (EVCardAttributeParam *param);
162 void                  e_vcard_attribute_add_param             (EVCardAttribute *attr, EVCardAttributeParam *param);
163 void                  e_vcard_attribute_add_param_with_value  (EVCardAttribute *attr,
164                                                                EVCardAttributeParam *param, const char *value);
165 void                  e_vcard_attribute_add_param_with_values (EVCardAttribute *attr,
166                                                                EVCardAttributeParam *param, ...);
167
168 void                  e_vcard_attribute_param_add_value       (EVCardAttributeParam *param,
169                                                                const char *value);
170 void                  e_vcard_attribute_param_add_values      (EVCardAttributeParam *param,
171                                                                ...);
172 void                  e_vcard_attribute_param_remove_values   (EVCardAttributeParam *param);
173
174 /* EVCard* accessors.  nothing returned from these functions should be
175    freed by the caller. */
176 EVCardAttribute *e_vcard_get_attribute        (EVCard *evc, const char *name);
177 GList*           e_vcard_get_attributes       (EVCard *evcard);
178 const char*      e_vcard_attribute_get_group  (EVCardAttribute *attr);
179 const char*      e_vcard_attribute_get_name   (EVCardAttribute *attr);
180 GList*           e_vcard_attribute_get_values (EVCardAttribute *attr);  /* GList elements are of type char* */
181 GList*           e_vcard_attribute_get_values_decoded (EVCardAttribute *attr); /* GList elements are of type GString* */
182
183 /* special accessors for single valued attributes */
184 gboolean              e_vcard_attribute_is_single_valued      (EVCardAttribute *attr);
185 char*                 e_vcard_attribute_get_value             (EVCardAttribute *attr);
186 GString*              e_vcard_attribute_get_value_decoded     (EVCardAttribute *attr);
187
188 GList*           e_vcard_attribute_get_params       (EVCardAttribute *attr);
189 GList*           e_vcard_attribute_get_param        (EVCardAttribute *attr, const char *name);
190 const char*      e_vcard_attribute_param_get_name   (EVCardAttributeParam *param);
191 GList*           e_vcard_attribute_param_get_values (EVCardAttributeParam *param);
192
193 /* special TYPE= parameter predicate (checks for TYPE=@typestr */
194 gboolean         e_vcard_attribute_has_type         (EVCardAttribute *attr, const char *typestr);
195
196 /* Utility functions. */
197 char*            e_vcard_escape_string (const char *s);
198 char*            e_vcard_unescape_string (const char *s);
199
200 G_END_DECLS
201
202 #endif /* _EVCARD_H */