aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@ximian.com>2002-05-17 00:41:35 +0800
committerRodrigo Moya <rodrigo@src.gnome.org>2002-05-17 00:41:35 +0800
commit48140af35f90d7ec4f994821a5265b1fe0159cfa (patch)
treedd2bde3e78c4fd5db7a97dbb754b59edf66bbb4e /calendar
parentaad3ac6ddd62d5cd1b3421f5bf45ccdcf1b0ed35 (diff)
downloadgsoc2013-evolution-48140af35f90d7ec4f994821a5265b1fe0159cfa.tar.gz
gsoc2013-evolution-48140af35f90d7ec4f994821a5265b1fe0159cfa.tar.zst
gsoc2013-evolution-48140af35f90d7ec4f994821a5265b1fe0159cfa.zip
added PermissionDenied exception and make it be raised in open,
2002-05-16 Rodrigo Moya <rodrigo@ximian.com> * 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
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog31
-rw-r--r--calendar/cal-client/cal-client.c99
-rw-r--r--calendar/cal-client/cal-client.h15
-rw-r--r--calendar/conduits/calendar/calendar-conduit.c4
-rw-r--r--calendar/conduits/todo/todo-conduit.c4
-rw-r--r--calendar/gui/calendar-model.c6
-rw-r--r--calendar/gui/dialogs/comp-editor.c23
-rw-r--r--calendar/gui/e-day-view.c18
-rw-r--r--calendar/gui/e-itip-control.c49
-rw-r--r--calendar/gui/e-week-view.c8
-rw-r--r--calendar/gui/tasks-migrate.c2
-rw-r--r--calendar/idl/evolution-calendar.idl8
-rw-r--r--calendar/importers/icalendar-importer.c10
-rw-r--r--calendar/pcs/cal-backend-file.c29
-rw-r--r--calendar/pcs/cal-backend.c12
-rw-r--r--calendar/pcs/cal-backend.h19
-rw-r--r--calendar/pcs/cal.c28
17 files changed, 249 insertions, 116 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index edb0a2087a..a575a07eef 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,34 @@
+2002-05-16 Rodrigo Moya <rodrigo@ximian.com>
+
+ * 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.
+
2002-05-15 Ettore Perazzoli <ettore@ximian.com>
* gui/component-factory.c (create_object): Pass NULL as
diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c
index 30402bf126..612da541f5 100644
--- a/calendar/cal-client/cal-client.c
+++ b/calendar/cal-client/cal-client.c
@@ -2240,7 +2240,6 @@ cal_client_get_component_as_string (CalClient *client,
TRUE);
}
-
/**
* cal_client_update_object:
* @client: A calendar client.
@@ -2251,47 +2250,49 @@ cal_client_get_component_as_string (CalClient *client,
* assume that the object is actually in the server's storage until it has
* received the "obj_updated" notification signal.
*
- * Return value: TRUE on success, FALSE on specifying an invalid component.
+ * Return value: a #CalClientResult value indicating the result of the
+ * operation.
**/
-gboolean
+CalClientResult
cal_client_update_object (CalClient *client, CalComponent *comp)
{
CalClientPrivate *priv;
CORBA_Environment ev;
- gboolean retval;
+ CalClientResult retval;
char *obj_string;
- 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, CAL_CLIENT_RESULT_INVALID_OBJECT);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_INVALID_OBJECT);
priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, FALSE);
+ g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_RESULT_INVALID_OBJECT);
- g_return_val_if_fail (comp != NULL, FALSE);
-
- retval = FALSE;
+ g_return_val_if_fail (comp != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
cal_component_commit_sequence (comp);
obj_string = cal_client_get_component_as_string_internal (client,
comp, FALSE);
if (obj_string == NULL)
- return FALSE;
+ return CAL_CLIENT_RESULT_INVALID_OBJECT;
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Cal_updateObjects (priv->cal, obj_string, &ev);
g_free (obj_string);
if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject))
- goto out;
+ retval = CAL_CLIENT_RESULT_INVALID_OBJECT;
+ else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
+ retval = CAL_CLIENT_RESULT_NOT_FOUND;
+ else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied))
+ retval = CAL_CLIENT_RESULT_PERMISSION_DENIED;
else if (BONOBO_EX (&ev)) {
g_message ("cal_client_update_object(): could not update the object");
- goto out;
+ retval = CAL_CLIENT_RESULT_CORBA_ERROR;
}
+ else
+ retval = CAL_CLIENT_RESULT_SUCCESS;
- retval = TRUE;
-
- out:
CORBA_exception_free (&ev);
return retval;
}
@@ -2311,26 +2312,25 @@ cal_client_update_object (CalClient *client, CalComponent *comp)
* server's storage until it has received the "obj_updated" notification
* signal.
*
- * Return value: TRUE on success, FALSE on specifying an invalid component.
+ * Return value: a #CalClientResult value indicating the result of the
+ * operation.
**/
-gboolean
+CalClientResult
cal_client_update_objects (CalClient *client, icalcomponent *icalcomp)
{
CalClientPrivate *priv;
CORBA_Environment ev;
- gboolean retval;
+ CalClientResult retval;
char *obj_string;
- 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, CAL_CLIENT_RESULT_INVALID_OBJECT);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_INVALID_OBJECT);
priv = client->priv;
g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED,
- FALSE);
+ CAL_CLIENT_RESULT_INVALID_OBJECT);
- g_return_val_if_fail (icalcomp != NULL, FALSE);
-
- retval = FALSE;
+ g_return_val_if_fail (icalcomp != NULL, CAL_CLIENT_RESULT_INVALID_OBJECT);
/* Libical owns this memory, using one of its temporary buffers. */
obj_string = icalcomponent_as_ical_string (icalcomp);
@@ -2339,18 +2339,20 @@ cal_client_update_objects (CalClient *client, icalcomponent *icalcomp)
GNOME_Evolution_Calendar_Cal_updateObjects (priv->cal, obj_string, &ev);
if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject))
- goto out;
+ retval = CAL_CLIENT_RESULT_INVALID_OBJECT;
+ else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
+ retval = CAL_CLIENT_RESULT_NOT_FOUND;
+ else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied))
+ retval = CAL_CLIENT_RESULT_PERMISSION_DENIED;
else if (BONOBO_EX (&ev)) {
g_message ("cal_client_update_objects(): could not update the objects");
- goto out;
+ retval = CAL_CLIENT_RESULT_CORBA_ERROR;
}
+ else
+ retval = CAL_CLIENT_RESULT_SUCCESS;
- retval = TRUE;
-
- out:
CORBA_exception_free (&ev);
return retval;
-
}
@@ -2363,41 +2365,40 @@ cal_client_update_objects (CalClient *client, icalcomponent *icalcomp)
* component, all clients will be notified and they will emit the "obj_removed"
* signal.
*
- * Return value: TRUE on success, FALSE on specifying a UID for a component that
- * is not in the server. Returning FALSE is normal; the object may have
- * disappeared from the server before the client has had a chance to receive the
- * corresponding notification.
+ * Return value: a #CalClientResult value indicating the result of the
+ * operation.
**/
-gboolean
+CalClientResult
cal_client_remove_object (CalClient *client, const char *uid)
{
CalClientPrivate *priv;
CORBA_Environment ev;
- gboolean retval;
+ CalClientResult retval;
- 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, CAL_CLIENT_RESULT_INVALID_OBJECT);
+ g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_INVALID_OBJECT);
priv = client->priv;
- g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, FALSE);
+ g_return_val_if_fail (priv->load_state == CAL_CLIENT_LOAD_LOADED, CAL_CLIENT_RESULT_INVALID_OBJECT);
- g_return_val_if_fail (uid != NULL, FALSE);
-
- retval = FALSE;
+ g_return_val_if_fail (uid != NULL, CAL_CLIENT_RESULT_NOT_FOUND);
CORBA_exception_init (&ev);
GNOME_Evolution_Calendar_Cal_removeObject (priv->cal, (char *) uid, &ev);
- if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
- goto out;
+ if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_InvalidObject))
+ retval = CAL_CLIENT_RESULT_INVALID_OBJECT;
+ else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
+ retval = CAL_CLIENT_RESULT_NOT_FOUND;
+ else if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_PermissionDenied))
+ retval = CAL_CLIENT_RESULT_PERMISSION_DENIED;
else if (BONOBO_EX (&ev)) {
g_message ("cal_client_remove_object(): could not remove the object");
- goto out;
+ retval = CAL_CLIENT_RESULT_CORBA_ERROR;
}
+ else
+ retval = CAL_CLIENT_RESULT_SUCCESS;
- retval = TRUE;
-
- out:
CORBA_exception_free (&ev);
return retval;
}
diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h
index a362059f3a..4a977e5a56 100644
--- a/calendar/cal-client/cal-client.h
+++ b/calendar/cal-client/cal-client.h
@@ -64,6 +64,15 @@ typedef enum {
CAL_CLIENT_GET_SYNTAX_ERROR
} CalClientGetStatus;
+/* Status for update_object(s) and remove_object */
+typedef enum {
+ CAL_CLIENT_RESULT_SUCCESS,
+ CAL_CLIENT_RESULT_CORBA_ERROR,
+ CAL_CLIENT_RESULT_INVALID_OBJECT,
+ CAL_CLIENT_RESULT_NOT_FOUND,
+ CAL_CLIENT_RESULT_PERMISSION_DENIED
+} CalClientResult;
+
/* Whether the client is not loaded, is being loaded, or is already loaded */
typedef enum {
CAL_CLIENT_LOAD_NOT_LOADED,
@@ -158,12 +167,12 @@ gboolean cal_client_get_alarms_for_object (CalClient *client, const char *uid,
/* Add or update a single object. When adding an object only builtin timezones
are allowed. To use external VTIMEZONE data call update_objects() instead.*/
-gboolean cal_client_update_object (CalClient *client, CalComponent *comp);
+CalClientResult cal_client_update_object (CalClient *client, CalComponent *comp);
/* Add or update multiple objects, possibly including VTIMEZONE data. */
-gboolean cal_client_update_objects (CalClient *client, icalcomponent *icalcomp);
+CalClientResult cal_client_update_objects (CalClient *client, icalcomponent *icalcomp);
-gboolean cal_client_remove_object (CalClient *client, const char *uid);
+CalClientResult cal_client_remove_object (CalClient *client, const char *uid);
CalQuery *cal_client_get_query (CalClient *client, const char *sexp);
diff --git a/calendar/conduits/calendar/calendar-conduit.c b/calendar/conduits/calendar/calendar-conduit.c
index f86e753232..6dfe288f34 100644
--- a/calendar/conduits/calendar/calendar-conduit.c
+++ b/calendar/conduits/calendar/calendar-conduit.c
@@ -1139,14 +1139,14 @@ static void
update_comp (GnomePilotConduitSyncAbs *conduit, CalComponent *comp,
ECalConduitContext *ctxt)
{
- gboolean success;
+ CalClientResult success;
g_return_if_fail (conduit != NULL);
g_return_if_fail (comp != NULL);
success = cal_client_update_object (ctxt->client, comp);
- if (!success)
+ if (success != CAL_CLIENT_RESULT_SUCCESS)
WARN (_("Error while communicating with calendar server"));
}
diff --git a/calendar/conduits/todo/todo-conduit.c b/calendar/conduits/todo/todo-conduit.c
index a460bd6ebc..42c8b3c865 100644
--- a/calendar/conduits/todo/todo-conduit.c
+++ b/calendar/conduits/todo/todo-conduit.c
@@ -824,14 +824,14 @@ static void
update_comp (GnomePilotConduitSyncAbs *conduit, CalComponent *comp,
EToDoConduitContext *ctxt)
{
- gboolean success;
+ CalClientResult success;
g_return_if_fail (conduit != NULL);
g_return_if_fail (comp != NULL);
success = cal_client_update_object (ctxt->client, comp);
- if (!success)
+ if (success != CAL_CLIENT_RESULT_SUCCESS)
WARN (_("Error while communicating with calendar server"));
}
diff --git a/calendar/gui/calendar-model.c b/calendar/gui/calendar-model.c
index e8317402ac..927b986212 100644
--- a/calendar/gui/calendar-model.c
+++ b/calendar/gui/calendar-model.c
@@ -1320,7 +1320,7 @@ calendar_model_set_value_at (ETableModel *etm, int col, int row, const void *val
return;
}
- if (!cal_client_update_object (priv->client, comp))
+ if (cal_client_update_object (priv->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
g_message ("calendar_model_set_value_at(): Could not update the object!");
}
@@ -1399,7 +1399,7 @@ calendar_model_append_row (ETableModel *etm, ETableModel *source, gint row)
set_complete (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_COMPLETE, row));
set_status (comp, e_table_model_value_at(source, CAL_COMPONENT_FIELD_STATUS, row));
- if (!cal_client_update_object (priv->client, comp)) {
+ if (cal_client_update_object (priv->client, comp) != CAL_CLIENT_RESULT_SUCCESS) {
/* FIXME: Show error dialog. */
g_message ("calendar_model_append_row(): Could not add new object!");
}
@@ -2270,7 +2270,7 @@ calendar_model_mark_task_complete (CalendarModel *model,
ensure_task_complete (comp, -1);
- if (!cal_client_update_object (priv->client, comp))
+ if (cal_client_update_object (priv->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
g_message ("calendar_model_mark_task_complete(): Could not update the object!");
}
diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c
index cad55ebf08..05710b7581 100644
--- a/calendar/gui/dialogs/comp-editor.c
+++ b/calendar/gui/dialogs/comp-editor.c
@@ -297,6 +297,7 @@ save_comp (CompEditor *editor)
CompEditorPrivate *priv;
CalComponent *clone;
GList *l;
+ CalClientResult result;
priv = editor->priv;
@@ -316,11 +317,29 @@ save_comp (CompEditor *editor)
priv->updating = TRUE;
- if (!cal_client_update_object (priv->client, priv->comp)) {
+ result = cal_client_update_object (priv->client, priv->comp);
+ if (result != CAL_CLIENT_RESULT_SUCCESS) {
GtkWidget *dlg;
+ char *msg;
+
+ switch (result) {
+ case CAL_CLIENT_RESULT_INVALID_OBJECT :
+ msg = g_strdup (_("Could not update invalid object"));
+ break;
+ case CAL_CLIENT_RESULT_NOT_FOUND :
+ msg = g_strdup (_("Object not found, not updated"));
+ break;
+ case CAL_CLIENT_RESULT_PERMISSION_DENIED :
+ msg = g_strdup (_("You don't have permissions to update this object"));
+ break;
+ default :
+ msg = g_strdup (_("Could not update object"));
+ break;
+ }
- dlg = gnome_error_dialog (_("Could not update object!"));
+ dlg = gnome_error_dialog (msg);
gnome_dialog_run_and_close (GNOME_DIALOG (dlg));
+ g_free (msg);
return FALSE;
} else {
diff --git a/calendar/gui/e-day-view.c b/calendar/gui/e-day-view.c
index 2a346cdbf9..d305190352 100644
--- a/calendar/gui/e-day-view.c
+++ b/calendar/gui/e-day-view.c
@@ -3996,7 +3996,7 @@ e_day_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
comp = cal_component_clone (event->comp);
cal_comp_util_add_exdate (comp, event->start, day_view->zone);
- if (!cal_client_update_object (day_view->client, comp))
+ if (cal_client_update_object (day_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_day_view_on_delete_occurrence(): Could not update the object!");
gtk_object_unref (GTK_OBJECT (comp));
@@ -4172,12 +4172,12 @@ e_day_view_on_unrecur_appointment (GtkWidget *widget, gpointer data)
/* Now update both CalComponents. Note that we do this last since at
* present the updates happen synchronously so our event may disappear.
*/
- if (!cal_client_update_object (day_view->client, comp))
+ if (cal_client_update_object (day_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
gtk_object_unref (GTK_OBJECT (comp));
- if (!cal_client_update_object (day_view->client, new_comp))
+ if (cal_client_update_object (day_view->client, new_comp) != CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_day_view_on_unrecur_appointment(): Could not update the object!");
gtk_object_unref (GTK_OBJECT (new_comp));
@@ -4712,7 +4712,7 @@ e_day_view_finish_long_event_resize (EDayView *day_view)
day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE;
- if (cal_client_update_object (day_view->client, comp)) {
+ if (cal_client_update_object (day_view->client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (cal_component_has_attendees (comp) && send_component_dialog (comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, day_view->client, NULL);
} else {
@@ -4773,7 +4773,7 @@ e_day_view_finish_resize (EDayView *day_view)
day_view->resize_drag_pos = E_DAY_VIEW_POS_NONE;
- if (cal_client_update_object (day_view->client, comp)) {
+ if (cal_client_update_object (day_view->client, comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (cal_component_has_attendees (comp) && send_component_dialog (comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp, day_view->client, NULL);
} else {
@@ -6116,7 +6116,7 @@ e_day_view_on_editing_stopped (EDayView *day_view,
summary.altrep = NULL;
cal_component_set_summary (event->comp, &summary);
- if (cal_client_update_object (day_view->client, event->comp)) {
+ if (cal_client_update_object (day_view->client, event->comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (cal_component_has_attendees (event->comp) && send_component_dialog (event->comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp,
day_view->client, NULL);
@@ -7165,7 +7165,8 @@ e_day_view_on_top_canvas_drag_data_received (GtkWidget *widget,
if (event->canvas_item)
gnome_canvas_item_show (event->canvas_item);
- if (cal_client_update_object (day_view->client, comp)) {
+ if (cal_client_update_object (day_view->client, comp)
+ == CAL_CLIENT_RESULT_SUCCESS) {
if (cal_component_has_attendees (comp) && send_component_dialog (comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
day_view->client, NULL);
@@ -7278,7 +7279,8 @@ e_day_view_on_main_canvas_drag_data_received (GtkWidget *widget,
if (event->canvas_item)
gnome_canvas_item_show (event->canvas_item);
- if (cal_client_update_object (day_view->client, comp)) {
+ if (cal_client_update_object (day_view->client, comp)
+ == CAL_CLIENT_RESULT_SUCCESS) {
if (cal_component_has_attendees (comp) && send_component_dialog (comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, comp,
day_view->client, NULL);
diff --git a/calendar/gui/e-itip-control.c b/calendar/gui/e-itip-control.c
index f8cfe2fea3..75be4d098d 100644
--- a/calendar/gui/e-itip-control.c
+++ b/calendar/gui/e-itip-control.c
@@ -1548,6 +1548,7 @@ update_item (EItipControl *itip)
CalClient *client;
CalComponentVType type;
GtkWidget *dialog;
+ CalClientResult result;
priv = itip->priv;
@@ -1560,10 +1561,27 @@ update_item (EItipControl *itip)
clone = icalcomponent_new_clone (priv->ical_comp);
icalcomponent_add_component (priv->top_level, clone);
- if (!cal_client_update_objects (client, priv->top_level))
- dialog = gnome_warning_dialog (_("Calendar file could not be updated!\n"));
- else
+ result = cal_client_update_objects (client, priv->top_level);
+ switch (result) {
+ case CAL_CLIENT_RESULT_INVALID_OBJECT :
+ dialog = gnome_warning_dialog (_("Object is invalid and cannot be updated\n"));
+ break;
+ case CAL_CLIENT_RESULT_CORBA_ERROR :
+ dialog = gnome_warning_dialog (_("There was an error on the CORBA system\n"));
+ break;
+ case CAL_CLIENT_RESULT_NOT_FOUND :
+ dialog = gnome_warning_dialog (_("Object could not be found\n"));
+ break;
+ case CAL_CLIENT_RESULT_PERMISSION_DENIED :
+ dialog = gnome_warning_dialog (_("You don't have permissions to update the calendar\n"));
+ break;
+ case CAL_CLIENT_RESULT_SUCCESS :
dialog = gnome_ok_dialog (_("Update complete\n"));
+ break;
+ default :
+ dialog = gnome_warning_dialog (_("Calendar file could not be updated!\n"));
+ break;
+ }
gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
icalcomponent_remove_component (priv->top_level, clone);
@@ -1579,6 +1597,7 @@ update_attendee_status (EItipControl *itip)
CalComponentVType type;
const char *uid;
GtkWidget *dialog;
+ CalClientResult result;
priv = itip->priv;
@@ -1634,10 +1653,26 @@ update_attendee_status (EItipControl *itip)
}
}
- if (!cal_client_update_object (client, comp))
- dialog = gnome_warning_dialog (_("Attendee status could not be updated!\n"));
- else
+ result = cal_client_update_object (client, comp);
+ switch (result) {
+ case CAL_CLIENT_RESULT_INVALID_OBJECT :
+ dialog = gnome_warning_dialog (_("Object is invalid and cannot be updated\n"));
+ break;
+ case CAL_CLIENT_RESULT_CORBA_ERROR :
+ dialog = gnome_warning_dialog (_("There was an error on the CORBA system\n"));
+ break;
+ case CAL_CLIENT_RESULT_NOT_FOUND :
+ dialog = gnome_warning_dialog (_("Object could not be found\n"));
+ break;
+ case CAL_CLIENT_RESULT_PERMISSION_DENIED :
+ dialog = gnome_warning_dialog (_("You don't have permissions to update the calendar\n"));
+ break;
+ case CAL_CLIENT_RESULT_SUCCESS :
dialog = gnome_ok_dialog (_("Attendee status updated\n"));
+ break;
+ default :
+ dialog = gnome_warning_dialog (_("Attendee status could not be updated!\n"));
+ }
} else {
dialog = gnome_warning_dialog (_("Attendee status can not be updated "
"because the item no longer exists"));
@@ -1670,7 +1705,7 @@ remove_item (EItipControl *itip)
return;
cal_component_get_uid (priv->comp, &uid);
- if (cal_client_remove_object (client, uid)) {
+ if (cal_client_remove_object (client, uid) == CAL_CLIENT_RESULT_SUCCESS) {
dialog = gnome_ok_dialog (_("Removal Complete"));
gnome_dialog_run_and_close (GNOME_DIALOG (dialog));
}
diff --git a/calendar/gui/e-week-view.c b/calendar/gui/e-week-view.c
index f0913e3e28..514558cc58 100644
--- a/calendar/gui/e-week-view.c
+++ b/calendar/gui/e-week-view.c
@@ -3216,7 +3216,7 @@ e_week_view_on_editing_stopped (EWeekView *week_view,
summary.altrep = NULL;
cal_component_set_summary (event->comp, &summary);
- if (cal_client_update_object (week_view->client, event->comp)) {
+ if (cal_client_update_object (week_view->client, event->comp) == CAL_CLIENT_RESULT_SUCCESS) {
if (cal_component_has_attendees (event->comp) && send_component_dialog (event->comp, FALSE))
itip_send_comp (CAL_COMPONENT_METHOD_REQUEST, event->comp,
week_view->client, NULL);
@@ -3870,7 +3870,7 @@ e_week_view_on_delete_occurrence (GtkWidget *widget, gpointer data)
comp = cal_component_clone (event->comp);
cal_comp_util_add_exdate (comp, event->start, week_view->zone);
- if (!cal_client_update_object (week_view->client, comp))
+ if (cal_client_update_object (week_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_week_view_on_delete_occurrence(): Could not update the object!");
gtk_object_unref (GTK_OBJECT (comp));
@@ -4030,12 +4030,12 @@ e_week_view_on_unrecur_appointment (GtkWidget *widget, gpointer data)
/* Now update both CalComponents. Note that we do this last since at
present the updates happen synchronously so our event may disappear.
*/
- if (!cal_client_update_object (week_view->client, comp))
+ if (cal_client_update_object (week_view->client, comp) != CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!");
gtk_object_unref (GTK_OBJECT (comp));
- if (!cal_client_update_object (week_view->client, new_comp))
+ if (cal_client_update_object (week_view->client, new_comp) != CAL_CLIENT_RESULT_SUCCESS)
g_message ("e_week_view_on_unrecur_appointment(): Could not update the object!");
gtk_object_unref (GTK_OBJECT (new_comp));
diff --git a/calendar/gui/tasks-migrate.c b/calendar/gui/tasks-migrate.c
index 5c9a4fa7c5..c6c6309528 100644
--- a/calendar/gui/tasks-migrate.c
+++ b/calendar/gui/tasks-migrate.c
@@ -75,7 +75,7 @@ migrate (void)
switch (status) {
case CAL_CLIENT_GET_SUCCESS:
- if (cal_client_update_object (tasks_client, comp))
+ if (cal_client_update_object (tasks_client, comp) == CAL_CLIENT_RESULT_SUCCESS)
cal_client_remove_object (calendar_client, uid);
else
success = FALSE;
diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl
index 7ad011aecf..08ad056c3b 100644
--- a/calendar/idl/evolution-calendar.idl
+++ b/calendar/idl/evolution-calendar.idl
@@ -131,6 +131,7 @@ module Calendar {
exception InvalidRange {};
exception InvalidObject {};
exception CouldNotCreate {};
+ exception PermissionDenied {};
/* A calendar is identified by its URI */
readonly attribute string uri;
@@ -199,11 +200,11 @@ module Calendar {
* updated version.
*/
void updateObjects (in CalObj calobj)
- raises (InvalidObject);
+ raises (InvalidObject, PermissionDenied);
/* Removes a component */
void removeObject (in CalObjUID uid)
- raises (NotFound);
+ raises (NotFound, PermissionDenied);
/* Initiates a live query of the calendar. Returns a handle
* to the live query itself; changes to components that are
@@ -292,10 +293,11 @@ module Calendar {
exception NilListener {};
exception InvalidURI {};
exception UnsupportedMethod {};
+ exception PermissionDenied {};
/* Open a calendar from an URI */
void open (in string uri, in boolean only_if_exists, in Listener listener)
- raises (NilListener, InvalidURI, UnsupportedMethod);
+ raises (NilListener, InvalidURI, UnsupportedMethod, PermissionDenied);
/* List of open URI's */
StringSeq uriList (in CalMode mode);
diff --git a/calendar/importers/icalendar-importer.c b/calendar/importers/icalendar-importer.c
index 6a7a6f363f..bacf9b7eff 100644
--- a/calendar/importers/icalendar-importer.c
+++ b/calendar/importers/icalendar-importer.c
@@ -261,20 +261,20 @@ process_item_fn (EvolutionImporter *importer,
contains just tasks, we strip out the VEVENTs, which do not get
imported at all. */
if (ici->folder_contains_events && ici->folder_contains_tasks) {
- if (!cal_client_update_objects (ici->client, ici->icalcomp))
+ if (cal_client_update_objects (ici->client, ici->icalcomp) != CAL_CLIENT_RESULT_SUCCESS)
result = GNOME_Evolution_ImporterListener_BAD_DATA;
} else if (ici->folder_contains_events) {
GList *vtodos = prepare_events (ici->icalcomp);
- if (!cal_client_update_objects (ici->client, ici->icalcomp))
+ if (cal_client_update_objects (ici->client, ici->icalcomp) != CAL_CLIENT_RESULT_SUCCESS)
result = GNOME_Evolution_ImporterListener_BAD_DATA;
prepare_tasks (ici->icalcomp, vtodos);
- if (!cal_client_update_objects (ici->tasks_client,
- ici->icalcomp))
+ if (cal_client_update_objects (ici->tasks_client,
+ ici->icalcomp) != CAL_CLIENT_RESULT_SUCCESS)
result = GNOME_Evolution_ImporterListener_BAD_DATA;
} else {
prepare_tasks (ici->icalcomp, NULL);
- if (!cal_client_update_objects (ici->client, ici->icalcomp))
+ if (cal_client_update_objects (ici->client, ici->icalcomp) != CAL_CLIENT_RESULT_SUCCESS)
result = GNOME_Evolution_ImporterListener_BAD_DATA;
}
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 */