summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMilan Crha <mcrha@redhat.com>2023-03-14 13:22:19 +0100
committerMilan Crha <mcrha@redhat.com>2023-03-14 17:05:52 +0100
commit5fd3a7ed39ee948281ae9fc0dbdd2b48f497b82d (patch)
tree50d40911413c948d3ada2a3dbbed2a0e6035b155
parentcccef85ccd325e0d4b64cf14ef6ed456762fcc52 (diff)
downloadevolution-data-server-5fd3a7ed39ee948281ae9fc0dbdd2b48f497b82d.tar.gz
e-cal-util: Check for duplicate UIDs when generating alarms
Detached instances may have the same alarm UID as the main object, in which case it would duplicate the alarms, which is not desired.
-rw-r--r--src/calendar/libecal/e-cal-util.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/calendar/libecal/e-cal-util.c b/src/calendar/libecal/e-cal-util.c
index c5afaecd9..996da1bdd 100644
--- a/src/calendar/libecal/e-cal-util.c
+++ b/src/calendar/libecal/e-cal-util.c
@@ -932,6 +932,7 @@ e_cal_util_generate_alarms_for_uid_sync (ECalClient *client,
GCancellable *cancellable,
GError **error)
{
+ GHashTable *alarm_uids_hash;
GSList *alarm_uids = NULL;
GSList *objects = NULL, *link;
time_t alarm_start = start, alarm_end = end;
@@ -944,16 +945,32 @@ e_cal_util_generate_alarms_for_uid_sync (ECalClient *client,
if (!e_cal_client_get_objects_for_uid_sync (client, uid, &objects, cancellable, error))
return NULL;
+ alarm_uids_hash = g_hash_table_new (g_str_hash, g_str_equal);
+
for (link = objects; link; link = g_slist_next (link)) {
ECalComponent *comp = link->data;
GSList *auids = e_cal_component_get_alarm_uids (comp);
if (auids) {
+ GSList *alink;
+
compute_alarm_range (comp, auids, alarm_start, alarm_end, &alarm_start, &alarm_end);
- alarm_uids = g_slist_concat (alarm_uids, auids);
+
+ for (alink = auids; alink; alink = g_slist_next (alink)) {
+ const gchar *auid = alink->data;
+ if (auid && !g_hash_table_contains (alarm_uids_hash, auid)) {
+ alarm_uids = g_slist_prepend (alarm_uids, (gpointer) auid);
+ g_hash_table_add (alarm_uids_hash, (gpointer) auid);
+ alink->data = NULL;
+ }
+ }
+
+ g_slist_free_full (auids, g_free);
}
}
+ g_clear_pointer (&alarm_uids_hash, g_hash_table_destroy);
+
aod.comp = NULL;
aod.alarm_uids = alarm_uids;
aod.start = start;