[libgdata] Added a convenience function to get the time of a calendar event



commit 536d985087eb2a65717ce35fbe0f933c22281fc9
Author: Philip Withnall <philip tecnocode co uk>
Date:   Thu Apr 23 18:25:56 2009 +0100

    Added a convenience function to get the time of a calendar event
    
    Added gdata_calendar_event_get_primary_time, allowing the only time period
    of an event to be easily retrieved.
---
 docs/reference/gdata-sections.txt              |    1 +
 gdata/gdata.symbols                            |    1 +
 gdata/services/calendar/gdata-calendar-event.c |   36 ++++++++++++++++++++++++
 gdata/services/calendar/gdata-calendar-event.h |    1 +
 4 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 75fce40..c0d24a2 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -519,6 +519,7 @@ gdata_calendar_event_add_person
 gdata_calendar_event_get_places
 gdata_calendar_event_add_place
 gdata_calendar_event_get_times
+gdata_calendar_event_get_primary_time
 gdata_calendar_event_add_time
 gdata_calendar_event_get_anyone_can_add_self
 gdata_calendar_event_set_anyone_can_add_self
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 4bfc757..e9af12a 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -197,6 +197,7 @@ gdata_calendar_event_add_place
 gdata_calendar_event_get_places
 gdata_calendar_event_add_time
 gdata_calendar_event_get_times
+gdata_calendar_event_get_primary_time
 gdata_calendar_query_get_type
 gdata_calendar_query_new
 gdata_calendar_query_new_with_limits
diff --git a/gdata/services/calendar/gdata-calendar-event.c b/gdata/services/calendar/gdata-calendar-event.c
index 61c5304..ae9ba47 100644
--- a/gdata/services/calendar/gdata-calendar-event.c
+++ b/gdata/services/calendar/gdata-calendar-event.c
@@ -1081,3 +1081,39 @@ gdata_calendar_event_get_times (GDataCalendarEvent *self)
 	g_return_val_if_fail (GDATA_IS_CALENDAR_EVENT (self), NULL);
 	return self->priv->times;
 }
+
+/**
+ * gdata_calendar_event_get_primary_time:
+ * @self: a #GDataCalendarEvent
+ * @start_time: a #GTimeVal for the start time, or %NULL
+ * @end_time: a #GTimeVal for the end time, or %NULL
+ * @when: a #GDataGDWhen for the primary time structure, or %NULL
+ *
+ * Gets the first time period associated with the event, conveniently returning just its start and
+ * end times if required.
+ *
+ * If there are no time periods, or more than one time period, associated with the event, %FALSE will
+ * be returned, and the parameters will remain unmodified.
+ *
+ * Return value: %TRUE if there is only one time period associated with the event, %FALSE otherwise
+ **/
+gboolean
+gdata_calendar_event_get_primary_time (GDataCalendarEvent *self, GTimeVal *start_time, GTimeVal *end_time, GDataGDWhen **when)
+{
+	GDataGDWhen *primary_when;
+
+	g_return_val_if_fail (GDATA_IS_CALENDAR_EVENT (self), FALSE);
+
+	if (self->priv->times == NULL || self->priv->times->next != NULL)
+		return FALSE;
+
+	primary_when = (GDataGDWhen*) self->priv->times->data;
+	if (start_time != NULL)
+		*start_time = primary_when->start_time;
+	if (end_time != NULL)
+		*end_time = primary_when->end_time;
+	if (when != NULL)
+		*when = primary_when;
+
+	return TRUE;
+}
diff --git a/gdata/services/calendar/gdata-calendar-event.h b/gdata/services/calendar/gdata-calendar-event.h
index 3aba384..f991697 100644
--- a/gdata/services/calendar/gdata-calendar-event.h
+++ b/gdata/services/calendar/gdata-calendar-event.h
@@ -88,6 +88,7 @@ void gdata_calendar_event_add_place (GDataCalendarEvent *self, GDataGDWhere *whe
 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);
+gboolean gdata_calendar_event_get_primary_time (GDataCalendarEvent *self, GTimeVal *start_time, GTimeVal *end_time, GDataGDWhen **when);
 
 G_END_DECLS
 



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