From 83cbc862e6981bd06b406a0ae01e50d15a3502e7 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Wed, 2 Aug 2000 22:15:22 +0000 Subject: New files for the iCalendar file backend. 2000-08-02 Federico Mena Quintero * pcs/cal-backend-file.[ch]: New files for the iCalendar file backend. * pcs/Makefile.am (libpcs_a_SOURCES): Added cal-backend-file.[ch]. * cal-util/cal-component.c (cal_component_set_icalcomponent): Return an operation success code for if we are passed a component of a type we don't support. svn path=/trunk/; revision=4479 --- calendar/cal-util/cal-component.c | 33 ++++++++++++++++++++++++++------- calendar/cal-util/cal-component.h | 2 +- 2 files changed, 27 insertions(+), 8 deletions(-) (limited to 'calendar/cal-util') diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index e8b1adb96c..b697b60389 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -652,29 +652,48 @@ cal_component_set_new_vtype (CalComponent *comp, CalComponentVType type) * structure. If the @comp already had an #icalcomponent set into it, it will * will be freed automatically if the #icalcomponent does not have a parent * component itself. + * + * Supported component types are VEVENT, VTODO, VJOURNAL, VFREEBUSY, and VTIMEZONE. + * + * Return value: TRUE on success, FALSE if @icalcomp is an unsupported component + * type. **/ -void +gboolean cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp) { CalComponentPrivate *priv; + icalcomponent_kind kind; - g_return_if_fail (comp != NULL); - g_return_if_fail (IS_CAL_COMPONENT (comp)); + g_return_val_if_fail (comp != NULL, FALSE); + g_return_val_if_fail (IS_CAL_COMPONENT (comp), FALSE); priv = comp->priv; if (priv->icalcomp == icalcomp) - return; + return TRUE; free_icalcomponent (comp); - priv->icalcomp = icalcomp; + if (!icalcomp) { + priv->icalcomp = NULL; + return TRUE; + } - if (!icalcomp) - return; + kind = icalcomponent_isa (icalcomp); + + if (!(kind == ICAL_VEVENT_COMPONENT + || kind == ICAL_VTODO_COMPONENT + || kind == ICAL_VJOURNAL_COMPONENT + || kind == ICAL_VFREEBUSY_COMPONENT + || kind == ICAL_VTIMEZONE_COMPONENT)) + return FALSE; + + priv->icalcomp = icalcomp; scan_icalcomponent (comp); ensure_mandatory_properties (comp); + + return TRUE; } /** diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index c09c73d5bb..38b9e60aed 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -128,7 +128,7 @@ CalComponent *cal_component_new (void); void cal_component_set_new_vtype (CalComponent *comp, CalComponentVType type); -void cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp); +gboolean cal_component_set_icalcomponent (CalComponent *comp, icalcomponent *icalcomp); icalcomponent *cal_component_get_icalcomponent (CalComponent *comp); CalComponentVType cal_component_get_vtype (CalComponent *comp); -- cgit v1.2.3