[libgdata] calendar: Add support for querying for deleted events
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata] calendar: Add support for querying for deleted events
- Date: Mon, 20 Jun 2011 20:38:29 +0000 (UTC)
commit 54fa219d3e55b476b6b843deec63d3889b960ef2
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Jun 20 21:09:01 2011 +0100
calendar: Add support for querying for deleted events
Add support for the âshowdeletedâ query parameter, cf. the Google Contacts
service.
This adds the following API:
â GDataCalendarQuery:show-deleted
â gdata_calendar_query_show_deleted()
â gdata_calendar_query_set_show_deleted()
docs/reference/gdata-sections.txt | 2 +
gdata/gdata.symbols | 2 +
gdata/services/calendar/gdata-calendar-query.c | 67 ++++++++++++++++++++++++
gdata/services/calendar/gdata-calendar-query.h | 2 +
gdata/tests/calendar.c | 12 +++-
5 files changed, 82 insertions(+), 3 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index ce40b27..a922447 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -495,6 +495,8 @@ gdata_calendar_query_get_timezone
gdata_calendar_query_set_timezone
gdata_calendar_query_get_max_attendees
gdata_calendar_query_set_max_attendees
+gdata_calendar_query_show_deleted
+gdata_calendar_query_set_show_deleted
<SUBSECTION Standard>
gdata_calendar_query_get_type
GDATA_CALENDAR_QUERY
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 959f9f3..2ef3235 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -907,3 +907,5 @@ gdata_oauth1_authorizer_get_timeout
gdata_oauth1_authorizer_set_timeout
gdata_calendar_query_get_max_attendees
gdata_calendar_query_set_max_attendees
+gdata_calendar_query_show_deleted
+gdata_calendar_query_set_show_deleted
diff --git a/gdata/services/calendar/gdata-calendar-query.c b/gdata/services/calendar/gdata-calendar-query.c
index f019dca..5177e80 100644
--- a/gdata/services/calendar/gdata-calendar-query.c
+++ b/gdata/services/calendar/gdata-calendar-query.c
@@ -101,6 +101,7 @@ struct _GDataCalendarQueryPrivate {
gint64 start_max;
gchar *timezone;
guint max_attendees;
+ gboolean show_deleted;
};
enum {
@@ -114,6 +115,7 @@ enum {
PROP_START_MAX,
PROP_TIMEZONE,
PROP_MAX_ATTENDEES,
+ PROP_SHOW_DELETED,
};
G_DEFINE_TYPE (GDataCalendarQuery, gdata_calendar_query, GDATA_TYPE_QUERY)
@@ -260,6 +262,20 @@ gdata_calendar_query_class_init (GDataCalendarQueryClass *klass)
"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));
+
+ /**
+ * GDataCalendarQuery:show-deleted:
+ *
+ * Whether to include deleted/cancelled events in the query feed. Deleted events have their #GDataCalendarEvent:status property set to
+ * %GDATA_GD_EVENT_STATUS_CANCELED. They do not normally appear in query results.
+ *
+ * Since: 0.9.1
+ */
+ g_object_class_install_property (gobject_class, PROP_SHOW_DELETED,
+ g_param_spec_boolean ("show-deleted",
+ "Show deleted?", "Whether to include deleted/cancelled events in the query feed.",
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
@@ -321,6 +337,9 @@ gdata_calendar_query_get_property (GObject *object, guint property_id, GValue *v
case PROP_MAX_ATTENDEES:
g_value_set_uint (value, priv->max_attendees);
break;
+ case PROP_SHOW_DELETED:
+ g_value_set_boolean (value, priv->show_deleted);
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -364,6 +383,9 @@ gdata_calendar_query_set_property (GObject *object, guint property_id, const GVa
case PROP_MAX_ATTENDEES:
gdata_calendar_query_set_max_attendees (self, g_value_get_uint (value));
break;
+ case PROP_SHOW_DELETED:
+ gdata_calendar_query_set_show_deleted (self, g_value_get_boolean (value));
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -455,6 +477,13 @@ get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboo
APPEND_SEP
g_string_append_printf (query_uri, "max-attendees=%u", priv->max_attendees);
}
+
+ APPEND_SEP
+ if (priv->show_deleted == TRUE) {
+ g_string_append (query_uri, "showdeleted=true");
+ } else {
+ g_string_append (query_uri, "showdeleted=false");
+ }
}
/**
@@ -878,3 +907,41 @@ gdata_calendar_query_set_max_attendees (GDataCalendarQuery *self, guint max_atte
/* Our current ETag will no longer be relevant */
gdata_query_set_etag (GDATA_QUERY (self), NULL);
}
+
+/**
+ * gdata_calendar_query_show_deleted:
+ * @self: a #GDataCalendarQuery
+ *
+ * Gets the #GDataCalendarQuery:show-deleted property.
+ *
+ * Return value: %TRUE if deleted/cancelled events should be shown, %FALSE otherwise
+ *
+ * Since: 0.9.1
+ */
+gboolean
+gdata_calendar_query_show_deleted (GDataCalendarQuery *self)
+{
+ g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), FALSE);
+ return self->priv->show_deleted;
+}
+
+/**
+ * gdata_calendar_query_set_show_deleted:
+ * @self: a #GDataCalendarQuery
+ * @show_deleted: %TRUE to show deleted events, %FALSE otherwise
+ *
+ * Sets the #GDataCalendarQuery:show-deleted property of the #GDataCalendarQuery.
+ *
+ * Since: 0.9.1
+ */
+void
+gdata_calendar_query_set_show_deleted (GDataCalendarQuery *self, gboolean show_deleted)
+{
+ g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
+
+ self->priv->show_deleted = show_deleted;
+ g_object_notify (G_OBJECT (self), "show-deleted");
+
+ /* 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 7d133f2..03ebc20 100644
--- a/gdata/services/calendar/gdata-calendar-query.h
+++ b/gdata/services/calendar/gdata-calendar-query.h
@@ -82,6 +82,8 @@ const gchar *gdata_calendar_query_get_timezone (GDataCalendarQuery *self) G_GNUC
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);
+gboolean gdata_calendar_query_show_deleted (GDataCalendarQuery *self) G_GNUC_PURE;
+void gdata_calendar_query_set_show_deleted (GDataCalendarQuery *self, gboolean show_deleted);
G_END_DECLS
diff --git a/gdata/tests/calendar.c b/gdata/tests/calendar.c
index 8b97974..f28f4af 100644
--- a/gdata/tests/calendar.c
+++ b/gdata/tests/calendar.c
@@ -706,18 +706,23 @@ test_query_uri (void)
gdata_calendar_query_set_max_attendees (query, 15);
g_assert_cmpuint (gdata_calendar_query_get_max_attendees (query), ==, 15);
+ gdata_calendar_query_set_show_deleted (query, TRUE);
+ g_assert (gdata_calendar_query_show_deleted (query) == TRUE);
+
/* 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&max-attendees=15");
+ "&start-min=2009-04-17T15:00:00Z&start-max=2010-04-17T15:00:00Z&ctz=America%2FLos_Angeles&max-attendees=15"
+ "&showdeleted=true");
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&max-attendees=15");
+ "&start-min=2009-04-17T15:00:00Z&start-max=2010-04-17T15:00:00Z&ctz=America%2FLos_Angeles&max-attendees=15"
+ "&showdeleted=true");
g_free (query_uri);
/* âwith a feed URI with pre-existing arguments */
@@ -725,7 +730,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&max-attendees=15");
+ "&ctz=America%2FLos_Angeles&max-attendees=15&showdeleted=true");
g_free (query_uri);
g_object_unref (query);
@@ -754,6 +759,7 @@ test_query_etag (void)
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))
+ CHECK_ETAG (gdata_calendar_query_set_show_deleted (query, TRUE))
#undef CHECK_ETAG
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]