diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-01-17 18:44:33 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-01-17 18:44:33 +0800 |
commit | 0932fd7ec9d21e763371a043283384af8bc987fb (patch) | |
tree | dbfd7dcaf49fd667712a6408eae165bd201c3219 /calendar/pcs | |
parent | ff6098b51168decc542245a215056dc6219ebd69 (diff) | |
download | gsoc2013-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')
-rw-r--r-- | calendar/pcs/cal-backend-file.c | 147 | ||||
-rw-r--r-- | calendar/pcs/cal-backend-file.h | 3 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.c | 99 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.h | 22 | ||||
-rw-r--r-- | calendar/pcs/cal-common.h | 3 | ||||
-rw-r--r-- | calendar/pcs/cal-factory.c | 298 | ||||
-rw-r--r-- | calendar/pcs/cal-factory.h | 3 | ||||
-rw-r--r-- | calendar/pcs/cal.c | 3 | ||||
-rw-r--r-- | calendar/pcs/cal.h | 3 | ||||
-rw-r--r-- | calendar/pcs/job.c | 3 | ||||
-rw-r--r-- | calendar/pcs/job.h | 3 |
11 files changed, 214 insertions, 373 deletions
diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index 10d0a35746..623031fa69 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -1,8 +1,9 @@ /* Evolution calendar - iCalendar file backend * * 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 @@ -65,8 +66,8 @@ static void cal_backend_file_destroy (GtkObject *object); static GnomeVFSURI *cal_backend_file_get_uri (CalBackend *backend); static void cal_backend_file_add_cal (CalBackend *backend, Cal *cal); -static CalBackendLoadStatus cal_backend_file_load (CalBackend *backend, GnomeVFSURI *uri); -static void cal_backend_file_create (CalBackend *backend, GnomeVFSURI *uri); +static CalBackendOpenStatus cal_backend_file_open (CalBackend *backend, GnomeVFSURI *uri, + gboolean only_if_exists); static int cal_backend_file_get_n_objects (CalBackend *backend, CalObjType type); static char *cal_backend_file_get_object (CalBackend *backend, const char *uid); @@ -138,8 +139,7 @@ cal_backend_file_class_init (CalBackendFileClass *class) backend_class->get_uri = cal_backend_file_get_uri; backend_class->add_cal = cal_backend_file_add_cal; - backend_class->load = cal_backend_file_load; - backend_class->create = cal_backend_file_create; + backend_class->open = cal_backend_file_open; backend_class->get_n_objects = cal_backend_file_get_n_objects; backend_class->get_object = cal_backend_file_get_object; backend_class->get_type_by_uid = cal_backend_file_get_type_by_uid; @@ -587,7 +587,7 @@ scan_vcalendar (CalBackendFile *cbfile) /* Callback used from icalparser_parse() */ static char * -get_line (char *s, size_t size, void *data) +get_line_fn (char *s, size_t size, void *data) { FILE *file; @@ -595,91 +595,71 @@ get_line (char *s, size_t size, void *data) return fgets (s, size, file); } -/* Load handler for the file backend */ -static CalBackendLoadStatus -cal_backend_file_load (CalBackend *backend, GnomeVFSURI *uri) +/* Parses an open iCalendar file and returns a toplevel component with the contents */ +static icalcomponent * +parse_file (FILE *file) { - CalBackendFile *cbfile; - CalBackendFilePrivate *priv; - char *str_uri; - FILE *file; icalparser *parser; icalcomponent *icalcomp; - cbfile = CAL_BACKEND_FILE (backend); - priv = cbfile->priv; - - g_return_val_if_fail (priv->icalcomp == NULL, CAL_BACKEND_LOAD_ERROR); - g_return_val_if_fail (uri != NULL, CAL_BACKEND_LOAD_ERROR); + parser = icalparser_new (); + icalparser_set_gen_data (parser, file); - if (!gnome_vfs_uri_is_local (uri)) - return CAL_BACKEND_LOAD_ERROR; + icalcomp = icalparser_parse (parser, get_line_fn); + icalparser_free (parser); - str_uri = gnome_vfs_uri_to_string (uri, - (GNOME_VFS_URI_HIDE_USER_NAME - | GNOME_VFS_URI_HIDE_PASSWORD - | GNOME_VFS_URI_HIDE_HOST_NAME - | GNOME_VFS_URI_HIDE_HOST_PORT - | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD)); + return icalcomp; +} - /* Load! */ - file = fopen (str_uri, "r"); - g_free (str_uri); +/* Parses an open iCalendar file and loads it into the backend */ +static CalBackendOpenStatus +open_cal (CalBackendFile *cbfile, GnomeVFSURI *uri, FILE *file) +{ + CalBackendFilePrivate *priv; + icalcomponent *icalcomp; - if (!file) - return CAL_BACKEND_LOAD_ERROR; + priv = cbfile->priv; - parser = icalparser_new (); - icalparser_set_gen_data (parser, file); + icalcomp = parse_file (file); - icalcomp = icalparser_parse (parser, get_line); - icalparser_free (parser); + if (fclose (file) != 0) { + if (icalcomp) + icalcomponent_free (icalcomp); - if (fclose (file) != 0) - return CAL_BACKEND_LOAD_ERROR; + return CAL_BACKEND_OPEN_ERROR; + } if (!icalcomp) - return CAL_BACKEND_LOAD_ERROR; - - /* FIXME: should we try to demangle XROOT components and individual - * components as well? + return CAL_BACKEND_OPEN_ERROR; + + /* FIXME: should we try to demangle XROOT components and + * individual components as well? */ if (icalcomponent_isa (icalcomp) != ICAL_VCALENDAR_COMPONENT) - return CAL_BACKEND_LOAD_ERROR; + return CAL_BACKEND_OPEN_ERROR; priv->icalcomp = icalcomp; priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); scan_vcalendar (cbfile); - /* Clean up */ - if (priv->uri) - gnome_vfs_uri_unref (priv->uri); - gnome_vfs_uri_ref (uri); priv->uri = uri; - return CAL_BACKEND_LOAD_SUCCESS; + return CAL_BACKEND_OPEN_SUCCESS; } -/* Create handler for the file backend */ -static void -cal_backend_file_create (CalBackend *backend, GnomeVFSURI *uri) +static CalBackendOpenStatus +create_cal (CalBackendFile *cbfile, GnomeVFSURI *uri) { - CalBackendFile *cbfile; CalBackendFilePrivate *priv; icalproperty *prop; - cbfile = CAL_BACKEND_FILE (backend); priv = cbfile->priv; - g_return_if_fail (priv->icalcomp == NULL); - g_return_if_fail (uri != NULL); - /* Create the new calendar information */ - g_assert (priv->icalcomp == NULL); priv->icalcomp = icalcomponent_new (ICAL_VCALENDAR_COMPONENT); /* RFC 2445, section 4.7.1 */ @@ -687,26 +667,67 @@ cal_backend_file_create (CalBackend *backend, GnomeVFSURI *uri) icalcomponent_add_property (priv->icalcomp, prop); /* RFC 2445, section 4.7.3 */ - prop = icalproperty_new_prodid ("-//Helix Code//NONSGML Evolution Calendar//EN"); + prop = icalproperty_new_prodid ("-//Ximian//NONSGML Evolution Calendar//EN"); icalcomponent_add_property (priv->icalcomp, prop); - /* RFC 2445, section 4.7.4 */ + /* RFC 2445, section 4.7.4. This is the iCalendar spec version, *NOT* + * the product version! Do not change this! + */ prop = icalproperty_new_version ("2.0"); icalcomponent_add_property (priv->icalcomp, prop); /* Create our internal data */ - g_assert (priv->comp_uid_hash == NULL); priv->comp_uid_hash = g_hash_table_new (g_str_hash, g_str_equal); - /* Clean up */ - if (priv->uri) - gnome_vfs_uri_unref (priv->uri); - gnome_vfs_uri_ref (uri); priv->uri = uri; mark_dirty (cbfile); + + return CAL_BACKEND_OPEN_SUCCESS; +} + +/* Open handler for the file backend */ +static CalBackendOpenStatus +cal_backend_file_open (CalBackend *backend, GnomeVFSURI *uri, gboolean only_if_exists) +{ + CalBackendFile *cbfile; + CalBackendFilePrivate *priv; + char *str_uri; + FILE *file; + + cbfile = CAL_BACKEND_FILE (backend); + priv = cbfile->priv; + + g_return_val_if_fail (priv->icalcomp == NULL, CAL_BACKEND_OPEN_ERROR); + g_return_val_if_fail (uri != NULL, CAL_BACKEND_OPEN_ERROR); + + g_assert (priv->uri == NULL); + g_assert (priv->comp_uid_hash == NULL); + + if (!gnome_vfs_uri_is_local (uri)) + return CAL_BACKEND_OPEN_ERROR; + + str_uri = gnome_vfs_uri_to_string (uri, + (GNOME_VFS_URI_HIDE_USER_NAME + | GNOME_VFS_URI_HIDE_PASSWORD + | GNOME_VFS_URI_HIDE_HOST_NAME + | GNOME_VFS_URI_HIDE_HOST_PORT + | GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD)); + + /* Load! */ + file = fopen (str_uri, "r"); + g_free (str_uri); + + if (file) + return open_cal (cbfile, uri, file); + else { + if (only_if_exists) + return CAL_BACKEND_OPEN_NOT_FOUND; + + return create_cal (cbfile, uri); + } } /* Get_n_objects handler for the file backend */ diff --git a/calendar/pcs/cal-backend-file.h b/calendar/pcs/cal-backend-file.h index 376790751c..a85c6d20fd 100644 --- a/calendar/pcs/cal-backend-file.h +++ b/calendar/pcs/cal-backend-file.h @@ -1,8 +1,9 @@ /* Evolution calendar - iCalendar file backend * * 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 diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index 0dc5d45883..6353fbbcd7 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -2,9 +2,10 @@ /* Evolution calendar - generic backend class * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena-Quintero <federico@helixcode.com> - * JP Rosevear <jpr@helixcode.com> + * Authors: Federico Mena-Quintero <federico@ximian.com> + * JP Rosevear <jpr@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 @@ -40,10 +41,6 @@ enum { }; static void cal_backend_class_init (CalBackendClass *class); -static void cal_backend_init (CalBackend *backend); -static void cal_backend_destroy (GtkObject *object); - -static GtkObjectClass *parent_class; static guint cal_backend_signals[LAST_SIGNAL]; @@ -71,7 +68,7 @@ cal_backend_get_type (void) sizeof (CalBackend), sizeof (CalBackendClass), (GtkClassInitFunc) cal_backend_class_init, - (GtkObjectInitFunc) cal_backend_init, + (GtkObjectInitFunc) NULL, NULL, /* reserved_1 */ NULL, /* reserved_2 */ (GtkClassInitFunc) NULL @@ -92,10 +89,6 @@ cal_backend_class_init (CalBackendClass *class) object_class = (GtkObjectClass *) class; - parent_class = gtk_type_class (GTK_TYPE_OBJECT); - - object_class->destroy = cal_backend_destroy; - cal_backend_signals[LAST_CLIENT_GONE] = gtk_signal_new ("last_client_gone", GTK_RUN_FIRST, @@ -107,37 +100,13 @@ cal_backend_class_init (CalBackendClass *class) gtk_object_class_add_signals (object_class, cal_backend_signals, LAST_SIGNAL); } -/* Per instance initialization function */ -static void -cal_backend_init (CalBackend *backend) -{ - backend->uri = NULL; -} - -static void -cal_backend_destroy (GtkObject *object) -{ - CalBackend *backend; - - g_return_if_fail (object != NULL); - g_return_if_fail (IS_CAL_BACKEND (object)); - - backend = CAL_BACKEND (object); - - if (backend->uri) - gnome_vfs_uri_unref (backend->uri); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - /** * cal_backend_get_uri: * @backend: A calendar backend. * - * Queries the URI of a calendar backend, which must already have a loaded + * Queries the URI of a calendar backend, which must already have an open * calendar. * * Return value: The URI where the calendar is stored. @@ -152,23 +121,13 @@ cal_backend_get_uri (CalBackend *backend) return (* CLASS (backend)->get_uri) (backend); } -static void -cal_backend_set_uri (CalBackend *backend, GnomeVFSURI *uri) -{ - if (backend->uri) - gnome_vfs_uri_unref (backend->uri); - - gnome_vfs_uri_ref (uri); - backend->uri = uri; -} - /** * cal_backend_add_cal: * @backend: A calendar backend. * @cal: A calendar client interface object. * * Adds a calendar client interface object to a calendar @backend. - * The calendar backend must already have a loaded calendar. + * The calendar backend must already have an open calendar. **/ void cal_backend_add_cal (CalBackend *backend, Cal *cal) @@ -181,54 +140,34 @@ cal_backend_add_cal (CalBackend *backend, Cal *cal) } /** - * cal_backend_load: + * cal_backend_open: * @backend: A calendar backend. * @uri: URI that contains the calendar data. + * @only_if_exists: Whether the calendar should be opened only if it already + * exists. If FALSE, a new calendar will be created when the specified @uri + * does not exist. * - * Loads a calendar backend with data from a calendar stored at the specified + * Opens a calendar backend with data from a calendar stored at the specified * URI. * * Return value: An operation status code. **/ -CalBackendLoadStatus -cal_backend_load (CalBackend *backend, GnomeVFSURI *uri) +CalBackendOpenStatus +cal_backend_open (CalBackend *backend, GnomeVFSURI *uri, gboolean only_if_exists) { - CalBackendLoadStatus result; + CalBackendOpenStatus result; - 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 (uri != NULL, CAL_BACKEND_LOAD_ERROR); + g_return_val_if_fail (backend != NULL, CAL_BACKEND_OPEN_ERROR); + g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_OPEN_ERROR); + g_return_val_if_fail (uri != NULL, CAL_BACKEND_OPEN_ERROR); - g_assert (CLASS (backend)->load != NULL); - result = (* CLASS (backend)->load) (backend, uri); + g_assert (CLASS (backend)->open != NULL); + result = (* CLASS (backend)->open) (backend, uri, only_if_exists); - if (result == CAL_BACKEND_LOAD_SUCCESS) - cal_backend_set_uri (backend, uri); - return result; } /** - * cal_backend_create: - * @backend: A calendar backend. - * @uri: URI that will contain the calendar data. - * - * Creates a new empty calendar in a calendar backend. - **/ -void -cal_backend_create (CalBackend *backend, GnomeVFSURI *uri) -{ - g_return_if_fail (backend != NULL); - g_return_if_fail (IS_CAL_BACKEND (backend)); - g_return_if_fail (uri != NULL); - - g_assert (CLASS (backend)->create != NULL); - (* CLASS (backend)->create) (backend, uri); - - cal_backend_set_uri (backend, uri); -} - -/** * cal_backend_get_n_objects: * @backend: A calendar backend. * @type: Types of objects that will be included in the count. diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h index 6194630b43..efb7068165 100644 --- a/calendar/pcs/cal-backend.h +++ b/calendar/pcs/cal-backend.h @@ -2,8 +2,9 @@ /* Evolution calendar - generic backend class * * 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 @@ -44,9 +45,10 @@ BEGIN_GNOME_DECLS /* Load status values */ typedef enum { - CAL_BACKEND_LOAD_SUCCESS, /* Loading OK */ - CAL_BACKEND_LOAD_ERROR /* We need better error reporting in libversit */ -} CalBackendLoadStatus; + CAL_BACKEND_OPEN_SUCCESS, /* Loading OK */ + CAL_BACKEND_OPEN_ERROR, /* We need better error reporting in libversit */ + CAL_BACKEND_OPEN_NOT_FOUND +} CalBackendOpenStatus; /* Result codes for ::get_alarms_in_range() */ typedef enum { @@ -57,8 +59,6 @@ typedef enum { struct _CalBackend { GtkObject object; - - GnomeVFSURI *uri; }; struct _CalBackendClass { @@ -70,8 +70,9 @@ struct _CalBackendClass { /* Virtual methods */ GnomeVFSURI *(* get_uri) (CalBackend *backend); void (* add_cal) (CalBackend *backend, Cal *cal); - CalBackendLoadStatus (* load) (CalBackend *backend, GnomeVFSURI *uri); - void (* create) (CalBackend *backend, GnomeVFSURI *uri); + + CalBackendOpenStatus (* open) (CalBackend *backend, GnomeVFSURI *uri, + gboolean only_if_exists); int (* get_n_objects) (CalBackend *backend, CalObjType type); char *(* get_object) (CalBackend *backend, const char *uid); @@ -97,9 +98,8 @@ GnomeVFSURI *cal_backend_get_uri (CalBackend *backend); void cal_backend_add_cal (CalBackend *backend, Cal *cal); -CalBackendLoadStatus cal_backend_load (CalBackend *backend, GnomeVFSURI *uri); - -void cal_backend_create (CalBackend *backend, GnomeVFSURI *uri); +CalBackendOpenStatus cal_backend_open (CalBackend *backend, GnomeVFSURI *uri, + gboolean only_if_exists); int cal_backend_get_n_objects (CalBackend *backend, CalObjType type); diff --git a/calendar/pcs/cal-common.h b/calendar/pcs/cal-common.h index e51ddf1bdd..3454742ce8 100644 --- a/calendar/pcs/cal-common.h +++ b/calendar/pcs/cal-common.h @@ -1,8 +1,9 @@ /* Evolution calendar server - common declarations * * 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 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. **/ diff --git a/calendar/pcs/cal-factory.h b/calendar/pcs/cal-factory.h index 5e61d26ab5..4bdf9bf52f 100644 --- a/calendar/pcs/cal-factory.h +++ b/calendar/pcs/cal-factory.h @@ -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 diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 77f18806d9..69eccd7f55 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -1,8 +1,9 @@ /* Evolution calendar client interface object * * 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 diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h index d4c9f02650..844640cd8d 100644 --- a/calendar/pcs/cal.h +++ b/calendar/pcs/cal.h @@ -1,8 +1,9 @@ /* Evolution calendar client interface object * * 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 diff --git a/calendar/pcs/job.c b/calendar/pcs/job.c index d97df6d883..f8223f0bab 100644 --- a/calendar/pcs/job.c +++ b/calendar/pcs/job.c @@ -1,8 +1,9 @@ /* GNOME personal calendar server - job manager * * 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 diff --git a/calendar/pcs/job.h b/calendar/pcs/job.h index c9bce24dd4..f9a0d86923 100644 --- a/calendar/pcs/job.h +++ b/calendar/pcs/job.h @@ -1,8 +1,9 @@ /* GNOME personal calendar server - job manager * * 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 |