From b2da9f93edf316bbd6103c7635e1451305bac942 Mon Sep 17 00:00:00 2001 From: Rodrigo Moya Date: Tue, 18 Mar 2003 14:17:16 +0000 Subject: Fixes #34505 2003-03-18 Rodrigo Moya Fixes #34505 * gui/alarm-notify/alarm-queue.c (remove_queued_alarm): added removal of the alarm itself in the calendar if the (new) argument says so. Also, set expecting_update flag to TRUE. (add_component_alarms): initialize expecting_update to FALSE. (remove_alarms): don't remove the component if expecting_update is TRUE. (obj_updated_cb, notify_dialog_cb, procedure_notification): adapted to changes in remove_queued_alarm. svn path=/trunk/; revision=20335 --- calendar/gui/alarm-notify/alarm-queue.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'calendar/gui') diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 58f3429ab6..fc52172851 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -22,6 +22,7 @@ #include #endif +#include #include #include #include @@ -86,6 +87,9 @@ typedef struct { /* List of QueuedAlarm structures */ GSList *queued_alarms; + + /* Flags */ + gboolean expecting_update; } CompQueuedAlarms; /* Pair of a queued alarm ID and the alarm trigger instance it refers to */ @@ -192,7 +196,8 @@ lookup_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id) * the last one listed for the component, it removes the component itself. */ static void -remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, gboolean free_object) +remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, + gboolean free_object, gboolean remove_alarm) { QueuedAlarm *qa; const char *uid; @@ -212,6 +217,13 @@ remove_queued_alarm (CompQueuedAlarms *cqa, gpointer alarm_id, gboolean free_obj cqa->queued_alarms = g_slist_remove_link (cqa->queued_alarms, l); g_slist_free_1 (l); + if (remove_alarm) { + cal_component_remove_alarm (cqa->alarms->comp, qa->instance->auid); + cqa->expecting_update = TRUE; + cal_client_update_object (cqa->parent_client->client, cqa->alarms->comp); + cqa->expecting_update = FALSE; + } + g_free (qa); /* If this was the last queued alarm for this component, remove the @@ -307,6 +319,7 @@ add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms) cqa = g_new (CompQueuedAlarms, 1); cqa->parent_client = ca; cqa->alarms = alarms; + cqa->expecting_update = FALSE; cqa->queued_alarms = NULL; @@ -442,7 +455,7 @@ remove_alarms (CompQueuedAlarms *cqa, gboolean free_object) l = l->next; alarm_remove (qa->alarm_id); - remove_queued_alarm (cqa, qa->alarm_id, free_object); + remove_queued_alarm (cqa, qa->alarm_id, free_object, FALSE); } } @@ -532,9 +545,10 @@ obj_updated_cb (CalClient *client, const char *uid, gpointer data) cqa->queued_alarms = g_slist_prepend (cqa->queued_alarms, qa); } - if (cqa->queued_alarms == NULL) - remove_comp (ca, uid); - else + if (cqa->queued_alarms == NULL) { + if (!cqa->expecting_update) + remove_comp (ca, uid); + } else cqa->queued_alarms = g_slist_reverse (cqa->queued_alarms); } } @@ -704,7 +718,7 @@ notify_dialog_cb (AlarmNotifyResult result, int snooze_mins, gpointer data) } if (c->cqa != NULL) - remove_queued_alarm (c->cqa, c->alarm_id, TRUE); + remove_queued_alarm (c->cqa, c->alarm_id, TRUE, TRUE); g_object_unref (c->comp); g_object_unref (c->client); g_free (c); @@ -941,7 +955,7 @@ procedure_notification (time_t trigger, CompQueuedAlarms *cqa, gpointer alarm_id if (result < 0) goto fallback; - remove_queued_alarm (cqa, alarm_id, TRUE); + remove_queued_alarm (cqa, alarm_id, TRUE, TRUE); return; fallback: -- cgit v1.2.3