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;
46 /* Cal::get_uri method */
48 impl_Cal_get_uri (PortableServer_Servant servant,
49 CORBA_Environment *ev)
52 EDataCalPrivate *priv;
54 CORBA_char *str_uri_copy;
56 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
59 str_uri = e_cal_backend_get_uri (priv->backend);
60 str_uri_copy = CORBA_string_dup (str_uri);
66 impl_Cal_open (PortableServer_Servant servant,
67 CORBA_boolean only_if_exists,
68 const CORBA_char *username,
69 const CORBA_char *password,
70 CORBA_Environment *ev)
73 EDataCalPrivate *priv;
75 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
78 e_cal_backend_open (priv->backend, cal, only_if_exists, username, password);
82 impl_Cal_remove (PortableServer_Servant servant,
83 CORBA_Environment *ev)
86 EDataCalPrivate *priv;
88 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
91 e_cal_backend_remove (priv->backend, cal);
94 /* Cal::isReadOnly method */
96 impl_Cal_isReadOnly (PortableServer_Servant servant,
97 CORBA_Environment *ev)
100 EDataCalPrivate *priv;
102 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
105 e_cal_backend_is_read_only (priv->backend, cal);
108 /* Cal::getEmailAddress method */
110 impl_Cal_getCalAddress (PortableServer_Servant servant,
111 CORBA_Environment *ev)
114 EDataCalPrivate *priv;
116 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
119 e_cal_backend_get_cal_address (priv->backend, cal);
122 /* Cal::get_alarm_email_address method */
124 impl_Cal_getAlarmEmailAddress (PortableServer_Servant servant,
125 CORBA_Environment *ev)
128 EDataCalPrivate *priv;
130 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
133 e_cal_backend_get_alarm_email_address (priv->backend, cal);
136 /* Cal::get_ldap_attribute method */
138 impl_Cal_getLdapAttribute (PortableServer_Servant servant,
139 CORBA_Environment *ev)
142 EDataCalPrivate *priv;
144 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
147 e_cal_backend_get_ldap_attribute (priv->backend, cal);
150 /* Cal::getSchedulingInformation method */
152 impl_Cal_getStaticCapabilities (PortableServer_Servant servant,
153 CORBA_Environment *ev)
156 EDataCalPrivate *priv;
158 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
161 e_cal_backend_get_static_capabilities (priv->backend, cal);
164 /* Cal::setMode method */
166 impl_Cal_setMode (PortableServer_Servant servant,
167 GNOME_Evolution_Calendar_CalMode mode,
168 CORBA_Environment *ev)
171 EDataCalPrivate *priv;
173 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
176 e_cal_backend_set_mode (priv->backend, mode);
180 impl_Cal_getDefaultObject (PortableServer_Servant servant,
181 CORBA_Environment *ev)
184 EDataCalPrivate *priv;
186 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
189 e_cal_backend_get_default_object (priv->backend, cal);
192 /* Cal::getObject method */
194 impl_Cal_getObject (PortableServer_Servant servant,
195 const CORBA_char *uid,
196 const CORBA_char *rid,
197 CORBA_Environment *ev)
200 EDataCalPrivate *priv;
202 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
205 e_cal_backend_get_object (priv->backend, cal, uid, rid);
208 /* Cal::getObjectsInRange method */
210 impl_Cal_getObjectList (PortableServer_Servant servant,
211 const CORBA_char *query,
212 CORBA_Environment *ev)
215 EDataCalPrivate *priv;
217 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
220 e_cal_backend_get_object_list (priv->backend, cal, query);
223 /* Cal::getChanges method */
225 impl_Cal_getChanges (PortableServer_Servant servant,
226 const CORBA_char *change_id,
227 CORBA_Environment *ev)
230 EDataCalPrivate *priv;
232 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
235 e_cal_backend_get_changes (priv->backend, cal, change_id);
238 /* Cal::getFreeBusy method */
240 impl_Cal_getFreeBusy (PortableServer_Servant servant,
241 const GNOME_Evolution_Calendar_UserList *user_list,
242 const GNOME_Evolution_Calendar_Time_t start,
243 const GNOME_Evolution_Calendar_Time_t end,
244 CORBA_Environment *ev)
247 EDataCalPrivate *priv;
250 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
253 /* convert the CORBA user list to a GList */
257 for (i = 0; i < user_list->_length; i++)
258 users = g_list_append (users, user_list->_buffer[i]);
261 /* call the backend's get_free_busy method */
262 e_cal_backend_get_free_busy (priv->backend, cal, users, start, end);
265 /* Cal::discardAlarm method */
267 impl_Cal_discardAlarm (PortableServer_Servant servant,
268 const CORBA_char *uid,
269 const CORBA_char *auid,
270 CORBA_Environment *ev)
273 EDataCalPrivate *priv;
275 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
278 e_cal_backend_discard_alarm (priv->backend, cal, uid, auid);
282 impl_Cal_createObject (PortableServer_Servant servant,
283 const CORBA_char *calobj,
284 CORBA_Environment *ev)
287 EDataCalPrivate *priv;
289 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
292 e_cal_backend_create_object (priv->backend, cal, calobj);
296 impl_Cal_modifyObject (PortableServer_Servant servant,
297 const CORBA_char *calobj,
298 const GNOME_Evolution_Calendar_CalObjModType mod,
299 CORBA_Environment *ev)
302 EDataCalPrivate *priv;
304 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
307 e_cal_backend_modify_object (priv->backend, cal, calobj, mod);
310 /* Cal::removeObject method */
312 impl_Cal_removeObject (PortableServer_Servant servant,
313 const CORBA_char *uid,
314 const CORBA_char *rid,
315 const GNOME_Evolution_Calendar_CalObjModType mod,
316 CORBA_Environment *ev)
319 EDataCalPrivate *priv;
321 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
324 e_cal_backend_remove_object (priv->backend, cal, uid, rid, mod);
328 impl_Cal_receiveObjects (PortableServer_Servant servant,
329 const CORBA_char *calobj,
330 CORBA_Environment *ev)
333 EDataCalPrivate *priv;
335 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
338 e_cal_backend_receive_objects (priv->backend, cal, calobj);
342 impl_Cal_sendObjects (PortableServer_Servant servant,
343 const CORBA_char *calobj,
344 CORBA_Environment *ev)
347 EDataCalPrivate *priv;
349 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
352 e_cal_backend_send_objects (priv->backend, cal, calobj);
355 /* Cal::getQuery implementation */
357 impl_Cal_getQuery (PortableServer_Servant servant,
358 const CORBA_char *sexp,
359 GNOME_Evolution_Calendar_CalViewListener ql,
360 CORBA_Environment *ev)
364 EDataCalPrivate *priv;
366 ECalBackendSExp *obj_sexp;
368 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
371 /* we handle this entirely here, since it doesn't require any
372 backend involvement now that we have pas_book_view_start to
373 actually kick off the search. */
375 obj_sexp = e_cal_backend_sexp_new (sexp);
377 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_InvalidQuery, NULL);
382 query = e_data_cal_view_new (priv->backend, ql, obj_sexp);
384 g_object_unref (obj_sexp);
385 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_OtherError, NULL);
390 e_cal_backend_add_query (priv->backend, query);
392 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
394 g_object_unref (query);
398 /* Cal::getTimezone method */
400 impl_Cal_getTimezone (PortableServer_Servant servant,
401 const CORBA_char *tzid,
402 CORBA_Environment *ev)
405 EDataCalPrivate *priv;
407 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
410 e_cal_backend_get_timezone (priv->backend, cal, tzid);
413 /* Cal::addTimezone method */
415 impl_Cal_addTimezone (PortableServer_Servant servant,
416 const CORBA_char *tz,
417 CORBA_Environment *ev)
420 EDataCalPrivate *priv;
422 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
425 e_cal_backend_add_timezone (priv->backend, cal, tz);
428 /* Cal::setDefaultTimezone method */
430 impl_Cal_setDefaultTimezone (PortableServer_Servant servant,
431 const CORBA_char *tzid,
432 CORBA_Environment *ev)
435 EDataCalPrivate *priv;
437 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
440 e_cal_backend_set_default_timezone (priv->backend, cal, tzid);
445 * @cal: A calendar client interface.
446 * @corba_cal: CORBA object for the calendar.
447 * @backend: Calendar backend that this @cal presents an interface to.
448 * @listener: Calendar listener for notification.
450 * Constructs a calendar client interface object by binding the corresponding
451 * CORBA object to it. The calendar interface is bound to the specified
452 * @backend, and will notify the @listener about changes to the calendar.
454 * Return value: The same object as the @cal argument.
457 e_data_cal_construct (EDataCal *cal,
458 ECalBackend *backend,
459 GNOME_Evolution_Calendar_CalListener listener)
461 EDataCalPrivate *priv;
462 CORBA_Environment ev;
464 g_return_val_if_fail (cal != NULL, NULL);
465 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
466 g_return_val_if_fail (backend != NULL, NULL);
467 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
471 CORBA_exception_init (&ev);
472 priv->listener = CORBA_Object_duplicate (listener, &ev);
473 if (BONOBO_EX (&ev)) {
474 g_message ("cal_construct: could not duplicate the listener");
475 priv->listener = CORBA_OBJECT_NIL;
476 CORBA_exception_free (&ev);
480 CORBA_exception_free (&ev);
482 priv->backend = backend;
489 * @backend: A calendar backend.
490 * @listener: A calendar listener.
492 * Creates a new calendar client interface object and binds it to the
493 * specified @backend and @listener objects.
495 * Return value: A newly-created #EDataCal calendar client interface
496 * object, or %NULL if its corresponding CORBA object could not be
500 e_data_cal_new (ECalBackend *backend, const char *uri, GNOME_Evolution_Calendar_CalListener listener)
502 EDataCal *cal, *retval;
504 g_return_val_if_fail (backend != NULL, NULL);
505 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
507 cal = E_DATA_CAL (g_object_new (E_TYPE_DATA_CAL,
508 "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
511 retval = e_data_cal_construct (cal, backend, listener);
513 g_message (G_STRLOC ": could not construct the calendar client interface");
514 bonobo_object_unref (BONOBO_OBJECT (cal));
522 e_data_cal_get_backend (EDataCal *cal)
524 g_return_val_if_fail (cal != NULL, NULL);
525 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
527 return cal->priv->backend;
530 GNOME_Evolution_Calendar_CalListener
531 e_data_cal_get_listener (EDataCal *cal)
533 g_return_val_if_fail (cal != NULL, NULL);
534 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
536 return cal->priv->listener;
539 /* Destroy handler for the calendar */
541 cal_finalize (GObject *object)
544 EDataCalPrivate *priv;
545 CORBA_Environment ev;
547 g_return_if_fail (object != NULL);
548 g_return_if_fail (E_IS_DATA_CAL (object));
550 cal = E_DATA_CAL (object);
553 priv->backend = NULL;
555 CORBA_exception_init (&ev);
556 bonobo_object_release_unref (priv->listener, &ev);
558 g_message (G_STRLOC ": could not release the listener");
560 priv->listener = NULL;
561 CORBA_exception_free (&ev);
565 if (G_OBJECT_CLASS (parent_class)->finalize)
566 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
571 /* Class initialization function for the calendar */
573 e_data_cal_class_init (EDataCalClass *klass)
575 GObjectClass *object_class = (GObjectClass *) klass;
576 POA_GNOME_Evolution_Calendar_Cal__epv *epv = &klass->epv;
578 parent_class = g_type_class_peek_parent (klass);
580 /* Class method overrides */
581 object_class->finalize = cal_finalize;
584 epv->_get_uri = impl_Cal_get_uri;
585 epv->open = impl_Cal_open;
586 epv->remove = impl_Cal_remove;
587 epv->isReadOnly = impl_Cal_isReadOnly;
588 epv->getCalAddress = impl_Cal_getCalAddress;
589 epv->getAlarmEmailAddress = impl_Cal_getAlarmEmailAddress;
590 epv->getLdapAttribute = impl_Cal_getLdapAttribute;
591 epv->getStaticCapabilities = impl_Cal_getStaticCapabilities;
592 epv->setMode = impl_Cal_setMode;
593 epv->getDefaultObject = impl_Cal_getDefaultObject;
594 epv->getObject = impl_Cal_getObject;
595 epv->getTimezone = impl_Cal_getTimezone;
596 epv->addTimezone = impl_Cal_addTimezone;
597 epv->setDefaultTimezone = impl_Cal_setDefaultTimezone;
598 epv->getObjectList = impl_Cal_getObjectList;
599 epv->getChanges = impl_Cal_getChanges;
600 epv->getFreeBusy = impl_Cal_getFreeBusy;
601 epv->discardAlarm = impl_Cal_discardAlarm;
602 epv->createObject = impl_Cal_createObject;
603 epv->modifyObject = impl_Cal_modifyObject;
604 epv->removeObject = impl_Cal_removeObject;
605 epv->receiveObjects = impl_Cal_receiveObjects;
606 epv->sendObjects = impl_Cal_sendObjects;
607 epv->getQuery = impl_Cal_getQuery;
611 /* Object initialization function for the calendar */
613 e_data_cal_init (EDataCal *cal, EDataCalClass *klass)
615 EDataCalPrivate *priv;
617 priv = g_new0 (EDataCalPrivate, 1);
620 priv->listener = CORBA_OBJECT_NIL;
623 BONOBO_TYPE_FUNC_FULL (EDataCal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, e_data_cal);
626 e_data_cal_notify_read_only (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only)
628 EDataCalPrivate *priv;
629 CORBA_Environment ev;
631 g_return_if_fail (cal != NULL);
632 g_return_if_fail (E_IS_DATA_CAL (cal));
635 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
637 CORBA_exception_init (&ev);
638 GNOME_Evolution_Calendar_CalListener_notifyReadOnly (priv->listener, status, read_only, &ev);
641 g_message (G_STRLOC ": could not notify the listener of read only");
643 CORBA_exception_free (&ev);
647 e_data_cal_notify_cal_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
649 EDataCalPrivate *priv;
650 CORBA_Environment ev;
652 g_return_if_fail (cal != NULL);
653 g_return_if_fail (E_IS_DATA_CAL (cal));
656 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
658 CORBA_exception_init (&ev);
659 GNOME_Evolution_Calendar_CalListener_notifyCalAddress (priv->listener, status, address ? address : "", &ev);
662 g_message (G_STRLOC ": could not notify the listener of cal address");
664 CORBA_exception_free (&ev);
668 e_data_cal_notify_alarm_email_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
670 EDataCalPrivate *priv;
671 CORBA_Environment ev;
673 g_return_if_fail (cal != NULL);
674 g_return_if_fail (E_IS_DATA_CAL (cal));
677 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
679 CORBA_exception_init (&ev);
680 GNOME_Evolution_Calendar_CalListener_notifyAlarmEmailAddress (priv->listener, status, address ? address : "", &ev);
683 g_message (G_STRLOC ": could not notify the listener of alarm address");
685 CORBA_exception_free (&ev);
689 e_data_cal_notify_ldap_attribute (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *attribute)
691 EDataCalPrivate *priv;
692 CORBA_Environment ev;
694 g_return_if_fail (cal != NULL);
695 g_return_if_fail (E_IS_DATA_CAL (cal));
698 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
700 CORBA_exception_init (&ev);
701 GNOME_Evolution_Calendar_CalListener_notifyLDAPAttribute (priv->listener, status, attribute ? attribute : "", &ev);
704 g_message (G_STRLOC ": could not notify the listener of ldap attribute");
706 CORBA_exception_free (&ev);
710 e_data_cal_notify_static_capabilities (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *capabilities)
712 EDataCalPrivate *priv;
713 CORBA_Environment ev;
715 g_return_if_fail (cal != NULL);
716 g_return_if_fail (E_IS_DATA_CAL (cal));
719 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
721 CORBA_exception_init (&ev);
722 GNOME_Evolution_Calendar_CalListener_notifyStaticCapabilities (priv->listener, status,
723 capabilities ? capabilities : "", &ev);
726 g_message (G_STRLOC ": could not notify the listener of static capabilities");
728 CORBA_exception_free (&ev);
732 e_data_cal_notify_open (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
734 EDataCalPrivate *priv;
735 CORBA_Environment ev;
737 g_return_if_fail (cal != NULL);
738 g_return_if_fail (E_IS_DATA_CAL (cal));
741 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
743 CORBA_exception_init (&ev);
744 GNOME_Evolution_Calendar_CalListener_notifyCalOpened (priv->listener, status, &ev);
747 g_message (G_STRLOC ": could not notify the listener of open");
749 CORBA_exception_free (&ev);
753 e_data_cal_notify_remove (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
755 EDataCalPrivate *priv;
756 CORBA_Environment ev;
758 g_return_if_fail (cal != NULL);
759 g_return_if_fail (E_IS_DATA_CAL (cal));
762 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
764 CORBA_exception_init (&ev);
765 GNOME_Evolution_Calendar_CalListener_notifyCalRemoved (priv->listener, status, &ev);
768 g_message (G_STRLOC ": could not notify the listener of remove");
770 CORBA_exception_free (&ev);
774 e_data_cal_notify_object_created (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
775 const char *uid, const char *object)
777 EDataCalPrivate *priv;
778 CORBA_Environment ev;
780 g_return_if_fail (cal != NULL);
781 g_return_if_fail (E_IS_DATA_CAL (cal));
784 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
786 if (status == GNOME_Evolution_Calendar_Success)
787 e_cal_backend_notify_object_created (priv->backend, object);
789 CORBA_exception_init (&ev);
790 GNOME_Evolution_Calendar_CalListener_notifyObjectCreated (priv->listener, status, uid ? uid : "", &ev);
793 g_message (G_STRLOC ": could not notify the listener of object creation");
795 CORBA_exception_free (&ev);
799 e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
800 const char *old_object, const char *object)
802 EDataCalPrivate *priv;
803 CORBA_Environment ev;
805 g_return_if_fail (cal != NULL);
806 g_return_if_fail (E_IS_DATA_CAL (cal));
809 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
811 if (status == GNOME_Evolution_Calendar_Success)
812 e_cal_backend_notify_object_modified (priv->backend, old_object, object);
814 CORBA_exception_init (&ev);
815 GNOME_Evolution_Calendar_CalListener_notifyObjectModified (priv->listener, status, &ev);
818 g_message (G_STRLOC ": could not notify the listener of object creation");
820 CORBA_exception_free (&ev);
824 e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
825 const char *uid, const char *object)
827 EDataCalPrivate *priv;
828 CORBA_Environment ev;
830 g_return_if_fail (cal != NULL);
831 g_return_if_fail (E_IS_DATA_CAL (cal));
834 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
836 if (status == GNOME_Evolution_Calendar_Success)
837 e_cal_backend_notify_object_removed (priv->backend, uid, object);
839 CORBA_exception_init (&ev);
840 GNOME_Evolution_Calendar_CalListener_notifyObjectRemoved (priv->listener, status, &ev);
843 g_message (G_STRLOC ": could not notify the listener of object removal");
845 CORBA_exception_free (&ev);
849 e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
851 EDataCalPrivate *priv;
852 CORBA_Environment ev;
854 g_return_if_fail (cal != NULL);
855 g_return_if_fail (E_IS_DATA_CAL (cal));
858 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
860 CORBA_exception_init (&ev);
861 GNOME_Evolution_Calendar_CalListener_notifyObjectsReceived (priv->listener, status, &ev);
864 g_message (G_STRLOC ": could not notify the listener of objects received");
866 CORBA_exception_free (&ev);
870 e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
872 EDataCalPrivate *priv;
873 CORBA_Environment ev;
875 g_return_if_fail (cal != NULL);
876 g_return_if_fail (E_IS_DATA_CAL (cal));
879 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
881 CORBA_exception_init (&ev);
882 GNOME_Evolution_Calendar_CalListener_notifyAlarmDiscarded (priv->listener, status, &ev);
885 g_message (G_STRLOC ": could not notify the listener of alarm discarded");
887 CORBA_exception_free (&ev);
891 e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *users, const char *calobj)
893 EDataCalPrivate *priv;
894 CORBA_Environment ev;
895 GNOME_Evolution_Calendar_UserList *corba_users;
897 g_return_if_fail (cal != NULL);
898 g_return_if_fail (E_IS_DATA_CAL (cal));
901 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
903 corba_users = GNOME_Evolution_Calendar_UserList__alloc ();
904 corba_users->_length = g_list_length (users);
909 corba_users->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (corba_users->_length);
910 for (l = users, n = 0; l != NULL; l = l->next, n++)
911 corba_users->_buffer[n] = CORBA_string_dup (l->data);
914 CORBA_exception_init (&ev);
915 GNOME_Evolution_Calendar_CalListener_notifyObjectsSent (priv->listener, status, corba_users,
916 calobj ? calobj : "", &ev);
919 g_message (G_STRLOC ": could not notify the listener of objects sent");
921 CORBA_exception_free (&ev);
922 CORBA_free (corba_users);
926 e_data_cal_notify_default_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
928 EDataCalPrivate *priv;
929 CORBA_Environment ev;
931 g_return_if_fail (cal != NULL);
932 g_return_if_fail (E_IS_DATA_CAL (cal));
935 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
937 CORBA_exception_init (&ev);
939 GNOME_Evolution_Calendar_CalListener_notifyDefaultObjectRequested (priv->listener, status,
940 object ? object : "", &ev);
943 g_message (G_STRLOC ": could not notify the listener of default object");
945 CORBA_exception_free (&ev);
949 e_data_cal_notify_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
951 EDataCalPrivate *priv;
952 CORBA_Environment ev;
954 g_return_if_fail (cal != NULL);
955 g_return_if_fail (E_IS_DATA_CAL (cal));
958 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
960 CORBA_exception_init (&ev);
962 GNOME_Evolution_Calendar_CalListener_notifyObjectRequested (priv->listener, status,
963 object ? object : "", &ev);
966 g_message (G_STRLOC ": could not notify the listener of object");
968 CORBA_exception_free (&ev);
972 e_data_cal_notify_object_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects)
974 EDataCalPrivate *priv;
975 CORBA_Environment ev;
976 GNOME_Evolution_Calendar_stringlist seq;
980 g_return_if_fail (cal != NULL);
981 g_return_if_fail (E_IS_DATA_CAL (cal));
984 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
986 CORBA_exception_init (&ev);
988 seq._maximum = g_list_length (objects);
990 seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
992 for (l = objects, i = 0; l; l = l->next, i++) {
993 seq._buffer[i] = CORBA_string_dup (l->data);
997 GNOME_Evolution_Calendar_CalListener_notifyObjectListRequested (priv->listener, status, &seq, &ev);
1000 g_message (G_STRLOC ": could not notify the listener of object list");
1002 CORBA_exception_free (&ev);
1004 CORBA_free(seq._buffer);
1008 e_data_cal_notify_query (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, EDataCalView *query)
1010 EDataCalPrivate *priv;
1011 CORBA_Environment ev;
1013 g_return_if_fail (cal != NULL);
1014 g_return_if_fail (E_IS_DATA_CAL (cal));
1017 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1019 CORBA_exception_init (&ev);
1020 GNOME_Evolution_Calendar_CalListener_notifyQuery (priv->listener, status, BONOBO_OBJREF (query), &ev);
1022 if (BONOBO_EX (&ev))
1023 g_message (G_STRLOC ": could not notify the listener of query");
1025 CORBA_exception_free (&ev);
1029 e_data_cal_notify_timezone_requested (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
1031 EDataCalPrivate *priv;
1032 CORBA_Environment ev;
1034 g_return_if_fail (E_IS_DATA_CAL (cal));
1037 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1039 CORBA_exception_init (&ev);
1040 GNOME_Evolution_Calendar_CalListener_notifyTimezoneRequested (priv->listener, status, object ? object : "", &ev);
1042 if (BONOBO_EX (&ev))
1043 g_warning (G_STRLOC ": could not notify the listener of timezone requested");
1045 CORBA_exception_free (&ev);
1049 e_data_cal_notify_timezone_added (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *tzid)
1051 EDataCalPrivate *priv;
1052 CORBA_Environment ev;
1054 g_return_if_fail (E_IS_DATA_CAL (cal));
1057 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1059 CORBA_exception_init (&ev);
1060 GNOME_Evolution_Calendar_CalListener_notifyTimezoneAdded (priv->listener, status, tzid ? tzid : "", &ev);
1062 if (BONOBO_EX (&ev))
1063 g_warning (G_STRLOC ": could not notify the listener of timezone added");
1065 CORBA_exception_free (&ev);
1069 e_data_cal_notify_default_timezone_set (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
1071 EDataCalPrivate *priv;
1072 CORBA_Environment ev;
1074 g_return_if_fail (E_IS_DATA_CAL (cal));
1077 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1079 CORBA_exception_init (&ev);
1080 GNOME_Evolution_Calendar_CalListener_notifyDefaultTimezoneSet (priv->listener, status, &ev);
1082 if (BONOBO_EX (&ev))
1083 g_warning (G_STRLOC ": could not notify the listener of default timezone set");
1085 CORBA_exception_free (&ev);
1089 e_data_cal_notify_changes (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
1090 GList *adds, GList *modifies, GList *deletes)
1092 EDataCalPrivate *priv;
1093 CORBA_Environment ev;
1094 GNOME_Evolution_Calendar_CalObjChangeSeq seq;
1098 g_return_if_fail (E_IS_DATA_CAL (cal));
1101 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1103 n = g_list_length (adds) + g_list_length (modifies) + g_list_length (deletes);
1106 seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObjChange_allocbuf (n);
1109 for (l = adds; l; i++, l = l->next) {
1110 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1112 change->calobj = CORBA_string_dup (l->data);
1113 change->type = GNOME_Evolution_Calendar_ADDED;
1116 for (l = modifies; l; i++, l = l->next) {
1117 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1119 change->calobj = CORBA_string_dup (l->data);
1120 change->type = GNOME_Evolution_Calendar_MODIFIED;
1123 for (l = deletes; l; i++, l = l->next) {
1124 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1126 change->calobj = CORBA_string_dup (l->data);
1127 change->type = GNOME_Evolution_Calendar_DELETED;
1130 CORBA_exception_init (&ev);
1131 GNOME_Evolution_Calendar_CalListener_notifyChanges (priv->listener, status, &seq, &ev);
1133 CORBA_free (seq._buffer);
1135 if (BONOBO_EX (&ev))
1136 g_warning (G_STRLOC ": could not notify the listener of default timezone set");
1138 CORBA_exception_free (&ev);
1142 e_data_cal_notify_free_busy (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy)
1144 EDataCalPrivate *priv;
1145 CORBA_Environment ev;
1146 GNOME_Evolution_Calendar_CalObjSeq seq;
1150 g_return_if_fail (E_IS_DATA_CAL (cal));
1153 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1155 n = g_list_length (freebusy);
1158 seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (n);
1160 for (i = 0, l = freebusy; l; i++, l = l->next)
1161 seq._buffer[i] = CORBA_string_dup (l->data);
1163 CORBA_exception_init (&ev);
1164 GNOME_Evolution_Calendar_CalListener_notifyFreeBusy (priv->listener, status, &seq, &ev);
1166 CORBA_free (seq._buffer);
1168 if (BONOBO_EX (&ev))
1169 g_warning (G_STRLOC ": could not notify the listener of freebusy");
1171 CORBA_exception_free (&ev);
1175 * e_data_cal_notify_mode:
1176 * @cal: A calendar client interface.
1177 * @status: Status of the mode set.
1178 * @mode: The current mode.
1180 * Notifys the listener of the results of a setMode call.
1183 e_data_cal_notify_mode (EDataCal *cal,
1184 GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
1185 GNOME_Evolution_Calendar_CalMode mode)
1187 EDataCalPrivate *priv;
1188 CORBA_Environment ev;
1190 g_return_if_fail (cal != NULL);
1191 g_return_if_fail (E_IS_DATA_CAL (cal));
1194 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1196 CORBA_exception_init (&ev);
1197 GNOME_Evolution_Calendar_CalListener_notifyCalSetMode (priv->listener, status, mode, &ev);
1199 if (BONOBO_EX (&ev))
1200 g_message ("e_data_cal_notify_mode(): could not notify the listener "
1201 "about a mode change");
1203 CORBA_exception_free (&ev);
1207 * e_data_cal_notify_error
1208 * @cal: A calendar client interface.
1209 * @message: Error message.
1211 * Notify a calendar client of an error occurred in the backend.
1214 e_data_cal_notify_error (EDataCal *cal, const char *message)
1216 EDataCalPrivate *priv;
1217 CORBA_Environment ev;
1219 g_return_if_fail (cal != NULL);
1220 g_return_if_fail (E_IS_DATA_CAL (cal));
1221 g_return_if_fail (message != NULL);
1224 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1226 CORBA_exception_init (&ev);
1227 GNOME_Evolution_Calendar_CalListener_notifyErrorOccurred (priv->listener, (char *) message, &ev);
1229 if (BONOBO_EX (&ev))
1230 g_message ("e_data_cal_notify_remove(): could not notify the listener "
1231 "about a removed object");
1233 CORBA_exception_free (&ev);
1237 * e_data_cal_notify_categories_changed:
1238 * @cal: A calendar client interface.
1239 * @categories: List of categories.
1241 * Notifies a listener attached to a calendar client interface object about the
1242 * current set of categories in a calendar backend.
1245 e_data_cal_notify_categories_changed (EDataCal *cal, GNOME_Evolution_Calendar_StringSeq *categories)
1247 EDataCalPrivate *priv;
1248 CORBA_Environment ev;
1250 g_return_if_fail (cal != NULL);
1251 g_return_if_fail (E_IS_DATA_CAL (cal));
1252 g_return_if_fail (categories != NULL);
1255 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1257 CORBA_exception_init (&ev);
1258 GNOME_Evolution_Calendar_CalListener_notifyCategoriesChanged (priv->listener, categories, &ev);
1260 if (BONOBO_EX (&ev))
1261 g_message ("e_data_cal_notify_categories_changed(): Could not notify the listener "
1262 "about the current set of categories");
1264 CORBA_exception_free (&ev);