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



Hi, Rodrigo and JRP,
    I just made a patch for HEAD. Please review it. I will change it if needed.
    Thanks!
       Harry

Harry Lu wrote:
Patch for 1.4 has been checked into 1.4 branch.
As for HEAD, per JPR's request, I wrote a mail to discuss this problem.
If there is a conclusion, I will made patch for HEAD.
Thanks!
    Harry
   

Rodrigo Moya wrote:
On Tue, 2003-11-18 at 06:43, Harry Lu wrote:
  
Rodrigo,
    What is your suggestions?  :)
    Thanks!
       Harry

    
looks ok, please commit to 1.4 branch. For HEAD you'll have to do
another patch, since the code has changed a bit.

Also, please send patches to the list :-)

cheers

  
Harry Lu wrote:
    
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 

        

Index: calendar//ChangeLog
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/ChangeLog,v
retrieving revision 1.24
diff -u -r1.24 ChangeLog
--- calendar//ChangeLog	18 Nov 2003 14:57:39 -0000	1.24
+++ calendar//ChangeLog	19 Nov 2003 05:59:08 -0000
@@ -1,3 +1,14 @@
+2003-11-19  Harry Lu  <harry lu sun com>
+
+	* backends/file/e-cal-backend-file.c:
+	(e_cal_backend_file_internal_get_default_timezone): move to the front
+	to avoid a compile warning.
+	(e_cal_backend_file_internal_get_timezone): ditto.
+	(e_cal_backend_file_fix_tzid): If the component's timezone is not 
+	included in buildin timezone list, convert it to local default timezone.
+	(e_cal_backend_file_create_object): call e_cal_backend_file_fix_tzid().
+	(e_cal_backend_file_modify_object): ditto.
+
 2003-11-18  Rodrigo Moya <rodrigo ximian com>
 
 	* backends/groupwise/e-gw-connection.h: fixed typo.
Index: calendar//backends/file/e-cal-backend-file.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/calendar/backends/file/e-cal-backend-file.c,v
retrieving revision 1.3
diff -u -r1.3 e-cal-backend-file.c
--- calendar//backends/file/e-cal-backend-file.c	6 Nov 2003 15:50:15 -0000	1.3
+++ calendar//backends/file/e-cal-backend-file.c	19 Nov 2003 05:59:09 -0000
@@ -1485,6 +1485,92 @@
 	return GNOME_Evolution_Calendar_Success;
 }
 
