From 02ee28bf7749fd4f6cc764d1765405edf2e9293e Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 2 Jan 2001 22:47:28 +0000 Subject: If the component has no alarms, do not try to queue them. 2001-01-02 Federico Mena Quintero * gui/alarm-notify.c (add_component_alarms): If the component has no alarms, do not try to queue them. (remove_client_alarms): New function to remove all the queued alarms for a calendar client. (alarm_notify_remove_client): Remove the client's alarms. svn path=/trunk/; revision=7218 --- calendar/ChangeLog | 8 ++++++ calendar/gui/alarm-notify.c | 48 ++++++++++++++++++++++++++++++++- calendar/gui/alarm-notify/alarm-queue.c | 48 ++++++++++++++++++++++++++++++++- calendar/pcs/cal-backend-file.c | 3 +-- 4 files changed, 103 insertions(+), 4 deletions(-) (limited to 'calendar') diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 04abb82c3b..19d36d3649 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,11 @@ +2001-01-02 Federico Mena Quintero + + * gui/alarm-notify.c (add_component_alarms): If the component has + no alarms, do not try to queue them. + (remove_client_alarms): New function to remove all the queued + alarms for a calendar client. + (alarm_notify_remove_client): Remove the client's alarms. + 2001-01-02 Federico Mena Quintero * gui/dialogs/delete-comp.c (delete_component_dialog): Do not diff --git a/calendar/gui/alarm-notify.c b/calendar/gui/alarm-notify.c index 805b29f81d..d824b2a189 100644 --- a/calendar/gui/alarm-notify.c +++ b/calendar/gui/alarm-notify.c @@ -204,6 +204,12 @@ add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms) CompQueuedAlarms *cqa; GSList *l; + /* No alarms? */ + if (alarms->alarms == NULL) { + cal_component_alarms_free (alarms); + return; + } + cqa = g_new (CompQueuedAlarms, 1); cqa->parent_client = ca; cqa->alarms = alarms; @@ -469,6 +475,46 @@ alarm_notify_add_client (CalClient *client) load_alarms (ca); } +/* Called from g_hash_table_foreach(); adds a component UID to a list */ +static void +add_uid_cb (gpointer key, gpointer value, gpointer data) +{ + GSList **uids; + const char *uid; + + uids = data; + uid = key; + + *uids = g_slist_prepend (*uids, (char *) uid); +} + +/* Removes all the alarms queued for a particular calendar client */ +static void +remove_client_alarms (ClientAlarms *ca) +{ + GSList *uids; + GSList *l; + + /* First we build a list of UIDs so that we can remove them one by one */ + + uids = NULL; + g_hash_table_foreach (ca->uid_alarms_hash, add_uid_cb, &uids); + + for (l = uids; l; l = l->next) { + const char *uid; + + uid = l->data; + + remove_comp (ca, uid); + } + + g_slist_free (uids); + + /* The hash table should be empty now */ + + g_assert (g_hash_table_size (ca->uid_alarms_hash) == 0); +} + /** * alarm_notify_remove_client: * @client: A calendar client. @@ -493,7 +539,7 @@ alarm_notify_remove_client (CalClient *client) if (ca->refcount > 0) return; - /* FIXME: remove alarms */ + remove_client_alarms (ca); /* Clean up */ diff --git a/calendar/gui/alarm-notify/alarm-queue.c b/calendar/gui/alarm-notify/alarm-queue.c index 805b29f81d..d824b2a189 100644 --- a/calendar/gui/alarm-notify/alarm-queue.c +++ b/calendar/gui/alarm-notify/alarm-queue.c @@ -204,6 +204,12 @@ add_component_alarms (ClientAlarms *ca, CalComponentAlarms *alarms) CompQueuedAlarms *cqa; GSList *l; + /* No alarms? */ + if (alarms->alarms == NULL) { + cal_component_alarms_free (alarms); + return; + } + cqa = g_new (CompQueuedAlarms, 1); cqa->parent_client = ca; cqa->alarms = alarms; @@ -469,6 +475,46 @@ alarm_notify_add_client (CalClient *client) load_alarms (ca); } +/* Called from g_hash_table_foreach(); adds a component UID to a list */ +static void +add_uid_cb (gpointer key, gpointer value, gpointer data) +{ + GSList **uids; + const char *uid; + + uids = data; + uid = key; + + *uids = g_slist_prepend (*uids, (char *) uid); +} + +/* Removes all the alarms queued for a particular calendar client */ +static void +remove_client_alarms (ClientAlarms *ca) +{ + GSList *uids; + GSList *l; + + /* First we build a list of UIDs so that we can remove them one by one */ + + uids = NULL; + g_hash_table_foreach (ca->uid_alarms_hash, add_uid_cb, &uids); + + for (l = uids; l; l = l->next) { + const char *uid; + + uid = l->data; + + remove_comp (ca, uid); + } + + g_slist_free (uids); + + /* The hash table should be empty now */ + + g_assert (g_hash_table_size (ca->uid_alarms_hash) == 0); +} + /** * alarm_notify_remove_client: * @client: A calendar client. @@ -493,7 +539,7 @@ alarm_notify_remove_client (CalClient *client) if (ca->refcount > 0) return; - /* FIXME: remove alarms */ + remove_client_alarms (ca); /* Clean up */ diff --git a/calendar/pcs/cal-backend-file.c b/calendar/pcs/cal-backend-file.c index 168067f41e..10d0a35746 100644 --- a/calendar/pcs/cal-backend-file.c +++ b/calendar/pcs/cal-backend-file.c @@ -1293,9 +1293,8 @@ cal_backend_file_get_alarms_for_object (CalBackend *backend, const char *uid, if (alarms) { fill_alarm_instances_seq (&corba_alarms->alarms, alarms->alarms); cal_component_alarms_free (alarms); - } else { + } else fill_alarm_instances_seq (&corba_alarms->alarms, NULL); - } return corba_alarms; } -- cgit v1.2.3