aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/cal-client/cal-listener.c
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@ximian.com>2001-01-17 18:44:33 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-01-17 18:44:33 +0800
commit0932fd7ec9d21e763371a043283384af8bc987fb (patch)
treedbfd7dcaf49fd667712a6408eae165bd201c3219 /calendar/cal-client/cal-listener.c
parentff6098b51168decc542245a215056dc6219ebd69 (diff)
downloadgsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.gz
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.bz2
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.lz
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.xz
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.zst
gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.zip
Ximianified email addresses and copyrights.
2001-01-17 Federico Mena Quintero <federico@ximian.com> * */*: Ximianified email addresses and copyrights. * idl/evolution-calendar.idl (CalFactory::open): Renamed from ::load(), and added an only_if_exists argument. (CalFactory::create): Removed method. (Listener::OpenStatus): Removed the IN_USE error and replaced it with a NOT_FOUND one; renamed the enum from LoadStatus. (Listener::notifyCalOpened): Renamed from notifyCalLoaded(). * pcs/cal-backend.h (CalBackend): Removed the uri field. (CalBackendOpenStatus): Renamed from CalBackendLoadStatus and added a NOT_FOUND value. (CalBackendClass::open): Put in a slot for the open method. * pcs/cal-backend.c (cal_backend_create): Removed function. * pcs/cal-backend-file.c (cal_backend_file_open): Return the appropriate value when only_if_exists is TRUE. (create_cal): We are Ximian now, so set the PRODID property to the appropriate foo. * pcs/cal-factory.c (CalFactory_open): implemented, replacing CalFactory_load() and CalFactory_create(). (CalFactory_open): Moved the queue_load_create_job() stuff to here, since we now only need to contemplate the open case instead of load/create ones. (open_backend): Do everything here; replaces load_backend() and create_backend(). * cal-client/cal-listener.h (CalListenerClass::cal_opened): Renamed from cal_loaded. (CalListenerClass): Replaced the silly signals, which are gratuitous abstraction, by a set of function pointers in the instance structure. * cal-client/cal-listener.c (cal_listener_get_calendar): Removed unused function. (cal_listener_construct): Added the listener notification functions. (cal_listener_new): Ditto. (Listener_notifyCalOpened): Renamed to our new naming convention for servant implementations. (Listener_notifyObjUpdated): Ditto. (Listener_notifyObjRemoved): Ditto. * cal-client/cal-client.h (CalClientOpenStatus): Renamed from CalClientLoadStatus. (CalClientClass::cal_opened): Renamed from ::cal_loaded(). (CalClientLoadState): New enum; basically make LoadState public so that users of this code do not have to maintain their own states. * cal-client/cal-client.c (cal_client_create_calendar): Removed function. (cal_client_open_calendar): Moved the functionality over from load_or_create(); now we do everything here. (*): Use the CalClientLoadState enum values instead of the old LoadState values. (cal_client_get_load_state): Renamed from cal_client_is_loaded(), and return the appropriate value. (CalClientPrivate): Added an uri field. (cal_client_init): Initialize priv->uri. (cal_client_destroy): Free the priv->uri. (cal_opened_cb): Maintain the priv->uri. (cal_client_open_calendar): Fill in the priv->uri. (cal_client_get_uri): New function. * gui/calendar-model.c (calendar_model_set_new_comp_vtype): New function to configure the type of calendar components to create when doing click-to-add. This makes the model usable for something other than task lists. (calendar_model_get_new_comp_vtype): New function. * gui/e-calendar-table.c (e_calendar_table_get_model): New function. (e_calendar_table_destroy): Unref the subset_model. * gui/gnome-cal.h (GnomeCalendarOpenMode): Removed enum. * gui/gnome-cal.c (LoadState): Removed enum; we now use the CalClientLoadState from the client objects. (GnomeCalendarPrivate): Removed the loading_uri and task_pad_loading_uri fields as well as the load_state and task_pad_load_state fields, as we can now query them directly from the CalClient. (open_error): Renamed from load_error(). (create_error): Removed function. (gnome_calendar_open): Do not take in the mode parameter. (cal_opened_cb): Get rid of our beautifully-crafted state machine and replace it with simple code; all the loading smarts are in the Wombat now. (setup_widgets): Set the new component vtype of the table model to CAL_COMPONENT_TODO. * gui/Makefile.am (evolution_calendar_SOURCES): Removed gnome-month-item.[ch] from the list of sources. * gui/calendar-summary.c (CalSummary): Removed unused cal_loaded field. (create_summary_view): Do not check if the file exists; this is the job of the Wombat. (generate_html_summary): Fixed prototype. (alarm_fn): Fixed prototype. (property_dialog): Fixed prototype. Wonder if/how this ever worked. (create_summary_view): Cast the component and view as appropriate. Removed unused html variable. [Iain dude, are you compiling with -Wall?] * gui/e-itip-control.c (cal_opened_cb): Sigh, this function signature was *very* wrong. It was using CalClientGetStatus instead of CalClientOpenStatus. * gui/e-tasks.h (ETasksOpenMode): Removed enum. * gui/e-tasks.c (setup_widgets): Set the new component vtype of the table model to CAL_COMPONENT_TODO. (LoadState): Removed the state machine foo. (e_tasks_open): Removed the mode parameter. (initial_load): Removed function. (create_error): Removed function. (ETasksPrivate): Removed folder_uri field. (cal_opened_cb): Remove the state machine. * gui/component-factory.c: #include "tasks-control.h" * conduits/calendar/calendar-conduit.h (ECalConduitContext): Removed calendar_load_tried field. * conduits/calendar/calendar-conduit.c (start_calendar_server_cb): Sigh, fixed function prototype. * conduits/todo/todo-conduit.h (EToDoConduitContext): Removed calendar_load_tried field. * conduits/todo/todo-conduit.c (start_calendar_server_cb): Fixed function prototype. svn path=/trunk/; revision=7571
Diffstat (limited to 'calendar/cal-client/cal-listener.c')
-rw-r--r--calendar/cal-client/cal-listener.c193
1 files changed, 89 insertions, 104 deletions
diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c
index cf7442b0e9..b5c3bdbd6b 100644
--- a/calendar/cal-client/cal-listener.c
+++ b/calendar/cal-client/cal-listener.c
@@ -1,8 +1,9 @@
/* Evolution calendar listener
*
* Copyright (C) 2000 Helix Code, Inc.
+ * Copyright (C) 2000 Ximian, Inc.
*
- * Author: Federico Mena-Quintero <federico@helixcode.com>
+ * Author: Federico Mena-Quintero <federico@ximian.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -29,28 +30,22 @@
struct _CalListenerPrivate {
/* The calendar this listener refers to */
GNOME_Evolution_Calendar_Cal cal;
+
+ /* Notification functions and their closure data */
+ CalListenerCalOpenedFn cal_opened_fn;
+ CalListenerObjUpdatedFn obj_updated_fn;
+ CalListenerObjRemovedFn obj_removed_fn;
+ gpointer fn_data;
};
-/* Signal IDs */
-enum {
- CAL_LOADED,
- OBJ_UPDATED,
- OBJ_REMOVED,
- LAST_SIGNAL
-};
-
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_Evolution_Calendar_Listener__vepv cal_listener_vepv;
-static guint cal_listener_signals[LAST_SIGNAL];
-
static BonoboObjectClass *parent_class;
@@ -105,34 +100,6 @@ cal_listener_class_init (CalListenerClass *class)
parent_class = gtk_type_class (bonobo_object_get_type ());
- cal_listener_signals[CAL_LOADED] =
- gtk_signal_new ("cal_loaded",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, cal_loaded),
- marshal_cal_loaded,
- GTK_TYPE_NONE, 2,
- GTK_TYPE_ENUM,
- GTK_TYPE_POINTER);
- cal_listener_signals[OBJ_UPDATED] =
- gtk_signal_new ("obj_updated",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, obj_updated),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
- cal_listener_signals[OBJ_REMOVED] =
- gtk_signal_new ("obj_removed",
- GTK_RUN_FIRST,
- object_class->type,
- GTK_SIGNAL_OFFSET (CalListenerClass, obj_removed),
- gtk_marshal_NONE__POINTER,
- GTK_TYPE_NONE, 1,
- GTK_TYPE_POINTER);
-
- gtk_object_class_add_signals (object_class, cal_listener_signals, LAST_SIGNAL);
-
object_class->destroy = cal_listener_destroy;
init_cal_listener_corba_class ();
@@ -148,6 +115,9 @@ cal_listener_init (CalListener *listener)
listener->priv = priv;
priv->cal = CORBA_OBJECT_NIL;
+ priv->cal_opened_fn = NULL;
+ priv->obj_updated_fn = NULL;
+ priv->obj_removed_fn = NULL;
}
/* Destroy handler for the calendar listener */
@@ -192,29 +162,14 @@ 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 */
+/* Listener::notifyCalOpened method */
static void
-Listener_cal_loaded (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_Listener_LoadStatus status,
- GNOME_Evolution_Calendar_Cal cal,
- CORBA_Environment *ev)
+Listener_notifyCalOpened (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_Listener_OpenStatus status,
+ GNOME_Evolution_Calendar_Cal cal,
+ CORBA_Environment *ev)
{
CalListener *listener;
CalListenerPrivate *priv;
@@ -225,7 +180,7 @@ Listener_cal_loaded (PortableServer_Servant servant,
priv = listener->priv;
if (priv->cal != CORBA_OBJECT_NIL) {
- g_message ("Listener_cal_loaded(): calendar was already loaded!");
+ g_message ("Listener_notifyCalOpened(): calendar was already open!");
return;
}
@@ -233,7 +188,7 @@ Listener_cal_loaded (PortableServer_Servant servant,
cal_copy = CORBA_Object_duplicate (cal, &aev);
if (aev._major != CORBA_NO_EXCEPTION) {
- g_message ("Listener_cal_loaded(): could not duplicate the calendar");
+ g_message ("Listener_notifyCalOpened(): could not duplicate the calendar");
CORBA_exception_free (&aev);
return;
}
@@ -241,34 +196,40 @@ Listener_cal_loaded (PortableServer_Servant servant,
priv->cal = cal_copy;
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[CAL_LOADED],
- status, cal);
+ g_assert (priv->cal_opened_fn != NULL);
+ (* priv->cal_opened_fn) (listener, status, cal, priv->fn_data);
}
-/* Listener::obj_updated method */
+/* Listener::notifyObjUpdated method */
static void
-Listener_obj_updated (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
+Listener_notifyObjUpdated (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_CalObjUID uid,
+ CORBA_Environment *ev)
{
CalListener *listener;
+ CalListenerPrivate *priv;
listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_UPDATED],
- uid);
+ priv = listener->priv;
+
+ g_assert (priv->obj_updated_fn != NULL);
+ (* priv->obj_updated_fn) (listener, uid, priv->fn_data);
}
-/* Listener::obj_removed method */
+/* Listener::notifyObjRemoved method */
static void
-Listener_obj_removed (PortableServer_Servant servant,
- GNOME_Evolution_Calendar_CalObjUID uid,
- CORBA_Environment *ev)
+Listener_notifyObjRemoved (PortableServer_Servant servant,
+ GNOME_Evolution_Calendar_CalObjUID uid,
+ CORBA_Environment *ev)
{
CalListener *listener;
+ CalListenerPrivate *priv;
listener = CAL_LISTENER (bonobo_object_from_servant (servant));
- gtk_signal_emit (GTK_OBJECT (listener), cal_listener_signals[OBJ_REMOVED],
- uid);
+ priv = listener->priv;
+
+ g_assert (priv->obj_removed_fn != NULL);
+ (* priv->obj_removed_fn) (listener, uid, priv->fn_data);
}
/**
@@ -285,9 +246,9 @@ cal_listener_get_epv (void)
POA_GNOME_Evolution_Calendar_Listener__epv *epv;
epv = g_new0 (POA_GNOME_Evolution_Calendar_Listener__epv, 1);
- epv->notifyCalLoaded = Listener_cal_loaded;
- epv->notifyObjUpdated = Listener_obj_updated;
- epv->notifyObjRemoved = Listener_obj_removed;
+ epv->notifyCalOpened = Listener_notifyCalOpened;
+ epv->notifyObjUpdated = Listener_notifyObjUpdated;
+ epv->notifyObjRemoved = Listener_notifyObjRemoved;
return epv;
}
@@ -297,6 +258,14 @@ cal_listener_get_epv (void)
* cal_listener_construct:
* @listener: A calendar listener.
* @corba_listener: CORBA object for the calendar listener.
+ * @cal_opened_fn: Function that will be called to notify that a calendar was
+ * opened.
+ * @obj_updated_fn: Function that will be called to notify that an object in the
+ * calendar was updated.
+ * @obj_removed_fn: Function that will be called to notify that an object in the
+ * calendar was removed.
+ * @fn_data: Closure data pointer that will be passed to the notification
+ * functions.
*
* Constructs a calendar listener by binding the corresponding CORBA object to
* it.
@@ -304,10 +273,27 @@ cal_listener_get_epv (void)
* Return value: the same object as the @listener argument.
**/
CalListener *
-cal_listener_construct (CalListener *listener, GNOME_Evolution_Calendar_Listener corba_listener)
+cal_listener_construct (CalListener *listener,
+ GNOME_Evolution_Calendar_Listener corba_listener,
+ CalListenerCalOpenedFn cal_opened_fn,
+ CalListenerObjUpdatedFn obj_updated_fn,
+ CalListenerObjRemovedFn obj_removed_fn,
+ gpointer fn_data)
{
+ CalListenerPrivate *priv;
+
g_return_val_if_fail (listener != NULL, NULL);
g_return_val_if_fail (IS_CAL_LISTENER (listener), NULL);
+ g_return_val_if_fail (cal_opened_fn != NULL, NULL);
+ g_return_val_if_fail (obj_updated_fn != NULL, NULL);
+ g_return_val_if_fail (obj_removed_fn != NULL, NULL);
+
+ priv = listener->priv;
+
+ priv->cal_opened_fn = cal_opened_fn;
+ priv->obj_updated_fn = obj_updated_fn;
+ priv->obj_removed_fn = obj_removed_fn;
+ priv->fn_data = fn_data;
bonobo_object_construct (BONOBO_OBJECT (listener), corba_listener);
return listener;
@@ -349,7 +335,14 @@ cal_listener_corba_object_create (BonoboObject *object)
/**
* cal_listener_new:
- * @void:
+ * @cal_opened_fn: Function that will be called to notify that a calendar was
+ * opened.
+ * @obj_updated_fn: Function that will be called to notify that an object in the
+ * calendar was updated.
+ * @obj_removed_fn: Function that will be called to notify that an object in the
+ * calendar was removed.
+ * @fn_data: Closure data pointer that will be passed to the notification
+ * functions.
*
* Creates a new #CalListener object.
*
@@ -357,13 +350,20 @@ cal_listener_corba_object_create (BonoboObject *object)
* CORBA object could not be created.
**/
CalListener *
-cal_listener_new (void)
+cal_listener_new (CalListenerCalOpenedFn cal_opened_fn,
+ CalListenerObjUpdatedFn obj_updated_fn,
+ CalListenerObjRemovedFn obj_removed_fn,
+ gpointer fn_data)
{
CalListener *listener;
CORBA_Environment ev;
GNOME_Evolution_Calendar_Listener corba_listener;
gboolean result;
+ g_return_val_if_fail (cal_opened_fn != NULL, NULL);
+ g_return_val_if_fail (obj_updated_fn != NULL, NULL);
+ g_return_val_if_fail (obj_removed_fn != NULL, NULL);
+
listener = gtk_type_new (CAL_LISTENER_TYPE);
corba_listener = cal_listener_corba_object_create (BONOBO_OBJECT (listener));
@@ -379,25 +379,10 @@ cal_listener_new (void)
}
CORBA_exception_free (&ev);
- return cal_listener_construct (listener, corba_listener);
-}
-
-/**
- * cal_listener_get_calendar:
- * @listener: A calendar listener.
- *
- * Queries the calendar that a listener is watching.
- *
- * Return value: The calendar that the listener is watching.
- **/
-GNOME_Evolution_Calendar_Cal
-cal_listener_get_calendar (CalListener *listener)
-{
- CalListenerPrivate *priv;
-
- g_return_val_if_fail (listener != NULL, CORBA_OBJECT_NIL);
- g_return_val_if_fail (IS_CAL_LISTENER (listener), CORBA_OBJECT_NIL);
-
- priv = listener->priv;
- return priv->cal;
+ return cal_listener_construct (listener,
+ corba_listener,
+ cal_opened_fn,
+ obj_updated_fn,
+ obj_removed_fn,
+ fn_data);
}