[libgdata] Bug 639405 — Add max-attendees query parameter
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] Bug 639405 — Add max-attendees query parameter
- Date: Mon, 20 Jun 2011 20:38:24 +0000 (UTC)
commit 4c6b5ea87204ca695e1d51ac65af9dbdbc9e1e59
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Jun 20 20:56:14 2011 +0100
Bug 639405 â Add max-attendees query parameter
This adds the following API:
â GDataCalendarQuery:max-attendees
â gdata_calendar_query_get_max_attendees()
â gdata_calendar_query_set_max_attendees()
Closes: bgo#639405
docs/reference/gdata-sections.txt | 2 +
gdata/gdata.symbols | 2 +
gdata/services/calendar/gdata-calendar-query.c | 69 +++++++++++++++++++++++-
gdata/services/calendar/gdata-calendar-query.h | 2 +
gdata/tests/calendar.c | 10 +++-
5 files changed, 81 insertions(+), 4 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 7de7f59..ce40b27 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -493,6 +493,8 @@ gdata_calendar_query_get_recurrence_expansion_end
gdata_calendar_query_set_recurrence_expansion_end
gdata_calendar_query_get_timezone
gdata_calendar_query_set_timezone
+gdata_calendar_query_get_max_attendees
+gdata_calendar_query_set_max_attendees
<SUBSECTION Standard>
gdata_calendar_query_get_type
GDATA_CALENDAR_QUERY
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 203cf85..959f9f3 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -905,3 +905,5 @@ gdata_oauth1_authorizer_get_proxy_uri
gdata_oauth1_authorizer_set_proxy_uri
gdata_oauth1_authorizer_get_timeout
gdata_oauth1_authorizer_set_timeout
+gdata_calendar_query_get_max_attendees
+gdata_calendar_query_set_max_attendees
diff --git a/gdata/services/calendar/gdata-calendar-query.c b/gdata/services/calendar/gdata-calendar-query.c
index b8e214b..f019dca 100644
--- a/gdata/services/calendar/gdata-calendar-query.c
+++ b/gdata/services/calendar/gdata-calendar-query.c
@@ -100,6 +100,7 @@ struct _GDataCalendarQueryPrivate {
gint64 start_min;
gint64 start_max;
gchar *timezone;
+ guint max_attendees;
};
enum {
@@ -111,7 +112,8 @@ enum {
PROP_SORT_ORDER,
PROP_START_MIN,
PROP_START_MAX,
- PROP_TIMEZONE
+ PROP_TIMEZONE,
+ PROP_MAX_ATTENDEES,
};
G_DEFINE_TYPE (GDataCalendarQuery, gdata_calendar_query, GDATA_TYPE_QUERY)
@@ -244,6 +246,20 @@ gdata_calendar_query_class_init (GDataCalendarQueryClass *klass)
"Timezone", "The current timezone.",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataCalendarQuery:max-attendees:
+ *
+ * Specifies the maximum number of attendees to list for an event. If the actual number of attendees for an event is greater than this value,
+ * only the current user and the event organiser are listed.
+ *
+ * Since: 0.9.1
+ */
+ g_object_class_install_property (gobject_class, PROP_MAX_ATTENDEES,
+ g_param_spec_uint ("max-attendees",
+ "Max attendee count", "Specifies the maximum number of attendees to list for an event.",
+ 0, G_MAXUINT, 0,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
@@ -302,6 +318,9 @@ gdata_calendar_query_get_property (GObject *object, guint property_id, GValue *v
case PROP_TIMEZONE:
g_value_set_string (value, priv->timezone);
break;
+ case PROP_MAX_ATTENDEES:
+ g_value_set_uint (value, priv->max_attendees);
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -342,6 +361,9 @@ gdata_calendar_query_set_property (GObject *object, guint property_id, const GVa
case PROP_TIMEZONE:
gdata_calendar_query_set_timezone (self, g_value_get_string (value));
break;
+ case PROP_MAX_ATTENDEES:
+ gdata_calendar_query_set_max_attendees (self, g_value_get_uint (value));
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -428,6 +450,11 @@ get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboo
g_string_append (query_uri, "ctz=");
g_string_append_uri_escaped (query_uri, priv->timezone, NULL, FALSE);
}
+
+ if (priv->max_attendees > 0) {
+ APPEND_SEP
+ g_string_append_printf (query_uri, "max-attendees=%u", priv->max_attendees);
+ }
}
/**
@@ -811,3 +838,43 @@ gdata_calendar_query_set_timezone (GDataCalendarQuery *self, const gchar *_timez
/* Our current ETag will no longer be relevant */
gdata_query_set_etag (GDATA_QUERY (self), NULL);
}
+
+/**
+ * gdata_calendar_query_get_max_attendees:
+ * @self: a #GDataCalendarQuery
+ *
+ * Gets the #GDataCalendarQuery:max-attendees property. If the property is unset, <code class="literal">0</code> will be returned.
+ *
+ * Return value: the maximum number of attendees, or <code class="literal">0</code>
+ *
+ * Since: 0.9.1
+ */
+guint
+gdata_calendar_query_get_max_attendees (GDataCalendarQuery *self)
+{
+ g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), 0);
+ return self->priv->max_attendees;
+}
+
+/**
+ * gdata_calendar_query_set_max_attendees:
+ * @self: a #GDataCalendarQuery
+ * @max_attendees: a new maximum attendee count, or <code class="literal">0</code>
+ *
+ * Sets the #GDataCalendarQuery:max-attendees property of the #GDataCalendarQuery to the new value, @max_attendees.
+ *
+ * Set @max_attendees to <code class="literal">0</code> to unset the property in the query URI.
+ *
+ * Since: 0.9.1
+ */
+void
+gdata_calendar_query_set_max_attendees (GDataCalendarQuery *self, guint max_attendees)
+{
+ g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
+
+ self->priv->max_attendees = max_attendees;
+ g_object_notify (G_OBJECT (self), "max-attendees");
+
+ /* Our current ETag will no longer be relevant */
+ gdata_query_set_etag (GDATA_QUERY (self), NULL);
+}
diff --git a/gdata/services/calendar/gdata-calendar-query.h b/gdata/services/calendar/gdata-calendar-query.h
index 65807b6..7d133f2 100644
--- a/gdata/services/calendar/gdata-calendar-query.h
+++ b/gdata/services/calendar/gdata-calendar-query.h
@@ -80,6 +80,8 @@ gint64 gdata_calendar_query_get_start_max (GDataCalendarQuery *self);
void gdata_calendar_query_set_start_max (GDataCalendarQuery *self, gint64 start_max);
const gchar *gdata_calendar_query_get_timezone (GDataCalendarQuery *self) G_GNUC_PURE;
void gdata_calendar_query_set_timezone (GDataCalendarQuery *self, const gchar *_timezone);
+guint gdata_calendar_query_get_max_attendees (GDataCalendarQuery *self) G_GNUC_PURE;
+void gdata_calendar_query_set_max_attendees (GDataCalendarQuery *self, guint max_attendees);
G_END_DECLS
diff --git a/gdata/tests/calendar.c b/gdata/tests/calendar.c
index b6f8fa0..8b97974 100644
--- a/gdata/tests/calendar.c
+++ b/gdata/tests/calendar.c
@@ -703,18 +703,21 @@ test_query_uri (void)
gdata_calendar_query_set_timezone (query, "America/Los Angeles");
g_assert_cmpstr (gdata_calendar_query_get_timezone (query), ==, "America/Los_Angeles");
+ gdata_calendar_query_set_max_attendees (query, 15);
+ g_assert_cmpuint (gdata_calendar_query_get_max_attendees (query), ==, 15);
+
/* Check the built query URI with a normal feed URI */
query_uri = gdata_query_get_query_uri (GDATA_QUERY (query), "http://example.com");
g_assert_cmpstr (query_uri, ==, "http://example.com?q=q&futureevents=true&orderby=starttime&recurrence-expansion-start=2009-04-17T15:00:00Z"
"&recurrence-expansion-end=2010-04-17T15:00:00Z&singleevents=true&sortorder=descending"
- "&start-min=2009-04-17T15:00:00Z&start-max=2010-04-17T15:00:00Z&ctz=America%2FLos_Angeles");
+ "&start-min=2009-04-17T15:00:00Z&start-max=2010-04-17T15:00:00Z&ctz=America%2FLos_Angeles&max-attendees=15");
g_free (query_uri);
/* âwith a feed URI with a trailing slash */
query_uri = gdata_query_get_query_uri (GDATA_QUERY (query), "http://example.com/");
g_assert_cmpstr (query_uri, ==, "http://example.com/?q=q&futureevents=true&orderby=starttime&recurrence-expansion-start=2009-04-17T15:00:00Z"
"&recurrence-expansion-end=2010-04-17T15:00:00Z&singleevents=true&sortorder=descending"
- "&start-min=2009-04-17T15:00:00Z&start-max=2010-04-17T15:00:00Z&ctz=America%2FLos_Angeles");
+ "&start-min=2009-04-17T15:00:00Z&start-max=2010-04-17T15:00:00Z&ctz=America%2FLos_Angeles&max-attendees=15");
g_free (query_uri);
/* âwith a feed URI with pre-existing arguments */
@@ -722,7 +725,7 @@ test_query_uri (void)
g_assert_cmpstr (query_uri, ==, "http://example.com/bar/?test=test&this=that&q=q&futureevents=true&orderby=starttime"
"&recurrence-expansion-start=2009-04-17T15:00:00Z&recurrence-expansion-end=2010-04-17T15:00:00Z"
"&singleevents=true&sortorder=descending&start-min=2009-04-17T15:00:00Z&start-max=2010-04-17T15:00:00Z"
- "&ctz=America%2FLos_Angeles");
+ "&ctz=America%2FLos_Angeles&max-attendees=15");
g_free (query_uri);
g_object_unref (query);
@@ -750,6 +753,7 @@ test_query_etag (void)
CHECK_ETAG (gdata_calendar_query_set_start_min (query, -1))
CHECK_ETAG (gdata_calendar_query_set_start_max (query, -1))
CHECK_ETAG (gdata_calendar_query_set_timezone (query, "about now"))
+ CHECK_ETAG (gdata_calendar_query_set_max_attendees (query, 10))
#undef CHECK_ETAG
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]