Commit Graph
124 Commits
Author SHA1 Message Date
Milan Crha 1ba749ee59 gcal-recurrence: Handle invalid 'until' time
When the until's time part is invalid, the libical claims the time
as valid, but the conversion into the GDateTime fails and returns NULL.
Such events, which claim to have until-date recurrence, but NULL 'until'
cannot be edited, because they cause a crash of the application.

More information can be found downstream at:
https://bugzilla.redhat.com/show_bug.cgi?id=2135772

Related to https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/892
2022-11-17 10:46:16 +00:00
Georges Basile Stavracas Neto 1fee8ff144 core/recurrence: Port to gatomicrefcount 2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto e3c7a1d777 core/manager: Remove old hack around recurrences
We handle it all before reaching GcalManager now.
2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto 2f1fe2b49b core/event: Fix transfer annotation 2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto 1beb3c9cf3 manager: Remove unnecessary comment 2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto db43bcd096 event: Trivial style fix 2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto a0963c0d36 calendar-monitor: Properly update and delete recurrent events
When we receive the 'objects-modified' signal, we get components
that may represent main events. We also may receive components
that have no recurrency because they were just changed from being
recurrent to non-recurrent.

We need to handle all these cases properly.

If the event has no recurrency set, remove any potential old
recurrence instance lingering around. If we're changing an event
with recurrency, make sure the recurrency instances are in sync
with the new recurrency.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/881
(or so I hope.)
2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto 16b9337e3f calendar-monitor: Move events hash table to shared section
We'll start accessing the hash table from multiple threads, so
it must be in the shared section of the structure, and it must
be encapsulated by locking.
2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto 791d443c54 calendar-monitor: Simplify locking code a bit
Use GRWLock*Locker to simplify the locking code in a couple of
places.
2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto 5f67c55304 calendar-monitor: Replace mutex by a rw-lock
This will be more appropriate once we start accessing the events
hash table from the monitor thread.
2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto baacf696a6 calendar-monitor: Shuffle some variables around
Move them to where they're used.
2022-10-17 23:37:13 -03:00
Georges Basile Stavracas Neto 4c9e7a2d03 manager: Bring back credentials 2022-06-23 13:50:20 -03:00
Milan Crha bde989cc0e event: Workaround libical-glib bug before 3.0.12 version
Even the is_daylight argument is optional, the libical-glib had a bug
to require it. No need to bump the dependency, just workaround the problem.

Related to https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/444
2022-03-07 14:53:52 -03:00
Milan Crha be95d58cda event: Rework initialization process
While fixing timezone bugs, it was found that the calendar property needs
to be set before the component property. The component times may require
to have the calendar set, to be able to lookup the custom timezones in the
calendar, thus make sure the calendar is set before the component is set,
during the construction time.

Rework the initialization process so that setting the construct-only
component property merely takes a hold on the references; and the actual
setting up of the event happens during g_initable_init().

Closes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/788
2022-03-07 14:53:52 -03:00
Georges Basile Stavracas Neto ee5acbd493 Reimplement event drag n' drop
Reintroduce the code using GTK4 tooling for in-process DnD.
This is looking much better!
2022-02-12 13:08:50 -03:00
Georges Basile Stavracas Neto fcfb387f5a importer: Port to GTK4 2022-02-11 09:18:42 -03:00
Georges Basile Stavracas Neto 2139f40e67 project: Adjust color rendering to use GdkPaintable 2022-02-11 09:18:38 -03:00
Georges Basile Stavracas Neto 2b7e2cb574 build: Temporarily remove libedataserverui dep
Since we'll be switching to GTK4, we can't depend on this
library which links to GTK3. There's a GTK4 port underway,
we'll reenable when it lands
2022-02-11 09:18:38 -03:00
Alexander Mikhaylenko 83249b0d84 core: Remove follow-night-light
The system will do the scheduling instead.
2021-12-11 20:40:00 +05:00
Alexander Mikhaylenko 7144300a49 application: Support dark style preference
Depend on libhandy 1.5.0.
2021-12-11 17:25:49 +05:00
Georges Basile Stavracas Neto 0811242180 event: Query client timezone on failure
If we can't find an appropriate timezone, query the ECalClient
for it and give it an extra chance of finding the right timezone.

Thanks to Milan Crha for proposing this fix.

Related: https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/444
2021-12-07 12:39:15 -03:00
Georges Basile Stavracas Neto f1ac400e5d Drop gnome-online-accounts dependency
We don't need it anymore.
2021-10-13 13:48:09 -03:00
Georges Basile Stavracas Neto e90c67a57d manager: Ensure default calendar property is always set 2021-08-16 15:26:59 -03:00
Sebastian Keller af7a17ef01 event: Fix multiday detection for all-day events
All-day events always use UTC, so when the multiday detection code was
converting them to the local timezone, they span an additional day if
the local timezone is not the same as UTC. This was leading to all-day
events always being considered multiday events.

Fix this by ignoring the timezone for all-day events, like all other
comparisons do. Also don't consider all-day events spanning 1 day to be
multiday since as per RFC 5545 the end date is non-inclusive and if
omitted to be start + 1 day.
2021-05-11 19:35:31 +00:00
Sebastian Keller 44e2420645 range: Handle zero-length ranges when calculating overlap
Zero length ranges, such as for events without a DTEND could be
considered to overlap a range if they were at exactly the end of the
range. The end of a range however is the first date that is supposed to
not overlap, so a zero-length range on exactly this point should not be
considered overlapping.

