diff options
author | Federico Mena Quintero <federico@helixcode.com> | 2000-08-08 05:38:28 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2000-08-08 05:38:28 +0800 |
commit | 4de1f796a496703b01bcc0a8245030e4fbc378b8 (patch) | |
tree | 9817b8c5b886275946ae6aba5fc3b4f643ec82b4 /calendar/cal-util | |
parent | 3d4dc806bfa5832e7d91218b50512e672e377791 (diff) | |
download | gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.gz gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.bz2 gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.lz gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.xz gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.tar.zst gsoc2013-evolution-4de1f796a496703b01bcc0a8245030e4fbc378b8.zip |
Big sync. Disable calendar compilation for a few hours - Federico
2000-08-07 Federico Mena Quintero <federico@helixcode.com>
* cal-util/cal-component.c (cal_component_get_as_string): Doh,
libical owns the string's memory, so do not free it.
* cal-client/client-test.c (create_client): Connect to the destroy
signal of the client here.
* cal-client/test.ics: New test file, modified from Eric Busboom's
test file from RFC 2445.
2000-08-05 Federico Mena Quintero <federico@helixcode.com>
* cal-client/client-test.c (dump_component): This was gone for
some reason.
(main): Load a new test file.
2000-08-04 Federico Mena Quintero <federico@helixcode.com>
* cal-util/cal-component.c (cal_component_commit_sequence): New
function to commit changes to the SEQUENCE property.
(cal_component_get_as_string): Ensure that the sequence has been
committed.
* cal-client/cal-client.c (cal_client_get_object): Use
CalComponent instead of the old iCalObject.
(cal_client_update_object): Use iCalObject. Commit the SEQUENCE
property before stringifying the object and piping it over to the
Wombat.
svn path=/trunk/; revision=4585
Diffstat (limited to 'calendar/cal-util')
-rw-r--r-- | calendar/cal-util/cal-component.c | 56 | ||||
-rw-r--r-- | calendar/cal-util/cal-component.h | 2 | ||||
-rw-r--r-- | calendar/cal-util/cal-util.h | 3 |
3 files changed, 55 insertions, 6 deletions
diff --git a/calendar/cal-util/cal-component.c b/calendar/cal-util/cal-component.c index b697b60389..0020c7d727 100644 --- a/calendar/cal-util/cal-component.c +++ b/calendar/cal-util/cal-component.c @@ -766,7 +766,9 @@ cal_component_get_vtype (CalComponent *comp) * cal_component_get_as_string: * @comp: A calendar component. * - * Gets the iCalendar string representation of a calendar component. + * Gets the iCalendar string representation of a calendar component. You should + * call cal_component_commit_sequence() before this function to ensure that the + * component's sequence number is consistent with the state of the object. * * Return value: String representation of the calendar component according to * RFC 2445. @@ -783,20 +785,64 @@ cal_component_get_as_string (CalComponent *comp) priv = comp->priv; g_return_val_if_fail (priv->icalcomp != NULL, NULL); - /* Sigh, we dup and dup and dup and dup because of g_malloc() versus malloc()... */ + /* Ensure that the user has committed the new SEQUENCE */ + g_return_val_if_fail (priv->need_sequence_inc == FALSE, NULL); + + /* We dup the string; libical owns that memory */ str = icalcomponent_as_ical_string (priv->icalcomp); - if (str) { + if (str) buf = g_strdup (str); - free (str); - } else + else buf = NULL; return buf; } /** + * cal_component_commit_sequence: + * @comp: + * + * Increments the sequence number property in a calendar component object if it + * needs it. This needs to be done when any of a number of properties listed in + * RFC 2445 change values, such as the start and end dates of a component. + * + * This function must be called before calling cal_component_get_as_string() to + * ensure that the component is fully consistent. + **/ +void +cal_component_commit_sequence (CalComponent *comp) +{ + CalComponentPrivate *priv; + + g_return_if_fail (comp != NULL); + g_return_if_fail (IS_CAL_COMPONENT (comp)); + + priv = comp->priv; + g_return_if_fail (priv->icalcomp != NULL); + + if (!priv->need_sequence_inc) + return; + + if (priv->sequence) { + int seq; + + seq = icalproperty_get_sequence (priv->sequence); + icalproperty_set_sequence (priv->sequence, seq + 1); + } else { + /* The component had no SEQUENCE property, so assume that the + * default would have been zero. Since it needed incrementing + * anyways, we use a value of 1 here. + */ + priv->sequence = icalproperty_new_sequence (1); + icalcomponent_add_property (priv->icalcomp, priv->sequence); + } + + priv->need_sequence_inc = FALSE; +} + +/** * cal_component_get_uid: * @comp: A calendar component object. * @uid: Return value for the UID string. diff --git a/calendar/cal-util/cal-component.h b/calendar/cal-util/cal-component.h index 38b9e60aed..7c12d8a980 100644 --- a/calendar/cal-util/cal-component.h +++ b/calendar/cal-util/cal-component.h @@ -135,6 +135,8 @@ CalComponentVType cal_component_get_vtype (CalComponent *comp); char *cal_component_get_as_string (CalComponent *comp); +void cal_component_commit_sequence (CalComponent *comp); + void cal_component_get_uid (CalComponent *comp, const char **uid); void cal_component_set_uid (CalComponent *comp, const char *uid); diff --git a/calendar/cal-util/cal-util.h b/calendar/cal-util/cal-util.h index 2859a406b3..154f4c2ad5 100644 --- a/calendar/cal-util/cal-util.h +++ b/calendar/cal-util/cal-util.h @@ -25,7 +25,6 @@ #include <libgnome/gnome-defs.h> #include <time.h> #include <glib.h> -#include <cal-util/calobj.h> BEGIN_GNOME_DECLS @@ -45,7 +44,9 @@ void cal_obj_instance_list_free (GList *list); /* Instance of an alarm trigger */ typedef struct { char *uid; /* UID of object */ +#if 0 enum AlarmType type; /* Type of alarm */ +#endif time_t trigger; /* Alarm trigger time */ time_t occur; /* Occurrence time */ } CalAlarmInstance; |