diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-01-17 18:44:33 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-01-17 18:44:33 +0800 |
commit | 0932fd7ec9d21e763371a043283384af8bc987fb (patch) | |
tree | dbfd7dcaf49fd667712a6408eae165bd201c3219 /calendar/cal-client/cal-client.c | |
parent | ff6098b51168decc542245a215056dc6219ebd69 (diff) | |
download | gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.gz gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.tar.zst gsoc2013-evolution-0932fd7ec9d21e763371a043283384af8bc987fb.zip |
Ximianified email addresses and copyrights.
2001-01-17 Federico Mena Quintero <federico@ximian.com>
* */*: Ximianified email addresses and copyrights.
* idl/evolution-calendar.idl (CalFactory::open): Renamed from
::load(), and added an only_if_exists argument.
(CalFactory::create): Removed method.
(Listener::OpenStatus): Removed the IN_USE error and replaced it
with a NOT_FOUND one; renamed the enum from LoadStatus.
(Listener::notifyCalOpened): Renamed from notifyCalLoaded().
* pcs/cal-backend.h (CalBackend): Removed the uri field.
(CalBackendOpenStatus): Renamed from CalBackendLoadStatus and
added a NOT_FOUND value.
(CalBackendClass::open): Put in a slot for the open method.
* pcs/cal-backend.c (cal_backend_create): Removed function.
* pcs/cal-backend-file.c (cal_backend_file_open): Return the
appropriate value when only_if_exists is TRUE.
(create_cal): We are Ximian now, so set the PRODID property to
the appropriate foo.
* pcs/cal-factory.c (CalFactory_open): implemented, replacing
CalFactory_load() and CalFactory_create().
(CalFactory_open): Moved the queue_load_create_job() stuff to
here, since we now only need to contemplate the open case instead
of load/create ones.
(open_backend): Do everything here; replaces load_backend() and
create_backend().
* cal-client/cal-listener.h (CalListenerClass::cal_opened):
Renamed from cal_loaded.
(CalListenerClass): Replaced the silly signals, which are
gratuitous abstraction, by a set of function pointers in the
instance structure.
* cal-client/cal-listener.c (cal_listener_get_calendar): Removed
unused function.
(cal_listener_construct): Added the listener notification functions.
(cal_listener_new): Ditto.
(Listener_notifyCalOpened): Renamed to our new naming convention
for servant implementations.
(Listener_notifyObjUpdated): Ditto.
(Listener_notifyObjRemoved): Ditto.
* cal-client/cal-client.h (CalClientOpenStatus): Renamed from
CalClientLoadStatus.
(CalClientClass::cal_opened): Renamed from ::cal_loaded().
(CalClientLoadState): New enum; basically make LoadState public so
that users of this code do not have to maintain their own states.
* cal-client/cal-client.c (cal_client_create_calendar): Removed
function.
(cal_client_open_calendar): Moved the functionality over from
load_or_create(); now we do everything here.
(*): Use the CalClientLoadState enum values instead of the old
LoadState values.
(cal_client_get_load_state): Renamed from cal_client_is_loaded(),
and return the appropriate value.
(CalClientPrivate): Added an uri field.
(cal_client_init): Initialize priv->uri.
(cal_client_destroy): Free the priv->uri.
(cal_opened_cb): Maintain the priv->uri.
(cal_client_open_calendar): Fill in the priv->uri.
(cal_client_get_uri): New function.
* gui/calendar-model.c (calendar_model_set_new_comp_vtype): New
function to configure the type of calendar components to create
when doing click-to-add. This makes the model usable for
something other than task lists.
(calendar_model_get_new_comp_vtype): New function.
* gui/e-calendar-table.c (e_calendar_table_get_model): New function.
(e_calendar_table_destroy): Unref the subset_model.
* gui/gnome-cal.h (GnomeCalendarOpenMode): Removed enum.
* gui/gnome-cal.c (LoadState): Removed enum; we now use the
CalClientLoadState from the client objects.
(GnomeCalendarPrivate): Removed the loading_uri and
task_pad_loading_uri fields as well as the load_state and
task_pad_load_state fields, as we can now query them directly from
the CalClient.
(open_error): Renamed from load_error().
(create_error): Removed function.
(gnome_calendar_open): Do not take in the mode parameter.
(cal_opened_cb): Get rid of our beautifully-crafted state machine
and replace it with simple code; all the loading smarts are in the
Wombat now.
(setup_widgets): Set the new component vtype of the table model to
CAL_COMPONENT_TODO.
* gui/Makefile.am (evolution_calendar_SOURCES): Removed
gnome-month-item.[ch] from the list of sources.
* gui/calendar-summary.c (CalSummary): Removed unused cal_loaded
field.
(create_summary_view): Do not check if the file exists; this is
the job of the Wombat.
(generate_html_summary): Fixed prototype.
(alarm_fn): Fixed prototype.
(property_dialog): Fixed prototype. Wonder if/how this ever
worked.
(create_summary_view): Cast the component and view as
appropriate. Removed unused html variable.
[Iain dude, are you compiling with -Wall?]
* gui/e-itip-control.c (cal_opened_cb): Sigh, this function
signature was *very* wrong. It was using CalClientGetStatus
instead of CalClientOpenStatus.
* gui/e-tasks.h (ETasksOpenMode): Removed enum.
* gui/e-tasks.c (setup_widgets): Set the new component vtype of
the table model to CAL_COMPONENT_TODO.
(LoadState): Removed the state machine foo.
(e_tasks_open): Removed the mode parameter.
(initial_load): Removed function.
(create_error): Removed function.
(ETasksPrivate): Removed folder_uri field.
(cal_opened_cb): Remove the state machine.
* gui/component-factory.c: #include "tasks-control.h"
* conduits/calendar/calendar-conduit.h (ECalConduitContext):
Removed calendar_load_tried field.
* conduits/calendar/calendar-conduit.c (start_calendar_server_cb):
Sigh, fixed function prototype.
* conduits/todo/todo-conduit.h (EToDoConduitContext): Removed
calendar_load_tried field.
* conduits/todo/todo-conduit.c (start_calendar_server_cb): Fixed
function prototype.
svn path=/trunk/; revision=7571
Diffstat (limited to 'calendar/cal-client/cal-client.c')
-rw-r--r-- | calendar/cal-client/cal-client.c | 223 |
1 files changed, 119 insertions, 104 deletions
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 <federico@helixcode.com> + * Author: Federico Mena-Quintero <federico@ximian.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -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); |