aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/pcs/cal-factory.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/pcs/cal-factory.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/pcs/cal-factory.c')
-rw-r--r--calendar/pcs/cal-factory.c298
1 files changed, 86 insertions, 212 deletions
diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c
index 3834c34e62..40ffd2b735 100644
--- a/calendar/pcs/cal-factory.c
+++ b/calendar/pcs/cal-factory.c
@@ -1,8 +1,9 @@
/* Evolution calendar factory
*
* 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
@@ -197,58 +198,7 @@ cal_factory_destroy (GtkObject *object)
-/* Loading and creating calendars */
-
-/* Job data */
-typedef struct {
- CalFactory *factory;
- char *uri;
- GNOME_Evolution_Calendar_Listener listener;
-} LoadCreateJobData;
-
-/* Queues a load or create request */
-static void
-queue_load_create_job (CalFactory *factory, const char *uri, GNOME_Evolution_Calendar_Listener listener,
- JobFunc func)
-{
- LoadCreateJobData *jd;
- CORBA_Environment ev;
- GNOME_Evolution_Calendar_Listener listener_copy;
- gboolean result;
-
- g_assert (uri != NULL);
-
- CORBA_exception_init (&ev);
- result = CORBA_Object_is_nil (listener, &ev);
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("queue_load_create_job(): could not see if the listener was NIL");
- CORBA_exception_free (&ev);
- return;
- }
- CORBA_exception_free (&ev);
-
- if (result) {
- g_message ("queue_load_create_job(): cannot operate on a NIL listener!");
- return;
- }
-
- listener_copy = CORBA_Object_duplicate (listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION) {
- g_message ("queue_load_create_job(): could not duplicate the listener");
- CORBA_exception_free (&ev);
- return;
- }
-
- CORBA_exception_free (&ev);
-
- jd = g_new (LoadCreateJobData, 1);
- jd->factory = factory;
- jd->uri = g_strdup (uri);
- jd->listener = listener_copy;
-
- job_add (func, jd);
-}
+/* Opening calendars */
/* Looks up a calendar backend in a factory's hash table of uri->cal */
static CalBackend *
@@ -339,7 +289,7 @@ launch_backend_for_uri (CalFactory *factory, GnomeVFSURI *uri, GNOME_Evolution_C
CORBA_Environment ev;
CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Listener_notifyCalLoaded (
+ GNOME_Evolution_Calendar_Listener_notifyCalOpened (
listener,
GNOME_Evolution_Calendar_Listener_METHOD_NOT_SUPPORTED,
CORBA_OBJECT_NIL,
@@ -359,13 +309,14 @@ launch_backend_for_uri (CalFactory *factory, GnomeVFSURI *uri, GNOME_Evolution_C
return backend;
}
-/* Loads a calendar backend and puts it in the factory's backend hash table */
+/* Opens a calendar backend and puts it in the factory's backend hash table */
static CalBackend *
-load_backend (CalFactory *factory, GnomeVFSURI *uri, GNOME_Evolution_Calendar_Listener listener)
+open_backend (CalFactory *factory, GnomeVFSURI *uri, gboolean only_if_exists,
+ GNOME_Evolution_Calendar_Listener listener)
{
CalFactoryPrivate *priv;
CalBackend *backend;
- CalBackendLoadStatus status;
+ CalBackendOpenStatus status;
CORBA_Environment ev;
priv = factory->priv;
@@ -374,70 +325,49 @@ load_backend (CalFactory *factory, GnomeVFSURI *uri, GNOME_Evolution_Calendar_Li
if (!backend)
return NULL;
- status = cal_backend_load (backend, uri);
+ status = cal_backend_open (backend, uri, only_if_exists);
switch (status) {
- case CAL_BACKEND_LOAD_SUCCESS:
+ case CAL_BACKEND_OPEN_SUCCESS:
add_backend (factory, uri, backend);
return backend;
- case CAL_BACKEND_LOAD_ERROR:
+ case CAL_BACKEND_OPEN_ERROR:
gtk_object_unref (GTK_OBJECT (backend));
CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Listener_notifyCalLoaded (listener,
- GNOME_Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
+ GNOME_Evolution_Calendar_Listener_notifyCalOpened (
+ listener,
+ GNOME_Evolution_Calendar_Listener_ERROR,
+ CORBA_OBJECT_NIL,
+ &ev);
if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("load_backend(): could not notify the listener");
+ g_message ("open_backend(): could not notify the listener");
CORBA_exception_free (&ev);
return NULL;
- default:
- g_assert_not_reached ();
- return NULL;
- }
-}
-
-/* Creates a calendar backend and puts it in the factory's backend hash table */
-static CalBackend *
-create_backend (CalFactory *factory, GnomeVFSURI *uri, GNOME_Evolution_Calendar_Listener listener)
-{
- CalFactoryPrivate *priv;
- CalBackend *backend;
-
- priv = factory->priv;
-
- backend = launch_backend_for_uri (factory, uri, listener);
- if (!backend)
- return NULL;
-
- cal_backend_create (backend, uri);
-
- /* FIXME: add error reporting to cal_backend_create() */
-#if 0
- {
- CORBA_Environment ev;
+ case CAL_BACKEND_OPEN_NOT_FOUND:
+ gtk_object_unref (GTK_OBJECT (backend));
CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Listener_notifyCalLoaded (listener,
- GNOME_Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
+ GNOME_Evolution_Calendar_Listener_notifyCalOpened (
+ listener,
+ GNOME_Evolution_Calendar_Listener_NOT_FOUND,
+ CORBA_OBJECT_NIL,
+ &ev);
if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("create_fn(): could not notify the listener");
+ g_message ("open_backend(): could not notify the listener");
CORBA_exception_free (&ev);
- }
-#endif
-
- add_backend (factory, uri, backend);
+ return NULL;
- return backend;
+ default:
+ g_assert_not_reached ();
+ return NULL;
+ }
}
/* Adds a listener to a calendar backend by creating a calendar client interface
@@ -454,10 +384,11 @@ add_calendar_client (CalFactory *factory, CalBackend *backend, GNOME_Evolution_C
g_message ("add_calendar_client(): could not create the calendar client interface");
CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Listener_notifyCalLoaded (listener,
- GNOME_Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
+ GNOME_Evolution_Calendar_Listener_notifyCalOpened (
+ listener,
+ GNOME_Evolution_Calendar_Listener_ERROR,
+ CORBA_OBJECT_NIL,
+ &ev);
if (ev._major != CORBA_NO_EXCEPTION)
g_message ("add_calendar_client(): could not notify the listener");
@@ -468,10 +399,11 @@ add_calendar_client (CalFactory *factory, CalBackend *backend, GNOME_Evolution_C
cal_backend_add_cal (backend, cal);
CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Listener_notifyCalLoaded (listener,
- GNOME_Evolution_Calendar_Listener_SUCCESS,
- bonobo_object_corba_objref (BONOBO_OBJECT (cal)),
- &ev);
+ GNOME_Evolution_Calendar_Listener_notifyCalOpened (
+ listener,
+ GNOME_Evolution_Calendar_Listener_SUCCESS,
+ bonobo_object_corba_objref (BONOBO_OBJECT (cal)),
+ &ev);
if (ev._major != CORBA_NO_EXCEPTION) {
g_message ("add_calendar_client(): could not notify the listener");
@@ -481,73 +413,22 @@ add_calendar_client (CalFactory *factory, CalBackend *backend, GNOME_Evolution_C
CORBA_exception_free (&ev);
}
-/* Job handler for the load calendar command */
-static void
-load_fn (gpointer data)
-{
- LoadCreateJobData *jd;
+/* Job data */
+typedef struct {
CalFactory *factory;
- GnomeVFSURI *uri;
+ char *uri;
+ gboolean only_if_exists;
GNOME_Evolution_Calendar_Listener listener;
- CalBackend *backend;
- CORBA_Environment ev;
-
- jd = data;
- g_assert (jd->uri != NULL);
-
- /* Check the URI */
-
- uri = gnome_vfs_uri_new (jd->uri);
- g_free (jd->uri);
-
- factory = jd->factory;
- listener = jd->listener;
- g_free (jd);
-
- if (!uri) {
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Listener_notifyCalLoaded (listener,
- GNOME_Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("load_fn(): Could not notify the listener!");
-
- CORBA_exception_free (&ev);
- goto out;
- }
-
- /* Look up the backend and create it if needed */
-
- backend = lookup_backend (factory, uri);
-
- if (!backend)
- backend = load_backend (factory, uri, listener);
-
- gnome_vfs_uri_unref (uri);
-
- if (backend)
- add_calendar_client (factory, backend, listener);
-
- out:
-
- CORBA_exception_init (&ev);
- CORBA_Object_release (listener, &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("load_fn(): could not release the listener");
+} OpenJobData;
- CORBA_exception_free (&ev);
-}
-
-/* Job handler for the create calendar command */
+/* Job handler for the open calendar command */
static void
-create_fn (gpointer data)
+open_fn (gpointer data)
{
- LoadCreateJobData *jd;
+ OpenJobData *jd;
CalFactory *factory;
GnomeVFSURI *uri;
+ gboolean only_if_exists;
GNOME_Evolution_Calendar_Listener listener;
CalBackend *backend;
CORBA_Environment ev;
@@ -560,58 +441,45 @@ create_fn (gpointer data)
uri = gnome_vfs_uri_new (jd->uri);
g_free (jd->uri);
+ only_if_exists = jd->only_if_exists;
factory = jd->factory;
listener = jd->listener;
g_free (jd);
if (!uri) {
CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Listener_notifyCalLoaded (listener,
- GNOME_Evolution_Calendar_Listener_ERROR,
- CORBA_OBJECT_NIL,
- &ev);
+ GNOME_Evolution_Calendar_Listener_notifyCalOpened (
+ listener,
+ GNOME_Evolution_Calendar_Listener_ERROR,
+ CORBA_OBJECT_NIL,
+ &ev);
if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("create_fn(): Could not notify the listener!");
+ g_message ("open_fn(): Could not notify the listener!");
CORBA_exception_free (&ev);
goto out;
}
- /* Check that the backend is not in use */
+ /* Look up the backend and create it if needed */
backend = lookup_backend (factory, uri);
- if (backend) {
- CORBA_exception_init (&ev);
- GNOME_Evolution_Calendar_Listener_notifyCalLoaded (listener,
- GNOME_Evolution_Calendar_Listener_IN_USE,
- CORBA_OBJECT_NIL,
- &ev);
-
- if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("create_fn(): could not notify the listener");
-
- CORBA_exception_free (&ev);
- goto out;
- }
-
- /* Create the backend */
+ if (!backend)
+ backend = open_backend (factory, uri, only_if_exists, listener);
- backend = create_backend (factory, uri, listener);
+ gnome_vfs_uri_unref (uri);
if (backend)
add_calendar_client (factory, backend, listener);
- gnome_vfs_uri_unref (uri);
-
out:
CORBA_exception_init (&ev);
CORBA_Object_release (listener, &ev);
if (ev._major != CORBA_NO_EXCEPTION)
- g_message ("create_fn(): could not release the listener");
+ g_message ("open_fn(): could not release the listener");
CORBA_exception_free (&ev);
}
@@ -620,10 +488,11 @@ create_fn (gpointer data)
/* CORBA servant implementation */
-/* CalFactory::load method */
+/* CalFactory::open method */
static void
-CalFactory_load (PortableServer_Servant servant,
+CalFactory_open (PortableServer_Servant servant,
const CORBA_char *uri,
+ CORBA_boolean only_if_exists,
GNOME_Evolution_Calendar_Listener listener,
CORBA_Environment *ev)
{
@@ -631,6 +500,8 @@ CalFactory_load (PortableServer_Servant servant,
CalFactoryPrivate *priv;
CORBA_Environment ev2;
gboolean result;
+ OpenJobData *jd;
+ GNOME_Evolution_Calendar_Listener listener_copy;
factory = CAL_FACTORY (bonobo_object_from_servant (servant));
priv = factory->priv;
@@ -648,23 +519,27 @@ CalFactory_load (PortableServer_Servant servant,
}
CORBA_exception_free (&ev2);
- queue_load_create_job (factory, uri, listener, load_fn);
-}
+ CORBA_exception_init (&ev2);
+ listener_copy = CORBA_Object_duplicate (listener, &ev2);
-/* CalFactory::create method */
-static void
-CalFactory_create (PortableServer_Servant servant,
- const CORBA_char *uri,
- GNOME_Evolution_Calendar_Listener listener,
- CORBA_Environment *ev)
-{
- CalFactory *factory;
- CalFactoryPrivate *priv;
+ if (ev2._major != CORBA_NO_EXCEPTION) {
+ g_message ("CalFactory_open(): could not duplicate the listener");
+ CORBA_exception_free (&ev2);
+ CORBA_exception_set (ev, CORBA_USER_EXCEPTION,
+ ex_GNOME_Evolution_Calendar_CalFactory_NilListener,
+ NULL);
+ return;
+ }
- factory = CAL_FACTORY (bonobo_object_from_servant (servant));
- priv = factory->priv;
+ CORBA_exception_free (&ev2);
+
+ jd = g_new (OpenJobData, 1);
+ jd->factory = factory;
+ jd->uri = g_strdup (uri);
+ jd->only_if_exists = only_if_exists;
+ jd->listener = listener_copy;
- queue_load_create_job (factory, uri, listener, create_fn);
+ job_add (open_fn, jd);
}
/**
@@ -681,8 +556,7 @@ cal_factory_get_epv (void)
POA_GNOME_Evolution_Calendar_CalFactory__epv *epv;
epv = g_new0 (POA_GNOME_Evolution_Calendar_CalFactory__epv, 1);
- epv->load = CalFactory_load;
- epv->create = CalFactory_create;
+ epv->open = CalFactory_open;
return epv;
}
@@ -802,7 +676,7 @@ str_tolower (const char *s)
* @backend_type: Class type of the backend to create for this @method.
*
* Registers the type of a #CalBackend subclass that will be used to handle URIs
- * with a particular method. When the factory is asked to load a particular
+ * with a particular method. When the factory is asked to open a particular
* URI, it will look in its list of registered methods and create a backend of
* the appropriate type.
**/