From 84b566863ec2c8d462db645b19a871837e85c989 Mon Sep 17 00:00:00 2001 From: James Bottomley Date: Thu, 11 Aug 2011 13:46:11 +0200 Subject: Bug #655843 - Copy to calendar doesn't add timezone information --- modules/calendar/e-cal-shell-view-private.c | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'modules/calendar') diff --git a/modules/calendar/e-cal-shell-view-private.c b/modules/calendar/e-cal-shell-view-private.c index 0ca3f344ec..01ae23cc1c 100644 --- a/modules/calendar/e-cal-shell-view-private.c +++ b/modules/calendar/e-cal-shell-view-private.c @@ -821,6 +821,31 @@ e_cal_shell_view_set_status_message (ECalShellView *cal_shell_view, cal_shell_view->priv->calendar_activity = activity; } +struct ForeachTzidData +{ + ECalClient *source_client; + ECalClient *dest_client; +}; + +static void +add_timezone_to_cal_cb (icalparameter *param, gpointer data) +{ + struct ForeachTzidData *ftd = data; + icaltimezone *tz = NULL; + const gchar *tzid; + + g_return_if_fail (ftd != NULL); + g_return_if_fail (ftd->source_client != NULL); + g_return_if_fail (ftd->dest_client != NULL); + + tzid = icalparameter_get_tzid (param); + if (!tzid || !*tzid) + return; + + if (e_cal_client_get_timezone_sync (ftd->source_client, tzid, &tz, NULL, NULL) && tz) + e_cal_client_add_timezone_sync (ftd->dest_client, tz, NULL, NULL); +} + void e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, ECalendarViewEvent *event, @@ -863,6 +888,10 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, icalproperty *icalprop; gchar *new_uid; GError *error = NULL; + struct ForeachTzidData ftd; + + ftd.source_client = event->comp_data->client; + ftd.dest_client = destination_client; if (e_cal_util_component_is_instance (icalcomp_event)) { success = e_cal_client_get_object_sync ( @@ -904,6 +933,7 @@ e_cal_shell_view_transfer_item_to (ECalShellView *cal_shell_view, } new_uid = NULL; + icalcomponent_foreach_tzid (icalcomp_clone, add_timezone_to_cal_cb, &ftd); success = e_cal_client_create_object_sync ( destination_client, icalcomp_clone, &new_uid, NULL, &error); if (!success) { -- cgit v1.2.3