diff options
author | Rodrigo Moya <rodrigo@ximian.com> | 2002-07-27 00:32:33 +0800 |
---|---|---|
committer | Rodrigo Moya <rodrigo@src.gnome.org> | 2002-07-27 00:32:33 +0800 |
commit | e40b1868be45996f361fce9c1ea30dacd03306b2 (patch) | |
tree | 0463640cbb4c87e65c99c78ab80038e5b03768d0 /calendar/cal-util | |
parent | 6651d98ae36bc2565d5d6bb6914dc397278e00fd (diff) | |
download | gsoc2013-evolution-e40b1868be45996f361fce9c1ea30dacd03306b2.tar.gz gsoc2013-evolution-e40b1868be45996f361fce9c1ea30dacd03306b2.tar.zst gsoc2013-evolution-e40b1868be45996f361fce9c1ea30dacd03306b2.zip |
new function for adding VTIMEZONE components to a VCALENDAR component.
2002-07-26 Rodrigo Moya <rodrigo@ximian.com>
* cal-util/cal-util.[ch] (cal_util_add_timezones_from_component):
new function for adding VTIMEZONE components to a VCALENDAR
component.
* gui/e-calendar-table.c (copy_row_cb): added VTIMEZONE components
to resulting VCALENDAR top-level component.
* gui/e-week-view.c (e_week_view_copy_clipboard): copy to the
clipboard a top-level VCALENDAR component, with all the needed
VTIMEZONE components.
(e_week_view_on_copy): likewise.
* gui/e-day-view.c (e_day_view_copy_clipboard): likewise.
(e_day_view_on_copy): likewise.
svn path=/trunk/; revision=17604
Diffstat (limited to 'calendar/cal-util')
-rw-r--r-- | calendar/cal-util/cal-util.c | 55 | ||||
-rw-r--r-- | calendar/cal-util/cal-util.h | 2 |
2 files changed, 57 insertions, 0 deletions
diff --git a/calendar/cal-util/cal-util.c b/calendar/cal-util/cal-util.c index 8ba1ff7d63..d4a86e1a8f 100644 --- a/calendar/cal-util/cal-util.c +++ b/calendar/cal-util/cal-util.c @@ -558,3 +558,58 @@ cal_util_expand_uri (char *uri, gboolean tasks) return file_uri; } + +/* callback for icalcomponent_foreach_tzid */ +typedef struct { + icalcomponent *vcal_comp; + CalComponent *comp; +} ForeachTzidData; + +static void +add_timezone_cb (icalparameter *param, void *data) +{ + icaltimezone *tz; + const char *tzid; + icalcomponent *vtz_comp; + ForeachTzidData *f_data = (ForeachTzidData *) data; + + tzid = icalparameter_get_tzid (param); + if (!tzid) + return; + + tz = icalcomponent_get_timezone (f_data->vcal_comp, tzid); + if (tz) + return; + + tz = icalcomponent_get_timezone (cal_component_get_icalcomponent (f_data->comp), + tzid); + if (!tz) { + tz = icaltimezone_get_builtin_timezone_from_tzid (tzid); + if (!tz) + return; + } + + vtz_comp = icaltimezone_get_component (tz); + if (!vtz_comp) + return; + + icalcomponent_add_component (f_data->vcal_comp, + icalcomponent_new_clone (vtz_comp)); +} + +/* Adds VTIMEZONE components to a VCALENDAR for all tzid's + * in the given CalComponent. */ +void +cal_util_add_timezones_from_component (icalcomponent *vcal_comp, + CalComponent *comp) +{ + ForeachTzidData f_data; + + g_return_if_fail (vcal_comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + + f_data.vcal_comp = vcal_comp; + f_data.comp = comp; + icalcomponent_foreach_tzid (cal_component_get_icalcomponent (comp), + add_timezone_cb, &f_data); +} diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h index d4ccfb5388..e1afc1c3a0 100644 --- a/calendar/cal-util/cal-util.h +++ b/calendar/cal-util/cal-util.h @@ -85,6 +85,8 @@ int cal_util_priority_from_string (const char *string); char *cal_util_expand_uri (char *uri, gboolean tasks); +void cal_util_add_timezones_from_component (icalcomponent *vcal_comp, + CalComponent *comp); END_GNOME_DECLS |