7782d25bd567eef52283016b2f7505d998d32de1
[platform/upstream/evolution-data-server.git] / addressbook / libebook / e-book.h
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3  * The Evolution addressbook client object.
4  *
5  * Author:
6  *   Chris Toshok (toshok@ximian.com)
7  *
8  * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
9  */
10
11 #if !defined (__LIBEBOOK_H_INSIDE__) && !defined (LIBEBOOK_COMPILATION)
12 #error "Only <libebook/libebook.h> should be included directly."
13 #endif
14
15 #ifndef __E_BOOK_H__
16 #define __E_BOOK_H__
17
18 /* e-book deprecated since 3.2, use e-book-client instead */
19 #ifndef E_BOOK_DISABLE_DEPRECATED
20
21 #include <libedataserver/libedataserver.h>
22
23 #include <libebook/e-contact.h>
24 #include <libebook/e-book-query.h>
25 #include <libebook/e-book-view.h>
26 #include <libebook/e-book-types.h>
27
28 #define E_TYPE_BOOK        (e_book_get_type ())
29 #define E_BOOK(o)          (G_TYPE_CHECK_INSTANCE_CAST ((o), E_TYPE_BOOK, EBook))
30 #define E_BOOK_CLASS(k)    (G_TYPE_CHECK_CLASS_CAST ((k), E_TYPE_BOOK, EBookClass))
31 #define E_IS_BOOK(o)       (G_TYPE_CHECK_INSTANCE_TYPE ((o), E_TYPE_BOOK))
32 #define E_IS_BOOK_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), E_TYPE_BOOK))
33 #define E_BOOK_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), E_TYPE_BOOK, EBookClass))
34
35 G_BEGIN_DECLS
36
37 typedef struct _EBook        EBook;
38 typedef struct _EBookClass   EBookClass;
39 typedef struct _EBookPrivate EBookPrivate;
40
41 #ifndef E_BOOK_DISABLE_DEPRECATED
42 typedef void (*EBookCallback) (EBook *book, EBookStatus status, gpointer closure);
43 #endif
44
45 /**
46  * EBookAsyncCallback:
47  *
48  * Since: 2.32
49  **/
50 typedef void (*EBookAsyncCallback) (EBook *book, const GError *error, gpointer closure);
51
52 /**
53  * EBookOpenProgressCallback:
54  *
55  * Since: 2.32
56  **/
57 typedef void (*EBookOpenProgressCallback)     (EBook          *book,
58                                                const gchar     *status_message,
59                                                gshort           percent,
60                                                gpointer        closure);
61 #ifndef E_BOOK_DISABLE_DEPRECATED
62 typedef void (*EBookIdCallback)       (EBook *book, EBookStatus status, const gchar *id, gpointer closure);
63 typedef void (*EBookContactCallback)  (EBook *book, EBookStatus status, EContact *contact, gpointer closure);
64 typedef void (*EBookListCallback)     (EBook *book, EBookStatus status, GList *list, gpointer closure);
65 typedef void (*EBookBookViewCallback) (EBook *book, EBookStatus status, EBookView *book_view, gpointer closure);
66 typedef void (*EBookEListCallback)   (EBook *book, EBookStatus status, EList *list, gpointer closure);
67 #endif
68
69 /**
70  * EBookIdAsyncCallback:
71  *
72  * Since: 2.32
73  **/
74 typedef void (*EBookIdAsyncCallback)       (EBook *book, const GError *error, const gchar *id, gpointer closure);
75
76 /**
77  * EBookContactAsyncCallback:
78  *
79  * Since: 2.32
80  **/
81 typedef void (*EBookContactAsyncCallback)  (EBook *book, const GError *error, EContact *contact, gpointer closure);
82
83 /**
84  * EBookListAsyncCallback:
85  *
86  * Since: 2.32
87  **/
88 typedef void (*EBookListAsyncCallback)     (EBook *book, const GError *error, GList *list, gpointer closure);
89
90 /**
91  * EBookBookViewAsyncCallback:
92  *
93  * Since: 2.32
94  **/
95 typedef void (*EBookBookViewAsyncCallback) (EBook *book, const GError *error, EBookView *book_view, gpointer closure);
96
97 /**
98  * EBookEListAsyncCallback:
99  *
100  * Since: 2.32
101  **/
102 typedef void (*EBookEListAsyncCallback)   (EBook *book, const GError *error, EList *list, gpointer closure);
103
104 struct _EBook {
105         GObject       parent;
106         /*< private >*/
107         EBookPrivate *priv;
108 };
109
110 struct _EBookClass {
111         GObjectClass parent;
112
113         /*
114          * Signals.
115          */
116         void (* writable_status) (EBook *book, gboolean writable);
117         void (* connection_status) (EBook *book, gboolean connected);
118         void (* backend_died)    (EBook *book);
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 /* Creating a new addressbook. */
129 EBook    *e_book_new                       (ESource *source, GError **error);
130
131 /* loading addressbooks */
132 gboolean e_book_open                       (EBook       *book,
133                                             gboolean     only_if_exists,
134                                             GError     **error);
135
136 #ifndef E_BOOK_DISABLE_DEPRECATED
137 gboolean    e_book_async_open                 (EBook         *book,
138                                             gboolean       only_if_exists,
139                                             EBookCallback  open_response,
140                                             gpointer       closure);
141 #endif
142
143 gboolean e_book_open_async                 (EBook              *book,
144                                             gboolean            only_if_exists,
145                                             EBookAsyncCallback  open_response,
146                                             gpointer            closure);
147
148 gboolean e_book_remove                     (EBook       *book,
149                                             GError     **error);
150 #ifndef E_BOOK_DISABLE_DEPRECATED
151 gboolean    e_book_async_remove               (EBook   *book,
152                                             EBookCallback cb,
153                                             gpointer closure);
154 #endif
155
156 gboolean e_book_remove_async               (EBook             *book,
157                                             EBookAsyncCallback cb,
158                                             gpointer           closure);
159
160 gboolean e_book_get_required_fields       (EBook       *book,
161                                             GList      **fields,
162                                             GError     **error);
163
164 #ifndef E_BOOK_DISABLE_DEPRECATED
165 gboolean e_book_async_get_required_fields (EBook              *book,
166                                             EBookEListCallback  cb,
167                                             gpointer            closure);
168 #endif
169
170 gboolean e_book_get_required_fields_async (EBook                  *book,
171                                            EBookEListAsyncCallback cb,
172                                            gpointer                closure);
173
174 gboolean e_book_get_supported_fields       (EBook       *book,
175                                             GList      **fields,
176                                             GError     **error);
177
178 #ifndef E_BOOK_DISABLE_DEPRECATED
179 gboolean    e_book_async_get_supported_fields (EBook              *book,
180                                             EBookEListCallback  cb,
181                                             gpointer            closure);
182 #endif
183
184 gboolean e_book_get_supported_fields_async (EBook                  *book,
185                                             EBookEListAsyncCallback cb,
186                                             gpointer                closure);
187
188 gboolean e_book_get_supported_auth_methods       (EBook       *book,
189                                                   GList      **auth_methods,
190                                                   GError     **error);
191
192 #ifndef E_BOOK_DISABLE_DEPRECATED
193 gboolean    e_book_async_get_supported_auth_methods (EBook              *book,
194                                                   EBookEListCallback  cb,
195                                                   gpointer            closure);
196 #endif
197
198 gboolean e_book_get_supported_auth_methods_async (EBook                  *book,
199                                                   EBookEListAsyncCallback cb,
200                                                   gpointer                closure);
201
202 /* Fetching contacts. */
203 gboolean e_book_get_contact                (EBook       *book,
204                                             const gchar  *id,
205                                             EContact   **contact,
206                                             GError     **error);
207
208 #ifndef E_BOOK_DISABLE_DEPRECATED
209 gboolean     e_book_async_get_contact         (EBook                 *book,
210                                             const gchar            *id,
211                                             EBookContactCallback   cb,
212                                             gpointer               closure);
213 #endif
214
215 gboolean  e_book_get_contact_async      (EBook                    *book,
216                                          const gchar              *id,
217                                          EBookContactAsyncCallback cb,
218                                          gpointer                  closure);
219
220 /* Deleting contacts. */
221 gboolean e_book_remove_contact             (EBook       *book,
222                                             const gchar  *id,
223                                             GError     **error);
224
225 #ifndef E_BOOK_DISABLE_DEPRECATED
226 gboolean    e_book_async_remove_contact       (EBook                 *book,
227                                             EContact              *contact,
228                                             EBookCallback          cb,
229                                             gpointer               closure);
230 gboolean    e_book_async_remove_contact_by_id (EBook                 *book,
231                                             const gchar           *id,
232                                             EBookCallback          cb,
233                                             gpointer               closure);
234 #endif
235
236 gboolean e_book_remove_contact_async        (EBook                *book,
237                                             EContact              *contact,
238                                             EBookAsyncCallback     cb,
239                                             gpointer               closure);
240 gboolean e_book_remove_contact_by_id_async (EBook                 *book,
241                                             const gchar           *id,
242                                             EBookAsyncCallback     cb,
243                                             gpointer               closure);
244
245 gboolean e_book_remove_contacts            (EBook       *book,
246                                             GList       *ids,
247                                             GError     **error);
248
249 #ifndef E_BOOK_DISABLE_DEPRECATED
250 gboolean    e_book_async_remove_contacts      (EBook                 *book,
251                                             GList                 *ids,
252                                             EBookCallback          cb,
253                                             gpointer               closure);
254 #endif
255
256 gboolean e_book_remove_contacts_async   (EBook                 *book,
257                                          GList                 *ids,
258                                          EBookAsyncCallback     cb,
259                                          gpointer               closure);
260
261 /* Adding contacts. */
262 gboolean e_book_add_contact                (EBook           *book,
263                                             EContact        *contact,
264                                             GError         **error);
265
266 #ifndef E_BOOK_DISABLE_DEPRECATED
267 gboolean e_book_async_add_contact          (EBook           *book,
268                                             EContact        *contact,
269                                             EBookIdCallback  cb,
270                                             gpointer         closure);
271 #endif
272
273 gboolean e_book_add_contact_async       (EBook                 *book,
274                                          EContact              *contact,
275                                          EBookIdAsyncCallback   cb,
276                                          gpointer               closure);
277
278 /* Modifying contacts. */
279 gboolean e_book_commit_contact             (EBook       *book,
280                                             EContact    *contact,
281                                             GError     **error);
282
283 #ifndef E_BOOK_DISABLE_DEPRECATED
284 gboolean e_book_async_commit_contact          (EBook                 *book,
285                                             EContact              *contact,
286                                             EBookCallback          cb,
287                                             gpointer               closure);
288 #endif
289
290 gboolean e_book_commit_contact_async    (EBook                 *book,
291                                          EContact              *contact,
292                                          EBookAsyncCallback     cb,
293                                          gpointer               closure);
294
295 /* Returns a live view of a query. */
296 gboolean e_book_get_book_view              (EBook       *book,
297                                             EBookQuery  *query,
298                                             GList       *requested_fields,
299                                             gint          max_results,
300                                             EBookView  **book_view,
301                                             GError     **error);
302
303 #ifndef E_BOOK_DISABLE_DEPRECATED
304 gboolean e_book_async_get_book_view           (EBook                 *book,
305                                             EBookQuery            *query,
306                                             GList                 *requested_fields,
307                                             gint                    max_results,
308                                             EBookBookViewCallback  cb,
309                                             gpointer               closure);
310 #endif
311
312 gboolean e_book_get_book_view_async     (EBook                     *book,
313                                          EBookQuery                *query,
314                                          GList                     *requested_fields,
315                                          gint                       max_results,
316                                          EBookBookViewAsyncCallback cb,
317                                          gpointer                   closure);
318
319 /* Returns a static snapshot of a query. */
320 gboolean e_book_get_contacts               (EBook       *book,
321                                             EBookQuery  *query,
322                                             GList      **contacts,
323                                             GError     **error);
324
325 #ifndef E_BOOK_DISABLE_DEPRECATED
326 gboolean     e_book_async_get_contacts        (EBook             *book,
327                                             EBookQuery        *query,
328                                             EBookListCallback  cb,
329                                             gpointer           closure);
330 #endif
331
332 gboolean  e_book_get_contacts_async     (EBook                 *book,
333                                          EBookQuery            *query,
334                                          EBookListAsyncCallback cb,
335                                          gpointer               closure);
336
337 /* Needed for syncing */
338 gboolean e_book_get_changes                (EBook       *book,
339                                             const gchar *changeid,
340                                             GList      **changes,
341                                             GError     **error);
342
343 #ifndef E_BOOK_DISABLE_DEPRECATED
344 gboolean    e_book_async_get_changes          (EBook             *book,
345                                             const gchar       *changeid,
346                                             EBookListCallback  cb,
347                                             gpointer           closure);
348 #endif
349
350 gboolean e_book_get_changes_async       (EBook                 *book,
351                                          const gchar           *changeid,
352                                          EBookListAsyncCallback cb,
353                                          gpointer               closure);
354
355 void     e_book_free_change_list           (GList       *change_list);
356
357 ESource    *e_book_get_source              (EBook       *book);
358
359 const gchar *e_book_get_static_capabilities (EBook    *book,
360                                             GError  **error);
361 gboolean    e_book_check_static_capability (EBook       *book,
362                                             const gchar  *cap);
363 gboolean    e_book_is_opened               (EBook       *book);
364 gboolean    e_book_is_writable             (EBook       *book);
365
366 gboolean    e_book_is_online               (EBook       *book);
367
368 /* Cancel a pending operation. */
369 gboolean    e_book_cancel                  (EBook   *book,
370                                             GError **error);
371
372 gboolean    e_book_cancel_async_op         (EBook   *book,
373                                             GError **error);
374
375 /* Identity */
376 gboolean    e_book_get_self                (ESourceRegistry *registry, EContact **contact, EBook **book, GError **error);
377 gboolean    e_book_set_self                (EBook *book, EContact *contact, GError **error);
378 gboolean    e_book_is_self                 (EContact *contact);
379
380 GType        e_book_get_type                  (void);
381
382 G_END_DECLS
383
384 #endif /* E_BOOK_DISABLE_DEPRECATED */
385
386 #endif /* __E_BOOK_H__ */