From 72a6450017852b5c5e3fe30ed76b82c916d5a566 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Thu, 4 Nov 2021 17:07:50 +0100 Subject: [PATCH] calendar-server: Remove the all-day property of events The way it is currently calculated is broken for days with DST changes or leap seconds and it is not needed anymore anyway. This will also make the fix in the following commit simpler. Part-of: --- .../org.gnome.Shell.CalendarServer.xml | 2 +- js/ui/calendar.js | 7 +-- .../gnome-shell-calendar-server.c | 59 ++----------------- 3 files changed, 8 insertions(+), 60 deletions(-) diff --git a/data/dbus-interfaces/org.gnome.Shell.CalendarServer.xml b/data/dbus-interfaces/org.gnome.Shell.CalendarServer.xml index 51b71ef03..581471016 100644 --- a/data/dbus-interfaces/org.gnome.Shell.CalendarServer.xml +++ b/data/dbus-interfaces/org.gnome.Shell.CalendarServer.xml @@ -6,7 +6,7 @@ - + diff --git a/js/ui/calendar.js b/js/ui/calendar.js index a42d70ffb..852f1d0fe 100644 --- a/js/ui/calendar.js +++ b/js/ui/calendar.js @@ -78,12 +78,11 @@ function _getCalendarDayAbbreviation(dayNumber) { // Abstraction for an appointment/event in a calendar var CalendarEvent = class CalendarEvent { - constructor(id, date, end, summary, allDay) { + constructor(id, date, end, summary) { this.id = id; this.date = date; this.end = end; this.summary = summary; - this.allDay = allDay; } }; @@ -288,10 +287,10 @@ class DBusEventSource extends EventSourceBase { let changed = false; for (let n = 0; n < appointments.length; n++) { - const [id, summary, allDay, startTime, endTime] = appointments[n]; + const [id, summary, startTime, endTime] = appointments[n]; const date = new Date(startTime * 1000); const end = new Date(endTime * 1000); - let event = new CalendarEvent(id, date, end, summary, allDay); + let event = new CalendarEvent(id, date, end, summary); this._events.set(event.id, event); changed = true; diff --git a/src/calendar-server/gnome-shell-calendar-server.c b/src/calendar-server/gnome-shell-calendar-server.c index 4c5a64542..c8e2eafaf 100644 --- a/src/calendar-server/gnome-shell-calendar-server.c +++ b/src/calendar-server/gnome-shell-calendar-server.c @@ -52,7 +52,7 @@ static const gchar introspection_xml[] = " " " " " " - " " + " " " " " " " " @@ -110,7 +110,6 @@ typedef struct gchar *summary; time_t start_time; time_t end_time; - guint is_all_day : 1; } CalendarAppointment; static time_t @@ -175,51 +174,6 @@ get_ical_end_time (ECalClient *cal, default_zone); } -static gboolean -get_ical_is_all_day (ECalClient *cal, - ICalComponent *icomp, - time_t start_time, - ICalTimezone *default_zone) -{ - ICalProperty *prop; - ICalDuration *duration; - ICalTime *dtstart; - struct tm *start_tm; - time_t end_time; - gboolean retval; - - dtstart = i_cal_component_get_dtstart (icomp); - if (dtstart && i_cal_time_is_date (dtstart)) - { - g_clear_object (&dtstart); - return TRUE; - } - - g_clear_object (&dtstart); - - start_tm = gmtime (&start_time); - if (start_tm->tm_sec != 0 || - start_tm->tm_min != 0 || - start_tm->tm_hour != 0) - return FALSE; - - if ((end_time = get_ical_end_time (cal, icomp, default_zone))) - return (end_time - start_time) % 86400 == 0; - - prop = i_cal_component_get_first_property (icomp, I_CAL_DURATION_PROPERTY); - if (!prop) - return FALSE; - - duration = i_cal_property_get_duration (prop); - - retval = duration && (i_cal_duration_as_int (duration) % 86400) == 0; - - g_clear_object (&duration); - g_clear_object (&prop); - - return retval; -} - static CalendarAppointment * calendar_appointment_new (ECalClient *cal, ECalComponent *comp) @@ -241,10 +195,6 @@ calendar_appointment_new (ECalClient *cal, appt->summary = g_strdup (i_cal_component_get_summary (ical)); appt->start_time = get_ical_start_time (cal, ical, default_zone); appt->end_time = get_ical_end_time (cal, ical, default_zone); - appt->is_all_day = get_ical_is_all_day (cal, - ical, - appt->start_time, - default_zone); e_cal_component_id_free (id); @@ -361,7 +311,7 @@ app_notify_events_added (App *app) /* The a{sv} is used as an escape hatch in case we want to provide more * information in the future without breaking ABI */ - g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ssbxxa{sv})")); + g_variant_builder_init (&builder, G_VARIANT_TYPE ("a(ssxxa{sv})")); for (link = events; link; link = g_slist_next (link)) { CalendarAppointment *appt = link->data; @@ -375,10 +325,9 @@ app_notify_events_added (App *app) { g_variant_builder_init (&extras_builder, G_VARIANT_TYPE ("a{sv}")); g_variant_builder_add (&builder, - "(ssbxxa{sv})", + "(ssxxa{sv})", appt->id, appt->summary != NULL ? appt->summary : "", - (gboolean) appt->is_all_day, (gint64) start_time, (gint64) end_time, &extras_builder); @@ -390,7 +339,7 @@ app_notify_events_added (App *app) "/org/gnome/Shell/CalendarServer", "org.gnome.Shell.CalendarServer", "EventsAddedOrUpdated", - g_variant_new ("(a(ssbxxa{sv}))", &builder), + g_variant_new ("(a(ssxxa{sv}))", &builder), NULL); g_variant_builder_clear (&builder);