[libgdata] Improved time handling for GDataCalendarEvent



commit da63cd5a60953a4e14990be483c29f99d2fd5dbb
Author: Philip Withnall <philip tecnocode co uk>
Date:   Wed Apr 22 21:18:12 2009 +0100

    Improved time handling for GDataCalendarEvent
    
    GDataCalendarEvent now fully supports multiple times, with the new
    GDataGDWhen struct. Reminders are not yet supported, but the fields exist
    for them in the structs.
---
 docs/reference/gdata-sections.txt              |    6 +
 gdata/gdata-gdata.c                            |  112 ++++++++++++++
 gdata/gdata-gdata.h                            |   50 +++++++
 gdata/gdata.symbols                            |   12 +-
 gdata/services/calendar/gdata-calendar-event.c |  188 +++++++-----------------
 gdata/services/calendar/gdata-calendar-event.h |    8 +-
 gdata/tests/calendar.c                         |    5 +-
 7 files changed, 234 insertions(+), 147 deletions(-)

diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 36dfa74..30ac7ed 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -195,6 +195,12 @@ gdata_gd_postal_address_free
 GDataGDRating
 gdata_gd_rating_new
 gdata_gd_rating_free
+GDataGDWhen
+gdata_gd_when_new
+gdata_gd_when_free
+GDataGDReminder
+gdata_gd_reminder_new
+gdata_gd_reminder_free
 GDataGDWhere
 gdata_gd_where_new
 gdata_gd_where_free
