copy the TZID just in case the property we got it from gets modified.

2001-07-30  Damon Chaplin  <damon@ximian.com>

	* src/libical/icalcomponent.c (icalcomponent_merge_vtimezone): copy
	the TZID just in case the property we got it from gets modified.
	(icalcomponent_rename_tzids_callback): break out of the loop if we
	have renamed the TZID parameter. Otherwise our tzid variable would be
	invalid.

	* scripts/mkderivedproperties.pl (fudge_data): changed this so we can
	set EXDATEs that are DATE values, by checking the is_date field.
	I'm not entirely sure this is the way it should be done.
	If it is, I'll also do this for other things like DTSTART/DTEND.

	* src/libical/icalrecur.c (icalrecurrencetype_as_string): handle
	UNTIL as a DATE value as well as a DATE-TIME.

	* src/libical/icalcomponent.c (icalcomponent_compare_vtimezones):
	fixed stupid error, getting TZID property from wrong VTIMEZONE.
	This would only have affected iTIP stuff, with VTIMEZONEs that don't
	use the '/' prefix (i.e. from Outlook). It probably just meant we
	kept multiple copies of the same VTIMEZONE.

	* src/libical/icaltimezone.c: removed some debugging messages.

svn path=/trunk/; revision=11491
This commit is contained in:
Damon Chaplin
2001-07-30 21:31:43 +00:00
committed by Damon Chaplin
parent 1b595a7e2f
commit ddbf92b2ec
6 changed files with 71 additions and 22 deletions

View File

@ -1,3 +1,27 @@
2001-07-30 Damon Chaplin <damon@ximian.com>
* src/libical/icalcomponent.c (icalcomponent_merge_vtimezone): copy
the TZID just in case the property we got it from gets modified.
(icalcomponent_rename_tzids_callback): break out of the loop if we
have renamed the TZID parameter. Otherwise our tzid variable would be
invalid.
* scripts/mkderivedproperties.pl (fudge_data): changed this so we can
set EXDATEs that are DATE values, by checking the is_date field.
I'm not entirely sure this is the way it should be done.
If it is, I'll also do this for other things like DTSTART/DTEND.
* src/libical/icalrecur.c (icalrecurrencetype_as_string): handle
UNTIL as a DATE value as well as a DATE-TIME.
* src/libical/icalcomponent.c (icalcomponent_compare_vtimezones):
fixed stupid error, getting TZID property from wrong VTIMEZONE.
This would only have affected iTIP stuff, with VTIMEZONEs that don't
use the '/' prefix (i.e. from Outlook). It probably just meant we
kept multiple copies of the same VTIMEZONE.
* src/libical/icaltimezone.c: removed some debugging messages.
2001-07-26 JP Rosevear <jpr@ximian.com>
* src/libical/icalcomponent.c (icalcomponent_begin_component):

View File

