1 /* Evolution calendar client interface object
3 * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com)
5 * Authors: Federico Mena-Quintero <federico@ximian.com>
6 * Rodrigo Moya <rodrigo@ximian.com>
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.
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.
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.
26 #include <libical/ical.h>
27 #include <bonobo/bonobo-main.h>
28 #include <bonobo/bonobo-exception.h>
29 #include <libedata-cal/e-cal-backend.h>
30 #include "e-data-cal.h"
32 #define PARENT_TYPE BONOBO_TYPE_OBJECT
34 static BonoboObjectClass *parent_class;
36 /* Private part of the Cal structure */
37 struct _EDataCalPrivate {
41 /* Listener on the client we notify */
42 GNOME_Evolution_Calendar_CalListener listener;
44 /* Cache of live queries */
45 GHashTable *live_queries;
48 /* Cal::get_uri method */
50 impl_Cal_get_uri (PortableServer_Servant servant,
51 CORBA_Environment *ev)
54 EDataCalPrivate *priv;
56 CORBA_char *str_uri_copy;
58 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
61 str_uri = e_cal_backend_get_uri (priv->backend);
62 str_uri_copy = CORBA_string_dup (str_uri);
68 impl_Cal_open (PortableServer_Servant servant,
69 CORBA_boolean only_if_exists,
70 const CORBA_char *username,
71 const CORBA_char *password,
72 CORBA_Environment *ev)
75 EDataCalPrivate *priv;
77 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
80 e_cal_backend_open (priv->backend, cal, only_if_exists, username, password);
84 impl_Cal_remove (PortableServer_Servant servant,
85 CORBA_Environment *ev)
88 EDataCalPrivate *priv;
90 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
93 e_cal_backend_remove (priv->backend, cal);
96 /* Cal::isReadOnly method */
98 impl_Cal_isReadOnly (PortableServer_Servant servant,
99 CORBA_Environment *ev)
102 EDataCalPrivate *priv;
104 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
107 e_cal_backend_is_read_only (priv->backend, cal);
110 /* Cal::getEmailAddress method */
112 impl_Cal_getCalAddress (PortableServer_Servant servant,
113 CORBA_Environment *ev)
116 EDataCalPrivate *priv;
118 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
121 e_cal_backend_get_cal_address (priv->backend, cal);
124 /* Cal::get_alarm_email_address method */
126 impl_Cal_getAlarmEmailAddress (PortableServer_Servant servant,
127 CORBA_Environment *ev)
130 EDataCalPrivate *priv;
132 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
135 e_cal_backend_get_alarm_email_address (priv->backend, cal);
138 /* Cal::get_ldap_attribute method */
140 impl_Cal_getLdapAttribute (PortableServer_Servant servant,
141 CORBA_Environment *ev)
144 EDataCalPrivate *priv;
146 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
149 e_cal_backend_get_ldap_attribute (priv->backend, cal);
152 /* Cal::getSchedulingInformation method */
154 impl_Cal_getStaticCapabilities (PortableServer_Servant servant,
155 CORBA_Environment *ev)
158 EDataCalPrivate *priv;
160 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
163 e_cal_backend_get_static_capabilities (priv->backend, cal);
166 /* Cal::setMode method */
168 impl_Cal_setMode (PortableServer_Servant servant,
169 GNOME_Evolution_Calendar_CalMode mode,
170 CORBA_Environment *ev)
173 EDataCalPrivate *priv;
175 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
178 e_cal_backend_set_mode (priv->backend, mode);
182 impl_Cal_getDefaultObject (PortableServer_Servant servant,
183 CORBA_Environment *ev)
186 EDataCalPrivate *priv;
188 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
191 e_cal_backend_get_default_object (priv->backend, cal);
194 /* Cal::getObject method */
196 impl_Cal_getObject (PortableServer_Servant servant,
197 const CORBA_char *uid,
198 const CORBA_char *rid,
199 CORBA_Environment *ev)
202 EDataCalPrivate *priv;
204 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
207 e_cal_backend_get_object (priv->backend, cal, uid, rid);
210 /* Cal::getObjectList method */
212 impl_Cal_getObjectList (PortableServer_Servant servant,
213 const CORBA_char *sexp,
214 CORBA_Environment *ev)
217 EDataCalPrivate *priv;
220 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
223 query = g_hash_table_lookup (priv->live_queries, sexp);
225 GList *matched_objects;
227 matched_objects = e_data_cal_view_get_matched_objects (query);
228 e_data_cal_notify_object_list (
230 e_data_cal_view_is_done (query) ? e_data_cal_view_get_done_status (query) : GNOME_Evolution_Calendar_Success,
233 g_list_free (matched_objects);
235 e_cal_backend_get_object_list (priv->backend, cal, sexp);
238 /* Cal::getAttachmentList method */
240 impl_Cal_getAttachmentList (PortableServer_Servant servant,
241 const CORBA_char *uid,
242 const CORBA_char *rid,
243 CORBA_Environment *ev)
246 EDataCalPrivate *priv;
248 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
251 e_cal_backend_get_attachment_list (priv->backend, cal, uid, rid);
254 /* Cal::getChanges method */
256 impl_Cal_getChanges (PortableServer_Servant servant,
257 const CORBA_char *change_id,
258 CORBA_Environment *ev)
261 EDataCalPrivate *priv;
263 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
266 e_cal_backend_get_changes (priv->backend, cal, change_id);
269 /* Cal::getFreeBusy method */
271 impl_Cal_getFreeBusy (PortableServer_Servant servant,
272 const GNOME_Evolution_Calendar_UserList *user_list,
273 const GNOME_Evolution_Calendar_Time_t start,
274 const GNOME_Evolution_Calendar_Time_t end,
275 CORBA_Environment *ev)
278 EDataCalPrivate *priv;
281 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
284 /* convert the CORBA user list to a GList */
288 for (i = 0; i < user_list->_length; i++)
289 users = g_list_append (users, user_list->_buffer[i]);
292 /* call the backend's get_free_busy method */
293 e_cal_backend_get_free_busy (priv->backend, cal, users, start, end);
296 /* Cal::discardAlarm method */
298 impl_Cal_discardAlarm (PortableServer_Servant servant,
299 const CORBA_char *uid,
300 const CORBA_char *auid,
301 CORBA_Environment *ev)
304 EDataCalPrivate *priv;
306 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
309 e_cal_backend_discard_alarm (priv->backend, cal, uid, auid);
313 impl_Cal_createObject (PortableServer_Servant servant,
314 const CORBA_char *calobj,
315 CORBA_Environment *ev)
318 EDataCalPrivate *priv;
320 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
323 e_cal_backend_create_object (priv->backend, cal, calobj);
327 impl_Cal_modifyObject (PortableServer_Servant servant,
328 const CORBA_char *calobj,
329 const GNOME_Evolution_Calendar_CalObjModType mod,
330 CORBA_Environment *ev)
333 EDataCalPrivate *priv;
335 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
338 e_cal_backend_modify_object (priv->backend, cal, calobj, mod);
341 /* Cal::removeObject method */
343 impl_Cal_removeObject (PortableServer_Servant servant,
344 const CORBA_char *uid,
345 const CORBA_char *rid,
346 const GNOME_Evolution_Calendar_CalObjModType mod,
347 CORBA_Environment *ev)
350 EDataCalPrivate *priv;
352 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
355 e_cal_backend_remove_object (priv->backend, cal, uid, rid, mod);
359 impl_Cal_receiveObjects (PortableServer_Servant servant,
360 const CORBA_char *calobj,
361 CORBA_Environment *ev)
364 EDataCalPrivate *priv;
366 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
369 e_cal_backend_receive_objects (priv->backend, cal, calobj);
373 impl_Cal_sendObjects (PortableServer_Servant servant,
374 const CORBA_char *calobj,
375 CORBA_Environment *ev)
378 EDataCalPrivate *priv;
380 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
383 e_cal_backend_send_objects (priv->backend, cal, calobj);
387 disconnect_query (gpointer key, EDataCalView *query, EDataCal *cal)
389 g_signal_handlers_disconnect_matched (query, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, cal);
390 e_cal_backend_remove_query (cal->priv->backend, query);
394 query_last_listener_gone_cb (EDataCalView *query, EDataCal *cal)
396 EDataCalPrivate *priv;
398 g_return_if_fail (cal != NULL);
402 disconnect_query (NULL, query, cal);
403 g_hash_table_remove (priv->live_queries, e_data_cal_view_get_text (query));
406 /* Cal::getQuery implementation */
408 impl_Cal_getQuery (PortableServer_Servant servant,
409 const CORBA_char *sexp,
410 GNOME_Evolution_Calendar_CalViewListener ql,
411 CORBA_Environment *ev)
415 EDataCalPrivate *priv;
417 ECalBackendSExp *obj_sexp;
419 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
422 /* first see if we already have the query in the cache */
423 query = g_hash_table_lookup (priv->live_queries, sexp);
425 e_data_cal_view_add_listener (query, ql);
426 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
430 /* we handle this entirely here, since it doesn't require any
431 backend involvement now that we have e_cal_view_start to
432 actually kick off the search. */
434 obj_sexp = e_cal_backend_sexp_new (sexp);
436 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_InvalidQuery, NULL);
441 query = e_data_cal_view_new (priv->backend, ql, obj_sexp);
443 g_object_unref (obj_sexp);
444 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_OtherError, NULL);
449 g_signal_connect (query, "last_listener_gone", G_CALLBACK (query_last_listener_gone_cb), cal);
451 g_hash_table_insert (priv->live_queries, g_strdup (sexp), query);
452 e_cal_backend_add_query (priv->backend, query);
454 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
458 /* Cal::getTimezone method */
460 impl_Cal_getTimezone (PortableServer_Servant servant,
461 const CORBA_char *tzid,
462 CORBA_Environment *ev)
465 EDataCalPrivate *priv;
467 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
470 e_cal_backend_get_timezone (priv->backend, cal, tzid);
473 /* Cal::addTimezone method */
475 impl_Cal_addTimezone (PortableServer_Servant servant,
476 const CORBA_char *tz,
477 CORBA_Environment *ev)
480 EDataCalPrivate *priv;
482 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
485 e_cal_backend_add_timezone (priv->backend, cal, tz);
488 /* Cal::setDefaultTimezone method */
490 impl_Cal_setDefaultTimezone (PortableServer_Servant servant,
491 const CORBA_char *tz,
492 CORBA_Environment *ev)
495 EDataCalPrivate *priv;
497 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
500 e_cal_backend_set_default_zone (priv->backend, cal, tz);
504 * e_data_cal_construct:
505 * @cal: A calendar client interface.
506 * @backend: Calendar backend that this @cal presents an interface to.
507 * @listener: Calendar listener for notification.
509 * Constructs a calendar client interface object by binding the corresponding
510 * CORBA object to it. The calendar interface is bound to the specified
511 * @backend, and will notify the @listener about changes to the calendar.
513 * Return value: The same object as the @cal argument.
516 e_data_cal_construct (EDataCal *cal,
517 ECalBackend *backend,
518 GNOME_Evolution_Calendar_CalListener listener)
520 EDataCalPrivate *priv;
521 CORBA_Environment ev;
523 g_return_val_if_fail (cal != NULL, NULL);
524 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
525 g_return_val_if_fail (backend != NULL, NULL);
526 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
530 CORBA_exception_init (&ev);
531 priv->listener = CORBA_Object_duplicate (listener, &ev);
532 if (BONOBO_EX (&ev)) {
533 g_message ("cal_construct: could not duplicate the listener");
534 priv->listener = CORBA_OBJECT_NIL;
535 CORBA_exception_free (&ev);
539 CORBA_exception_free (&ev);
541 priv->backend = backend;
548 * @backend: A calendar backend.
549 * @listener: A calendar listener.
551 * Creates a new calendar client interface object and binds it to the
552 * specified @backend and @listener objects.
554 * Return value: A newly-created #EDataCal calendar client interface
555 * object, or %NULL if its corresponding CORBA object could not be
559 e_data_cal_new (ECalBackend *backend, GNOME_Evolution_Calendar_CalListener listener)
561 EDataCal *cal, *retval;
563 g_return_val_if_fail (backend != NULL, NULL);
564 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
566 cal = E_DATA_CAL (g_object_new (E_TYPE_DATA_CAL,
567 "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
570 retval = e_data_cal_construct (cal, backend, listener);
572 g_message (G_STRLOC ": could not construct the calendar client interface");
573 bonobo_object_unref (BONOBO_OBJECT (cal));
581 * e_data_cal_get_backend:
582 * @cal: A calendar client interface.
584 * Gets the associated backend.
586 * Return value: An #ECalBackend.
589 e_data_cal_get_backend (EDataCal *cal)
591 g_return_val_if_fail (cal != NULL, NULL);
592 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
594 return cal->priv->backend;
598 * e_data_cal_get_listener:
599 * @cal: A calendar client interface.
601 * Gets the listener associated with a calendar client interface.
603 * Return value: The listener.
605 GNOME_Evolution_Calendar_CalListener
606 e_data_cal_get_listener (EDataCal *cal)
608 g_return_val_if_fail (cal != NULL, NULL);
609 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
611 return cal->priv->listener;
614 /* Destroy handler for the calendar */
616 e_data_cal_finalize (GObject *object)
619 EDataCalPrivate *priv;
620 CORBA_Environment ev;
622 g_return_if_fail (object != NULL);
623 g_return_if_fail (E_IS_DATA_CAL (object));
625 cal = E_DATA_CAL (object);
628 priv->backend = NULL;
630 CORBA_exception_init (&ev);
631 bonobo_object_release_unref (priv->listener, &ev);
633 g_message (G_STRLOC ": could not release the listener");
635 priv->listener = NULL;
636 CORBA_exception_free (&ev);
638 g_hash_table_foreach (priv->live_queries, (GHFunc) disconnect_query, cal);
639 g_hash_table_destroy (priv->live_queries);
640 priv->live_queries = NULL;
644 if (G_OBJECT_CLASS (parent_class)->finalize)
645 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
650 /* Class initialization function for the calendar */
652 e_data_cal_class_init (EDataCalClass *klass)
654 GObjectClass *object_class = (GObjectClass *) klass;
655 POA_GNOME_Evolution_Calendar_Cal__epv *epv = &klass->epv;
657 parent_class = g_type_class_peek_parent (klass);
659 /* Class method overrides */
660 object_class->finalize = e_data_cal_finalize;
663 epv->_get_uri = impl_Cal_get_uri;
664 epv->open = impl_Cal_open;
665 epv->remove = impl_Cal_remove;
666 epv->isReadOnly = impl_Cal_isReadOnly;
667 epv->getCalAddress = impl_Cal_getCalAddress;
668 epv->getAlarmEmailAddress = impl_Cal_getAlarmEmailAddress;
669 epv->getLdapAttribute = impl_Cal_getLdapAttribute;
670 epv->getStaticCapabilities = impl_Cal_getStaticCapabilities;
671 epv->setMode = impl_Cal_setMode;
672 epv->getDefaultObject = impl_Cal_getDefaultObject;
673 epv->getObject = impl_Cal_getObject;
674 epv->getTimezone = impl_Cal_getTimezone;
675 epv->addTimezone = impl_Cal_addTimezone;
676 epv->setDefaultTimezone = impl_Cal_setDefaultTimezone;
677 epv->getObjectList = impl_Cal_getObjectList;
678 epv->getAttachmentList = impl_Cal_getAttachmentList;
679 epv->getChanges = impl_Cal_getChanges;
680 epv->getFreeBusy = impl_Cal_getFreeBusy;
681 epv->discardAlarm = impl_Cal_discardAlarm;
682 epv->createObject = impl_Cal_createObject;
683 epv->modifyObject = impl_Cal_modifyObject;
684 epv->removeObject = impl_Cal_removeObject;
685 epv->receiveObjects = impl_Cal_receiveObjects;
686 epv->sendObjects = impl_Cal_sendObjects;
687 epv->getQuery = impl_Cal_getQuery;
690 /* Object initialization function for the calendar */
692 e_data_cal_init (EDataCal *cal, EDataCalClass *klass)
694 EDataCalPrivate *priv;
696 priv = g_new0 (EDataCalPrivate, 1);
699 priv->listener = CORBA_OBJECT_NIL;
700 priv->live_queries = g_hash_table_new_full (g_str_hash, g_str_equal,
701 (GDestroyNotify) g_free,
702 (GDestroyNotify) bonobo_object_unref);
705 BONOBO_TYPE_FUNC_FULL (EDataCal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, e_data_cal);
708 * e_data_cal_notify_read_only:
709 * @cal: A calendar client interface.
710 * @status: Status code.
711 * @read_only: Read only value.
713 * Notifies listeners of the completion of the is_read_only method call.
716 e_data_cal_notify_read_only (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only)
718 EDataCalPrivate *priv;
719 CORBA_Environment ev;
721 g_return_if_fail (cal != NULL);
722 g_return_if_fail (E_IS_DATA_CAL (cal));
725 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
727 CORBA_exception_init (&ev);
728 GNOME_Evolution_Calendar_CalListener_notifyReadOnly (priv->listener, status, read_only, &ev);
731 g_message (G_STRLOC ": could not notify the listener of read only");
733 CORBA_exception_free (&ev);
737 * e_data_cal_notify_cal_address:
738 * @cal: A calendar client interface.
739 * @status: Status code.
740 * @address: Calendar address.
742 * Notifies listeners of the completion of the get_cal_address method call.
745 e_data_cal_notify_cal_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
747 EDataCalPrivate *priv;
748 CORBA_Environment ev;
750 g_return_if_fail (cal != NULL);
751 g_return_if_fail (E_IS_DATA_CAL (cal));
754 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
756 CORBA_exception_init (&ev);
757 GNOME_Evolution_Calendar_CalListener_notifyCalAddress (priv->listener, status, address ? address : "", &ev);
760 g_message (G_STRLOC ": could not notify the listener of cal address");
762 CORBA_exception_free (&ev);
766 * e_data_cal_notify_alarm_email_address:
767 * @cal: A calendar client interface.
768 * @status: Status code.
769 * @address: Alarm email address.
771 * Notifies listeners of the completion of the get_alarm_email_address method call.
774 e_data_cal_notify_alarm_email_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
776 EDataCalPrivate *priv;
777 CORBA_Environment ev;
779 g_return_if_fail (cal != NULL);
780 g_return_if_fail (E_IS_DATA_CAL (cal));
783 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
785 CORBA_exception_init (&ev);
786 GNOME_Evolution_Calendar_CalListener_notifyAlarmEmailAddress (priv->listener, status, address ? address : "", &ev);
789 g_message (G_STRLOC ": could not notify the listener of alarm address");
791 CORBA_exception_free (&ev);
795 * e_data_cal_notify_ldap_attribute:
796 * @cal: A calendar client interface.
797 * @status: Status code.
798 * @attibute: LDAP attribute.
800 * Notifies listeners of the completion of the get_ldap_attribute method call.
803 e_data_cal_notify_ldap_attribute (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *attribute)
805 EDataCalPrivate *priv;
806 CORBA_Environment ev;
808 g_return_if_fail (cal != NULL);
809 g_return_if_fail (E_IS_DATA_CAL (cal));
812 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
814 CORBA_exception_init (&ev);
815 GNOME_Evolution_Calendar_CalListener_notifyLDAPAttribute (priv->listener, status, attribute ? attribute : "", &ev);
818 g_message (G_STRLOC ": could not notify the listener of ldap attribute");
820 CORBA_exception_free (&ev);
824 * e_data_cal_notify_static_capabilities:
825 * @cal: A calendar client interface.
826 * @status: Status code.
827 * @capabilities: Static capabilities from the backend.
829 * Notifies listeners of the completion of the get_static_capabilities method call.
832 e_data_cal_notify_static_capabilities (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *capabilities)
834 EDataCalPrivate *priv;
835 CORBA_Environment ev;
837 g_return_if_fail (cal != NULL);
838 g_return_if_fail (E_IS_DATA_CAL (cal));
841 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
843 CORBA_exception_init (&ev);
844 GNOME_Evolution_Calendar_CalListener_notifyStaticCapabilities (priv->listener, status,
845 capabilities ? capabilities : "", &ev);
848 g_message (G_STRLOC ": could not notify the listener of static capabilities");
850 CORBA_exception_free (&ev);
854 * e_data_cal_notify_open:
855 * @cal: A calendar client interface.
856 * @status: Status code.
858 * Notifies listeners of the completion of the open method call.
861 e_data_cal_notify_open (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
863 EDataCalPrivate *priv;
864 CORBA_Environment ev;
866 g_return_if_fail (cal != NULL);
867 g_return_if_fail (E_IS_DATA_CAL (cal));
870 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
872 CORBA_exception_init (&ev);
873 GNOME_Evolution_Calendar_CalListener_notifyCalOpened (priv->listener, status, &ev);
876 g_message (G_STRLOC ": could not notify the listener of open");
878 CORBA_exception_free (&ev);
882 * e_data_cal_notify_remove:
883 * @cal: A calendar client interface.
884 * @status: Status code.
886 * Notifies listeners of the completion of the remove method call.
889 e_data_cal_notify_remove (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
891 EDataCalPrivate *priv;
892 CORBA_Environment ev;
894 g_return_if_fail (cal != NULL);
895 g_return_if_fail (E_IS_DATA_CAL (cal));
898 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
900 CORBA_exception_init (&ev);
901 GNOME_Evolution_Calendar_CalListener_notifyCalRemoved (priv->listener, status, &ev);
904 g_message (G_STRLOC ": could not notify the listener of remove");
906 CORBA_exception_free (&ev);
910 * e_data_cal_notify_object_created:
911 * @cal: A calendar client interface.
912 * @status: Status code.
913 * @uid: UID of the object created.
914 * @object: The object created as an iCalendar string.
916 * Notifies listeners of the completion of the create_object method call.
919 e_data_cal_notify_object_created (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
920 const char *uid, const char *object)
922 EDataCalPrivate *priv;
923 CORBA_Environment ev;
925 g_return_if_fail (cal != NULL);
926 g_return_if_fail (E_IS_DATA_CAL (cal));
929 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
931 /* If the object is NULL, it means the object has been created on the server sucessfully,
932 but it is not shown in the UI if delay delivery is set */
933 if (status == GNOME_Evolution_Calendar_Success && object)
934 e_cal_backend_notify_object_created (priv->backend, object);
936 CORBA_exception_init (&ev);
937 GNOME_Evolution_Calendar_CalListener_notifyObjectCreated (priv->listener, status, uid ? uid : "", &ev);
940 g_message (G_STRLOC ": could not notify the listener of object creation");
942 CORBA_exception_free (&ev);
946 * e_data_cal_notify_object_modified:
947 * @cal: A calendar client interface.
948 * @status: Status code.
949 * @old_object: The old object as an iCalendar string.
950 * @object: The modified object as an iCalendar string.
952 * Notifies listeners of the completion of the modify_object method call.
955 e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
956 const char *old_object, const char *object)
958 EDataCalPrivate *priv;
959 CORBA_Environment ev;
961 g_return_if_fail (cal != NULL);
962 g_return_if_fail (E_IS_DATA_CAL (cal));
965 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
967 if (status == GNOME_Evolution_Calendar_Success)
968 e_cal_backend_notify_object_modified (priv->backend, old_object, object);
970 CORBA_exception_init (&ev);
971 GNOME_Evolution_Calendar_CalListener_notifyObjectModified (priv->listener, status, &ev);
974 g_message (G_STRLOC ": could not notify the listener of object creation");
976 CORBA_exception_free (&ev);
980 * e_data_cal_notify_object_removed:
981 * @cal: A calendar client interface.
982 * @status: Status code.
983 * @uid: UID of the removed object.
984 * @old_object: The old object as an iCalendar string.
985 * @object: The new object as an iCalendar string. This will not be NULL only
986 * when removing instances of a recurring appointment.
988 * Notifies listeners of the completion of the remove_object method call.
991 e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
992 const ECalComponentId *id, const char *old_object, const char *object)
994 EDataCalPrivate *priv;
995 CORBA_Environment ev;
997 g_return_if_fail (cal != NULL);
998 g_return_if_fail (E_IS_DATA_CAL (cal));
1001 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1003 if (status == GNOME_Evolution_Calendar_Success)
1004 e_cal_backend_notify_object_removed (priv->backend, id, old_object, object);
1006 CORBA_exception_init (&ev);
1007 GNOME_Evolution_Calendar_CalListener_notifyObjectRemoved (priv->listener, status, &ev);
1009 if (BONOBO_EX (&ev))
1010 g_message (G_STRLOC ": could not notify the listener of object removal");
1012 CORBA_exception_free (&ev);
1016 * e_data_cal_notify_objects_received:
1017 * @cal: A calendar client interface.
1018 * @status: Status code.
1020 * Notifies listeners of the completion of the receive_objects method call.
1023 e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
1025 EDataCalPrivate *priv;
1026 CORBA_Environment ev;
1028 g_return_if_fail (cal != NULL);
1029 g_return_if_fail (E_IS_DATA_CAL (cal));
1032 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1034 CORBA_exception_init (&ev);
1035 GNOME_Evolution_Calendar_CalListener_notifyObjectsReceived (priv->listener, status, &ev);
1037 if (BONOBO_EX (&ev))
1038 g_message (G_STRLOC ": could not notify the listener of objects received");
1040 CORBA_exception_free (&ev);
1044 * e_data_cal_notify_alarm_discarded:
1045 * @cal: A calendar client interface.
1046 * @status: Status code.
1048 * Notifies listeners of the completion of the discard_alarm method call.
1051 e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
1053 EDataCalPrivate *priv;
1054 CORBA_Environment ev;
1056 g_return_if_fail (cal != NULL);
1057 g_return_if_fail (E_IS_DATA_CAL (cal));
1060 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1062 CORBA_exception_init (&ev);
1063 GNOME_Evolution_Calendar_CalListener_notifyAlarmDiscarded (priv->listener, status, &ev);
1065 if (BONOBO_EX (&ev))
1066 g_message (G_STRLOC ": could not notify the listener of alarm discarded");
1068 CORBA_exception_free (&ev);
1072 * e_data_cal_notify_objects_sent:
1073 * @cal: A calendar client interface.
1074 * @status: Status code.
1075 * @users: List of users.
1076 * @calobj: An iCalendar string representing the object sent.
1078 * Notifies listeners of the completion of the send_objects method call.
1081 e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *users, const char *calobj)
1083 EDataCalPrivate *priv;
1084 CORBA_Environment ev;
1085 GNOME_Evolution_Calendar_UserList *corba_users;
1087 g_return_if_fail (cal != NULL);
1088 g_return_if_fail (E_IS_DATA_CAL (cal));
1091 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1093 corba_users = GNOME_Evolution_Calendar_UserList__alloc ();
1094 corba_users->_length = g_list_length (users);
1099 corba_users->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (corba_users->_length);
1100 for (l = users, n = 0; l != NULL; l = l->next, n++)
1101 corba_users->_buffer[n] = CORBA_string_dup (l->data);
1104 CORBA_exception_init (&ev);
1105 GNOME_Evolution_Calendar_CalListener_notifyObjectsSent (priv->listener, status, corba_users,
1106 calobj ? calobj : "", &ev);
1108 if (BONOBO_EX (&ev))
1109 g_message (G_STRLOC ": could not notify the listener of objects sent");
1111 CORBA_exception_free (&ev);
1112 CORBA_free (corba_users);
1116 * e_data_cal_notify_default_object:
1117 * @cal: A calendar client interface.
1118 * @status: Status code.
1119 * @object: The default object as an iCalendar string.
1121 * Notifies listeners of the completion of the get_default_object method call.
1124 e_data_cal_notify_default_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
1126 EDataCalPrivate *priv;
1127 CORBA_Environment ev;
1129 g_return_if_fail (cal != NULL);
1130 g_return_if_fail (E_IS_DATA_CAL (cal));
1133 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1135 CORBA_exception_init (&ev);
1137 GNOME_Evolution_Calendar_CalListener_notifyDefaultObjectRequested (priv->listener, status,
1138 object ? object : "", &ev);
1140 if (BONOBO_EX (&ev))
1141 g_message (G_STRLOC ": could not notify the listener of default object");
1143 CORBA_exception_free (&ev);
1147 * e_data_cal_notify_object:
1148 * @cal: A calendar client interface.
1149 * @status: Status code.
1150 * @object: The object retrieved as an iCalendar string.
1152 * Notifies listeners of the completion of the get_object method call.
1155 e_data_cal_notify_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
1157 EDataCalPrivate *priv;
1158 CORBA_Environment ev;
1160 g_return_if_fail (cal != NULL);
1161 g_return_if_fail (E_IS_DATA_CAL (cal));
1164 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1166 CORBA_exception_init (&ev);
1168 GNOME_Evolution_Calendar_CalListener_notifyObjectRequested (priv->listener, status,
1169 object ? object : "", &ev);
1171 if (BONOBO_EX (&ev))
1172 g_message (G_STRLOC ": could not notify the listener of object");
1174 CORBA_exception_free (&ev);
1178 * e_data_cal_notify_object_list:
1179 * @cal: A calendar client interface.
1180 * @status: Status code.
1181 * @objects: List of retrieved objects.
1183 * Notifies listeners of the completion of the get_object_list method call.
1186 e_data_cal_notify_object_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects)
1188 EDataCalPrivate *priv;
1189 CORBA_Environment ev;
1190 GNOME_Evolution_Calendar_stringlist seq;
1194 g_return_if_fail (cal != NULL);
1195 g_return_if_fail (E_IS_DATA_CAL (cal));
1198 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1200 CORBA_exception_init (&ev);
1202 seq._maximum = g_list_length (objects);
1204 seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
1206 for (l = objects, i = 0; l; l = l->next, i++) {
1207 seq._buffer[i] = CORBA_string_dup (l->data);
1211 GNOME_Evolution_Calendar_CalListener_notifyObjectListRequested (priv->listener, status, &seq, &ev);
1213 if (BONOBO_EX (&ev))
1214 g_message (G_STRLOC ": could not notify the listener of object list");
1216 CORBA_exception_free (&ev);
1218 CORBA_free(seq._buffer);
1222 * e_data_cal_notify_attachment_list:
1223 * @cal: A calendar client interface.
1224 * @status: Status code.
1225 * @attachments: List of retrieved attachment uri's.
1227 * Notifies listeners of the completion of the get_attachment_list method call.
1230 e_data_cal_notify_attachment_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GSList *attachments)
1232 EDataCalPrivate *priv;
1233 CORBA_Environment ev;
1234 GNOME_Evolution_Calendar_stringlist seq;
1238 g_return_if_fail (cal != NULL);
1239 g_return_if_fail (E_IS_DATA_CAL (cal));
1242 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1244 CORBA_exception_init (&ev);
1246 seq._maximum = g_slist_length (attachments);
1248 seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
1250 for (l = attachments, i = 0; l; l = l->next, i++) {
1251 seq._buffer[i] = CORBA_string_dup (l->data);
1255 GNOME_Evolution_Calendar_CalListener_notifyAttachmentListRequested (priv->listener, status, &seq, &ev);
1257 if (BONOBO_EX (&ev))
1258 g_message (G_STRLOC ": could not notify the listener of object list");
1260 CORBA_exception_free (&ev);
1262 CORBA_free(seq._buffer);
1266 * e_data_cal_notify_query:
1267 * @cal: A calendar client interface.
1268 * @status: Status code.
1269 * @query: The new live query.
1271 * Notifies listeners of the completion of the get_query method call.
1274 e_data_cal_notify_query (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, EDataCalView *query)
1276 EDataCalPrivate *priv;
1277 CORBA_Environment ev;
1279 g_return_if_fail (cal != NULL);
1280 g_return_if_fail (E_IS_DATA_CAL (cal));
1283 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1285 CORBA_exception_init (&ev);
1286 GNOME_Evolution_Calendar_CalListener_notifyQuery (priv->listener, status, BONOBO_OBJREF (query), &ev);
1288 if (BONOBO_EX (&ev))
1289 g_message (G_STRLOC ": could not notify the listener of query");
1291 CORBA_exception_free (&ev);
1295 * e_data_cal_notify_timezone_requested:
1296 * @cal: A calendar client interface.
1297 * @status: Status code.
1298 * @object: The requested timezone as an iCalendar string.
1300 * Notifies listeners of the completion of the get_timezone method call.
1303 e_data_cal_notify_timezone_requested (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
1305 EDataCalPrivate *priv;
1306 CORBA_Environment ev;
1308 g_return_if_fail (E_IS_DATA_CAL (cal));
1311 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1313 CORBA_exception_init (&ev);
1314 GNOME_Evolution_Calendar_CalListener_notifyTimezoneRequested (priv->listener, status, object ? object : "", &ev);
1316 if (BONOBO_EX (&ev))
1317 g_warning (G_STRLOC ": could not notify the listener of timezone requested");
1319 CORBA_exception_free (&ev);
1323 * e_data_cal_notify_timezone_added:
1324 * @cal: A calendar client interface.
1325 * @status: Status code.
1326 * @tzid: ID of the added timezone.
1328 * Notifies listeners of the completion of the add_timezone method call.
1331 e_data_cal_notify_timezone_added (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *tzid)
1333 EDataCalPrivate *priv;
1334 CORBA_Environment ev;
1336 g_return_if_fail (E_IS_DATA_CAL (cal));
1339 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1341 CORBA_exception_init (&ev);
1342 GNOME_Evolution_Calendar_CalListener_notifyTimezoneAdded (priv->listener, status, tzid ? tzid : "", &ev);
1344 if (BONOBO_EX (&ev))
1345 g_warning (G_STRLOC ": could not notify the listener of timezone added");
1347 CORBA_exception_free (&ev);
1351 * e_data_cal_notify_default_timezone_set:
1352 * @cal: A calendar client interface.
1353 * @status: Status code.
1355 * Notifies listeners of the completion of the set_default_timezone method call.
1358 e_data_cal_notify_default_timezone_set (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
1360 EDataCalPrivate *priv;
1361 CORBA_Environment ev;
1363 g_return_if_fail (E_IS_DATA_CAL (cal));
1366 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1368 CORBA_exception_init (&ev);
1369 GNOME_Evolution_Calendar_CalListener_notifyDefaultTimezoneSet (priv->listener, status, &ev);
1371 if (BONOBO_EX (&ev))
1372 g_warning (G_STRLOC ": could not notify the listener of default timezone set");
1374 CORBA_exception_free (&ev);
1378 * e_data_cal_notify_changes:
1379 * @cal: A calendar client interface.
1380 * @status: Status code.
1381 * @adds: List of additions.
1382 * @modifies: List of modifications.
1383 * @deletes: List of removals.
1385 * Notifies listeners of the completion of the get_changes method call.
1388 e_data_cal_notify_changes (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
1389 GList *adds, GList *modifies, GList *deletes)
1391 EDataCalPrivate *priv;
1392 CORBA_Environment ev;
1393 GNOME_Evolution_Calendar_CalObjChangeSeq seq;
1397 g_return_if_fail (E_IS_DATA_CAL (cal));
1400 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1402 n = g_list_length (adds) + g_list_length (modifies) + g_list_length (deletes);
1405 seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObjChange_allocbuf (n);
1408 for (l = adds; l; i++, l = l->next) {
1409 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1411 change->calobj = CORBA_string_dup (l->data);
1412 change->type = GNOME_Evolution_Calendar_ADDED;
1415 for (l = modifies; l; i++, l = l->next) {
1416 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1418 change->calobj = CORBA_string_dup (l->data);
1419 change->type = GNOME_Evolution_Calendar_MODIFIED;
1422 for (l = deletes; l; i++, l = l->next) {
1423 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1425 change->calobj = CORBA_string_dup (l->data);
1426 change->type = GNOME_Evolution_Calendar_DELETED;
1429 CORBA_exception_init (&ev);
1430 GNOME_Evolution_Calendar_CalListener_notifyChanges (priv->listener, status, &seq, &ev);
1432 CORBA_free (seq._buffer);
1434 if (BONOBO_EX (&ev))
1435 g_warning (G_STRLOC ": could not notify the listener of default timezone set");
1437 CORBA_exception_free (&ev);
1441 * e_data_cal_notify_free_busy:
1442 * @cal: A calendar client interface.
1443 * @status: Status code.
1444 * @freebusy: List of free/busy objects.
1446 * Notifies listeners of the completion of the get_free_busy method call.
1449 e_data_cal_notify_free_busy (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy)
1451 EDataCalPrivate *priv;
1452 CORBA_Environment ev;
1453 GNOME_Evolution_Calendar_CalObjSeq seq;
1457 g_return_if_fail (E_IS_DATA_CAL (cal));
1460 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1462 n = g_list_length (freebusy);
1465 seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (n);
1467 for (i = 0, l = freebusy; l; i++, l = l->next)
1468 seq._buffer[i] = CORBA_string_dup (l->data);
1470 CORBA_exception_init (&ev);
1471 GNOME_Evolution_Calendar_CalListener_notifyFreeBusy (priv->listener, status, &seq, &ev);
1473 CORBA_free (seq._buffer);
1475 if (BONOBO_EX (&ev))
1476 g_warning (G_STRLOC ": could not notify the listener of freebusy");
1478 CORBA_exception_free (&ev);
1482 * e_data_cal_notify_mode:
1483 * @cal: A calendar client interface.
1484 * @status: Status of the mode set.
1485 * @mode: The current mode.
1487 * Notifies the listener of the results of a set_mode call.
1490 e_data_cal_notify_mode (EDataCal *cal,
1491 GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
1492 GNOME_Evolution_Calendar_CalMode mode)
1494 EDataCalPrivate *priv;
1495 CORBA_Environment ev;
1497 g_return_if_fail (cal != NULL);
1498 g_return_if_fail (E_IS_DATA_CAL (cal));
1501 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1503 CORBA_exception_init (&ev);
1504 GNOME_Evolution_Calendar_CalListener_notifyCalSetMode (priv->listener, status, mode, &ev);
1506 if (BONOBO_EX (&ev))
1507 g_message ("e_data_cal_notify_mode(): could not notify the listener "
1508 "about a mode change");
1510 CORBA_exception_free (&ev);
1514 * e_data_cal_notify_auth_required:
1515 * @cal: A calendar client interface.
1517 * Notifies listeners that authorization is required to open the calendar.
1520 e_data_cal_notify_auth_required (EDataCal *cal)
1522 EDataCalPrivate *priv;
1523 CORBA_Environment ev;
1525 g_return_if_fail (cal != NULL);
1526 g_return_if_fail (E_IS_DATA_CAL (cal));
1529 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1531 CORBA_exception_init (&ev);
1532 GNOME_Evolution_Calendar_CalListener_notifyAuthRequired (priv->listener, &ev);
1533 if (BONOBO_EX (&ev))
1534 g_message ("e_data_cal_notify_auth_required: could not notify the listener "
1535 "about auth required");
1537 CORBA_exception_free (&ev);
1541 * e_data_cal_notify_error
1542 * @cal: A calendar client interface.
1543 * @message: Error message.
1545 * Notify a calendar client of an error occurred in the backend.
1548 e_data_cal_notify_error (EDataCal *cal, const char *message)
1550 EDataCalPrivate *priv;
1551 CORBA_Environment ev;
1553 g_return_if_fail (cal != NULL);
1554 g_return_if_fail (E_IS_DATA_CAL (cal));
1555 g_return_if_fail (message != NULL);
1558 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1560 CORBA_exception_init (&ev);
1561 GNOME_Evolution_Calendar_CalListener_notifyErrorOccurred (priv->listener, (char *) message, &ev);
1563 if (BONOBO_EX (&ev))
1564 g_message ("e_data_cal_notify_remove(): could not notify the listener "
1565 "about a removed object");
1567 CORBA_exception_free (&ev);