[evolution-patches] A patch related to Calendar's import



Rodrigo and JPR,
   Here is a patch based on 1.4 branch.  Please review it.
Here is the problem. The attached Bruins.ics is get from http://www.apple.com/ical/library/. I cut it to 2 events. If I import it into Evolution, since the timezone (US/Eastern) is not included in Evolution's buildin timezone list, though the import is successfu and I can see some black dates from the date calendar at the upper right, I can see nothing from dayview, weekview and month view. My patch changed the timezone into local default timezone so that the events can be seen. For the CVS HEAD, I guess this patch should go to e_cal_backend_file_receive_objects(), right? But this function is not finished yet, so I cannot patch it now. Let me know what I should do.
   Thanks!
      Harry
BEGIN:VCALENDAR
CALSCALE:GREGORIAN
METHOD:PUBLISH
X-WR-TIMEZONE;VALUE=TEXT:US/Pacific
X-WR-CALDESC:Boston Bruins
PRODID:-//Apple Computer\, Inc//iCal 1.0//EN
X-WR-RELCALID;VALUE=TEXT:334e484c-426f-11D7-BECF-427275696579
X-WR-CALNAME;VALUE=TEXT:Bruins
VERSION:2.0
BEGIN:VEVENT
SEQUENCE:2
DTSTAMP:20030922T092213Z
SUMMARY:Bruins vs Devils
LOCATION:FleetCenter, Boston
UID:44657669-1008-11D7-BECF-427275696579
DTSTART;TZID=US/Eastern:20031008T200000
DURATION:PT2H30M
END:VEVENT
BEGIN:VEVENT
SEQUENCE:2
DTSTAMP:20030922T092213Z
SUMMARY:Bruins at Lightning
LOCATION:St. Pete Times Forum, Tampa Bay
UID:4c696768-1010-11D7-BECF-427275696579
DTSTART;TZID=US/Eastern:20031010T193000
DURATION:PT2H30M
END:VEVENT
END:VCALENDAR

Index: calendar//ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution/calendar/ChangeLog,v
retrieving revision 1.1802.2.37
diff -u -r1.1802.2.37 ChangeLog
--- calendar//ChangeLog	17 Nov 2003 04:16:34 -0000	1.1802.2.37
+++ calendar//ChangeLog	17 Nov 2003 09:29:35 -0000
@@ -1,3 +1,9 @@
+2003-11-17  Harry Lu  <harry lu sun com>
+
+	* pcs/cal-backend-file.c (cal_backend_file_update_object):
+	If the component's timezone is not included in buildin timezone
+	list, convert it to local default timezone.
+
 2003-11-11  Harry Lu  <harry lu sun com>
 
 	* gui/dialogs/recurrence-page.c (make_ending_count_special):
Index: calendar//pcs/cal-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution/calendar/pcs/Attic/cal-backend-file.c,v
retrieving revision 1.80
diff -u -r1.80 cal-backend-file.c
--- calendar//pcs/cal-backend-file.c	26 Apr 2003 16:44:48 -0000	1.80
+++ calendar//pcs/cal-backend-file.c	17 Nov 2003 09:29:37 -0000
@@ -1543,6 +1543,8 @@
 {
 	CalComponent *old_comp;
 	CalComponent *comp;
+	CalComponentDateTime dt;
+	icaltimezone *zone, *default_zone;
 	const char *comp_uid;
 	struct icaltimetype last_modified;
 
@@ -1564,6 +1566,46 @@
 	last_modified = icaltime_from_timet (time (NULL), 0);
 	cal_component_set_last_modified (comp, &last_modified);
 	
+	/* Check dtstart ,dtend and due's timezone, and convert it to local 
+	 * default timezone if the timezone is not in our builtin timezone
+	 * list */
+	cal_component_get_dtstart (comp, &dt);
+	if (dt.value && dt.tzid) {
+		zone = cal_backend_file_get_timezone ((CalBackend *)cbfile, dt.tzid);
+		if (!zone) {
+			default_zone = cal_backend_file_get_default_timezone ((CalBackend *)cbfile);
+			g_free ((char *)dt.tzid);
+			dt.tzid = g_strdup (icaltimezone_get_tzid (default_zone));
+			cal_component_set_dtstart (comp, &dt);
+		}
+	}
+	cal_component_free_datetime (&dt);
+
+	cal_component_get_dtend (comp, &dt);
+	if (dt.value && dt.tzid) {
+		zone = cal_backend_file_get_timezone ((CalBackend *)cbfile, dt.tzid);
+		if (!zone) {
+			default_zone = cal_backend_file_get_default_timezone ((CalBackend *)cbfile);
+			g_free ((char *)dt.tzid);
+			dt.tzid = g_strdup (icaltimezone_get_tzid (default_zone));
+			cal_component_set_dtend (comp, &dt);
+		}
+	}
+	cal_component_free_datetime (&dt);
+	 
+	cal_component_get_due (comp, &dt);
+	if (dt.value && dt.tzid) {
+		zone = cal_backend_file_get_timezone ((CalBackend *)cbfile, dt.tzid);
+		if (!zone) {
+			default_zone = cal_backend_file_get_default_timezone ((CalBackend *)cbfile);
+			g_free ((char *)dt.tzid);
+			dt.tzid = g_strdup (icaltimezone_get_tzid (default_zone));
+			cal_component_set_due (comp, &dt);
+		}
+	}
+	cal_component_free_datetime (&dt);
+	cal_component_abort_sequence (comp);
+	 
 	/* Remove any old version of the component. */
 	old_comp = lookup_component (cbfile, comp_uid);
 	if (old_comp)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]