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 Lesser 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 Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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::getAttachmentList method */
241 impl_Cal_getAttachmentList (PortableServer_Servant servant,
242 const CORBA_char *uid,
243 const CORBA_char *rid,
244 CORBA_Environment *ev)
247 EDataCalPrivate *priv;
249 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
252 e_cal_backend_get_attachment_list (priv->backend, cal, uid, rid);
255 /* Cal::getChanges method */
257 impl_Cal_getChanges (PortableServer_Servant servant,
258 const CORBA_char *change_id,
259 CORBA_Environment *ev)
262 EDataCalPrivate *priv;
264 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
267 e_cal_backend_get_changes (priv->backend, cal, change_id);
270 /* Cal::getFreeBusy method */
272 impl_Cal_getFreeBusy (PortableServer_Servant servant,
273 const GNOME_Evolution_Calendar_UserList *user_list,
274 const GNOME_Evolution_Calendar_Time_t start,
275 const GNOME_Evolution_Calendar_Time_t end,
276 CORBA_Environment *ev)
279 EDataCalPrivate *priv;
282 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
285 /* convert the CORBA user list to a GList */
289 for (i = 0; i < user_list->_length; i++)
290 users = g_list_append (users, user_list->_buffer[i]);
293 /* call the backend's get_free_busy method */
294 e_cal_backend_get_free_busy (priv->backend, cal, users, start, end);
297 /* Cal::discardAlarm method */
299 impl_Cal_discardAlarm (PortableServer_Servant servant,
300 const CORBA_char *uid,
301 const CORBA_char *auid,
302 CORBA_Environment *ev)
305 EDataCalPrivate *priv;
307 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
310 e_cal_backend_discard_alarm (priv->backend, cal, uid, auid);
314 impl_Cal_createObject (PortableServer_Servant servant,
315 const CORBA_char *calobj,
316 CORBA_Environment *ev)
319 EDataCalPrivate *priv;
321 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
324 e_cal_backend_create_object (priv->backend, cal, calobj);
328 impl_Cal_modifyObject (PortableServer_Servant servant,
329 const CORBA_char *calobj,
330 const GNOME_Evolution_Calendar_CalObjModType mod,
331 CORBA_Environment *ev)
334 EDataCalPrivate *priv;
336 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
339 e_cal_backend_modify_object (priv->backend, cal, calobj, mod);
342 /* Cal::removeObject method */
344 impl_Cal_removeObject (PortableServer_Servant servant,
345 const CORBA_char *uid,
346 const CORBA_char *rid,
347 const GNOME_Evolution_Calendar_CalObjModType mod,
348 CORBA_Environment *ev)
351 EDataCalPrivate *priv;
353 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
356 e_cal_backend_remove_object (priv->backend, cal, uid, rid, mod);
360 impl_Cal_receiveObjects (PortableServer_Servant servant,
361 const CORBA_char *calobj,
362 CORBA_Environment *ev)
365 EDataCalPrivate *priv;
367 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
370 e_cal_backend_receive_objects (priv->backend, cal, calobj);
374 impl_Cal_sendObjects (PortableServer_Servant servant,
375 const CORBA_char *calobj,
376 CORBA_Environment *ev)
379 EDataCalPrivate *priv;
381 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
384 e_cal_backend_send_objects (priv->backend, cal, calobj);
387 /* Cal::getQuery implementation */
389 impl_Cal_getQuery (PortableServer_Servant servant,
390 const CORBA_char *sexp,
391 GNOME_Evolution_Calendar_CalViewListener ql,
392 CORBA_Environment *ev)
396 EDataCalPrivate *priv;
398 ECalBackendSExp *obj_sexp;
400 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
403 /* first see if we already have the query in the cache */
404 query = g_hash_table_lookup (priv->live_queries, sexp);
406 e_data_cal_view_add_listener (query, ql);
407 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
411 /* we handle this entirely here, since it doesn't require any
412 backend involvement now that we have e_cal_view_start to
413 actually kick off the search. */
415 obj_sexp = e_cal_backend_sexp_new (sexp);
417 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_InvalidQuery, NULL);
422 query = e_data_cal_view_new (priv->backend, ql, obj_sexp);
424 g_object_unref (obj_sexp);
425 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_OtherError, NULL);
430 g_hash_table_insert (priv->live_queries, g_strdup (sexp), query);
431 e_cal_backend_add_query (priv->backend, query);
433 e_data_cal_notify_query (cal, GNOME_Evolution_Calendar_Success, query);
437 /* Cal::getTimezone method */
439 impl_Cal_getTimezone (PortableServer_Servant servant,
440 const CORBA_char *tzid,
441 CORBA_Environment *ev)
444 EDataCalPrivate *priv;
446 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
449 e_cal_backend_get_timezone (priv->backend, cal, tzid);
452 /* Cal::addTimezone method */
454 impl_Cal_addTimezone (PortableServer_Servant servant,
455 const CORBA_char *tz,
456 CORBA_Environment *ev)
459 EDataCalPrivate *priv;
461 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
464 e_cal_backend_add_timezone (priv->backend, cal, tz);
467 /* Cal::setDefaultTimezone method */
469 impl_Cal_setDefaultTimezone (PortableServer_Servant servant,
470 const CORBA_char *tz,
471 CORBA_Environment *ev)
474 EDataCalPrivate *priv;
476 cal = E_DATA_CAL (bonobo_object_from_servant (servant));
479 e_cal_backend_set_default_zone (priv->backend, cal, tz);
483 * e_data_cal_construct:
484 * @cal: A calendar client interface.
485 * @backend: Calendar backend that this @cal presents an interface to.
486 * @listener: Calendar listener for notification.
488 * Constructs a calendar client interface object by binding the corresponding
489 * CORBA object to it. The calendar interface is bound to the specified
490 * @backend, and will notify the @listener about changes to the calendar.
492 * Return value: The same object as the @cal argument.
495 e_data_cal_construct (EDataCal *cal,
496 ECalBackend *backend,
497 GNOME_Evolution_Calendar_CalListener listener)
499 EDataCalPrivate *priv;
500 CORBA_Environment ev;
502 g_return_val_if_fail (cal != NULL, NULL);
503 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
504 g_return_val_if_fail (backend != NULL, NULL);
505 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
509 CORBA_exception_init (&ev);
510 priv->listener = CORBA_Object_duplicate (listener, &ev);
511 if (BONOBO_EX (&ev)) {
512 g_message ("cal_construct: could not duplicate the listener");
513 priv->listener = CORBA_OBJECT_NIL;
514 CORBA_exception_free (&ev);
518 CORBA_exception_free (&ev);
520 priv->backend = backend;
527 * @backend: A calendar backend.
528 * @listener: A calendar listener.
530 * Creates a new calendar client interface object and binds it to the
531 * specified @backend and @listener objects.
533 * Return value: A newly-created #EDataCal calendar client interface
534 * object, or %NULL if its corresponding CORBA object could not be
538 e_data_cal_new (ECalBackend *backend, GNOME_Evolution_Calendar_CalListener listener)
540 EDataCal *cal, *retval;
542 g_return_val_if_fail (backend != NULL, NULL);
543 g_return_val_if_fail (E_IS_CAL_BACKEND (backend), NULL);
545 cal = E_DATA_CAL (g_object_new (E_TYPE_DATA_CAL,
546 "poa", bonobo_poa_get_threaded (ORBIT_THREAD_HINT_PER_REQUEST, NULL),
549 retval = e_data_cal_construct (cal, backend, listener);
551 g_message (G_STRLOC ": could not construct the calendar client interface");
552 bonobo_object_unref (BONOBO_OBJECT (cal));
560 * e_data_cal_get_backend:
561 * @cal: A calendar client interface.
563 * Gets the associated backend.
565 * Return value: An #ECalBackend.
568 e_data_cal_get_backend (EDataCal *cal)
570 g_return_val_if_fail (cal != NULL, NULL);
571 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
573 return cal->priv->backend;
577 * e_data_cal_get_listener:
578 * @cal: A calendar client interface.
580 * Gets the listener associated with a calendar client interface.
582 * Return value: The listener.
584 GNOME_Evolution_Calendar_CalListener
585 e_data_cal_get_listener (EDataCal *cal)
587 g_return_val_if_fail (cal != NULL, NULL);
588 g_return_val_if_fail (E_IS_DATA_CAL (cal), NULL);
590 return cal->priv->listener;
593 /* Destroy handler for the calendar */
595 e_data_cal_finalize (GObject *object)
598 EDataCalPrivate *priv;
599 CORBA_Environment ev;
601 g_return_if_fail (object != NULL);
602 g_return_if_fail (E_IS_DATA_CAL (object));
604 cal = E_DATA_CAL (object);
607 priv->backend = NULL;
609 CORBA_exception_init (&ev);
610 bonobo_object_release_unref (priv->listener, &ev);
612 g_message (G_STRLOC ": could not release the listener");
614 priv->listener = NULL;
615 CORBA_exception_free (&ev);
617 g_hash_table_destroy (priv->live_queries);
618 priv->live_queries = NULL;
622 if (G_OBJECT_CLASS (parent_class)->finalize)
623 (* G_OBJECT_CLASS (parent_class)->finalize) (object);
628 /* Class initialization function for the calendar */
630 e_data_cal_class_init (EDataCalClass *klass)
632 GObjectClass *object_class = (GObjectClass *) klass;
633 POA_GNOME_Evolution_Calendar_Cal__epv *epv = &klass->epv;
635 parent_class = g_type_class_peek_parent (klass);
637 /* Class method overrides */
638 object_class->finalize = e_data_cal_finalize;
641 epv->_get_uri = impl_Cal_get_uri;
642 epv->open = impl_Cal_open;
643 epv->remove = impl_Cal_remove;
644 epv->isReadOnly = impl_Cal_isReadOnly;
645 epv->getCalAddress = impl_Cal_getCalAddress;
646 epv->getAlarmEmailAddress = impl_Cal_getAlarmEmailAddress;
647 epv->getLdapAttribute = impl_Cal_getLdapAttribute;
648 epv->getStaticCapabilities = impl_Cal_getStaticCapabilities;
649 epv->setMode = impl_Cal_setMode;
650 epv->getDefaultObject = impl_Cal_getDefaultObject;
651 epv->getObject = impl_Cal_getObject;
652 epv->getTimezone = impl_Cal_getTimezone;
653 epv->addTimezone = impl_Cal_addTimezone;
654 epv->setDefaultTimezone = impl_Cal_setDefaultTimezone;
655 epv->getObjectList = impl_Cal_getObjectList;
656 epv->getAttachmentList = impl_Cal_getAttachmentList;
657 epv->getChanges = impl_Cal_getChanges;
658 epv->getFreeBusy = impl_Cal_getFreeBusy;
659 epv->discardAlarm = impl_Cal_discardAlarm;
660 epv->createObject = impl_Cal_createObject;
661 epv->modifyObject = impl_Cal_modifyObject;
662 epv->removeObject = impl_Cal_removeObject;
663 epv->receiveObjects = impl_Cal_receiveObjects;
664 epv->sendObjects = impl_Cal_sendObjects;
665 epv->getQuery = impl_Cal_getQuery;
669 /* Object initialization function for the calendar */
671 e_data_cal_init (EDataCal *cal, EDataCalClass *klass)
673 EDataCalPrivate *priv;
675 priv = g_new0 (EDataCalPrivate, 1);
678 priv->listener = CORBA_OBJECT_NIL;
679 priv->live_queries = g_hash_table_new_full (g_str_hash, g_str_equal,
680 (GDestroyNotify) g_free,
681 (GDestroyNotify) g_object_unref);
684 BONOBO_TYPE_FUNC_FULL (EDataCal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, e_data_cal);
687 * e_data_cal_notify_read_only:
688 * @cal: A calendar client interface.
689 * @status: Status code.
690 * @read_only: Read only value.
692 * Notifies listeners of the completion of the is_read_only method call.
695 e_data_cal_notify_read_only (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, gboolean read_only)
697 EDataCalPrivate *priv;
698 CORBA_Environment ev;
700 g_return_if_fail (cal != NULL);
701 g_return_if_fail (E_IS_DATA_CAL (cal));
704 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
706 CORBA_exception_init (&ev);
707 GNOME_Evolution_Calendar_CalListener_notifyReadOnly (priv->listener, status, read_only, &ev);
710 g_message (G_STRLOC ": could not notify the listener of read only");
712 CORBA_exception_free (&ev);
716 * e_data_cal_notify_cal_address:
717 * @cal: A calendar client interface.
718 * @status: Status code.
719 * @address: Calendar address.
721 * Notifies listeners of the completion of the get_cal_address method call.
724 e_data_cal_notify_cal_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
726 EDataCalPrivate *priv;
727 CORBA_Environment ev;
729 g_return_if_fail (cal != NULL);
730 g_return_if_fail (E_IS_DATA_CAL (cal));
733 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
735 CORBA_exception_init (&ev);
736 GNOME_Evolution_Calendar_CalListener_notifyCalAddress (priv->listener, status, address ? address : "", &ev);
739 g_message (G_STRLOC ": could not notify the listener of cal address");
741 CORBA_exception_free (&ev);
745 * e_data_cal_notify_alarm_email_address:
746 * @cal: A calendar client interface.
747 * @status: Status code.
748 * @address: Alarm email address.
750 * Notifies listeners of the completion of the get_alarm_email_address method call.
753 e_data_cal_notify_alarm_email_address (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *address)
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_notifyAlarmEmailAddress (priv->listener, status, address ? address : "", &ev);
768 g_message (G_STRLOC ": could not notify the listener of alarm address");
770 CORBA_exception_free (&ev);
774 * e_data_cal_notify_ldap_attribute:
775 * @cal: A calendar client interface.
776 * @status: Status code.
777 * @attibute: LDAP attribute.
779 * Notifies listeners of the completion of the get_ldap_attribute method call.
782 e_data_cal_notify_ldap_attribute (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *attribute)
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_notifyLDAPAttribute (priv->listener, status, attribute ? attribute : "", &ev);
797 g_message (G_STRLOC ": could not notify the listener of ldap attribute");
799 CORBA_exception_free (&ev);
803 * e_data_cal_notify_static_capabilities:
804 * @cal: A calendar client interface.
805 * @status: Status code.
806 * @capabilities: Static capabilities from the backend.
808 * Notifies listeners of the completion of the get_static_capabilities method call.
811 e_data_cal_notify_static_capabilities (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *capabilities)
813 EDataCalPrivate *priv;
814 CORBA_Environment ev;
816 g_return_if_fail (cal != NULL);
817 g_return_if_fail (E_IS_DATA_CAL (cal));
820 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
822 CORBA_exception_init (&ev);
823 GNOME_Evolution_Calendar_CalListener_notifyStaticCapabilities (priv->listener, status,
824 capabilities ? capabilities : "", &ev);
827 g_message (G_STRLOC ": could not notify the listener of static capabilities");
829 CORBA_exception_free (&ev);
833 * e_data_cal_notify_open:
834 * @cal: A calendar client interface.
835 * @status: Status code.
837 * Notifies listeners of the completion of the open method call.
840 e_data_cal_notify_open (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
842 EDataCalPrivate *priv;
843 CORBA_Environment ev;
845 g_return_if_fail (cal != NULL);
846 g_return_if_fail (E_IS_DATA_CAL (cal));
849 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
851 CORBA_exception_init (&ev);
852 GNOME_Evolution_Calendar_CalListener_notifyCalOpened (priv->listener, status, &ev);
855 g_message (G_STRLOC ": could not notify the listener of open");
857 CORBA_exception_free (&ev);
861 * e_data_cal_notify_remove:
862 * @cal: A calendar client interface.
863 * @status: Status code.
865 * Notifies listeners of the completion of the remove method call.
868 e_data_cal_notify_remove (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
870 EDataCalPrivate *priv;
871 CORBA_Environment ev;
873 g_return_if_fail (cal != NULL);
874 g_return_if_fail (E_IS_DATA_CAL (cal));
877 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
879 CORBA_exception_init (&ev);
880 GNOME_Evolution_Calendar_CalListener_notifyCalRemoved (priv->listener, status, &ev);
883 g_message (G_STRLOC ": could not notify the listener of remove");
885 CORBA_exception_free (&ev);
889 * e_data_cal_notify_object_created:
890 * @cal: A calendar client interface.
891 * @status: Status code.
892 * @uid: UID of the object created.
893 * @object: The object created as an iCalendar string.
895 * Notifies listeners of the completion of the create_object method call.
898 e_data_cal_notify_object_created (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
899 const char *uid, const char *object)
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 /* If the object is NULL, it means the object has been created on the server sucessfully,
911 but it is not shown in the UI if delay delivery is set */
912 if (status == GNOME_Evolution_Calendar_Success && object)
913 e_cal_backend_notify_object_created (priv->backend, object);
915 CORBA_exception_init (&ev);
916 GNOME_Evolution_Calendar_CalListener_notifyObjectCreated (priv->listener, status, uid ? uid : "", &ev);
919 g_message (G_STRLOC ": could not notify the listener of object creation");
921 CORBA_exception_free (&ev);
925 * e_data_cal_notify_object_modified:
926 * @cal: A calendar client interface.
927 * @status: Status code.
928 * @old_object: The old object as an iCalendar string.
929 * @object: The modified object as an iCalendar string.
931 * Notifies listeners of the completion of the modify_object method call.
934 e_data_cal_notify_object_modified (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
935 const char *old_object, const char *object)
937 EDataCalPrivate *priv;
938 CORBA_Environment ev;
940 g_return_if_fail (cal != NULL);
941 g_return_if_fail (E_IS_DATA_CAL (cal));
944 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
946 if (status == GNOME_Evolution_Calendar_Success)
947 e_cal_backend_notify_object_modified (priv->backend, old_object, object);
949 CORBA_exception_init (&ev);
950 GNOME_Evolution_Calendar_CalListener_notifyObjectModified (priv->listener, status, &ev);
953 g_message (G_STRLOC ": could not notify the listener of object creation");
955 CORBA_exception_free (&ev);
959 * e_data_cal_notify_object_removed:
960 * @cal: A calendar client interface.
961 * @status: Status code.
962 * @uid: UID of the removed object.
963 * @old_object: The old object as an iCalendar string.
964 * @object: The new object as an iCalendar string. This will not be NULL only
965 * when removing instances of a recurring appointment.
967 * Notifies listeners of the completion of the remove_object method call.
970 e_data_cal_notify_object_removed (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
971 const ECalComponentId *id, const char *old_object, const char *object)
973 EDataCalPrivate *priv;
974 CORBA_Environment ev;
976 g_return_if_fail (cal != NULL);
977 g_return_if_fail (E_IS_DATA_CAL (cal));
980 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
982 if (status == GNOME_Evolution_Calendar_Success)
983 e_cal_backend_notify_object_removed (priv->backend, id, old_object, object);
985 CORBA_exception_init (&ev);
986 GNOME_Evolution_Calendar_CalListener_notifyObjectRemoved (priv->listener, status, &ev);
989 g_message (G_STRLOC ": could not notify the listener of object removal");
991 CORBA_exception_free (&ev);
995 * e_data_cal_notify_objects_received:
996 * @cal: A calendar client interface.
997 * @status: Status code.
999 * Notifies listeners of the completion of the receive_objects method call.
1002 e_data_cal_notify_objects_received (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
1004 EDataCalPrivate *priv;
1005 CORBA_Environment ev;
1007 g_return_if_fail (cal != NULL);
1008 g_return_if_fail (E_IS_DATA_CAL (cal));
1011 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1013 CORBA_exception_init (&ev);
1014 GNOME_Evolution_Calendar_CalListener_notifyObjectsReceived (priv->listener, status, &ev);
1016 if (BONOBO_EX (&ev))
1017 g_message (G_STRLOC ": could not notify the listener of objects received");
1019 CORBA_exception_free (&ev);
1023 * e_data_cal_notify_alarm_discarded:
1024 * @cal: A calendar client interface.
1025 * @status: Status code.
1027 * Notifies listeners of the completion of the discard_alarm method call.
1030 e_data_cal_notify_alarm_discarded (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
1032 EDataCalPrivate *priv;
1033 CORBA_Environment ev;
1035 g_return_if_fail (cal != NULL);
1036 g_return_if_fail (E_IS_DATA_CAL (cal));
1039 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1041 CORBA_exception_init (&ev);
1042 GNOME_Evolution_Calendar_CalListener_notifyAlarmDiscarded (priv->listener, status, &ev);
1044 if (BONOBO_EX (&ev))
1045 g_message (G_STRLOC ": could not notify the listener of alarm discarded");
1047 CORBA_exception_free (&ev);
1051 * e_data_cal_notify_objects_sent:
1052 * @cal: A calendar client interface.
1053 * @status: Status code.
1054 * @users: List of users.
1055 * @calobj: An iCalendar string representing the object sent.
1057 * Notifies listeners of the completion of the send_objects method call.
1060 e_data_cal_notify_objects_sent (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *users, const char *calobj)
1062 EDataCalPrivate *priv;
1063 CORBA_Environment ev;
1064 GNOME_Evolution_Calendar_UserList *corba_users;
1066 g_return_if_fail (cal != NULL);
1067 g_return_if_fail (E_IS_DATA_CAL (cal));
1070 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1072 corba_users = GNOME_Evolution_Calendar_UserList__alloc ();
1073 corba_users->_length = g_list_length (users);
1078 corba_users->_buffer = CORBA_sequence_GNOME_Evolution_Calendar_User_allocbuf (corba_users->_length);
1079 for (l = users, n = 0; l != NULL; l = l->next, n++)
1080 corba_users->_buffer[n] = CORBA_string_dup (l->data);
1083 CORBA_exception_init (&ev);
1084 GNOME_Evolution_Calendar_CalListener_notifyObjectsSent (priv->listener, status, corba_users,
1085 calobj ? calobj : "", &ev);
1087 if (BONOBO_EX (&ev))
1088 g_message (G_STRLOC ": could not notify the listener of objects sent");
1090 CORBA_exception_free (&ev);
1091 CORBA_free (corba_users);
1095 * e_data_cal_notify_default_object:
1096 * @cal: A calendar client interface.
1097 * @status: Status code.
1098 * @object: The default object as an iCalendar string.
1100 * Notifies listeners of the completion of the get_default_object method call.
1103 e_data_cal_notify_default_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
1105 EDataCalPrivate *priv;
1106 CORBA_Environment ev;
1108 g_return_if_fail (cal != NULL);
1109 g_return_if_fail (E_IS_DATA_CAL (cal));
1112 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1114 CORBA_exception_init (&ev);
1116 GNOME_Evolution_Calendar_CalListener_notifyDefaultObjectRequested (priv->listener, status,
1117 object ? object : "", &ev);
1119 if (BONOBO_EX (&ev))
1120 g_message (G_STRLOC ": could not notify the listener of default object");
1122 CORBA_exception_free (&ev);
1126 * e_data_cal_notify_object:
1127 * @cal: A calendar client interface.
1128 * @status: Status code.
1129 * @object: The object retrieved as an iCalendar string.
1131 * Notifies listeners of the completion of the get_object method call.
1134 e_data_cal_notify_object (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
1136 EDataCalPrivate *priv;
1137 CORBA_Environment ev;
1139 g_return_if_fail (cal != NULL);
1140 g_return_if_fail (E_IS_DATA_CAL (cal));
1143 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1145 CORBA_exception_init (&ev);
1147 GNOME_Evolution_Calendar_CalListener_notifyObjectRequested (priv->listener, status,
1148 object ? object : "", &ev);
1150 if (BONOBO_EX (&ev))
1151 g_message (G_STRLOC ": could not notify the listener of object");
1153 CORBA_exception_free (&ev);
1157 * e_data_cal_notify_object_list:
1158 * @cal: A calendar client interface.
1159 * @status: Status code.
1160 * @objects: List of retrieved objects.
1162 * Notifies listeners of the completion of the get_object_list method call.
1165 e_data_cal_notify_object_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *objects)
1167 EDataCalPrivate *priv;
1168 CORBA_Environment ev;
1169 GNOME_Evolution_Calendar_stringlist seq;
1173 g_return_if_fail (cal != NULL);
1174 g_return_if_fail (E_IS_DATA_CAL (cal));
1177 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1179 CORBA_exception_init (&ev);
1181 seq._maximum = g_list_length (objects);
1183 seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
1185 for (l = objects, i = 0; l; l = l->next, i++) {
1186 seq._buffer[i] = CORBA_string_dup (l->data);
1190 GNOME_Evolution_Calendar_CalListener_notifyObjectListRequested (priv->listener, status, &seq, &ev);
1192 if (BONOBO_EX (&ev))
1193 g_message (G_STRLOC ": could not notify the listener of object list");
1195 CORBA_exception_free (&ev);
1197 CORBA_free(seq._buffer);
1201 * e_data_cal_notify_attachment_list:
1202 * @cal: A calendar client interface.
1203 * @status: Status code.
1204 * @attachments: List of retrieved attachment uri's.
1206 * Notifies listeners of the completion of the get_attachment_list method call.
1209 e_data_cal_notify_attachment_list (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GSList *attachments)
1211 EDataCalPrivate *priv;
1212 CORBA_Environment ev;
1213 GNOME_Evolution_Calendar_stringlist seq;
1217 g_return_if_fail (cal != NULL);
1218 g_return_if_fail (E_IS_DATA_CAL (cal));
1221 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1223 CORBA_exception_init (&ev);
1225 seq._maximum = g_slist_length (attachments);
1227 seq._buffer = GNOME_Evolution_Calendar_stringlist_allocbuf (seq._maximum);
1229 for (l = attachments, i = 0; l; l = l->next, i++) {
1230 seq._buffer[i] = CORBA_string_dup (l->data);
1234 GNOME_Evolution_Calendar_CalListener_notifyAttachmentListRequested (priv->listener, status, &seq, &ev);
1236 if (BONOBO_EX (&ev))
1237 g_message (G_STRLOC ": could not notify the listener of object list");
1239 CORBA_exception_free (&ev);
1241 CORBA_free(seq._buffer);
1245 * e_data_cal_notify_query:
1246 * @cal: A calendar client interface.
1247 * @status: Status code.
1248 * @query: The new live query.
1250 * Notifies listeners of the completion of the get_query method call.
1253 e_data_cal_notify_query (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, EDataCalView *query)
1255 EDataCalPrivate *priv;
1256 CORBA_Environment ev;
1258 g_return_if_fail (cal != NULL);
1259 g_return_if_fail (E_IS_DATA_CAL (cal));
1262 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1264 CORBA_exception_init (&ev);
1265 GNOME_Evolution_Calendar_CalListener_notifyQuery (priv->listener, status, BONOBO_OBJREF (query), &ev);
1267 if (BONOBO_EX (&ev))
1268 g_message (G_STRLOC ": could not notify the listener of query");
1270 CORBA_exception_free (&ev);
1274 * e_data_cal_notify_timezone_requested:
1275 * @cal: A calendar client interface.
1276 * @status: Status code.
1277 * @object: The requested timezone as an iCalendar string.
1279 * Notifies listeners of the completion of the get_timezone method call.
1282 e_data_cal_notify_timezone_requested (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *object)
1284 EDataCalPrivate *priv;
1285 CORBA_Environment ev;
1287 g_return_if_fail (E_IS_DATA_CAL (cal));
1290 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1292 CORBA_exception_init (&ev);
1293 GNOME_Evolution_Calendar_CalListener_notifyTimezoneRequested (priv->listener, status, object ? object : "", &ev);
1295 if (BONOBO_EX (&ev))
1296 g_warning (G_STRLOC ": could not notify the listener of timezone requested");
1298 CORBA_exception_free (&ev);
1302 * e_data_cal_notify_timezone_added:
1303 * @cal: A calendar client interface.
1304 * @status: Status code.
1305 * @tzid: ID of the added timezone.
1307 * Notifies listeners of the completion of the add_timezone method call.
1310 e_data_cal_notify_timezone_added (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, const char *tzid)
1312 EDataCalPrivate *priv;
1313 CORBA_Environment ev;
1315 g_return_if_fail (E_IS_DATA_CAL (cal));
1318 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1320 CORBA_exception_init (&ev);
1321 GNOME_Evolution_Calendar_CalListener_notifyTimezoneAdded (priv->listener, status, tzid ? tzid : "", &ev);
1323 if (BONOBO_EX (&ev))
1324 g_warning (G_STRLOC ": could not notify the listener of timezone added");
1326 CORBA_exception_free (&ev);
1330 * e_data_cal_notify_default_timezone_set:
1331 * @cal: A calendar client interface.
1332 * @status: Status code.
1334 * Notifies listeners of the completion of the set_default_timezone method call.
1337 e_data_cal_notify_default_timezone_set (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status)
1339 EDataCalPrivate *priv;
1340 CORBA_Environment ev;
1342 g_return_if_fail (E_IS_DATA_CAL (cal));
1345 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1347 CORBA_exception_init (&ev);
1348 GNOME_Evolution_Calendar_CalListener_notifyDefaultTimezoneSet (priv->listener, status, &ev);
1350 if (BONOBO_EX (&ev))
1351 g_warning (G_STRLOC ": could not notify the listener of default timezone set");
1353 CORBA_exception_free (&ev);
1357 * e_data_cal_notify_changes:
1358 * @cal: A calendar client interface.
1359 * @status: Status code.
1360 * @adds: List of additions.
1361 * @modifies: List of modifications.
1362 * @deletes: List of removals.
1364 * Notifies listeners of the completion of the get_changes method call.
1367 e_data_cal_notify_changes (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status,
1368 GList *adds, GList *modifies, GList *deletes)
1370 EDataCalPrivate *priv;
1371 CORBA_Environment ev;
1372 GNOME_Evolution_Calendar_CalObjChangeSeq seq;
1376 g_return_if_fail (E_IS_DATA_CAL (cal));
1379 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1381 n = g_list_length (adds) + g_list_length (modifies) + g_list_length (deletes);
1384 seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObjChange_allocbuf (n);
1387 for (l = adds; l; i++, l = l->next) {
1388 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1390 change->calobj = CORBA_string_dup (l->data);
1391 change->type = GNOME_Evolution_Calendar_ADDED;
1394 for (l = modifies; l; i++, l = l->next) {
1395 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1397 change->calobj = CORBA_string_dup (l->data);
1398 change->type = GNOME_Evolution_Calendar_MODIFIED;
1401 for (l = deletes; l; i++, l = l->next) {
1402 GNOME_Evolution_Calendar_CalObjChange *change = &seq._buffer[i];
1404 change->calobj = CORBA_string_dup (l->data);
1405 change->type = GNOME_Evolution_Calendar_DELETED;
1408 CORBA_exception_init (&ev);
1409 GNOME_Evolution_Calendar_CalListener_notifyChanges (priv->listener, status, &seq, &ev);
1411 CORBA_free (seq._buffer);
1413 if (BONOBO_EX (&ev))
1414 g_warning (G_STRLOC ": could not notify the listener of default timezone set");
1416 CORBA_exception_free (&ev);
1420 * e_data_cal_notify_free_busy:
1421 * @cal: A calendar client interface.
1422 * @status: Status code.
1423 * @freebusy: List of free/busy objects.
1425 * Notifies listeners of the completion of the get_free_busy method call.
1428 e_data_cal_notify_free_busy (EDataCal *cal, GNOME_Evolution_Calendar_CallStatus status, GList *freebusy)
1430 EDataCalPrivate *priv;
1431 CORBA_Environment ev;
1432 GNOME_Evolution_Calendar_CalObjSeq seq;
1436 g_return_if_fail (E_IS_DATA_CAL (cal));
1439 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1441 n = g_list_length (freebusy);
1444 seq._buffer = CORBA_sequence_GNOME_Evolution_Calendar_CalObj_allocbuf (n);
1446 for (i = 0, l = freebusy; l; i++, l = l->next)
1447 seq._buffer[i] = CORBA_string_dup (l->data);
1449 CORBA_exception_init (&ev);
1450 GNOME_Evolution_Calendar_CalListener_notifyFreeBusy (priv->listener, status, &seq, &ev);
1452 CORBA_free (seq._buffer);
1454 if (BONOBO_EX (&ev))
1455 g_warning (G_STRLOC ": could not notify the listener of freebusy");
1457 CORBA_exception_free (&ev);
1461 * e_data_cal_notify_mode:
1462 * @cal: A calendar client interface.
1463 * @status: Status of the mode set.
1464 * @mode: The current mode.
1466 * Notifies the listener of the results of a set_mode call.
1469 e_data_cal_notify_mode (EDataCal *cal,
1470 GNOME_Evolution_Calendar_CalListener_SetModeStatus status,
1471 GNOME_Evolution_Calendar_CalMode mode)
1473 EDataCalPrivate *priv;
1474 CORBA_Environment ev;
1476 g_return_if_fail (cal != NULL);
1477 g_return_if_fail (E_IS_DATA_CAL (cal));
1480 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1482 CORBA_exception_init (&ev);
1483 GNOME_Evolution_Calendar_CalListener_notifyCalSetMode (priv->listener, status, mode, &ev);
1485 if (BONOBO_EX (&ev))
1486 g_message ("e_data_cal_notify_mode(): could not notify the listener "
1487 "about a mode change");
1489 CORBA_exception_free (&ev);
1493 * e_data_cal_notify_auth_required:
1494 * @cal: A calendar client interface.
1496 * Notifies listeners that authorization is required to open the calendar.
1499 e_data_cal_notify_auth_required (EDataCal *cal)
1501 EDataCalPrivate *priv;
1502 CORBA_Environment ev;
1504 g_return_if_fail (cal != NULL);
1505 g_return_if_fail (E_IS_DATA_CAL (cal));
1508 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1510 CORBA_exception_init (&ev);
1511 GNOME_Evolution_Calendar_CalListener_notifyAuthRequired (priv->listener, &ev);
1512 if (BONOBO_EX (&ev))
1513 g_message ("e_data_cal_notify_auth_required: could not notify the listener "
1514 "about auth required");
1516 CORBA_exception_free (&ev);
1520 * e_data_cal_notify_error
1521 * @cal: A calendar client interface.
1522 * @message: Error message.
1524 * Notify a calendar client of an error occurred in the backend.
1527 e_data_cal_notify_error (EDataCal *cal, const char *message)
1529 EDataCalPrivate *priv;
1530 CORBA_Environment ev;
1532 g_return_if_fail (cal != NULL);
1533 g_return_if_fail (E_IS_DATA_CAL (cal));
1534 g_return_if_fail (message != NULL);
1537 g_return_if_fail (priv->listener != CORBA_OBJECT_NIL);
1539 CORBA_exception_init (&ev);
1540 GNOME_Evolution_Calendar_CalListener_notifyErrorOccurred (priv->listener, (char *) message, &ev);
1542 if (BONOBO_EX (&ev))
1543 g_message ("e_data_cal_notify_remove(): could not notify the listener "
1544 "about a removed object");
1546 CORBA_exception_free (&ev);