+static icaltimezone *
+e_cal_backend_file_internal_get_default_timezone (ECalBackend *backend)
+{
+	ECalBackendFile *cbfile;
+	ECalBackendFilePrivate *priv;
+
+	cbfile = E_CAL_BACKEND_FILE (backend);
+	priv = cbfile->priv;
+
+	g_return_val_if_fail (priv->icalcomp != NULL, NULL);
+
+	return priv->default_zone;
+}
+
+static icaltimezone *
+e_cal_backend_file_internal_get_timezone (ECalBackend *backend, const char *tzid)
+{
+	ECalBackendFile *cbfile;
+	ECalBackendFilePrivate *priv;
+	icaltimezone *zone;
+
+	cbfile = E_CAL_BACKEND_FILE (backend);
+	priv = cbfile->priv;
+
+	g_return_val_if_fail (priv->icalcomp != NULL, NULL);
+
+	if (!strcmp (tzid, "UTC"))
+	        zone = icaltimezone_get_utc_timezone ();
+	else {
+		zone = icalcomponent_get_timezone (priv->icalcomp, tzid);
+		if (!zone)
+			zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
+	}
+
+	return zone;
+}
+
+static void
+e_cal_backend_file_fix_tzid (ECalBackendFile *cbfile, ECalComponent *comp)
+{
+	ECalComponentDateTime dt;
+	icaltimezone *zone, *default_zone;
+
+	/* Check dtstart, dtend and due's timezone, and convert it to local 
+	 * default timezone if the timezone is not in our builtin timezone
+	 * list */
+	e_cal_component_get_dtstart (comp, &dt);
+	if (dt.value && dt.tzid) {
+		zone = e_cal_backend_file_internal_get_timezone ((ECalBackend *)cbfile, dt.tzid);
+		if (!zone) {
+			default_zone = e_cal_backend_file_internal_get_default_timezone ((ECalBackend *)cbfile);
+			g_free ((char *)dt.tzid);
+			dt.tzid = g_strdup (icaltimezone_get_tzid (default_zone));
+			e_cal_component_set_dtstart (comp, &dt);
+		}
+	}
+	e_cal_component_free_datetime (&dt);
+
+	e_cal_component_get_dtend (comp, &dt);
+	if (dt.value && dt.tzid) {
+		zone = e_cal_backend_file_internal_get_timezone ((ECalBackend *)cbfile, dt.tzid);
+		if (!zone) {
+			default_zone = e_cal_backend_file_internal_get_default_timezone ((ECalBackend *)cbfile);
+			g_free ((char *)dt.tzid);
+			dt.tzid = g_strdup (icaltimezone_get_tzid (default_zone));
+			e_cal_component_set_dtend (comp, &dt);
+		}
+	}
+	e_cal_component_free_datetime (&dt);
+	 
+	e_cal_component_get_due (comp, &dt);
+	if (dt.value && dt.tzid) {
+		zone = e_cal_backend_file_internal_get_timezone ((ECalBackend *)cbfile, dt.tzid);
+		if (!zone) {
+			default_zone = e_cal_backend_file_internal_get_default_timezone ((ECalBackend *)cbfile);
+			g_free ((char *)dt.tzid);
+			dt.tzid = g_strdup (icaltimezone_get_tzid (default_zone));
+			e_cal_component_set_due (comp, &dt);
+		}
+	}
+	e_cal_component_free_datetime (&dt);
+	e_cal_component_abort_sequence (comp);
+
+}	
+
+
 static ECalBackendSyncStatus
 e_cal_backend_file_create_object (ECalBackendSync *backend, EDataCal *cal, const char *calobj, char **uid)
 {
@@ -1531,6 +1617,9 @@
 	e_cal_component_set_created (comp, &current);
 	e_cal_component_set_last_modified (comp, &current);
 
+	/* Fix the tzid if needed */
+	e_cal_backend_file_fix_tzid (cbfile, comp);
+
 	/* Add the object */
 	add_component (cbfile, comp, TRUE);
 
@@ -1592,6 +1681,9 @@
 	current = icaltime_from_timet (time (NULL), 0);
 	e_cal_component_set_last_modified (comp, &current);
 
+	/* Fix the tzid if needed */
+	e_cal_backend_file_fix_tzid (cbfile, comp);
+
 	/* handle mod_type */
 	switch (mod) {
 	case CALOBJ_MOD_THIS :
@@ -1981,43 +2073,6 @@
 	/* FIXME Put in a util routine to send stuff via email */
 	
 	return GNOME_Evolution_Calendar_Success;
-}
-
-static icaltimezone *
-e_cal_backend_file_internal_get_default_timezone (ECalBackend *backend)
-{
-	ECalBackendFile *cbfile;
-	ECalBackendFilePrivate *priv;
-
-	cbfile = E_CAL_BACKEND_FILE (backend);
-	priv = cbfile->priv;
-
-	g_return_val_if_fail (priv->icalcomp != NULL, NULL);
-
-	return priv->default_zone;
-}
-
-static icaltimezone *
-e_cal_backend_file_internal_get_timezone (ECalBackend *backend, const char *tzid)
-{
-	ECalBackendFile *cbfile;
-	ECalBackendFilePrivate *priv;
-	icaltimezone *zone;
-
-	cbfile = E_CAL_BACKEND_FILE (backend);
-	priv = cbfile->priv;
-
-	g_return_val_if_fail (priv->icalcomp != NULL, NULL);
-
-	if (!strcmp (tzid, "UTC"))
-	        zone = icaltimezone_get_utc_timezone ();
-	else {
-		zone = icalcomponent_get_timezone (priv->icalcomp, tzid);
-		if (!zone)
-			zone = icaltimezone_get_builtin_timezone_from_tzid (tzid);
-	}
-
-	return zone;
 }
 
 /* Object initialization function for the file backend */


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