[evolution-patches] patch for #41661



This adds the discardAlarm method, so that backends can do it in the way
they prefer.
? gui/alarm-notify/alarm-notify.gladep
? gui/dialogs/alarm-options.gladep
? gui/dialogs/alarm-page.gladep
? gui/dialogs/cal-prefs-dialog.gladep
? gui/dialogs/e-delegate-dialog.gladep
? gui/dialogs/event-page.gladep
? gui/dialogs/meeting-page.gladep
? gui/dialogs/recurrence-page.gladep
? gui/dialogs/schedule-page.gladep
? gui/dialogs/task-details-page.gladep
? gui/dialogs/task-page.gladep
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1745
diff -u -p -r1.1745 ChangeLog
--- ChangeLog	23 Apr 2003 22:03:56 -0000	1.1745
+++ ChangeLog	24 Apr 2003 16:43:05 -0000
@@ -1,3 +1,35 @@
+2003-04-24  Rodrigo Moya <rodrigo ximian com>
+
+	Fixes #41661
+
+	* idl/evolution-calendar.idl: added discardAlarm method to
+	GNOME:Evolution:Calendar:Cal interface.
+
+	* pcs/cal.c (cal_class_init): set new epv's method.
+	(impl_Cal_discardAlarm): implementation of new CORBA method.
+
+	* pcs/cal-backend.[ch]: added 'discard_alarm' virtual method, and
+	CAL_BACKEND_RESULT_NOT_IMPLEMENTED to CalBackendResult enum.
+	(cal_backend_class_init): initialize new class method.
+	(cal_backend_discard_alarm): new method.
+	(cal_backend_update_objects, cal_backend_remove_object): return
+	proper CalBackendResult values.
+
+	* pcs/cal-backend-file.c (cal_backend_file_class_init): initialize
+	new class method.
+	(cal_backend_file_discard_alarm): implementation of new method.
+	
+	* pcs/cal-client.[ch] (cal_client_discard_alarm): new function.
+
+	* gui/alarm-notify/alarm-queue.c (remove_qeueud_alarm): don't remove
+	the alarm directly from the component, call cal_client_discard_alarm
+	and let the backend deal with it.
+
 2003-04-23  Hans Petter Jansson  <hpj ximian com>
 
 	Fixes #41641
Index: cal-client/cal-client.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/cal-client/cal-client.c,v
retrieving revision 1.114
diff -u -p -r1.114 cal-client.c
--- cal-client/cal-client.c	11 Apr 2003 10:41:33 -0000	1.114
+++ cal-client/cal-client.c	24 Apr 2003 16:43:09 -0000
@@ -2486,6 +2486,47 @@ cal_client_get_alarms_for_object (CalCli
 	return retval;
 }
 
+/**
+ * cal_client_discard_alarm
+ * @client: A calendar client.
+ * @comp: The component to discard the alarm from.
+ * @auid: Unique identifier of the alarm to be discarded.
+ *
+ * Tells the calendar backend to get rid of the alarm identified by the
+ * @auid argument in @comp. Some backends might remove the alarm or
+ * update internal information about the alarm be discarded, or, like
+ * the file backend does, ignore the operation.
+ *
+ * Return value: a #CalClientResult value indicating the result of the
+ * operation.
+ */
+CalClientResult
+cal_client_discard_alarm (CalClient *client, CalComponent *comp, const char *auid)
+{
+	CalClientPrivate *priv;
+	CalClientResult retval;
+	CORBA_Environment ev;
+	const char *uid;
+
+	g_return_val_if_fail (IS_CAL_CLIENT (client), CAL_CLIENT_RESULT_NOT_FOUND);
+	g_return_val_if_fail (IS_CAL_COMPONENT (comp), CAL_CLIENT_RESULT_NOT_FOUND);
+	g_return_val_if_fail (auid != NULL, CAL_CLIENT_RESULT_NOT_FOUND);
+
+	cal_component_get_uid (comp, &uid);
+
+	CORBA_exception_init (&ev);
+	GNOME_Evolution_Calendar_Cal_discardAlarm (priv->cal, uid, auid, &ev);
+	if (BONOBO_USER_EX (&ev, ex_GNOME_Evolution_Calendar_Cal_NotFound))
+		retval = CAL_CLIENT_RESULT_NOT_FOUND;
+	else if (BONOBO_EX (&ev))
+		retval = CAL_CLIENT_RESULT_CORBA_ERROR;
+	else
+		retval = CAL_CLIENT_RESULT_SUCCESS;
+
+	CORBA_exception_free (&ev);
+	return retval;
+}
+
 typedef struct _ForeachTZIDCallbackData ForeachTZIDCallbackData;
 struct _ForeachTZIDCallbackData {
 	CalClient *client;
Index: cal-client/cal-client.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/cal-client/cal-client.h,v
retrieving revision 1.62
diff -u -p -r1.62 cal-client.h
--- cal-client/cal-client.h	4 Mar 2003 22:01:58 -0000	1.62
+++ cal-client/cal-client.h	24 Apr 2003 16:43:10 -0000
@@ -200,6 +200,8 @@ gboolean cal_client_get_alarms_for_objec
 					   time_t start, time_t end,
 					   CalComponentAlarms **alarms);
 
