Commit Graph
85 Commits
Author SHA1 Message Date
Georges Basile Stavracas Neto d2da70fb28 range: Properly compare ranges
The behavior of gcal_range_compare(), and the 'position' argument
of gcal_range_calculate_overlap(), should be the same. However,
because we were comparing the end dates in the wrong order, they
didn't match.

Fix that by properly comparing the end of the ranges.
2020-04-16 16:15:34 -03:00
Georges Basile Stavracas Neto a790f30176 timeline: Add sentinel events to the queue
Moving to have one subscriber per event made us face an interesting
problem: when removing an event, there may be no subscribers that
contain this event, in which case we never queue any REMOVE_EVENT
and the range tree isn't updated.

Add sentinel events (that update the range tree) and subscriber events
(that update subscribers, but not the range tree).
2020-04-16 16:10:33 -03:00
Georges Basile Stavracas Neto 494bd187d8 timeline: Cancel additions and removals
When we add an event to the queue, and later remove it, if the
event is still in the queue, we can just cancel both out and
save the timeline some processing time.
2020-04-16 15:11:53 -03:00
Georges Basile Stavracas Neto 61815ddccf timeline: Trivial code cleanup 2020-04-16 13:47:09 -03:00
Georges Basile Stavracas Neto 381ae0046a timeline: Protect against NULL arrays 2020-04-15 20:49:47 -03:00
Georges Basile Stavracas Neto 3073b6b6d8 timeline: Also queue remove events 2020-04-15 20:35:17 -03:00
Georges Basile Stavracas Neto b5cdc0bd38 timeline: Only diff when ranges intersect
When the old and the new range of the subscribers don't
overlap entirely, we can't use the regular diff algorithm.
It fails quite spectacularly.

Do a full cleanup when ranges don't overlap.
2020-04-15 20:35:04 -03:00
Georges Basile Stavracas Neto a1a4804315 timeline: Only modify event tree once
Now that we queue one event per subscriber, we need to
make sure to update the range tree only once.
2020-04-15 19:16:00 -03:00
Georges Basile Stavracas Neto 678d0acc00 timeline: Remove subscriber from range tree as well
update_range() does not remove any subscriber. They must be
removed manually.
2020-04-15 18:49:36 -03:00
Georges Basile Stavracas Neto e9812b2f28 timeline: Don't try to use removed subscribers
Because the timeline is essentially asynchronous, it may
try and process events after their subscribers were removed.

