diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-01-22 15:09:39 +0800 |
---|---|---|
committer | Arturo Espinosa <unammx@src.gnome.org> | 2000-01-22 15:09:39 +0800 |
commit | 101996359f684e0282f1261f92f54d5b10e1ddb3 (patch) | |
tree | 94006182b470ca2e6794e04c84613d4aec6d6156 | |
parent | 84423c930ecc93ce93040bfd49e20c68670d4364 (diff) | |
download | gsoc2013-evolution-101996359f684e0282f1261f92f54d5b10e1ddb3.tar gsoc2013-evolution-101996359f684e0282f1261f92f54d5b10e1ddb3.tar.gz gsoc2013-evolution-101996359f684e0282f1261f92f54d5b10e1ddb3.tar.bz2 gsoc2013-evolution-101996359f684e0282f1261f92f54d5b10e1ddb3.tar.lz gsoc2013-evolution-101996359f684e0282f1261f92f54d5b10e1ddb3.tar.xz gsoc2013-evolution-101996359f684e0282f1261f92f54d5b10e1ddb3.tar.zst gsoc2013-evolution-101996359f684e0282f1261f92f54d5b10e1ddb3.zip |
Take in a GnomeVFSURI, not a string.
2000-01-22 Federico Mena Quintero <federico@helixcode.com>
* cal-backend.c (cal_backend_load): Take in a GnomeVFSURI, not a
string.
* cal-listener.c (Listener_cal_loaded): Pass the load status to
the signal.
(cal_listener_destroy): Better error checking.
(cal_listener_new): Better error checking.
* cal-listener.h (CalListenerLoadStatus): New enum for the load
status of a calendar.
(CalListenerClass): Added the status argument to the cal_loaded
signal.
* gnome-calendar.idl (cal_loaded): Added a load status code.
* cal-backend.h (CalBackendLoadStatus): Renamed from
CalBackendLoadResult.
svn path=/trunk/; revision=1607
-rw-r--r-- | calendar/ChangeLog | 20 | ||||
-rw-r--r-- | calendar/cal-backend.c | 21 | ||||
-rw-r--r-- | calendar/cal-backend.h | 4 | ||||
-rw-r--r-- | calendar/cal-client/cal-listener.c | 116 | ||||
-rw-r--r-- | calendar/cal-client/cal-listener.h | 10 | ||||
-rw-r--r-- | calendar/cal-factory.c | 45 | ||||
-rw-r--r-- | calendar/cal-listener.c | 116 | ||||
-rw-r--r-- | calendar/cal-listener.h | 10 | ||||
-rw-r--r-- | calendar/evolution-calendar.idl | 8 | ||||
-rw-r--r-- | calendar/idl/evolution-calendar.idl | 8 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.c | 21 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.h | 4 | ||||
-rw-r--r-- | calendar/pcs/cal-factory.c | 45 |
13 files changed, 308 insertions, 120 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 3b32e80de3..6df4329dd9 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,23 @@ +2000-01-22 Federico Mena Quintero <federico@helixcode.com> + + * cal-backend.c (cal_backend_load): Take in a GnomeVFSURI, not a + string. + + * cal-listener.c (Listener_cal_loaded): Pass the load status to + the signal. + (cal_listener_destroy): Better error checking. + (cal_listener_new): Better error checking. + + * cal-listener.h (CalListenerLoadStatus): New enum for the load + status of a calendar. + (CalListenerClass): Added the status argument to the cal_loaded + signal. + + * gnome-calendar.idl (cal_loaded): Added a load status code. + + * cal-backend.h (CalBackendLoadStatus): Renamed from + CalBackendLoadResult. + 2000-01-18 Federico Mena Quintero <federico@helixcode.com> * cal-backend.c cal-backend.h: Moved the calendar backend here. diff --git a/calendar/cal-backend.c b/calendar/cal-backend.c index 2fb523dc14..0d90e7a2dd 100644 --- a/calendar/cal-backend.c +++ b/calendar/cal-backend.c @@ -303,41 +303,36 @@ cal_backend_add_cal (CalBackend *backend, Cal *cal) /** * cal_backend_load: * @backend: A calendar backend. - * @str_uri: URI that contains the calendar data. + * @uri: URI that contains the calendar data. * * Loads a calendar backend with data from a calendar stored at the specified * URI. * - * Return value: An operation result code. + * Return value: An operation status code. **/ -CalBackendLoadResult -cal_backend_load (CalBackend *backend, char *str_uri) +CalBackendLoadStatus +cal_backend_load (CalBackend *backend, GnomeVFSURI *uri) { CalBackendPrivate *priv; - GnomeVFSURI *uri; VObject *vobject; g_return_val_if_fail (backend != NULL, CAL_BACKEND_LOAD_ERROR); g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_LOAD_ERROR); - g_return_val_if_fail (str_uri != NULL, CAL_BACKEND_LOAD_ERROR); + g_return_val_if_fail (uri != NULL, CAL_BACKEND_LOAD_ERROR); priv = backend->priv; g_return_val_if_fail (!priv->loaded, CAL_BACKEND_LOAD_ERROR); - uri = gnome_vfs_uri_new (str_uri); - if (!uri) - return CAL_BACKEND_LOAD_ERROR; - vobject = Parse_MIME_FromURI (uri); - if (!vobject) { - gnome_vfs_uri_unref (uri); + if (!vobject) return CAL_BACKEND_LOAD_ERROR; - } load_from_vobject (backend, vobject); cleanVObject (vobject); cleanStrTbl (); + gnome_vfs_uri_ref (uri); + priv->uri = uri; priv->loaded = TRUE; return CAL_BACKEND_LOAD_SUCCESS; diff --git a/calendar/cal-backend.h b/calendar/cal-backend.h index 14cc903ae6..cffc3c5cc3 100644 --- a/calendar/cal-backend.h +++ b/calendar/cal-backend.h @@ -41,7 +41,7 @@ BEGIN_GNOME_DECLS typedef enum { CAL_BACKEND_LOAD_SUCCESS, /* Loading OK */ CAL_BACKEND_LOAD_ERROR /* We need better error reporting in libversit */ -} CalBackendLoadResult; +} CalBackendLoadStatus; struct _CalBackend { GtkObject object; @@ -62,7 +62,7 @@ GnomeVFSURI *cal_backend_get_uri (CalBackend *backend); void cal_backend_add_cal (CalBackend *backend, Cal *cal); -CalBackendLoadResult cal_backend_load (CalBackend *backend, char *str_uri); +CalBackendLoadStatus cal_backend_load (CalBackend *backend, GnomeVFSURI *uri); diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c index 2c3ffe119d..8583a689c8 100644 --- a/calendar/cal-client/cal-listener.c +++ b/calendar/cal-client/cal-listener.c @@ -45,6 +45,8 @@ static void cal_listener_class_init (CalListenerClass *class); static void cal_listener_init (CalListener *listener); static void cal_listener_destroy (GtkObject *object); +static void marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args); + static POA_GNOME_Calendar_Listener__vepv cal_listener_vepv; static guint cal_listener_signals[LAST_SIGNAL]; @@ -108,8 +110,9 @@ cal_listener_class_init (CalListenerClass *class) GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (CalListenerClass, cal_loaded), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, + marshal_cal_loaded, + GTK_TYPE_NONE, 2, + GTK_TYPE_ENUM, GTK_TYPE_POINTER); cal_listener_signals[OBJ_ADDED] = gtk_signal_new ("obj_added", @@ -155,20 +158,6 @@ cal_listener_init (CalListener *listener) priv->cal = CORBA_OBJECT_NIL; } -/* Returns whether a CORBA object is nil */ -static gboolean -corba_object_is_nil (CORBA_Object object) -{ - CORBA_Environment ev; - gboolean retval; - - CORBA_exception_init (&ev); - retval = CORBA_Object_is_nil (object, &ev); - CORBA_exception_free (&ev); - - return retval; -} - /* Destroy handler for the calendar listener */ static void cal_listener_destroy (GtkObject *object) @@ -176,6 +165,7 @@ cal_listener_destroy (GtkObject *object) CalListener *listener; CalListenerPrivate *priv; CORBA_Environment ev; + gboolean result; g_return_if_fail (object != NULL); g_return_if_fail (IS_CAL_LISTENER (object)); @@ -184,11 +174,20 @@ cal_listener_destroy (GtkObject *object) priv = listener->priv; CORBA_exception_init (&ev); + result = CORBA_Object_is_nil (priv->cal, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("cal_listener_destroy(): could not see if the calendar was NIL"); + else if (!result) { + CORBA_exception_free (&ev); - if (!CORBA_Object_is_nil (priv->cal, &ev)) { - GNOME_Unknown_unref (priv->cal, &ev); + CORBA_exception_init (&ev); CORBA_Object_release (priv->cal, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("cal_listener_destroy(): could not release the calendar"); } + CORBA_exception_free (&ev); g_free (priv); @@ -198,24 +197,72 @@ cal_listener_destroy (GtkObject *object) +/* Marshalers */ + +typedef void (* CalLoadedFunc) (GtkObject *object, gint status, gpointer cal, gpointer data); + +static void +marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args) +{ + CalLoadedFunc rfunc; + + rfunc = (CalLoadedFunc) func; + (* rfunc) (object, GTK_VALUE_ENUM (args[0]), GTK_VALUE_POINTER (args[1]), data); +} + + + /* CORBA servant implementation */ /* Listener::cal_loaded method */ static void Listener_cal_loaded (PortableServer_Servant servant, + GNOME_Calendar_Listener_LoadStatus status, GNOME_Calendar_Cal cal, CORBA_Environment *ev) { CalListener *listener; CalListenerPrivate *priv; + CORBA_Environment aev; + GNOME_Calendar_Cal cal_copy; + CalListenerLoadStatus load_status; listener = CAL_LISTENER (gnome_object_from_servant (servant)); priv = listener->priv; - priv->cal = CORBA_Object_duplicate (cal, ev); - GNOME_Unknown_ref (priv->cal); + if (priv->cal != CORBA_OBJECT_NIL) { + g_message ("Listener_cal_loaded(): calendar was already loaded!"); + return; + } + + CORBA_exception_init (&aev); + cal_copy = CORBA_Object_duplicate (cal, &aev); + + if (aev._major != CORBA_NO_EXCEPTION) { + g_message ("Listener_cal_loaded(): could not duplicate the calendar"); + CORBA_exception_free (&aev); + return; + } + CORBA_exception_free (&aev); + + priv->cal = cal_copy; + + switch (status) { + GNOME_Calendar_Listener_SUCESSS: + load_status = CAL_LISTENER_LOAD_SUCCESS; + break; + + GNOME_Calendar_Listener_ERROR: + load_status = CAL_LISTENER_LOAD_ERROR; + break; + + default: + load_status = CAL_LISTENER_LOAD_ERROR; /* keep gcc happy */ + g_assert_not_reached (); + } + gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED], - cal); + load_status, cal); } /* Listener::obj_added method */ @@ -281,20 +328,6 @@ cal_listener_get_epv (void) -/* Returns whether a CORBA object is nil */ -static gboolean -corba_object_is_nil (CORBA_Object object) -{ - CORBA_Environment ev; - gboolean retval; - - CORBA_exception_init (&ev); - retval = CORBA_Object_is_nil (object, &ev); - CORBA_exception_free (&ev); - - return retval; -} - /** * cal_listener_construct: * @listener: A calendar listener. @@ -310,7 +343,6 @@ cal_listener_construct (CalListener *listener, GNOME_Calendar_Listener corba_lis { g_return_val_if_fail (listener != NULL, NULL); g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL); - g_return_val_if_fail (!corba_object_is_nil (corba_listener), NULL); gnome_object_construct (GNOME_OBJECT (listener), corba_listener); return listener; @@ -363,14 +395,24 @@ CalListener * cal_listener_new (void) { CalListener *listener; + CORBA_Environment ev; GNOME_Calendar_Listener corba_listener; + gboolean result; listener = gtk_type_new (CAL_LISTENER_TYPE); + corba_listener = cal_listener_corba_object_create (GNOME_OBJECT (listener)); - if (corba_object_is_nil (corba_listener)) { + + CORBA_exception_init (&ev); + result = CORBA_Object_is_nil (corba_listener, &ev); + + if (ev._major != CORBA_NO_EXCEPTION || result) { + g_message ("cal_listener_new(): could not create the CORBA listener"); gtk_object_destroy (listener); + CORBA_exception_free (&ev); return NULL; } + CORBA_exception_free (&ev); return cal_listener_construct (listener, corba_listener); } diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h index 41665b2b58..c8d26dab80 100644 --- a/calendar/cal-client/cal-listener.h +++ b/calendar/cal-client/cal-listener.h @@ -40,6 +40,12 @@ BEGIN_GNOME_DECLS typedef struct _CalListener CalListener; typedef struct _CalListenerClass CalListenerClass; +/* Load status for the cal_loaded signal. We need better error reporting. */ +typedef enum { + CAL_LISTENER_LOAD_SUCCESS, + CAL_LISTENER_LOAD_ERROR +} CalListenerLoadStatus; + struct _CalListener { GnomeObject object; @@ -50,7 +56,9 @@ struct _CalListener { struct _CalListenerClass { GnomeObjectClass parent_class; - void (* cal_loaded) (CalListener *listener, GNOME_Calendar_Cal cal); + void (* cal_loaded) (CalListener *listener, + CalListenerLoadStatus status, + GNOME_Calendar_Cal cal); void (* obj_added) (CalListener *listener, GNOME_Calendar_CalObj calobj); void (* obj_removed) (CalListener *listener, GNOME_Calendar_CalObjUID uid); void (* obj_changed) (CalListener *listener, GNOME_Calendar_CalObj calobj); diff --git a/calendar/cal-factory.c b/calendar/cal-factory.c index 053baebe5c..75c281d235 100644 --- a/calendar/cal-factory.c +++ b/calendar/cal-factory.c @@ -20,6 +20,7 @@ */ #include <config.h> +#include "cal-backend.h" #include "cal-factory.h" #include "job.h" @@ -27,7 +28,7 @@ /* Private part of the CalFactory structure */ typedef struct { - /* Hash table from GnomeVFSURI structures to loaded calendars */ + /* Hash table from GnomeVFSURI structures to CalBackend objects */ GHashTable *calendars; } CalFactoryPrivate; @@ -215,7 +216,33 @@ lookup_calendar (CalFactory *factory, GnomeVFSURI *uri) static void load_calendar (CalFactory *factory, GnomeVFSURI *uri, GNOME_Calendar_Listener listener) { - /* FIXME */ + CalFactoryPrivate *priv; + CalBackend *backend; + CalBackendLoadStatus status; + + priv = factory->priv; + + backend = cal_backend_new (); + if (!backend) { + CORBA_Environment ev; + + g_message ("load_calendar(): could not create the backend"); + + CORBA_exception_init (&ev); + GNOME_Calendar_Listener_cal_loaded (listener, + GNOME_Calendar_Listener_ERROR, + CORBA_OBJECT_NIL, + &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("load_calendar(): could not notify the listener"); + CORBA_exception_free (&ev); + gtk_object_unref (backend); + return; + } + CORBA_exception_free (&ev); + } + + status = cal_backend_load (backend, uri); } /* Adds a listener to a calendar */ @@ -250,10 +277,15 @@ load_fn (gpointer data) g_free (jd->uri); CORBA_exception_init (&ev); - GNOME_Unknown_unref (jd->listener, &ev); CORBA_Object_release (jd->listener, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("load_fn(): could not release the listener"); + CORBA_exception_free (&ev); + /* Done */ + g_free (jd); } @@ -303,6 +335,7 @@ cal_factory_corba_object_create (GnomeObject *object) CORBA_exception_init (&ev); POA_GNOME_Calendar_CalFactory__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { g_message ("cal_factory_corba_object_create(): could not init the servant"); g_free (servant); @@ -334,16 +367,16 @@ cal_factory_new (void) factory = gtk_type_new (CAL_FACTORY_TYPE); corba_factory = cal_factory_corba_object_create (GNOME_OBJECT (factory)); + CORBA_exception_init (&ev); retval = CORBA_Object_is_nil (corba_factory, &ev); if (ev._major != CORBA_NO_EXCEPTION || retval) { - g_message ("cal_factory_new(): could not create the CORBA object"); + g_message ("cal_factory_new(): could not create the CORBA factory"); gtk_object_unref (factory); CORBA_exception_free (&ev); return NULL; } - CORBA_exception_free (&ev); return cal_factory_construct (factory, corba_factory); @@ -357,8 +390,8 @@ cal_factory_load (CalFactory *factory, const char *uri, GNOME_Calendar_Listener GNOME_Calendar_Listener listener_copy; CORBA_exception_init (&ev); - listener_copy = CORBA_Object_duplicate (listener, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { g_message ("cal_factory_load(): could not duplicate the listener"); CORBA_exception_free (&ev); diff --git a/calendar/cal-listener.c b/calendar/cal-listener.c index 2c3ffe119d..8583a689c8 100644 --- a/calendar/cal-listener.c +++ b/calendar/cal-listener.c @@ -45,6 +45,8 @@ static void cal_listener_class_init (CalListenerClass *class); static void cal_listener_init (CalListener *listener); static void cal_listener_destroy (GtkObject *object); +static void marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args); + static POA_GNOME_Calendar_Listener__vepv cal_listener_vepv; static guint cal_listener_signals[LAST_SIGNAL]; @@ -108,8 +110,9 @@ cal_listener_class_init (CalListenerClass *class) GTK_RUN_FIRST, object_class->type, GTK_SIGNAL_OFFSET (CalListenerClass, cal_loaded), - gtk_marshal_NONE__POINTER, - GTK_TYPE_NONE, 1, + marshal_cal_loaded, + GTK_TYPE_NONE, 2, + GTK_TYPE_ENUM, GTK_TYPE_POINTER); cal_listener_signals[OBJ_ADDED] = gtk_signal_new ("obj_added", @@ -155,20 +158,6 @@ cal_listener_init (CalListener *listener) priv->cal = CORBA_OBJECT_NIL; } -/* Returns whether a CORBA object is nil */ -static gboolean -corba_object_is_nil (CORBA_Object object) -{ - CORBA_Environment ev; - gboolean retval; - - CORBA_exception_init (&ev); - retval = CORBA_Object_is_nil (object, &ev); - CORBA_exception_free (&ev); - - return retval; -} - /* Destroy handler for the calendar listener */ static void cal_listener_destroy (GtkObject *object) @@ -176,6 +165,7 @@ cal_listener_destroy (GtkObject *object) CalListener *listener; CalListenerPrivate *priv; CORBA_Environment ev; + gboolean result; g_return_if_fail (object != NULL); g_return_if_fail (IS_CAL_LISTENER (object)); @@ -184,11 +174,20 @@ cal_listener_destroy (GtkObject *object) priv = listener->priv; CORBA_exception_init (&ev); + result = CORBA_Object_is_nil (priv->cal, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("cal_listener_destroy(): could not see if the calendar was NIL"); + else if (!result) { + CORBA_exception_free (&ev); - if (!CORBA_Object_is_nil (priv->cal, &ev)) { - GNOME_Unknown_unref (priv->cal, &ev); + CORBA_exception_init (&ev); CORBA_Object_release (priv->cal, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("cal_listener_destroy(): could not release the calendar"); } + CORBA_exception_free (&ev); g_free (priv); @@ -198,24 +197,72 @@ cal_listener_destroy (GtkObject *object) +/* Marshalers */ + +typedef void (* CalLoadedFunc) (GtkObject *object, gint status, gpointer cal, gpointer data); + +static void +marshal_cal_loaded (GtkObject *object, GtkSignalFunc func, gpointer data, GtkArg *args) +{ + CalLoadedFunc rfunc; + + rfunc = (CalLoadedFunc) func; + (* rfunc) (object, GTK_VALUE_ENUM (args[0]), GTK_VALUE_POINTER (args[1]), data); +} + + + /* CORBA servant implementation */ /* Listener::cal_loaded method */ static void Listener_cal_loaded (PortableServer_Servant servant, + GNOME_Calendar_Listener_LoadStatus status, GNOME_Calendar_Cal cal, CORBA_Environment *ev) { CalListener *listener; CalListenerPrivate *priv; + CORBA_Environment aev; + GNOME_Calendar_Cal cal_copy; + CalListenerLoadStatus load_status; listener = CAL_LISTENER (gnome_object_from_servant (servant)); priv = listener->priv; - priv->cal = CORBA_Object_duplicate (cal, ev); - GNOME_Unknown_ref (priv->cal); + if (priv->cal != CORBA_OBJECT_NIL) { + g_message ("Listener_cal_loaded(): calendar was already loaded!"); + return; + } + + CORBA_exception_init (&aev); + cal_copy = CORBA_Object_duplicate (cal, &aev); + + if (aev._major != CORBA_NO_EXCEPTION) { + g_message ("Listener_cal_loaded(): could not duplicate the calendar"); + CORBA_exception_free (&aev); + return; + } + CORBA_exception_free (&aev); + + priv->cal = cal_copy; + + switch (status) { + GNOME_Calendar_Listener_SUCESSS: + load_status = CAL_LISTENER_LOAD_SUCCESS; + break; + + GNOME_Calendar_Listener_ERROR: + load_status = CAL_LISTENER_LOAD_ERROR; + break; + + default: + load_status = CAL_LISTENER_LOAD_ERROR; /* keep gcc happy */ + g_assert_not_reached (); + } + gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED], - cal); + load_status, cal); } /* Listener::obj_added method */ @@ -281,20 +328,6 @@ cal_listener_get_epv (void) -/* Returns whether a CORBA object is nil */ -static gboolean -corba_object_is_nil (CORBA_Object object) -{ - CORBA_Environment ev; - gboolean retval; - - CORBA_exception_init (&ev); - retval = CORBA_Object_is_nil (object, &ev); - CORBA_exception_free (&ev); - - return retval; -} - /** * cal_listener_construct: * @listener: A calendar listener. @@ -310,7 +343,6 @@ cal_listener_construct (CalListener *listener, GNOME_Calendar_Listener corba_lis { g_return_val_if_fail (listener != NULL, NULL); g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL); - g_return_val_if_fail (!corba_object_is_nil (corba_listener), NULL); gnome_object_construct (GNOME_OBJECT (listener), corba_listener); return listener; @@ -363,14 +395,24 @@ CalListener * cal_listener_new (void) { CalListener *listener; + CORBA_Environment ev; GNOME_Calendar_Listener corba_listener; + gboolean result; listener = gtk_type_new (CAL_LISTENER_TYPE); + corba_listener = cal_listener_corba_object_create (GNOME_OBJECT (listener)); - if (corba_object_is_nil (corba_listener)) { + + CORBA_exception_init (&ev); + result = CORBA_Object_is_nil (corba_listener, &ev); + + if (ev._major != CORBA_NO_EXCEPTION || result) { + g_message ("cal_listener_new(): could not create the CORBA listener"); gtk_object_destroy (listener); + CORBA_exception_free (&ev); return NULL; } + CORBA_exception_free (&ev); return cal_listener_construct (listener, corba_listener); } diff --git a/calendar/cal-listener.h b/calendar/cal-listener.h index 41665b2b58..c8d26dab80 100644 --- a/calendar/cal-listener.h +++ b/calendar/cal-listener.h @@ -40,6 +40,12 @@ BEGIN_GNOME_DECLS typedef struct _CalListener CalListener; typedef struct _CalListenerClass CalListenerClass; +/* Load status for the cal_loaded signal. We need better error reporting. */ +typedef enum { + CAL_LISTENER_LOAD_SUCCESS, + CAL_LISTENER_LOAD_ERROR +} CalListenerLoadStatus; + struct _CalListener { GnomeObject object; @@ -50,7 +56,9 @@ struct _CalListener { struct _CalListenerClass { GnomeObjectClass parent_class; - void (* cal_loaded) (CalListener *listener, GNOME_Calendar_Cal cal); + void (* cal_loaded) (CalListener *listener, + CalListenerLoadStatus status, + GNOME_Calendar_Cal cal); void (* obj_added) (CalListener *listener, GNOME_Calendar_CalObj calobj); void (* obj_removed) (CalListener *listener, GNOME_Calendar_CalObjUID uid); void (* obj_changed) (CalListener *listener, GNOME_Calendar_CalObj calobj); diff --git a/calendar/evolution-calendar.idl b/calendar/evolution-calendar.idl index 9ff87f62f6..390dfa1531 100644 --- a/calendar/evolution-calendar.idl +++ b/calendar/evolution-calendar.idl @@ -33,10 +33,16 @@ module Calendar { /* Listener for changes in a calendar */ interface Listener : Unknown { + /* Return status when loading a calendar; we need better error reporting */ + enum LoadStatus { + SUCESSS, + ERROR + }; + /* Called from a CalFactory when a calendar is initially loaded * or created. The listener must remember the cal object. */ - void cal_loaded (in Cal cal); + void cal_loaded (in LoadStatus status, in Cal cal); /* Called from a Calendar when an object is added */ void obj_added (in CalObj calobj); diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl index 9ff87f62f6..390dfa1531 100644 --- a/calendar/idl/evolution-calendar.idl +++ b/calendar/idl/evolution-calendar.idl @@ -33,10 +33,16 @@ module Calendar { /* Listener for changes in a calendar */ interface Listener : Unknown { + /* Return status when loading a calendar; we need better error reporting */ + enum LoadStatus { + SUCESSS, + ERROR + }; + /* Called from a CalFactory when a calendar is initially loaded * or created. The listener must remember the cal object. */ - void cal_loaded (in Cal cal); + void cal_loaded (in LoadStatus status, in Cal cal); /* Called from a Calendar when an object is added */ void obj_added (in CalObj calobj); diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index 2fb523dc14..0d90e7a2dd 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -303,41 +303,36 @@ cal_backend_add_cal (CalBackend *backend, Cal *cal) /** * cal_backend_load: * @backend: A calendar backend. - * @str_uri: URI that contains the calendar data. + * @uri: URI that contains the calendar data. * * Loads a calendar backend with data from a calendar stored at the specified * URI. * - * Return value: An operation result code. + * Return value: An operation status code. **/ -CalBackendLoadResult -cal_backend_load (CalBackend *backend, char *str_uri) +CalBackendLoadStatus +cal_backend_load (CalBackend *backend, GnomeVFSURI *uri) { CalBackendPrivate *priv; - GnomeVFSURI *uri; VObject *vobject; g_return_val_if_fail (backend != NULL, CAL_BACKEND_LOAD_ERROR); g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_LOAD_ERROR); - g_return_val_if_fail (str_uri != NULL, CAL_BACKEND_LOAD_ERROR); + g_return_val_if_fail (uri != NULL, CAL_BACKEND_LOAD_ERROR); priv = backend->priv; g_return_val_if_fail (!priv->loaded, CAL_BACKEND_LOAD_ERROR); - uri = gnome_vfs_uri_new (str_uri); - if (!uri) - return CAL_BACKEND_LOAD_ERROR; - vobject = Parse_MIME_FromURI (uri); - if (!vobject) { - gnome_vfs_uri_unref (uri); + if (!vobject) return CAL_BACKEND_LOAD_ERROR; - } load_from_vobject (backend, vobject); cleanVObject (vobject); cleanStrTbl (); + gnome_vfs_uri_ref (uri); + priv->uri = uri; priv->loaded = TRUE; return CAL_BACKEND_LOAD_SUCCESS; diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h index 14cc903ae6..cffc3c5cc3 100644 --- a/calendar/pcs/cal-backend.h +++ b/calendar/pcs/cal-backend.h @@ -41,7 +41,7 @@ BEGIN_GNOME_DECLS typedef enum { CAL_BACKEND_LOAD_SUCCESS, /* Loading OK */ CAL_BACKEND_LOAD_ERROR /* We need better error reporting in libversit */ -} CalBackendLoadResult; +} CalBackendLoadStatus; struct _CalBackend { GtkObject object; @@ -62,7 +62,7 @@ GnomeVFSURI *cal_backend_get_uri (CalBackend *backend); void cal_backend_add_cal (CalBackend *backend, Cal *cal); -CalBackendLoadResult cal_backend_load (CalBackend *backend, char *str_uri); +CalBackendLoadStatus cal_backend_load (CalBackend *backend, GnomeVFSURI *uri); diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c index 053baebe5c..75c281d235 100644 --- a/calendar/pcs/cal-factory.c +++ b/calendar/pcs/cal-factory.c @@ -20,6 +20,7 @@ */ #include <config.h> +#include "cal-backend.h" #include "cal-factory.h" #include "job.h" @@ -27,7 +28,7 @@ /* Private part of the CalFactory structure */ typedef struct { - /* Hash table from GnomeVFSURI structures to loaded calendars */ + /* Hash table from GnomeVFSURI structures to CalBackend objects */ GHashTable *calendars; } CalFactoryPrivate; @@ -215,7 +216,33 @@ lookup_calendar (CalFactory *factory, GnomeVFSURI *uri) static void load_calendar (CalFactory *factory, GnomeVFSURI *uri, GNOME_Calendar_Listener listener) { - /* FIXME */ + CalFactoryPrivate *priv; + CalBackend *backend; + CalBackendLoadStatus status; + + priv = factory->priv; + + backend = cal_backend_new (); + if (!backend) { + CORBA_Environment ev; + + g_message ("load_calendar(): could not create the backend"); + + CORBA_exception_init (&ev); + GNOME_Calendar_Listener_cal_loaded (listener, + GNOME_Calendar_Listener_ERROR, + CORBA_OBJECT_NIL, + &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_message ("load_calendar(): could not notify the listener"); + CORBA_exception_free (&ev); + gtk_object_unref (backend); + return; + } + CORBA_exception_free (&ev); + } + + status = cal_backend_load (backend, uri); } /* Adds a listener to a calendar */ @@ -250,10 +277,15 @@ load_fn (gpointer data) g_free (jd->uri); CORBA_exception_init (&ev); - GNOME_Unknown_unref (jd->listener, &ev); CORBA_Object_release (jd->listener, &ev); + + if (ev._major != CORBA_NO_EXCEPTION) + g_message ("load_fn(): could not release the listener"); + CORBA_exception_free (&ev); + /* Done */ + g_free (jd); } @@ -303,6 +335,7 @@ cal_factory_corba_object_create (GnomeObject *object) CORBA_exception_init (&ev); POA_GNOME_Calendar_CalFactory__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { g_message ("cal_factory_corba_object_create(): could not init the servant"); g_free (servant); @@ -334,16 +367,16 @@ cal_factory_new (void) factory = gtk_type_new (CAL_FACTORY_TYPE); corba_factory = cal_factory_corba_object_create (GNOME_OBJECT (factory)); + CORBA_exception_init (&ev); retval = CORBA_Object_is_nil (corba_factory, &ev); if (ev._major != CORBA_NO_EXCEPTION || retval) { - g_message ("cal_factory_new(): could not create the CORBA object"); + g_message ("cal_factory_new(): could not create the CORBA factory"); gtk_object_unref (factory); CORBA_exception_free (&ev); return NULL; } - CORBA_exception_free (&ev); return cal_factory_construct (factory, corba_factory); @@ -357,8 +390,8 @@ cal_factory_load (CalFactory *factory, const char *uri, GNOME_Calendar_Listener GNOME_Calendar_Listener listener_copy; CORBA_exception_init (&ev); - listener_copy = CORBA_Object_duplicate (listener, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { g_message ("cal_factory_load(): could not duplicate the listener"); CORBA_exception_free (&ev); |