@ -179,6 +179,24 @@ icalproperty* icalproperty_vanew_${lc}($type v, ...){
va_end(args);
return (icalproperty*)impl;
}
EOM
# Allow EXDATEs to take DATE values easily.
if ($lc eq "exdate") {
print<<EOM;
void icalproperty_set_${lc}(icalproperty* prop, $type v){
icalvalue *value;
$set_pointer_check
icalerror_check_arg_rv( (prop!=0),"prop");
if (v.is_date)
value = icalvalue_new_date(v);
else
value = icalvalue_new_datetime(v);
icalproperty_set_value(prop,value);
}
EOM
} else {
print<<EOM;
void icalproperty_set_${lc}(icalproperty* prop, $type v){
icalvalue *value;
$set_pointer_check
@ -186,6 +204,10 @@ void icalproperty_set_${lc}(icalproperty* prop, $type v){
value = icalvalue_new_${lcvalue}(v);
icalproperty_set_value(prop,value);
}
EOM
}
print<<EOM;
$type icalproperty_get_${lc}(icalproperty* prop){
icalvalue *value;
icalerror_check_arg( (prop!=0),"prop");

View File

@ -563,16 +563,12 @@ icalcomponent_add_component (icalcomponent* parent, icalcomponent* child)
icalerror_assert( (cimpl->parent ==0),"The child component has already been added to a parent component. Remove the component with icalcomponent_remove_component before calling icalcomponent_add_component");
fprintf (stderr, "In icalcomponent_add_component\n");
cimpl->parent = parent;
pvl_push(impl->components,child);
/* If the new component is a VTIMEZONE, add it to our array. */
if (cimpl->kind == ICAL_VTIMEZONE_COMPONENT) {
fprintf (stderr, " it is a VTIMEZONE component.\n");
/* FIXME: Currently we are also creating this array when loading in
a builtin VTIMEZONE, when we don't need it. */
if (!impl->timezones)
@ -582,9 +578,6 @@ icalcomponent_add_component (icalcomponent* parent, icalcomponent* child)
/* Flag that we need to sort it before doing any binary searches. */
impl->timezones_sorted = 0;
fprintf (stderr, " num timezones in array: %i\n",
impl->timezones->num_elements);
}
}
@ -1584,6 +1577,7 @@ static void icalcomponent_merge_vtimezone (icalcomponent *comp,
{
icalproperty *tzid_prop;
const char *tzid;
char *tzid_copy;
icaltimezone *existing_vtimezone;
/* Get the TZID of the VTIMEZONE. */
@ -1614,14 +1608,22 @@ static void icalcomponent_merge_vtimezone (icalcomponent *comp,
/* Now we have two VTIMEZONEs with the same TZID (which isn't a globally
unique one), so we compare the VTIMEZONE components to see if they are
the same. If they are, we don't need to do anything. */
if (icalcomponent_compare_vtimezones (existing_vtimezone, vtimezone))
the same. If they are, we don't need to do anything. We make a copy of
the tzid, since the parameter may get modified in these calls. */
tzid_copy = strdup (tzid);
if (!tzid_copy) {
icalerror_set_errno(ICAL_NEWFAILED_ERROR);
return;
/* FIXME: Handle possible NEWFAILED error. */
}
/* Now we have two different VTIMEZONEs with the same TZID. */
icalcomponent_handle_conflicting_vtimezones (comp, vtimezone, tzid_prop,
tzid, tzids_to_rename);
if (!icalcomponent_compare_vtimezones (existing_vtimezone, vtimezone)) {
/* FIXME: Handle possible NEWFAILED error. */
/* Now we have two different VTIMEZONEs with the same TZID. */
icalcomponent_handle_conflicting_vtimezones (comp, vtimezone, tzid_prop,
tzid_copy, tzids_to_rename);
}
free (tzid_copy);
}
@ -1745,8 +1747,10 @@ static void icalcomponent_rename_tzids_callback(icalparameter *param, void *data
/* Step through the rename table to see if the current TZID matches
any of the ones we want to rename. */
for (i = 0; i < rename_table->num_elements - 1; i += 2) {
if (!strcmp (tzid, icalarray_element_at (rename_table, i)))
if (!strcmp (tzid, icalarray_element_at (rename_table, i))) {
icalparameter_set_tzid (param, icalarray_element_at (rename_table, i + 1));
break;
}
}
}
@ -1813,13 +1817,10 @@ icaltimezone* icalcomponent_get_timezone(icalcomponent* comp, const char *tzid)
lower = middle = 0;
upper = impl->timezones->num_elements;
fprintf (stderr, "In icalcomponent_get_timezone (%i): %s\n", upper, tzid);
while (lower < upper) {
middle = (lower + upper) >> 1;
zone = icalarray_element_at (impl->timezones, middle);
zone_tzid = icaltimezone_get_tzid (zone);
fprintf (stderr, " comparing with: %s\n", zone_tzid);
cmp = strcmp (tzid, zone_tzid);
if (cmp == 0)
return zone;
@ -1871,7 +1872,7 @@ static int icalcomponent_compare_vtimezones (icalcomponent *vtimezone1,
return -1;
/* Get the TZID property of the second VTIMEZONE. */
prop2 = icalcomponent_get_first_property (vtimezone1, ICAL_TZID_PROPERTY);
prop2 = icalcomponent_get_first_property (vtimezone2, ICAL_TZID_PROPERTY);
if (!prop2)
return -1;

View File

@ -459,6 +459,7 @@ struct { char* str;size_t offset; short limit; } recurmap[] =
};
/* A private routine in icalvalue.c */
void print_date_to_string(char* str, struct icaltimetype *data);
void print_datetime_to_string(char* str, struct icaltimetype *data);
char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
@ -483,7 +484,10 @@ char* icalrecurrencetype_as_string(struct icalrecurrencetype *recur)
if(recur->until.year != 0){
temp[0] = 0;
print_datetime_to_string(temp,&(recur->until));
if (recur->until.is_date)
print_date_to_string(temp,&(recur->until));
else
print_datetime_to_string(temp,&(recur->until));
icalmemory_append_string(&str,&str_p,&buf_sz,";UNTIL=");
icalmemory_append_string(&str,&str_p,&buf_sz, temp);

View File

@ -1305,7 +1305,6 @@ icaltimezone_get_builtin_timezone (const char *location)
middle = (lower + upper) >> 1;
zone = icalarray_element_at (builtin_timezones, middle);
zone_location = icaltimezone_get_location (zone);
fprintf (stderr, " comparing with: %s\n", zone_location);
cmp = strcmp (location, zone_location);
if (cmp == 0)
return zone;
@ -1315,7 +1314,7 @@ icaltimezone_get_builtin_timezone (const char *location)
lower = middle + 1;
}
fprintf (stderr, " not found\n");
fprintf (stderr, " ***** not found\n");
return NULL;
}

View File

@ -805,7 +805,6 @@ void print_datetime_to_string(char* str, struct icaltimetype *data)
print_date_to_string(str,data);
strcat(str,"T");
print_time_to_string(str,data);
}
const char* icalvalue_datetime_as_ical_string(icalvalue* value) {