Protect against that.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/576
2020-04-15 18:49:36 -03:00
Georges Basile Stavracas Neto db668a0b90 timeline: Queue one event per subscriber
Right now, GcalTimeline queues one event per N subscribers. Queue
one event per subscriber instead.
2020-04-15 18:49:36 -03:00
Michael Catanzaro 60c3c26ad6 timeline: fix leak of timeline source
g_source_destroy doesn't free memory, just removes the source from its
main context. We have to do both. (g_source_unref() might call
g_source_destroy() if it has the last ref, but if something else has
another ref, then disaster could result if we don't call it manually.)
2020-04-15 21:18:16 +00:00
Georges Basile Stavracas Neto 98e6ac28e7 event: Remove unused method
Comparing ranges is so easy now that we don't need this
helper anymore.
2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto fd32492053 timeline, calendar-monitor: Remove useless event range checks
GcalRange is now smart enough to compare correctly with other ranges.
2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto d4a6cd0e61 timeline: Process events in batches
A batch size of 5 doesn't seem to impact the mainloop
any more than a batch of size 1, but it reduces the
amount of time spinning the loop quite considerably.
2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto 16c156914a calendar-monitor: Use GcalRange 2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto f3c3bbf5ab event: Use GcalRange in public API 2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto 12fd607d56 utils: Make date comparison follow time comparison semantics
Right now, comparing dates with gcal_date_time_compare_date() gives
the exact opposite result of when comparing using g_date_time_compare().

As shown by this patch, this was a source of *many* bugs.
2020-04-14 19:08:06 +00:00
Georges Basile Stavracas Neto bed8e10609 range-tree: Add print utility
Useful for debugging
2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto 3efbc2436c range-tree: Use GcalRange 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto b97c4a27e0 range-tree: Cleanup header 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto 923e3b7b71 project: Move range tree to core/ 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto 0935a67558 event: Add helper API to return a GcalRange 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto d9733aee27 event: Simplify some code 2020-04-14 19:08:05 +00:00
Georges Basile Stavracas Neto dbfebc85fa Introduce GcalRange
GcalRange is a new structure that represents a time range. It is
always inclusive at the start, and exclusive at the end.
2020-04-14 19:08:05 +00:00
Michael Catanzaro 2bf6cfe289 Avoid critical on startup when a calendar is broken
This is a workaround for evolution-data-server#205. Depending on the
resolution of that bug, this might even be the correct fix.
2020-04-02 15:59:32 -05:00
Georges Basile Stavracas Neto aaab4af282 timeline: Respond well to subscriber removal 2020-04-01 23:10:01 -03:00
Georges Basile Stavracas Neto 93542e8853 timeline: Add already cached events to new subscribers 2020-04-01 23:10:01 -03:00
Michael Catanzaro 164ec8620b calendar-monitor: Fix critical in finalize
self->thread can be NULL if gcal_calendar_monitor_set_range() was never
called prior to finalize. This is fine, so just check for NULL here
using g_clear_pointer().
2020-04-02 01:54:33 +00:00
Michael Catanzaro e816657116 calendar-monitor: fix unused variable warning
Fixes:

[43/52] Compiling C object 'src/25a6634@@gcal-private@sta/core_gcal-calendar-monitor.c.o'
../../../../Projects/gnome-calendar/src/core/gcal-calendar-monitor.c: In function ‘on_client_view_objects_added_cb’:
../../../../Projects/gnome-calendar/src/core/gcal-calendar-monitor.c:402:16: warning: variable ‘old_size’ set but not used [-Wunused-but-set-variable]
  402 |           gint old_size;
      |                ^~~~~~~~
2020-04-01 20:30:06 -05:00
Georges Basile Stavracas Neto d606bafd15 calendar-monitor: Properly cleanup ECalComponents
Unfortunately, they do not have autoptr functions.
2020-04-01 21:08:21 -03:00
Georges Basile Stavracas Neto a65a370317 time-zone-monitor: Clear GTimeZone with g_time_zone_unref
GTimeZone is not an object, and it cannot be cleared with g_clear_object().
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto cfa4b56a05 timeline: Implement processing changes in idle 2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 7a0b55aa61 timeline: Replace useless function by GcalEvent counterpart 2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 1f6559de68 Remove ECalDataModel and ECalDataModelSubscriber
Drop the bomb!
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto c68ef4b9ab manager: Remove more unused API 2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 399b9d8d00 Simplify calendar views
We don't need a split subscription update step in GcalView
anymore, since subscribers communicate range directly to
the timeline now.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 84eeb58804 Move Shell search to GcalShellSearchProvider
Add a custom timeline to GcalShellSearchProvier and use
it to gather events.

Do a massive cleanup of unused APIs as well.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 02f21fddab manager: Remove main ECalDataModel
It is not used by any views, nor by the search engine.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 9cb29b6dc5 manager: Update event gathering API 2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 72952e42cb timeline: Add API to gather events at a certain range
Will be used by the month popover.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 70bcc18bf9 manager: Remove unused API 2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 2d46e673ca timeline: Add filtering API
This will be used by the search.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 6bcf1a3705 manager: Add GcalTimelineSubscribers to GcalTimeline
Instead of subscribing to the ECalDataModel's API, use the
new API.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 3692a0ccf6 Introduce the new calendar monitoring API
It is, as expected, heavily inspired by the ECalDataModel code,
except it uses GDateTime, is timezone aware, and can handle all
day events correctly.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 94413c26b1 event: Remove event cache
It's for the best. The cache was being more
problematic than it was worth it.
2020-04-01 21:06:51 -03:00
Georges Basile Stavracas Neto 78248bec5e calendar: Mark all properties as G_PARAM_EXPLICIT_NOTIFY
We explicitly notify them all, so mark them as such. Otherwise,
GLib notifies it when changing these properties through bindings
and such.
2020-04-01 21:06:50 -03:00
Georges Basile Stavracas Neto 90597ca128 calendar: Only notify visibility when it changes
Otherwise we get weird double-notify issues from it.
2020-04-01 21:06:50 -03:00
Georges Basile Stavracas Neto f182813e49 event: Protect event cache with a lock
We'll be creating events from multiple threads soon,
so make sure the event cache is protected enough.
2020-04-01 21:06:50 -03:00
Georges Basile Stavracas Neto 047078d67d build: Move foward typedefs to gcal-types.h
Standard practice; gcal-types.h is meant to only be
used by header files.
2020-04-01 21:06:50 -03:00