New EClient/EBookClient/ECalClient API deprecating EBook/ECal
[platform/upstream/evolution-data-server.git] / calendar / libecal / e-cal.h
1 /* Evolution calendar ecal
2  *
3  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
4  *
5  * Authors: Federico Mena-Quintero <federico@ximian.com>
6  *          Rodrigo Moya <rodrigo@novell.com>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of version 2 of the GNU Lesser General Public
10  * License as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  */
21
22 #ifndef E_CAL_H
23 #define E_CAL_H
24
25 #ifndef E_CAL_DISABLE_DEPRECATED
26
27 #include <glib-object.h>
28 #include "libedataserver/e-source-list.h"
29 #include "libedataserver/e-source.h"
30 #include <libecal/e-cal-recur.h>
31 #include <libecal/e-cal-util.h>
32 #include <libecal/e-cal-view.h>
33 #include <libecal/e-cal-types.h>
34
35 G_BEGIN_DECLS
36
37 \f
38
39 #define E_TYPE_CAL            (e_cal_get_type ())
40 #define E_CAL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL, ECal))
41 #define E_CAL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CAL, ECalClass))
42 #define E_IS_CAL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL))
43 #define E_IS_CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL))
44
45 #define E_TYPE_CAL_SOURCE_TYPE (e_cal_source_type_enum_get_type ())
46 #define E_CAL_SET_MODE_STATUS_ENUM_TYPE (e_cal_set_mode_status_enum_get_type ())
47 #define CAL_MODE_ENUM_TYPE                   (cal_mode_enum_get_type ())
48
49 typedef struct _ECal ECal;
50 typedef struct _ECalClass ECalClass;
51 typedef struct _ECalPrivate ECalPrivate;
52
53 typedef enum {
54         E_CAL_SOURCE_TYPE_EVENT,
55         E_CAL_SOURCE_TYPE_TODO,
56         E_CAL_SOURCE_TYPE_JOURNAL,
57         E_CAL_SOURCE_TYPE_LAST
58 } ECalSourceType;
59
60 /* Set mode status for the e_cal_set_mode function */
61 typedef enum {
62         E_CAL_SET_MODE_SUCCESS,
63         E_CAL_SET_MODE_ERROR,
64         E_CAL_SET_MODE_NOT_SUPPORTED
65 } ECalSetModeStatus;
66
67 /* Whether the ecal is not loaded, is being loaded, or is already loaded */
68 typedef enum {
69         E_CAL_LOAD_NOT_LOADED,
70         E_CAL_LOAD_AUTHENTICATING,
71         E_CAL_LOAD_LOADING,
72         E_CAL_LOAD_LOADED
73 } ECalLoadState;
74
75 #ifndef E_CAL_DISABLE_DEPRECATED
76 typedef enum {
77         Local = 1 << 0,
78         Remote = 1 << 1,
79         AnyMode = 0x07
80 } EDataCalMode;
81 #endif
82
83 struct _ECal {
84         GObject object;
85
86         /*< private >*/
87         ECalPrivate *priv;
88 };
89
90 struct _ECalClass {
91         GObjectClass parent_class;
92
93         /* Notification signals */
94
95         #ifndef E_CAL_DISABLE_DEPRECATED
96         void (* cal_opened) (ECal *ecal, ECalendarStatus status);
97         #endif
98         void (* cal_opened_ex) (ECal *ecal, const GError *error);
99         void (* cal_set_mode) (ECal *ecal, ECalSetModeStatus status, CalMode mode);
100
101         void (* backend_error) (ECal *ecal, const gchar *message);
102         void (* backend_died) (ECal *ecal);
103 };
104
105 typedef gchar * (* ECalAuthFunc) (ECal *ecal,
106                                  const gchar *prompt,
107                                  const gchar *key,
108                                  gpointer user_data);
109
110 GType e_cal_get_type (void);
111
112 GType e_cal_source_type_enum_get_type (void);
113 GType e_cal_set_mode_status_enum_get_type (void);
114 GType cal_mode_enum_get_type (void);
115
116 ECal *e_cal_new (ESource *source, ECalSourceType type);
117 ECal *e_cal_new_from_uri (const gchar *uri, ECalSourceType type);
118 ECal *e_cal_new_system_calendar (void);
119 ECal *e_cal_new_system_tasks (void);
120 ECal *e_cal_new_system_memos (void);
121
122 void e_cal_set_auth_func (ECal *ecal, ECalAuthFunc func, gpointer data);
123
124 gboolean e_cal_open (ECal *ecal, gboolean only_if_exists, GError **error);
125 void e_cal_open_async (ECal *ecal, gboolean only_if_exists);
126 gboolean e_cal_refresh (ECal *ecal, GError **error);
127 gboolean e_cal_remove (ECal *ecal, GError **error);
128
129 GList *e_cal_uri_list (ECal *ecal, CalMode mode);
130
131 ECalSourceType e_cal_get_source_type (ECal *ecal);
132 ECalLoadState e_cal_get_load_state (ECal *ecal);
133
134 ESource *e_cal_get_source (ECal *ecal);
135 const gchar *e_cal_get_uri (ECal *ecal);
136
137 gboolean e_cal_is_read_only (ECal *ecal, gboolean *read_only, GError **error);
138 gboolean e_cal_get_cal_address (ECal *ecal, gchar **cal_address, GError **error);
139 gboolean e_cal_get_alarm_email_address (ECal *ecal, gchar **alarm_address, GError **error);
140 gboolean e_cal_get_ldap_attribute (ECal *ecal, gchar **ldap_attribute, GError **error);
141
142 gboolean e_cal_get_one_alarm_only (ECal *ecal);
143 gboolean e_cal_get_organizer_must_attend (ECal *ecal);
144 gboolean e_cal_get_save_schedules (ECal *ecal);
145 gboolean e_cal_get_static_capability (ECal *ecal, const gchar *cap);
146 gboolean e_cal_get_organizer_must_accept (ECal *ecal);
147 gboolean e_cal_get_refresh_supported (ECal *ecal);
148
149 gboolean e_cal_set_mode (ECal *ecal, CalMode mode);
150
151 gboolean e_cal_get_default_object (ECal *ecal,
152                                    icalcomponent **icalcomp, GError **error);
153
154 gboolean e_cal_get_object (ECal *ecal,
155                            const gchar *uid,
156                            const gchar *rid,
157                            icalcomponent **icalcomp,
158                            GError **error);
159 gboolean e_cal_get_objects_for_uid (ECal *ecal,
160                                     const gchar *uid,
161                                     GList **objects,
162                                     GError **error);
163
164 gboolean e_cal_get_changes (ECal *ecal, const gchar *change_id, GList **changes, GError **error);
165 void e_cal_free_change_list (GList *list);
166
167 gboolean e_cal_get_object_list (ECal *ecal, const gchar *query, GList **objects, GError **error);
168 gboolean e_cal_get_object_list_as_comp (ECal *ecal, const gchar *query, GList **objects, GError **error);
169 void e_cal_free_object_list (GList *objects);
170
171 gboolean e_cal_get_free_busy (ECal *ecal, GList *users, time_t start, time_t end,
172                               GList **freebusy, GError **error);
173
174 void e_cal_generate_instances (ECal *ecal, time_t start, time_t end,
175                                ECalRecurInstanceFn cb, gpointer cb_data);
176 void e_cal_generate_instances_for_object (ECal *ecal, icalcomponent *icalcomp,
177                                           time_t start, time_t end,
178                                           ECalRecurInstanceFn cb, gpointer cb_data);
179
180 GSList *e_cal_get_alarms_in_range (ECal *ecal, time_t start, time_t end);
181
182 void e_cal_free_alarms (GSList *comp_alarms);
183
184 gboolean e_cal_get_alarms_for_object (ECal *ecal, const ECalComponentId *id,
185                                       time_t start, time_t end,
186                                       ECalComponentAlarms **alarms);
187
188 gboolean e_cal_create_object (ECal *ecal, icalcomponent *icalcomp, gchar **uid, GError **error);
189 gboolean e_cal_modify_object (ECal *ecal, icalcomponent *icalcomp, CalObjModType mod, GError **error);
190 gboolean e_cal_remove_object (ECal *ecal, const gchar *uid, GError **error);
191 gboolean e_cal_remove_object_with_mod (ECal *ecal, const gchar *uid, const gchar *rid, CalObjModType mod, GError **error);
192
193 gboolean e_cal_discard_alarm (ECal *ecal, ECalComponent *comp, const gchar *auid, GError **error);
194
195 gboolean e_cal_receive_objects (ECal *ecal, icalcomponent *icalcomp, GError **error);
196 gboolean e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GList **users, icalcomponent **modified_icalcomp, GError **error);
197
198 gboolean e_cal_get_timezone (ECal *ecal, const gchar *tzid, icaltimezone **zone, GError **error);
199 gboolean e_cal_add_timezone (ECal *ecal, icaltimezone *izone, GError **error);
200 /* Sets the default timezone to use to resolve DATE and floating DATE-TIME
201    values. This will typically be from the user's timezone setting. Call this
202    before using any other functions. It will pass the default timezone on to
203    the server. Returns TRUE on success. */
204 gboolean e_cal_set_default_timezone (ECal *ecal, icaltimezone *zone, GError **error);
205
206 gboolean e_cal_get_query (ECal *ecal, const gchar *sexp, ECalView **query, GError **error);
207
208 /* Resolves TZIDs for the recurrence generator. */
209 icaltimezone *e_cal_resolve_tzid_cb (const gchar *tzid, gpointer data);
210
211 /* Returns a complete VCALENDAR for a VEVENT/VTODO including all VTIMEZONEs
212    used by the component. It also includes a 'METHOD:PUBLISH' property. */
213 gchar * e_cal_get_component_as_string (ECal *ecal, icalcomponent *icalcomp);
214
215 const gchar * e_cal_get_error_message (ECalendarStatus status);
216
217 /* Calendar/Tasks Discovery */
218 gboolean    e_cal_open_default (ECal **ecal, ECalSourceType type, ECalAuthFunc func, gpointer data, GError **error);
219 gboolean    e_cal_set_default (ECal  *ecal, GError **error);
220 gboolean    e_cal_set_default_source (ESource *source, ECalSourceType type, GError **error);
221 gboolean    e_cal_get_sources (ESourceList **sources, ECalSourceType type, GError **error);
222 const gchar * e_cal_get_local_attachment_store (ECal *ecal);
223 gboolean e_cal_get_recurrences_no_master (ECal *ecal);
224 gboolean e_cal_get_attachments_for_comp (ECal *ecal, const gchar *uid, const gchar *rid, GSList **list, GError **error);
225
226 G_END_DECLS
227
228 #endif /* E_CAL_DISABLE_DEPRECATED */
229
230 #endif