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 /calendar/pcs | |
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
Diffstat (limited to 'calendar/pcs')
-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 |
6 files changed, 131 insertions, 26 deletions
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); |