From 3799134926a1db309a2b46706d8a33581999f778 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Thu, 14 May 1998 23:12:10 +0000 Subject: Do not add the spurious padding. 1998-05-14 Miguel de Icaza * timeutil.c (isodate_from_time_t): Do not add the spurious padding. * calobj.c (store_date_list): Bug fix: I was using the wrong pointer when saving the exception date list. (set_date_list): Bug fix: load correctly the complete exception date list. (set_date_list): Use ',' for the exception date separator as the versit people can not get their standard right. * gncal-full-day.c (unrecur_appointment): Support for making an existing recurrent event `movable' for a day. * calobj.c (ical_object_add_exdate): New routine, used to add exception dates. (ical_object_duplicate): New routine: used to do the magic recur->no-recur event. svn path=/trunk/; revision=214 --- calendar/pcs/calobj.c | 48 +++++++++++++++++++++++++++++++++++++++++++----- calendar/pcs/calobj.h | 2 ++ 2 files changed, 45 insertions(+), 5 deletions(-) (limited to 'calendar/pcs') diff --git a/calendar/pcs/calobj.c b/calendar/pcs/calobj.c index f3cf23e78d..7b9b42b716 100644 --- a/calendar/pcs/calobj.c +++ b/calendar/pcs/calobj.c @@ -92,6 +92,7 @@ ical_object_destroy (iCalObject *ico) free_if_defined (ico->status); free_if_defined (ico->class); free_if_defined (ico->url); + free_if_defined (ico->recur); /* Lists */ lfree_if_defined (ico->exdate); @@ -127,15 +128,26 @@ set_date_list (char *str) GList *list = 0; char *s; - for (s = strtok (str, ";"); s; s = strtok (NULL, ";")){ + for (s = strtok (str, ";,"); s; s = strtok (NULL, ";,")){ time_t *t = g_new (time_t, 1); + while (*s && isspace (*s)) + s++; *t = time_from_isodate (s); list = g_list_prepend (list, t); } return list; } +void +ical_object_add_exdate (iCalObject *o, time_t t) +{ + time_t *pt = g_new (time_t, 1); + + *pt = t; + o->exdate = g_list_prepend (o->exdate, pt); +} + static void ignore_space(char **str) { @@ -455,6 +467,31 @@ setup_alarm_at (iCalObject *ico, CalendarAlarm *alarm, char *iso_time, VObject * } } +/* + * Duplicates an iCalObject. Implementation is a grand hack + */ +iCalObject * +ical_object_duplicate (iCalObject *o) +{ + VObject *vo; + iCalObject *new; + + vo = ical_object_to_vobject (o); + switch (o->type){ + case ICAL_EVENT: + new = ical_object_create_from_vobject (vo, VCEventProp); + break; + case ICAL_TODO: + new = ical_object_create_from_vobject (vo, VCTodoProp); + break; + default: + new = NULL; + } + + cleanVObject (vo); + return new; +} + /* FIXME: we need to load the recurrence properties */ iCalObject * ical_object_create_from_vobject (VObject *o, const char *object_name) @@ -716,7 +753,7 @@ static void store_date_list (VObject *o, char *prop, GList *values) { GList *l; - int size; + int size, len; char *s, *p; size = g_list_length (values); @@ -724,12 +761,13 @@ store_date_list (VObject *o, char *prop, GList *values) for (l = values; l; l = l->next){ strcpy (s, isodate_from_time_t (*(time_t *)l->data)); - s [16] = ';'; - s += 17; + len = strlen (s); + s [len] = ','; + s += len + 1; } s--; *s = 0; - addPropValue (o, prop, s); + addPropValue (o, prop, p); g_free (p); } diff --git a/calendar/pcs/calobj.h b/calendar/pcs/calobj.h index 12b7578f10..d18acd4f8a 100644 --- a/calendar/pcs/calobj.h +++ b/calendar/pcs/calobj.h @@ -182,8 +182,10 @@ iCalObject *ical_object_new (void); void ical_object_destroy (iCalObject *ico); iCalObject *ical_object_create_from_vobject (VObject *obj, const char *object_name); VObject *ical_object_to_vobject (iCalObject *ical); +iCalObject *ical_object_duplicate (iCalObject *o); void ical_foreach (GList *events, calendarfn fn, void *closure); void ical_object_generate_events (iCalObject *ico, time_t start, time_t end, calendarfn cb, void *closure); +void ical_object_add_exdate (iCalObject *o, time_t t); /* Computes the enddate field of the recurrence based on the duration */ void ical_object_compute_end (iCalObject *ico); -- cgit v1.2.3