+ void on_button_calendar_clicked () {
+ var ical = new StringBuilder ("BEGIN:VCALENDAR\nVERSION:2.0\nMETHOD:PUBLISH\nBEGIN:VEVENT\nUID:");
+ ical.append ("beifahrer" + lift.href); // UID
+ ical.append ("\nCLASS:PUBLIC\nSUMMARY:");
+ ical.append_printf (_("From %s to %s with %s"), lift.city_from, lift.city_to, lift.name);
+ ical.append ("\nDTSTART;TZID=Europe/Berlin:");
+ ical.append_printf ("%04d%02d%02dT%02d%02d00", lift.time.year + 2000, lift.time.month, lift.time.day, lift.time.hour, lift.time.minute);
+ ical.append ("\nDTEND;TZID=Europe/Berlin:");
+ ical.append_printf ("%04d%02d%02dT%02d%02d00", lift.time.year + 2000, lift.time.month, lift.time.day, lift.time.hour, lift.time.minute);
+ ical.append ("\nDESCRIPTION:");
+ ical.append (lift.description.replace ("\n", "\\n"));
+ ical.append ("\nEND:VEVENT\nEND:VCALENDAR\n");
+
+ ics_filename = Path.build_path ("/", Environment.get_tmp_dir (),
+ "beifahrer.ics");
+ try {
+ FileUtils.set_contents (ics_filename, ical.str);
+ } catch (FileError e) {
+ stderr.printf ("Failed to write %s: %s\n", ics_filename, e.message);
+ return;
+ }
+
+ var error = DBus.RawError ();
+ var bus = DBus.RawBus.get (DBus.BusType.SESSION, ref error);
+ var res = HildonMime.open_file (bus, "file://" + ics_filename);
+ }
+
+ void on_destroy () {
+ if (ics_filename != null)
+ FileUtils.remove (ics_filename);
+ }
+