aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/pcs')
-rw-r--r--calendar/pcs/cal-backend.c21
-rw-r--r--calendar/pcs/cal-backend.h4
-rw-r--r--calendar/pcs/cal-factory.c45
3 files changed, 49 insertions, 21 deletions
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);