1 /* Evolution calendar client interface object
3 * Copyright (C) 2000 Ximian, Inc.
4 * Copyright (C) 2000 Ximian, Inc.
6 * Authors: Federico Mena-Quintero <federico@ximian.com>
7 * Rodrigo Moya <rodrigo@ximian.com>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of version 2 of the GNU General Public
11 * License as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
27 #include <libical/ical.h>
28 #include <bonobo/bonobo-main.h>
29 #include <bonobo/bonobo-exception.h>
30 #include <libedata-cal/e-cal-backend.h>
31 #include "e-data-cal.h"
33 #define PARENT_TYPE BONOBO_TYPE_OBJECT
35 static BonoboObjectClass *parent_class;
37 /* Private part of the Cal structure */
38 struct _EDataCalPrivate {
42 /* Listener on the client we notify */
43 GNOME_Evolution_Calendar_CalListener listener;
45 /* Cache of live queries */
46 GHashTable *live_queries;
49 /* Cal::get_uri method */
51 impl_Cal_get_uri (PortableServer_Servant servant,
52 CORBA_Environment *ev)
55 EDataCalPrivate *priv;
57 CORBA_char *str_uri_copy;
59 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
62 str_uri = e_cal_backend_get_uri (priv->backend);
63 str_uri_copy = CORBA_string_dup (str_uri);
69 impl_Cal_open (PortableServer_Servant servant,
70 CORBA_boolean only_if_exists,
71 const CORBA_char *username,
72 const CORBA_char *password,
73 CORBA_Environment *ev)
76 EDataCalPrivate *priv;
78 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
81 e_cal_backend_open (priv->backend, cal, only_if_exists, username, password);
85 impl_Cal_remove (PortableServer_Servant servant,
86 CORBA_Environment *ev)
89 EDataCalPrivate *priv;
91 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
94 e_cal_backend_remove (priv->backend, cal);
97 /* Cal::isReadOnly method */
99 impl_Cal_isReadOnly (PortableServer_Servant servant,
100 CORBA_Environment *ev)
103 EDataCalPrivate *priv;
105 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
108 e_cal_backend_is_read_only (priv->backend, cal);
111 /* Cal::getEmailAddress method */
113 impl_Cal_getCalAddress (PortableServer_Servant servant,
114 CORBA_Environment *ev)
117 EDataCalPrivate *priv;
119 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
122 e_cal_backend_get_cal_address (priv->backend, cal);
125 /* Cal::get_alarm_email_address method */
127 impl_Cal_getAlarmEmailAddress (PortableServer_Servant servant,
128 CORBA_Environment *ev)
131 EDataCalPrivate *priv;
133 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
136 e_cal_backend_get_alarm_email_address (priv->backend, cal);
139 /* Cal::get_ldap_attribute method */
141 impl_Cal_getLdapAttribute (PortableServer_Servant servant,
142 CORBA_Environment *ev)
145 EDataCalPrivate *priv;
147 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
150 e_cal_backend_get_ldap_attribute (priv->backend, cal);
153 /* Cal::getSchedulingInformation method */
155 impl_Cal_getStaticCapabilities (PortableServer_Servant servant,
156 CORBA_Environment *ev)
159 EDataCalPrivate *priv;
161 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
164 e_cal_backend_get_static_capabilities (priv->backend, cal);
167 /* Cal::setMode method */
169 impl_Cal_setMode (PortableServer_Servant servant,
170 GNOME_Evolution_Calendar_CalMode mode,
171 CORBA_Environment *ev)
174 EDataCalPrivate *priv;
176 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
179 e_cal_backend_set_mode (priv->backend, mode);
183 impl_Cal_getDefaultObject (PortableServer_Servant servant,
184 CORBA_Environment *ev)
187 EDataCalPrivate *priv;
189 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
192 e_cal_backend_get_default_object (priv->backend, cal);
195 /* Cal::getObject method */
197 impl_Cal_getObject (PortableServer_Servant servant,
198 const CORBA_char *uid,
199 const CORBA_char *rid,
200 CORBA_Environment *ev)
203 EDataCalPrivate *priv;
205 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
208 e_cal_backend_get_object (priv->backend, cal, uid, rid);
211 /* Cal::getObjectList method */
213 impl_Cal_getObjectList (PortableServer_Servant servant,
214 const CORBA_char *sexp,
215 CORBA_Environment *ev)
218 EDataCalPrivate *priv;
221 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
224 query = g_hash_table_lookup (priv->live_queries, sexp);
226 GList *matched_objects;
228 matched_objects = e_data_cal_view_get_matched_objects (query);
229 e_data_cal_notify_object_list (
231 e_data_cal_view_is_done (query) ? e_data_cal_view_get_done_status (query) : GNOME_Evolution_Calendar_Success,
234 g_list_free (matched_objects);
236 e_cal_backend_get_object_list (priv->backend, cal, sexp);
239 /* Cal::getChanges method */
241 impl_Cal_getChanges (PortableServer_Servant servant,
242 const CORBA_char *change_id,
243 CORBA_Environment *ev)
246 EDataCalPrivate *priv;
248 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
251 e_cal_backend_get_changes (priv->backend, cal, change_id);
254 /* Cal::getFreeBusy method */
256 impl_Cal_getFreeBusy (PortableServer_Servant servant,
257 const GNOME_Evolution_Calendar_UserList *user_list,
258 const GNOME_Evolution_Calendar_Time_t start,
259 const GNOME_Evolution_Calendar_Time_t end,
260 CORBA_Environment *ev)
263 EDataCalPrivate *priv;
266 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
269 /* convert the CORBA user list to a GList */
273 for (i = 0; i < user_list->_length; i++)
274 users = g_list_append (users, user_list->_buffer[i]);
277 /* call the backend's get_free_busy method */
278 e_cal_backend_get_free_busy (priv->backend, cal, users, start, end);
281 /* Cal::discardAlarm method */
283 impl_Cal_discardAlarm (PortableServer_Servant servant,
284 const CORBA_char *uid,
285 const CORBA_char *auid,
286 CORBA_Environment *ev)
289 EDataCalPrivate *priv;
291 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
294 e_cal_backend_discard_alarm (priv->backend, cal, uid, auid);
298 impl_Cal_createObject (PortableServer_Servant servant,
299 const CORBA_char *calobj,
300 CORBA_Environment *ev)
303 EDataCalPrivate *priv;
305 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
308 e_cal_backend_create_object (priv->backend, cal, calobj);
312 impl_Cal_modifyObject (PortableServer_Servant servant,
313 const CORBA_char *calobj,
314 const GNOME_Evolution_Calendar_CalObjModType mod,
315 CORBA_Environment *ev)
318 EDataCalPrivate *priv;
320 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
323 e_cal_backend_modify_object (priv->backend, cal, calobj, mod);
326 /* Cal::removeObject method */
328 impl_Cal_removeObject (PortableServer_Servant servant,
329 const CORBA_char *uid,
330 const CORBA_char *rid,
331 const GNOME_Evolution_Calendar_CalObjModType mod,
332 CORBA_Environment *ev)
335 EDataCalPrivate *priv;
337 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
340 e_cal_backend_remove_object (priv->backend, cal, uid, rid, mod);
344 impl_Cal_receiveObjects (PortableServer_Servant servant,
345 const CORBA_char *calobj,
346 CORBA_Environment *ev)
349 EDataCalPrivate *priv;
351 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
354 e_cal_backend_receive_objects (priv->backend, cal, calobj);
358 impl_Cal_sendObjects (PortableServer_Servant servant,
359 const CORBA_char *calobj,
360 CORBA_Environment *ev)
363 EDataCalPrivate *priv;
365 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
368 e_cal_backend_send_objects (priv->backend, cal, calobj);
371 /* Cal::getQuery implementation */
373 impl_Cal_getQuery (PortableServer_Servant servant,
374 const CORBA_char *sexp,
375 GNOME_Evolution_Calendar_CalViewListener ql,
376 CORBA_Environment *ev)
380 EDataCalPrivate *priv;
382 ECalBackendSExp *obj_sexp;
384 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
387 /* first see if we already have the query in the cache */
388 query = g_hash_table_lookup (priv->live_queries, sexp);
390 e_data_cal_view_add_listener (query, ql);
391 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
395 /* we handle this entirely here, since it doesn't require any
396 backend involvement now that we have e_cal_view_start to
397 actually kick off the search. */
399 obj_sexp = e_cal_backend_sexp_new (sexp);
401 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_InvalidQuery, NULL);
406 query = e_data_cal_view_new (priv->backend, ql, obj_sexp);
408 g_object_unref (obj_sexp);
409 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_OtherError, NULL);
414 g_hash_table_insert (priv->live_queries, g_strdup (sexp), query);
415 e_cal_backend_add_query (priv->backend, query);
417 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
421 /* Cal::getTimezone method */
423 impl_Cal_getTimezone (PortableServer_Servant servant,
424 const CORBA_char *tzid,
425 CORBA_Environment *ev)
428 EDataCalPrivate *priv;
430 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
433 e_cal_backend_get_timezone (priv->backend, cal, tzid);
436 /* Cal::addTimezone method */
438 impl_Cal_addTimezone (PortableServer_Servant servant,
439 const CORBA_char *tz,
440 CORBA_Environment *ev)
443 EDataCalPrivate *priv;
445 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
448 e_cal_backend_add_timezone (priv->backend, cal, tz);
451 /* Cal::setDefaultTimezone method */
453 impl_Cal_setDefaultTimezone (PortableServer_Servant servant,
454 const CORBA_char *tzid,
455 CORBA_Environment *ev)
458 EDataCalPrivate *priv;
460 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
463 e_cal_backend_set_default_timezone (priv->backend, cal, tzid);
468 * @cal: A calendar client interface.
469 * @corba_cal: CORBA object for the calendar.
470 * @backend: Calendar backend that this @cal presents an interface to.
471 * @listener: Calendar listener for notification.
473 * Constructs a calendar client interface object by binding the corresponding
474 * CORBA object to it. The calendar interface is bound to the specified
475 * @backend, and will notify the @listener about changes to the calendar.
477 * Return value: The same object as the @cal argument.
480 e_data_cal_construct (EDataCal *cal,
481 ECalBackend *backend,
482 GNOME_Evolution_Calendar_CalListener listener)
484 EDataCalPrivate *priv;
485 CORBA_Environment ev;
487 g_return_val_if_fail (cal != NULL, NULL);
488 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
489 g_return_val_if_fail (backend != NULL, NULL);
490 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
494 CORBA_exception_init (&ev);
495 priv->listener = CORBA_Object_duplicate (listener, &ev);
496 if (BONOBO_EX (&ev)) {
497 g_message ("cal_construct: could not duplicate the listener");
498 priv->listener = CORBA_OBJECT_NIL;
499 CORBA_exception_free (&ev);
503 CORBA_exception_free (&ev);
505 priv->backend = backend;
512 * @backend: A calendar backend.
513 * @listener: A calendar listener.
515 * Creates a new calendar client interface object and binds it to the
516 * specified @backend and @listener objects.
518 * Return value: A newly-created #EDataCal calendar client interface
519 * object, or %NULL if its corresponding CORBA object could not be
523 e_data_cal_new (ECalBackend *backend, GNOME_Evolution_Calendar_CalListener listener)
525 EDataCal *cal, *retval;
527 g_return_val_if_fail (backend != NULL, NULL);
528 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
530 cal = E_DATA_CAL (g_object_new (E_TYPE_DATA_CAL,
531 "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
534 retval = e_data_cal_construct (cal, backend, listener);
536 g_message (G_STRLOC ": could not construct the calendar client interface");
537 bonobo_object_unref (BONOBO_OBJECT (cal));
545 e_data_cal_get_backend (EDataCal *cal)
547 g_return_val_if_fail (cal != NULL, NULL);
548 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
550 return cal->priv->backend;
553 GNOME_Evolution_Calendar_CalListener
554 e_data_cal_get_listener (EDataCal *cal)
556 g_return_val_if_fail (cal != NULL, NULL);
557 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
559 return cal->priv->listener;
562 /* Destroy handler for the calendar */
564 e_data_cal_finalize (GObject *object)
567 EDataCalPrivate *priv;
568 CORBA_Environment ev;
570 g_return_if_fail (object != NULL);
571 g_return_if_fail (E_IS_DATA_CAL (object));
573 cal = E_DATA_CAL (object);
576 priv->backend = NULL;
578 CORBA_exception_init (&ev);
579 bonobo_object_release_unref (priv->listener, &ev);
581 g_message (G_STRLOC ": could not release the listener");
583 priv->listener = NULL;
584 CORBA_exception_free (&ev);
586 g_hash_table_destroy (priv->live_queries);
587 priv->live_queries = NULL;
591 if (G_OBJECT_CLASS (parent_class)->finalize)
592 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
597 /* Class initialization function for the calendar */
599 e_data_cal_class_init (EDataCalClass *klass)
601 GObjectClass *object_class = (GObjectClass *) klass;
602 POA_GNOME_Evolution_Calendar_Cal__epv *epv = &klass->epv;
604 parent_class = g_type_class_peek_parent (klass);
606 /* Class method overrides */
607 object_class->finalize = e_data_cal_finalize;
610 epv->_get_uri = impl_Cal_get_uri;
611 epv->open = impl_Cal_open;
612 epv->remove = impl_Cal_remove;
613 epv->isReadOnly = impl_Cal_isReadOnly;
614 epv->getCalAddress = impl_Cal_getCalAddress;
615 epv->getAlarmEmailAddress = impl_Cal_getAlarmEmailAddress;
616 epv->getLdapAttribute = impl_Cal_getLdapAttribute;
617 epv->getStaticCapabilities = impl_Cal_getStaticCapabilities;
618 epv->setMode = impl_Cal_setMode;
619 epv->getDefaultObject = impl_Cal_getDefaultObject;
620 epv->getObject = impl_Cal_getObject;
621 epv->getTimezone = impl_Cal_getTimezone;
622 epv->addTimezone = impl_Cal_addTimezone;
623 epv->setDefaultTimezone = impl_Cal_setDefaultTimezone;
624 epv->getObjectList = impl_Cal_getObjectList;
625 epv->getChanges = impl_Cal_getChanges;
626 epv->getFreeBusy = impl_Cal_getFreeBusy;
627 epv->discardAlarm = impl_Cal_discardAlarm;
628 epv->createObject = impl_Cal_createObject;
629 epv->modifyObject = impl_Cal_modifyObject;
630 epv->removeObject = impl_Cal_removeObject;
631 epv->receiveObjects = impl_Cal_receiveObjects;
632 epv->sendObjects = impl_Cal_sendObjects;
633 epv->getQuery = impl_Cal_getQuery;
637 /* Object initialization function for the calendar */
639 e_data_cal_init (EDataCal *cal, EDataCalClass *klass)
641 EDataCalPrivate *priv;
643 priv = g_new0 (EDataCalPrivate, 1);
646 priv->listener = CORBA_OBJECT_NIL;
647 priv->live_queries = g_hash_table_new_full (g_str_hash, g_str_equal,
648 (GDestroyNotify) g_free,
649 (GDestroyNotify) g_object_unref);
652 BONOBO_TYPE_FUNC_FULL (EDataCal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, e_data_cal);
655 e_data_cal_notify_read_only (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only)
657 EDataCalPrivate *priv;
658 CORBA_Environment ev;
660 g_return_if_fail (cal != NULL);
661 g_return_if_fail (E_IS_DATA_CAL (cal));
664 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
666 CORBA_exception_init (&ev);
667 GNOME_Evolution_Calendar_CalListener_notifyReadOnly (priv->listener, status, read_only, &ev);
670 g_message (G_STRLOC ": could not notify the listener of read only");
672 CORBA_exception_free (&ev);
676 e_data_cal_notify_cal_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
678 EDataCalPrivate *priv;
679 CORBA_Environment ev;
681 g_return_if_fail (cal != NULL);
682 g_return_if_fail (E_IS_DATA_CAL (cal));
685 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
687 CORBA_exception_init (&ev);
688 GNOME_Evolution_Calendar_CalListener_notifyCalAddress (priv->listener, status, address ? address : "", &ev);
691 g_message (G_STRLOC ": could not notify the listener of cal address");
693 CORBA_exception_free (&ev);
697 e_data_cal_notify_alarm_email_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
699 EDataCalPrivate *priv;
700 CORBA_Environment ev;
702 g_return_if_fail (cal != NULL);
703 g_return_if_fail (E_IS_DATA_CAL (cal));
706 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
708 CORBA_exception_init (&ev);
709 GNOME_Evolution_Calendar_CalListener_notifyAlarmEmailAddress (priv->listener, status, address ? address : "", &ev);
712 g_message (G_STRLOC ": could not notify the listener of alarm address");
714 CORBA_exception_free (&ev);
718 e_data_cal_notify_ldap_attribute (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *attribute)
720 EDataCalPrivate *priv;
721 CORBA_Environment ev;
723 g_return_if_fail (cal != NULL);
724 g_return_if_fail (E_IS_DATA_CAL (cal));
727 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
729 CORBA_exception_init (&ev);
730 GNOME_Evolution_Calendar_CalListener_notifyLDAPAttribute (priv->listener, status, attribute ? attribute : "", &ev);
733 g_message (G_STRLOC ": could not notify the listener of ldap attribute");
735 CORBA_exception_free (&ev);
739 e_data_cal_notify_static_capabilities (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *capabilities)
741 EDataCalPrivate *priv;
742 CORBA_Environment ev;
744 g_return_if_fail (cal != NULL);
745 g_return_if_fail (E_IS_DATA_CAL (cal));
748 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
750 CORBA_exception_init (&ev);
751 GNOME_Evolution_Calendar_CalListener_notifyStaticCapabilities (priv->listener, status,
752 capabilities ? capabilities : "", &ev);
755 g_message (G_STRLOC ": could not notify the listener of static capabilities");
757 CORBA_exception_free (&ev);
761 e_data_cal_notify_open (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
763 EDataCalPrivate *priv;
764 CORBA_Environment ev;
766 g_return_if_fail (cal != NULL);
767 g_return_if_fail (E_IS_DATA_CAL (cal));
770 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
772 CORBA_exception_init (&ev);
773 GNOME_Evolution_Calendar_CalListener_notifyCalOpened (priv->listener, status, &ev);
776 g_message (G_STRLOC ": could not notify the listener of open");
778 CORBA_exception_free (&ev);
782 e_data_cal_notify_remove (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
784 EDataCalPrivate *priv;
785 CORBA_Environment ev;
787 g_return_if_fail (cal != NULL);
788 g_return_if_fail (E_IS_DATA_CAL (cal));
791 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
793 CORBA_exception_init (&ev);
794 GNOME_Evolution_Calendar_CalListener_notifyCalRemoved (priv->listener, status, &ev);
797 g_message (G_STRLOC ": could not notify the listener of remove");
799 CORBA_exception_free (&ev);
803 e_data_cal_notify_object_created (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
804 const char *uid, const char *object)
806 EDataCalPrivate *priv;
807 CORBA_Environment ev;
809 g_return_if_fail (cal != NULL);
810 g_return_if_fail (E_IS_DATA_CAL (cal));
813 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
815 if (status == GNOME_Evolution_Calendar_Success)
816 e_cal_backend_notify_object_created (priv->backend, object);
818 CORBA_exception_init (&ev);
819 GNOME_Evolution_Calendar_CalListener_notifyObjectCreated (priv->listener, status, uid ? uid : "", &ev);
822 g_message (G_STRLOC ": could not notify the listener of object creation");
824 CORBA_exception_free (&ev);
828 e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
829 const char *old_object, const char *object)
831 EDataCalPrivate *priv;
832 CORBA_Environment ev;
834 g_return_if_fail (cal != NULL);
835 g_return_if_fail (E_IS_DATA_CAL (cal));
838 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
840 if (status == GNOME_Evolution_Calendar_Success)
841 e_cal_backend_notify_object_modified (priv->backend, old_object, object);
843 CORBA_exception_init (&ev);
844 GNOME_Evolution_Calendar_CalListener_notifyObjectModified (priv->listener, status, &ev);
847 g_message (G_STRLOC ": could not notify the listener of object creation");
849 CORBA_exception_free (&ev);
853 e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
854 const char *uid, const char *old_object, const char *object)
856 EDataCalPrivate *priv;
857 CORBA_Environment ev;
859 g_return_if_fail (cal != NULL);
860 g_return_if_fail (E_IS_DATA_CAL (cal));
863 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
865 if (status == GNOME_Evolution_Calendar_Success)
866 e_cal_backend_notify_object_removed (priv->backend, uid, old_object, object);
868 CORBA_exception_init (&ev);
869 GNOME_Evolution_Calendar_CalListener_notifyObjectRemoved (priv->listener, status, &ev);
872 g_message (G_STRLOC ": could not notify the listener of object removal");
874 CORBA_exception_free (&ev);
878 e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
880 EDataCalPrivate *priv;
881 CORBA_Environment ev;
883 g_return_if_fail (cal != NULL);
884 g_return_if_fail (E_IS_DATA_CAL (cal));
887 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
889 CORBA_exception_init (&ev);
890 GNOME_Evolution_Calendar_CalListener_notifyObjectsReceived (priv->listener, status, &ev);
893 g_message (G_STRLOC ": could not notify the listener of objects received");
895 CORBA_exception_free (&ev);
899 e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
901 EDataCalPrivate *priv;
902 CORBA_Environment ev;
904 g_return_if_fail (cal != NULL);
905 g_return_if_fail (E_IS_DATA_CAL (cal));
908 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
910 CORBA_exception_init (&ev);
911 GNOME_Evolution_Calendar_CalListener_notifyAlarmDiscarded (priv->listener, status, &ev);
914 g_message (G_STRLOC ": could not notify the listener of alarm discarded");
916 CORBA_exception_free (&ev);
920 e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *users, const char *calobj)
922 EDataCalPrivate *priv;
923 CORBA_Environment ev;
924 GNOME_Evolution_Calendar_UserList *corba_users;
926 g_return_if_fail (cal != NULL);
927 g_return_if_fail (E_IS_DATA_CAL (cal));
930 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
932 corba_users = GNOME_Evolution_Calendar_UserList__alloc ();
933 corba_users->_length = g_list_length (users);
938 corba_users->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (corba_users->_length);
939 for (l = users, n = 0; l != NULL; l = l->next, n++)
940 corba_users->_buffer[n] = CORBA_string_dup (l->data);
943 CORBA_exception_init (&ev);
944 GNOME_Evolution_Calendar_CalListener_notifyObjectsSent (priv->listener, status, corba_users,
945 calobj ? calobj : "", &ev);
948 g_message (G_STRLOC ": could not notify the listener of objects sent");
950 CORBA_exception_free (&ev);
951 CORBA_free (corba_users);
955 e_data_cal_notify_default_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
957 EDataCalPrivate *priv;
958 CORBA_Environment ev;
960 g_return_if_fail (cal != NULL);
961 g_return_if_fail (E_IS_DATA_CAL (cal));
964 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
966 CORBA_exception_init (&ev);
968 GNOME_Evolution_Calendar_CalListener_notifyDefaultObjectRequested (priv->listener, status,
969 object ? object : "", &ev);
972 g_message (G_STRLOC ": could not notify the listener of default object");
974 CORBA_exception_free (&ev);
978 e_data_cal_notify_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
980 EDataCalPrivate *priv;
981 CORBA_Environment ev;
983 g_return_if_fail (cal != NULL);
984 g_return_if_fail (E_IS_DATA_CAL (cal));
987 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
989 CORBA_exception_init (&ev);
991 GNOME_Evolution_Calendar_CalListener_notifyObjectRequested (priv->listener, status,
992 object ? object : "", &ev);
995 g_message (G_STRLOC ": could not notify the listener of object");
997 CORBA_exception_free (&ev);
1001 e_data_cal_notify_object_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects)
1003 EDataCalPrivate *priv;
1004 CORBA_Environment ev;
1005 GNOME_Evolution_Calendar_stringlist seq;
1009 g_return_if_fail (cal != NULL);
1010 g_return_if_fail (E_IS_DATA_CAL (cal));
1013 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1015 CORBA_exception_init (&ev);
1017 seq._maximum = g_list_length (objects);
1019 seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
1021 for (l = objects, i = 0; l; l = l->next, i++) {
1022 seq._buffer[i] = CORBA_string_dup (l->data);
1026 GNOME_Evolution_Calendar_CalListener_notifyObjectListRequested (priv->listener, status, &seq, &ev);
1028 if (BONOBO_EX (&ev))
1029 g_message (G_STRLOC ": could not notify the listener of object list");
1031 CORBA_exception_free (&ev);
1033 CORBA_free(seq._buffer);
1037 e_data_cal_notify_query (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, EDataCalView *query)
1039 EDataCalPrivate *priv;
1040 CORBA_Environment ev;
1042 g_return_if_fail (cal != NULL);
1043 g_return_if_fail (E_IS_DATA_CAL (cal));
1046 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1048 CORBA_exception_init (&ev);
1049 GNOME_Evolution_Calendar_CalListener_notifyQuery (priv->listener, status, BONOBO_OBJREF (query), &ev);
1051 if (BONOBO_EX (&ev))
1052 g_message (G_STRLOC ": could not notify the listener of query");
1054 CORBA_exception_free (&ev);
1058 e_data_cal_notify_timezone_requested (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
1060 EDataCalPrivate *priv;
1061 CORBA_Environment ev;
1063 g_return_if_fail (E_IS_DATA_CAL (cal));
1066 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1068 CORBA_exception_init (&ev);
1069 GNOME_Evolution_Calendar_CalListener_notifyTimezoneRequested (priv->listener, status, object ? object : "", &ev);
1071 if (BONOBO_EX (&ev))
1072 g_warning (G_STRLOC ": could not notify the listener of timezone requested");
1074 CORBA_exception_free (&ev);
1078 e_data_cal_notify_timezone_added (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *tzid)
1080 EDataCalPrivate *priv;
1081 CORBA_Environment ev;
1083 g_return_if_fail (E_IS_DATA_CAL (cal));
1086 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1088 CORBA_exception_init (&ev);
1089 GNOME_Evolution_Calendar_CalListener_notifyTimezoneAdded (priv->listener, status, tzid ? tzid : "", &ev);
1091 if (BONOBO_EX (&ev))
1092 g_warning (G_STRLOC ": could not notify the listener of timezone added");
1094 CORBA_exception_free (&ev);
1098 e_data_cal_notify_default_timezone_set (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
1100 EDataCalPrivate *priv;
1101 CORBA_Environment ev;
1103 g_return_if_fail (E_IS_DATA_CAL (cal));
1106 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1108 CORBA_exception_init (&ev);
1109 GNOME_Evolution_Calendar_CalListener_notifyDefaultTimezoneSet (priv->listener, status, &ev);
1111 if (BONOBO_EX (&ev))
1112 g_warning (G_STRLOC ": could not notify the listener of default timezone set");
1114 CORBA_exception_free (&ev);
1118 e_data_cal_notify_changes (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
1119 GList *adds, GList *modifies, GList *deletes)
1121 EDataCalPrivate *priv;
1122 CORBA_Environment ev;
1123 GNOME_Evolution_Calendar_CalObjChangeSeq seq;
1127 g_return_if_fail (E_IS_DATA_CAL (cal));
1130 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1132 n = g_list_length (adds) + g_list_length (modifies) + g_list_length (deletes);
1135 seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObjChange_allocbuf (n);
1138 for (l = adds; l; i++, l = l->next) {
1139 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1141 change->calobj = CORBA_string_dup (l->data);
1142 change->type = GNOME_Evolution_Calendar_ADDED;
1145 for (l = modifies; l; i++, l = l->next) {
1146 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1148 change->calobj = CORBA_string_dup (l->data);
1149 change->type = GNOME_Evolution_Calendar_MODIFIED;
1152 for (l = deletes; l; i++, l = l->next) {
1153 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1155 change->calobj = CORBA_string_dup (l->data);
1156 change->type = GNOME_Evolution_Calendar_DELETED;
1159 CORBA_exception_init (&ev);
1160 GNOME_Evolution_Calendar_CalListener_notifyChanges (priv->listener, status, &seq, &ev);
1162 CORBA_free (seq._buffer);
1164 if (BONOBO_EX (&ev))
1165 g_warning (G_STRLOC ": could not notify the listener of default timezone set");
1167 CORBA_exception_free (&ev);
1171 e_data_cal_notify_free_busy (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy)
1173 EDataCalPrivate *priv;
1174 CORBA_Environment ev;
1175 GNOME_Evolution_Calendar_CalObjSeq seq;
1179 g_return_if_fail (E_IS_DATA_CAL (cal));
1182 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1184 n = g_list_length (freebusy);
1187 seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (n);
1189 for (i = 0, l = freebusy; l; i++, l = l->next)
1190 seq._buffer[i] = CORBA_string_dup (l->data);
1192 CORBA_exception_init (&ev);
1193 GNOME_Evolution_Calendar_CalListener_notifyFreeBusy (priv->listener, status, &seq, &ev);
1195 CORBA_free (seq._buffer);
1197 if (BONOBO_EX (&ev))
1198 g_warning (G_STRLOC ": could not notify the listener of freebusy");
1200 CORBA_exception_free (&ev);
1204 * e_data_cal_notify_mode:
1205 * @cal: A calendar client interface.
1206 * @status: Status of the mode set.
1207 * @mode: The current mode.
1209 * Notifys the listener of the results of a setMode call.
1212 e_data_cal_notify_mode (EDataCal *cal,
1213 GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
1214 GNOME_Evolution_Calendar_CalMode mode)
1216 EDataCalPrivate *priv;
1217 CORBA_Environment ev;
1219 g_return_if_fail (cal != NULL);
1220 g_return_if_fail (E_IS_DATA_CAL (cal));
1223 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1225 CORBA_exception_init (&ev);
1226 GNOME_Evolution_Calendar_CalListener_notifyCalSetMode (priv->listener, status, mode, &ev);
1228 if (BONOBO_EX (&ev))
1229 g_message ("e_data_cal_notify_mode(): could not notify the listener "
1230 "about a mode change");
1232 CORBA_exception_free (&ev);
1237 e_data_cal_notify_auth_required (EDataCal *cal)
1239 EDataCalPrivate *priv;
1240 CORBA_Environment ev;
1242 g_return_if_fail (cal != NULL);
1243 g_return_if_fail (E_IS_DATA_CAL (cal));
1246 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1248 CORBA_exception_init (&ev);
1249 GNOME_Evolution_Calendar_CalListener_notifyAuthRequired (priv->listener, &ev);
1250 if (BONOBO_EX (&ev))
1251 g_message ("e_data_cal_notify_auth_required: could not notify the listener "
1252 "about auth required");
1254 CORBA_exception_free (&ev);
1258 * e_data_cal_notify_error
1259 * @cal: A calendar client interface.
1260 * @message: Error message.
1262 * Notify a calendar client of an error occurred in the backend.
1265 e_data_cal_notify_error (EDataCal *cal, const char *message)
1267 EDataCalPrivate *priv;
1268 CORBA_Environment ev;
1270 g_return_if_fail (cal != NULL);
1271 g_return_if_fail (E_IS_DATA_CAL (cal));
1272 g_return_if_fail (message != NULL);
1275 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1277 CORBA_exception_init (&ev);
1278 GNOME_Evolution_Calendar_CalListener_notifyErrorOccurred (priv->listener, (char *) message, &ev);
1280 if (BONOBO_EX (&ev))
1281 g_message ("e_data_cal_notify_remove(): could not notify the listener "
1282 "about a removed object");
1284 CORBA_exception_free (&ev);
1288 * e_data_cal_notify_categories_changed:
1289 * @cal: A calendar client interface.
1290 * @categories: List of categories.
1292 * Notifies a listener attached to a calendar client interface object about the
1293 * current set of categories in a calendar backend.
1296 e_data_cal_notify_categories_changed (EDataCal *cal, GNOME_Evolution_Calendar_StringSeq *categories)
1298 EDataCalPrivate *priv;
1299 CORBA_Environment ev;
1301 g_return_if_fail (cal != NULL);
1302 g_return_if_fail (E_IS_DATA_CAL (cal));
1303 g_return_if_fail (categories != NULL);
1306 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1308 CORBA_exception_init (&ev);
1309 GNOME_Evolution_Calendar_CalListener_notifyCategoriesChanged (priv->listener, categories, &ev);
1311 if (BONOBO_EX (&ev))
1312 g_message ("e_data_cal_notify_categories_changed(): Could not notify the listener "
1313 "about the current set of categories");
1315 CORBA_exception_free (&ev);