+CalClientResult cal_client_discard_alarm (CalClient *client, CalComponent *comp, const char *auid);
+
 /* Add or update a single object. When adding an object only builtin timezones
    are allowed. To use external VTIMEZONE data call update_objects() instead.*/
 CalClientResult cal_client_update_object (CalClient *client, CalComponent *comp);
Index: gui/alarm-notify/alarm-queue.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/gui/alarm-notify/alarm-queue.c,v
retrieving revision 1.37
diff -u -p -r1.37 alarm-queue.c
--- gui/alarm-notify/alarm-queue.c	23 Apr 2003 22:38:02 -0000	1.37
+++ gui/alarm-notify/alarm-queue.c	24 Apr 2003 16:43:20 -0000
@@ -219,12 +219,10 @@ remove_queued_alarm (CompQueuedAlarms *c
 	cqa->queued_alarms = g_slist_remove_link (cqa->queued_alarms, l);
 	g_slist_free_1 (l);
 
-	if (remove_alarm &&
-	    cal_client_get_static_capability (cqa->parent_client->client,
-					      CAL_STATIC_CAPABILITY_REMOVE_ALARMS)) {
-		cal_component_remove_alarm (cqa->alarms->comp, qa->instance->auid);
+	if (remove_alarm) {
 		cqa->expecting_update = TRUE;
-		cal_client_update_object (cqa->parent_client->client, cqa->alarms->comp);
+		cal_client_discard_alarm (cqa->parent_client->client, cqa->alarms->comp,
+					  qa->instance->auid);
 		cqa->expecting_update = FALSE;
 	}
 
Index: idl/evolution-calendar.idl
===================================================================
RCS file: /cvs/gnome/evolution/calendar/idl/evolution-calendar.idl,v
retrieving revision 1.66
diff -u -p -r1.66 evolution-calendar.idl
--- idl/evolution-calendar.idl	4 Mar 2003 22:19:31 -0000	1.66
+++ idl/evolution-calendar.idl	24 Apr 2003 16:43:20 -0000
@@ -214,6 +214,10 @@ module Calendar {
 			raises (NotFound, InvalidRange);
 
 
+		/* Discards an alarm from a given component */
+		void discardAlarm (in CalObjUID uid, in CalAlarmUID auid)
+			raises (NotFound);
+
 		/* Adds or updates one or more VEVENT/VTODO/VTIMEZONE
 		 * components. The calobj should be a string representation of
 		 * a complete VCALENDAR object (we also support single
Index: pcs/cal-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/pcs/cal-backend-file.c,v
retrieving revision 1.79
diff -u -p -r1.79 cal-backend-file.c
--- pcs/cal-backend-file.c	10 Apr 2003 14:38:24 -0000	1.79
+++ pcs/cal-backend-file.c	24 Apr 2003 16:43:23 -0000
@@ -112,6 +112,10 @@ static GNOME_Evolution_Calendar_CalCompo
 	CalBackend *backend, const char *uid,
 	time_t start, time_t end, gboolean *object_found);
 
+static CalBackendResult cal_backend_file_discard_alarm (CalBackend *backend,
+							const char *uid,
+							const char *auid);
+
 static CalBackendResult cal_backend_file_update_objects (CalBackend *backend,
 							 const char *calobj,
 							 CalObjModType mod);
@@ -199,6 +203,7 @@ cal_backend_file_class_init (CalBackendF
 	backend_class->get_changes = cal_backend_file_get_changes;
 	backend_class->get_alarms_in_range = cal_backend_file_get_alarms_in_range;
 	backend_class->get_alarms_for_object = cal_backend_file_get_alarms_for_object;
+	backend_class->discard_alarm = cal_backend_file_discard_alarm;
 	backend_class->update_objects = cal_backend_file_update_objects;
 	backend_class->remove_object = cal_backend_file_remove_object;
 	backend_class->send_object = cal_backend_file_send_object;
@@ -1518,6 +1523,14 @@ cal_backend_file_get_alarms_for_object (
 		cal_backend_util_fill_alarm_instances_seq (&corba_alarms->alarms, NULL);
 
 	return corba_alarms;
+}
+
+/* Discard_alarm handler for the file backend */
+static CalBackendResult
+cal_backend_file_discard_alarm (CalBackend *backend, const char *uid, const char *auid)
+{
+	/* we just do nothing with the alarm */
+	return CAL_BACKEND_RESULT_SUCCESS;
 }
 
 /* Creates a CalComponent for the given icalcomponent and adds it to our
Index: pcs/cal-backend.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/pcs/cal-backend.c,v
retrieving revision 1.92
diff -u -p -r1.92 cal-backend.c
--- pcs/cal-backend.c	9 Apr 2003 16:15:51 -0000	1.92
+++ pcs/cal-backend.c	24 Apr 2003 16:43:24 -0000
@@ -193,6 +193,7 @@ cal_backend_class_init (CalBackendClass 
 	class->get_changes = NULL;
 	class->get_alarms_in_range = NULL;
 	class->get_alarms_for_object = NULL;
+	class->discard_alarm = NULL;
 	class->update_objects = NULL;
 	class->remove_object = NULL;
 	class->send_object = NULL;
@@ -825,6 +826,30 @@ cal_backend_get_alarms_for_object (CalBa
 }
 
 /**
+ * cal_backend_discard_alarm
+ * @backend: A calendar backend.
+ * @uid: UID of the component to discard the alarm from.
+ * @auid: Alarm ID.
+ *
+ * Discards an alarm from the given component. This allows the specific backend
+ * to do whatever is needed to really discard the alarm.
+ *
+ * Return value: a #CalBackendResult value, which indicates the
+ * result of the operation.
+ **/
+CalBackendResult
+cal_backend_discard_alarm (CalBackend *backend, const char *uid, const char *auid)
+{
+	g_return_val_if_fail (backend != NULL, CAL_BACKEND_RESULT_NOT_FOUND);
+	g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_RESULT_NOT_FOUND);
+	g_return_val_if_fail (uid != NULL, CAL_BACKEND_RESULT_NOT_FOUND);
+	g_return_val_if_fail (auid != NULL, CAL_BACKEND_RESULT_NOT_FOUND);
+	g_return_val_if_fail (CLASS (backend)->discard_alarm != NULL, CAL_BACKEND_RESULT_NOT_FOUND);
+
+	return (* CLASS (backend)->discard_alarm) (backend, uid, auid);
+}
+
+/**
  * cal_backend_update_objects:
  * @backend: A calendar backend.
  * @calobj: String representation of the new calendar object(s).
@@ -839,9 +864,9 @@ cal_backend_get_alarms_for_object (CalBa
 CalBackendResult
 cal_backend_update_objects (CalBackend *backend, const char *calobj, CalObjModType mod)
 {
-	g_return_val_if_fail (backend != NULL, FALSE);
-	g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE);
-	g_return_val_if_fail (calobj != NULL, FALSE);
+	g_return_val_if_fail (backend != NULL, CAL_BACKEND_RESULT_NOT_FOUND);
+	g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_RESULT_NOT_FOUND);
+	g_return_val_if_fail (calobj != NULL, CAL_BACKEND_RESULT_NOT_FOUND);
 
 	g_assert (CLASS (backend)->update_objects != NULL);
 	return (* CLASS (backend)->update_objects) (backend, calobj, mod);
@@ -861,9 +886,9 @@ cal_backend_update_objects (CalBackend *
 CalBackendResult
 cal_backend_remove_object (CalBackend *backend, const char *uid, CalObjModType mod)
 {
-	g_return_val_if_fail (backend != NULL, FALSE);
-	g_return_val_if_fail (IS_CAL_BACKEND (backend), FALSE);
-	g_return_val_if_fail (uid != NULL, FALSE);
+	g_return_val_if_fail (backend != NULL, CAL_BACKEND_RESULT_NOT_FOUND);
+	g_return_val_if_fail (IS_CAL_BACKEND (backend), CAL_BACKEND_RESULT_NOT_FOUND);
+	g_return_val_if_fail (uid != NULL, CAL_BACKEND_RESULT_NOT_FOUND);
 
 	g_assert (CLASS (backend)->remove_object != NULL);
 	return (* CLASS (backend)->remove_object) (backend, uid, mod);
Index: pcs/cal-backend.h
===================================================================
RCS file: /cvs/gnome/evolution/calendar/pcs/cal-backend.h,v
retrieving revision 1.58
diff -u -p -r1.58 cal-backend.h
--- pcs/cal-backend.h	4 Mar 2003 22:02:01 -0000	1.58
+++ pcs/cal-backend.h	24 Apr 2003 16:43:24 -0000
@@ -47,7 +47,7 @@ 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_PERMISSION_DENIED
+	CAL_BACKEND_OPEN_PERMISSION_DENIED,
 } CalBackendOpenStatus;
 
 /* Update and Remove result values */
@@ -137,6 +137,7 @@ struct _CalBackendClass {
 	GNOME_Evolution_Calendar_CalComponentAlarms *(* get_alarms_for_object) (
 		CalBackend *backend, const char *uid,
 		time_t start, time_t end, gboolean *object_found);
+	CalBackendResult (* discard_alarm) (CalBackend *backend, const char *uid, const char *auid);
 
 	/* Object manipulation virtual methods */
 	CalBackendResult (* update_objects) (CalBackend *backend, const char *calobj, CalObjModType mod);
@@ -209,6 +210,8 @@ GNOME_Evolution_Calendar_CalComponentAla
 	CalBackend *backend, const char *uid,
 	time_t start, time_t end,
 	CalBackendGetAlarmsForObjectResult *result);
+
+CalBackendResult cal_backend_discard_alarm (CalBackend *backend, const char *uid, const char *auid);
 
 
 CalBackendResult cal_backend_update_objects (CalBackend *backend, const char *calobj, CalObjModType mod);
Index: pcs/cal.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/pcs/cal.c,v
retrieving revision 1.71
diff -u -p -r1.71 cal.c
--- pcs/cal.c	4 Mar 2003 22:02:01 -0000	1.71
+++ pcs/cal.c	24 Apr 2003 16:43:25 -0000
@@ -513,6 +513,25 @@ impl_Cal_getAlarmsForObject (PortableSer
 	}
 }
 
+/* Cal::discardAlarm method */
+static void
+impl_Cal_discardAlarm (PortableServer_Servant servant,
+		       const CORBA_char *uid,
+		       const CORBA_char *auid,
+		       CORBA_Environment *ev)
+{
+	Cal *cal;
+	CalPrivate *priv;
+	CalBackendResult result;
+
+	cal = CAL (bonobo_object_from_servant (servant));
+	priv = cal->priv;
+
+	result = cal_backend_discard_alarm (priv->backend, uid, auid);
+	if (result == CAL_BACKEND_RESULT_NOT_FOUND)
+		bonobo_exception_set (ev, ex_GNOME_Evolution_Calendar_Cal_NotFound);
+}
+
 /* Cal::updateObjects method */
 static void
 impl_Cal_updateObjects (PortableServer_Servant servant,
@@ -855,6 +874,7 @@ cal_class_init (CalClass *klass)
 	epv->getFreeBusy = impl_Cal_getFreeBusy;
 	epv->getAlarmsInRange = impl_Cal_getAlarmsInRange;
 	epv->getAlarmsForObject = impl_Cal_getAlarmsForObject;
+	epv->discardAlarm = impl_Cal_discardAlarm;
 	epv->updateObjects = impl_Cal_updateObjects;
 	epv->removeObject = impl_Cal_removeObject;
 	epv->sendObject = impl_Cal_sendObject;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]