aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChenthill Palanisamy <pchen@src.gnome.org>2007-02-21 02:10:26 +0800
committerChenthill Palanisamy <pchen@src.gnome.org>2007-02-21 02:10:26 +0800
commit14da7a959fe99ea2d2c3d6d5e1c435537a1e0155 (patch)
treede39a3956a2300cf5747311a4bf9c16ae2c9b3c3
parent8944db28d709a7f97f914be9df94c9dfb75b7546 (diff)
downloadgsoc2013-evolution-14da7a959fe99ea2d2c3d6d5e1c435537a1e0155.tar
gsoc2013-evolution-14da7a959fe99ea2d2c3d6d5e1c435537a1e0155.tar.gz
gsoc2013-evolution-14da7a959fe99ea2d2c3d6d5e1c435537a1e0155.tar.bz2
gsoc2013-evolution-14da7a959fe99ea2d2c3d6d5e1c435537a1e0155.tar.lz
gsoc2013-evolution-14da7a959fe99ea2d2c3d6d5e1c435537a1e0155.tar.xz
gsoc2013-evolution-14da7a959fe99ea2d2c3d6d5e1c435537a1e0155.tar.zst
gsoc2013-evolution-14da7a959fe99ea2d2c3d6d5e1c435537a1e0155.zip
Add the timezone information while exporting the calendars.
svn path=/trunk/; revision=33230
-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);