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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2023>
This commit is contained in:
Sebastian Keller 2021-11-04 17:07:50 +01:00 committed by Marge Bot
parent d8efce0ffd
commit 72a6450017
3 changed files with 8 additions and 60 deletions

View File

@ -6,7 +6,7 @@
<arg type="b" name="force_reload" direction="in"/>
</method>
<signal name="EventsAddedOrUpdated">
<arg type="a(ssbxxa{sv})" name="events" direction="out"/>
<arg type="a(ssxxa{sv})" name="events" direction="out"/>
</signal>
<signal name="EventsRemoved">
<arg type="as" name="ids" direction="out"/>

View File

@ -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;

View File

@ -52,7 +52,7 @@ static const gchar introspection_xml[] =
" <arg type='b' name='force_reload' direction='in'/>"
" </method>"
" <signal name='EventsAddedOrUpdated'>"
" <arg type='a(ssbxxa{sv})' name='events' direction='out'/>"
" <arg type='a(ssxxa{sv})' name='events' direction='out'/>"
" </signal>"
" <signal name='EventsRemoved'>"
" <arg type='as' name='ids' direction='out'/>"
@ -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);