aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog15
-rw-r--r--calendar/cal-client/cal-listener.c9
-rw-r--r--calendar/cal-client/cal-listener.h3
-rw-r--r--calendar/cal-factory.c116
-rw-r--r--calendar/cal-factory.h2
-rw-r--r--calendar/cal-listener.c9
-rw-r--r--calendar/cal-listener.h3
-rw-r--r--calendar/evolution-calendar.idl2
-rw-r--r--calendar/idl/evolution-calendar.idl2
-rw-r--r--calendar/pcs/cal-factory.c116
-rw-r--r--calendar/pcs/cal-factory.h2
11 files changed, 251 insertions, 28 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 21812d4f17..a934f5145e 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,18 @@
+2000-01-18 Federico Mena Quintero <federico@helixcode.com>
+
+ * cal-factory.c (cal_factory_load): Queue a load job.
+ (load_fn): Load job handler. Lookup the calendar by URI, load it
+ if it is not loaded, or just report it to the new listener if it is.
+
+ * job.c job.h: New files with a simple job queue manager.
+
+ * gnome-calendar.idl (Listener::cal_loaded): Do not return the
+ whole calendar object string. The client will be able to query
+ the calendar for the events it needs.
+
+ * cal-listener.c (Listener_cal_loaded): Ref the calendar GNOME
+ object. We unref it when the listener is destroyed.
+
2000-01-11 Federico Mena Quintero <federico@helixcode.com>
* cal.c: Removed the CORBA listener methods, adjusted for the new
diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c
index 581f7eeb6e..2c3ffe119d 100644
--- a/calendar/cal-client/cal-listener.c
+++ b/calendar/cal-client/cal-listener.c
@@ -108,9 +108,8 @@ cal_listener_class_init (CalListenerClass *class)
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (CalListenerClass, cal_loaded),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_POINTER,
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
cal_listener_signals[OBJ_ADDED] =
gtk_signal_new ("obj_added",
@@ -205,7 +204,6 @@ cal_listener_destroy (GtkObject *object)
static void
Listener_cal_loaded (PortableServer_Servant servant,
GNOME_Calendar_Cal cal,
- GNOME_Calendar_CalObj calobj,
CORBA_Environment *ev)
{
CalListener *listener;
@@ -215,8 +213,9 @@ Listener_cal_loaded (PortableServer_Servant servant,
priv = listener->priv;
priv->cal = CORBA_Object_duplicate (cal, ev);
+ GNOME_Unknown_ref (priv->cal);
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED],
- cal, calobj);
+ cal);
}
/* Listener::obj_added method */
diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h
index 55772cb1ba..41665b2b58 100644
--- a/calendar/cal-client/cal-listener.h
+++ b/calendar/cal-client/cal-listener.h
@@ -50,8 +50,7 @@ struct _CalListener {
struct _CalListenerClass {
GnomeObjectClass parent_class;
- void (* cal_loaded) (CalListener *listener, GNOME_Calendar_Cal cal,
- GNOME_Calendar_CalObj calobj);
+ void (* cal_loaded) (CalListener *listener, 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 2dc1260f1b..1874939c61 100644
--- a/calendar/cal-factory.c
+++ b/calendar/cal-factory.c
@@ -21,12 +21,13 @@
#include <config.h>
#include "cal-factory.h"
+#include "job.h"
/* Private part of the CalFactory structure */
typedef struct {
- /* Hash table from canonized uris to loaded calendars */
+ /* Hash table from GnomeVFSURI structures to loaded calendars */
GHashTable *calendars;
} CalFactoryPrivate;
@@ -106,7 +107,7 @@ cal_factory_init (CalFactory *factory)
priv = g_new0 (CalFactoryPrivate, 1);
factory->priv = priv;
- priv->calendars = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->calendars = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal);
}
/* Destroy handler for the calendar */
@@ -122,6 +123,8 @@ cal_factory_destroy (GtkObject *object)
factory = CAL_FACTORY (object);
priv = factory->priv;
+ /* FIXME: free the calendar hash table */
+
g_free (priv);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
@@ -152,6 +155,7 @@ CalFactory_load (PortableServer_Servant servant,
static GNOME_Calendar_Cal
CalFactory_create (PortableServer_Servant servant,
CORBA_char *uri,
+ GNOME_Calendar_Listener listener,
CORBA_Environment *ev)
{
CalFactory *factory;
@@ -160,9 +164,17 @@ CalFactory_create (PortableServer_Servant servant,
factory = CAL_FACTORY (gnome_object_from_servant (servant));
priv = factory->priv;
- return cal_factory_create (factory, uri);
+ cal_factory_create (factory, uri, listener);
}
+/**
+ * cal_factory_get_epv:
+ * @void:
+ *
+ * Creates an EPV for the CalFactory CORBA class.
+ *
+ * Return value: A newly-allocated EPV.
+ **/
POA_GNOME_Calendar_CalFactory__epv *
cal_factory_get_epv (void)
{
@@ -175,8 +187,6 @@ cal_factory_get_epv (void)
return epv;
}
-
-
/* Returns whether a CORBA object is nil */
static gboolean
corba_object_is_nil (CORBA_Object object)
@@ -191,6 +201,77 @@ corba_object_is_nil (CORBA_Object object)
return retval;
}
+
+
+/* Loading and creating calendars */
+
+/* Job data */
+typedef struct {
+ CalFactory *factory;
+ char *uri;
+ GNOME_Calendar_Listener listener;
+} LoadCreateJobData;
+
+/* Looks up a calendar in a factory's hash table of uri->cal */
+static Cal *
+lookup_calendar (CalFactory *factory, GnomeVFSURI *uri)
+{
+ CalFactoryPrivate *priv;
+ Cal *cal;
+
+ priv = factory->priv;
+
+ cal = g_hash_table_lookup (priv->calendars, uri);
+ return cal;
+}
+
+/* Loads a calendar and puts it in the factory's hash table */
+static void
+load_calendar (CalFactory *factory, GnomeVFSURI *uri, GNOME_Calendar_Listener listener)
+{
+}
+
+/* Adds a listener to a calendar */
+static void
+add_calendar_listener (CalFactory *factory, Cal *cal, GNOME_Calendar_Listener listener)
+{
+ /* FIXME */
+}
+
+/* Job handler for the load calendar command */
+static void
+load_fn (gpointer data)
+{
+ LoadCreateJobData jd;
+ GnomeVFSURI *uri;
+ Cal *cal;
+ CORBA_Environment ev;
+
+ jd = data;
+
+ /* Look up the calendar */
+
+ uri = gnome_vfs_uri_new (jd->uri);
+ cal = lookup_calendar (jd->factory, uri);
+
+ if (!cal)
+ load_calendar (factory, uri, jd->listener);
+ else
+ add_calendar_listener (factory, cal, jd->listener);
+
+ gnome_vfs_uri_unref (uri);
+ g_free (jd->uri);
+
+ CORBA_exception_init (&ev);
+ GNOME_Unknown_unref (jd->listener, &ev);
+ CORBA_Object_release (jd->listener, &ev);
+ CORBA_exception_free (&ev);
+
+ g_free (jd);
+}
+
+
+
/**
* cal_factory_construct:
* @factory: A calendar factory.
@@ -270,3 +351,28 @@ cal_factory_new (void)
return cal_factory_construct (factory, corba_factory);
}
+
+void
+cal_factory_load (CalFactory *factory, const char *uri, GNOME_Calendar_Listener listener)
+{
+ LoadCreateJobData *jd;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ jd = g_new (LoadCreateJobData, 1);
+ jd->factory = factory;
+ jd->uri = g_strdup (uri);
+ jd->listener = CORBA_Object_duplicate (listener, &ev);
+ GNOME_Unknown_ref (jd->listener);
+
+ job_add (load_fn, jd);
+
+ CORBA_exception_free (&ev);
+}
+
+void
+cal_factory_create (CalFactory *factory, const char *uri, GNOME_Calendar_Listener listener)
+{
+ /* FIXME */
+}
diff --git a/calendar/cal-factory.h b/calendar/cal-factory.h
index 0baa3f746a..0c227148c2 100644
--- a/calendar/cal-factory.h
+++ b/calendar/cal-factory.h
@@ -59,7 +59,7 @@ GNOME_Calendar_CalFactory cal_factory_corba_object_create (GnomeObject *object);
CalFactory *cal_factory_new (void);
void cal_factory_load (CalFactory *factory, const char *uri, GNOME_Calendar_Listener listener);
-GNOME_Calendar_Cal cal_factory_create (CalFactory *factory, const char *uri);
+void cal_factory_create (CalFactory *factory, const char *uri, GNOME_Calendar_Listener listener);
POA_GNOME_Calendar_CalFactory__epv *cal_factory_get_epv (void);
diff --git a/calendar/cal-listener.c b/calendar/cal-listener.c
index 581f7eeb6e..2c3ffe119d 100644
--- a/calendar/cal-listener.c
+++ b/calendar/cal-listener.c
@@ -108,9 +108,8 @@ cal_listener_class_init (CalListenerClass *class)
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (CalListenerClass, cal_loaded),
- gtk_marshal_NONE__POINTER_POINTER,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_POINTER,
+ gtk_marshal_NONE__POINTER,
+ GTK_TYPE_NONE, 1,
GTK_TYPE_POINTER);
cal_listener_signals[OBJ_ADDED] =
gtk_signal_new ("obj_added",
@@ -205,7 +204,6 @@ cal_listener_destroy (GtkObject *object)
static void
Listener_cal_loaded (PortableServer_Servant servant,
GNOME_Calendar_Cal cal,
- GNOME_Calendar_CalObj calobj,
CORBA_Environment *ev)
{
CalListener *listener;
@@ -215,8 +213,9 @@ Listener_cal_loaded (PortableServer_Servant servant,
priv = listener->priv;
priv->cal = CORBA_Object_duplicate (cal, ev);
+ GNOME_Unknown_ref (priv->cal);
gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED],
- cal, calobj);
+ cal);
}
/* Listener::obj_added method */
diff --git a/calendar/cal-listener.h b/calendar/cal-listener.h
index 55772cb1ba..41665b2b58 100644
--- a/calendar/cal-listener.h
+++ b/calendar/cal-listener.h
@@ -50,8 +50,7 @@ struct _CalListener {
struct _CalListenerClass {
GnomeObjectClass parent_class;
- void (* cal_loaded) (CalListener *listener, GNOME_Calendar_Cal cal,
- GNOME_Calendar_CalObj calobj);
+ void (* cal_loaded) (CalListener *listener, 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 6357a014d0..77d4c1193c 100644
--- a/calendar/evolution-calendar.idl
+++ b/calendar/evolution-calendar.idl
@@ -36,7 +36,7 @@ module Calendar {
/* 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, in CalObj calobj);
+ void cal_loaded (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 6357a014d0..77d4c1193c 100644
--- a/calendar/idl/evolution-calendar.idl
+++ b/calendar/idl/evolution-calendar.idl
@@ -36,7 +36,7 @@ module Calendar {
/* 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, in CalObj calobj);
+ void cal_loaded (in Cal cal);
/* Called from a Calendar when an object is added */
void obj_added (in CalObj calobj);
diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c
index 2dc1260f1b..1874939c61 100644
--- a/calendar/pcs/cal-factory.c
+++ b/calendar/pcs/cal-factory.c
@@ -21,12 +21,13 @@
#include <config.h>
#include "cal-factory.h"
+#include "job.h"
/* Private part of the CalFactory structure */
typedef struct {
- /* Hash table from canonized uris to loaded calendars */
+ /* Hash table from GnomeVFSURI structures to loaded calendars */
GHashTable *calendars;
} CalFactoryPrivate;
@@ -106,7 +107,7 @@ cal_factory_init (CalFactory *factory)
priv = g_new0 (CalFactoryPrivate, 1);
factory->priv = priv;
- priv->calendars = g_hash_table_new (g_str_hash, g_str_equal);
+ priv->calendars = g_hash_table_new (gnome_vfs_uri_hash, gnome_vfs_uri_hequal);
}
/* Destroy handler for the calendar */
@@ -122,6 +123,8 @@ cal_factory_destroy (GtkObject *object)
factory = CAL_FACTORY (object);
priv = factory->priv;
+ /* FIXME: free the calendar hash table */
+
g_free (priv);
if (GTK_OBJECT_CLASS (parent_class)->destroy)
@@ -152,6 +155,7 @@ CalFactory_load (PortableServer_Servant servant,
static GNOME_Calendar_Cal
CalFactory_create (PortableServer_Servant servant,
CORBA_char *uri,
+ GNOME_Calendar_Listener listener,
CORBA_Environment *ev)
{
CalFactory *factory;
@@ -160,9 +164,17 @@ CalFactory_create (PortableServer_Servant servant,
factory = CAL_FACTORY (gnome_object_from_servant (servant));
priv = factory->priv;
- return cal_factory_create (factory, uri);
+ cal_factory_create (factory, uri, listener);
}
+/**
+ * cal_factory_get_epv:
+ * @void:
+ *
+ * Creates an EPV for the CalFactory CORBA class.
+ *
+ * Return value: A newly-allocated EPV.
+ **/
POA_GNOME_Calendar_CalFactory__epv *
cal_factory_get_epv (void)
{
@@ -175,8 +187,6 @@ cal_factory_get_epv (void)
return epv;
}
-
-
/* Returns whether a CORBA object is nil */
static gboolean
corba_object_is_nil (CORBA_Object object)
@@ -191,6 +201,77 @@ corba_object_is_nil (CORBA_Object object)
return retval;
}
+
+
+/* Loading and creating calendars */
+
+/* Job data */
+typedef struct {
+ CalFactory *factory;
+ char *uri;
+ GNOME_Calendar_Listener listener;
+} LoadCreateJobData;
+
+/* Looks up a calendar in a factory's hash table of uri->cal */
+static Cal *
+lookup_calendar (CalFactory *factory, GnomeVFSURI *uri)
+{
+ CalFactoryPrivate *priv;
+ Cal *cal;
+
+ priv = factory->priv;
+
+ cal = g_hash_table_lookup (priv->calendars, uri);
+ return cal;
+}
+
+/* Loads a calendar and puts it in the factory's hash table */
+static void
+load_calendar (CalFactory *factory, GnomeVFSURI *uri, GNOME_Calendar_Listener listener)
+{
+}
+
+/* Adds a listener to a calendar */
+static void
+add_calendar_listener (CalFactory *factory, Cal *cal, GNOME_Calendar_Listener listener)
+{
+ /* FIXME */
+}
+
+/* Job handler for the load calendar command */
+static void
+load_fn (gpointer data)
+{
+ LoadCreateJobData jd;
+ GnomeVFSURI *uri;
+ Cal *cal;
+ CORBA_Environment ev;
+
+ jd = data;
+
+ /* Look up the calendar */
+
+ uri = gnome_vfs_uri_new (jd->uri);
+ cal = lookup_calendar (jd->factory, uri);
+
+ if (!cal)
+ load_calendar (factory, uri, jd->listener);
+ else
+ add_calendar_listener (factory, cal, jd->listener);
+
+ gnome_vfs_uri_unref (uri);
+ g_free (jd->uri);
+
+ CORBA_exception_init (&ev);
+ GNOME_Unknown_unref (jd->listener, &ev);
+ CORBA_Object_release (jd->listener, &ev);
+ CORBA_exception_free (&ev);
+
+ g_free (jd);
+}
+
+
+
/**
* cal_factory_construct:
* @factory: A calendar factory.
@@ -270,3 +351,28 @@ cal_factory_new (void)
return cal_factory_construct (factory, corba_factory);
}
+
+void
+cal_factory_load (CalFactory *factory, const char *uri, GNOME_Calendar_Listener listener)
+{
+ LoadCreateJobData *jd;
+ CORBA_Environment ev;
+
+ CORBA_exception_init (&ev);
+
+ jd = g_new (LoadCreateJobData, 1);
+ jd->factory = factory;
+ jd->uri = g_strdup (uri);
+ jd->listener = CORBA_Object_duplicate (listener, &ev);
+ GNOME_Unknown_ref (jd->listener);
+
+ job_add (load_fn, jd);
+
+ CORBA_exception_free (&ev);
+}
+
+void
+cal_factory_create (CalFactory *factory, const char *uri, GNOME_Calendar_Listener listener)
+{
+ /* FIXME */
+}
diff --git a/calendar/pcs/cal-factory.h b/calendar/pcs/cal-factory.h
index 0baa3f746a..0c227148c2 100644
--- a/calendar/pcs/cal-factory.h
+++ b/calendar/pcs/cal-factory.h
@@ -59,7 +59,7 @@ GNOME_Calendar_CalFactory cal_factory_corba_object_create (GnomeObject *object);
CalFactory *cal_factory_new (void);
void cal_factory_load (CalFactory *factory, const char *uri, GNOME_Calendar_Listener listener);
-GNOME_Calendar_Cal cal_factory_create (CalFactory *factory, const char *uri);
+void cal_factory_create (CalFactory *factory, const char *uri, GNOME_Calendar_Listener listener);
POA_GNOME_Calendar_CalFactory__epv *cal_factory_get_epv (void);