1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /* Evolution calendar - generic backend class
4 * Copyright (C) 2000 Ximian, Inc.
5 * Copyright (C) 2000 Ximian, Inc.
7 * Authors: Federico Mena-Quintero <federico@ximian.com>
8 * JP Rosevear <jpr@ximian.com>
9 * Rodrigo Moya <rodrigo@ximian.com>
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of version 2 of the GNU General Public
13 * License as published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
26 #include <libxml/parser.h>
27 #include <libxml/parserInternals.h>
28 #include <libxml/xmlmemory.h>
30 #include "e-cal-backend.h"
34 /* Private part of the CalBackend structure */
35 struct _ECalBackendPrivate {
36 /* The source for this backend */
39 /* URI, from source. This is cached, since we return const. */
42 /* The kind of components for this backend */
43 icalcomponent_kind kind;
45 /* List of Cal objects */
46 GMutex *clients_mutex;
49 GMutex *queries_mutex;
52 /* ECalBackend to pass notifications on to */
53 ECalBackend *notification_proxy;
71 static guint e_cal_backend_signals[LAST_SIGNAL];
73 static void e_cal_backend_class_init (ECalBackendClass *class);
74 static void e_cal_backend_init (ECalBackend *backend);
75 static void e_cal_backend_finalize (GObject *object);
77 #define CLASS(backend) (E_CAL_BACKEND_CLASS (G_OBJECT_GET_CLASS (backend)))
79 static GObjectClass *parent_class;
84 * e_cal_backend_get_type:
86 * Registers the #ECalBackend class if necessary, and returns the type ID
89 * Return value: The type ID of the #ECalBackend class.
92 e_cal_backend_get_type (void)
94 static GType e_cal_backend_type = 0;
96 if (!e_cal_backend_type) {
97 static GTypeInfo info = {
98 sizeof (ECalBackendClass),
100 (GBaseFinalizeFunc) NULL,
101 (GClassInitFunc) e_cal_backend_class_init,
103 sizeof (ECalBackend),
105 (GInstanceInitFunc) e_cal_backend_init,
107 e_cal_backend_type = g_type_register_static (G_TYPE_OBJECT, "ECalBackend", &info, 0);
110 return e_cal_backend_type;
114 e_cal_backend_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
116 ECalBackend *backend;
117 ECalBackendPrivate *priv;
119 backend = E_CAL_BACKEND (object);
120 priv = backend->priv;
122 switch (property_id) {
127 new_source = g_value_get_object (value);
129 g_object_ref (new_source);
132 g_object_unref (priv->source);
134 priv->source = new_source;
139 priv->uri = e_source_get_uri (priv->source);
146 priv->uri = g_value_dup_string (value);
150 priv->kind = g_value_get_ulong (value);
153 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
159 e_cal_backend_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
161 ECalBackend *backend;
162 ECalBackendPrivate *priv;
164 backend = E_CAL_BACKEND (object);
165 priv = backend->priv;
167 switch (property_id) {
169 g_value_set_object (value, e_cal_backend_get_source (backend));
172 g_value_set_string (value, e_cal_backend_get_uri (backend));
175 g_value_set_ulong (value, e_cal_backend_get_kind (backend));
178 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
183 /* Class initialization function for the calendar backend */
185 e_cal_backend_class_init (ECalBackendClass *class)
187 GObjectClass *object_class;
189 parent_class = (GObjectClass *) g_type_class_peek_parent (class);
191 object_class = (GObjectClass *) class;
193 object_class->set_property = e_cal_backend_set_property;
194 object_class->get_property = e_cal_backend_get_property;
195 object_class->finalize = e_cal_backend_finalize;
197 g_object_class_install_property (object_class, PROP_SOURCE,
198 g_param_spec_object ("source", NULL, NULL, E_TYPE_SOURCE,
199 G_PARAM_READABLE | G_PARAM_WRITABLE
200 | G_PARAM_CONSTRUCT_ONLY));
202 g_object_class_install_property (object_class, PROP_URI,
203 g_param_spec_string ("uri", NULL, NULL, "",
204 G_PARAM_READABLE | G_PARAM_WRITABLE
205 | G_PARAM_CONSTRUCT_ONLY));
207 g_object_class_install_property (object_class, PROP_KIND,
208 g_param_spec_ulong ("kind", NULL, NULL,
209 ICAL_NO_COMPONENT, ICAL_XLICMIMEPART_COMPONENT,
211 G_PARAM_READABLE | G_PARAM_WRITABLE
212 | G_PARAM_CONSTRUCT_ONLY));
213 e_cal_backend_signals[LAST_CLIENT_GONE] =
214 g_signal_new ("last_client_gone",
215 G_TYPE_FROM_CLASS (class),
217 G_STRUCT_OFFSET (ECalBackendClass, last_client_gone),
219 g_cclosure_marshal_VOID__VOID,
221 e_cal_backend_signals[OPENED] =
222 g_signal_new ("opened",
223 G_TYPE_FROM_CLASS (class),
225 G_STRUCT_OFFSET (ECalBackendClass, opened),
227 g_cclosure_marshal_VOID__ENUM,
230 e_cal_backend_signals[REMOVED] =
231 g_signal_new ("removed",
232 G_TYPE_FROM_CLASS (class),
234 G_STRUCT_OFFSET (ECalBackendClass, removed),
236 g_cclosure_marshal_VOID__ENUM,
240 class->last_client_gone = NULL;
241 class->opened = NULL;
242 class->obj_updated = NULL;
244 class->get_cal_address = NULL;
245 class->get_alarm_email_address = NULL;
246 class->get_static_capabilities = NULL;
248 class->is_loaded = NULL;
249 class->is_read_only = NULL;
250 class->start_query = NULL;
251 class->get_mode = NULL;
252 class->set_mode = NULL;
253 class->get_object = NULL;
254 class->get_default_object = NULL;
255 class->get_object_list = NULL;
256 class->get_free_busy = NULL;
257 class->get_changes = NULL;
258 class->discard_alarm = NULL;
259 class->create_object = NULL;
260 class->modify_object = NULL;
261 class->remove_object = NULL;
262 class->receive_objects = NULL;
263 class->send_objects = NULL;
264 class->get_timezone = NULL;
265 class->add_timezone = NULL;
266 class->set_default_timezone = NULL;
269 /* Object initialization func for the calendar backend */
271 e_cal_backend_init (ECalBackend *backend)
273 ECalBackendPrivate *priv;
275 priv = g_new0 (ECalBackendPrivate, 1);
276 backend->priv = priv;
278 priv->clients = NULL;
279 priv->clients_mutex = g_mutex_new ();
281 /* FIXME bonobo_object_ref/unref? */
282 priv->queries = e_list_new((EListCopyFunc) g_object_ref, (EListFreeFunc) g_object_unref, NULL);
283 priv->queries_mutex = g_mutex_new ();
287 e_cal_backend_finalize (GObject *object)
289 ECalBackend *backend = (ECalBackend *)object;
290 ECalBackendPrivate *priv;
292 priv = backend->priv;
294 g_assert (priv->clients == NULL);
296 g_object_unref (priv->queries);
298 g_mutex_free (priv->clients_mutex);
299 g_mutex_free (priv->queries_mutex);
303 G_OBJECT_CLASS (parent_class)->finalize (object);
309 * e_cal_backend_get_source:
310 * @backend: An #ECalBackend object.
312 * Gets the #ESource associated with the given backend.
314 * Return value: The #ESource for the backend.
317 e_cal_backend_get_source (ECalBackend *backend)
319 ECalBackendPrivate *priv;
321 g_return_val_if_fail (backend != NULL, NULL);
322 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
324 priv = backend->priv;
330 * e_cal_backend_get_uri:
331 * @backend: A calendar backend.
333 * Queries the URI of a calendar backend, which must already have an open
336 * Return value: The URI where the calendar is stored.
339 e_cal_backend_get_uri (ECalBackend *backend)
341 ECalBackendPrivate *priv;
343 g_return_val_if_fail (backend != NULL, NULL);
344 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
346 priv = backend->priv;
352 * e_cal_backend_get_kind:
353 * @backend: An #ECalBackend object.
355 * Gets the kind of components the given backend stores.
357 * Return value: The kind of components for this backend.
360 e_cal_backend_get_kind (ECalBackend *backend)
362 ECalBackendPrivate *priv;
364 g_return_val_if_fail (backend != NULL, ICAL_NO_COMPONENT);
365 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), ICAL_NO_COMPONENT);
367 priv = backend->priv;
373 cal_destroy_cb (gpointer data, GObject *where_cal_was)
375 ECalBackend *backend = E_CAL_BACKEND (data);
377 e_cal_backend_remove_client (backend, (EDataCal *) where_cal_was);
381 listener_died_cb (gpointer cnx, gpointer data)
383 EDataCal *cal = E_DATA_CAL (data);
385 e_cal_backend_remove_client (e_data_cal_get_backend (cal), cal);
389 last_client_gone (ECalBackend *backend)
391 g_signal_emit (backend, e_cal_backend_signals[LAST_CLIENT_GONE], 0);
395 * e_cal_backend_add_client:
396 * @backend: An ECalBackend object.
397 * @cal: An EDataCal object.
399 * Adds a new client to the given backend. For any event, the backend will
400 * notify all clients added via this function.
403 e_cal_backend_add_client (ECalBackend *backend, EDataCal *cal)
405 ECalBackendPrivate *priv;
407 g_return_if_fail (backend != NULL);
408 g_return_if_fail (E_IS_CAL_BACKEND (backend));
409 g_return_if_fail (cal != NULL);
410 g_return_if_fail (E_IS_DATA_CAL (cal));
412 priv = backend->priv;
414 bonobo_object_set_immortal (BONOBO_OBJECT (cal), TRUE);
416 g_object_weak_ref (G_OBJECT (cal), cal_destroy_cb, backend);
418 ORBit_small_listen_for_broken (e_data_cal_get_listener (cal), G_CALLBACK (listener_died_cb), cal);
420 g_mutex_lock (priv->clients_mutex);
421 priv->clients = g_list_append (priv->clients, cal);
422 g_mutex_unlock (priv->clients_mutex);
426 * e_cal_backend_remove_client:
427 * @backend: An #ECalBackend object.
428 * @cal: An #EDataCal object.
430 * Removes a client from the list of connected clients to the given backend.
433 e_cal_backend_remove_client (ECalBackend *backend, EDataCal *cal)
435 ECalBackendPrivate *priv;
437 /* XXX this needs a bit more thinking wrt the mutex - we
438 should be holding it when we check to see if clients is
440 g_return_if_fail (backend != NULL);
441 g_return_if_fail (E_IS_CAL_BACKEND (backend));
442 g_return_if_fail (cal != NULL);
443 g_return_if_fail (E_IS_DATA_CAL (cal));
445 priv = backend->priv;
448 g_mutex_lock (priv->clients_mutex);
449 priv->clients = g_list_remove (priv->clients, cal);
450 g_mutex_unlock (priv->clients_mutex);
452 /* When all clients go away, notify the parent factory about it so that
453 * it may decide whether to kill the backend or not.
456 last_client_gone (backend);
460 * e_cal_backend_add_query:
461 * @backend: An #ECalBackend object.
462 * @query: An #EDataCalView object.
464 * Adds a query to the list of live queries being run by the given backend.
465 * Doing so means that any listener on the query will get notified of any
466 * change that affect the live query.
469 e_cal_backend_add_query (ECalBackend *backend, EDataCalView *query)
471 g_return_if_fail (backend != NULL);
472 g_return_if_fail (E_IS_CAL_BACKEND (backend));
474 g_mutex_lock (backend->priv->queries_mutex);
476 e_list_append (backend->priv->queries, query);
478 g_mutex_unlock (backend->priv->queries_mutex);
482 * e_cal_backend_get_queries:
483 * @backend: An #ECalBackend object.
485 * Gets the list of live queries being run on the given backend.
487 * Return value: The list of live queries.
490 e_cal_backend_get_queries (ECalBackend *backend)
492 g_return_val_if_fail (backend != NULL, NULL);
493 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
495 return backend->priv->queries;
500 * e_cal_backend_get_cal_address:
501 * @backend: A calendar backend.
503 * Queries the cal address associated with a calendar backend, which
504 * must already have an open calendar.
507 e_cal_backend_get_cal_address (ECalBackend *backend, EDataCal *cal)
509 g_return_if_fail (backend != NULL);
510 g_return_if_fail (E_IS_CAL_BACKEND (backend));
512 g_assert (CLASS (backend)->get_cal_address != NULL);
513 (* CLASS (backend)->get_cal_address) (backend, cal);
517 * e_cal_backend_get_alarm_email_address:
518 * @backend: An #ECalBackend object.
519 * @cal: An #EDataCal object.
521 * Calls the get_alarm_email_address method on the given backend.
524 e_cal_backend_get_alarm_email_address (ECalBackend *backend, EDataCal *cal)
526 g_return_if_fail (backend != NULL);
527 g_return_if_fail (E_IS_CAL_BACKEND (backend));
529 g_assert (CLASS (backend)->get_alarm_email_address != NULL);
530 (* CLASS (backend)->get_alarm_email_address) (backend, cal);
534 *e_cal_backend_get_alarm_email_address:
535 * @backend: An #ECalBackend object.
536 * @cal: An #EDataCal object.
538 * Calls the get_ldap_attribute method of the given backend.
541 e_cal_backend_get_ldap_attribute (ECalBackend *backend, EDataCal *cal)
543 g_return_if_fail (backend != NULL);
544 g_return_if_fail (E_IS_CAL_BACKEND (backend));
546 g_assert (CLASS (backend)->get_ldap_attribute != NULL);
547 (* CLASS (backend)->get_ldap_attribute) (backend, cal);
551 * e_cal_backend_get_alarm_email_address:
552 * @backend: An #ECalBackend object.
553 * @cal: An #EDataCal object.
555 * Calls the get_static_capabilities method on the given backend.
558 e_cal_backend_get_static_capabilities (ECalBackend *backend, EDataCal *cal)
560 g_return_if_fail (backend != NULL);
561 g_return_if_fail (E_IS_CAL_BACKEND (backend));
563 g_assert (CLASS (backend)->get_static_capabilities != NULL);
564 (* CLASS (backend)->get_static_capabilities) (backend, cal);
568 * e_cal_backend_open:
569 * @backend: A calendar backend.
570 * @cal: An #EDataCal object.
571 * @only_if_exists: Whether the calendar should be opened only if it already
572 * exists. If FALSE, a new calendar will be created when the specified @uri
574 * @username: User name to use for authentication (if needed).
575 * @password: Password for @username.
577 * Opens a calendar backend with data from a calendar stored at the specified
581 e_cal_backend_open (ECalBackend *backend, EDataCal *cal, gboolean only_if_exists,
582 const char *username, const char *password)
584 g_return_if_fail (backend != NULL);
585 g_return_if_fail (E_IS_CAL_BACKEND (backend));
587 g_assert (CLASS (backend)->open != NULL);
588 (* CLASS (backend)->open) (backend, cal, only_if_exists, username, password);
592 * e_cal_backend_remove:
593 * @backend: A calendar backend.
594 * @cal: An #EDataCal object.
596 * Removes the calendar being accessed by the given backend.
599 e_cal_backend_remove (ECalBackend *backend, EDataCal *cal)
601 g_return_if_fail (backend != NULL);
602 g_return_if_fail (E_IS_CAL_BACKEND (backend));
604 g_assert (CLASS (backend)->remove != NULL);
605 (* CLASS (backend)->remove) (backend, cal);
609 * e_cal_backend_is_loaded:
610 * @backend: A calendar backend.
612 * Queries whether a calendar backend has been loaded yet.
614 * Return value: TRUE if the backend has been loaded with data, FALSE
618 e_cal_backend_is_loaded (ECalBackend *backend)
622 g_return_val_if_fail (backend != NULL, FALSE);
623 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
625 g_assert (CLASS (backend)->is_loaded != NULL);
626 result = (* CLASS (backend)->is_loaded) (backend);
632 * e_cal_backend_is_read_only
633 * @backend: A calendar backend.
634 * @cal: An #EDataCal object.
636 * Queries whether a calendar backend is read only or not.
640 e_cal_backend_is_read_only (ECalBackend *backend, EDataCal *cal)
642 g_return_if_fail (backend != NULL);
643 g_return_if_fail (E_IS_CAL_BACKEND (backend));
645 g_assert (CLASS (backend)->is_read_only != NULL);
646 (* CLASS (backend)->is_read_only) (backend, cal);
650 * e_cal_backend_start_query:
651 * @backend: A calendar backend.
652 * @query: The query to be started.
654 * Starts a new live query on the given backend.
657 e_cal_backend_start_query (ECalBackend *backend, EDataCalView *query)
659 g_return_if_fail (backend != NULL);
660 g_return_if_fail (E_IS_CAL_BACKEND (backend));
662 g_assert (CLASS (backend)->start_query != NULL);
663 (* CLASS (backend)->start_query) (backend, query);
667 * e_cal_backend_get_mode:
668 * @backend: A calendar backend.
670 * Queries whether a calendar backend is connected remotely.
672 * Return value: The current mode the calendar is in
675 e_cal_backend_get_mode (ECalBackend *backend)
679 g_return_val_if_fail (backend != NULL, FALSE);
680 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), FALSE);
682 g_assert (CLASS (backend)->get_mode != NULL);
683 result = (* CLASS (backend)->get_mode) (backend);
690 * e_cal_backend_set_mode:
691 * @backend: A calendar backend
692 * @mode: Mode to change to
694 * Sets the mode of the calendar
697 e_cal_backend_set_mode (ECalBackend *backend, CalMode mode)
699 g_return_if_fail (backend != NULL);
700 g_return_if_fail (E_IS_CAL_BACKEND (backend));
702 g_assert (CLASS (backend)->set_mode != NULL);
703 (* CLASS (backend)->set_mode) (backend, mode);
707 * e_cal_backend_get_default_object:
708 * @backend: A calendar backend.
709 * @cal: An #EDataCal object.
711 * Calls the get_default_object method on the given backend.
714 e_cal_backend_get_default_object (ECalBackend *backend, EDataCal *cal)
716 g_return_if_fail (backend != NULL);
717 g_return_if_fail (E_IS_CAL_BACKEND (backend));
719 g_assert (CLASS (backend)->get_default_object != NULL);
720 (* CLASS (backend)->get_default_object) (backend, cal);
724 * e_cal_backend_get_object:
725 * @backend: A calendar backend.
726 * @cal: An #EDataCal object.
727 * @uid: Unique identifier for a calendar object.
728 * @rid: ID for the object's recurrence to get.
730 * Queries a calendar backend for a calendar object based on its unique
731 * identifier and its recurrence ID (if a recurrent appointment).
734 e_cal_backend_get_object (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid)
736 g_return_if_fail (backend != NULL);
737 g_return_if_fail (E_IS_CAL_BACKEND (backend));
738 g_return_if_fail (uid != NULL);
740 g_assert (CLASS (backend)->get_object != NULL);
741 (* CLASS (backend)->get_object) (backend, cal, uid, rid);
745 * e_cal_backend_get_object_list:
746 * @backend: A calendar backend.
747 * @cal: An #EDataCal object.
748 * @sexp: Expression to search for.
750 * Calls the get_object_list method on the given backend.
753 e_cal_backend_get_object_list (ECalBackend *backend, EDataCal *cal, const char *sexp)
755 g_return_if_fail (backend != NULL);
756 g_return_if_fail (E_IS_CAL_BACKEND (backend));
758 g_assert (CLASS (backend)->get_object_list != NULL);
759 (* CLASS (backend)->get_object_list) (backend, cal, sexp);
763 * e_cal_backend_get_free_busy:
764 * @backend: A calendar backend.
765 * @cal: An #EDataCal object.
766 * @users: List of users to get free/busy information for.
767 * @start: Start time for query.
768 * @end: End time for query.
770 * Gets a free/busy object for the given time interval
773 e_cal_backend_get_free_busy (ECalBackend *backend, EDataCal *cal, GList *users, time_t start, time_t end)
775 g_return_if_fail (backend != NULL);
776 g_return_if_fail (E_IS_CAL_BACKEND (backend));
777 g_return_if_fail (start != -1 && end != -1);
778 g_return_if_fail (start <= end);
780 g_assert (CLASS (backend)->get_free_busy != NULL);
781 (* CLASS (backend)->get_free_busy) (backend, cal, users, start, end);
785 * e_cal_backend_get_changes:
786 * @backend: A calendar backend.
787 * @cal: An #EDataCal object.
788 * @change_id: A unique uid for the callers change list
790 * Builds a sequence of objects and the type of change that occurred on them since
791 * the last time the give change_id was seen
794 e_cal_backend_get_changes (ECalBackend *backend, EDataCal *cal, const char *change_id)
796 g_return_if_fail (backend != NULL);
797 g_return_if_fail (E_IS_CAL_BACKEND (backend));
798 g_return_if_fail (change_id != NULL);
800 g_assert (CLASS (backend)->get_changes != NULL);
801 (* CLASS (backend)->get_changes) (backend, cal, change_id);
805 * e_cal_backend_discard_alarm
806 * @backend: A calendar backend.
807 * @cal: An #EDataCal object.
808 * @uid: UID of the component to discard the alarm from.
811 * Discards an alarm from the given component. This allows the specific backend
812 * to do whatever is needed to really discard the alarm.
815 e_cal_backend_discard_alarm (ECalBackend *backend, EDataCal *cal, const char *uid, const char *auid)
817 g_return_if_fail (backend != NULL);
818 g_return_if_fail (E_IS_CAL_BACKEND (backend));
819 g_return_if_fail (uid != NULL);
820 g_return_if_fail (auid != NULL);
822 g_assert (CLASS (backend)->discard_alarm != NULL);
823 (* CLASS (backend)->discard_alarm) (backend, cal, uid, auid);
827 * e_cal_backend_create_object:
828 * @backend: A calendar backend.
829 * @cal: An #EDataCal object.
830 * @calobj: The object to create.
832 * Calls the create_object method on the given backend.
835 e_cal_backend_create_object (ECalBackend *backend, EDataCal *cal, const char *calobj)
837 g_return_if_fail (backend != NULL);
838 g_return_if_fail (E_IS_CAL_BACKEND (backend));
839 g_return_if_fail (calobj != NULL);
841 if (CLASS (backend)->create_object)
842 (* CLASS (backend)->create_object) (backend, cal, calobj);
844 e_data_cal_notify_object_created (cal, GNOME_Evolution_Calendar_PermissionDenied, NULL, NULL);
848 * e_cal_backend_modify_object:
849 * @backend: A calendar backend.
850 * @cal: An #EDataCal object.
851 * @calobj: Object to be modified.
852 * @mod: Type of modification.
854 * Calls the modify_object method on the given backend.
857 e_cal_backend_modify_object (ECalBackend *backend, EDataCal *cal, const char *calobj, CalObjModType mod)
859 g_return_if_fail (backend != NULL);
860 g_return_if_fail (E_IS_CAL_BACKEND (backend));
861 g_return_if_fail (calobj != NULL);
863 if (CLASS (backend)->modify_object)
864 (* CLASS (backend)->modify_object) (backend, cal, calobj, mod);
866 e_data_cal_notify_object_removed (cal, GNOME_Evolution_Calendar_PermissionDenied, NULL, NULL, NULL);
870 * e_cal_backend_remove_object:
871 * @backend: A calendar backend.
872 * @cal: An #EDataCal object.
873 * @uid: Unique identifier of the object to remove.
874 * @rid: A recurrence ID.
875 * @mod: Type of removal.
877 * Removes an object in a calendar backend. The backend will notify all of its
878 * clients about the change.
881 e_cal_backend_remove_object (ECalBackend *backend, EDataCal *cal, const char *uid, const char *rid, CalObjModType mod)
883 g_return_if_fail (backend != NULL);
884 g_return_if_fail (E_IS_CAL_BACKEND (backend));
885 g_return_if_fail (uid != NULL);
887 g_assert (CLASS (backend)->remove_object != NULL);
888 (* CLASS (backend)->remove_object) (backend, cal, uid, rid, mod);
892 * e_cal_backend_receive_objects:
893 * @backend: A calendar backend.
894 * @cal: An #EDataCal object.
895 * @calobj: iCalendar object.
897 * Calls the receive_objects method on the given backend.
900 e_cal_backend_receive_objects (ECalBackend *backend, EDataCal *cal, const char *calobj)
902 g_return_if_fail (backend != NULL);
903 g_return_if_fail (E_IS_CAL_BACKEND (backend));
904 g_return_if_fail (calobj != NULL);
906 g_assert (CLASS (backend)->receive_objects != NULL);
907 (* CLASS (backend)->receive_objects) (backend, cal, calobj);
911 * e_cal_backend_send_objects:
912 * @backend: A calendar backend.
913 * @cal: An #EDataCal object.
914 * @calobj: iCalendar object to be sent.
916 * Calls the send_objects method on the given backend.
919 e_cal_backend_send_objects (ECalBackend *backend, EDataCal *cal, const char *calobj)
921 g_return_if_fail (backend != NULL);
922 g_return_if_fail (E_IS_CAL_BACKEND (backend));
923 g_return_if_fail (calobj != NULL);
925 g_assert (CLASS (backend)->send_objects != NULL);
926 (* CLASS (backend)->send_objects) (backend, cal, calobj);
930 * e_cal_backend_get_timezone:
931 * @backend: A calendar backend.
932 * @cal: An #EDataCal object.
933 * @tzid: Unique identifier of a VTIMEZONE object. Note that this must not be
936 * Returns the icaltimezone* corresponding to the TZID, or NULL if the TZID
940 e_cal_backend_get_timezone (ECalBackend *backend, EDataCal *cal, const char *tzid)
942 g_return_if_fail (backend != NULL);
943 g_return_if_fail (E_IS_CAL_BACKEND (backend));
944 g_return_if_fail (tzid != NULL);
946 g_assert (CLASS (backend)->get_timezone != NULL);
947 (* CLASS (backend)->get_timezone) (backend, cal, tzid);
951 * e_cal_backend_set_default_timezone:
952 * @backend: A calendar backend.
953 * @cal: An #EDataCal object.
954 * @tzid: The TZID identifying the timezone.
956 * Sets the default timezone for the calendar, which is used to resolve
957 * DATE and floating DATE-TIME values.
960 e_cal_backend_set_default_timezone (ECalBackend *backend, EDataCal *cal, const char *tzid)
962 g_return_if_fail (backend != NULL);
963 g_return_if_fail (E_IS_CAL_BACKEND (backend));
964 g_return_if_fail (tzid != NULL);
966 g_assert (CLASS (backend)->set_default_timezone != NULL);
967 (* CLASS (backend)->set_default_timezone) (backend, cal, tzid);
971 * e_cal_backend_add_timezone
972 * @backend: A calendar backend.
973 * @cal: An #EDataCal object.
974 * @tzobj: The timezone object, in a string.
976 * Add a timezone object to the given backend.
979 e_cal_backend_add_timezone (ECalBackend *backend, EDataCal *cal, const char *tzobj)
981 g_return_if_fail (E_IS_CAL_BACKEND (backend));
982 g_return_if_fail (tzobj != NULL);
983 g_return_if_fail (CLASS (backend)->add_timezone != NULL);
985 (* CLASS (backend)->add_timezone) (backend, cal, tzobj);
989 * e_cal_backend_internal_get_default_timezone:
990 * @backend: A calendar backend.
992 * Calls the internal_get_default_timezone method on the given backend.
995 e_cal_backend_internal_get_default_timezone (ECalBackend *backend)
997 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
998 g_return_val_if_fail (CLASS (backend)->internal_get_default_timezone != NULL, NULL);
1000 return (* CLASS (backend)->internal_get_default_timezone) (backend);
1004 * e_cal_backend_internal_get_timezone:
1005 * @backend: A calendar backend.
1006 * @tzid: ID of the timezone to get.
1008 * Calls the internal_get_timezone method on the given backend.
1011 e_cal_backend_internal_get_timezone (ECalBackend *backend, const char *tzid)
1013 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
1014 g_return_val_if_fail (tzid != NULL, NULL);
1015 g_return_val_if_fail (CLASS (backend)->internal_get_timezone != NULL, NULL);
1017 return (* CLASS (backend)->internal_get_timezone) (backend, tzid);
1021 * e_cal_backend_set_notification_proxy:
1022 * @backend: A calendar backend.
1023 * @proxy: The calendar backend to act as notification proxy.
1025 * Sets the backend that will act as notification proxy for the given backend.
1028 e_cal_backend_set_notification_proxy (ECalBackend *backend, ECalBackend *proxy)
1030 ECalBackendPrivate *priv;
1032 g_return_if_fail (E_IS_CAL_BACKEND (backend));
1034 priv = backend->priv;
1036 priv->notification_proxy = proxy;
1040 * e_cal_backend_notify_object_created:
1041 * @backend: A calendar backend.
1042 * @calobj: iCalendar representation of new object
1044 * Notifies each of the backend's listeners about a new object.
1046 * #e_data_cal_notify_object_created() calls this for you. You only need to
1047 * call e_cal_backend_notify_object_created() yourself to report objects
1048 * created by non-EDS clients.
1051 e_cal_backend_notify_object_created (ECalBackend *backend, const char *calobj)
1053 ECalBackendPrivate *priv;
1056 EDataCalView *query;
1058 priv = backend->priv;
1060 if (priv->notification_proxy) {
1061 e_cal_backend_notify_object_created (priv->notification_proxy, calobj);
1065 queries = e_cal_backend_get_queries (backend);
1066 iter = e_list_get_iterator (queries);
1068 while (e_iterator_is_valid (iter)) {
1069 query = QUERY (e_iterator_get (iter));
1071 bonobo_object_ref (query);
1072 if (e_data_cal_view_object_matches (query, calobj))
1073 e_data_cal_view_notify_objects_added_1 (query, calobj);
1074 bonobo_object_unref (query);
1076 e_iterator_next (iter);
1078 g_object_unref (iter);
1082 match_query_and_notify (EDataCalView *query, const char *old_object, const char *object)
1084 gboolean old_match, new_match;
1086 old_match = e_data_cal_view_object_matches (query, old_object);
1087 new_match = e_data_cal_view_object_matches (query, object);
1088 if (old_match && new_match)
1089 e_data_cal_view_notify_objects_modified_1 (query, object);
1091 e_data_cal_view_notify_objects_added_1 (query, object);
1092 else if (old_match) {
1093 icalcomponent *icalcomp;
1095 icalcomp = icalcomponent_new_from_string ((char *) old_object);
1097 e_data_cal_view_notify_objects_removed_1 (query, icalcomponent_get_uid (icalcomp));
1098 icalcomponent_free (icalcomp);
1104 * e_cal_backend_notify_view_progress:
1105 * @backend: A calendar backend.
1106 * @message: the UID of the removed object
1107 * @percent: percentage of the objects loaded in the view
1109 * Notifies each of the backend's listeners about the view_progress in downloading the items.
1112 e_cal_backend_notify_view_progress (ECalBackend *backend, const char *message, int percent)
1114 ECalBackendPrivate *priv;
1117 EDataCalView *query;
1119 priv = backend->priv;
1121 if (priv->notification_proxy) {
1122 e_cal_backend_notify_view_progress (priv->notification_proxy, message, percent);
1126 queries = e_cal_backend_get_queries (backend);
1127 iter = e_list_get_iterator (queries);
1129 while (e_iterator_is_valid (iter)) {
1130 query = QUERY (e_iterator_get (iter));
1132 bonobo_object_ref (query);
1134 e_data_cal_view_notify_progress (query, message, percent);
1136 bonobo_object_unref (query);
1138 e_iterator_next (iter);
1140 g_object_unref (iter);
1144 * e_cal_backend_notify_view_done:
1145 * @backend: A calendar backend.
1146 * @status: returns the status once the view is fully populated.
1148 * Notifies each of the backend's listeners about the view_done in downloading the items.
1151 e_cal_backend_notify_view_done (ECalBackend *backend, GNOME_Evolution_Calendar_CallStatus status)
1153 ECalBackendPrivate *priv;
1156 EDataCalView *query;
1158 priv = backend->priv;
1160 if (priv->notification_proxy) {
1161 e_cal_backend_notify_view_done (priv->notification_proxy, status);
1165 queries = e_cal_backend_get_queries (backend);
1166 iter = e_list_get_iterator (queries);
1168 while (e_iterator_is_valid (iter)) {
1169 query = QUERY (e_iterator_get (iter));
1171 bonobo_object_ref (query);
1173 e_data_cal_view_notify_done (query, status);
1175 bonobo_object_unref (query);
1177 e_iterator_next (iter);
1179 g_object_unref (iter);
1183 * e_cal_backend_notify_object_modified:
1184 * @backend: A calendar backend.
1185 * @old_object: iCalendar representation of the original form of the object
1186 * @object: iCalendar representation of the new form of the object
1188 * Notifies each of the backend's listeners about a modified object.
1190 * #e_data_cal_notify_object_modified() calls this for you. You only need to
1191 * call e_cal_backend_notify_object_modified() yourself to report objects
1192 * modified by non-EDS clients.
1195 e_cal_backend_notify_object_modified (ECalBackend *backend,
1196 const char *old_object, const char *object)
1198 ECalBackendPrivate *priv;
1201 EDataCalView *query;
1203 priv = backend->priv;
1205 if (priv->notification_proxy) {
1206 e_cal_backend_notify_object_modified (priv->notification_proxy, old_object, object);
1210 queries = e_cal_backend_get_queries (backend);
1211 iter = e_list_get_iterator (queries);
1213 while (e_iterator_is_valid (iter)) {
1214 query = QUERY (e_iterator_get (iter));
1216 bonobo_object_ref (query);
1217 match_query_and_notify (query, old_object, object);
1218 bonobo_object_unref (query);
1220 e_iterator_next (iter);
1222 g_object_unref (iter);
1226 * e_cal_backend_notify_object_removed:
1227 * @backend: A calendar backend.
1228 * @uid: the UID of the removed object
1229 * @old_object: iCalendar representation of the removed object
1230 * @new_object: iCalendar representation of the object after the removal. This
1231 * only applies to recurrent appointments that had an instance removed. In that
1232 * case, this function notifies a modification instead of a removal.
1234 * Notifies each of the backend's listeners about a removed object.
1236 * e_data_cal_notify_object_removed() calls this for you. You only need to
1237 * call e_cal_backend_notify_object_removed() yourself to report objects
1238 * removed by non-EDS clients.
1241 e_cal_backend_notify_object_removed (ECalBackend *backend, const char *uid,
1242 const char *old_object, const char *object)
1244 ECalBackendPrivate *priv;
1247 EDataCalView *query;
1249 priv = backend->priv;
1251 if (priv->notification_proxy) {
1252 e_cal_backend_notify_object_removed (priv->notification_proxy, uid, old_object, object);
1256 queries = e_cal_backend_get_queries (backend);
1257 iter = e_list_get_iterator (queries);
1259 while (e_iterator_is_valid (iter)) {
1260 query = QUERY (e_iterator_get (iter));
1262 bonobo_object_ref (query);
1264 if (object == NULL) {
1265 /* if object == NULL, it means the object has been completely
1266 removed from the backend */
1267 if (e_data_cal_view_object_matches (query, old_object))
1268 e_data_cal_view_notify_objects_removed_1 (query, uid);
1270 match_query_and_notify (query, old_object, object);
1272 bonobo_object_unref (query);
1274 e_iterator_next (iter);
1276 g_object_unref (iter);
1280 * e_cal_backend_notify_mode:
1281 * @backend: A calendar backend.
1282 * @status: Status of the mode set
1283 * @mode: the current mode
1285 * Notifies each of the backend's listeners about the results of a
1289 e_cal_backend_notify_mode (ECalBackend *backend,
1290 GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
1291 GNOME_Evolution_Calendar_CalMode mode)
1293 ECalBackendPrivate *priv = backend->priv;
1296 if (priv->notification_proxy) {
1297 e_cal_backend_notify_mode (priv->notification_proxy, status, mode);
1301 for (l = priv->clients; l; l = l->next)
1302 e_data_cal_notify_mode (l->data, status, mode);
1306 * e_cal_backend_notify_auth_required:
1307 * @backend: A calendar backend.
1309 * Notifies each of the backend's listeners that authentication is required to
1310 * open the calendar.
1313 e_cal_backend_notify_auth_required (ECalBackend *backend)
1315 ECalBackendPrivate *priv = backend->priv;
1318 for (l = priv->clients; l; l = l->next)
1319 e_data_cal_notify_auth_required (l->data);
1323 * e_cal_backend_notify_error:
1324 * @backend: A calendar backend.
1325 * @message: Error message
1327 * Notifies each of the backend's listeners about an error
1330 e_cal_backend_notify_error (ECalBackend *backend, const char *message)
1332 ECalBackendPrivate *priv = backend->priv;
1335 if (priv->notification_proxy) {
1336 e_cal_backend_notify_error (priv->notification_proxy, message);
1340 for (l = priv->clients; l; l = l->next)
1341 e_data_cal_notify_error (l->data, message);