Skip to content
Permalink
Browse files

Add support for libecal-2.0 (#202)

  • Loading branch information
tintou authored and danrabbit committed Dec 6, 2019
1 parent 2185278 commit 3ccd05d611e6dd5274a03f061ba1b5e13d6fe0cf
Showing with 45 additions and 11 deletions.
  1. +14 −2 meson.build
  2. +21 −7 src/Widgets/calendar/CalendarModel.vala
  3. +10 −2 src/Widgets/calendar/Util.vala
@@ -24,6 +24,18 @@ gresource = gnome.compile_resources(
wingpanel_dep = dependency('wingpanel-2.0')
wingpanel_indicatorsdir = wingpanel_dep.get_pkgconfig_variable('indicatorsdir', define_variable: ['libdir', libdir])


libecal_dep = dependency('libecal-2.0', required: false)
if libecal_dep.found()
libical_dep = dependency('libical-glib')
add_project_arguments('--define=E_CAL_2_0', language: 'vala')
add_project_arguments('-DLIBICAL_GLIB_UNSTABLE_API=1', language: 'c')
else
libecal_dep = dependency('libecal-1.2', version: '>=3.8.0')
libical_dep = dependency('libical')
add_project_arguments('--vapidir', join_paths(meson.current_source_dir(), 'vapi'), language: 'vala')
endif

shared_module(
meson.project_name(),
gresource,
@@ -43,9 +55,9 @@ shared_module(
dependency('gobject-2.0'),
dependency('granite'),
dependency('gtk+-3.0'),
dependency('libecal-1.2'),
libecal_dep,
dependency('libedataserver-1.2'),
dependency('libical'),
libical_dep,
wingpanel_dep,
],
install: true,
@@ -260,25 +260,35 @@ namespace DateTime.Widgets {
return view;
}

private void on_objects_added (E.Source source, ECal.Client client, SList<unowned ICal.Component> objects) {
#if E_CAL_2_0
private void on_objects_added (E.Source source, ECal.Client client, SList<ICal.Component> objects) {
#else
private void on_objects_added (E.Source source, ECal.Client client, SList<weak ICal.Component> objects) {
#endif
debug (@"Received $(objects.length()) added event(s) for source '%s'", source.dup_display_name ());
var events = source_events.get (source);
var added_events = new Gee.ArrayList<ECal.Component> ((Gee.EqualDataFunc<ECal.Component>?) Util.calcomponent_equal_func);

objects.foreach ((comp) => {
unowned string uid = comp.get_uid ();
#if E_CAL_2_0
client.generate_instances_for_object_sync (comp, (time_t) data_range.first_dt.to_unix (), (time_t) data_range.last_dt.to_unix (), null, (comp, start, end) => {
var event = new ECal.Component.from_icalcomponent (comp);
#else
client.generate_instances_for_object_sync (comp, (time_t) data_range.first_dt.to_unix (), (time_t) data_range.last_dt.to_unix (), (event, start, end) => {
#endif
debug_event (source, event);
events.set (uid, event);
added_events.add (event);
return true;
});
});

events_added (source, added_events.read_only_view);
}

private void on_objects_modified (E.Source source, ECal.Client client, SList<unowned ICal.Component> objects) {
#if E_CAL_2_0
private void on_objects_modified (E.Source source, ECal.Client client, SList<ICal.Component> objects) {
#else
private void on_objects_modified (E.Source source, ECal.Client client, SList<weak ICal.Component> objects) {
#endif
debug (@"Received $(objects.length()) modified event(s) for source '%s'", source.dup_display_name ());
var updated_events = new Gee.ArrayList<ECal.Component> ((Gee.EqualDataFunc<ECal.Component>?) Util.calcomponent_equal_func);

@@ -294,7 +304,11 @@ namespace DateTime.Widgets {
events_updated (source, updated_events.read_only_view);
}

private void on_objects_removed (E.Source source, ECal.Client client, SList<unowned ECal.ComponentId?> cids) {
#if E_CAL_2_0
private void on_objects_removed (E.Source source, ECal.Client client, SList<ECal.ComponentId?> cids) {
#else
private void on_objects_removed (E.Source source, ECal.Client client, SList<weak ECal.ComponentId?> cids) {
#endif
debug (@"Received $(cids.length()) removed event(s) for source '%s'", source.dup_display_name ());
var events = source_events.get (source);
var removed_events = new Gee.ArrayList<ECal.Component> ((Gee.EqualDataFunc<ECal.Component>?) Util.calcomponent_equal_func);
@@ -304,7 +318,7 @@ namespace DateTime.Widgets {
return;
}

var comps = events.get (cid.uid);
var comps = events.get (cid.get_uid ());
foreach (ECal.Component event in comps) {
removed_events.add (event);
debug_event (source, event);
@@ -93,8 +93,16 @@ namespace Util {
* XXX : Track next versions of evolution in order to convert ICal.Timezone to GLib.TimeZone with a dedicated function…
*/
public GLib.DateTime ical_to_date_time (ICal.Time date) {
#if E_CAL_2_0
int year, month, day, hour, minute, second;
date.get_date (out year, out month, out day);
date.get_time (out hour, out minute, out second);
return new GLib.DateTime (timezone_from_ical (date), year, month,
day, hour, minute, second);
#else
return new GLib.DateTime (timezone_from_ical (date), date.year, date.month,
date.day, date.hour, date.minute, date.second);
#endif
}

/**
@@ -162,9 +170,9 @@ namespace Util {

var a_id = a.get_id ();
var b_id = b.get_id ();
int res = GLib.strcmp (a_id.uid, b_id.uid);
int res = GLib.strcmp (a_id.get_uid (), b_id.get_uid ());
if (res == 0) {
return GLib.strcmp (a_id.rid, b_id.rid);
return GLib.strcmp (a_id.get_rid (), b_id.get_rid ());
}

return res;

0 comments on commit 3ccd05d

Please sign in to comment.
You can’t perform that action at this time.