Unref source. (fetch_corba_cal): Ref and keep source. (e_cal_get_source):
[platform/upstream/evolution-data-server.git] / calendar / libecal / e-cal.h
1 /* Evolution calendar ecal
2  *
3  * Copyright (C) 2001 Ximian, Inc.
4  *
5  * Authors: Federico Mena-Quintero <federico@ximian.com>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of version 2 of the GNU General Public
9  * License as published by the Free Software Foundation.
10  *
11  * This program 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
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef E_CAL_H
22 #define E_CAL_H
23
24 #include <glib-object.h>
25 #include <libedataserver/e-source.h>
26 #include <libecal/e-cal-recur.h>
27 #include <libecal/e-cal-util.h>
28 #include <libecal/e-cal-view.h>
29 #include <libecal/e-cal-types.h>
30
31 G_BEGIN_DECLS
32
33 \f
34
35 #define E_TYPE_CAL            (e_cal_get_type ())
36 #define E_CAL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_CAL, ECal))
37 #define E_CAL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_CAL, ECalClass))
38 #define E_IS_CAL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_CAL))
39 #define E_IS_CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_CAL))
40
41 #define E_CAL_SET_MODE_STATUS_ENUM_TYPE (e_cal_set_mode_status_enum_get_type ())
42 #define CAL_MODE_ENUM_TYPE                   (cal_mode_enum_get_type ())
43
44 typedef struct _ECal ECal;
45 typedef struct _ECalClass ECalClass;
46 typedef struct _ECalPrivate ECalPrivate;
47
48 /* Set mode status for the e_cal_set_mode function */
49 typedef enum {
50         E_CAL_SET_MODE_SUCCESS,
51         E_CAL_SET_MODE_ERROR,
52         E_CAL_SET_MODE_NOT_SUPPORTED
53 } ECalSetModeStatus;
54
55 /* Whether the ecal is not loaded, is being loaded, or is already loaded */
56 typedef enum {
57         E_CAL_LOAD_NOT_LOADED,
58         E_CAL_LOAD_LOADING,
59         E_CAL_LOAD_LOADED
60 } ECalLoadState;
61
62 struct _ECal {
63         GObject object;
64
65         /*< private >*/
66         ECalPrivate *priv;
67 };
68
69 struct _ECalClass {
70         GObjectClass parent_class;
71
72         /* Notification signals */
73
74         void (* cal_opened) (ECal *ecal, ECalendarStatus status);
75         void (* cal_set_mode) (ECal *ecal, ECalSetModeStatus status, CalMode mode);     
76
77         void (* backend_error) (ECal *ecal, const char *message);
78
79         void (* categories_changed) (ECal *ecal, GPtrArray *categories);
80
81         void (* forget_password) (ECal *ecal, const char *key);
82
83         void (* backend_died) (ECal *ecal);
84 };
85
86 typedef gchar * (* ECalAuthFunc) (ECal *ecal,
87                                   const gchar *prompt,
88                                   const gchar *key,
89                                   gpointer user_data);
90
91 GType e_cal_get_type (void);
92
93 GType e_cal_open_status_enum_get_type (void);
94 GType e_cal_set_mode_status_enum_get_type (void);
95 GType cal_mode_enum_get_type (void);
96
97 ECal *e_cal_new (ESource *source, CalObjType type);
98 ECal *e_cal_new_from_uri (const gchar *uri, CalObjType type);
99
100 void e_cal_set_auth_func (ECal *ecal, ECalAuthFunc func, gpointer data);
101
102 gboolean e_cal_open (ECal *ecal, gboolean only_if_exists, GError **error);
103 void e_cal_open_async (ECal *ecal, gboolean only_if_exists);
104 gboolean e_cal_remove_calendar (ECal *ecal, GError **error);
105
106 GList *e_cal_uri_list (ECal *ecal, CalMode mode);
107
108 ECalLoadState e_cal_get_load_state (ECal *ecal);
109
110 ESource *e_cal_get_source (ECal *ecal);
111 const char *e_cal_get_uri (ECal *ecal);
112
113 gboolean e_cal_is_read_only (ECal *ecal, gboolean *read_only, GError **error);
114 gboolean e_cal_get_cal_address (ECal *ecal, char **cal_address, GError **error);
115 gboolean e_cal_get_alarm_email_address (ECal *ecal, char **alarm_address, GError **error);
116 gboolean e_cal_get_ldap_attribute (ECal *ecal, char **ldap_attribute, GError **error);
117
118 gboolean e_cal_get_one_alarm_only (ECal *ecal);
119 gboolean e_cal_get_organizer_must_attend (ECal *ecal);
120 gboolean e_cal_get_save_schedules (ECal *ecal);
121 gboolean e_cal_get_static_capability (ECal *ecal, const char *cap);
122
123 gboolean e_cal_set_mode (ECal *ecal, CalMode mode);
124
125 gboolean e_cal_get_default_object (ECal *ecal,
126                                    icalcomponent **icalcomp, GError **error);
127
128 gboolean e_cal_get_object (ECal *ecal,
129                            const char *uid,
130                            const char *rid,
131                            icalcomponent **icalcomp,
132                            GError **error);
133
134 gboolean e_cal_get_changes (ECal *ecal, const char *change_id, GList **changes, GError **error);
135 void e_cal_free_change_list (GList *list);
136
137 gboolean e_cal_get_object_list (ECal *ecal, const char *query, GList **objects, GError **error);
138 gboolean e_cal_get_object_list_as_comp (ECal *ecal, const char *query, GList **objects, GError **error);
139 void e_cal_free_object_list (GList *objects);
140
141 gboolean e_cal_get_free_busy (ECal *ecal, GList *users, time_t start, time_t end, 
142                               GList **freebusy, GError **error);
143
144 void e_cal_generate_instances (ECal *ecal, CalObjType type,
145                                time_t start, time_t end,
146                                ECalRecurInstanceFn cb, gpointer cb_data);
147
148 GSList *e_cal_get_alarms_in_range (ECal *ecal, time_t start, time_t end);
149
150 void e_cal_free_alarms (GSList *comp_alarms);
151
152 gboolean e_cal_get_alarms_for_object (ECal *ecal, const char *uid,
153                                       time_t start, time_t end,
154                                       ECalComponentAlarms **alarms);
155
156 gboolean e_cal_create_object (ECal *ecal, icalcomponent *icalcomp, char **uid, GError **error);
157 gboolean e_cal_modify_object (ECal *ecal, icalcomponent *icalcomp, CalObjModType mod, GError **error);
158 gboolean e_cal_remove_object (ECal *ecal, const char *uid, GError **error);
159 gboolean e_cal_remove_object_with_mod (ECal *ecal, const char *uid, const char *rid, CalObjModType mod, GError **error);
160
161 gboolean e_cal_discard_alarm (ECal *ecal, ECalComponent *comp, const char *auid, GError **error);
162
163 gboolean e_cal_receive_objects (ECal *ecal, icalcomponent *icalcomp, GError **error);
164 gboolean e_cal_send_objects (ECal *ecal, icalcomponent *icalcomp, GError **error);
165
166 gboolean e_cal_get_timezone (ECal *ecal, const char *tzid, icaltimezone **zone, GError **error);
167 gboolean e_cal_add_timezone (ECal *ecal, icaltimezone *izone, GError **error);
168 /* Sets the default timezone to use to resolve DATE and floating DATE-TIME
169    values. This will typically be from the user's timezone setting. Call this
170    before using any other functions. It will pass the default timezone on to
171    the server. Returns TRUE on success. */
172 gboolean e_cal_set_default_timezone (ECal *ecal, icaltimezone *zone, GError **error);
173
174 gboolean e_cal_get_query (ECal *ecal, const char *sexp, ECalView **query, GError **error);
175
176 /* Resolves TZIDs for the recurrence generator. */
177 icaltimezone *e_cal_resolve_tzid_cb (const char *tzid, gpointer data);
178
179 /* Returns a complete VCALENDAR for a VEVENT/VTODO including all VTIMEZONEs
180    used by the component. It also includes a 'METHOD:PUBLISH' property. */
181 char* e_cal_get_component_as_string (ECal *ecal, icalcomponent *icalcomp);
182
183 const char * e_cal_get_error_message (ECalendarStatus status);
184
185 G_END_DECLS
186
187 #endif