Blame gdata/services/calendar/gdata-calendar-query.c

Packit 4b6dd7
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
Packit 4b6dd7
/*
Packit 4b6dd7
 * GData Client
Packit 4b6dd7
 * Copyright (C) Philip Withnall 2009, 2010, 2017 <philip@tecnocode.co.uk>
Packit 4b6dd7
 *
Packit 4b6dd7
 * GData Client is free software; you can redistribute it and/or
Packit 4b6dd7
 * modify it under the terms of the GNU Lesser General Public
Packit 4b6dd7
 * License as published by the Free Software Foundation; either
Packit 4b6dd7
 * version 2.1 of the License, or (at your option) any later version.
Packit 4b6dd7
 *
Packit 4b6dd7
 * GData Client is distributed in the hope that it will be useful,
Packit 4b6dd7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4b6dd7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 4b6dd7
 * Lesser General Public License for more details.
Packit 4b6dd7
 *
Packit 4b6dd7
 * You should have received a copy of the GNU Lesser General Public
Packit 4b6dd7
 * License along with GData Client.  If not, see <http://www.gnu.org/licenses/>.
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * SECTION:gdata-calendar-query
Packit 4b6dd7
 * @short_description: GData Calendar query object
Packit 4b6dd7
 * @stability: Stable
Packit 4b6dd7
 * @include: gdata/services/calendar/gdata-calendar-query.h
Packit 4b6dd7
 *
Packit 4b6dd7
 * #GDataCalendarQuery represents a collection of query parameters specific to the Google Calendar service, which go above and beyond
Packit 4b6dd7
 * those catered for by #GDataQuery.
Packit 4b6dd7
 *
Packit 4b6dd7
 * For more information on the custom GData query parameters supported by #GDataCalendarQuery, see the 
Packit 4b6dd7
 * url="https://developers.google.com/google-apps/calendar/v3/reference/events/list">online
Packit 4b6dd7
 * documentation</ulink>.
Packit 4b6dd7
 *
Packit 4b6dd7
 * <example>
Packit 4b6dd7
 * 	<title>Querying for Events</title>
Packit 4b6dd7
 * 	<programlisting>
Packit 4b6dd7
 *	GDataCalendarService *service;
Packit 4b6dd7
 *	GDataCalendarCalendar *calendar;
Packit 4b6dd7
 *	GDataCalendarQuery *query;
Packit 4b6dd7
 *	GDataFeed *feed;
Packit 4b6dd7
 *	GTimeVal current_time;
Packit 4b6dd7
 *	GList *i;
Packit 4b6dd7
 *	GError *error = NULL;
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Create a service and find a calendar to query in */
Packit 4b6dd7
 *	service = create_calendar_service ();
Packit 4b6dd7
 *	calendar = get_calendar (service);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Create the query to use. We're going to query for events within the next week which match the search term "party",
Packit 4b6dd7
 *	 * ordered by last modification time (descending). */
Packit 4b6dd7
 *	g_get_current_time (&current_time);
Packit 4b6dd7
 *	query = gdata_calendar_query_new_with_limits ("party", current_time.tv_sec, current_time.tv_sec + 7 * 24 * 60 * 60);
Packit 4b6dd7
 *	gdata_calendar_query_set_order_by (query, "lastmodified");
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Execute the query */
Packit 4b6dd7
 *	feed = gdata_calendar_service_query_events (service, calendar, query, NULL, NULL, NULL, &error);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	g_object_unref (query);
Packit 4b6dd7
 *	g_object_unref (calendar);
Packit 4b6dd7
 *	g_object_unref (service);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	if (error != NULL) {
Packit 4b6dd7
 *		g_error ("Error querying for events: %s", error->message);
Packit 4b6dd7
 *		g_error_free (error);
Packit 4b6dd7
 *		return;
Packit 4b6dd7
 *	}
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Iterate through the returned events and do something with them */
Packit 4b6dd7
 *	for (i = gdata_feed_get_entries (feed); i != NULL; i = i->next) {
Packit 4b6dd7
 *		GDataCalendarEvent *event = GDATA_CALENDAR_EVENT (i->data);
Packit 4b6dd7
 *
Packit 4b6dd7
 *		/* Do something with the event here, such as insert it into a UI */
Packit 4b6dd7
 *	}
