|
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:
|
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, ¤t);
e_cal_component_set_last_modified (comp, ¤t);
+ /* 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, ¤t);
+ /* 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 */