Blame gdata/gd/gdata-gd-reminder.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 <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-gd-reminder
Packit 4b6dd7
 * @short_description: GData reminder element
Packit 4b6dd7
 * @stability: Stable
Packit 4b6dd7
 * @include: gdata/gd/gdata-gd-reminder.h
Packit 4b6dd7
 *
Packit 4b6dd7
 * #GDataGDReminder represents a "reminder" element from the
Packit 4b6dd7
 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdReminder">GData specification</ulink>.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
#include <glib.h>
Packit 4b6dd7
#include <libxml/parser.h>
Packit 4b6dd7
Packit 4b6dd7
#include "gdata-gd-reminder.h"
Packit 4b6dd7
#include "gdata-parsable.h"
Packit 4b6dd7
#include "gdata-parser.h"
Packit 4b6dd7
#include "gdata-types.h"
Packit 4b6dd7
#include "gdata-comparable.h"
Packit 4b6dd7
Packit 4b6dd7
static void gdata_gd_reminder_comparable_init (GDataComparableIface *iface);
Packit 4b6dd7
static void gdata_gd_reminder_finalize (GObject *object);
Packit 4b6dd7
static void gdata_gd_reminder_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void gdata_gd_reminder_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static gboolean pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error);
Packit 4b6dd7
static void pre_get_xml (GDataParsable *parsable, GString *xml_string);
Packit 4b6dd7
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
Packit 4b6dd7
Packit 4b6dd7
struct _GDataGDReminderPrivate {
Packit 4b6dd7
	gchar *method;
Packit 4b6dd7
	gint64 absolute_time;
Packit 4b6dd7
	gint relative_time;
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
enum {
Packit 4b6dd7
	PROP_METHOD = 1,
Packit 4b6dd7
	PROP_ABSOLUTE_TIME,
Packit 4b6dd7
	PROP_IS_ABSOLUTE_TIME,
Packit 4b6dd7
	PROP_RELATIVE_TIME
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
G_DEFINE_TYPE_WITH_CODE (GDataGDReminder, gdata_gd_reminder, GDATA_TYPE_PARSABLE,
Packit 4b6dd7
                         G_IMPLEMENT_INTERFACE (GDATA_TYPE_COMPARABLE, gdata_gd_reminder_comparable_init))
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_reminder_class_init (GDataGDReminderClass *klass)
Packit 4b6dd7
{
Packit 4b6dd7
	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
Packit 4b6dd7
	GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
Packit 4b6dd7
Packit 4b6dd7
	g_type_class_add_private (klass, sizeof (GDataGDReminderPrivate));
Packit 4b6dd7
Packit 4b6dd7
	gobject_class->get_property = gdata_gd_reminder_get_property;
Packit 4b6dd7
	gobject_class->set_property = gdata_gd_reminder_set_property;
Packit 4b6dd7
	gobject_class->finalize = gdata_gd_reminder_finalize;
Packit 4b6dd7
Packit 4b6dd7
	parsable_class->pre_parse_xml = pre_parse_xml;
Packit 4b6dd7
	parsable_class->pre_get_xml = pre_get_xml;
Packit 4b6dd7
	parsable_class->get_namespaces = get_namespaces;
Packit 4b6dd7
	parsable_class->element_name = "reminder";
Packit 4b6dd7
	parsable_class->element_namespace = "gd";
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDReminder:method:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The notification method the reminder should use. For example: %GDATA_GD_REMINDER_ALERT or %GDATA_GD_REMINDER_EMAIL.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdReminder">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_METHOD,
Packit 4b6dd7
	                                 g_param_spec_string ("method",
Packit 4b6dd7
	                                                      "Method", "The notification method the reminder should use.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDReminder:absolute-time:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Absolute time at which the reminder should be issued.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdReminder">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_ABSOLUTE_TIME,
Packit 4b6dd7
	                                 g_param_spec_int64 ("absolute-time",
Packit 4b6dd7
	                                                     "Absolute time", "Absolute time at which the reminder should be issued.",
Packit 4b6dd7
	                                                     -1, G_MAXINT64, -1,
Packit 4b6dd7
	                                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDReminder:is-absolute-time:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Whether the reminder is specified as an absolute or relative time.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdReminder">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_IS_ABSOLUTE_TIME,
Packit 4b6dd7
	                                 g_param_spec_boolean ("is-absolute-time",
Packit 4b6dd7
	                                                       "Absolute time?", "Whether the reminder is specified as an absolute or relative time.",
Packit 4b6dd7
	                                                       FALSE,
Packit 4b6dd7
	                                                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDReminder:relative-time:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Time at which the reminder should be issued, in minutes relative to the start time of the corresponding event.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdReminder">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_RELATIVE_TIME,
Packit 4b6dd7
	                                 g_param_spec_int ("relative-time",
Packit 4b6dd7
	                                                   "Relative time", "Time at which the reminder should be issued, in minutes.",
Packit 4b6dd7
	                                                   -1, G_MAXINT, -1,
Packit 4b6dd7
	                                                   G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gint
Packit 4b6dd7
compare_with (GDataComparable *self, GDataComparable *other)
Packit 4b6dd7
{
Packit 4b6dd7
	gint method_cmp, time_cmp;
Packit 4b6dd7
	GDataGDReminder *a = (GDataGDReminder*) self, *b = (GDataGDReminder*) other;
Packit 4b6dd7
Packit 4b6dd7
	if (gdata_gd_reminder_is_absolute_time (a) != gdata_gd_reminder_is_absolute_time (b))
Packit 4b6dd7
		return 1;
Packit 4b6dd7
Packit 4b6dd7
	method_cmp = g_strcmp0 (a->priv->method, b->priv->method);
Packit 4b6dd7
	if (gdata_gd_reminder_is_absolute_time (a) == TRUE) {
Packit 4b6dd7
		time_cmp = a->priv->absolute_time - b->priv->absolute_time;
Packit 4b6dd7
	} else {
Packit 4b6dd7
		time_cmp = a->priv->relative_time - b->priv->relative_time;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (method_cmp == 0)
Packit 4b6dd7
		return time_cmp;
Packit 4b6dd7
	else
Packit 4b6dd7
		return method_cmp;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_reminder_comparable_init (GDataComparableIface *iface)
Packit 4b6dd7
{
Packit 4b6dd7
	iface->compare_with = compare_with;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_reminder_init (GDataGDReminder *self)
Packit 4b6dd7
{
Packit 4b6dd7
	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_GD_REMINDER, GDataGDReminderPrivate);
Packit 4b6dd7
	self->priv->absolute_time = -1;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_reminder_finalize (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGDReminderPrivate *priv = GDATA_GD_REMINDER (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_free (priv->method);
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	G_OBJECT_CLASS (gdata_gd_reminder_parent_class)->finalize (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_reminder_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGDReminderPrivate *priv = GDATA_GD_REMINDER (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_METHOD:
Packit 4b6dd7
			g_value_set_string (value, priv->method);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_ABSOLUTE_TIME:
Packit 4b6dd7
			g_value_set_int64 (value, priv->absolute_time);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_IS_ABSOLUTE_TIME:
Packit 4b6dd7
			g_value_set_boolean (value, gdata_gd_reminder_is_absolute_time (GDATA_GD_REMINDER (object)));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RELATIVE_TIME:
Packit 4b6dd7
			g_value_set_int (value, priv->relative_time);
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_gd_reminder_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGDReminder *self = GDATA_GD_REMINDER (object);
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_METHOD:
Packit 4b6dd7
			gdata_gd_reminder_set_method (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_ABSOLUTE_TIME:
Packit 4b6dd7
			gdata_gd_reminder_set_absolute_time (self, g_value_get_int64 (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RELATIVE_TIME:
Packit 4b6dd7
			gdata_gd_reminder_set_relative_time (self, g_value_get_int (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
static gboolean
Packit 4b6dd7
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGDReminderPrivate *priv = GDATA_GD_REMINDER (parsable)->priv;
Packit 4b6dd7
	xmlChar *absolute_time, *relative_time;
Packit 4b6dd7
	gint64 absolute_time_int64;
Packit 4b6dd7
	gint relative_time_int = -1;
Packit 4b6dd7
	gboolean is_absolute_time = FALSE;
Packit 4b6dd7
Packit 4b6dd7
	/* Absolute time */
Packit 4b6dd7
	absolute_time = xmlGetProp (root_node, (xmlChar*) "absoluteTime");
Packit 4b6dd7
	if (absolute_time != NULL) {
Packit 4b6dd7
		is_absolute_time = TRUE;
Packit 4b6dd7
		if (gdata_parser_int64_from_iso8601 ((gchar*) absolute_time, &absolute_time_int64) == FALSE) {
Packit 4b6dd7
			/* Error */
Packit 4b6dd7
			gdata_parser_error_not_iso8601_format (root_node, (gchar*) absolute_time, error);
Packit 4b6dd7
			xmlFree (absolute_time);
Packit 4b6dd7
			return FALSE;
Packit 4b6dd7
		}
Packit 4b6dd7
		xmlFree (absolute_time);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Relative time */
Packit 4b6dd7
	relative_time = xmlGetProp (root_node, (xmlChar*) "days");
Packit 4b6dd7
	if (relative_time != NULL) {
Packit 4b6dd7
		relative_time_int = g_ascii_strtoll ((gchar*) relative_time, NULL, 10) * 60 * 24;
Packit 4b6dd7
	} else {
Packit 4b6dd7
		relative_time = xmlGetProp (root_node, (xmlChar*) "hours");
Packit 4b6dd7
		if (relative_time != NULL) {
Packit 4b6dd7
			relative_time_int = g_ascii_strtoll ((gchar*) relative_time, NULL, 10) * 60;
Packit 4b6dd7
		} else {
Packit 4b6dd7
			relative_time = xmlGetProp (root_node, (xmlChar*) "minutes");
Packit 4b6dd7
			if (relative_time != NULL)
Packit 4b6dd7
				relative_time_int = g_ascii_strtoll ((gchar*) relative_time, NULL, 10);
Packit 4b6dd7
		}
Packit 4b6dd7
	}
Packit 4b6dd7
	xmlFree (relative_time);
Packit 4b6dd7
Packit 4b6dd7
	if (is_absolute_time == TRUE) {
Packit 4b6dd7
		priv->absolute_time = absolute_time_int64;
Packit 4b6dd7
		priv->relative_time = -1;
Packit 4b6dd7
	} else {
Packit 4b6dd7
		priv->absolute_time = -1;
Packit 4b6dd7
		priv->relative_time = relative_time_int;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	priv->method = (gchar*) xmlGetProp (root_node, (xmlChar*) "method");
Packit 4b6dd7
Packit 4b6dd7
	return TRUE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
pre_get_xml (GDataParsable *parsable, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGDReminderPrivate *priv = GDATA_GD_REMINDER (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	if (priv->relative_time == -1) {
Packit 4b6dd7
		gchar *absolute_time = gdata_parser_int64_to_iso8601 (priv->absolute_time);
Packit 4b6dd7
		g_string_append_printf (xml_string, " absoluteTime='%s'", absolute_time);
Packit 4b6dd7
		g_free (absolute_time);
Packit 4b6dd7
	} else {
Packit 4b6dd7
		g_string_append_printf (xml_string, " minutes='%i'", priv->relative_time);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->method != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " method='", priv->method, "'");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
Packit 4b6dd7
{
Packit 4b6dd7
	g_hash_table_insert (namespaces, (gchar*) "gd", (gchar*) "http://schemas.google.com/g/2005");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_reminder_new:
Packit 4b6dd7
 * @method: (allow-none): the notification method the reminder should use, or %NULL
Packit 4b6dd7
 * @absolute_time: the absolute time for the reminder, or -1
Packit 4b6dd7
 * @relative_time: the relative time for the reminder, in minutes, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataGDReminder. More information is available in the 
Packit 4b6dd7
 * url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdReminder">GData specification</ulink>.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a new #GDataGDReminder, or %NULL; unref with g_object_unref()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGDReminder *
Packit 4b6dd7
gdata_gd_reminder_new (const gchar *method, gint64 absolute_time, gint relative_time)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (absolute_time == -1 || relative_time == -1, NULL);
Packit 4b6dd7
	g_return_val_if_fail (absolute_time >= -1, NULL);
Packit 4b6dd7
	g_return_val_if_fail (relative_time >= -1, NULL);
Packit 4b6dd7
	return g_object_new (GDATA_TYPE_GD_REMINDER, "absolute-time", absolute_time, "relative-time", relative_time, "method", method, NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_reminder_get_method:
Packit 4b6dd7
 * @self: a #GDataGDReminder
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGDReminder:method property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the method, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gd_reminder_get_method (GDataGDReminder *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_REMINDER (self), NULL);
Packit 4b6dd7
	return self->priv->method;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_reminder_set_method:
Packit 4b6dd7
 * @self: a #GDataGDReminder
Packit 4b6dd7
 * @method: (allow-none): the new method, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGDReminder:method property to @method.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @method to %NULL to unset the property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gd_reminder_set_method (GDataGDReminder *self, const gchar *method)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_REMINDER (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->method);
Packit 4b6dd7
	self->priv->method = g_strdup (method);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "method");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_reminder_get_absolute_time:
Packit 4b6dd7
 * @self: a #GDataGDReminder
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGDReminder:absolute-time property. If the property is unset, -1 will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the UNIX timestamp of the absolute time for the reminder, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
gint64
Packit 4b6dd7
gdata_gd_reminder_get_absolute_time (GDataGDReminder *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_REMINDER (self), -1);
Packit 4b6dd7
	return self->priv->absolute_time;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_reminder_set_absolute_time:
Packit 4b6dd7
 * @self: a #GDataGDReminder
Packit 4b6dd7
 * @absolute_time: the new absolute time, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGDReminder:absolute-time property to @absolute_time.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @absolute_time to -1 to unset the property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gd_reminder_set_absolute_time (GDataGDReminder *self, gint64 absolute_time)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_REMINDER (self));
Packit 4b6dd7
	g_return_if_fail (absolute_time >= -1);
Packit 4b6dd7
Packit 4b6dd7
	self->priv->absolute_time = absolute_time;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "absolute-time");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_reminder_is_absolute_time:
Packit 4b6dd7
 * @self: a #GDataGDReminder
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns whether the reminder is specified as an absolute time, or as a number of minutes after
Packit 4b6dd7
 * the corresponding event's start time.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if the reminder is absolute, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_gd_reminder_is_absolute_time (GDataGDReminder *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_REMINDER (self), FALSE);
Packit 4b6dd7
	return (self->priv->relative_time == -1) ? TRUE : FALSE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_reminder_get_relative_time:
Packit 4b6dd7
 * @self: a #GDataGDReminder
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGDReminder:relative-time property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the relative time, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
gint
Packit 4b6dd7
gdata_gd_reminder_get_relative_time (GDataGDReminder *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_REMINDER (self), -1);
Packit 4b6dd7
	return self->priv->relative_time;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_reminder_set_relative_time:
Packit 4b6dd7
 * @self: a #GDataGDReminder
Packit 4b6dd7
 * @relative_time: the new relative time, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGDReminder:relative-time property to @relative_time.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @relative_time to -1 to unset the property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gd_reminder_set_relative_time (GDataGDReminder *self, gint relative_time)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_REMINDER (self));
Packit 4b6dd7
	g_return_if_fail (relative_time >= -1);
Packit 4b6dd7
Packit 4b6dd7
	self->priv->relative_time = relative_time;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "method");
Packit 4b6dd7
}