Packit 4b6dd7
 *
Packit 4b6dd7
 *	g_object_unref (feed);
Packit 4b6dd7
 * 	</programlisting>
Packit 4b6dd7
 * </example>
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
#include <config.h>
Packit 4b6dd7
#include <glib.h>
Packit 4b6dd7
#include <glib/gi18n-lib.h>
Packit 4b6dd7
#include <string.h>
Packit 4b6dd7
Packit 4b6dd7
#include "gdata-calendar-query.h"
Packit 4b6dd7
#include "gdata-query.h"
Packit 4b6dd7
#include "gdata-parser.h"
Packit 4b6dd7
#include "gdata-private.h"
Packit 4b6dd7
Packit 4b6dd7
static void gdata_calendar_query_finalize (GObject *object);
Packit 4b6dd7
static void gdata_calendar_query_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void gdata_calendar_query_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboolean *params_started);
Packit 4b6dd7
Packit 4b6dd7
struct _GDataCalendarQueryPrivate {
Packit 4b6dd7
	gboolean future_events;
Packit 4b6dd7
	gchar *order_by; /* TODO: #defined values */
Packit 4b6dd7
	gint64 recurrence_expansion_start;
Packit 4b6dd7
	gint64 recurrence_expansion_end;
Packit 4b6dd7
	gboolean single_events;
Packit 4b6dd7
	gchar *sort_order; /* TODO: #defined values */
Packit 4b6dd7
	gint64 start_min;  /* UNIX timestamp, seconds */
Packit 4b6dd7
	gint64 start_max;  /* UNIX timestamp, seconds */
Packit 4b6dd7
	gchar *timezone;
Packit 4b6dd7
	guint max_attendees;
Packit 4b6dd7
	gboolean show_deleted;
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
enum {
Packit 4b6dd7
	PROP_FUTURE_EVENTS = 1,
Packit 4b6dd7
	PROP_ORDER_BY,
Packit 4b6dd7
	PROP_RECURRENCE_EXPANSION_START,
Packit 4b6dd7
	PROP_RECURRENCE_EXPANSION_END,
Packit 4b6dd7
	PROP_SINGLE_EVENTS,
Packit 4b6dd7
	PROP_SORT_ORDER,
Packit 4b6dd7
	PROP_START_MIN,
Packit 4b6dd7
	PROP_START_MAX,
Packit 4b6dd7
	PROP_TIMEZONE,
Packit 4b6dd7
	PROP_MAX_ATTENDEES,
Packit 4b6dd7
	PROP_SHOW_DELETED,
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
G_DEFINE_TYPE (GDataCalendarQuery, gdata_calendar_query, GDATA_TYPE_QUERY)
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_calendar_query_class_init (GDataCalendarQueryClass *klass)
Packit 4b6dd7
{
Packit 4b6dd7
	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
Packit 4b6dd7
	GDataQueryClass *query_class = GDATA_QUERY_CLASS (klass);
Packit 4b6dd7
Packit 4b6dd7
	g_type_class_add_private (klass, sizeof (GDataCalendarQueryPrivate));
Packit 4b6dd7
Packit 4b6dd7
	gobject_class->set_property = gdata_calendar_query_set_property;
Packit 4b6dd7
	gobject_class->get_property = gdata_calendar_query_get_property;
Packit 4b6dd7
	gobject_class->finalize = gdata_calendar_query_finalize;
Packit 4b6dd7
Packit 4b6dd7
	query_class->get_query_uri = get_query_uri;
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:future-events:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A shortcut to request all events scheduled for the future. Overrides the
Packit 4b6dd7
	 * #GDataCalendarQuery:recurrence-expansion-start, #GDataCalendarQuery:recurrence-expansion-end,
Packit 4b6dd7
	 * #GDataCalendarQuery:start-min and #GDataCalendarQuery:start-max properties.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_FUTURE_EVENTS,
Packit 4b6dd7
	                                 g_param_spec_boolean ("future-events",
Packit 4b6dd7
	                                                       "Future events?", "A shortcut to request all events scheduled for the future.",
Packit 4b6dd7
	                                                       FALSE,
Packit 4b6dd7
	                                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:order-by:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Specifies order of entries in a feed. Supported values are <literal>lastmodified</literal> and
Packit 4b6dd7
	 * <literal>starttime</literal>.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_ORDER_BY,
Packit 4b6dd7
	                                 g_param_spec_string ("order-by",
Packit 4b6dd7
	                                                      "Order by", "Specifies order of entries in a feed.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:recurrence-expansion-start:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Specifies the beginning of the time period to expand recurring events for, inclusive.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Deprecated: 0.17.7: Use #GDataCalendarQuery:single-events instead, as this is no longer supported on the server.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_RECURRENCE_EXPANSION_START,
Packit 4b6dd7
	                                 g_param_spec_int64 ("recurrence-expansion-start",
Packit 4b6dd7
	                                                     "Recurrence expansion start", "Specifies start of period to expand recurrences for.",
Packit 4b6dd7
	                                                     -1, G_MAXINT64, -1,
Packit 4b6dd7
	                                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_DEPRECATED));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:recurrence-expansion-end:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Specifies the end of the time period to expand recurring events for, exclusive.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Deprecated: 0.17.7: Use #GDataCalendarQuery:single-events instead, as this is no longer supported on the server.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_RECURRENCE_EXPANSION_END,
Packit 4b6dd7
	                                 g_param_spec_int64 ("recurrence-expansion-end",
Packit 4b6dd7
	                                                     "Recurrence expansion end", "Specifies end of period to expand recurrences for.",
Packit 4b6dd7
	                                                     -1, G_MAXINT64, -1,
Packit 4b6dd7
	                                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_DEPRECATED));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:single-events:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Indicates whether recurring events should be expanded or represented as a single event.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_SINGLE_EVENTS,
Packit 4b6dd7
	                                 g_param_spec_boolean ("single-events",
Packit 4b6dd7
	                                                       "Single events?", "Indicates whether recurring events should be expanded.",
Packit 4b6dd7
	                                                       FALSE,
Packit 4b6dd7
	                                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:sort-order:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Specifies direction of sorting. Supported values are <literal>ascending</literal> and
Packit 4b6dd7
	 * <literal>descending</literal>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * By default, results are returned in ascending order.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Deprecated: 0.17.7: Manually sort the results after retrieving them, as this is no longer supported on the server.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_SORT_ORDER,
Packit 4b6dd7
	                                 g_param_spec_string ("sort-order",
Packit 4b6dd7
	                                                      "Sort order", "Specifies direction of sorting.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_DEPRECATED));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:start-min:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Together with #GDataCalendarQuery:start-max, creates a timespan such that only events within the timespan are returned.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * #GDataCalendarQuery:start-min is inclusive, while #GDataCalendarQuery:start-max is exclusive. Events that overlap the range are
Packit 4b6dd7
	 * included. Both are specified in seconds since the UNIX epoch.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * If not specified, the default #GDataCalendarQuery:start-min is <literal>1970-01-01</literal>.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_START_MIN,
Packit 4b6dd7
	                                 g_param_spec_int64 ("start-min",
Packit 4b6dd7
	                                                     "Start min", "A timespan such that only events within the timespan are returned.",
Packit 4b6dd7
	                                                     -1, G_MAXINT64, -1,
Packit 4b6dd7
	                                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:start-max:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Together with #GDataCalendarQuery:start-min, creates a timespan such that only events within the timespan are returned
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * #GDataCalendarQuery:start-min is inclusive, while #GDataCalendarQuery:start-max is exclusive. Events that overlap the range are
Packit 4b6dd7
	 * included. Both are specified in seconds since the UNIX epoch.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * If not specified, the default #GDataCalendarQuery:start-max is <literal>2031-01-01</literal>.
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_START_MAX,
Packit 4b6dd7
	                                 g_param_spec_int64 ("start-max",
Packit 4b6dd7
	                                                     "Start max", "A timespan such that only events within the timespan are returned.",
Packit 4b6dd7
	                                                     -1, G_MAXINT64, -1,
Packit 4b6dd7
	                                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:timezone:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The current timezone. If this is not specified, all times are returned in UTC.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.2.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_TIMEZONE,
Packit 4b6dd7
	                                 g_param_spec_string ("timezone",
Packit 4b6dd7
	                                                      "Timezone", "The current timezone.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:max-attendees:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * 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,
Packit 4b6dd7
	 * only the current user and the event organiser are listed.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.9.1
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_MAX_ATTENDEES,
Packit 4b6dd7
	                                 g_param_spec_uint ("max-attendees",
Packit 4b6dd7
	                                                    "Max attendee count", "Specifies the maximum number of attendees to list for an event.",
Packit 4b6dd7
	                                                    0, G_MAXUINT, 0,
Packit 4b6dd7
	                                                    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataCalendarQuery:show-deleted:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Whether to include deleted/cancelled events in the query feed. Deleted events have their #GDataCalendarEvent:status property set to
Packit 4b6dd7
	 * %GDATA_GD_EVENT_STATUS_CANCELED. They do not normally appear in query results.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.9.1
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_SHOW_DELETED,
Packit 4b6dd7
	                                 g_param_spec_boolean ("show-deleted",
Packit 4b6dd7
	                                                       "Show deleted?", "Whether to include deleted/cancelled events in the query feed.",
Packit 4b6dd7
	                                                       FALSE,
Packit 4b6dd7
	                                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_calendar_query_init (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_CALENDAR_QUERY, GDataCalendarQueryPrivate);
Packit 4b6dd7
	self->priv->recurrence_expansion_start = -1;
Packit 4b6dd7
	self->priv->recurrence_expansion_end = -1;
Packit 4b6dd7
	self->priv->start_min = -1;
Packit 4b6dd7
	self->priv->start_max = -1;
Packit 4b6dd7
Packit 4b6dd7
	_gdata_query_set_pagination_type (GDATA_QUERY (self),
Packit 4b6dd7
	                                  GDATA_QUERY_PAGINATION_TOKENS);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_calendar_query_finalize (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataCalendarQueryPrivate *priv = GDATA_CALENDAR_QUERY (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_free (priv->order_by);
Packit 4b6dd7
	g_free (priv->sort_order);
Packit 4b6dd7
	g_free (priv->timezone);
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	G_OBJECT_CLASS (gdata_calendar_query_parent_class)->finalize (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_calendar_query_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataCalendarQueryPrivate *priv = GDATA_CALENDAR_QUERY (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_FUTURE_EVENTS:
Packit 4b6dd7
			g_value_set_boolean (value, priv->future_events);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_ORDER_BY:
Packit 4b6dd7
			g_value_set_string (value, priv->order_by);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RECURRENCE_EXPANSION_START:
Packit 4b6dd7
			g_value_set_int64 (value, priv->recurrence_expansion_start);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RECURRENCE_EXPANSION_END:
Packit 4b6dd7
			g_value_set_int64 (value, priv->recurrence_expansion_end);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SINGLE_EVENTS:
Packit 4b6dd7
			g_value_set_boolean (value, priv->single_events);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SORT_ORDER:
Packit 4b6dd7
			g_value_set_string (value, priv->sort_order);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_START_MIN:
Packit 4b6dd7
			g_value_set_int64 (value, priv->start_min);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_START_MAX:
Packit 4b6dd7
			g_value_set_int64 (value, priv->start_max);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_TIMEZONE:
Packit 4b6dd7
			g_value_set_string (value, priv->timezone);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_MAX_ATTENDEES:
Packit 4b6dd7
			g_value_set_uint (value, priv->max_attendees);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SHOW_DELETED:
Packit 4b6dd7
			g_value_set_boolean (value, priv->show_deleted);
Packit 4b6dd7
			break;
Packit 4b6dd7
		default:
Packit 4b6dd7
			/* We don't have any other property... */
Packit 4b6dd7
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
Packit 4b6dd7
			break;
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_calendar_query_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataCalendarQuery *self = GDATA_CALENDAR_QUERY (object);
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_FUTURE_EVENTS:
Packit 4b6dd7
			gdata_calendar_query_set_future_events (self, g_value_get_boolean (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_ORDER_BY:
Packit 4b6dd7
			gdata_calendar_query_set_order_by (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RECURRENCE_EXPANSION_START:
Packit 4b6dd7
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 4b6dd7
			gdata_calendar_query_set_recurrence_expansion_start (self, g_value_get_int64 (value));
Packit 4b6dd7
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RECURRENCE_EXPANSION_END:
Packit 4b6dd7
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 4b6dd7
			gdata_calendar_query_set_recurrence_expansion_end (self, g_value_get_int64 (value));
Packit 4b6dd7
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SINGLE_EVENTS:
Packit 4b6dd7
			gdata_calendar_query_set_single_events (self, g_value_get_boolean (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SORT_ORDER:
Packit 4b6dd7
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
Packit 4b6dd7
			gdata_calendar_query_set_sort_order (self, g_value_get_string (value));
Packit 4b6dd7
G_GNUC_END_IGNORE_DEPRECATIONS
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_START_MIN:
Packit 4b6dd7
			gdata_calendar_query_set_start_min (self, g_value_get_int64 (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_START_MAX:
Packit 4b6dd7
			gdata_calendar_query_set_start_max (self, g_value_get_int64 (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_TIMEZONE:
Packit 4b6dd7
			gdata_calendar_query_set_timezone (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_MAX_ATTENDEES:
Packit 4b6dd7
			gdata_calendar_query_set_max_attendees (self, g_value_get_uint (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SHOW_DELETED:
Packit 4b6dd7
			gdata_calendar_query_set_show_deleted (self, g_value_get_boolean (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		default:
Packit 4b6dd7
			/* We don't have any other property... */
Packit 4b6dd7
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
Packit 4b6dd7
			break;
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/* Convert the v2 order-by values to the v3 orderBy values:
Packit 4b6dd7
 *  - https://developers.google.com/google-apps/calendar/v3/reference/events/list#orderBy
Packit 4b6dd7
 *  - There is no reference for v2 any more.
Packit 4b6dd7
 */
Packit 4b6dd7
static const gchar *
Packit 4b6dd7
order_by_to_v3 (const gchar *order_by)
Packit 4b6dd7
{
Packit 4b6dd7
	if (g_strcmp0 (order_by, "lastmodified") == 0)
Packit 4b6dd7
		return "updated";
Packit 4b6dd7
	else if (g_strcmp0 (order_by, "starttime") == 0)
Packit 4b6dd7
		return "startTime";
Packit 4b6dd7
	else
Packit 4b6dd7
		return order_by;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_query_uri (GDataQuery *self, const gchar *feed_uri, GString *query_uri, gboolean *params_started)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataCalendarQueryPrivate *priv = GDATA_CALENDAR_QUERY (self)->priv;
Packit 4b6dd7
Packit 4b6dd7
	#define APPEND_SEP g_string_append_c (query_uri, (*params_started == FALSE) ? '?' : '&';; *params_started = TRUE;
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	GDATA_QUERY_CLASS (gdata_calendar_query_parent_class)->get_query_uri (self, feed_uri, query_uri, params_started);
Packit 4b6dd7
Packit 4b6dd7
	if (gdata_query_get_max_results (GDATA_QUERY (self)) != 0) {
Packit 4b6dd7
		APPEND_SEP
Packit 4b6dd7
		g_string_append_printf (query_uri, "maxResults=%u",
Packit 4b6dd7
		                        gdata_query_get_max_results (GDATA_QUERY (self)));
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->order_by != NULL) {
Packit 4b6dd7
		APPEND_SEP
Packit 4b6dd7
		g_string_append (query_uri, "orderBy=");
Packit 4b6dd7
		g_string_append_uri_escaped (query_uri,
Packit 4b6dd7
		                             order_by_to_v3 (priv->order_by), NULL, FALSE);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Convert the deprecated recurrence-expansion-* properties into single-events. */
Packit 4b6dd7
	APPEND_SEP
Packit 4b6dd7
	if (priv->single_events == TRUE ||
Packit 4b6dd7
	    priv->recurrence_expansion_start >= 0 ||
Packit 4b6dd7
	    priv->recurrence_expansion_end >= 0)
Packit 4b6dd7
		g_string_append (query_uri, "singleEvents=true");
Packit 4b6dd7
	else
Packit 4b6dd7
		g_string_append (query_uri, "singleEvents=false");
Packit 4b6dd7
Packit 4b6dd7
	if (priv->start_min != -1) {
Packit 4b6dd7
		gchar *start_min;
Packit 4b6dd7
		gint64 start_min_time;
Packit 4b6dd7
Packit 4b6dd7
		if (priv->future_events)
Packit 4b6dd7
			start_min_time = g_get_real_time () / G_USEC_PER_SEC;
Packit 4b6dd7
		else
Packit 4b6dd7
			start_min_time = priv->start_min;
Packit 4b6dd7
Packit 4b6dd7
		APPEND_SEP
Packit 4b6dd7
		g_string_append (query_uri, "timeMin=");
Packit 4b6dd7
		start_min = gdata_parser_int64_to_iso8601 (start_min_time);
Packit 4b6dd7
		g_string_append (query_uri, start_min);
Packit 4b6dd7
		g_free (start_min);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->start_max != -1 && !priv->future_events) {
Packit 4b6dd7
		gchar *start_max;
Packit 4b6dd7
Packit 4b6dd7
		APPEND_SEP
Packit 4b6dd7
		g_string_append (query_uri, "timeMax=");
Packit 4b6dd7
		start_max = gdata_parser_int64_to_iso8601 (priv->start_max);
Packit 4b6dd7
		g_string_append (query_uri, start_max);
Packit 4b6dd7
		g_free (start_max);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->timezone != NULL) {
Packit 4b6dd7
		APPEND_SEP
Packit 4b6dd7
		g_string_append (query_uri, "timeZone=");
Packit 4b6dd7
		g_string_append_uri_escaped (query_uri, priv->timezone, NULL, FALSE);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->max_attendees > 0) {
Packit 4b6dd7
		APPEND_SEP
Packit 4b6dd7
		g_string_append_printf (query_uri, "maxAttendees=%u", priv->max_attendees);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	APPEND_SEP
Packit 4b6dd7
	if (priv->show_deleted == TRUE) {
Packit 4b6dd7
		g_string_append (query_uri, "showDeleted=true");
Packit 4b6dd7
	} else {
Packit 4b6dd7
		g_string_append (query_uri, "showDeleted=false");
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_new:
Packit 4b6dd7
 * @q: (allow-none): a query string, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataCalendarQuery with its #GDataQuery:q property set to @q.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a new #GDataCalendarQuery
Packit 4b6dd7
 */
Packit 4b6dd7
GDataCalendarQuery *
Packit 4b6dd7
gdata_calendar_query_new (const gchar *q)
Packit 4b6dd7
{
Packit 4b6dd7
	return g_object_new (GDATA_TYPE_CALENDAR_QUERY, "q", q, NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_new_with_limits:
Packit 4b6dd7
 * @q: (allow-none): a query string, or %NULL
Packit 4b6dd7
 * @start_min: a starting time for the event period, or -1
Packit 4b6dd7
 * @start_max: an ending time for the event period, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataCalendarQuery with its #GDataQuery:q property set to @q, and the time limits @start_min and @start_max
Packit 4b6dd7
 * applied (both in seconds since the UNIX epoch).
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a new #GDataCalendarQuery
Packit 4b6dd7
 */
Packit 4b6dd7
GDataCalendarQuery *
Packit 4b6dd7
gdata_calendar_query_new_with_limits (const gchar *q, gint64 start_min, gint64 start_max)
Packit 4b6dd7
{
Packit 4b6dd7
	return g_object_new (GDATA_TYPE_CALENDAR_QUERY,
Packit 4b6dd7
	                     "q", q,
Packit 4b6dd7
	                     "start-min", start_min,
Packit 4b6dd7
	                     "start-max", start_max,
Packit 4b6dd7
	                     NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_future_events:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:future-events property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the future events property
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_calendar_query_get_future_events (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), FALSE);
Packit 4b6dd7
	return self->priv->future_events;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_future_events:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @future_events: %TRUE to unconditionally show future events, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:future-events property of the #GDataCalendarQuery to @future_events.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_future_events (GDataCalendarQuery *self, gboolean future_events)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
	self->priv->future_events = future_events;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "future-events");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_order_by:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:order-by property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the order by property, or %NULL if it is unset
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_calendar_query_get_order_by (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), NULL);
Packit 4b6dd7
	return self->priv->order_by;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_order_by:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @order_by: (allow-none): a new order by string, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:order-by property of the #GDataCalendarQuery to the new order by string, @order_by.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @order_by to %NULL to unset the property in the query URI.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_order_by (GDataCalendarQuery *self, const gchar *order_by)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->order_by);
Packit 4b6dd7
	self->priv->order_by = g_strdup (order_by);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "order-by");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_recurrence_expansion_start:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:recurrence-expansion-start property. If the property is unset, -1 will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the UNIX timestamp for the recurrence-expansion-start property, or -1
Packit 4b6dd7
 * Deprecated: 0.17.7: Use #GDataCalendarQuery:single-events instead, as this is no longer supported on the server.
Packit 4b6dd7
 */
Packit 4b6dd7
gint64
Packit 4b6dd7
gdata_calendar_query_get_recurrence_expansion_start (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), -1);
Packit 4b6dd7
	return self->priv->recurrence_expansion_start;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_recurrence_expansion_start:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @start: a new start time, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:recurrence-expansion-start property of the #GDataCalendarQuery
Packit 4b6dd7
 * to the new time/date, @start.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @start to -1 to unset the property in the query URI.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Deprecated: 0.17.7: Use #GDataCalendarQuery:single-events instead, as this is no longer supported on the server.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_recurrence_expansion_start (GDataCalendarQuery *self, gint64 start)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
	g_return_if_fail (start >= -1);
Packit 4b6dd7
Packit 4b6dd7
	self->priv->recurrence_expansion_start = start;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "recurrence-expansion-start");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_recurrence_expansion_end:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:recurrence-expansion-end property. If the property is unset, -1 will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the UNIX timestamp for the recurrence-expansion-end property, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Deprecated: 0.17.7: Use #GDataCalendarQuery:single-events instead, as this is no longer supported on the server.
Packit 4b6dd7
 */
Packit 4b6dd7
gint64
Packit 4b6dd7
gdata_calendar_query_get_recurrence_expansion_end (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), -1	);
Packit 4b6dd7
	return self->priv->recurrence_expansion_end;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_recurrence_expansion_end:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @end: a new end time, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:recurrence-expansion-end property of the #GDataCalendarQuery
Packit 4b6dd7
 * to the new time/date, @end.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @end to -1 to unset the property in the query URI.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Deprecated: 0.17.7: Use #GDataCalendarQuery:single-events instead, as this is no longer supported on the server.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_recurrence_expansion_end (GDataCalendarQuery *self, gint64 end)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
	g_return_if_fail (end >= -1);
Packit 4b6dd7
Packit 4b6dd7
	self->priv->recurrence_expansion_end = end;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "recurrence-expansion-end");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_single_events:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:single-events property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the single events property
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_calendar_query_get_single_events (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), FALSE);
Packit 4b6dd7
	return self->priv->single_events;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_single_events:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @single_events: %TRUE to show recurring events as single events, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:single-events property of the #GDataCalendarQuery to @single_events.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_single_events (GDataCalendarQuery *self, gboolean single_events)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
	self->priv->single_events = single_events;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "single-events");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_sort_order:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:sort-order property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the sort order property, or %NULL if it is unset
Packit 4b6dd7
 * Deprecated: 0.17.7: Manually sort the results after retrieving them, as this is no longer supported on the server.
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_calendar_query_get_sort_order (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), NULL);
Packit 4b6dd7
	return self->priv->sort_order;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_sort_order:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @sort_order: (allow-none): a new sort order string, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:sort-order property of the #GDataCalendarQuery to the new sort order string, @sort_order.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @sort_order to %NULL to unset the property in the query URI.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Deprecated: 0.17.7: Manually sort the results after retrieving them, as this is no longer supported on the server.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_sort_order (GDataCalendarQuery *self, const gchar *sort_order)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->sort_order);
Packit 4b6dd7
	self->priv->sort_order = g_strdup (sort_order);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "sort-order");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_start_min:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:start-min property. If the property is unset, -1 will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the UNIX timestamp (in seconds) for the start-min property, or -1
Packit 4b6dd7
 */
Packit 4b6dd7
gint64
Packit 4b6dd7
gdata_calendar_query_get_start_min (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), -1);
Packit 4b6dd7
	return self->priv->start_min;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_start_min:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @start_min: a new minimum start time (in seconds since the UNIX epoch), or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:start-min property of the #GDataCalendarQuery
Packit 4b6dd7
 * to the new time/date, @start_min.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @start_min to -1 to unset the property in the query URI.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_start_min (GDataCalendarQuery *self, gint64 start_min)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
	g_return_if_fail (start_min >= -1);
Packit 4b6dd7
Packit 4b6dd7
	self->priv->start_min = start_min;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "start-min");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_start_max:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:start-max property. If the property is unset, -1 will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the UNIX timestamp (in seconds) for the start-max property, or -1
Packit 4b6dd7
 */
Packit 4b6dd7
gint64
Packit 4b6dd7
gdata_calendar_query_get_start_max (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), -1);
Packit 4b6dd7
	return self->priv->start_max;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_start_max:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @start_max: a new maximum start time (in seconds since the UNIX epoch), or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:start-max property of the #GDataCalendarQuery
Packit 4b6dd7
 * to the new time/date, @start_max.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @start_max to -1 to unset the property in the query URI.
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_start_max (GDataCalendarQuery *self, gint64 start_max)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
	g_return_if_fail (start_max >= -1);
Packit 4b6dd7
Packit 4b6dd7
	self->priv->start_max = start_max;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "start-max");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_timezone:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:timezone property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the timezone property, or %NULL if it is unset
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_calendar_query_get_timezone (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), NULL);
Packit 4b6dd7
	return self->priv->timezone;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_timezone:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @_timezone: (allow-none): a new timezone string, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:timezone property of the #GDataCalendarQuery to the new timezone string, @timezone.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @timezone to %NULL to unset the property in the query URI.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_timezone (GDataCalendarQuery *self, const gchar *_timezone)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->timezone);
Packit 4b6dd7
Packit 4b6dd7
	/* Replace all spaces with underscores */
Packit 4b6dd7
	if (_timezone != NULL) {
Packit 4b6dd7
		gchar *zone, *i;
Packit 4b6dd7
Packit 4b6dd7
		zone = g_strdup (_timezone);
Packit 4b6dd7
		for (i = zone; *i != '\0'; i++) {
Packit 4b6dd7
			if (*i == ' ')
Packit 4b6dd7
				*i = '_';
Packit 4b6dd7
		}
Packit 4b6dd7
		self->priv->timezone = zone;
Packit 4b6dd7
	} else {
Packit 4b6dd7
		self->priv->timezone = NULL;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "timezone");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_get_max_attendees:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:max-attendees property. If the property is unset, 0 will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the maximum number of attendees, or 0
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.9.1
Packit 4b6dd7
 */
Packit 4b6dd7
guint
Packit 4b6dd7
gdata_calendar_query_get_max_attendees (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), 0);
Packit 4b6dd7
	return self->priv->max_attendees;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_max_attendees:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @max_attendees: a new maximum attendee count, or 0
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:max-attendees property of the #GDataCalendarQuery to the new value, @max_attendees.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @max_attendees to 0 to unset the property in the query URI.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.9.1
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_max_attendees (GDataCalendarQuery *self, guint max_attendees)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->max_attendees = max_attendees;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "max-attendees");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_show_deleted:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataCalendarQuery:show-deleted property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if deleted/cancelled events should be shown, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.9.1
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_calendar_query_show_deleted (GDataCalendarQuery *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CALENDAR_QUERY (self), FALSE);
Packit 4b6dd7
	return self->priv->show_deleted;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_calendar_query_set_show_deleted:
Packit 4b6dd7
 * @self: a #GDataCalendarQuery
Packit 4b6dd7
 * @show_deleted: %TRUE to show deleted events, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataCalendarQuery:show-deleted property of the #GDataCalendarQuery.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.9.1
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_calendar_query_set_show_deleted (GDataCalendarQuery *self, gboolean show_deleted)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CALENDAR_QUERY (self));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->show_deleted = show_deleted;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "show-deleted");
Packit 4b6dd7
Packit 4b6dd7
	/* Our current ETag will no longer be relevant */
Packit 4b6dd7
	gdata_query_set_etag (GDATA_QUERY (self), NULL);
Packit 4b6dd7
}