- renamed all vformat_ and VFormat symbols in opensync plugin's
[barry.git] / opensync-plugin / src / vformat.h
blobced425d9e78fc5c9e95a9dddd5db8bca91a0ff19
1 /*
2 * Copyright (C) 2003 Ximian, Inc. 2005 Armin Bauer
4 * Copyright (C) 2003 Ximian, Inc.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * Author: Chris Toshok (toshok@ximian.com)
21 * Author: Armin Bauer (armin.bauer@opensync.org)
25 #ifndef _VFORMAT_H
26 #define _VFORMAT_H
28 #include <glib.h>
29 #include <time.h>
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
35 typedef enum {
36 VFORMAT_CARD_21,
37 VFORMAT_CARD_30,
38 VFORMAT_NOTE,
39 VFORMAT_EVENT_10,
40 VFORMAT_EVENT_20,
41 VFORMAT_TODO_10,
42 VFORMAT_TODO_20
43 } b_VFormatType;
45 typedef struct b_VFormat {
46 //b_VFormatType type;
47 GList *attributes;
48 } b_VFormat;
50 #define CRLF "\r\n"
52 typedef enum {
53 VF_ENCODING_RAW, /* no encoding */
54 VF_ENCODING_BASE64, /* base64 */
55 VF_ENCODING_QP, /* quoted-printable */
56 VF_ENCODING_8BIT
57 } b_VFormatEncoding;
59 typedef struct b_VFormatAttribute {
60 char *block; /* "vtimezone/standard", or "vevent", depending on
61 current begin/end location... may be null */
62 char *group;
63 char *name;
64 GList *params; /* b_VFormatParam */
65 GList *values;
66 GList *decoded_values;
67 b_VFormatEncoding encoding;
68 gboolean encoding_set;
69 } b_VFormatAttribute;
71 typedef struct b_VFormatParam {
72 char *name;
73 GList *values; /* GList of char*'s*/
74 } b_VFormatParam;
77 /*b_VFormat *vcard_new(b_VFormatType type);
78 b_VFormat *vcard_new_from_string (const char *str, b_VFormatType type);
79 //char *vcard_to_string(VFormat *card, VFormatType format);
81 VFormat *vnote_new(void);
82 VFormat *vnote_new_from_string(const char *str);
83 //char *vnote_to_string(VFormat *note);
86 VFormat *vevent_new(void);
87 VFormat *vevent_new_from_string(const char *str);
88 //char *vevent_to_string(VFormat *event);
90 VFormat *vtodo_new(void);
91 VFormat *vtodo_new_from_string(const char *str);*/
92 //char *vtodo_to_string(VFormat *todo);
94 /* mostly for debugging */
95 b_VFormat *b_vformat_new(void);
96 b_VFormat *b_vformat_new_from_string(const char *str);
97 void b_vformat_dump_structure(b_VFormat *format);
98 char *b_vformat_to_string(b_VFormat *evc, b_VFormatType type);
99 time_t b_vformat_time_to_unix(const char *inptime);
100 void b_vformat_free(b_VFormat *format);
102 /* attributes */
103 b_VFormatAttribute *b_vformat_attribute_new (const char *attr_group, const char *attr_name);
104 void b_vformat_attribute_free (b_VFormatAttribute *attr);
105 b_VFormatAttribute *b_vformat_attribute_copy (b_VFormatAttribute *attr);
106 void b_vformat_remove_attributes (b_VFormat *vformat, const char *attr_group, const char *attr_name);
107 void b_vformat_remove_attribute (b_VFormat *vformat, b_VFormatAttribute *attr);
108 void b_vformat_add_attribute (b_VFormat *vformat, b_VFormatAttribute *attr);
109 void b_vformat_add_attribute_with_value (b_VFormat *vformat, b_VFormatAttribute *attr, const char *value);
110 void b_vformat_add_attribute_with_values (b_VFormat *vformat, b_VFormatAttribute *attr, ...);
111 void b_vformat_attribute_add_value (b_VFormatAttribute *attr, const char *value);
112 void b_vformat_attribute_set_value (b_VFormatAttribute *attr, int nth, const char *value);
113 void b_vformat_attribute_add_value_decoded (b_VFormatAttribute *attr, const char *value, int len);
114 void b_vformat_attribute_add_values (b_VFormatAttribute *attr, ...);
115 void b_vformat_attribute_remove_values (b_VFormatAttribute *attr);
116 void b_vformat_attribute_remove_params (b_VFormatAttribute *attr);
117 b_VFormatAttribute *b_vformat_find_attribute (b_VFormat *evc, const char *name, int nth, const char *block);
119 /* attribute parameters */
120 b_VFormatParam* b_vformat_attribute_param_new (const char *param_name);
121 void b_vformat_attribute_param_free (b_VFormatParam *param);
122 b_VFormatParam* b_vformat_attribute_param_copy (b_VFormatParam *param);
123 void b_vformat_attribute_add_param (b_VFormatAttribute *attr, b_VFormatParam *param);
124 b_VFormatParam *b_vformat_attribute_find_param(b_VFormatAttribute *attr, const char *name);
125 void b_vformat_attribute_add_param_with_value (b_VFormatAttribute *attr, const char *name, const char *value);
126 void b_vformat_attribute_add_param_with_values (b_VFormatAttribute *attr,
127 b_VFormatParam *param, ...);
129 void b_vformat_attribute_param_add_value (b_VFormatParam *param,
130 const char *value);
131 void b_vformat_attribute_param_add_values (b_VFormatParam *param,
132 ...);
133 void b_vformat_attribute_param_remove_values (b_VFormatParam *param);
134 gboolean b_vformat_attribute_has_param(b_VFormatAttribute *attr, const char *name);
136 /* b_VFormat* accessors. nothing returned from these functions should be
137 freed by the caller. */
138 GList* b_vformat_get_attributes (b_VFormat *vformat);
139 const char* b_vformat_attribute_get_group (b_VFormatAttribute *attr);
140 const char* b_vformat_attribute_get_name (b_VFormatAttribute *attr);
141 const char* b_vformat_attribute_get_block (b_VFormatAttribute *attr);
142 GList* b_vformat_attribute_get_values (b_VFormatAttribute *attr); /* GList elements are of type char* */
143 GList* b_vformat_attribute_get_values_decoded (b_VFormatAttribute *attr); /* GList elements are of type GString* */
144 const char *b_vformat_attribute_get_nth_value(b_VFormatAttribute *attr, int nth);
146 /* special accessors for single valued attributes */
147 gboolean b_vformat_attribute_is_single_valued (b_VFormatAttribute *attr);
148 char* b_vformat_attribute_get_value (b_VFormatAttribute *attr);
149 GString* b_vformat_attribute_get_value_decoded (b_VFormatAttribute *attr);
151 GList* b_vformat_attribute_get_params (b_VFormatAttribute *attr);
152 const char* b_vformat_attribute_param_get_name (b_VFormatParam *param);
153 GList* b_vformat_attribute_param_get_values (b_VFormatParam *param);
154 const char *b_vformat_attribute_param_get_nth_value(b_VFormatParam *param, int nth);
156 /* special TYPE= parameter predicate (checks for TYPE=@typestr */
157 gboolean b_vformat_attribute_has_type (b_VFormatAttribute *attr, const char *typestr);
159 /* Utility functions. */
160 char* b_vformat_escape_string (const char *str, b_VFormatType type);
161 char* b_vformat_unescape_string (const char *str);
163 #ifdef __cplusplus
165 #endif
167 #endif /* _VFORMAT_H */