diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2001-01-03 06:47:28 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-01-03 06:47:28 +0800 |
commit | 02ee28bf7749fd4f6cc764d1765405edf2e9293e (patch) | |
tree | e75d163d068de3e74f86cf7ca4bdca2de845e434 /calendar/gui/alarm-notify | |
parent | 70844a59a3e7acb053f679f241fbb70d4ce79209 (diff) | |
download | gsoc2013-evolution-02ee28bf7749fd4f6cc764d1765405edf2e9293e.tar.gz gsoc2013-evolution-02ee28bf7749fd4f6cc764d1765405edf2e9293e.tar.zst gsoc2013-evolution-02ee28bf7749fd4f6cc764d1765405edf2e9293e.zip |
If the component has no alarms, do not try to queue them.
2001-01-02 Federico Mena Quintero <federico@helixcode.com>
* 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
Diffstat (limited to 'calendar/gui/alarm-notify')
-rw-r--r-- | calendar/gui/alarm-notify/alarm-queue.c | 48 |
1 files changed, 47 insertions, 1 deletions
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 */ |