diff options
author | JP Rosevear <jpr@ximian.com> | 2001-09-26 14:40:50 +0800 |
---|---|---|
committer | JP Rosevear <jpr@src.gnome.org> | 2001-09-26 14:40:50 +0800 |
commit | 943c0e6e2393607a1adf380db102cc2bad61ff52 (patch) | |
tree | c8bcf65617509c8c40e74fcbd82ff956c9584026 | |
parent | 225b147233ea335927385c2f867218b6abfb3994 (diff) | |
download | gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.gz gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.bz2 gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.lz gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.xz gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.tar.zst gsoc2013-evolution-943c0e6e2393607a1adf380db102cc2bad61ff52.zip |
new proto
2001-09-26 JP Rosevear <jpr@ximian.com>
* pcs/cal.h: new proto
* pcs/cal.c (impl_Cal_set_mode): implement set mode method
(cal_class_init): set setMode function in epv
(cal_notify_mode): notify listener of mode change
* pcs/cal-factory.c (add_uri): deal with UriType renaming
* pcs/cal-backend.h: add new virtual methods and protos
* pcs/cal-backend.c (cal_backend_class_init): init new virtual
methods to null
(cal_backend_set_mode): sets mode
(cal_backend_get_mode): gets mode
* pcs/cal-backend-file.c (cal_backend_file_class_init): overide
get_mode and set_mode methods
(cal_backend_file_get_mode): return mode
(notify_mode): have listeners notified of the set mode call
(cal_backend_file_set_mode): set the mode by indicating not
supported
* cal-client/cal-listener.h: update proto
* cal-client/cal-listener.c (impl_notifyCalSetMode): implement set
mode callback
(cal_listener_construct): take set mode callback
(cal_listener_new): ditto
* cal-client/cal-client.h: update protos, add signal proto
* cal-client/cal-client.c (cal_client_class_init): add
cal_set_mode signal
(cal_set_mode_cb): handle set mode callback from listener
(cal_client_open_calendar): pass additional param to cal_listener_new
(cal_client_set_mode): wrapper to set the calendar mode
* idl/evolution-calendar.idl: make UriType into CalMode, add
SetModeStatus enum and notifyCalSetMode method to the listener
* gui/calendar-offline-handler.c (create_connection_list): fetch
the uri list ourselves
(impl_prepareForOffline): reflect param change of
create_connect_list
(update_offline): ditto
(backend_cal_set_mode): set mode call back
(backend_cal_opened): cal opened call back, set mode to local
(impl_goOffline): reflect UriType renaming
* cal-util/cal-util.h: rename UriType to CalMode
svn path=/trunk/; revision=13142
-rw-r--r-- | calendar/ChangeLog | 53 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.c | 88 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.h | 14 | ||||
-rw-r--r-- | calendar/cal-client/cal-listener.c | 31 | ||||
-rw-r--r-- | calendar/cal-client/cal-listener.h | 7 | ||||
-rw-r--r-- | calendar/cal-util/cal-util.h | 10 | ||||
-rw-r--r-- | calendar/gui/calendar-offline-handler.c | 35 | ||||
-rw-r--r-- | calendar/idl/evolution-calendar.idl | 25 | ||||
-rw-r--r-- | calendar/pcs/cal-backend-file.c | 41 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.c | 37 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.h | 9 | ||||
-rw-r--r-- | calendar/pcs/cal-factory.c | 20 | ||||
-rw-r--r-- | calendar/pcs/cal.c | 47 | ||||
-rw-r--r-- | calendar/pcs/cal.h | 3 |
14 files changed, 369 insertions, 51 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index f58198addd..b4b48a9f5c 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,56 @@ +2001-09-26 JP Rosevear <jpr@ximian.com> + + * pcs/cal.h: new proto + + * pcs/cal.c (impl_Cal_set_mode): implement set mode method + (cal_class_init): set setMode function in epv + (cal_notify_mode): notify listener of mode change + + * pcs/cal-factory.c (add_uri): deal with UriType renaming + + * pcs/cal-backend.h: add new virtual methods and protos + + * pcs/cal-backend.c (cal_backend_class_init): init new virtual + methods to null + (cal_backend_set_mode): sets mode + (cal_backend_get_mode): gets mode + + * pcs/cal-backend-file.c (cal_backend_file_class_init): overide + get_mode and set_mode methods + (cal_backend_file_get_mode): return mode + (notify_mode): have listeners notified of the set mode call + (cal_backend_file_set_mode): set the mode by indicating not + supported + + * cal-client/cal-listener.h: update proto + + * cal-client/cal-listener.c (impl_notifyCalSetMode): implement set + mode callback + (cal_listener_construct): take set mode callback + (cal_listener_new): ditto + + * cal-client/cal-client.h: update protos, add signal proto + + * cal-client/cal-client.c (cal_client_class_init): add + cal_set_mode signal + (cal_set_mode_cb): handle set mode callback from listener + (cal_client_open_calendar): pass additional param to cal_listener_new + (cal_client_set_mode): wrapper to set the calendar mode + + * idl/evolution-calendar.idl: make UriType into CalMode, add + SetModeStatus enum and notifyCalSetMode method to the listener + + * gui/calendar-offline-handler.c (create_connection_list): fetch + the uri list ourselves + (impl_prepareForOffline): reflect param change of + create_connect_list + (update_offline): ditto + (backend_cal_set_mode): set mode call back + (backend_cal_opened): cal opened call back, set mode to local + (impl_goOffline): reflect UriType renaming + + * cal-util/cal-util.h: rename UriType to CalMode + 2001-09-25 Federico Mena Quintero <federico@ximian.com> Warning fixes courtesy of Chris Lahey <clahey@ximian.com>. diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index 78d31eeab6..27c827cbac 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -70,6 +70,7 @@ struct _CalClientPrivate { /* Signal IDs */ enum { CAL_OPENED, + CAL_SET_MODE, OBJ_UPDATED, OBJ_REMOVED, CATEGORIES_CHANGED, @@ -128,6 +129,8 @@ cal_client_get_type (void) return cal_client_type; } +#define marshal_NONE__ENUM_ENUM gtk_marshal_NONE__INT_INT + /* Class initialization function for the calendar client */ static void cal_client_class_init (CalClientClass *class) @@ -146,6 +149,15 @@ cal_client_class_init (CalClientClass *class) gtk_marshal_NONE__ENUM, GTK_TYPE_NONE, 1, GTK_TYPE_ENUM); + cal_client_signals[CAL_SET_MODE] = + gtk_signal_new ("cal_set_mode", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (CalClientClass, cal_set_mode), + marshal_NONE__ENUM_ENUM, + GTK_TYPE_NONE, 2, + GTK_TYPE_ENUM, + GTK_TYPE_ENUM); cal_client_signals[OBJ_UPDATED] = gtk_signal_new ("obj_updated", GTK_RUN_FIRST, @@ -443,6 +455,53 @@ cal_opened_cb (CalListener *listener, gtk_object_unref (GTK_OBJECT (client)); } +/* Handle the cal_set_mode notification from the listener */ +static void +cal_set_mode_cb (CalListener *listener, + GNOME_Evolution_Calendar_Listener_SetModeStatus status, + GNOME_Evolution_Calendar_CalMode mode, + gpointer data) +{ + CalClient *client; + CalClientPrivate *priv; + CalClientSetModeStatus client_status; + + client = CAL_CLIENT (data); + priv = client->priv; + + g_assert (priv->load_state == CAL_CLIENT_LOAD_LOADING); + g_assert (priv->uri != NULL); + + client_status = CAL_CLIENT_OPEN_ERROR; + + switch (status) { + case GNOME_Evolution_Calendar_Listener_MODE_SET: + client_status = CAL_CLIENT_SET_MODE_SUCCESS; + break; + case GNOME_Evolution_Calendar_Listener_MODE_NOT_SET: + client_status = CAL_CLIENT_SET_MODE_ERROR; + break; + case GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED: + client_status = CAL_CLIENT_SET_MODE_NOT_SUPPORTED; + break; + default: + g_assert_not_reached (); + } + + /* We are *not* inside a signal handler (this is just a simple callback + * called from the listener), so there is not a temporary reference to + * the client object. We ref() so that we can safely emit our own + * signal and clean up. + */ + + gtk_object_ref (GTK_OBJECT (client)); + + gtk_signal_emit (GTK_OBJECT (client), cal_client_signals[CAL_SET_MODE], + client_status, mode); + + gtk_object_unref (GTK_OBJECT (client)); +} + /* Handle the obj_updated signal from the listener */ static void obj_updated_cb (CalListener *listener, const GNOME_Evolution_Calendar_CalObjUID uid, gpointer data) @@ -655,6 +714,7 @@ cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_ g_return_val_if_fail (str_uri != NULL, FALSE); priv->listener = cal_listener_new (cal_opened_cb, + cal_set_mode_cb, obj_updated_cb, obj_removed_cb, categories_changed_cb, @@ -716,7 +776,7 @@ build_uri_list (GNOME_Evolution_Calendar_StringSeq *seq) * Return value: A list of URI's open on the wombat **/ GList * -cal_client_uri_list (CalClient *client, CalUriType type) +cal_client_uri_list (CalClient *client, CalMode mode) { CalClientPrivate *priv; GNOME_Evolution_Calendar_StringSeq *uri_seq; @@ -730,7 +790,7 @@ cal_client_uri_list (CalClient *client, CalUriType type) CORBA_exception_init (&ev); - uri_seq = GNOME_Evolution_Calendar_CalFactory_uriList (priv->factory, type, &ev); + uri_seq = GNOME_Evolution_Calendar_CalFactory_uriList (priv->factory, mode, &ev); if (BONOBO_EX (&ev)) g_message ("cal_client_uri_list(): request failed"); @@ -794,6 +854,30 @@ corba_obj_type (CalObjType type) | ((type & CALOBJ_TYPE_JOURNAL) ? GNOME_Evolution_Calendar_TYPE_JOURNAL : 0)); } +gboolean +cal_client_set_mode (CalClient *client, CalMode mode) +{ + CalClientPrivate *priv; + gboolean retval = TRUE; + CORBA_Environment ev; + + g_return_val_if_fail (client != NULL, -1); + g_return_val_if_fail (IS_CAL_CLIENT (client), -1); + + priv = client->priv; + g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, -1); + + CORBA_exception_init (&ev); + GNOME_Evolution_Calendar_Cal_setMode (priv->cal, mode, &ev); + + if (BONOBO_EX (&ev)) + retval = FALSE; + + CORBA_exception_free (&ev); + + return retval; +} + /** * cal_client_get_n_objects: * @client: A calendar client. diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h index 4237563dc7..10614ef83f 100644 --- a/calendar/cal-client/cal-client.h +++ b/calendar/cal-client/cal-client.h @@ -51,6 +51,13 @@ typedef enum { CAL_CLIENT_OPEN_METHOD_NOT_SUPPORTED } CalClientOpenStatus; +/* Set mode status for the cal_client_set_mode function */ +typedef enum { + CAL_CLIENT_SET_MODE_SUCCESS, + CAL_CLIENT_SET_MODE_ERROR, + CAL_CLIENT_SET_MODE_NOT_SUPPORTED +} CalClientSetModeStatus; + /* Get status for the cal_client_get_object() function */ typedef enum { CAL_CLIENT_GET_SUCCESS, @@ -78,7 +85,8 @@ struct _CalClientClass { /* Notification signals */ void (* cal_opened) (CalClient *client, CalClientOpenStatus status); - + void (* cal_set_mode) (CalClient *client, CalClientSetModeStatus status, CalMode mode); + void (* obj_updated) (CalClient *client, const char *uid); void (* obj_removed) (CalClient *client, const char *uid); @@ -101,12 +109,14 @@ CalClient *cal_client_new (void); void cal_client_set_auth_func (CalClient *client, CalClientAuthFunc func, gpointer data); gboolean cal_client_open_calendar (CalClient *client, const char *str_uri, gboolean only_if_exists); -GList *cal_client_uri_list (CalClient *client, CalUriType type); +GList *cal_client_uri_list (CalClient *client, CalMode mode); CalClientLoadState cal_client_get_load_state (CalClient *client); const char *cal_client_get_uri (CalClient *client); +gboolean cal_client_set_mode (CalClient *client, CalMode mode); + int cal_client_get_n_objects (CalClient *client, CalObjType type); CalClientGetStatus cal_client_get_object (CalClient *client, diff --git a/calendar/cal-client/cal-listener.c b/calendar/cal-client/cal-listener.c index 8d4d49c286..2623575151 100644 --- a/calendar/cal-client/cal-listener.c +++ b/calendar/cal-client/cal-listener.c @@ -28,6 +28,7 @@ struct CalListenerPrivate { /* Notification functions and their closure data */ CalListenerCalOpenedFn cal_opened_fn; + CalListenerCalSetModeFn cal_set_mode_fn; CalListenerObjUpdatedFn obj_updated_fn; CalListenerObjRemovedFn obj_removed_fn; CalListenerCategoriesChangedFn categories_changed_fn; @@ -47,6 +48,10 @@ static void impl_notifyCalOpened (PortableServer_Servant servant, GNOME_Evolution_Calendar_Listener_OpenStatus status, GNOME_Evolution_Calendar_Cal cal, CORBA_Environment *ev); +static void impl_notifyCalSetMode (PortableServer_Servant servant, + GNOME_Evolution_Calendar_Listener_SetModeStatus status, + GNOME_Evolution_Calendar_CalMode mode, + CORBA_Environment *ev); static void impl_notifyObjUpdated (PortableServer_Servant servant, GNOME_Evolution_Calendar_CalObjUID uid, CORBA_Environment *ev); @@ -77,6 +82,7 @@ cal_listener_class_init (CalListenerClass *class) parent_class = gtk_type_class (BONOBO_X_OBJECT_TYPE); class->epv.notifyCalOpened = impl_notifyCalOpened; + class->epv.notifyCalSetMode = impl_notifyCalSetMode; class->epv.notifyObjUpdated = impl_notifyObjUpdated; class->epv.notifyObjRemoved = impl_notifyObjRemoved; class->epv.notifyCategoriesChanged = impl_notifyCategoriesChanged; @@ -165,6 +171,26 @@ impl_notifyCalOpened (PortableServer_Servant servant, (* priv->cal_opened_fn) (listener, status, cal, priv->fn_data); } +/* ::notifyCalSetMode method */ +static void +impl_notifyCalSetMode (PortableServer_Servant servant, + GNOME_Evolution_Calendar_Listener_SetModeStatus status, + GNOME_Evolution_Calendar_CalMode mode, + CORBA_Environment *ev) +{ + CalListener *listener; + CalListenerPrivate *priv; + + listener = CAL_LISTENER (bonobo_object_from_servant (servant)); + priv = listener->priv; + + if (!priv->notify) + return; + + g_assert (priv->cal_set_mode_fn != NULL); + (* priv->cal_set_mode_fn) (listener, status, mode, priv->fn_data); +} + /* ::notifyObjUpdated method */ static void impl_notifyObjUpdated (PortableServer_Servant servant, @@ -246,6 +272,7 @@ impl_notifyCategoriesChanged (PortableServer_Servant servant, CalListener * cal_listener_construct (CalListener *listener, CalListenerCalOpenedFn cal_opened_fn, + CalListenerCalSetModeFn cal_set_mode_fn, CalListenerObjUpdatedFn obj_updated_fn, CalListenerObjRemovedFn obj_removed_fn, CalListenerCategoriesChangedFn categories_changed_fn, @@ -256,6 +283,7 @@ cal_listener_construct (CalListener *listener, 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 (cal_set_mode_fn != NULL, NULL); g_return_val_if_fail (obj_updated_fn != NULL, NULL); g_return_val_if_fail (obj_removed_fn != NULL, NULL); g_return_val_if_fail (categories_changed_fn != NULL, NULL); @@ -263,6 +291,7 @@ cal_listener_construct (CalListener *listener, priv = listener->priv; priv->cal_opened_fn = cal_opened_fn; + priv->cal_set_mode_fn = cal_set_mode_fn; priv->obj_updated_fn = obj_updated_fn; priv->obj_removed_fn = obj_removed_fn; priv->categories_changed_fn = categories_changed_fn; @@ -290,6 +319,7 @@ cal_listener_construct (CalListener *listener, **/ CalListener * cal_listener_new (CalListenerCalOpenedFn cal_opened_fn, + CalListenerCalSetModeFn cal_set_mode_fn, CalListenerObjUpdatedFn obj_updated_fn, CalListenerObjRemovedFn obj_removed_fn, CalListenerCategoriesChangedFn categories_changed_fn, @@ -305,6 +335,7 @@ cal_listener_new (CalListenerCalOpenedFn cal_opened_fn, listener = gtk_type_new (CAL_LISTENER_TYPE); return cal_listener_construct (listener, cal_opened_fn, + cal_set_mode_fn, obj_updated_fn, obj_removed_fn, categories_changed_fn, diff --git a/calendar/cal-client/cal-listener.h b/calendar/cal-client/cal-listener.h index 87a4f892fe..350eafff15 100644 --- a/calendar/cal-client/cal-listener.h +++ b/calendar/cal-client/cal-listener.h @@ -58,6 +58,11 @@ typedef void (* CalListenerCalOpenedFn) (CalListener *listener, GNOME_Evolution_Calendar_Cal cal, gpointer data); +typedef void (* CalListenerCalSetModeFn) (CalListener *listener, + GNOME_Evolution_Calendar_Listener_SetModeStatus status, + GNOME_Evolution_Calendar_CalMode mode, + gpointer data); + typedef void (* CalListenerObjUpdatedFn) (CalListener *listener, const GNOME_Evolution_Calendar_CalObjUID uid, gpointer data); @@ -74,12 +79,14 @@ GtkType cal_listener_get_type (void); CalListener *cal_listener_construct (CalListener *listener, CalListenerCalOpenedFn cal_opened_fn, + CalListenerCalSetModeFn cal_set_mode_fn, CalListenerObjUpdatedFn obj_updated_fn, CalListenerObjRemovedFn obj_removed_fn, CalListenerCategoriesChangedFn categories_changed_fn, gpointer fn_data); CalListener *cal_listener_new (CalListenerCalOpenedFn cal_opened_fn, + CalListenerCalSetModeFn cal_set_mode_fn, CalListenerObjUpdatedFn obj_updated_fn, CalListenerObjRemovedFn obj_removed_fn, CalListenerCategoriesChangedFn categories_changed_fn, diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h index 2cf7fcee8f..2fc75b29f8 100644 --- a/calendar/cal-util/cal-util.h +++ b/calendar/cal-util/cal-util.h @@ -53,12 +53,12 @@ typedef enum { CALOBJ_TYPE_ANY = 0x07 } CalObjType; -/* Used for uri list */ +/* Used for mode stuff */ typedef enum { - CALURI_TYPE_LOCAL = 1 << 0, - CALURI_TYPE_REMOTE = 1 << 1, - CALURI_TYPE_ANY = 0x07 -} CalUriType; + CAL_MODE_LOCAL = 1 << 0, + CAL_MODE_REMOTE = 1 << 1, + CAL_MODE_ANY = 0x07 +} CalMode; void cal_obj_uid_list_free (GList *list); diff --git a/calendar/gui/calendar-offline-handler.c b/calendar/gui/calendar-offline-handler.c index e57ba042ee..e804bc8040 100644 --- a/calendar/gui/calendar-offline-handler.c +++ b/calendar/gui/calendar-offline-handler.c @@ -28,6 +28,7 @@ #endif #include <gtk/gtkmain.h> +#include <gtk/gtksignal.h> #include <bonobo/bonobo-exception.h> #include <libgnomevfs/gnome-vfs-types.h> #include <libgnomevfs/gnome-vfs-uri.h> @@ -64,9 +65,15 @@ add_connection (gpointer data, gpointer user_data) } static GNOME_Evolution_ConnectionList * -create_connection_list (GList *uris) +create_connection_list (CalendarOfflineHandler *offline_handler) { + CalendarOfflineHandlerPrivate *priv; GNOME_Evolution_ConnectionList *list; + GList *uris; + + priv = offline_handler->priv; + + uris = cal_client_uri_list (priv->client, CAL_MODE_REMOTE); list = GNOME_Evolution_ConnectionList__alloc (); list->_length = 0; @@ -99,14 +106,11 @@ impl_prepareForOffline (PortableServer_Servant servant, { CalendarOfflineHandler *offline_handler; CalendarOfflineHandlerPrivate *priv; - GList *uris; offline_handler = CALENDAR_OFFLINE_HANDLER (bonobo_object_from_servant (servant)); priv = offline_handler->priv; - uris = cal_client_uri_list (priv->client, CALURI_TYPE_REMOTE); - - *active_connection_list = create_connection_list (uris); + *active_connection_list = create_connection_list (offline_handler); } static void @@ -118,8 +122,7 @@ update_offline (CalendarOfflineHandler *offline_handler) priv = offline_handler->priv; -#if 0 - connection_list = create_connection_list (); + connection_list = create_connection_list (offline_handler); CORBA_exception_init (&ev); @@ -130,9 +133,16 @@ update_offline (CalendarOfflineHandler *offline_handler) g_warning ("Error updating offline progress"); CORBA_exception_free (&ev); -#endif } - + +static void +backend_cal_set_mode (CalClient *client, CalClientSetModeStatus status, CalMode mode, gpointer data) +{ + CalendarOfflineHandler *offline_handler = data; + + update_offline (offline_handler); +} + static void backend_cal_opened (CalClient *client, CalClientOpenStatus status, gpointer data) { @@ -143,6 +153,11 @@ backend_cal_opened (CalClient *client, CalClientOpenStatus status, gpointer data gtk_object_unref (GTK_OBJECT (client)); return; } + + cal_client_set_mode (client, CAL_MODE_LOCAL); + + gtk_signal_connect (GTK_OBJECT (client), "cal_mode_set", + backend_cal_set_mode, offline_handler); } static void @@ -180,7 +195,7 @@ impl_goOffline (PortableServer_Servant servant, /* To update the status */ priv->listener_interface = CORBA_Object_duplicate (progress_listener, ev); - uris = cal_client_uri_list (priv->client, CALURI_TYPE_REMOTE); + uris = cal_client_uri_list (priv->client, CAL_MODE_REMOTE); g_list_foreach (uris, backend_go_offline, offline_handler); } diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl index be378a017a..df9b7ecf57 100644 --- a/calendar/idl/evolution-calendar.idl +++ b/calendar/idl/evolution-calendar.idl @@ -49,10 +49,10 @@ module Calendar { const CalObjType TYPE_ANY = 0x07; /* Flags for getting URI sequences */ - typedef long UriType; - const UriType URI_LOCAL = 1 << 0; - const UriType URI_REMOTE = 1 << 1; - const UriType URI_ANY = 0x07; + typedef long CalMode; + const CalMode MODE_LOCAL = 1 << 0; + const CalMode MODE_REMOTE = 1 << 1; + const CalMode MODE_ANY = 0x07; /* Types of object changes made */ typedef long CalObjChangeType; @@ -131,10 +131,13 @@ module Calendar { exception InvalidRange {}; exception InvalidObject {}; exception CouldNotCreate {}; - + /* A calendar is identified by its URI */ readonly attribute string uri; + /* For going online/offline */ + void setMode (in CalMode mode); + /* Gets the number of components of the specified types */ long countObjects (in CalObjType type); @@ -215,11 +218,21 @@ module Calendar { METHOD_NOT_SUPPORTED /* A method handler is not registered */ }; + /* Return status when setting calendar mode */ + enum SetModeStatus { + MODE_SET, /* All OK */ + MODE_NOT_SET, /* Generic error */ + MODE_NOT_SUPPORTED /* Mode not supported */ + }; + /* Called from a CalFactory when a calendar is initially opened. * The listener must remember the cal object. */ void notifyCalOpened (in OpenStatus status, in Cal cal); + /* Called from a Calendar when the mode is changed */ + void notifyCalSetMode (in SetModeStatus status, in CalMode mode); + /* Called from a Calendar when a component is added or changed */ void notifyObjUpdated (in CalObjUID uid); @@ -276,7 +289,7 @@ module Calendar { raises (NilListener); /* List of open URI's */ - StringSeq uriList (in UriType type); + StringSeq uriList (in CalMode mode); }; /* Interface to the alarm notification service */ diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index a1e679b1c0..c3fdea7234 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -90,7 +90,9 @@ static GnomeVFSURI *cal_backend_file_get_uri (CalBackend *backend); static CalBackendOpenStatus cal_backend_file_open (CalBackend *backend, GnomeVFSURI *uri, gboolean only_if_exists); static gboolean cal_backend_file_is_loaded (CalBackend *backend); -static gboolean cal_backend_file_is_remote (CalBackend *backend); + +static CalMode cal_backend_file_get_mode (CalBackend *backend); +static void cal_backend_file_set_mode (CalBackend *backend, CalMode mode); static int cal_backend_file_get_n_objects (CalBackend *backend, CalObjType type); static char *cal_backend_file_get_object (CalBackend *backend, const char *uid); @@ -170,7 +172,8 @@ cal_backend_file_class_init (CalBackendFileClass *class) backend_class->get_uri = cal_backend_file_get_uri; backend_class->open = cal_backend_file_open; backend_class->is_loaded = cal_backend_file_is_loaded; - backend_class->is_remote = cal_backend_file_is_remote; + backend_class->get_mode = cal_backend_file_get_mode; + backend_class->set_mode = cal_backend_file_set_mode; backend_class->get_n_objects = cal_backend_file_get_n_objects; backend_class->get_object = cal_backend_file_get_object; backend_class->get_object_component = cal_backend_file_get_object_component; @@ -881,8 +884,8 @@ cal_backend_file_is_loaded (CalBackend *backend) } /* is_remote handler for the file backend */ -static gboolean -cal_backend_file_is_remote (CalBackend *backend) +static CalMode +cal_backend_file_get_mode (CalBackend *backend) { CalBackendFile *cbfile; CalBackendFilePrivate *priv; @@ -890,7 +893,35 @@ cal_backend_file_is_remote (CalBackend *backend) cbfile = CAL_BACKEND_FILE (backend); priv = cbfile->priv; - return FALSE; + return CAL_MODE_LOCAL; +} + +static void +notify_mode (CalBackendFile *cbfile, + GNOME_Evolution_Calendar_Listener_SetModeStatus status, + GNOME_Evolution_Calendar_CalMode mode) +{ + CalBackendFilePrivate *priv; + GList *l; + + priv = cbfile->priv; + + for (l = CAL_BACKEND (cbfile)->clients; l; l = l->next) { + Cal *cal; + + cal = CAL (l->data); + cal_notify_mode (cal, status, mode); + } +} + +/* Set_mode handler for the file backend */ +static void +cal_backend_file_set_mode (CalBackend *backend, CalMode mode) +{ + notify_mode (CAL_BACKEND_FILE (backend), + GNOME_Evolution_Calendar_Listener_MODE_NOT_SUPPORTED, + GNOME_Evolution_Calendar_MODE_LOCAL); + } /* Get_n_objects handler for the file backend */ diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index 296af0e8a3..ae2bd328eb 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -144,7 +144,8 @@ cal_backend_class_init (CalBackendClass *class) class->get_uri = NULL; class->open = NULL; class->is_loaded = NULL; - class->is_remote = NULL; + class->get_mode = NULL; + class->set_mode = NULL; class->get_n_objects = NULL; class->get_object = NULL; class->get_object_component = NULL; @@ -297,28 +298,46 @@ cal_backend_is_loaded (CalBackend *backend) } /** - * cal_backend_is_remote: + * cal_backend_get_mode: * @backend: A calendar backend. * * Queries whether a calendar backend is connected remotely. * - * Return value: TRUE if the backend is connected remotely, FALSE - * otherwise. + * Return value: The current mode the calendar is in **/ -gboolean -cal_backend_is_remote (CalBackend *backend) +CalMode +cal_backend_get_mode (CalBackend *backend) { - gboolean result; + CalMode result; g_return_val_if_fail (backend != NULL, FALSE); g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE); - g_assert (CLASS (backend)->is_remote != NULL); - result = (* CLASS (backend)->is_remote) (backend); + g_assert (CLASS (backend)->get_mode != NULL); + result = (* CLASS (backend)->get_mode) (backend); return result; } + +/** + * cal_backend_set_mode: + * @backend: A calendar backend + * @mode: Mode to change to + * + * Sets the mode of the calendar + * + **/ +void +cal_backend_set_mode (CalBackend *backend, CalMode mode) +{ + g_return_if_fail (backend != NULL); + g_return_if_fail (IS_CAL_BACKEND (backend)); + + g_assert (CLASS (backend)->set_mode != NULL); + (* CLASS (backend)->set_mode) (backend, mode); +} + /** * cal_backend_get_n_objects: * @backend: A calendar backend. diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h index 32617f94ae..ff5d31d0dd 100644 --- a/calendar/pcs/cal-backend.h +++ b/calendar/pcs/cal-backend.h @@ -81,7 +81,10 @@ struct _CalBackendClass { gboolean only_if_exists); gboolean (* is_loaded) (CalBackend *backend); - gboolean (* is_remote) (CalBackend *backend); + + /* Mode relate virtual methods */ + CalMode (* get_mode) (CalBackend *backend); + void (* set_mode) (CalBackend *backend, CalMode mode); /* General object acquirement and information related virtual methods */ int (* get_n_objects) (CalBackend *backend, CalObjType type); @@ -123,7 +126,9 @@ CalBackendOpenStatus cal_backend_open (CalBackend *backend, GnomeVFSURI *uri, gboolean only_if_exists); gboolean cal_backend_is_loaded (CalBackend *backend); -gboolean cal_backend_is_remote (CalBackend *backend); + +CalMode cal_backend_get_mode (CalBackend *backend); +void cal_backend_set_mode (CalBackend *backend, CalMode mode); int cal_backend_get_n_objects (CalBackend *backend, CalObjType type); diff --git a/calendar/pcs/cal-factory.c b/calendar/pcs/cal-factory.c index 458279b65f..b2b718f861 100644 --- a/calendar/pcs/cal-factory.c +++ b/calendar/pcs/cal-factory.c @@ -54,7 +54,7 @@ struct _CalFactoryPrivate { typedef struct { CalFactory *factory; - GNOME_Evolution_Calendar_UriType type; + GNOME_Evolution_Calendar_CalMode mode; GNOME_Evolution_Calendar_StringSeq *list; } CalFactoryUriData; @@ -314,27 +314,27 @@ add_uri (gpointer key, gpointer value, gpointer data) CalFactoryUriData *cfud = data; CalFactory *factory = cfud->factory; GNOME_Evolution_Calendar_StringSeq *list = cfud->list; - GNOME_Evolution_Calendar_UriType type = cfud->type; + GNOME_Evolution_Calendar_CalMode mode = cfud->mode; char *uri_string = key; CalBackend *backend; GnomeVFSURI *uri; - switch (type) { - case GNOME_Evolution_Calendar_URI_LOCAL: + switch (mode) { + case GNOME_Evolution_Calendar_MODE_LOCAL: uri = gnome_vfs_uri_new_private (uri_string, TRUE, TRUE, TRUE); backend = lookup_backend (factory, uri); gnome_vfs_uri_unref (uri); - if (backend == NULL && cal_backend_is_remote (backend)) + if (backend == NULL && cal_backend_get_mode (backend) == CAL_MODE_LOCAL) return; break; - case GNOME_Evolution_Calendar_URI_REMOTE: + case GNOME_Evolution_Calendar_MODE_REMOTE: uri = gnome_vfs_uri_new_private (uri_string, TRUE, TRUE, TRUE); backend = lookup_backend (factory, uri); gnome_vfs_uri_unref (uri); - if (backend == NULL && !cal_backend_is_remote (backend)) + if (backend == NULL && cal_backend_get_mode (backend) == CAL_MODE_REMOTE) return; break; - case GNOME_Evolution_Calendar_URI_ANY: + case GNOME_Evolution_Calendar_MODE_ANY: break; } @@ -470,7 +470,7 @@ impl_CalFactory_open (PortableServer_Servant servant, static GNOME_Evolution_Calendar_StringSeq * impl_CalFactory_uriList (PortableServer_Servant servant, - GNOME_Evolution_Calendar_UriType type, + GNOME_Evolution_Calendar_CalMode mode, CORBA_Environment *ev) { CalFactory *factory; @@ -487,7 +487,7 @@ impl_CalFactory_uriList (PortableServer_Servant servant, list->_buffer = CORBA_sequence_CORBA_string_allocbuf (list->_maximum); cfud.factory = factory; - cfud.type = type; + cfud.mode = mode; cfud.list = list; g_hash_table_foreach (priv->backends, add_uri, &cfud); diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 481019bcb8..7a21aed95e 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -78,6 +78,20 @@ uncorba_obj_type (GNOME_Evolution_Calendar_CalObjType type) | ((type & GNOME_Evolution_Calendar_TYPE_JOURNAL) ? CALOBJ_TYPE_JOURNAL : 0)); } +static void +impl_Cal_set_mode (PortableServer_Servant servant, + GNOME_Evolution_Calendar_CalMode mode, + CORBA_Environment *ev) +{ + Cal *cal; + CalPrivate *priv; + + cal = CAL (bonobo_object_from_servant (servant)); + priv = cal->priv; + + cal_backend_set_mode (priv->backend, mode); +} + /* Cal::get_n_objects method */ static CORBA_long impl_Cal_get_n_objects (PortableServer_Servant servant, @@ -590,6 +604,7 @@ cal_class_init (CalClass *klass) /* Epv methods */ epv->_get_uri = impl_Cal_get_uri; + epv->setMode = impl_Cal_set_mode; epv->countObjects = impl_Cal_get_n_objects; epv->getObject = impl_Cal_get_object; epv->getTimezoneObject = impl_Cal_get_timezone_object; @@ -620,6 +635,38 @@ cal_init (Cal *cal) BONOBO_X_TYPE_FUNC_FULL (Cal, GNOME_Evolution_Calendar_Cal, PARENT_TYPE, cal); /** + * cal_notify_mode: + * @cal: A calendar client interface. + * @status: Status of the mode set. + * @mode: The current mode. + * + * Notifys the listener of the results of a setMode call. + **/ +void +cal_notify_mode (Cal *cal, + GNOME_Evolution_Calendar_Listener_SetModeStatus status, + GNOME_Evolution_Calendar_CalMode mode) +{ + CalPrivate *priv; + CORBA_Environment ev; + + g_return_if_fail (cal != NULL); + g_return_if_fail (IS_CAL (cal)); + + priv = cal->priv; + g_return_if_fail (priv->listener != CORBA_OBJECT_NIL); + + CORBA_exception_init (&ev); + GNOME_Evolution_Calendar_Listener_notifyCalSetMode (priv->listener, status, mode, &ev); + + if (BONOBO_EX (&ev)) + g_message ("cal_notify_mode(): could not notify the listener " + "about a mode change"); + + CORBA_exception_free (&ev); +} + +/** * cal_notify_update: * @cal: A calendar client interface. * @uid: UID of object that was updated. diff --git a/calendar/pcs/cal.h b/calendar/pcs/cal.h index fa11ba29e8..d9302309b9 100644 --- a/calendar/pcs/cal.h +++ b/calendar/pcs/cal.h @@ -62,6 +62,9 @@ Cal *cal_construct (Cal *cal, Cal *cal_new (CalBackend *backend, GNOME_Evolution_Calendar_Listener listener); +void cal_notify_mode (Cal *cal, + GNOME_Evolution_Calendar_Listener_SetModeStatus status, + GNOME_Evolution_Calendar_CalMode mode); void cal_notify_update (Cal *cal, const char *uid); void cal_notify_remove (Cal *cal, const char *uid); |