aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--plugins/save-calendar/ChangeLog7
-rw-r--r--plugins/save-calendar/ical-format.c47
2 files changed, 53 insertions, 1 deletions
diff --git a/plugins/save-calendar/ChangeLog b/plugins/save-calendar/ChangeLog
index 333bce30ae..4e19e4e72d 100644
--- a/plugins/save-calendar/ChangeLog
+++ b/plugins/save-calendar/ChangeLog
@@ -1,3 +1,10 @@
+2007-02-20 Chenthill Palanisamy <pchenthill@novell.com>
+
+ Fixes #238093 (bnc)
+ * ical-format.c: (insert_tz_comps), (append_tz_to_comp),
+ (do_save_calendar_ical): Add the timezone information while
+ exporting the calendars.
+
2006-08-17 Kjartan Maraas <kmaraas@gnome.org>
* rdf-format.c: (add_time_to_rdf): Plug a leak.
diff --git a/plugins/save-calendar/ical-format.c b/plugins/save-calendar/ical-format.c
index f4620b89a2..710fac9ce6 100644
--- a/plugins/save-calendar/ical-format.c
+++ b/plugins/save-calendar/ical-format.c
@@ -57,6 +57,41 @@ display_error_message (GtkWidget *parent, const char *message)
gtk_widget_destroy (dialog);
}
+typedef struct {
+ GHashTable *zones;
+ ECal *ecal;
+} CompTzData;
+
+static void
+insert_tz_comps (icalparameter *param, void *cb_data)
+{
+ const char *tzid;
+ CompTzData *tdata = cb_data;
+ icaltimezone *zone = NULL;
+ icalcomponent *tzcomp;
+ GError *error = NULL;
+
+ tzid = icalparameter_get_tzid (param);
+
+ if (g_hash_table_lookup (tdata->zones, tzid))
+ return;
+
+ if (!e_cal_get_timezone (tdata->ecal, tzid, &zone, &error)) {
+ g_warning ("Could not get the timezone information for %s : %s \n", tzid, error->message);
+ g_error_free (error);
+ return;
+ }
+
+ tzcomp = icalcomponent_new_clone (icaltimezone_get_component (zone));
+ g_hash_table_insert (tdata->zones, (gpointer) tzid, (gpointer) tzcomp);
+}
+
+static void
+append_tz_to_comp (gpointer key, gpointer value, icalcomponent *toplevel)
+{
+ icalcomponent_add_component (toplevel, (icalcomponent *) value);
+}
+
static void
do_save_calendar_ical (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSource *target, ECalSourceType type, char *dest_uri)
{
@@ -89,16 +124,26 @@ do_save_calendar_ical (FormatHandler *handler, EPlugin *ep, ECalPopupTargetSourc
if (e_cal_get_object_list (source_client, "#t", &objects, &error)) {
GnomeVFSResult result;
GnomeVFSHandle *handle;
+ CompTzData tdata;
+
+ tdata.zones = g_hash_table_new (g_str_hash, g_str_equal);
+ tdata.ecal = source_client;
while (objects != NULL) {
icalcomponent *icalcomp = objects->data;
-
+
+ icalcomponent_foreach_tzid (icalcomp, insert_tz_comps, &tdata);
icalcomponent_add_component (top_level, icalcomp);
/* remove item from the list */
objects = g_list_remove (objects, icalcomp);
}
+ g_hash_table_foreach (tdata.zones, (GHFunc) append_tz_to_comp, top_level);
+
+ g_hash_table_destroy (tdata.zones);
+ tdata.zones = NULL;
+
/* save the file */
uri = gnome_vfs_uri_new (dest_uri);