diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2003-04-27 00:44:49 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2003-04-27 00:44:49 +0800 |
commit | da12dd29a85fae5e4ebaffcfb9c40fa6068ec55d (patch) | |
tree | 90800ebe3c35b148eb0c1c7a537ebbc13835f7c9 /calendar | |
parent | 49802408e28d3f3938fd9c6c8c7c36a499277983 (diff) | |
download | gsoc2013-evolution-da12dd29a85fae5e4ebaffcfb9c40fa6068ec55d.tar gsoc2013-evolution-da12dd29a85fae5e4ebaffcfb9c40fa6068ec55d.tar.gz gsoc2013-evolution-da12dd29a85fae5e4ebaffcfb9c40fa6068ec55d.tar.bz2 gsoc2013-evolution-da12dd29a85fae5e4ebaffcfb9c40fa6068ec55d.tar.lz gsoc2013-evolution-da12dd29a85fae5e4ebaffcfb9c40fa6068ec55d.tar.xz gsoc2013-evolution-da12dd29a85fae5e4ebaffcfb9c40fa6068ec55d.tar.zst gsoc2013-evolution-da12dd29a85fae5e4ebaffcfb9c40fa6068ec55d.zip |
Fixes #41661
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.
svn path=/trunk/; revision=20973
Diffstat (limited to 'calendar')
-rw-r--r-- | calendar/ChangeLog | 27 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.c | 41 | ||||
-rw-r--r-- | calendar/cal-client/cal-client.h | 2 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 8 | ||||
-rw-r--r-- | calendar/idl/evolution-calendar.idl | 4 | ||||
-rw-r--r-- | calendar/pcs/cal-backend-file.c | 13 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.c | 37 | ||||
-rw-r--r-- | calendar/pcs/cal-backend.h | 5 | ||||
-rw-r--r-- | calendar/pcs/cal.c | 20 |
9 files changed, 145 insertions, 12 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 0b061bde6c..dd1412bd7d 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,30 @@ +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-24 JP Rosevear <jpr@ximian.com> * gui/apps_evolution_calendar.schemas: set the hpane default to diff --git a/calendar/cal-client/cal-client.c b/calendar/cal-client/cal-client.c index fc90c2a459..539d490a36 100644 --- a/calendar/cal-client/cal-client.c +++ b/calendar/cal-client/cal-client.c @@ -2486,6 +2486,47 @@ cal_client_get_alarms_for_object (CalClient *client, const char *uid, 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; diff --git a/calendar/cal-client/cal-client.h b/calendar/cal-client/cal-client.h index e44014b9be..556049f831 100644 --- a/calendar/cal-client/cal-client.h +++ b/calendar/cal-client/cal-client.h @@ -200,6 +200,8 @@ gboolean cal_client_get_alarms_for_object (CalClient *client, const char *uid, 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); diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index bf59a4312b..9aff1a8bf0 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -219,12 +219,10 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, 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; } diff --git a/calendar/idl/evolution-calendar.idl b/calendar/idl/evolution-calendar.idl index 4f5657b9f3..d13247d250 100644 --- a/calendar/idl/evolution-calendar.idl +++ b/calendar/idl/evolution-calendar.idl @@ -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 diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index 103d2a70c2..81697602d4 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -112,6 +112,10 @@ 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 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 (CalBackendFileClass *class) 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; @@ -1520,6 +1525,14 @@ cal_backend_file_get_alarms_for_object (CalBackend *backend, const char *uid, 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 cache. Note that the icalcomponent is not added to the toplevel icalcomponent here. That needs to be done elsewhere. It returns the uid diff --git a/calendar/pcs/cal-backend.c b/calendar/pcs/cal-backend.c index 22eecadecc..bf974ddc70 100644 --- a/calendar/pcs/cal-backend.c +++ b/calendar/pcs/cal-backend.c @@ -193,6 +193,7 @@ cal_backend_class_init (CalBackendClass *class) 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 (CalBackend *backend, const char *uid, } /** + * 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 (CalBackend *backend, const char *uid, 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 *backend, const char *calobj, CalObjModTy 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); diff --git a/calendar/pcs/cal-backend.h b/calendar/pcs/cal-backend.h index 962b468fc3..49d8b2d76e 100644 --- a/calendar/pcs/cal-backend.h +++ b/calendar/pcs/cal-backend.h @@ -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); @@ -210,6 +211,8 @@ GNOME_Evolution_Calendar_CalComponentAlarms *cal_backend_get_alarms_for_object ( 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); diff --git a/calendar/pcs/cal.c b/calendar/pcs/cal.c index bd6ffb4b38..7726540d5a 100644 --- a/calendar/pcs/cal.c +++ b/calendar/pcs/cal.c @@ -513,6 +513,25 @@ impl_Cal_getAlarmsForObject (PortableServer_Servant servant, } } +/* 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; |