From 0932fd7ec9d21e763371a043283384af8bc987fb Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 17 Jan 2001 10:44:33 +0000 Subject: Ximianified email addresses and copyrights. 2001-01-17 Federico Mena Quintero * */*: 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 --- calendar/ChangeLog | 138 +++++++++++ calendar/cal-client/cal-client-types.c | 5 +- calendar/cal-client/cal-client-types.h | 5 +- calendar/cal-client/cal-client.c | 223 +++++++++--------- calendar/cal-client/cal-client.h | 32 ++- calendar/cal-client/cal-listener.c | 193 +++++++-------- calendar/cal-client/cal-listener.h | 34 ++- calendar/cal-client/client-test.c | 38 ++- calendar/cal-util/cal-component.c | 3 +- calendar/cal-util/cal-component.h | 3 +- calendar/cal-util/cal-util.c | 3 +- calendar/cal-util/cal-util.h | 3 +- calendar/cal-util/timeutil.c | 6 +- calendar/cal-util/timeutil.h | 6 +- calendar/conduits/calendar/calendar-conduit.c | 38 ++- calendar/conduits/calendar/calendar-conduit.h | 3 +- calendar/conduits/todo/todo-conduit.c | 38 ++- calendar/conduits/todo/todo-conduit.h | 3 +- calendar/gui/Makefile.am | 4 - calendar/gui/alarm-notify/alarm-notify-dialog.c | 3 +- calendar/gui/alarm-notify/alarm-notify-dialog.h | 3 +- calendar/gui/alarm-notify/alarm-notify.c | 125 +++++++++- calendar/gui/alarm-notify/alarm-notify.h | 3 +- calendar/gui/alarm-notify/alarm-queue.c | 3 +- calendar/gui/alarm-notify/alarm-queue.h | 3 +- calendar/gui/alarm-notify/alarm.c | 5 +- calendar/gui/alarm-notify/alarm.h | 5 +- calendar/gui/alarm-notify/notify-main.c | 3 +- calendar/gui/calendar-commands.c | 30 ++- calendar/gui/calendar-commands.h | 25 ++ calendar/gui/calendar-component.c | 5 +- calendar/gui/calendar-component.h | 3 +- calendar/gui/calendar-config.c | 3 +- calendar/gui/calendar-config.h | 3 +- calendar/gui/calendar-model.c | 78 +++++-- calendar/gui/calendar-model.h | 7 +- calendar/gui/calendar-summary.c | 60 ++--- calendar/gui/calendar-summary.h | 3 +- calendar/gui/comp-util.c | 3 +- calendar/gui/comp-util.h | 3 +- calendar/gui/component-factory.c | 5 +- calendar/gui/component-factory.h | 3 +- calendar/gui/control-factory.c | 4 +- calendar/gui/control-factory.h | 3 +- calendar/gui/dialogs/alarm-notify-dialog.c | 3 +- calendar/gui/dialogs/alarm-notify-dialog.h | 3 +- calendar/gui/dialogs/cal-prefs-dialog.c | 3 +- calendar/gui/dialogs/cal-prefs-dialog.h | 3 +- calendar/gui/dialogs/delete-comp.c | 3 +- calendar/gui/dialogs/delete-comp.h | 3 +- calendar/gui/dialogs/task-editor.c | 47 ++-- calendar/gui/dialogs/task-editor.h | 3 +- calendar/gui/e-calendar-table.c | 24 +- calendar/gui/e-calendar-table.h | 4 +- calendar/gui/e-day-view-main-item.c | 3 +- calendar/gui/e-day-view-main-item.h | 3 +- calendar/gui/e-day-view-time-item.c | 3 +- calendar/gui/e-day-view-time-item.h | 3 +- calendar/gui/e-day-view-top-item.h | 3 +- calendar/gui/e-day-view.c | 15 +- calendar/gui/e-day-view.h | 3 +- calendar/gui/e-itip-control.c | 46 ++-- calendar/gui/e-itip-control.h | 22 ++ calendar/gui/e-meeting-edit.c | 3 +- calendar/gui/e-meeting-edit.h | 3 +- calendar/gui/e-tasks.c | 184 +++------------ calendar/gui/e-tasks.h | 13 +- calendar/gui/e-week-view-event-item.c | 3 +- calendar/gui/e-week-view-event-item.h | 3 +- calendar/gui/e-week-view-main-item.h | 3 +- calendar/gui/e-week-view-titles-item.h | 3 +- calendar/gui/e-week-view.c | 18 +- calendar/gui/e-week-view.h | 3 +- calendar/gui/event-editor.c | 73 +++--- calendar/gui/event-editor.h | 7 +- calendar/gui/gnome-cal.c | 260 ++++++--------------- calendar/gui/gnome-cal.h | 31 ++- calendar/gui/goto.c | 7 +- calendar/gui/goto.h | 5 +- calendar/gui/main.c | 6 +- calendar/gui/tag-calendar.c | 2 +- calendar/gui/tasks-control.c | 2 +- calendar/idl/evolution-calendar.idl | 25 +- calendar/pcs/cal-backend-file.c | 147 +++++++----- calendar/pcs/cal-backend-file.h | 3 +- calendar/pcs/cal-backend.c | 99 ++------ calendar/pcs/cal-backend.h | 22 +- calendar/pcs/cal-common.h | 3 +- calendar/pcs/cal-factory.c | 298 +++++++----------------- calendar/pcs/cal-factory.h | 3 +- calendar/pcs/cal.c | 3 +- calendar/pcs/cal.h | 3 +- calendar/pcs/job.c | 3 +- calendar/pcs/job.h | 3 +- 94 files changed, 1355 insertions(+), 1252 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index ec86c60745..c3f1a55047 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,141 @@ +2001-01-17 Federico Mena Quintero + + * */*: 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. + 2001-01-16 JP Rosevear * conduits/todo/todo-conduit.c (print_local): fix debug output diff --git a/calendar/cal-client/cal-client-types.c b/calendar/cal-client/cal-client-types.c index 98da8b8a6f..23aa14475f 100644 --- a/calendar/cal-client/cal-client-types.c +++ b/calendar/cal-client/cal-client-types.c @@ -1,9 +1,10 @@ /* Evolution calendar utilities and types * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena-Quintero - * JP Rosevear + * Authors: Federico Mena-Quintero + * JP Rosevear * * 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/cal-client/cal-client-types.h b/calendar/cal-client/cal-client-types.h index 5c017458ad..c356f2378e 100644 --- a/calendar/cal-client/cal-client-types.h +++ b/calendar/cal-client/cal-client-types.h @@ -1,9 +1,10 @@ /* Evolution calendar utilities and types * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena-Quintero - * JP Rosevear + * Authors: Federico Mena-Quintero + * JP Rosevear * * 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/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 344dd91545..a89cfae40c 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -1,10 +1,10 @@ - /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* Evolution calendar client * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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 @@ -31,17 +31,15 @@ -/* Loading state for the calendar client */ -typedef enum { - LOAD_STATE_NOT_LOADED, - LOAD_STATE_LOADING, - LOAD_STATE_LOADED -} LoadState; - /* Private part of the CalClient structure */ struct _CalClientPrivate { /* Load state to avoid multiple loads */ - LoadState load_state; + CalClientLoadState load_state; + + /* URI of the calendar that is being loaded or is already loaded, or + * NULL if we are not loaded. + */ + char *uri; /* The calendar factory we are contacting */ GNOME_Evolution_Calendar_CalFactory factory; @@ -57,7 +55,7 @@ struct _CalClientPrivate { /* Signal IDs */ enum { - CAL_LOADED, + CAL_OPENED, OBJ_UPDATED, OBJ_REMOVED, LAST_SIGNAL @@ -115,11 +113,11 @@ cal_client_class_init (CalClientClass *class) parent_class = gtk_type_class (GTK_TYPE_OBJECT); - cal_client_signals[CAL_LOADED] = - gtk_signal_new ("cal_loaded", + cal_client_signals[CAL_OPENED] = + gtk_signal_new ("cal_opened", GTK_RUN_FIRST, object_class->type, - GTK_SIGNAL_OFFSET (CalClientClass, cal_loaded), + GTK_SIGNAL_OFFSET (CalClientClass, cal_opened), gtk_marshal_NONE__ENUM, GTK_TYPE_NONE, 1, GTK_TYPE_ENUM); @@ -154,8 +152,9 @@ cal_client_init (CalClient *client) priv = g_new0 (CalClientPrivate, 1); client->priv = priv; + priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; + priv->uri = NULL; priv->factory = CORBA_OBJECT_NIL; - priv->load_state = LOAD_STATE_NOT_LOADED; } /* Gets rid of the factory that a client knows about */ @@ -263,7 +262,12 @@ cal_client_destroy (GtkObject *object) destroy_listener (client); destroy_cal (client); - priv->load_state = LOAD_STATE_NOT_LOADED; + priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; + + if (priv->uri) { + g_free (priv->uri); + priv->uri = NULL; + } g_free (priv); client->priv = NULL; @@ -276,10 +280,10 @@ cal_client_destroy (GtkObject *object) /* Signal handlers for the listener's signals */ -/* Handle the cal_loaded signal from the listener */ +/* Handle the cal_opened notification from the listener */ static void -cal_loaded_cb (CalListener *listener, - GNOME_Evolution_Calendar_Listener_LoadStatus status, +cal_opened_cb (CalListener *listener, + GNOME_Evolution_Calendar_Listener_OpenStatus status, GNOME_Evolution_Calendar_Cal cal, gpointer data) { @@ -287,42 +291,44 @@ cal_loaded_cb (CalListener *listener, CalClientPrivate *priv; CORBA_Environment ev; GNOME_Evolution_Calendar_Cal cal_copy; - CalClientLoadStatus client_status; + CalClientOpenStatus client_status; client = CAL_CLIENT (data); priv = client->priv; - g_assert (priv->load_state == LOAD_STATE_LOADING); + g_assert (priv->load_state == CAL_CLIENT_LOAD_LOADING); + g_assert (priv->uri != NULL); - client_status = CAL_CLIENT_LOAD_ERROR; + client_status = CAL_CLIENT_OPEN_ERROR; switch (status) { case GNOME_Evolution_Calendar_Listener_SUCCESS: CORBA_exception_init (&ev); cal_copy = CORBA_Object_duplicate (cal, &ev); if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("cal_loaded(): could not duplicate the calendar client interface"); + g_message ("cal_opened_cb(): could not duplicate the " + "calendar client interface"); CORBA_exception_free (&ev); goto error; } CORBA_exception_free (&ev); priv->cal = cal_copy; - priv->load_state = LOAD_STATE_LOADED; + priv->load_state = CAL_CLIENT_LOAD_LOADED; - client_status = CAL_CLIENT_LOAD_SUCCESS; + client_status = CAL_CLIENT_OPEN_SUCCESS; goto out; case GNOME_Evolution_Calendar_Listener_ERROR: - client_status = CAL_CLIENT_LOAD_ERROR; + client_status = CAL_CLIENT_OPEN_ERROR; goto error; - case GNOME_Evolution_Calendar_Listener_IN_USE: - client_status = CAL_CLIENT_LOAD_IN_USE; + case GNOME_Evolution_Calendar_Listener_NOT_FOUND: + client_status = CAL_CLIENT_OPEN_NOT_FOUND; goto error; case GNOME_Evolution_Calendar_Listener_METHOD_NOT_SUPPORTED: - client_status = CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED; + client_status = CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED; goto error; default: @@ -333,14 +339,24 @@ cal_loaded_cb (CalListener *listener, bonobo_object_unref (BONOBO_OBJECT (priv->listener)); priv->listener = NULL; - priv->load_state = LOAD_STATE_NOT_LOADED; + + /* We free the priv->uri and set the priv->load_state until after the + * "cal_opened" signal has been emitted so that handlers will be able to + * access this information. + */ out: - g_assert (priv->load_state != LOAD_STATE_LOADING); + g_assert (priv->load_state != CAL_CLIENT_LOAD_LOADING); - gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_LOADED], + gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_OPENED], client_status); + + if (client_status != CAL_CLIENT_OPEN_SUCCESS) { + priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; + g_free (priv->uri); + priv->uri = NULL; + } } /* Handle the obj_updated signal from the listener */ @@ -425,7 +441,7 @@ cal_client_construct (CalClient *client) * cal_client_new: * * Creates a new calendar client. It should be initialized by calling - * cal_client_load_calendar() or cal_client_create_calendar(). + * cal_client_open_calendar(). * * Return value: A newly-created calendar client, or NULL if the client could * not be constructed because it could not contact the calendar server. @@ -446,9 +462,23 @@ cal_client_new (void) return client; } -/* Issues a load or create request */ -static gboolean -load_or_create (CalClient *client, const char *str_uri, gboolean load) +/** + * cal_client_open_calendar: + * @client: A calendar client. + * @str_uri: URI of calendar to open. + * @only_if_exists: FALSE if the calendar should be opened even if there + * was no storage for it, i.e. to create a new calendar or load an existing + * one if it already exists. TRUE if it should only try to load calendars + * that already exist. + * + * Makes a calendar client initiate a request to open a calendar. The calendar + * client will emit the "cal_opened" signal when the response from the server is + * received. + * + * Return value: TRUE on success, FALSE on failure to issue the open request. + **/ +gboolean +cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_if_exists) { CalClientPrivate *priv; GNOME_Evolution_Calendar_Listener corba_listener; @@ -458,44 +488,41 @@ load_or_create (CalClient *client, const char *str_uri, gboolean load) g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_NOT_LOADED, FALSE); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_NOT_LOADED, FALSE); + g_assert (priv->uri == NULL); g_return_val_if_fail (str_uri != NULL, FALSE); - priv->listener = cal_listener_new (); + priv->listener = cal_listener_new (cal_opened_cb, + obj_updated_cb, + obj_removed_cb, + client); if (!priv->listener) { - g_message ("load_or_create(): could not create the listener"); + g_message ("cal_client_open_calendar(): could not create the listener"); return FALSE; } - gtk_signal_connect (GTK_OBJECT (priv->listener), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), - client); - gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_updated", - GTK_SIGNAL_FUNC (obj_updated_cb), - client); - gtk_signal_connect (GTK_OBJECT (priv->listener), "obj_removed", - GTK_SIGNAL_FUNC (obj_removed_cb), - client); - corba_listener = (GNOME_Evolution_Calendar_Listener) bonobo_object_corba_objref ( BONOBO_OBJECT (priv->listener)); - + CORBA_exception_init (&ev); - priv->load_state = LOAD_STATE_LOADING; + priv->load_state = CAL_CLIENT_LOAD_LOADING; + priv->uri = g_strdup (str_uri); - if (load) - GNOME_Evolution_Calendar_CalFactory_load (priv->factory, str_uri, corba_listener, &ev); - else - GNOME_Evolution_Calendar_CalFactory_create (priv->factory, str_uri, corba_listener, &ev); + GNOME_Evolution_Calendar_CalFactory_open (priv->factory, str_uri, only_if_exists, + corba_listener, &ev); if (ev._major != CORBA_NO_EXCEPTION) { - g_message ("load_or_create(): load/create request failed"); + CORBA_exception_free (&ev); + + g_message ("cal_client_open_calendar(): open request failed"); bonobo_object_unref (BONOBO_OBJECT (priv->listener)); priv->listener = NULL; - priv->load_state = LOAD_STATE_NOT_LOADED; - CORBA_exception_free (&ev); + priv->load_state = CAL_CLIENT_LOAD_NOT_LOADED; + g_free (priv->uri); + priv->uri = NULL; + return FALSE; } CORBA_exception_free (&ev); @@ -504,58 +531,46 @@ load_or_create (CalClient *client, const char *str_uri, gboolean load) } /** - * cal_client_load_calendar: + * cal_client_get_load_state: * @client: A calendar client. - * @str_uri: URI of calendar to load. - * - * Makes a calendar client initiate a request to load a calendar. The calendar - * client will emit the "cal_loaded" signal when the response from the server is - * received. - * - * Return value: TRUE on success, FALSE on failure to issue the load request. + * + * Queries the state of loading of a calendar client. + * + * Return value: A #CalClientLoadState value indicating whether the client has + * not been loaded with cal_client_open_calendar() yet, whether it is being + * loaded, or whether it is already loaded. **/ -gboolean -cal_client_load_calendar (CalClient *client, const char *str_uri) +CalClientLoadState +cal_client_get_load_state (CalClient *client) { - return load_or_create (client, str_uri, TRUE); -} + CalClientPrivate *priv; -/** - * cal_client_create_calendar: - * @client: A calendar client. - * @str_uri: URI that will contain the calendar data. - * - * Makes a calendar client initiate a request to create a new calendar. The - * calendar client will emit the "cal_loaded" signal when the response from the - * server is received. - * - * Return value: TRUE on success, FALSE on failure to issue the create request. - **/ -gboolean -cal_client_create_calendar (CalClient *client, const char *str_uri) -{ - return load_or_create (client, str_uri, FALSE); + g_return_val_if_fail (client != NULL, FALSE); + g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); + + priv = client->priv; + return priv->load_state; } /** - * cal_client_is_loaded: + * cal_client_get_uri: * @client: A calendar client. * - * Queries whether a calendar client has been loaded successfully. + * Queries the URI that is open in a calendar client. * - * Return value: TRUE if the client has been loaded, FALSE if it has not or if - * the loading process is not finished yet. + * Return value: The URI of the calendar that is already loaded or is being + * loaded, or NULL if the client has not started a load request yet. **/ -gboolean -cal_client_is_loaded (CalClient *client) +const char * +cal_client_get_uri (CalClient *client) { CalClientPrivate *priv; - g_return_val_if_fail (client != NULL, FALSE); - g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); + g_return_val_if_fail (client != NULL, NULL); + g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); priv = client->priv; - return (priv->load_state == LOAD_STATE_LOADED); + return priv->uri; } /* Converts our representation of a calendar component type into its CORBA representation */ @@ -589,7 +604,7 @@ cal_client_get_n_objects (CalClient *client, CalObjType type) g_return_val_if_fail (IS_CAL_CLIENT (client), -1); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, -1); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, -1); t = corba_obj_type (type); @@ -630,7 +645,7 @@ cal_client_get_object (CalClient *client, const char *uid, CalComponent **comp) g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_GET_NOT_FOUND); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, CAL_CLIENT_GET_NOT_FOUND); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_GET_NOT_FOUND); g_return_val_if_fail (uid != NULL, CAL_CLIENT_GET_NOT_FOUND); g_return_val_if_fail (comp != NULL, CAL_CLIENT_GET_NOT_FOUND); @@ -713,7 +728,7 @@ cal_client_get_uids (CalClient *client, CalObjType type) g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL); t = corba_obj_type (type); @@ -783,7 +798,7 @@ cal_client_get_changes (CalClient *client, CalObjType type, const char *change_i g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL); t = corba_obj_type (type); CORBA_exception_init (&ev); @@ -860,7 +875,7 @@ cal_client_get_objects_in_range (CalClient *client, CalObjType type, time_t star g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL); g_return_val_if_fail (start != -1 && end != -1, NULL); g_return_val_if_fail (start <= end, NULL); @@ -1110,7 +1125,7 @@ cal_client_generate_instances (CalClient *client, CalObjType type, g_return_if_fail (IS_CAL_CLIENT (client)); priv = client->priv; - g_return_if_fail (priv->load_state == LOAD_STATE_LOADED); + g_return_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED); g_return_if_fail (start != -1 && end != -1); g_return_if_fail (start <= end); @@ -1263,7 +1278,7 @@ cal_client_get_alarms_in_range (CalClient *client, time_t start, time_t end) g_return_val_if_fail (IS_CAL_CLIENT (client), NULL); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, NULL); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, NULL); g_return_val_if_fail (start != -1 && end != -1, NULL); g_return_val_if_fail (start <= end, NULL); @@ -1339,7 +1354,7 @@ cal_client_get_alarms_for_object (CalClient *client, const char *uid, g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, FALSE); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, FALSE); g_return_val_if_fail (uid != NULL, FALSE); g_return_val_if_fail (start != -1 && end != -1, FALSE); @@ -1409,7 +1424,7 @@ cal_client_update_object (CalClient *client, CalComponent *comp) g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, FALSE); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, FALSE); g_return_val_if_fail (comp != NULL, FALSE); @@ -1464,7 +1479,7 @@ cal_client_remove_object (CalClient *client, const char *uid) g_return_val_if_fail (IS_CAL_CLIENT (client), FALSE); priv = client->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_LOADED, FALSE); + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, FALSE); g_return_val_if_fail (uid != NULL, FALSE); diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h index bbd0d1871e..9e17b22b2b 100644 --- a/calendar/cal-client/cal-client.h +++ b/calendar/cal-client/cal-client.h @@ -1,8 +1,9 @@ /* Evolution calendar client * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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 @@ -42,20 +43,28 @@ typedef struct _CalClientClass CalClientClass; typedef struct _CalClientPrivate CalClientPrivate; -/* Load status for the cal_loaded signal */ +/* Open status for the cal_opened signal */ typedef enum { - CAL_CLIENT_LOAD_SUCCESS, - CAL_CLIENT_LOAD_ERROR, - CAL_CLIENT_LOAD_IN_USE, - CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED -} CalClientLoadStatus; + CAL_CLIENT_OPEN_SUCCESS, + CAL_CLIENT_OPEN_ERROR, + CAL_CLIENT_OPEN_NOT_FOUND, + CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED +} CalClientOpenStatus; +/* Get status for the cal_client_get_object() function */ typedef enum { CAL_CLIENT_GET_SUCCESS, CAL_CLIENT_GET_NOT_FOUND, CAL_CLIENT_GET_SYNTAX_ERROR } CalClientGetStatus; +/* Whether the client is not loaded, is being loaded, or is already loaded */ +typedef enum { + CAL_CLIENT_LOAD_NOT_LOADED, + CAL_CLIENT_LOAD_LOADING, + CAL_CLIENT_LOAD_LOADED +} CalClientLoadState; + struct _CalClient { GtkObject object; @@ -69,7 +78,7 @@ struct _CalClientClass { /* Notification signals */ - void (* cal_loaded) (CalClient *client, CalClientLoadStatus status); + void (* cal_opened) (CalClient *client, CalClientOpenStatus status); void (* obj_updated) (CalClient *client, const char *uid); void (* obj_removed) (CalClient *client, const char *uid); @@ -81,10 +90,11 @@ CalClient *cal_client_construct (CalClient *client); CalClient *cal_client_new (void); -gboolean cal_client_load_calendar (CalClient *client, const char *str_uri); -gboolean cal_client_create_calendar (CalClient *client, const char *str_uri); +gboolean cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_if_exists); + +CalClientLoadState cal_client_get_load_state (CalClient *client); -gboolean cal_client_is_loaded (CalClient *client); +const char *cal_client_get_uri (CalClient *client); int cal_client_get_n_objects (CalClient *client, CalObjType type); 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 + * Author: Federico Mena-Quintero * * 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); } diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h index 1a12f07ca2..612d1d889f 100644 --- a/calendar/cal-client/cal-listener.h +++ b/calendar/cal-client/cal-listener.h @@ -1,8 +1,9 @@ /* Evolution calendar listener * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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 @@ -54,23 +55,42 @@ struct _CalListenerClass { /* Notification signals */ - void (* cal_loaded) (CalListener *listener, - GNOME_Evolution_Calendar_Listener_LoadStatus status, + void (* cal_opened) (CalListener *listener, + GNOME_Evolution_Calendar_Listener_OpenStatus status, GNOME_Evolution_Calendar_Cal cal); void (* obj_updated) (CalListener *listener, const GNOME_Evolution_Calendar_CalObjUID uid); void (* obj_removed) (CalListener *listener, const GNOME_Evolution_Calendar_CalObjUID uid); }; +/* Notification functions */ +typedef void (* CalListenerCalOpenedFn) (CalListener *listener, + GNOME_Evolution_Calendar_Listener_OpenStatus status, + GNOME_Evolution_Calendar_Cal cal, + gpointer data); + +typedef void (* CalListenerObjUpdatedFn) (CalListener *listener, + const GNOME_Evolution_Calendar_CalObjUID uid, + gpointer data); +typedef void (* CalListenerObjRemovedFn) (CalListener *listener, + const GNOME_Evolution_Calendar_CalObjUID uid, + gpointer data); + + GtkType cal_listener_get_type (void); CalListener *cal_listener_construct (CalListener *listener, - GNOME_Evolution_Calendar_Listener corba_listener); + GNOME_Evolution_Calendar_Listener corba_listener, + CalListenerCalOpenedFn cal_opened_fn, + CalListenerObjUpdatedFn obj_updated_fn, + CalListenerObjRemovedFn obj_removed_fn, + gpointer fn_data); GNOME_Evolution_Calendar_Listener cal_listener_corba_object_create (BonoboObject *object); -CalListener *cal_listener_new (void); - -GNOME_Evolution_Calendar_Cal cal_listener_get_calendar (CalListener *listener); +CalListener *cal_listener_new (CalListenerCalOpenedFn cal_opened_fn, + CalListenerObjUpdatedFn obj_updated_fn, + CalListenerObjRemovedFn obj_removed_fn, + gpointer fn_data); POA_GNOME_Evolution_Calendar_Listener__epv *cal_listener_get_epv (void); diff --git a/calendar/cal-client/client-test.c b/calendar/cal-client/client-test.c index c28e3f5696..7ff8aab8fc 100644 --- a/calendar/cal-client/client-test.c +++ b/calendar/cal-client/client-test.c @@ -1,8 +1,9 @@ /* Evolution calendar client - test program * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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 @@ -115,17 +116,18 @@ list_uids (gpointer data) return FALSE; } -/* Callback used when a calendar is loaded */ +/* Callback used when a calendar is opened */ static void -cal_loaded (CalClient *client, CalClientLoadStatus status, gpointer data) +cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) { cl_printf (client, "Load/create %s\n", - ((status == CAL_CLIENT_LOAD_SUCCESS) ? "success" : - (status == CAL_CLIENT_LOAD_ERROR) ? "error" : - (status == CAL_CLIENT_LOAD_IN_USE) ? "in use" : + ((status == CAL_CLIENT_OPEN_SUCCESS) ? "success" : + (status == CAL_CLIENT_OPEN_ERROR) ? "error" : + (status == CAL_CLIENT_OPEN_NOT_FOUND) ? "not found" : + (status == CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED) ? "method not supported" : "unknown status value")); - if (status == CAL_CLIENT_LOAD_SUCCESS) + if (status == CAL_CLIENT_OPEN_SUCCESS) g_idle_add (list_uids, client); else gtk_object_unref (GTK_OBJECT (client)); @@ -133,7 +135,7 @@ cal_loaded (CalClient *client, CalClientLoadStatus status, gpointer data) /* Callback used when an object is updated */ static void -obj_updated (CalClient *client, const char *uid, gpointer data) +obj_updated_cb (CalClient *client, const char *uid, gpointer data) { cl_printf (client, "Object updated: %s\n", uid); } @@ -155,7 +157,7 @@ client_destroy_cb (GtkObject *object, gpointer data) /* Creates a calendar client and tries to load the specified URI into it */ static void -create_client (CalClient **client, const char *uri, gboolean load) +create_client (CalClient **client, const char *uri, gboolean only_if_exists) { gboolean result; @@ -169,23 +171,19 @@ create_client (CalClient **client, const char *uri, gboolean load) client_destroy_cb, NULL); - gtk_signal_connect (GTK_OBJECT (*client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded), + gtk_signal_connect (GTK_OBJECT (*client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), NULL); gtk_signal_connect (GTK_OBJECT (*client), "obj_updated", - GTK_SIGNAL_FUNC (obj_updated), + GTK_SIGNAL_FUNC (obj_updated_cb), NULL); printf ("Calendar loading `%s'...\n", uri); - if (load) - result = cal_client_load_calendar (*client, uri); - else - result = cal_client_create_calendar (*client, uri); + result = cal_client_open_calendar (*client, uri, only_if_exists); if (!result) { - g_message ("create_client(): failure when issuing calendar %s request `%s'", - load ? "load" : "create", + g_message ("create_client(): failure when issuing calendar open request `%s'", uri); exit (1); } @@ -205,8 +203,8 @@ main (int argc, char **argv) exit (1); } - create_client (&client1, "/cvs/evolution/calendar/cal-client/test.ics", TRUE); - create_client (&client2, "/cvs/evolution/calendar/cal-client/test.ics", FALSE); + create_client (&client1, "/cvs/evolution/calendar/cal-client/test.ics", FALSE); + create_client (&client2, "/cvs/evolution/calendar/cal-client/test.ics", TRUE); bonobo_main (); return 0; diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index ef0c491870..2c01991a90 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -1,8 +1,9 @@ /* Evolution calendar - iCalendar component object * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index 8887e1b86b..7f77544467 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -1,8 +1,9 @@ /* Evolution calendar - iCalendar component object * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/cal-util/cal-util.c b/calendar/cal-util/cal-util.c index c75a65d7d5..67da788b0f 100644 --- a/calendar/cal-util/cal-util.c +++ b/calendar/cal-util/cal-util.c @@ -1,8 +1,9 @@ /* Evolution calendar utilities and types * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/cal-util/cal-util.h b/calendar/cal-util/cal-util.h index ac7838885e..a0a111258d 100644 --- a/calendar/cal-util/cal-util.h +++ b/calendar/cal-util/cal-util.h @@ -1,8 +1,9 @@ /* Evolution calendar utilities and types * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/cal-util/timeutil.c b/calendar/cal-util/timeutil.c index 6bc893831d..30738e81ca 100644 --- a/calendar/cal-util/timeutil.c +++ b/calendar/cal-util/timeutil.c @@ -1,9 +1,11 @@ /* Miscellaneous time-related utilities * * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena - * Miguel de Icaza + * Authors: Federico Mena + * Miguel de Icaza */ #include diff --git a/calendar/cal-util/timeutil.h b/calendar/cal-util/timeutil.h index b32e82d7ce..730c7dc089 100644 --- a/calendar/cal-util/timeutil.h +++ b/calendar/cal-util/timeutil.h @@ -1,9 +1,11 @@ /* Miscellaneous time-related utilities * * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena - * Miguel de Icaza + * Authors: Federico Mena + * Miguel de Icaza */ #ifndef TIMEUTIL_H diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c index 1ffe47b890..0ed563b574 100644 --- a/calendar/conduits/calendar/calendar-conduit.c +++ b/calendar/conduits/calendar/calendar-conduit.c @@ -162,29 +162,23 @@ e_calendar_context_destroy (ECalConduitContext *ctxt) /* Calendar Server routines */ static void -start_calendar_server_cb (GtkWidget *cal_client, - CalClientLoadStatus status, - ECalConduitContext *ctxt) +start_calendar_server_cb (CalClient *cal_client, + CalClientOpenStatus status, + gpointer data) { - CalClient *client = CAL_CLIENT (cal_client); + ECalConduitContext *ctxt; + + ctxt = data; - LOG (" entering start_calendar_server_load_cb, tried=%d\n", - ctxt->calendar_load_tried); + LOG (" entering start_calendar_server_cb\n"); - if (status == CAL_CLIENT_LOAD_SUCCESS) { - ctxt->calendar_load_success = TRUE; + if (status == CAL_CLIENT_OPEN_SUCCESS) { + ctxt->calendar_open_success = TRUE; LOG (" success\n"); - gtk_main_quit (); /* end the sub event loop */ - } else { - if (ctxt->calendar_load_tried) { - LOG (" load and create of calendar failed\n"); - gtk_main_quit (); /* end the sub event loop */ - return; - } + } else + LOG (" open of calendar failed\n"); - cal_client_create_calendar (client, ctxt->calendar_file); - ctxt->calendar_load_tried = TRUE; - } + gtk_main_quit (); /* end the sub event loop */ } static int @@ -199,17 +193,17 @@ start_calendar_server (ECalConduitContext *ctxt) ctxt->calendar_file = g_concat_dir_and_file (g_get_home_dir (), "evolution/local/Calendar/calendar.ics"); - gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_loaded", + gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_opened", start_calendar_server_cb, ctxt); - LOG (" calling cal_client_load_calendar\n"); - cal_client_load_calendar (ctxt->client, ctxt->calendar_file); + LOG (" calling cal_client_open_calendar\n"); + cal_client_open_calendar (ctxt->client, ctxt->calendar_file, FALSE); /* run a sub event loop to turn cal-client's async load notification into a synchronous call */ gtk_main (); - if (ctxt->calendar_load_success) + if (ctxt->calendar_open_success) return 0; return -1; diff --git a/calendar/conduits/calendar/calendar-conduit.h b/calendar/conduits/calendar/calendar-conduit.h index 3b998716a2..03308e77d9 100644 --- a/calendar/conduits/calendar/calendar-conduit.h +++ b/calendar/conduits/calendar/calendar-conduit.h @@ -60,8 +60,7 @@ struct _ECalConduitContext { CalClient *client; char *calendar_file; - gboolean calendar_load_tried; - gboolean calendar_load_success; + gboolean calendar_open_success; time_t since; GList *uids; diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c index 07fe9f3122..fe50a7869b 100644 --- a/calendar/conduits/todo/todo-conduit.c +++ b/calendar/conduits/todo/todo-conduit.c @@ -166,29 +166,23 @@ e_todo_context_destroy (EToDoConduitContext *ctxt) /* Calendar Server routines */ static void -start_calendar_server_cb (GtkWidget *cal_client, - CalClientLoadStatus status, - EToDoConduitContext *ctxt) +start_calendar_server_cb (CalClient *cal_client, + CalClientOpenStatus status, + gpointer data) { - CalClient *client = CAL_CLIENT (cal_client); + EToDoConduitContext *ctxt; + + ctxt = data; - LOG (" entering start_calendar_server_load_cb, tried=%d\n", - ctxt->calendar_load_tried); + LOG (" entering start_calendar_server_cb\n"); - if (status == CAL_CLIENT_LOAD_SUCCESS) { - ctxt->calendar_load_success = TRUE; + if (status == CAL_CLIENT_OPEN_SUCCESS) { + ctxt->calendar_open_success = TRUE; LOG (" success\n"); - gtk_main_quit (); /* end the sub event loop */ - } else { - if (ctxt->calendar_load_tried) { - LOG (" load and create of calendar failed\n"); - gtk_main_quit (); /* end the sub event loop */ - return; - } + } else + LOG (" open of calendar failed\n"); - cal_client_create_calendar (client, ctxt->calendar_file); - ctxt->calendar_load_tried = TRUE; - } + gtk_main_quit (); /* end the sub event loop */ } static int @@ -203,17 +197,17 @@ start_calendar_server (EToDoConduitContext *ctxt) ctxt->calendar_file = g_concat_dir_and_file (g_get_home_dir (), "evolution/local/Tasks/tasks.ics"); - gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_loaded", + gtk_signal_connect (GTK_OBJECT (ctxt->client), "cal_opened", start_calendar_server_cb, ctxt); - LOG (" calling cal_client_load_calendar\n"); - cal_client_load_calendar (ctxt->client, ctxt->calendar_file); + LOG (" calling cal_client_open_calendar\n"); + cal_client_open_calendar (ctxt->client, ctxt->calendar_file, FALSE); /* run a sub event loop to turn cal-client's async load notification into a synchronous call */ gtk_main (); - if (ctxt->calendar_load_success) + if (ctxt->calendar_open_success) return 0; return -1; diff --git a/calendar/conduits/todo/todo-conduit.h b/calendar/conduits/todo/todo-conduit.h index 80245b11b0..46f89fc1a0 100644 --- a/calendar/conduits/todo/todo-conduit.h +++ b/calendar/conduits/todo/todo-conduit.h @@ -60,8 +60,7 @@ struct _EToDoConduitContext { CalClient *client; char *calendar_file; - gboolean calendar_load_tried; - gboolean calendar_load_success; + gboolean calendar_open_success; GList *uids; GList *changed; diff --git a/calendar/gui/Makefile.am b/calendar/gui/Makefile.am index 46daa28965..0f000de3f5 100644 --- a/calendar/gui/Makefile.am +++ b/calendar/gui/Makefile.am @@ -55,8 +55,6 @@ evolution_calendar_SOURCES = \ $(IDL_GENERATED) \ alarm.c \ alarm.h \ - alarm-notify.c \ - alarm-notify.h \ calendar-config.c \ calendar-config.h \ calendar-commands.c \ @@ -99,8 +97,6 @@ evolution_calendar_SOURCES = \ event-editor.h \ gnome-cal.c \ gnome-cal.h \ - gnome-month-item.c \ - gnome-month-item.h \ goto.c \ goto.h \ itip-utils.c \ diff --git a/calendar/gui/alarm-notify/alarm-notify-dialog.c b/calendar/gui/alarm-notify/alarm-notify-dialog.c index 7d8357599c..fbd8c1f097 100644 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.c +++ b/calendar/gui/alarm-notify/alarm-notify-dialog.c @@ -1,8 +1,9 @@ /* Evolution calendar - alarm notification dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/alarm-notify/alarm-notify-dialog.h b/calendar/gui/alarm-notify/alarm-notify-dialog.h index 1e56f1c586..f2c938c495 100644 --- a/calendar/gui/alarm-notify/alarm-notify-dialog.h +++ b/calendar/gui/alarm-notify/alarm-notify-dialog.h @@ -1,8 +1,9 @@ /* Evolution calendar - alarm notification dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index 348bb61bd3..fc87ad878d 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -1,8 +1,9 @@ /* Evolution calendar - Alarm notification service object * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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 @@ -38,7 +39,7 @@ static void alarm_notify_class_init (AlarmNotifyClass *class); static void alarm_notify_init (AlarmNotify *an); static void alarm_notify_destroy (GtkObject *object); -static POA_GNOME_Evolution_Calendar_AlarmListener__vepv alarm_listener_vepv; +static POA_GNOME_Evolution_Calendar_AlarmNotify__vepv alarm_notify_vepv; static BonoboObjectClass *parent_class; @@ -136,6 +137,32 @@ alarm_notify_destroy (GtkObject *object) /* CORBA servant implementation */ +/* AlarmNotify::addCalendar method */ +static void +AlarmNotify_addCalendar (PortableServer_Servant servant, + const CORBA_char *uri, + CORBA_Environment *ev) +{ + AlarmNotify *an; + + an = ALARM_NOTIFY (bonobo_object_from_servant (servant)); + + /* FIXME */ +} + +/* AlarmNotify::removeCalendar method */ +static void +AlarmNotify_removeCalendar (PortableServer_Servant servant, + const CORBA_char *uri, + CORBA_Environment *ev) +{ + AlarmNotify *an; + + an = ALARM_NOTIFY (bonobo_object_from_servant (servant)); + + /* FIXME */ +} + /** * alarm_notify_get_epv: * @@ -154,3 +181,97 @@ alarm_notify_get_epv (void) epv->die = AlarmNotify_die; return epv; } + + + +/** + * alarm_notify_construct: + * @an: An alarm notification service object. + * @corba_an: CORBA object for the alarm notification service. + * + * Constructs an alarm notification service object by binding the corresponding + * CORBA object to it. + * + * Return value: the same object as the @an argument. + **/ +AlarmNotify * +alarm_notify_construct (AlarmNotify *an, + GNOME_Evolution_Calendar_AlarmNotify corba_an) +{ + g_return_val_if_fail (an != NULL, NULL); + g_return_val_if_fail (IS_ALARM_NOTIFY (an), NULL); + + /* FIXME: add_interface the property bag here */ + + bonobo_object_construct (BONOBO_OBJECT (an), corba_an); + return an; +} + +/** + * alarm_notify_corba_object_create: + * @object: #BonoboObject that will wrap the CORBA object. + * + * Creates and activates the CORBA object that is wrapped by the specified alarm + * notification service @object. + * + * Return value: An activated object reference or #CORBA_OBJECT_NIL in case of + * failure. + **/ +GNOME_Evolution_Calendar_AlarmNotify +alarm_notify_corba_object_create (BonoboObject *object) +{ + POA_GNOME_Evolution_Calendar_AlarmNotify *servant; + CORBA_Environment ev; + + g_return_val_if_fail (object != NULL, CORBA_OBJECT_NIL); + g_return_val_if_fail (IS_ALARM_NOTIFY (object), CORBA_OBJECT_NIL); + + servant = (POA_GNOME_Evolution_Calendar_AlarmNotify *) g_new (BonoboObjectServant, 1); + servant->vepv = &alarm_notify_vepv; + + CORBA_exception_init (&ev); + POA_GNOME_Evolution_Calendar_AlarmNotify__init ((PortableServer_Servant) servant, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_free (servant); + CORBA_exception_free (&ev); + return CORBA_OBJECT_NIL; + } + + CORBA_exception_free (&ev); + return (GNOME_Evolution_Calendar_AlarmNotify) bonobo_object_activate_servant ( + object, servant); +} + +/** + * alarm_notify_new: + * + * Creates a new #AlarmNotify object. + * + * Return value: A newly-created #AlarmNotify, or NULL if its corresponding + * CORBA object could not be created. + **/ +AlarmNotify * +alarm_notify_new (void) +{ + AlarmNotify *an; + GNOME_Evolution_Calendar_AlarmNotify corba_an; + CORBA_Environment ev; + gboolean result; + + an = gtk_type_new (TYPE_ALARM_NOTIFY); + + corba_an = alarm_notify_corba_object_create (BONOBO_OBJECT (an)); + + CORBA_exception_init (&ev); + result = CORBA_Object_is_nil (corba_an, &ev); + + if (ev._major != CORBA_NO_EXCEPTION || result) { + g_message ("alarm_notify_new(): could not create the CORBA alarm notify service"); + bonobo_object_unref (BONOBO_OBJECT (an)); + CORBA_exception_free (&ev); + return NULL; + } + CORBA_exception_free (&ev); + + return alarm_notify_construct (an, corba_an); +} diff --git a/calendar/gui/alarm-notify/alarm-notify.h b/calendar/gui/alarm-notify/alarm-notify.h index 98fbfd2b70..e7a907485d 100644 --- a/calendar/gui/alarm-notify/alarm-notify.h +++ b/calendar/gui/alarm-notify/alarm-notify.h @@ -1,8 +1,9 @@ /* Evolution calendar - Alarm notification service object * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index fc4b2a5652..e2f2ae88db 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -1,8 +1,9 @@ /* Evolution calendar - Alarm queueing engine * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena-Quintero + * Authors: Federico Mena-Quintero * * 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/gui/alarm-notify/alarm-queue.h b/calendar/gui/alarm-notify/alarm-queue.h index ea1309a810..1f8871fb96 100644 --- a/calendar/gui/alarm-notify/alarm-queue.h +++ b/calendar/gui/alarm-notify/alarm-queue.h @@ -1,8 +1,9 @@ /* Evolution calendar - Alarm queueing engine * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena-Quintero + * Authors: Federico Mena-Quintero * * 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/gui/alarm-notify/alarm.c b/calendar/gui/alarm-notify/alarm.c index a0fe90f337..d32d8f1af9 100644 --- a/calendar/gui/alarm-notify/alarm.c +++ b/calendar/gui/alarm-notify/alarm.c @@ -1,9 +1,10 @@ /* Evolution calendar - Low-level alarm timer mechanism * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Miguel de Icaza - * Federico Mena-Quintero + * Authors: Miguel de Icaza + * Federico Mena-Quintero * * 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/gui/alarm-notify/alarm.h b/calendar/gui/alarm-notify/alarm.h index afa79edfd8..fc81908ef2 100644 --- a/calendar/gui/alarm-notify/alarm.h +++ b/calendar/gui/alarm-notify/alarm.h @@ -1,9 +1,10 @@ /* Evolution calendar - Low-level alarm timer mechanism * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Miguel de Icaza - * Federico Mena-Quintero + * Authors: Miguel de Icaza + * Federico Mena-Quintero * * 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/gui/alarm-notify/notify-main.c b/calendar/gui/alarm-notify/notify-main.c index 93123808b0..6712865725 100644 --- a/calendar/gui/alarm-notify/notify-main.c +++ b/calendar/gui/alarm-notify/notify-main.c @@ -1,8 +1,9 @@ /* Evolution calendar - Alarm notification service main file * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 7519e0458e..db1cb1dbc4 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -1,11 +1,27 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * Main file for the GNOME Calendar program - * Copyright (C) 1998 the Free Software Foundation +/* Evolution calendar - Commands for the calendar GUI control * - * Authors: - * Miguel de Icaza (miguel@kernel.org) - * Federico Mena (federico@helixcode.com) + * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. + * + * Authors: Miguel de Icaza + * Federico Mena-Quintero + * Seth Alves + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #include @@ -446,5 +462,5 @@ calendar_set_uri (GnomeCalendar *gcal, char *calendar_file) g_return_if_fail (gcal); g_return_if_fail (calendar_file); - gnome_calendar_open (gcal, calendar_file, CALENDAR_OPEN_OR_CREATE); + gnome_calendar_open (gcal, calendar_file); } diff --git a/calendar/gui/calendar-commands.h b/calendar/gui/calendar-commands.h index 81e1b33408..364051e3a3 100644 --- a/calendar/gui/calendar-commands.h +++ b/calendar/gui/calendar-commands.h @@ -1,3 +1,28 @@ +/* Evolution calendar - Commands for the calendar GUI control + * + * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. + * + * Authors: Miguel de Icaza + * Federico Mena-Quintero + * Seth Alves + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + #ifndef CALENDAR_COMMANDS_H #define CALENDAR_COMMANDS_H diff --git a/calendar/gui/calendar-component.c b/calendar/gui/calendar-component.c index de1b2d5839..4f98cbab6b 100644 --- a/calendar/gui/calendar-component.c +++ b/calendar/gui/calendar-component.c @@ -2,6 +2,7 @@ /* component-factory.c * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,7 +19,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Ettore Perazzoli + * Author: Ettore Perazzoli */ #include @@ -30,6 +31,8 @@ #include "control-factory.h" #include "calendar-config.h" #include "calendar-summary.h" +#include "tasks-control.h" + #define COMPONENT_FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_ShellComponentFactory" diff --git a/calendar/gui/calendar-component.h b/calendar/gui/calendar-component.h index 8e5cd6605f..d2d570e340 100644 --- a/calendar/gui/calendar-component.h +++ b/calendar/gui/calendar-component.h @@ -2,6 +2,7 @@ /* component-factory.h * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,7 +19,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Ettore Perazzoli + * Author: Ettore Perazzoli */ #ifndef _COMPONENT_FACTORY_H_ diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index dc12e60ab4..52f62f89df 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 2000, Helix Code, Inc. + * Copyright 2000, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/calendar-config.h b/calendar/gui/calendar-config.h index d5176d624c..8b11570f12 100644 --- a/calendar/gui/calendar-config.h +++ b/calendar/gui/calendar-config.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 2000, Helix Code, Inc. + * Copyright 2000, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c index 2fb4f89bf0..2ab801cdf3 100644 --- a/calendar/gui/calendar-model.c +++ b/calendar/gui/calendar-model.c @@ -3,8 +3,9 @@ /* Evolution calendar - Data model for ETable * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena-Quintero + * Authors: Federico Mena-Quintero * * 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 @@ -56,6 +57,9 @@ struct _CalendarModelPrivate { /* UID -> array index hash */ GHashTable *uid_index_hash; + /* Type of components to create when using click-to-add in the table */ + CalComponentVType new_comp_vtype; + /* Whether we display dates in 24-hour format. */ gboolean use_24_hour_format; @@ -73,7 +77,6 @@ struct _CalendarModelPrivate { enum { CATEGORIES_CHANGED, - LAST_SIGNAL }; @@ -196,6 +199,7 @@ calendar_model_init (CalendarModel *model) priv->objects = g_array_new (FALSE, TRUE, sizeof (CalComponent *)); priv->uid_index_hash = g_hash_table_new (g_str_hash, g_str_equal); + priv->new_comp_vtype = CAL_COMPONENT_EVENT; priv->use_24_hour_format = TRUE; priv->categories = g_tree_new ((GCompareFunc)strcmp); @@ -1307,7 +1311,7 @@ calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row) * is only used for the task list. */ comp = cal_component_new (); - cal_component_set_new_vtype (comp, CAL_COMPONENT_TODO); + cal_component_set_new_vtype (comp, priv->new_comp_vtype); cal_component_get_uid (comp, &uid); @@ -1534,17 +1538,17 @@ calendar_model_new (void) } -/* Callback used when a calendar is loaded into the server */ +/* Callback used when a calendar is opened into the server */ static void -cal_loaded_cb (CalClient *client, - CalClientLoadStatus status, - CalendarModel *model) +cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) { - g_return_if_fail (IS_CALENDAR_MODEL (model)); + CalendarModel *model; + + model = CALENDAR_MODEL (data); e_table_model_pre_change (E_TABLE_MODEL (model)); - if (status == CAL_CLIENT_LOAD_SUCCESS) { + if (status == CAL_CLIENT_OPEN_SUCCESS) { load_objects (model); calendar_model_collect_all_categories (model); } @@ -1744,8 +1748,7 @@ load_objects (CalendarModel *model) priv = model->priv; - if (!cal_client_is_loaded (priv->client)) - return; + g_assert (cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_LOADED); uids = cal_client_get_uids (priv->client, priv->type); @@ -1861,22 +1864,65 @@ calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjTy priv->type = type; if (priv->client) { - if (!cal_client_is_loaded (priv->client)) - gtk_signal_connect (GTK_OBJECT (priv->client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), model); - gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated", GTK_SIGNAL_FUNC (obj_updated_cb), model); gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed", GTK_SIGNAL_FUNC (obj_removed_cb), model); - load_objects (model); + if (cal_client_get_load_state (priv->client) != CAL_CLIENT_LOAD_LOADED) + gtk_signal_connect (GTK_OBJECT (priv->client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), model); + else + load_objects (model); } e_table_model_changed (E_TABLE_MODEL (model)); } +/** + * calendar_model_set_new_comp_vtype: + * @model: A calendar model. + * @vtype: Type of calendar components to create. + * + * Sets the type of calendar components that will be created by a calendar table + * model when the click-to-add functionality of the table is used. + **/ +void +calendar_model_set_new_comp_vtype (CalendarModel *model, CalComponentVType vtype) +{ + CalendarModelPrivate *priv; + + g_return_if_fail (model != NULL); + g_return_if_fail (IS_CALENDAR_MODEL (model)); + g_return_if_fail (vtype != CAL_COMPONENT_NO_TYPE); + + priv = model->priv; + priv->new_comp_vtype = vtype; +} + +/** + * calendar_model_get_new_comp_vtype: + * @model: A calendar model. + * + * Queries the type of calendar components that are created by a calendar table + * model when using the click-to-add functionality in a table. + * + * Return value: Type of components that are created. + **/ +CalComponentVType +calendar_model_get_new_comp_vtype (CalendarModel *model) +{ + CalendarModelPrivate *priv; + + g_return_val_if_fail (model != NULL, CAL_COMPONENT_NO_TYPE); + g_return_val_if_fail (IS_CALENDAR_MODEL (model), CAL_COMPONENT_NO_TYPE); + + priv = model->priv; + return priv->new_comp_vtype; +} + + void calendar_model_mark_task_complete (CalendarModel *model, gint row) diff --git a/calendar/gui/calendar-model.h b/calendar/gui/calendar-model.h index e4946393b6..5ff2f41c38 100644 --- a/calendar/gui/calendar-model.h +++ b/calendar/gui/calendar-model.h @@ -1,8 +1,9 @@ /* Evolution calendar - Data model for ETable * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Federico Mena-Quintero + * Authors: Federico Mena-Quintero * * 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 @@ -64,6 +65,10 @@ void calendar_model_set_cal_client (CalendarModel *model, CalClient *client, CalObjType type); +void calendar_model_set_new_comp_vtype (CalendarModel *model, + CalComponentVType vtype); +CalComponentVType calendar_model_get_new_comp_vtype (CalendarModel *model); + void calendar_model_mark_task_complete (CalendarModel *model, gint row); diff --git a/calendar/gui/calendar-summary.c b/calendar/gui/calendar-summary.c index 08ad225a43..76db68463e 100644 --- a/calendar/gui/calendar-summary.c +++ b/calendar/gui/calendar-summary.c @@ -1,9 +1,10 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* calendar-summary.c * - * Authors: Iain Holmes + * Authors: Iain Holmes * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -40,6 +41,7 @@ #include "cal-util/cal-component.h" #include "cal-util/timeutil.h" +#include "alarm.h" #include "calendar-model.h" #include "calendar-summary.h" @@ -49,7 +51,6 @@ typedef struct { ExecutiveSummaryHtmlView *view; BonoboPropertyControl *property_control; CalClient *client; - gboolean cal_loaded; GtkWidget *show_appointments; GtkWidget *show_tasks; @@ -77,12 +78,15 @@ static BonoboGenericFactory *factory; #define CALENDAR_SUMMARY_ID "OAFIID:GNOME_Evolution_Calendar_Summary_ComponentFactory" static gboolean -generate_html_summary (CalSummary *summary) +generate_html_summary (gpointer data) { + CalSummary *summary; time_t t, day_begin, day_end; struct tm *timeptr; GList *uids, *l; char *ret_html, *tmp, *datestr; + + summary = data; t = time (NULL); day_begin = time_day_begin (t); @@ -279,33 +283,33 @@ obj_removed_cb (CalClient *client, summary->idle = g_idle_add (generate_html_summary, summary); } + static void -cal_loaded_cb (CalClient *client, - CalClientLoadStatus status, +cal_opened_cb (CalClient *client, + CalClientOpenStatus status, CalSummary *summary) { switch (status) { - case CAL_CLIENT_LOAD_SUCCESS: - summary->cal_loaded = TRUE; - + case CAL_CLIENT_OPEN_SUCCESS: if (summary->idle != 0) return; summary->idle = g_idle_add (generate_html_summary, summary); break; - case CAL_CLIENT_LOAD_ERROR: + case CAL_CLIENT_OPEN_ERROR: executive_summary_html_view_set_html (summary->view, _("Error loading calendar")); break; - case CAL_CLIENT_LOAD_IN_USE: - executive_summary_html_view_set_html (summary->view, - _("Error loading calendar:
Calendar in use.")); - + case CAL_CLIENT_OPEN_NOT_FOUND: + /* We did not use only_if_exists when opening the calendar, so + * this should not happen. + */ + g_assert_not_reached (); break; - case CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED: + case CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED: executive_summary_html_view_set_html (summary->view, _("Error loading calendar:
Method not supported")); break; @@ -314,13 +318,17 @@ cal_loaded_cb (CalClient *client, break; } } + static void alarm_fn (gpointer alarm_id, time_t old_t, - CalSummary *summary) + gpointer data) { + CalSummary *summary; time_t t, day_end; + summary = data; + /* Remove the old alarm, and start a new one for the next midnight */ alarm_remove (alarm_id); @@ -464,10 +472,10 @@ property_dialog_changed (GtkWidget *widget, bonobo_property_control_changed (summary->property_control, NULL); } -static void +static BonoboControl * property_dialog (BonoboPropertyControl *property_control, int page_num, - gpointer user_data) + void *user_data) { BonoboControl *control; CalSummary *summary = (CalSummary *) user_data; @@ -530,7 +538,7 @@ create_summary_view (ExecutiveSummaryComponentFactory *_factory, BonoboPropertyControl *property_control; BonoboEventSource *event_source; CalSummary *summary; - char *html, *file; + char *file; time_t t, day_end; file = g_concat_dir_and_file (evolution_dir, "local/Calendar/calendar.ics"); @@ -539,11 +547,10 @@ create_summary_view (ExecutiveSummaryComponentFactory *_factory, component = executive_summary_component_new (); summary = g_new (CalSummary, 1); - summary->component = component; + summary->component = EXECUTIVE_SUMMARY_COMPONENT (component); summary->icon = g_strdup ("evolution-calendar.png"); summary->title = g_strdup ("Things to do"); summary->client = cal_client_new (); - summary->cal_loaded = FALSE; summary->idle = 0; summary->appointments = TRUE; summary->tasks = TRUE; @@ -552,17 +559,12 @@ create_summary_view (ExecutiveSummaryComponentFactory *_factory, day_end = time_day_end (t); summary->alarm = alarm_add (day_end, alarm_fn, summary, NULL); - /* Check for calendar files */ - if (!g_file_exists (file)) { - cal_client_create_calendar (summary->client, file); - } - /* Load calendar */ - cal_client_load_calendar (summary->client, file); + cal_client_open_calendar (summary->client, file, FALSE); g_free (file); - gtk_signal_connect (GTK_OBJECT (summary->client), "cal-loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), summary); + gtk_signal_connect (GTK_OBJECT (summary->client), "cal-opened", + GTK_SIGNAL_FUNC (cal_opened_cb), summary); gtk_signal_connect (GTK_OBJECT (summary->client), "obj-updated", GTK_SIGNAL_FUNC (obj_updated_cb), summary); gtk_signal_connect (GTK_OBJECT (summary->client), "obj-removed", @@ -575,7 +577,7 @@ create_summary_view (ExecutiveSummaryComponentFactory *_factory, /* HTML view */ view = executive_summary_html_view_new_full (event_source); - summary->view = view; + summary->view = EXECUTIVE_SUMMARY_HTML_VIEW (view); executive_summary_html_view_set_html (EXECUTIVE_SUMMARY_HTML_VIEW (view), _("Loading Calendar")); diff --git a/calendar/gui/calendar-summary.h b/calendar/gui/calendar-summary.h index 0fd3c3e7d6..cfb92c0697 100644 --- a/calendar/gui/calendar-summary.h +++ b/calendar/gui/calendar-summary.h @@ -1,9 +1,10 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* calendar-summary.c * - * Authors: Iain Holmes + * Authors: Iain Holmes * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/comp-util.c b/calendar/gui/comp-util.c index d6c26e7751..f1898e914e 100644 --- a/calendar/gui/comp-util.c +++ b/calendar/gui/comp-util.c @@ -1,8 +1,9 @@ /* Evolution calendar - Utilities for manipulating CalComponent objects * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/comp-util.h b/calendar/gui/comp-util.h index d08bfe993b..9c70172aee 100644 --- a/calendar/gui/comp-util.h +++ b/calendar/gui/comp-util.h @@ -1,8 +1,9 @@ /* Evolution calendar - Utilities for manipulating CalComponent objects * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/component-factory.c b/calendar/gui/component-factory.c index de1b2d5839..4f98cbab6b 100644 --- a/calendar/gui/component-factory.c +++ b/calendar/gui/component-factory.c @@ -2,6 +2,7 @@ /* component-factory.c * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,7 +19,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Ettore Perazzoli + * Author: Ettore Perazzoli */ #include @@ -30,6 +31,8 @@ #include "control-factory.h" #include "calendar-config.h" #include "calendar-summary.h" +#include "tasks-control.h" + #define COMPONENT_FACTORY_ID "OAFIID:GNOME_Evolution_Calendar_ShellComponentFactory" diff --git a/calendar/gui/component-factory.h b/calendar/gui/component-factory.h index 8e5cd6605f..d2d570e340 100644 --- a/calendar/gui/component-factory.h +++ b/calendar/gui/component-factory.h @@ -2,6 +2,7 @@ /* component-factory.h * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,7 +19,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Ettore Perazzoli + * Author: Ettore Perazzoli */ #ifndef _COMPONENT_FACTORY_H_ diff --git a/calendar/gui/control-factory.c b/calendar/gui/control-factory.c index fc88738f5b..a97375de77 100644 --- a/calendar/gui/control-factory.c +++ b/calendar/gui/control-factory.c @@ -2,6 +2,7 @@ /* control-factory.c * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,7 +19,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Ettore Perazzoli + * Author: Ettore Perazzoli */ #include @@ -31,7 +32,6 @@ #include #include -#include #include #include diff --git a/calendar/gui/control-factory.h b/calendar/gui/control-factory.h index bacd2d3d90..7170404cda 100644 --- a/calendar/gui/control-factory.h +++ b/calendar/gui/control-factory.h @@ -2,6 +2,7 @@ /* control-factory.c * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,7 +19,7 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Author: Federico Mena Quintero + * Author: Ettore Perazzoli */ #ifndef _CONTROL_FACTORY_H_ diff --git a/calendar/gui/dialogs/alarm-notify-dialog.c b/calendar/gui/dialogs/alarm-notify-dialog.c index 7d8357599c..fbd8c1f097 100644 --- a/calendar/gui/dialogs/alarm-notify-dialog.c +++ b/calendar/gui/dialogs/alarm-notify-dialog.c @@ -1,8 +1,9 @@ /* Evolution calendar - alarm notification dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/dialogs/alarm-notify-dialog.h b/calendar/gui/dialogs/alarm-notify-dialog.h index 1e56f1c586..f2c938c495 100644 --- a/calendar/gui/dialogs/alarm-notify-dialog.h +++ b/calendar/gui/dialogs/alarm-notify-dialog.h @@ -1,8 +1,9 @@ /* Evolution calendar - alarm notification dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/dialogs/cal-prefs-dialog.c b/calendar/gui/dialogs/cal-prefs-dialog.c index 98e6da9d8a..af5d15e9d9 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.c +++ b/calendar/gui/dialogs/cal-prefs-dialog.c @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 2000, Helix Code, Inc. + * Copyright 2000, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/dialogs/cal-prefs-dialog.h b/calendar/gui/dialogs/cal-prefs-dialog.h index 52f115e0ac..9d744f806d 100644 --- a/calendar/gui/dialogs/cal-prefs-dialog.h +++ b/calendar/gui/dialogs/cal-prefs-dialog.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 2000, Helix Code, Inc. + * Copyright 2000, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/dialogs/delete-comp.c b/calendar/gui/dialogs/delete-comp.c index 97e1b69cd6..5099c80de2 100644 --- a/calendar/gui/dialogs/delete-comp.c +++ b/calendar/gui/dialogs/delete-comp.c @@ -1,8 +1,9 @@ /* Evolution calendar - Delete calendar component dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/dialogs/delete-comp.h b/calendar/gui/dialogs/delete-comp.h index cae8531981..b01daecfe0 100644 --- a/calendar/gui/dialogs/delete-comp.h +++ b/calendar/gui/dialogs/delete-comp.h @@ -1,8 +1,9 @@ /* Evolution calendar - Delete calendar component dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Author: Federico Mena-Quintero + * Author: Federico Mena-Quintero * * 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/gui/dialogs/task-editor.c b/calendar/gui/dialogs/task-editor.c index cca8298713..571f9917ef 100644 --- a/calendar/gui/dialogs/task-editor.c +++ b/calendar/gui/dialogs/task-editor.c @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 2000, Helix Code, Inc. + * Copyright 2000, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -50,7 +51,7 @@ typedef struct { /* Client to use */ CalClient *client; - + /* Calendar component we are editing; this is an internal copy and is * not one of the read-only objects from the parent calendar. */ @@ -167,7 +168,7 @@ static void field_changed (GtkWidget *widget, static void task_editor_set_changed (TaskEditor *tedit, gboolean changed); static gboolean prompt_to_save_changes (TaskEditor *tedit); -static void categories_clicked (GtkWidget *button, +static void categories_clicked (GtkWidget *button, TaskEditor *editor); /* The function libglade calls to create the EDateEdit widgets in the GUI. */ @@ -227,7 +228,7 @@ static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("FileDelete", file_delete_cb), BONOBO_UI_VERB ("FileClose", file_close_cb), BONOBO_UI_VERB ("FileSaveAndClose", file_save_and_close_cb), - + BONOBO_UI_VERB ("DebugDumpXml", debug_xml_cb), BONOBO_UI_VERB_END @@ -236,9 +237,9 @@ static BonoboUIVerb verbs [] = { /** * task_editor_construct: * @tedit: A #TaskEditor. - * + * * Constructs a task editor by loading its Glade XML file. - * + * * Return value: The same object as @tedit, or NULL if the widgets could not be * created. In the latter case, the task editor will automatically be * destroyed. @@ -521,7 +522,7 @@ task_editor_destroy (GtkObject *object) } -void +void task_editor_set_cal_client (TaskEditor *tedit, CalClient *client) { @@ -539,8 +540,8 @@ task_editor_set_cal_client (TaskEditor *tedit, g_return_if_fail (IS_CAL_CLIENT (client)); if (client) - g_return_if_fail (cal_client_is_loaded (client)); - + g_return_if_fail (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED); + if (client) gtk_object_ref (GTK_OBJECT (client)); @@ -576,7 +577,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) g_return_if_fail (IS_TASK_EDITOR (tedit)); priv = tedit->priv; - + /* If we aren't showing the object which has been updated, return. */ if (!priv->comp) return; @@ -650,7 +651,7 @@ raise_and_focus (GtkWidget *widget) * task_editor_set_todo_object: * @tedit: A #TaskEditor. * @comp: A todo object. - * + * * Sets the todo object that a task editor dialog will manipulate. **/ void @@ -684,7 +685,7 @@ make_title_from_comp (CalComponent *comp) const char *summary; CalComponentVType type; CalComponentText text; - + if (!comp) return g_strdup (_("Edit Task")); @@ -694,7 +695,7 @@ make_title_from_comp (CalComponent *comp) else summary = _("No summary"); - + type = cal_component_get_vtype (comp); switch (type) { case CAL_COMPONENT_EVENT: @@ -761,7 +762,7 @@ fill_widgets (TaskEditor *tedit) TaskEditorPriority priority; const char *url; const char *categories; - + priv = tedit->priv; task_editor_set_changed (tedit, FALSE); @@ -786,7 +787,7 @@ fill_widgets (TaskEditor *tedit) e_dialog_editable_set (priv->description, NULL); } cal_component_free_text_list (l); - + /* Due Date. */ cal_component_get_due (priv->comp, &d); if (d.value) { @@ -905,7 +906,7 @@ dialog_to_comp_object (TaskEditor *tedit) CalComponentClassification classification; char *url, *cat; char *str; - + priv = tedit->priv; comp = priv->comp; @@ -942,7 +943,7 @@ dialog_to_comp_object (TaskEditor *tedit) cal_component_set_description_list (comp, &l); } - + if (!str) g_free (str); @@ -1020,7 +1021,7 @@ debug_xml_cb (BonoboUIComponent *uic, gpointer data, const char *path) { TaskEditor *tedit = TASK_EDITOR (data); TaskEditorPrivate *priv = tedit->priv; - + bonobo_window_dump (BONOBO_WINDOW (priv->app), "on demand"); } @@ -1052,13 +1053,13 @@ file_delete_cb (BonoboUIComponent *uic, gpointer data, const char *path) TaskEditor *tedit; TaskEditorPrivate *priv; const char *uid; - + tedit = TASK_EDITOR (data); g_return_if_fail (IS_TASK_EDITOR (tedit)); priv = tedit->priv; - + g_return_if_fail (priv->comp); cal_component_get_uid (priv->comp, &uid); @@ -1097,7 +1098,7 @@ priority_value_to_index (int priority_value) retval = PRIORITY_HIGH; else if (priority_value == 5) retval = PRIORITY_NORMAL; - else + else retval = PRIORITY_LOW; return retval; @@ -1298,7 +1299,7 @@ prompt_to_save_changes (TaskEditor *tedit) gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (priv->app)); - + switch (gnome_dialog_run_and_close (GNOME_DIALOG (dialog))) { case 0: /* Save */ /* FIXME: If an error occurs here, we should popup a dialog @@ -1329,7 +1330,7 @@ categories_clicked(GtkWidget *button, TaskEditor *tedit) dialog = GNOME_DIALOG (e_categories_new (categories)); result = gnome_dialog_run (dialog); g_free (categories); - + if (result == 0) { gtk_object_get (GTK_OBJECT (dialog), "categories", &categories, diff --git a/calendar/gui/dialogs/task-editor.h b/calendar/gui/dialogs/task-editor.h index c74e979dff..69e3bd41d8 100644 --- a/calendar/gui/dialogs/task-editor.h +++ b/calendar/gui/dialogs/task-editor.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 2000, Helix Code, Inc. + * Copyright 2000, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-calendar-table.c b/calendar/gui/e-calendar-table.c index 536051ea1f..0fa5bc6f84 100644 --- a/calendar/gui/e-calendar-table.c +++ b/calendar/gui/e-calendar-table.c @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 2000, Helix Code, Inc. + * Copyright 2000, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -335,6 +336,24 @@ e_calendar_table_new (void) } +/** + * e_calendar_table_get_model: + * @cal_table: A calendar table. + * + * Queries the calendar data model that a calendar table is using. + * + * Return value: A calendar model. + **/ +CalendarModel * +e_calendar_table_get_model (ECalendarTable *cal_table) +{ + g_return_val_if_fail (cal_table != NULL, NULL); + g_return_val_if_fail (E_IS_CALENDAR_TABLE (cal_table), NULL); + + return cal_table->model; +} + + static void e_calendar_table_destroy (GtkObject *object) { @@ -345,6 +364,9 @@ e_calendar_table_destroy (GtkObject *object) gtk_object_unref (GTK_OBJECT (cal_table->model)); cal_table->model = NULL; + gtk_object_unref (GTK_OBJECT (cal_table->subset_model)); + cal_table->subset_model = NULL; + GTK_OBJECT_CLASS (parent_class)->destroy (object); } diff --git a/calendar/gui/e-calendar-table.h b/calendar/gui/e-calendar-table.h index 6ca8a32515..555ea357af 100644 --- a/calendar/gui/e-calendar-table.h +++ b/calendar/gui/e-calendar-table.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 2000, Helix Code, Inc. + * Copyright 2000, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -88,6 +89,7 @@ struct _ECalendarTableClass GtkType e_calendar_table_get_type (void); GtkWidget* e_calendar_table_new (void); +CalendarModel *e_calendar_table_get_model (ECalendarTable *cal_table); void e_calendar_table_set_cal_client (ECalendarTable *cal_table, CalClient *client); diff --git a/calendar/gui/e-day-view-main-item.c b/calendar/gui/e-day-view-main-item.c index edcb0b4b82..6867434d53 100644 --- a/calendar/gui/e-day-view-main-item.c +++ b/calendar/gui/e-day-view-main-item.c @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 1999, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-day-view-main-item.h b/calendar/gui/e-day-view-main-item.h index d8305e594d..cb9e2589d8 100644 --- a/calendar/gui/e-day-view-main-item.h +++ b/calendar/gui/e-day-view-main-item.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 1999, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-day-view-time-item.c b/calendar/gui/e-day-view-time-item.c index b0e51aa053..a6c6c66062 100644 --- a/calendar/gui/e-day-view-time-item.c +++ b/calendar/gui/e-day-view-time-item.c @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 1999, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-day-view-time-item.h b/calendar/gui/e-day-view-time-item.h index 8b20fe999e..972f01e1b5 100644 --- a/calendar/gui/e-day-view-time-item.h +++ b/calendar/gui/e-day-view-time-item.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 1999, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-day-view-top-item.h b/calendar/gui/e-day-view-top-item.h index 435ef12b58..53db4eda79 100644 --- a/calendar/gui/e-day-view-top-item.h +++ b/calendar/gui/e-day-view-top-item.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 1999, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c index 1cb4b182ec..1960071cdd 100644 --- a/calendar/gui/e-day-view.c +++ b/calendar/gui/e-day-view.c @@ -1295,15 +1295,15 @@ e_day_view_set_calendar (EDayView *day_view, } -/* Callback used when the calendar client finishes loading */ +/* Callback used when the calendar client finishes opening */ static void -cal_loaded_cb (CalClient *client, CalClientLoadStatus status, gpointer data) +cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) { EDayView *day_view; day_view = E_DAY_VIEW (data); - if (status != CAL_CLIENT_LOAD_SUCCESS) + if (status != CAL_CLIENT_OPEN_SUCCESS) return; e_day_view_queue_reload_events (day_view); @@ -1453,9 +1453,9 @@ e_day_view_set_cal_client (EDayView *day_view, day_view->client = client; if (day_view->client) { - if (!cal_client_is_loaded (day_view->client)) - gtk_signal_connect (GTK_OBJECT (day_view->client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), day_view); + if (cal_client_get_load_state (day_view->client) == CAL_CLIENT_LOAD_LOADED) + gtk_signal_connect (GTK_OBJECT (day_view->client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), day_view); gtk_signal_connect (GTK_OBJECT (day_view->client), "obj_updated", GTK_SIGNAL_FUNC (obj_updated_cb), day_view); @@ -3834,7 +3834,8 @@ e_day_view_reload_events (EDayView *day_view) { e_day_view_free_events (day_view); - if (!(day_view->client && cal_client_is_loaded (day_view->client))) + if (!(day_view->client + && cal_client_get_load_state (day_view->client) == CAL_CLIENT_LOAD_LOADED)) return; /* If both lower & upper are 0, then the time range hasn't been set, diff --git a/calendar/gui/e-day-view.h b/calendar/gui/e-day-view.h index 7e6ea8ac2a..b02bcd7710 100644 --- a/calendar/gui/e-day-view.h +++ b/calendar/gui/e-day-view.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 1999, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c index e46d4a78ee..b72637137f 100644 --- a/calendar/gui/e-itip-control.c +++ b/calendar/gui/e-itip-control.c @@ -1,11 +1,24 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * e-itip-control.c +/* Evolution calendar - Control for displaying iTIP mail messages + * + * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. + * + * Author: Jesse Pavel + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * - * Authors: - * Jesse Pavel + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Copyright 2000, Helix Code, Inc. + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #include @@ -126,29 +139,26 @@ itip_control_destroy_cb (GtkObject *object, static void -cal_loaded_cb (GtkObject *object, CalClientGetStatus status, gpointer data) +cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) { - CalClient *client = CAL_CLIENT (object); EItipControlPrivate *priv = data; gtk_widget_hide (priv->loading_progress); - if (status == CAL_CLIENT_GET_SUCCESS) { + if (status == CAL_CLIENT_OPEN_SUCCESS) { if (cal_client_update_object (client, priv->cal_comp) == FALSE) { GtkWidget *dialog; dialog = gnome_warning_dialog("I couldn't update your calendar file!\n"); gnome_dialog_run (GNOME_DIALOG(dialog)); - } - else { + } else { /* We have success. */ GtkWidget *dialog; dialog = gnome_ok_dialog("Component successfully updated."); gnome_dialog_run (GNOME_DIALOG(dialog)); } - } - else { + } else { GtkWidget *dialog; dialog = gnome_ok_dialog("There was an error loading the calendar file."); @@ -169,10 +179,10 @@ update_calendar (EItipControlPrivate *priv) client = cal_client_new (); - gtk_signal_connect (GTK_OBJECT (client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), priv); + gtk_signal_connect (GTK_OBJECT (client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), priv); - if (cal_client_load_calendar (client, cal_uri) == FALSE) { + if (cal_client_open_calendar (client, cal_uri, FALSE) == FALSE) { GtkWidget *dialog; dialog = gnome_warning_dialog("I couldn't open your calendar file!\n"); @@ -407,11 +417,13 @@ load_calendar_store (char *cal_uri, CalClient **cal_client) } *cal_client = cal_client_new (); - if (cal_client_load_calendar (*cal_client, uri) == FALSE) { + if (cal_client_open_calendar (*cal_client, uri, FALSE) == FALSE) { return FALSE; } - while (!cal_client_is_loaded (*cal_client)) { + /* FIXME!!!!!! This is fucking ugly. */ + + while (!cal_client_get_load_state (*cal_client) != CAL_CLIENT_LOAD_LOADED) { gtk_main_iteration_do (FALSE); /* Do a non-blocking iteration. */ usleep (200000L); /* Pause for 1/5th of a second before checking again.*/ } diff --git a/calendar/gui/e-itip-control.h b/calendar/gui/e-itip-control.h index 467f0578ef..6c2df626ce 100644 --- a/calendar/gui/e-itip-control.h +++ b/calendar/gui/e-itip-control.h @@ -1,3 +1,25 @@ +/* Evolution calendar - Control for displaying iTIP mail messages + * + * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. + * + * Author: Jesse Pavel + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. + */ + #ifndef __E_ITIP_CONTROL_H__ #define __E_ITIP_CONTROL_H__ diff --git a/calendar/gui/e-meeting-edit.c b/calendar/gui/e-meeting-edit.c index abff825a29..5b1b7bda7b 100644 --- a/calendar/gui/e-meeting-edit.c +++ b/calendar/gui/e-meeting-edit.c @@ -1,8 +1,9 @@ /* Evolution calendar - Meeting editor dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Jesse Pavel + * Authors: Jesse Pavel * * 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/gui/e-meeting-edit.h b/calendar/gui/e-meeting-edit.h index 953dd23428..b54909cad7 100644 --- a/calendar/gui/e-meeting-edit.h +++ b/calendar/gui/e-meeting-edit.h @@ -1,8 +1,9 @@ /* Evolution calendar - Meeting editor dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * - * Authors: Jesse Pavel + * Authors: Jesse Pavel * * 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/gui/e-tasks.c b/calendar/gui/e-tasks.c index 29c067783a..9e88a91513 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -2,6 +2,7 @@ /* e-tasks.c * * Copyright (C) 2001 Helix Code, Inc. + * Copyright (C) 2001 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,8 +19,8 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Authors: Federico Mena Quintero - * Damon Chaplin + * Authors: Federico Mena Quintero + * Damon Chaplin */ #include @@ -28,32 +29,16 @@ #include #include "dialogs/task-editor.h" #include "e-calendar-table.h" -#include "alarm-notify.h" #include "component-factory.h" #include "e-tasks.h" -/* States for the calendar loading and creation state machine */ -typedef enum { - LOAD_STATE_NOT_LOADED, - LOAD_STATE_WAIT_LOAD, - LOAD_STATE_WAIT_LOAD_BEFORE_CREATE, - LOAD_STATE_WAIT_CREATE, - LOAD_STATE_LOADED -} LoadState; - /* Private part of the GnomeCalendar structure */ struct _ETasksPrivate { /* The calendar client object we monitor */ CalClient *client; - /* Loading state; we can be loading or creating a calendar */ - LoadState load_state; - - /* URI of the folder being shown. */ - char *folder_uri; - /* The ECalendarTable showing the tasks. */ GtkWidget *tasks_view; @@ -68,7 +53,7 @@ static void e_tasks_init (ETasks *tasks); static void setup_widgets (ETasks *tasks); static void e_tasks_destroy (GtkObject *object); -static void cal_loaded_cb (CalClient *client, CalClientLoadStatus status, gpointer data); +static void cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data); static void obj_updated_cb (CalClient *client, const char *uid, gpointer data); static void obj_removed_cb (CalClient *client, const char *uid, gpointer data); @@ -115,8 +100,6 @@ e_tasks_init (ETasks *tasks) priv = g_new0 (ETasksPrivate, 1); tasks->priv = priv; - priv->load_state = LOAD_STATE_NOT_LOADED; - setup_widgets (tasks); } @@ -138,6 +121,7 @@ setup_widgets (ETasks *tasks) ETasksPrivate *priv; ETable *etable; GtkWidget *hbox, *menuitem, *categories_label; + CalendarModel *model; priv = tasks->priv; @@ -165,13 +149,17 @@ setup_widgets (ETasks *tasks) priv->tasks_view = e_calendar_table_new (); + model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->tasks_view)); + calendar_model_set_new_comp_vtype (model, CAL_COMPONENT_TODO); etable = e_table_scrolled_get_table (E_TABLE_SCROLLED (E_CALENDAR_TABLE (priv->tasks_view)->etable)); e_table_set_state (etable, E_TASKS_TABLE_DEFAULT_STATE); gtk_table_attach (GTK_TABLE (tasks), priv->tasks_view, 0, 1, 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); gtk_widget_show (priv->tasks_view); - gtk_signal_connect (GTK_OBJECT (E_CALENDAR_TABLE (priv->tasks_view)->model), "categories-changed", GTK_SIGNAL_FUNC (e_tasks_on_categories_changed), tasks); + gtk_signal_connect (GTK_OBJECT (E_CALENDAR_TABLE (priv->tasks_view)->model), + "categories-changed", + GTK_SIGNAL_FUNC (e_tasks_on_categories_changed), tasks); } @@ -189,14 +177,16 @@ e_tasks_construct (ETasks *tasks) if (!priv->client) return NULL; - gtk_signal_connect (GTK_OBJECT (priv->client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), tasks); + gtk_signal_connect (GTK_OBJECT (priv->client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), tasks); gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated", GTK_SIGNAL_FUNC (obj_updated_cb), tasks); gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed", GTK_SIGNAL_FUNC (obj_removed_cb), tasks); +#if 0 alarm_notify_add_client (priv->client); +#endif e_calendar_table_set_cal_client (E_CALENDAR_TABLE (priv->tasks_view), priv->client); @@ -241,15 +231,10 @@ e_tasks_destroy (GtkObject *object) config_filename); g_free (config_filename); - priv->load_state = LOAD_STATE_NOT_LOADED; - - if (priv->folder_uri) { - g_free (priv->folder_uri); - priv->folder_uri = NULL; - } - if (priv->client) { +#if 0 alarm_notify_remove_client (priv->client); +#endif gtk_object_unref (GTK_OBJECT (priv->client)); priv->client = NULL; } @@ -264,8 +249,7 @@ e_tasks_destroy (GtkObject *object) gboolean e_tasks_open (ETasks *tasks, - char *file, - ETasksOpenMode gcom) + char *file) { ETasksPrivate *priv; char *config_filename; @@ -275,21 +259,6 @@ e_tasks_open (ETasks *tasks, g_return_val_if_fail (file != NULL, FALSE); priv = tasks->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_NOT_LOADED, - FALSE); - - g_assert (priv->folder_uri == NULL); - - priv->folder_uri = g_strdup (file); - - if (gcom == E_TASKS_OPEN) - priv->load_state = LOAD_STATE_WAIT_LOAD; - else if (gcom == E_TASKS_OPEN_OR_CREATE) - priv->load_state = LOAD_STATE_WAIT_LOAD_BEFORE_CREATE; - else { - g_assert_not_reached (); - return FALSE; - } config_filename = e_tasks_get_config_filename (tasks); e_calendar_table_load_state (E_CALENDAR_TABLE (priv->tasks_view), @@ -297,11 +266,7 @@ e_tasks_open (ETasks *tasks, g_free (config_filename); - if (!cal_client_load_calendar (priv->client, file)) { - priv->load_state = LOAD_STATE_NOT_LOADED; - g_free (priv->folder_uri); - priv->folder_uri = NULL; - + if (!cal_client_open_calendar (priv->client, file, FALSE)) { g_message ("e_tasks_open(): Could not issue the request"); return FALSE; } @@ -310,19 +275,6 @@ e_tasks_open (ETasks *tasks, } -/* Loads the initial data into the calendar; this should be called right after - * the cal_loaded signal from the client is invoked. - */ -static void -initial_load (ETasks *tasks) -{ - ETasksPrivate *priv; - - priv = tasks->priv; - - /* FIXME: Do we need to do anything? */ -} - /* Displays an error to indicate that loading a calendar failed */ static void load_error (ETasks *tasks, @@ -335,19 +287,6 @@ load_error (ETasks *tasks, g_free (msg); } -/* Displays an error to indicate that creating a calendar failed */ -static void -create_error (ETasks *tasks, - const char *uri) -{ - char *msg; - - msg = g_strdup_printf (_("Could not create a tasks file in `%s'"), - uri); - gnome_error_dialog_parented (msg, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (tasks)))); - g_free (msg); -} - /* Displays an error to indicate that the specified URI method is not supported */ static void method_error (ETasks *tasks, @@ -360,89 +299,34 @@ method_error (ETasks *tasks, g_free (msg); } -/* Callback from the calendar client when a calendar is loaded */ +/* Callback from the calendar client when a calendar is opened */ static void -cal_loaded_cb (CalClient *client, - CalClientLoadStatus status, +cal_opened_cb (CalClient *client, + CalClientOpenStatus status, gpointer data) { ETasks *tasks; ETasksPrivate *priv; - gboolean free_uri; tasks = E_TASKS (data); priv = tasks->priv; - g_assert (priv->load_state != LOAD_STATE_NOT_LOADED - && priv->load_state != LOAD_STATE_LOADED); - g_assert (priv->folder_uri != NULL); - - free_uri = TRUE; - - switch (priv->load_state) { - case LOAD_STATE_WAIT_LOAD: - if (status == CAL_CLIENT_LOAD_SUCCESS) { - priv->load_state = LOAD_STATE_LOADED; - initial_load (tasks); - } else if (status == CAL_CLIENT_LOAD_ERROR) { - priv->load_state = LOAD_STATE_NOT_LOADED; - load_error (tasks, priv->folder_uri); - } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) { - priv->load_state = LOAD_STATE_NOT_LOADED; - method_error (tasks, priv->folder_uri); - } else - g_assert_not_reached (); + switch (status) { + case CAL_CLIENT_OPEN_SUCCESS: + /* Everything is OK */ + return; + case CAL_CLIENT_OPEN_ERROR: + load_error (tasks, cal_client_get_uri (client)); break; - case LOAD_STATE_WAIT_LOAD_BEFORE_CREATE: - if (status == CAL_CLIENT_LOAD_SUCCESS) { - priv->load_state = LOAD_STATE_LOADED; - initial_load (tasks); - } else if (status == CAL_CLIENT_LOAD_ERROR) { - priv->load_state = LOAD_STATE_WAIT_CREATE; - free_uri = FALSE; - - if (!cal_client_create_calendar (priv->client, - priv->folder_uri)) { - priv->load_state = LOAD_STATE_NOT_LOADED; - free_uri = TRUE; - g_message ("cal_loaded_cb(): Could not issue the create request"); - } - } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) { - priv->load_state = LOAD_STATE_NOT_LOADED; - method_error (tasks, priv->folder_uri); - } else - g_assert_not_reached (); - - break; - - case LOAD_STATE_WAIT_CREATE: - if (status == CAL_CLIENT_LOAD_SUCCESS) { - priv->load_state = LOAD_STATE_LOADED; - initial_load (tasks); - } else if (status == CAL_CLIENT_LOAD_ERROR) { - priv->load_state = LOAD_STATE_NOT_LOADED; - create_error (tasks, priv->folder_uri); - } else if (status == CAL_CLIENT_LOAD_IN_USE) { - /* Someone created the URI while we were issuing the - * create request, so we just try to reload. - */ - priv->load_state = LOAD_STATE_WAIT_LOAD; - free_uri = FALSE; - - if (!cal_client_load_calendar (priv->client, - priv->folder_uri)) { - priv->load_state = LOAD_STATE_NOT_LOADED; - free_uri = TRUE; - g_message ("cal_loaded_cb(): Could not issue the load request"); - } - } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) { - priv->load_state = LOAD_STATE_NOT_LOADED; - method_error (tasks, priv->folder_uri); - } else - g_assert_not_reached (); + case CAL_CLIENT_OPEN_NOT_FOUND: + /* bullshit; we did not specify only_if_exists */ + g_assert_not_reached (); + return; + case CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED: + method_error (tasks, cal_client_get_uri (client)); break; default: @@ -491,7 +375,7 @@ e_tasks_get_config_filename (ETasks *tasks) priv = tasks->priv; - url = g_strdup (priv->folder_uri); + url = g_strdup (cal_client_get_uri (priv->client)); /* This turns all funny characters into '_', in the string itself. */ e_filename_make_safe (url); diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h index a777c32375..f63ac92a65 100644 --- a/calendar/gui/e-tasks.h +++ b/calendar/gui/e-tasks.h @@ -2,6 +2,7 @@ /* e-tasks.h * * Copyright (C) 2001 Helix Code, Inc. + * Copyright (C) 2001 Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -18,8 +19,8 @@ * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * - * Authors: Federico Mena Quintero - * Damon Chaplin + * Authors: Federico Mena Quintero + * Damon Chaplin */ #ifndef _E_TASKS_H_ @@ -51,19 +52,13 @@ struct _ETasksClass { }; -typedef enum { - E_TASKS_OPEN, - E_TASKS_OPEN_OR_CREATE -} ETasksOpenMode; - GtkType e_tasks_get_type (void); GtkWidget *e_tasks_construct (ETasks *tasks); GtkWidget *e_tasks_new (void); gboolean e_tasks_open (ETasks *tasks, - char *file, - ETasksOpenMode gcom); + char *file); CalClient *e_tasks_get_cal_client (ETasks *tasks); diff --git a/calendar/gui/e-week-view-event-item.c b/calendar/gui/e-week-view-event-item.c index ee77573f6e..5615e86bb6 100644 --- a/calendar/gui/e-week-view-event-item.c +++ b/calendar/gui/e-week-view-event-item.c @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 2001, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-week-view-event-item.h b/calendar/gui/e-week-view-event-item.h index cfe58699b0..ff2b9b2c9f 100644 --- a/calendar/gui/e-week-view-event-item.h +++ b/calendar/gui/e-week-view-event-item.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 2001, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-week-view-main-item.h b/calendar/gui/e-week-view-main-item.h index f75dcb0ec9..71ebe423dc 100644 --- a/calendar/gui/e-week-view-main-item.h +++ b/calendar/gui/e-week-view-main-item.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 2001, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-week-view-titles-item.h b/calendar/gui/e-week-view-titles-item.h index 7ce1ccd386..fc4d45107d 100644 --- a/calendar/gui/e-week-view-titles-item.h +++ b/calendar/gui/e-week-view-titles-item.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 2001, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c index 0b7743e970..b205bdc34e 100644 --- a/calendar/gui/e-week-view.c +++ b/calendar/gui/e-week-view.c @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 2001, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -831,15 +832,15 @@ e_week_view_set_calendar (EWeekView *week_view, } -/* Callback used when the calendar client finishes loading */ +/* Callback used when the calendar client finishes opening */ static void -cal_loaded_cb (CalClient *client, CalClientLoadStatus status, gpointer data) +cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) { EWeekView *week_view; week_view = E_WEEK_VIEW (data); - if (status != CAL_CLIENT_LOAD_SUCCESS) + if (status != CAL_CLIENT_OPEN_SUCCESS) return; e_week_view_queue_reload_events (week_view); @@ -976,9 +977,9 @@ e_week_view_set_cal_client (EWeekView *week_view, week_view->client = client; if (week_view->client) { - if (!cal_client_is_loaded (week_view->client)) - gtk_signal_connect (GTK_OBJECT (week_view->client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), week_view); + if (cal_client_get_load_state (week_view->client) != CAL_CLIENT_LOAD_LOADED) + gtk_signal_connect (GTK_OBJECT (week_view->client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), week_view); gtk_signal_connect (GTK_OBJECT (week_view->client), "obj_updated", GTK_SIGNAL_FUNC (obj_updated_cb), week_view); @@ -2012,7 +2013,8 @@ e_week_view_reload_events (EWeekView *week_view) e_week_view_free_events (week_view); - if (!(week_view->client && cal_client_is_loaded (week_view->client))) + if (!(week_view->client + && cal_client_get_load_state (week_view->client) == CAL_CLIENT_LOAD_LOADED)) return; /* Only load events if the date range has been set. */ diff --git a/calendar/gui/e-week-view.h b/calendar/gui/e-week-view.h index aa9ba05fb9..be2f1057da 100644 --- a/calendar/gui/e-week-view.h +++ b/calendar/gui/e-week-view.h @@ -2,9 +2,10 @@ /* * Author : - * Damon Chaplin + * Damon Chaplin * * Copyright 1999, Helix Code, Inc. + * Copyright 2001, Ximian, Inc. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as diff --git a/calendar/gui/event-editor.c b/calendar/gui/event-editor.c index 16a9737b35..350de507e7 100644 --- a/calendar/gui/event-editor.c +++ b/calendar/gui/event-editor.c @@ -3,10 +3,11 @@ /* Evolution calendar - Event editor dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2001 Ximian, Inc. * - * Authors: Miguel de Icaza - * Federico Mena-Quintero - * Seth Alves + * Authors: Miguel de Icaza + * Federico Mena-Quintero + * Seth Alves * * 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 @@ -75,7 +76,7 @@ struct _EventEditorPrivate { /* Client to use */ CalClient *client; - + /* Calendar object/uid we are editing; this is an internal copy */ CalComponent *comp; @@ -113,7 +114,7 @@ struct _EventEditorPrivate { GtkWidget *categories; GtkWidget *categories_btn; - + GtkWidget *recurrence_summary; GtkWidget *recurrence_starting_date; @@ -325,7 +326,7 @@ make_title_from_comp (CalComponent *comp) const char *summary; CalComponentVType type; CalComponentText text; - + if (!comp) return g_strdup (_("Edit Appointment")); @@ -335,7 +336,7 @@ make_title_from_comp (CalComponent *comp) else summary = _("No summary"); - + type = cal_component_get_vtype (comp); switch (type) { case CAL_COMPONENT_EVENT: @@ -845,7 +846,7 @@ sensitize_recur_widgets (EventEditor *ee) g_assert_not_reached (); } } - + /* Callback used when one of the recurrence type radio buttons is toggled. We * enable or the recurrence parameters. */ @@ -1869,7 +1870,7 @@ fill_widgets (EventEditor *ee) GSList *l; time_t dtstart, dtend; const char *categories; - + priv = ee->priv; clear_widgets (ee); @@ -1888,7 +1889,7 @@ fill_widgets (EventEditor *ee) e_dialog_editable_set (priv->description, text.value); } cal_component_free_text_list (l); - + /* Start and end times */ /* All-day events are inclusive, i.e. if the end date shown is 2nd Feb @@ -1984,7 +1985,7 @@ fill_widgets (EventEditor *ee) /** * event_editor_update_widgets: * @ee: An event editor. - * + * * Causes an event editor dialog to re-read the values of its calendar component * object. This function should be used if the #CalComponent is changed by * external means while it is open in the editor. @@ -2232,7 +2233,7 @@ recur_to_comp_object (EventEditor *ee, CalComponent *comp) tim = gtk_clist_get_row_data (exception_list, i); *cdt->value = icaltime_from_timet (*tim, FALSE, TRUE); - + list = g_slist_prepend (list, cdt); } @@ -2249,7 +2250,7 @@ dialog_to_comp_object (EventEditor *ee, CalComponent *comp) time_t t; gboolean all_day_event; char *cat, *str; - + priv = ee->priv; /* Summary */ @@ -2285,12 +2286,12 @@ dialog_to_comp_object (EventEditor *ee, CalComponent *comp) cal_component_set_description_list (comp, &l); } - + if (!str) g_free (str); /* Dates */ - + date.value = g_new (struct icaltimetype, 1); date.tzid = NULL; @@ -2400,7 +2401,7 @@ debug_xml_cb (BonoboUIComponent *uic, gpointer data, const char *path) { EventEditor *ee = EVENT_EDITOR (data); EventEditorPrivate *priv = ee->priv; - + bonobo_window_dump (BONOBO_WINDOW (priv->app), "on demand"); } @@ -2431,13 +2432,13 @@ file_delete_cb (BonoboUIComponent *uic, gpointer data, const char *path) { EventEditor *ee; EventEditorPrivate *priv; - + ee = EVENT_EDITOR (data); g_return_if_fail (IS_EVENT_EDITOR (ee)); priv = ee->priv; - + g_return_if_fail (priv->comp); if (delete_component_dialog (priv->comp, priv->app)) { @@ -2496,9 +2497,9 @@ static BonoboUIVerb verbs [] = { BONOBO_UI_VERB ("FileDelete", file_delete_cb), BONOBO_UI_VERB ("FileClose", file_close_cb), BONOBO_UI_VERB ("FileSaveAndClose", file_save_and_close_cb), - + BONOBO_UI_VERB ("ActionScheduleMeeting", schedule_meeting_cb), - + BONOBO_UI_VERB ("DebugDumpXml", debug_xml_cb), BONOBO_UI_VERB_END @@ -2525,9 +2526,9 @@ app_delete_event_cb (GtkWidget *widget, GdkEvent *event, gpointer data) /** * event_editor_construct: * @ee: An event editor. - * + * * Constructs an event editor by loading its Glade data. - * + * * Return value: The same object as @ee, or NULL if the widgets could not be * created. In the latter case, the event editor will automatically be * destroyed. @@ -2604,7 +2605,7 @@ event_editor_construct (EventEditor *ee) /* Add focus to the summary entry */ - + gtk_widget_grab_focus (GTK_WIDGET (priv->general_summary)); /* Show the dialog */ @@ -2621,9 +2622,9 @@ event_editor_construct (EventEditor *ee) /** * event_editor_new: - * + * * Creates a new event editor dialog. - * + * * Return value: A newly-created event editor dialog, or NULL if the event * editor could not be created. **/ @@ -2660,7 +2661,7 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) g_return_if_fail (IS_EVENT_EDITOR (ee)); priv = ee->priv; - + /* If we aren't showing the object which has been updated, return. */ if (!priv->comp) return; @@ -2723,11 +2724,11 @@ obj_removed_cb (CalClient *client, const char *uid, gpointer data) * event_editor_set_cal_client: * @ee: An event editor. * @client: Calendar client. - * + * * Sets the calendar client than an event editor will use for updating its * calendar components. **/ -void +void event_editor_set_cal_client (EventEditor *ee, CalClient *client) { EventEditorPrivate *priv; @@ -2744,8 +2745,8 @@ event_editor_set_cal_client (EventEditor *ee, CalClient *client) g_return_if_fail (IS_CAL_CLIENT (client)); if (client) - g_return_if_fail (cal_client_is_loaded (client)); - + g_return_if_fail (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED); + if (client) gtk_object_ref (GTK_OBJECT (client)); @@ -2767,10 +2768,10 @@ event_editor_set_cal_client (EventEditor *ee, CalClient *client) /** * event_editor_get_cal_client: * @ee: An event editor. - * + * * Queries the calendar client that an event editor is using to update its * calendar components. - * + * * Return value: A calendar client object. **/ CalClient * @@ -2789,7 +2790,7 @@ event_editor_get_cal_client (EventEditor *ee) * event_editor_set_event_object: * @ee: An event editor. * @comp: A calendar object. - * + * * Sets the calendar object that an event editor dialog will manipulate. **/ void @@ -2818,7 +2819,7 @@ event_editor_set_event_object (EventEditor *ee, CalComponent *comp) /** * event_editor_focus: * @ee: An event editor. - * + * * Makes sure an event editor is shown, on top of other windows, and focused. **/ void @@ -3275,7 +3276,7 @@ prompt_to_save_changes (EventEditor *ee) gnome_dialog_set_parent (GNOME_DIALOG (dialog), GTK_WINDOW (priv->app)); - + switch (gnome_dialog_run_and_close (GNOME_DIALOG (dialog))) { case 0: /* Save */ /* FIXME: If an error occurs here, we should popup a dialog @@ -3305,7 +3306,7 @@ categories_clicked (GtkWidget *button, EventEditor *ee) dialog = GNOME_DIALOG (e_categories_new (categories)); result = gnome_dialog_run (dialog); g_free (categories); - + if (result == 0) { gtk_object_get (GTK_OBJECT (dialog), "categories", &categories, diff --git a/calendar/gui/event-editor.h b/calendar/gui/event-editor.h index 1be61eb860..60be54c784 100644 --- a/calendar/gui/event-editor.h +++ b/calendar/gui/event-editor.h @@ -1,10 +1,11 @@ /* Evolution calendar - Event editor dialog * * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2001 Ximian, Inc. * - * Authors: Miguel de Icaza - * Federico Mena-Quintero - * Seth Alves + * Authors: Miguel de Icaza + * Federico Mena-Quintero + * Seth Alves * * 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/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index fafd31d583..3cd835680d 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -1,10 +1,27 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* - * GnomeCalendar widget - * Copyright (C) 1998 the Free Software Foundation +/* Evolution calendar - Main calendar view widget * - * Authors: Miguel de Icaza (miguel@kernel.org) - * Federico Mena-Quintero + * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2001 Ximian, Inc. + * + * Authors: Miguel de Icaza + * Federico Mena-Quintero + * Seth Alves + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #include @@ -18,7 +35,6 @@ #include #include #include "dialogs/alarm-notify-dialog.h" -#include "alarm-notify.h" #include "e-calendar-table.h" #include "e-day-view.h" #include "e-week-view.h" @@ -40,30 +56,14 @@ typedef enum { VIEW_MONTH } ViewType; -/* States for the calendar loading and creation state machine */ -typedef enum { - LOAD_STATE_NOT_LOADED, - LOAD_STATE_WAIT_LOAD, - LOAD_STATE_WAIT_LOAD_BEFORE_CREATE, - LOAD_STATE_WAIT_CREATE, - LOAD_STATE_LOADED -} LoadState; - /* Private part of the GnomeCalendar structure */ struct _GnomeCalendarPrivate { - /* * The Calendar Folder. */ /* The calendar client object we monitor */ - CalClient *client; - - /* Loading state; we can be loading or creating a calendar */ - LoadState load_state; - - /* URI being loaded, NULL if we are not being loaded */ - char *loading_uri; + CalClient *client; /* * The TaskPad Folder. @@ -72,13 +72,9 @@ struct _GnomeCalendarPrivate { /* The calendar client object we monitor */ CalClient *task_pad_client; - /* Loading state; we can be loading or creating a calendar */ - LoadState task_pad_load_state; - - /* URI being loaded, NULL if we are not being loaded */ - char *task_pad_loading_uri; - - + /* + * Fields for the calendar view + */ /* Mapping of component UIDs to event editors */ GHashTable *object_editor_hash; @@ -209,6 +205,7 @@ setup_widgets (GnomeCalendar *gcal) GnomeCalendarPrivate *priv; GtkWidget *w; gchar *filename; + CalendarModel *model; priv = gcal->priv; @@ -257,6 +254,8 @@ setup_widgets (GnomeCalendar *gcal) /* The ToDo list. */ priv->todo = e_calendar_table_new (); + model = e_calendar_table_get_model (E_CALENDAR_TABLE (priv->todo)); + calendar_model_set_new_comp_vtype (model, CAL_COMPONENT_TODO); e_paned_pack2 (E_PANED (priv->vpane), priv->todo, TRUE, TRUE); gtk_widget_show (priv->todo); @@ -308,9 +307,6 @@ gnome_calendar_init (GnomeCalendar *gcal) priv = g_new0 (GnomeCalendarPrivate, 1); gcal->priv = priv; - priv->load_state = LOAD_STATE_NOT_LOADED; - priv->task_pad_load_state = LOAD_STATE_NOT_LOADED; - priv->object_editor_hash = g_hash_table_new (g_str_hash, g_str_equal); priv->current_view_type = VIEW_NOT_SET; @@ -350,27 +346,18 @@ gnome_calendar_destroy (GtkObject *object) e_calendar_table_save_state (E_CALENDAR_TABLE (priv->todo), filename); g_free (filename); - priv->load_state = LOAD_STATE_NOT_LOADED; - priv->task_pad_load_state = LOAD_STATE_NOT_LOADED; - - if (priv->loading_uri) { - g_free (priv->loading_uri); - priv->loading_uri = NULL; - } - - if (priv->task_pad_loading_uri) { - g_free (priv->task_pad_loading_uri); - priv->task_pad_loading_uri = NULL; - } - if (priv->client) { +#if 0 alarm_notify_remove_client (priv->client); +#endif gtk_object_unref (GTK_OBJECT (priv->client)); priv->client = NULL; } if (priv->task_pad_client) { +#if 0 alarm_notify_remove_client (priv->task_pad_client); +#endif gtk_object_unref (GTK_OBJECT (priv->task_pad_client)); priv->task_pad_client = NULL; } @@ -688,7 +675,7 @@ gnome_calendar_set_pane_positions (GnomeCalendar *gcal) } /* Loads the initial data into the calendar; this should be called right after - * the cal_loaded signal from the client is invoked. + * the cal_opened signal from the client is invoked. */ static void initial_load (GnomeCalendar *gcal) @@ -700,24 +687,13 @@ initial_load (GnomeCalendar *gcal) tag_calendar_by_client (priv->date_navigator, priv->client); } -/* Displays an error to indicate that loading a calendar failed */ -static void -load_error (GnomeCalendar *gcal, const char *uri) -{ - char *msg; - - msg = g_strdup_printf (_("Could not load the folder in `%s'"), uri); - gnome_error_dialog_parented (msg, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); - g_free (msg); -} - -/* Displays an error to indicate that creating a calendar failed */ +/* Displays an error to indicate that opening a calendar failed */ static void -create_error (GnomeCalendar *gcal, const char *uri) +open_error (GnomeCalendar *gcal, const char *uri) { char *msg; - msg = g_strdup_printf (_("Could not create a folder in `%s'"), uri); + msg = g_strdup_printf (_("Could not open the folder in `%s'"), uri); gnome_error_dialog_parented (msg, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); g_free (msg); } @@ -728,118 +704,44 @@ method_error (GnomeCalendar *gcal, const char *uri) { char *msg; - msg = g_strdup_printf (_("The method required to load `%s' is not supported"), uri); + msg = g_strdup_printf (_("The method required to open `%s' is not supported"), uri); gnome_error_dialog_parented (msg, GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (gcal)))); g_free (msg); } /* Callback from the calendar client when a calendar is loaded */ static void -cal_loaded_cb (CalClient *client, CalClientLoadStatus status, gpointer data) +cal_opened_cb (CalClient *client, CalClientOpenStatus status, gpointer data) { GnomeCalendar *gcal; GnomeCalendarPrivate *priv; - gboolean free_uri, is_calendar = FALSE; - LoadState *load_state; - char **loading_uri; gcal = GNOME_CALENDAR (data); priv = gcal->priv; - if (client == priv->client) { - is_calendar = TRUE; - load_state = &priv->load_state; - loading_uri = &priv->loading_uri; - } else if (client == priv->task_pad_client) { - load_state = &priv->task_pad_load_state; - loading_uri = &priv->task_pad_loading_uri; - } else { - g_assert_not_reached (); - return; - } - - g_assert (*load_state != LOAD_STATE_NOT_LOADED - && *load_state != LOAD_STATE_LOADED); - g_assert (*loading_uri != NULL); - - free_uri = TRUE; - - switch (*load_state) { - case LOAD_STATE_WAIT_LOAD: - if (status == CAL_CLIENT_LOAD_SUCCESS) { - *load_state = LOAD_STATE_LOADED; - if (is_calendar) - initial_load (gcal); - } else if (status == CAL_CLIENT_LOAD_ERROR) { - *load_state = LOAD_STATE_NOT_LOADED; - load_error (gcal, *loading_uri); - } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) { - *load_state = LOAD_STATE_NOT_LOADED; - method_error (gcal, *loading_uri); - } else - g_assert_not_reached (); + switch (status) { + case CAL_CLIENT_OPEN_SUCCESS: + if (client == priv->client) + initial_load (gcal); break; - case LOAD_STATE_WAIT_LOAD_BEFORE_CREATE: - if (status == CAL_CLIENT_LOAD_SUCCESS) { - *load_state = LOAD_STATE_LOADED; - if (is_calendar) - initial_load (gcal); - } else if (status == CAL_CLIENT_LOAD_ERROR) { - *load_state = LOAD_STATE_WAIT_CREATE; - free_uri = FALSE; - - if (!cal_client_create_calendar (client, - *loading_uri)) { - *load_state = LOAD_STATE_NOT_LOADED; - free_uri = TRUE; - g_message ("cal_loaded_cb(): Could not issue the create request"); - } - } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) { - *load_state = LOAD_STATE_NOT_LOADED; - method_error (gcal, *loading_uri); - } else - g_assert_not_reached (); - + case CAL_CLIENT_OPEN_ERROR: + open_error (gcal, cal_client_get_uri (client)); break; - case LOAD_STATE_WAIT_CREATE: - if (status == CAL_CLIENT_LOAD_SUCCESS) { - *load_state = LOAD_STATE_LOADED; - if (is_calendar) - initial_load (gcal); - } else if (status == CAL_CLIENT_LOAD_ERROR) { - *load_state = LOAD_STATE_NOT_LOADED; - create_error (gcal, *loading_uri); - } else if (status == CAL_CLIENT_LOAD_IN_USE) { - /* Someone created the URI while we were issuing the - * create request, so we just try to reload. - */ - *load_state = LOAD_STATE_WAIT_LOAD; - free_uri = FALSE; - - if (!cal_client_load_calendar (client, - *loading_uri)) { - *load_state = LOAD_STATE_NOT_LOADED; - free_uri = TRUE; - g_message ("cal_loaded_cb(): Could not issue the load request"); - } - } else if (status == CAL_CLIENT_LOAD_METHOD_NOT_SUPPORTED) { - *load_state = LOAD_STATE_NOT_LOADED; - method_error (gcal, *loading_uri); - } else - g_assert_not_reached (); + case CAL_CLIENT_OPEN_NOT_FOUND: + /* bullshit; we did not specify only_if_exists */ + g_assert_not_reached (); + return; + case CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED: + method_error (gcal, cal_client_get_uri (client)); break; default: g_assert_not_reached (); - } - - if (free_uri) { - g_free (*loading_uri); - *loading_uri = NULL; + return; } } @@ -888,14 +790,16 @@ gnome_calendar_construct (GnomeCalendar *gcal) if (!priv->client) return NULL; - gtk_signal_connect (GTK_OBJECT (priv->client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), gcal); + gtk_signal_connect (GTK_OBJECT (priv->client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), gcal); gtk_signal_connect (GTK_OBJECT (priv->client), "obj_updated", GTK_SIGNAL_FUNC (obj_updated_cb), gcal); gtk_signal_connect (GTK_OBJECT (priv->client), "obj_removed", GTK_SIGNAL_FUNC (obj_removed_cb), gcal); +#if 0 alarm_notify_add_client (priv->client); +#endif e_day_view_set_cal_client (E_DAY_VIEW (priv->day_view), priv->client); @@ -913,10 +817,12 @@ gnome_calendar_construct (GnomeCalendar *gcal) if (!priv->task_pad_client) return NULL; - gtk_signal_connect (GTK_OBJECT (priv->task_pad_client), "cal_loaded", - GTK_SIGNAL_FUNC (cal_loaded_cb), gcal); + gtk_signal_connect (GTK_OBJECT (priv->task_pad_client), "cal_opened", + GTK_SIGNAL_FUNC (cal_opened_cb), gcal); +#if 0 alarm_notify_add_client (priv->task_pad_client); +#endif e_calendar_table_set_cal_client (E_CALENDAR_TABLE (priv->todo), priv->task_pad_client); @@ -982,40 +888,27 @@ gnome_calendar_get_cal_client (GnomeCalendar *gcal) } gboolean -gnome_calendar_open (GnomeCalendar *gcal, char *file, GnomeCalendarOpenMode gcom) +gnome_calendar_open (GnomeCalendar *gcal, char *str_uri) { GnomeCalendarPrivate *priv; - LoadState initial_load_state; + char *tasks_uri; + gboolean success; g_return_val_if_fail (gcal != NULL, FALSE); g_return_val_if_fail (GNOME_IS_CALENDAR (gcal), FALSE); - g_return_val_if_fail (file != NULL, FALSE); + g_return_val_if_fail (str_uri != NULL, FALSE); priv = gcal->priv; - g_return_val_if_fail (priv->load_state == LOAD_STATE_NOT_LOADED, FALSE); - g_return_val_if_fail (priv->task_pad_load_state == LOAD_STATE_NOT_LOADED, FALSE); - - g_assert (priv->loading_uri == NULL); - g_assert (priv->task_pad_loading_uri == NULL); - - priv->loading_uri = g_strdup (file); - - if (gcom == CALENDAR_OPEN) - priv->load_state = LOAD_STATE_WAIT_LOAD; - else if (gcom == CALENDAR_OPEN_OR_CREATE) - priv->load_state = LOAD_STATE_WAIT_LOAD_BEFORE_CREATE; - else { - g_assert_not_reached (); - return FALSE; - } - initial_load_state = priv->load_state; + g_return_val_if_fail ( + cal_client_get_load_state (priv->client) == CAL_CLIENT_LOAD_NOT_LOADED, + FALSE); - if (!cal_client_load_calendar (priv->client, file)) { - priv->load_state = LOAD_STATE_NOT_LOADED; - g_free (priv->loading_uri); - priv->loading_uri = NULL; + g_return_val_if_fail ( + cal_client_get_load_state (priv->task_pad_client) == CAL_CLIENT_LOAD_NOT_LOADED, + FALSE); + if (!cal_client_open_calendar (priv->client, str_uri, FALSE)) { g_message ("gnome_calendar_open(): Could not issue the request"); return FALSE; } @@ -1023,15 +916,12 @@ gnome_calendar_open (GnomeCalendar *gcal, char *file, GnomeCalendarOpenMode gcom /* Open the appropriate Tasks folder to show in the TaskPad. Currently we just show the folder named "Tasks", but it will be a per-calendar option in future. */ - priv->task_pad_loading_uri = g_strdup_printf ("%s/local/Tasks/tasks.ics", evolution_dir); - priv->task_pad_load_state = initial_load_state; - if (!cal_client_load_calendar (priv->task_pad_client, - priv->task_pad_loading_uri)) { - priv->task_pad_load_state = LOAD_STATE_NOT_LOADED; - g_free (priv->task_pad_loading_uri); - priv->task_pad_loading_uri = NULL; + tasks_uri = g_strdup_printf ("%s/local/Tasks/tasks.ics", evolution_dir); + success = cal_client_open_calendar (priv->task_pad_client, tasks_uri, FALSE); + g_free (tasks_uri); + if (!success) { g_message ("gnome_calendar_open(): Could not issue the request"); return FALSE; } diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 6ac320b51b..5b4f2623b6 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -1,9 +1,26 @@ -/* - * GnomeCalendar widget - * Copyright (C) 1998 the Free Software Foundation +/* Evolution calendar - Main calendar view widget + * + * Copyright (C) 1998 The Free Software Foundation + * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2001 Ximian, Inc. + * + * Authors: Miguel de Icaza + * Federico Mena-Quintero + * Seth Alves + * + * 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * Authors: Miguel de Icaza (miguel@kernel.org) - * Federico Mena-Quintero + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #ifndef GNOME_CALENDAR_APP_H @@ -55,9 +72,7 @@ GtkWidget *gnome_calendar_new (void); CalClient *gnome_calendar_get_cal_client (GnomeCalendar *gcal); -gboolean gnome_calendar_open (GnomeCalendar *gcal, - char *file, - GnomeCalendarOpenMode gcom); +gboolean gnome_calendar_open (GnomeCalendar *gcal, char *str_uri); /* int gnome_calendar_create (GnomeCalendar *gcal, char *file); diff --git a/calendar/gui/goto.c b/calendar/gui/goto.c index 6da562b603..89ad47844e 100644 --- a/calendar/gui/goto.c +++ b/calendar/gui/goto.c @@ -1,10 +1,11 @@ /* Go to date dialog for Evolution * - * Copyright (C) 1998 Red Hat Software, Inc. + * Copyright (C) 1998 Red Hat, Inc. * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2001 Ximian, Inc. * - * Authors: Federico Mena - * JP Rosevear + * Authors: Federico Mena + * JP Rosevear */ #include diff --git a/calendar/gui/goto.h b/calendar/gui/goto.h index f0dc41feba..b40c222fc4 100644 --- a/calendar/gui/goto.h +++ b/calendar/gui/goto.h @@ -1,8 +1,11 @@ /* Evolution calendar - Go To Date dialog * + * Copyright (C) 1998 Red Hat, Inc. * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2001 Ximian, Inc. * - * Author: JP Rosevear + * Authors: Federico Mena + * JP Rosevear * * 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/gui/main.c b/calendar/gui/main.c index b286eb060a..ebfc54d87d 100644 --- a/calendar/gui/main.c +++ b/calendar/gui/main.c @@ -33,8 +33,8 @@ #include #include + #include "alarm.h" -#include "alarm-notify.h" #include "calendar-commands.h" #include "calendar-config.h" #include "component-factory.h" @@ -65,7 +65,6 @@ main (int argc, char **argv) init_bonobo (argc, argv); glade_gnome_init (); alarm_init (); - alarm_notify_init (); e_cursors_init (); #if 0 @@ -82,9 +81,8 @@ main (int argc, char **argv) bonobo_main (); - calendar_config_write_on_exit (); - alarm_notify_done (); alarm_done (); + calendar_config_write_on_exit (); return 0; } diff --git a/calendar/gui/tag-calendar.c b/calendar/gui/tag-calendar.c index 4d8e154c4c..ce2047b3ad 100644 --- a/calendar/gui/tag-calendar.c +++ b/calendar/gui/tag-calendar.c @@ -123,7 +123,7 @@ tag_calendar_by_client (ECalendar *ecal, CalClient *client) prepare_tag (ecal, &c); - if (!cal_client_is_loaded (client)) + if (cal_client_get_load_state (client) == CAL_CLIENT_LOAD_LOADED) return; #if 0 diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c index e45f72623b..c93836f1fa 100644 --- a/calendar/gui/tasks-control.c +++ b/calendar/gui/tasks-control.c @@ -151,7 +151,7 @@ tasks_control_set_property (BonoboPropertyBag *bag, case TASKS_CONTROL_PROPERTY_URI_IDX: filename = g_strdup_printf ("%s/tasks.ics", BONOBO_ARG_GET_STRING (arg)); - e_tasks_open (tasks, filename, E_TASKS_OPEN_OR_CREATE); + e_tasks_open (tasks, filename); g_free (filename); break; diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl index 024efee2d3..571d514370 100644 --- a/calendar/idl/evolution-calendar.idl +++ b/calendar/idl/evolution-calendar.idl @@ -2,9 +2,10 @@ * * Copyright (C) 2000 Eskil Heyn Olsen * Copyright (C) 2000 Helix Code, Inc. + * Copyright (C) 2000 Ximian, Inc. * * Authors: Eskil Heyn Olsen - * Federico Mena-Quintero + * Federico Mena-Quintero */ #ifndef _EVOLUTION_CALENDAR_IDL_ @@ -154,20 +155,20 @@ module Calendar { /* Listener for changes in a calendar */ interface Listener : Bonobo::Unknown { - /* Return status when loading a calendar; we need better error reporting */ - enum LoadStatus { + /* Return status when opening a calendar */ + enum OpenStatus { SUCCESS, /* All OK */ ERROR, /* Generic error */ - IN_USE, /* Requested create while a calendar - * with the same URI was in use. + NOT_FOUND, /* Requested opening in only_if_exists mode + * when the URI did not exist. */ METHOD_NOT_SUPPORTED /* A method handler is not registered */ }; - /* Called from a CalFactory when a calendar is initially loaded - * or created. The listener must remember the cal object. + /* Called from a CalFactory when a calendar is initially opened. + * The listener must remember the cal object. */ - void notifyCalLoaded (in LoadStatus status, in Cal cal); + void notifyCalOpened (in OpenStatus status, in Cal cal); /* Called from a Calendar when a component is added or changed */ void notifyObjUpdated (in CalObjUID uid); @@ -180,12 +181,8 @@ module Calendar { interface CalFactory : Bonobo::Unknown { exception NilListener {}; - /* Load a calendar from an URI */ - void load (in string uri, in Listener listener) - raises (NilListener); - - /* Create a new calendar at the specified URI */ - void create (in string uri, in Listener listener) + /* Open a calendar from an URI */ + void open (in string uri, in boolean only_if_exists, in Listener listener) raises (NilListener); }; 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 + * Author: Federico Mena-Quintero * * 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 + * Author: Federico Mena-Quintero * * 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 - * JP Rosevear + * Authors: Federico Mena-Quintero + * JP Rosevear * * 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,53 +140,33 @@ 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. 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 + * Author: Federico Mena-Quintero * * 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 + * Author: Federico Mena-Quintero * * 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 + * Author: Federico Mena-Quintero * * 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 + * Author: Federico Mena-Quintero * * 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 + * Author: Federico Mena-Quintero * * 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 + * Author: Federico Mena-Quintero * * 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 + * Author: Federico Mena-Quintero * * 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 + * Author: Federico Mena-Quintero * * 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 -- cgit v1.2.3