diff --git a/gdata/gdata-gdata.c b/gdata/gdata-gdata.c
index a16b476..e9c4833 100644
--- a/gdata/gdata-gdata.c
+++ b/gdata/gdata-gdata.c
@@ -116,6 +116,62 @@ gdata_gd_feed_link_free (GDataGDFeedLink *self)
 }
 
 /**
+ * gdata_gd_when_new:
+ * @start_time: when the event starts or (for zero-duration events) when it occurs
+ * @end_time: when the event ends, or %NULL
+ * @value_string: a string to represent the time period, or %NULL
+ * @reminders: a #GList of #GDataGDReminder<!-- -->s for the time period, or %NULL
+ *
+ * Creates a new #GDataGDWhen. More information is available in the <ulink type="http"
+ * url="http://code.google.com/apis/gdata/elements.html#gdWhen";>GData specification</ulink>.
+ *
+ * This function takes ownership of @reminders, so the list (or its entries) must not be freed
+ * by the caller after a call to gdata_gd_when_new has finished.
+ *
+ * Return value: a new #GDataGDWhen, or %NULL on error
+ **/
+GDataGDWhen *
+gdata_gd_when_new (GTimeVal *start_time, GTimeVal *end_time, const gchar *value_string, GList *reminders)
+{
+	GDataGDWhen *self;
+
+	g_return_val_if_fail (start_time != NULL, NULL);
+
+	self = g_slice_new (GDataGDWhen);
+
+	self->start_time = *start_time;
+	if (end_time != NULL) {
+		self->end_time = *end_time;
+	} else {
+		self->end_time.tv_sec = 0;
+		self->end_time.tv_usec = 0;
+	}
+
+	self->value_string = g_strdup (value_string);
+	self->reminders = reminders;
+
+	return self;
+}
+
+/**
+ * gdata_gd_when_free:
+ * @self: a #GDataGDWhen
+ *
+ * Frees a #GDataGDWhen.
+ **/
+void
+gdata_gd_when_free (GDataGDWhen *self)
+{
+	if (G_UNLIKELY (self == NULL))
+		return;
+
+	g_free (self->value_string);
+	g_list_foreach (self->reminders, (GFunc) gdata_gd_reminder_free, NULL);
+	g_list_free (self->reminders);
+	g_slice_free (GDataGDWhen, self);
+}
+
+/**
  * gdata_gd_who_new:
  * @rel: the relationship between the item and this person, or %NULL
  * @value_string: a string to represent the person, or %NULL
@@ -427,3 +483,59 @@ gdata_gd_organization_free (GDataGDOrganization *self)
 	g_free (self->label);
 	g_slice_free (GDataGDOrganization, self);
 }
+
+/**
+ * gdata_gd_reminder_new:
+ * @method: the notification method the reminder should use, or %NULL
+ * @absolute_time: the absolute time for the reminder, or %NULL
+ * @days: number of days before the event's start time for the reminder, or %-1
+ * @hours: number of hours before the event's start time for the reminder, or %-1
+ * @minutes: number of minutes before the event's start time for the reminder, or %-1
+ *
+ * Creates a new #GDataGDReminder. More information is available in the <ulink type="http"
+ * url="http://code.google.com/apis/gdata/elements.html#gdReminder";>GData specification</ulink>.
+ *
+ * Return value: a new #GDataGDReminder, or %NULL on error
+ **/
+GDataGDReminder *
+gdata_gd_reminder_new (const gchar *method, GTimeVal *absolute_time, gint days, gint hours, gint minutes)
+{
+	GDataGDReminder *self;
+
+	g_return_val_if_fail (absolute_time != NULL && (days != -1 || hours != -1 || minutes != -1), NULL);
+	g_return_val_if_fail (days != -1 && (hours != -1 || minutes != -1), NULL);
+	g_return_val_if_fail (hours != -1 && (minutes != -1 || days != -1), NULL);
+	g_return_val_if_fail (minutes != -1 && (days != -1 || hours != -1), NULL);
+
+	self = g_slice_new (GDataGDReminder);
+
+	if (absolute_time != NULL) {
+		self->absolute_time = *absolute_time;
+	} else {
+		self->absolute_time.tv_sec = 0;
+		self->absolute_time.tv_usec = 0;
+	}
+
+	self->method = g_strdup (method);
+	self->days = days;
+	self->hours = hours;
+	self->minutes = minutes;
+
+	return self;
+}
+
+/**
+ * gdata_gd_reminder_free:
+ * @self: a #GDataGDReminder
+ *
+ * Frees a #GDataGDReminder.
+ **/
+void
+gdata_gd_reminder_free (GDataGDReminder *self)
+{
+	if (G_UNLIKELY (self == NULL))
+		return;
+
+	g_free (self->method);
+	g_slice_free (GDataGDReminder, self);
+}
diff --git a/gdata/gdata-gdata.h b/gdata/gdata-gdata.h
index dcb084b..a7372fe 100644
--- a/gdata/gdata-gdata.h
+++ b/gdata/gdata-gdata.h
@@ -72,6 +72,31 @@ GDataGDFeedLink *gdata_gd_feed_link_new (const gchar *href, const gchar *rel, gu
 void gdata_gd_feed_link_free (GDataGDFeedLink *self);
 
 /**
+ * GDataGDWhen:
+ * @start_time: when the event starts or (for zero-duration events) when it occurs
+ * @end_time: when the event ends
+ * @value_string: a string to represent the time period, or %NULL
+ * @reminders: a #GList of #GDataGDReminder<!-- -->s for the time period, or %NULL
+ *
+ * A structure fully representing a GData "when" element. The @start_time field is required, but the others are optional.
+ *
+ * If @end_time is empty (all fields are zero), the structure is considered to represent: an instance in time if
+ * @start_time is a time, or an entire day if @start_time is a date.
+ *
+ * See the <ulink type="http" url="http://code.google.com/apis/gdata/elements.html#gdWhen";>GData specification</ulink>
+ * for more information.
+ **/
+typedef struct {
+	GTimeVal start_time;
+	GTimeVal end_time;
+	gchar *value_string;
+	GList *reminders;
+} GDataGDWhen;
+
+GDataGDWhen *gdata_gd_when_new (GTimeVal *start_time, GTimeVal *end_time, const gchar *value_string, GList *reminders);
+void gdata_gd_when_free (GDataGDWhen *self);
+
+/**
  * GDataGDWho:
  * @rel: the relationship between the item and this person, or %NULL
  * @value_string: a string to represent the person, or %NULL
@@ -241,6 +266,31 @@ GDataGDOrganization *gdata_gd_organization_new (const gchar *name, const gchar *
 						const gchar *label, gboolean primary) G_GNUC_WARN_UNUSED_RESULT;
 void gdata_gd_organization_free (GDataGDOrganization *self);
 
+/**
+ * GDataGDReminder:
+ * @method: the notification method the reminder should use, or %NULL
+ * @absolute_time: the absolute time for the reminder, or %NULL
+ * @days: number of days before the event's start time for the reminder, or %-1
+ * @hours: number of hours before the event's start time for the reminder, or %-1
+ * @minutes: number of minutes before the event's start time for the reminder, or %-1
+ *
+ * A structure fully representing a GData "reminder" element. All fields are optional. The @days, @hours
+ * and @minutes fields are mutually exclusive with each other, and all mutually exclusive with @absolute_time.
+ *
+ * See the <ulink type="http" url="http://code.google.com/apis/gdata/elements.html#gdReminder";>GData specification</ulink>
+ * for more information.
+ **/
+typedef struct {
+	gchar *method;
+	GTimeVal absolute_time;
+	gint days;
+	gint hours;
+	gint minutes;
+} GDataGDReminder;
+
+GDataGDReminder *gdata_gd_reminder_new (const gchar *method, GTimeVal *absolute_time, gint days, gint hours, gint minutes);
+void gdata_gd_reminder_free (GDataGDReminder *self);
+
 G_END_DECLS
 
 #endif /* !GDATA_GDATA_H */
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 44de79a..cc9def5 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -184,12 +184,6 @@ gdata_calendar_event_get_uid
 gdata_calendar_event_set_uid
 gdata_calendar_event_get_sequence
 gdata_calendar_event_set_sequence
-gdata_calendar_event_get_start_time
-gdata_calendar_event_set_start_time
-gdata_calendar_event_get_end_time
-gdata_calendar_event_set_end_time
-gdata_calendar_event_get_when_value
-gdata_calendar_event_set_when_value
 gdata_calendar_event_get_guests_can_modify
 gdata_calendar_event_set_guests_can_modify
 gdata_calendar_event_get_guests_can_invite_others
@@ -202,6 +196,8 @@ gdata_calendar_event_add_person
 gdata_calendar_event_get_people
 gdata_calendar_event_add_place
 gdata_calendar_event_get_places
+gdata_calendar_event_add_time
+gdata_calendar_event_get_times
 gdata_calendar_query_get_type
 gdata_calendar_query_new
 gdata_calendar_query_new_with_limits
@@ -237,6 +233,8 @@ gdata_gd_rating_new
 gdata_gd_rating_free
 gdata_gd_feed_link_new
 gdata_gd_feed_link_free
+gdata_gd_when_new
+gdata_gd_when_free
 gdata_gd_who_new
 gdata_gd_who_free
 gdata_gd_where_new
@@ -251,6 +249,8 @@ gdata_gd_postal_address_new
 gdata_gd_postal_address_free
 gdata_gd_organization_new
 gdata_gd_organization_free
+gdata_gd_reminder_new
+gdata_gd_reminder_free
 gdata_media_expression_get_type
 gdata_parser_error_get_type
 gdata_parser_error_quark
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 216bb33..2a1fdb3 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -44,16 +44,14 @@ struct _GDataCalendarEventPrivate {
 	gchar *transparency;
 	gchar *uid;
 	guint sequence;
-	GTimeVal start_time;
-	GTimeVal end_time;
-	gchar *when_value;
+	GList *times; /* GDataGDWhen */
 	GList *reminders;
 	gboolean guests_can_modify; /* TODO: Merge these three somehow? */
 	gboolean guests_can_invite_others;
 	gboolean guests_can_see_guests;
 	gboolean anyone_can_add_self;
-	GList *people;
-	GList *places;
+	GList *people; /* GDataGDWho */
+	GList *places; /* GDataGDWhere */
 };
 
 enum {
@@ -63,9 +61,6 @@ enum {
 	PROP_TRANSPARENCY,
 	PROP_UID,
 	PROP_SEQUENCE,
-	PROP_START_TIME,
-	PROP_END_TIME,
-	PROP_WHEN_VALUE,
 	PROP_GUESTS_CAN_MODIFY,
 	PROP_GUESTS_CAN_INVITE_OTHERS,
 	PROP_GUESTS_CAN_SEE_GUESTS,
@@ -121,22 +116,6 @@ gdata_calendar_event_class_init (GDataCalendarEventClass *klass)
 					"Sequence", "TODO",
 					0, G_MAXUINT, 0,
 					G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-	g_object_class_install_property (gobject_class, PROP_START_TIME,
-				g_param_spec_boxed ("start-time",
-					"Start time", "TODO",
-					GDATA_TYPE_G_TIME_VAL,
-					G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-	g_object_class_install_property (gobject_class, PROP_END_TIME,
-				g_param_spec_boxed ("end-time",
-					"End time", "TODO",
-					GDATA_TYPE_G_TIME_VAL,
-					G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-	/* TODO: when-value is a stupid name */
-	g_object_class_install_property (gobject_class, PROP_WHEN_VALUE,
-				g_param_spec_string ("when-value",
-					"When value", "TODO",
-					NULL,
-					G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 	g_object_class_install_property (gobject_class, PROP_GUESTS_CAN_MODIFY,
 				g_param_spec_boolean ("guests-can-modify",
 					"Guests can modify", "TODO",
@@ -174,7 +153,8 @@ gdata_calendar_event_finalize (GObject *object)
 	g_free (priv->visibility);
 	g_free (priv->transparency);
 	g_free (priv->uid);
-	g_free (priv->when_value);
+	g_list_foreach (priv->times, (GFunc) gdata_gd_when_free, NULL);
+	g_list_free (priv->times);
 	g_list_foreach (priv->people, (GFunc) gdata_gd_who_free, NULL);
 	g_list_free (priv->people);
 	g_list_foreach (priv->places, (GFunc) gdata_gd_where_free, NULL);
@@ -208,15 +188,6 @@ gdata_calendar_event_get_property (GObject *object, guint property_id, GValue *v
 		case PROP_SEQUENCE:
 			g_value_set_uint (value, priv->sequence);
 			break;
-		case PROP_START_TIME:
-			g_value_set_boxed (value, &(priv->start_time));
-			break;
-		case PROP_END_TIME:
-			g_value_set_boxed (value, &(priv->end_time));
-			break;
-		case PROP_WHEN_VALUE:
-			g_value_set_string (value, priv->when_value);
-			break;
 		case PROP_GUESTS_CAN_MODIFY:
 			g_value_set_boolean (value, priv->guests_can_modify);
 			break;
@@ -260,15 +231,6 @@ gdata_calendar_event_set_property (GObject *object, guint property_id, const GVa
 		case PROP_SEQUENCE:
 			gdata_calendar_event_set_sequence (self, g_value_get_uint (value));
 			break;
-		case PROP_START_TIME:
-			gdata_calendar_event_set_start_time (self, g_value_get_boxed (value));
-			break;
-		case PROP_END_TIME:
-			gdata_calendar_event_set_end_time (self, g_value_get_boxed (value));
-			break;
-		case PROP_WHEN_VALUE:
-			gdata_calendar_event_set_when_value (self, g_value_get_string (value));
-			break;
 		case PROP_GUESTS_CAN_MODIFY:
 			gdata_calendar_event_set_guests_can_modify (self, g_value_get_boolean (value));
 			break;
@@ -393,8 +355,9 @@ parse_xml (GDataEntry *entry, xmlDoc *doc, xmlNode *node, GError **error)
 		gdata_calendar_event_set_sequence (self, value_uint);
 	} else if (xmlStrcmp (node->name, (xmlChar*) "when") == 0) {
 		/* gd:when */
-		xmlChar *start_time, *end_time, *value;
+		xmlChar *start_time, *end_time, *value_string;
 		GTimeVal start_time_timeval, end_time_timeval;
+		GDataGDWhen *when;
 
 		/* Start time */
 		start_time = xmlGetProp (node, (xmlChar*) "startTime");
@@ -405,13 +368,10 @@ parse_xml (GDataEntry *entry, xmlDoc *doc, xmlNode *node, GError **error)
 			return FALSE;
 		}
 		xmlFree (start_time);
-		gdata_calendar_event_set_start_time (self, &start_time_timeval);
 
 		/* End time (optional) */
 		end_time = xmlGetProp (node, (xmlChar*) "endTime");
-		if (end_time == NULL)
-			gdata_calendar_event_set_end_time (self, NULL);
-		else {
+		if (end_time != NULL) {
 			if (g_time_val_from_iso8601 ((gchar*) end_time, &end_time_timeval) == FALSE) {
 				/* Error */
 				gdata_parser_error_not_iso8601_format ("gd:when", "entry", (gchar*) end_time, error);
@@ -419,13 +379,13 @@ parse_xml (GDataEntry *entry, xmlDoc *doc, xmlNode *node, GError **error)
 				return FALSE;
 			}
 			xmlFree (end_time);
-			gdata_calendar_event_set_end_time (self, &end_time_timeval);
 		}
 
-		/* Value (optional) */
-		value = xmlGetProp (node, (xmlChar*) "value");
-		gdata_calendar_event_set_when_value (self, (gchar*) value);
-		xmlFree (value);
+		value_string = xmlGetProp (node, (xmlChar*) "value");
+		when = gdata_gd_when_new (&start_time_timeval, (end_time == NULL) ? NULL : &end_time_timeval, (gchar*) value_string, NULL);
+		xmlFree (value_string);
+
+		gdata_calendar_event_add_time (self, when);
 
 		/* TODO: Deal with reminders (<gd:reminder> child elements) */
 	} else if (xmlStrcmp (node->name, (xmlChar*) "guestsCanModify") == 0) {
@@ -500,7 +460,7 @@ static void
 get_xml (GDataEntry *entry, GString *xml_string)
 {
 	GDataCalendarEventPrivate *priv = GDATA_CALENDAR_EVENT (entry)->priv;
-	GList *person, *place;
+	GList *i;
 
 	/* Chain up to the parent class */
 	GDATA_ENTRY_CLASS (gdata_calendar_event_parent_class)->get_xml (entry, xml_string);
@@ -524,25 +484,6 @@ get_xml (GDataEntry *entry, GString *xml_string)
 	if (priv->sequence != 0)
 		g_string_append_printf (xml_string, "<gCal:sequence value='%u'/>", priv->sequence);
 
-	if (priv->start_time.tv_sec != 0 || priv->start_time.tv_usec != 0) {
-		gchar *start_time = g_time_val_to_iso8601 (&(priv->start_time));
-		g_string_append_printf (xml_string, "<gd:when startTime='%s'", start_time);
-		g_free (start_time);
-
-		if (priv->end_time.tv_sec != 0 || priv->end_time.tv_usec != 0) {
-			gchar *end_time = g_time_val_to_iso8601 (&(priv->end_time));
-			g_string_append_printf (xml_string, " endTime='%s'", end_time);
-			g_free (end_time);
-		}
-
-		if (priv->when_value != NULL)
-			g_string_append_printf (xml_string, " value='%s'", priv->when_value);
-
-		g_string_append (xml_string, "/>");
-
-		/* TODO: Deal with reminders (<gd:reminder> child elements) */
-	}
-
 	if (priv->guests_can_modify == TRUE)
 		g_string_append (xml_string, "<gCal:guestsCanModify value='true'/>");
 	else
@@ -563,8 +504,29 @@ get_xml (GDataEntry *entry, GString *xml_string)
 	else
 		g_string_append (xml_string, "<gCal:anyoneCanAddSelf value='false'/>");
 
-	for (person = priv->people; person != NULL; person = person->next) {
-		GDataGDWho *who = (GDataGDWho*) person->data;
+	for (i = priv->times; i != NULL; i = i->next) {
+		GDataGDWhen *when = (GDataGDWhen*) i->data;
+
+		gchar *start_time = g_time_val_to_iso8601 (&(when->start_time));
+		g_string_append_printf (xml_string, "<gd:when startTime='%s'", start_time);
+		g_free (start_time);
+
+		if (when->end_time.tv_sec != 0 || when->end_time.tv_usec != 0) {
+			gchar *end_time = g_time_val_to_iso8601 (&(when->end_time));
+			g_string_append_printf (xml_string, " endTime='%s'", end_time);
+			g_free (end_time);
+		}
+
+		if (when->value_string != NULL)
+			g_string_append_printf (xml_string, " value='%s'", when->value_string);
+
+		g_string_append (xml_string, "/>");
+
+		/* TODO: Deal with reminders (<gd:reminder> child elements) */
+	}
+
+	for (i = priv->people; i != NULL; i = i->next) {
+		GDataGDWho *who = (GDataGDWho*) i->data;
 
 		g_string_append (xml_string, "<gd:who");
 		if (who->email != NULL)
@@ -578,8 +540,8 @@ get_xml (GDataEntry *entry, GString *xml_string)
 		/* TODO: deal with the attendeeType, attendeeStatus and entryLink */
 	}
 
-	for (place = priv->places; place != NULL; place = place->next) {
-		GDataGDWhere *where = (GDataGDWhere*) place->data;
+	for (i = priv->places; i != NULL; i = i->next) {
+		GDataGDWhere *where = (GDataGDWhere*) i->data;
 
 		g_string_append (xml_string, "<gd:where");
 		if (where->label != NULL)
@@ -713,62 +675,6 @@ gdata_calendar_event_set_sequence (GDataCalendarEvent *self, guint sequence)
 	g_object_notify (G_OBJECT (self), "sequence");
 }
 
-void
-gdata_calendar_event_get_start_time (GDataCalendarEvent *self, GTimeVal *start_time)
-{
-	g_return_if_fail (GDATA_IS_CALENDAR_EVENT (self));
-	g_return_if_fail (start_time != NULL);
-	*start_time = self->priv->start_time;
-}
-
-void
-gdata_calendar_event_set_start_time (GDataCalendarEvent *self, GTimeVal *start_time)
-{
-	g_return_if_fail (GDATA_IS_CALENDAR_EVENT (self));
-	g_return_if_fail (start_time != NULL);
-	self->priv->start_time = *start_time;
-	g_object_notify (G_OBJECT (self), "start-time");
-}
-
-void
-gdata_calendar_event_get_end_time (GDataCalendarEvent *self, GTimeVal *end_time)
-{
-	g_return_if_fail (GDATA_IS_CALENDAR_EVENT (self));
-	g_return_if_fail (end_time != NULL);
-	*end_time = self->priv->end_time;
-}
-
-void
-gdata_calendar_event_set_end_time (GDataCalendarEvent *self, GTimeVal *end_time)
-{
-	g_return_if_fail (GDATA_IS_CALENDAR_EVENT (self));
-
-	if (end_time == NULL) {
-		self->priv->end_time.tv_sec = 0;
-		self->priv->end_time.tv_usec = 0;
-	} else {
-		self->priv->end_time = *end_time;
-	}
-	g_object_notify (G_OBJECT (self), "end-time");
-}
-
-const gchar *
-gdata_calendar_event_get_when_value (GDataCalendarEvent *self)
-{
-	g_return_val_if_fail (GDATA_IS_CALENDAR_EVENT (self), NULL);
-	return self->priv->when_value;
-}
-
-void
-gdata_calendar_event_set_when_value (GDataCalendarEvent *self, const gchar *when_value)
-{
-	g_return_if_fail (GDATA_IS_CALENDAR_EVENT (self));
-
-	g_free (self->priv->when_value);
-	self->priv->when_value = g_strdup (when_value);
-	g_object_notify (G_OBJECT (self), "when-value");
-}
-
 gboolean
 gdata_calendar_event_get_guests_can_modify (GDataCalendarEvent *self)
 {
@@ -860,3 +766,19 @@ gdata_calendar_event_get_places (GDataCalendarEvent *self)
 	g_return_val_if_fail (GDATA_IS_CALENDAR_EVENT (self), NULL);
 	return self->priv->places;
 }
+
+void
+gdata_calendar_event_add_time (GDataCalendarEvent *self, GDataGDWhen *when)
+{
+	g_return_if_fail (GDATA_IS_CALENDAR_EVENT (self));
+	g_return_if_fail (when != NULL);
+
+	self->priv->times = g_list_append (self->priv->times, when);
+}
+
+GList *
+gdata_calendar_event_get_times (GDataCalendarEvent *self)
+{
+	g_return_val_if_fail (GDATA_IS_CALENDAR_EVENT (self), NULL);
+	return self->priv->times;
+}
diff --git a/gdata/services/calendar/gdata-calendar-event.h b/gdata/services/calendar/gdata-calendar-event.h
index 1f00183..f0a0429 100644
--- a/gdata/services/calendar/gdata-calendar-event.h
+++ b/gdata/services/calendar/gdata-calendar-event.h
@@ -64,12 +64,6 @@ const gchar *gdata_calendar_event_get_uid (GDataCalendarEvent *self);
 void gdata_calendar_event_set_uid (GDataCalendarEvent *self, const gchar *uid);
 guint gdata_calendar_event_get_sequence (GDataCalendarEvent *self);
 void gdata_calendar_event_set_sequence (GDataCalendarEvent *self, guint sequence);
-void gdata_calendar_event_get_start_time (GDataCalendarEvent *self, GTimeVal *start_time);
-void gdata_calendar_event_set_start_time (GDataCalendarEvent *self, GTimeVal *start_time);
-void gdata_calendar_event_get_end_time (GDataCalendarEvent *self, GTimeVal *end_time);
-void gdata_calendar_event_set_end_time (GDataCalendarEvent *self, GTimeVal *end_time);
-const gchar *gdata_calendar_event_get_when_value (GDataCalendarEvent *self);
-void gdata_calendar_event_set_when_value (GDataCalendarEvent *self, const gchar *when_value);
 gboolean gdata_calendar_event_get_guests_can_modify (GDataCalendarEvent *self);
 void gdata_calendar_event_set_guests_can_modify (GDataCalendarEvent *self, gboolean guests_can_modify);
 gboolean gdata_calendar_event_get_guests_can_invite_others (GDataCalendarEvent *self);
@@ -82,6 +76,8 @@ void gdata_calendar_event_add_person (GDataCalendarEvent *self, GDataGDWho *who)
 GList *gdata_calendar_event_get_people (GDataCalendarEvent *self);
 void gdata_calendar_event_add_place (GDataCalendarEvent *self, GDataGDWhere *where);
 GList *gdata_calendar_event_get_places (GDataCalendarEvent *self);
+void gdata_calendar_event_add_time (GDataCalendarEvent *self, GDataGDWhen *when);
+GList *gdata_calendar_event_get_times (GDataCalendarEvent *self);
 
 G_END_DECLS
 
diff --git a/gdata/tests/calendar.c b/gdata/tests/calendar.c
index d6a2f76..598a6e5 100644
--- a/gdata/tests/calendar.c
+++ b/gdata/tests/calendar.c
@@ -226,6 +226,7 @@ test_insert_simple (void)
 	GDataCategory *category;
 	GDataGDWhere *where;
 	GDataGDWho *who;
+	GDataGDWhen *when;
 	GTimeVal start_time, end_time;
 	gchar *xml;
 	GError *error = NULL;
@@ -246,8 +247,8 @@ test_insert_simple (void)
 	gdata_calendar_event_add_person (event, who);
 	g_time_val_from_iso8601 ("2009-04-17T15:00:00.000Z", &start_time);
 	g_time_val_from_iso8601 ("2009-04-17T17:00:00.000Z", &end_time);
-	gdata_calendar_event_set_start_time (event, &start_time);
-	gdata_calendar_event_set_end_time (event, &end_time);
+	when = gdata_gd_when_new (&start_time, &end_time, NULL, NULL);
+	gdata_calendar_event_add_time (event, when);
 
 	/* Check the XML */
 	xml = gdata_entry_get_xml (GDATA_ENTRY (event));



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]