This fixes cases where all-day events from the next month could show up
on the same day of the current month if they did not have a DTEND.

This also adds tests for all possible cases of such zero-length events
overlapping.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/701
2021-04-21 13:59:26 +00:00
Sebastian Keller fb242dd109 time-zone-monitor: Use local timezone as fallback without dbus service
On systems without anything providing the org.freedesktop.timedate1
interface, the timezone returned by the monitor would always be NULL,
because it was never set. This can lead to crashes in places that expect
the monitor to always return a valid timezone. So in that case use the
local timezone from when the monitor got initialized.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/703
2021-04-11 00:27:08 +00:00
Sebastian Keller a0d24cd5d8 time-zone-monitor: Fix timezone leak on timezone changes
The old timezone was never being unref'ed before it got overwritten.
2021-04-11 00:27:08 +00:00
Georges Basile Stavracas Neto d1a0dbd8f5 event: Switch to g_time_zone_new_identifier()
And add the relevant NULL checks here.
2021-02-26 19:26:49 -03:00
Georges Basile Stavracas Neto 27c6d2c017 time-zone-monitor: Switch to g_time_zone_new_identifier()
We don't even need to check for NULL here because if the system timezone
is invalid, we're too screwed to have a fallback path anyway.
2021-02-26 19:26:49 -03:00
Georges Basile Stavracas Neto a146b9050d project: Silence CI warnings 2020-10-31 16:55:06 -03:00
Georges Basile Stavracas Neto eb954505e4 project: Split meson files in subdirs
It allows us to better control what each subdir does, etc. This is
only the first step; we want to also split GResources, etc.
2020-10-30 13:45:50 -03:00
Michael Catanzaro 9ac1528e54 gcal-timeline: completed_calendars should be unsigned
In on_calendar_monitor_completed_cb() we have this assert:

g_assert (self->completed_calendars <= g_hash_table_size (self->calendars));

That is comparing a signed integer to unsigned. This is dangerous. We
could add casts to say that we really want to do it, but
completed_calendars should never be negative, so might as well use
unsigned.
2020-10-14 09:14:34 -05:00
Michael Catanzaro c2c89b667e gcal-timeline: never reset completed_calendars
Since 78cb11c64d, GcalCalendarMonitor now
notifies when a completed calendar transitions to incomplete, and
GcalTimeline decrements its completed_calendars counter. But we forgot
to remove the code that resets completed_calendars when previously
needed. That's not required anymore, because we can trust
GcalCalendarMonitor to do the right thing.

In my case, I have 5 calendars enabled and 6 total. When starting
gnome-calendar, all 5 are successively completed, and
completed_calendars increments from 0 -> 1 -> 2 -> 3 -> 4 -> 5. Then,
when transitioning month view from January 2020 to December 2019, we
call reset_completed_calendars() and completed_calenders gets clobbered
to 0. Then it decrements from 0 -> -1 -> -2 -> -3 -> -4 -> -5 as the
GcalCalendarMonitors notify that they are no longer completed. Well,
that is what would happen, if it didn't crash when decrementing to -1.
We assert -1 <= 6 (the total number of calendars) and crash because -1
gets promoted to a huge unsigned int, since we're comparing signed to
unsigned. (That crash would have been avoided if we used
-Wsign-compare, although that warning would not have caught the logic
problem.)

Anyway, since GcalMonitor now notifies when calendars are no longer
complete, it is safe to simply remove reset_completed_calendars().
GcalTimeline will still notify if it needs to change its own complete
property (in on_calendar_monitor_completed_cb).

Fixes #567
Fixes #636
Fixes #638
Fixes #647
Fixes #650
2020-10-14 09:13:12 -05:00
Yuri Edward 78cb11c64d calendar-monitor: Turn "completed" signal into a boolean property
And make GcalTimeline decrease the completed calendars counter when
any GcalCalendarMonitor goes from complete to incomplete.

Fixes https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/625
2020-08-17 15:59:33 -03:00
Georges Basile Stavracas Neto 158c65db4b event: Trivial cleanup
We can avoid a lookup by simply checking if the alarm id
isn't NULL.
2020-06-17 21:24:36 -03:00
Georges Basile Stavracas Neto 4b6a559924 manager: Assert that cloning was successful
Cloning an ECalComponent can fail, and we need to be able to
catch these failures.

Assert that cloning was successful before procceeding with
the move.
2020-06-17 21:24:36 -03:00
Georges Basile Stavracas Neto c1ec9e734b event: Commit component more often
GcalEvent was mising many points where committing the component
is required. Commit the component more often.

https://gitlab.gnome.org/GNOME/gnome-calendar/-/issues/620
2020-06-17 21:24:36 -03:00
Georges Basile Stavracas Neto dbd81f401c event: Add API to clone events
This will be useful for updating events without having
to keep track of the event states.

Add the new API, and also a unit test.
2020-06-15 13:07:48 -03:00
Georges Basile Stavracas Neto e5986a05c1 calendar-monitor: Use inclusive end date for ECalClientView
May prevent a few events from being transmitted.
2020-04-16 16:31:36 -03:00
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