aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@helixcode.com>2001-01-03 06:47:28 +0800
committerFederico Mena Quintero <federico@src.gnome.org>2001-01-03 06:47:28 +0800
commit02ee28bf7749fd4f6cc764d1765405edf2e9293e (patch)
treee75d163d068de3e74f86cf7ca4bdca2de845e434 /calendar
parent70844a59a3e7acb053f679f241fbb70d4ce79209 (diff)
downloadgsoc2013-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')
-rw-r--r--calendar/ChangeLog8
-rw-r--r--calendar/gui/alarm-notify.c48
-rw-r--r--calendar/gui/alarm-notify/alarm-queue.c48
-rw-r--r--calendar/pcs/cal-backend-file.c3
4 files changed, 103 insertions, 4 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index 04abb82c3b..19d36d3649 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,5 +1,13 @@
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.
+
+2001-01-02 Federico Mena Quintero <federico@helixcode.com>
+
* gui/dialogs/delete-comp.c (delete_component_dialog): Do not
compose strings so that they can be localized correctly. Also,
convert from UTF8 into the font's encoding. Fixes bug #1030.
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;
}