From 48140af35f90d7ec4f994821a5265b1fe0159cfa Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Thu, 16 May 2002 16:41:35 +0000 Subject: added PermissionDenied exception and make it be raised in open, 2002-05-16 Rodrigo Moya * idl/evolution-calendar.idl: added PermissionDenied exception and make it be raised in open, updateObjects and removeObject. * pcs/cal-backend.h: added CAL_BACKEND_OPEN_PERMISSION_DENIED to CalBackendOpenStatus enumeration, added CalBackendResult enumeration. * pcs/cal.c: * pcs/cal-backend.c: * pcs/cal-backend-file.c: adapted to changes in update_objects and remove_object methods. * cal-client/cal-client.[ch]: added CalClientResult enumeration. (cal_client_update_object, cal_client_update_objects, cal_client_remove_object): changed to return a CalClientResult. * conduits/calendar/calendar-conduit.c: * calendar/conduits/todo/todo-conduit.c: * importers/icalendar-importer.c: * gui/dialogs/comp-editor.c: * gui/calendar-model.c: * gui/e-calendar-table.c: * gui/e-day-view.c: * gui/e-itip-control.c: * gui/e-week-view.c: * gui/comp-util.c: * gui/e-tasks.c: * gui/tasks-migrate.c: adapted to changes in cal_client_update_object(s) and cal_client_remove_object. svn path=/trunk/; revision=16932 --- calendar/pcs/cal-backend-file.c | 29 +++++++++++++++-------------- calendar/pcs/cal-backend.c | 12 ++++++------ calendar/pcs/cal-backend.h | 19 ++++++++++++++----- calendar/pcs/cal.c | 28 ++++++++++++++++++++++++++-- 4 files changed, 61 insertions(+), 27 deletions(-) (limited to 'calendar/pcs') diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index 5ca5a06f0e..cccac9a633 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -120,8 +120,9 @@ static GNOME_Evolution_Calendar_CalComponentAlarms *cal_backend_file_get_alarms_ CalBackend *backend, const char *uid, time_t start, time_t end, gboolean *object_found); -static gboolean cal_backend_file_update_objects (CalBackend *backend, const char *calobj); -static gboolean cal_backend_file_remove_object (CalBackend *backend, const char *uid); +static CalBackendResult cal_backend_file_update_objects (CalBackend *backend, + const char *calobj); +static CalBackendResult cal_backend_file_remove_object (CalBackend *backend, const char *uid); static icaltimezone* cal_backend_file_get_timezone (CalBackend *backend, const char *tzid); static icaltimezone* cal_backend_file_get_default_timezone (CalBackend *backend); @@ -1743,7 +1744,7 @@ cal_backend_file_update_object (CalBackendFile *cbfile, /* Update_objects handler for the file backend. */ -static gboolean +static CalBackendResult cal_backend_file_update_objects (CalBackend *backend, const char *calobj) { CalBackendFile *cbfile; @@ -1752,22 +1753,22 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) icalcomponent_kind kind; int old_n_categories, new_n_categories; icalcomponent *subcomp; - gboolean retval = TRUE; + CalBackendResult retval = CAL_BACKEND_RESULT_SUCCESS; GList *comp_uid_list = NULL, *elem; cbfile = CAL_BACKEND_FILE (backend); priv = cbfile->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); + g_return_val_if_fail (priv->icalcomp != NULL, CAL_BACKEND_RESULT_INVALID_OBJECT); - g_return_val_if_fail (calobj != NULL, FALSE); + g_return_val_if_fail (calobj != NULL, CAL_BACKEND_RESULT_INVALID_OBJECT); /* Pull the component from the string and ensure that it is sane */ toplevel_comp = icalparser_parse_string ((char *) calobj); if (!toplevel_comp) - return FALSE; + return CAL_BACKEND_RESULT_INVALID_OBJECT; kind = icalcomponent_isa (toplevel_comp); @@ -1782,7 +1783,7 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) } else if (kind != ICAL_VCALENDAR_COMPONENT) { /* We don't support this type of component */ icalcomponent_free (toplevel_comp); - return FALSE; + return CAL_BACKEND_RESULT_INVALID_OBJECT; } /* The list of removed categories must be empty because we are about to @@ -1816,7 +1817,7 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) comp_uid_list = g_list_prepend (comp_uid_list, g_strdup (comp_uid)); } else { - retval = FALSE; + retval = CAL_BACKEND_RESULT_INVALID_OBJECT; } } subcomp = icalcomponent_get_next_component (toplevel_comp, @@ -1852,7 +1853,7 @@ cal_backend_file_update_objects (CalBackend *backend, const char *calobj) /* Remove_object handler for the file backend */ -static gboolean +static CalBackendResult cal_backend_file_remove_object (CalBackend *backend, const char *uid) { CalBackendFile *cbfile; @@ -1862,13 +1863,13 @@ cal_backend_file_remove_object (CalBackend *backend, const char *uid) cbfile = CAL_BACKEND_FILE (backend); priv = cbfile->priv; - g_return_val_if_fail (priv->icalcomp != NULL, FALSE); + g_return_val_if_fail (priv->icalcomp != NULL, CAL_BACKEND_RESULT_INVALID_OBJECT); - g_return_val_if_fail (uid != NULL, FALSE); + g_return_val_if_fail (uid != NULL, CAL_BACKEND_RESULT_NOT_FOUND); comp = lookup_component (cbfile, uid); if (!comp) - return FALSE; + return CAL_BACKEND_RESULT_NOT_FOUND; /* The list of removed categories must be empty because we are about to * start a new scanning process. @@ -1886,7 +1887,7 @@ cal_backend_file_remove_object (CalBackend *backend, const char *uid) notify_categories_changed (cbfile); } - return TRUE; + return CAL_BACKEND_RESULT_SUCCESS; } diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index 95dc9957e6..50aeb148e2 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -673,10 +673,10 @@ cal_backend_get_alarms_for_object (CalBackend *backend, const char *uid, * object that has the same UID as the specified one. The backend will in * turn notify all of its clients about the change. * - * Return value: TRUE on success, FALSE on being passed an invalid object or one - * with an unsupported type. + * Return value: a #CalBackendResult value, which indicates the + * result of the operation. **/ -gboolean +CalBackendResult cal_backend_update_objects (CalBackend *backend, const char *calobj) { g_return_val_if_fail (backend != NULL, FALSE); @@ -695,10 +695,10 @@ cal_backend_update_objects (CalBackend *backend, const char *calobj) * Removes an object in a calendar backend. The backend will notify all of its * clients about the change. * - * Return value: TRUE on success, FALSE on being passed an UID for an object - * that does not exist in the backend. + * Return value: a #CalBackendResult value, which indicates the + * result of the operation. **/ -gboolean +CalBackendResult cal_backend_remove_object (CalBackend *backend, const char *uid) { g_return_val_if_fail (backend != NULL, FALSE); diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h index 4fd0a42bd0..26b3456e9e 100644 --- a/calendar/pcs/cal-backend.h +++ b/calendar/pcs/cal-backend.h @@ -47,9 +47,18 @@ BEGIN_GNOME_DECLS typedef enum { CAL_BACKEND_OPEN_SUCCESS, /* Loading OK */ CAL_BACKEND_OPEN_ERROR, /* We need better error reporting in libversit */ - CAL_BACKEND_OPEN_NOT_FOUND + CAL_BACKEND_OPEN_NOT_FOUND, + CAL_BACKEND_OPEN_PERMISSION_DENIED } CalBackendOpenStatus; +/* Update and Remove result values */ +typedef enum { + CAL_BACKEND_RESULT_SUCCESS, + CAL_BACKEND_RESULT_INVALID_OBJECT, + CAL_BACKEND_RESULT_NOT_FOUND, + CAL_BACKEND_RESULT_PERMISSION_DENIED +} CalBackendResult; + /* Result codes for ::get_alarms_in_range() */ typedef enum { CAL_BACKEND_GET_ALARMS_SUCCESS, @@ -112,8 +121,8 @@ struct _CalBackendClass { time_t start, time_t end, gboolean *object_found); /* Object manipulation virtual methods */ - gboolean (* update_objects) (CalBackend *backend, const char *calobj); - gboolean (* remove_object) (CalBackend *backend, const char *uid); + CalBackendResult (* update_objects) (CalBackend *backend, const char *calobj); + CalBackendResult (* remove_object) (CalBackend *backend, const char *uid); /* Timezone related virtual methods */ icaltimezone *(* get_timezone) (CalBackend *backend, const char *tzid); @@ -170,9 +179,9 @@ GNOME_Evolution_Calendar_CalComponentAlarms *cal_backend_get_alarms_for_object ( CalBackendGetAlarmsForObjectResult *result); -gboolean cal_backend_update_objects (CalBackend *backend, const char *calobj); +CalBackendResult cal_backend_update_objects (CalBackend *backend, const char *calobj); -gboolean cal_backend_remove_object (CalBackend *backend, const char *uid); +CalBackendResult cal_backend_remove_object (CalBackend *backend, const char *uid); icaltimezone* cal_backend_get_timezone (CalBackend *backend, const char *tzid); icaltimezone* cal_backend_get_default_timezone (CalBackend *backend); diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index 5225b5680e..2d2f953a86 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -393,12 +393,24 @@ impl_Cal_update_objects (PortableServer_Servant servant, { Cal *cal; CalPrivate *priv; + CalBackendResult result; cal = CAL (bonobo_object_from_servant (servant)); priv = cal->priv; - if (!cal_backend_update_objects (priv->backend, calobj)) + result = cal_backend_update_objects (priv->backend, calobj); + switch (result) { + case CAL_BACKEND_RESULT_INVALID_OBJECT : bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject); + break; + case CAL_BACKEND_RESULT_NOT_FOUND : + bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_NotFound); + break; + case CAL_BACKEND_RESULT_PERMISSION_DENIED : + bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied); + break; + default : + } } /* Cal::remove_object method */ @@ -409,12 +421,24 @@ impl_Cal_remove_object (PortableServer_Servant servant, { Cal *cal; CalPrivate *priv; + CalBackendResult result; cal = CAL (bonobo_object_from_servant (servant)); priv = cal->priv; - if (!cal_backend_remove_object (priv->backend, uid)) + result = cal_backend_remove_object (priv->backend, uid); + switch (result) { + case CAL_BACKEND_RESULT_INVALID_OBJECT : + bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject); + break; + case CAL_BACKEND_RESULT_NOT_FOUND : bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_NotFound); + break; + case CAL_BACKEND_RESULT_PERMISSION_DENIED : + bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied); + break; + default : + } } /* Cal::getQuery implementation */ -- cgit