Adapt libedata-cal to the new ESource API.
[platform/upstream/evolution-data-server.git] / calendar / libedata-cal / e-data-cal.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* Evolution calendar client interface object
3  *
4  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
5  *
6  * Authors: Federico Mena-Quintero <federico@ximian.com>
7  *          Rodrigo Moya <rodrigo@ximian.com>
8  *
9  * This program is free software; you can redistribute it and/or
10  * modify it under the terms of version 2 of the GNU Lesser General Public
11  * License as published by the Free Software Foundation.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22
23 #ifndef E_DATA_CAL_H
24 #define E_DATA_CAL_H
25
26 #include <gio/gio.h>
27 #include <libedata-cal/e-data-cal-common.h>
28 #include <libedata-cal/e-data-cal-view.h>
29 #include <libedata-cal/e-data-cal-types.h>
30
31 G_BEGIN_DECLS
32
33 \f
34
35 #define E_TYPE_DATA_CAL            (e_data_cal_get_type ())
36 #define E_DATA_CAL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), E_TYPE_DATA_CAL, EDataCal))
37 #define E_DATA_CAL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), E_TYPE_DATA_CAL, EDataCalClass))
38 #define E_IS_DATA_CAL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), E_TYPE_DATA_CAL))
39 #define E_IS_DATA_CAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), E_TYPE_DATA_CAL))
40
41 GQuark e_data_cal_error_quark (void);
42
43 /**
44  * E_DATA_CAL_ERROR:
45  *
46  * Since: 2.30
47  **/
48 #define E_DATA_CAL_ERROR e_data_cal_error_quark ()
49
50 /**
51  * e_data_cal_create_error:
52  * @status: #EDataCalStatus code
53  * @custom_msg: Custom message to use for the error. When NULL,
54  *              then uses a default message based on the @status code.
55  *
56  * Returns: NULL, when the @status is Success,
57  *          or a newly allocated GError, which should be freed
58  *          with g_error_free() call.
59  **/
60 GError *e_data_cal_create_error (EDataCalCallStatus status, const gchar *custom_msg);
61
62 /**
63  * e_data_cal_create_error_fmt:
64  *
65  * Similar as e_data_cal_create_error(), only here, instead of custom_msg,
66  * is used a printf() format to create a custom_msg for the error.
67  **/
68 GError *e_data_cal_create_error_fmt (EDataCalCallStatus status, const gchar *custom_msg_fmt, ...) G_GNUC_PRINTF (2, 3);
69
70 const gchar *e_data_cal_status_to_string (EDataCalCallStatus status);
71
72 /**
73  * e_return_data_cal_error_if_fail:
74  *
75  * Since: 2.32
76  **/
77 #define e_return_data_cal_error_if_fail(expr, _code)                            \
78         G_STMT_START {                                                          \
79                 if (G_LIKELY (expr)) {                                          \
80                 } else {                                                        \
81                         g_log (G_LOG_DOMAIN,                                    \
82                                 G_LOG_LEVEL_CRITICAL,                           \
83                                 "file %s: line %d (%s): assertion `%s' failed", \
84                                 __FILE__, __LINE__, G_STRFUNC, #expr);          \
85                         g_set_error (error, E_DATA_CAL_ERROR, (_code),          \
86                                 "file %s: line %d (%s): assertion `%s' failed", \
87                                 __FILE__, __LINE__, G_STRFUNC, #expr);          \
88                         return;                                                 \
89                 }                                                               \
90         } G_STMT_END
91
92 /**
93  * e_return_data_cal_error_val_if_fail:
94  *
95  * Same as e_return_data_cal_error_if_fail(), only returns FALSE on a failure
96  *
97  * Since: 3.2
98  **/
99 #define e_return_data_cal_error_val_if_fail(expr, _code)                        \
100         G_STMT_START {                                                          \
101                 if (G_LIKELY (expr)) {                                          \
102                 } else {                                                        \
103                         g_log (G_LOG_DOMAIN,                                    \
104                                 G_LOG_LEVEL_CRITICAL,                           \
105                                 "file %s: line %d (%s): assertion `%s' failed", \
106                                 __FILE__, __LINE__, G_STRFUNC, #expr);          \
107                         g_set_error (error, E_DATA_CAL_ERROR, (_code),          \
108                                 "file %s: line %d (%s): assertion `%s' failed", \
109                                 __FILE__, __LINE__, G_STRFUNC, #expr);          \
110                         return FALSE;                                           \
111                 }                                                               \
112         } G_STMT_END
113
114 typedef struct _EDataCalPrivate EDataCalPrivate;
115
116 struct _EDataCal {
117         GObject parent;
118         EDataCalPrivate *priv;
119 };
120
121 struct _EDataCalClass {
122         GObjectClass parent_class;
123 };
124
125 GType e_data_cal_get_type (void);
126
127 EDataCal *      e_data_cal_new                                  (ECalBackend *backend);
128 ECalBackend *   e_data_cal_get_backend                          (EDataCal *cal);
129 guint           e_data_cal_register_gdbus_object                (EDataCal *cal, GDBusConnection *connection, const gchar *object_path, GError **error);
130
131 void            e_data_cal_respond_open                         (EDataCal *cal, guint32 opid, GError *error);
132 void            e_data_cal_respond_remove                       (EDataCal *cal, guint32 opid, GError *error);
133 void            e_data_cal_respond_refresh                      (EDataCal *cal, guint32 opid, GError *error);
134 void            e_data_cal_respond_get_backend_property         (EDataCal *cal, guint32 opid, GError *error, const gchar *prop_value);
135 void            e_data_cal_respond_set_backend_property         (EDataCal *cal, guint32 opid, GError *error);
136 void            e_data_cal_respond_get_object                   (EDataCal *cal, guint32 opid, GError *error, const gchar *object);
137 void            e_data_cal_respond_get_object_list              (EDataCal *cal, guint32 opid, GError *error, const GSList *objects);
138 void            e_data_cal_respond_get_free_busy                (EDataCal *cal, guint32 opid, GError *error);
139 void            e_data_cal_respond_create_objects               (EDataCal *cal, guint32 opid, GError *error, const GSList *uids, /*const */ GSList *new_components);
140 void            e_data_cal_respond_modify_objects               (EDataCal *cal, guint32 opid, GError *error, /* const */ GSList *old_components, /* const */ GSList *new_components);
141 void            e_data_cal_respond_remove_objects               (EDataCal *cal, guint32 opid, GError *error, const GSList *ids, /* const */ GSList *old_components, /* const */ GSList *new_components);
142 void            e_data_cal_respond_receive_objects              (EDataCal *cal, guint32 opid, GError *error);
143 void            e_data_cal_respond_send_objects                 (EDataCal *cal, guint32 opid, GError *error, const GSList *users, const gchar *calobj);
144 void            e_data_cal_respond_get_attachment_uris          (EDataCal *cal, guint32 opid, GError *error, const GSList *attachment_uris);
145 void            e_data_cal_respond_discard_alarm                (EDataCal *cal, guint32 opid, GError *error);
146 void            e_data_cal_respond_get_view                     (EDataCal *cal, guint32 opid, GError *error, const gchar *view_path);
147 void            e_data_cal_respond_get_timezone                 (EDataCal *cal, guint32 opid, GError *error, const gchar *tzobject);
148 void            e_data_cal_respond_add_timezone                 (EDataCal *cal, guint32 opid, GError *error);
149
150 void            e_data_cal_report_error                         (EDataCal *cal, const gchar *message);
151 void            e_data_cal_report_readonly                      (EDataCal *cal, gboolean is_readonly);
152 void            e_data_cal_report_online                        (EDataCal *cal, gboolean is_online);
153 void            e_data_cal_report_opened                        (EDataCal *cal, const GError *error);
154 void            e_data_cal_report_free_busy_data                (EDataCal *cal, const GSList *freebusy);
155 void            e_data_cal_report_backend_property_changed      (EDataCal *cal, const gchar *prop_name, const gchar *prop_value);
156
157 G_END_DECLS
158
159 #endif