From 8aeebbbf78a21c6e3220439775da8c6b53323810 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 6 Mar 2015 23:20:26 +0100 Subject: [PATCH] calendar-server: Give each event an unambiguous ID Each event returned by GetEvents includes the (currently unused) UID, which is not always enough to unambiguously identify an event (different calendar sources, recurring events, ...). As we will start using the property to record events that have been dismissed and should be persistently hidden from the calendar, change it to a truly unique ID. https://bugzilla.gnome.org/show_bug.cgi?id=744927 --- .../gnome-shell-calendar-server.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/calendar-server/gnome-shell-calendar-server.c b/src/calendar-server/gnome-shell-calendar-server.c index da7d6e8fe..10e00f3f0 100644 --- a/src/calendar-server/gnome-shell-calendar-server.c +++ b/src/calendar-server/gnome-shell-calendar-server.c @@ -80,6 +80,7 @@ typedef struct typedef struct { + char *id; char *uid; char *rid; char *backend_name; @@ -348,6 +349,9 @@ calendar_appointment_free (CalendarAppointment *appointment) g_slist_free (appointment->occurrences); appointment->occurrences = NULL; + g_free (appointment->id); + appointment->id = NULL; + g_free (appointment->uid); appointment->uid = NULL; @@ -376,6 +380,8 @@ calendar_appointment_init (CalendarAppointment *appointment, ECalClient *cal, icaltimezone *default_zone) { + const char *source_uid; + appointment->uid = get_ical_uid (ical); appointment->rid = get_ical_rid (ical); appointment->backend_name = get_source_backend_name (cal); @@ -387,6 +393,16 @@ calendar_appointment_init (CalendarAppointment *appointment, appointment->is_all_day = get_ical_is_all_day (ical, appointment->start_time, default_zone); + + /* While the UID is usually enough to identify an event, only the triple + * of (source,UID,RID) is fully unambiguous; neither may contain '\n', + * so we can safely use it to create a unique ID from the triple + */ + source_uid = e_source_get_uid (e_client_get_source (E_CLIENT (cal))); + appointment->id = g_strdup_printf ("%s\n%s\n%s", + source_uid, + appointment->uid, + appointment->rid ? appointment->rid : ""); } static icaltimezone * @@ -916,7 +932,7 @@ handle_method_call (GDBusConnection *connection, g_variant_builder_init (&extras_builder, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_add (&builder, "(sssbxxa{sv})", - a->uid, + a->id, a->summary != NULL ? a->summary : "", a->description != NULL ? a->description : "", (gboolean) a->is_all_day,