Blame gdata/gcontact/gdata-gcontact-calendar.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 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-gcontact-calendar
Packit 4b6dd7
 * @short_description: gContact calendar element
Packit 4b6dd7
 * @stability: Stable
Packit 4b6dd7
 * @include: gdata/gcontact/gdata-gcontact-calendar.h
Packit 4b6dd7
 *
Packit 4b6dd7
 * #GDataGContactCalendar represents a "calendarLink" element from the
Packit 4b6dd7
 * <ulink type="http" url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcCalendarLink">gContact specification</ulink>.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
#include <glib.h>
Packit 4b6dd7
#include <libxml/parser.h>
Packit 4b6dd7
Packit 4b6dd7
#include "gdata-gcontact-calendar.h"
Packit 4b6dd7
#include "gdata-parsable.h"
Packit 4b6dd7
#include "gdata-parser.h"
Packit 4b6dd7
#include "gdata-comparable.h"
Packit 4b6dd7
Packit 4b6dd7
static void gdata_gcontact_calendar_comparable_init (GDataComparableIface *iface);
Packit 4b6dd7
static void gdata_gcontact_calendar_finalize (GObject *object);
Packit 4b6dd7
static void gdata_gcontact_calendar_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void gdata_gcontact_calendar_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 _GDataGContactCalendarPrivate {
Packit 4b6dd7
	gchar *uri;
Packit 4b6dd7
	gchar *relation_type;
Packit 4b6dd7
	gchar *label;
Packit 4b6dd7
	gboolean is_primary;
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
enum {
Packit 4b6dd7
	PROP_URI = 1,
Packit 4b6dd7
	PROP_RELATION_TYPE,
Packit 4b6dd7
	PROP_LABEL,
Packit 4b6dd7
	PROP_IS_PRIMARY
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
G_DEFINE_TYPE_WITH_CODE (GDataGContactCalendar, gdata_gcontact_calendar, GDATA_TYPE_PARSABLE,
Packit 4b6dd7
                         G_IMPLEMENT_INTERFACE (GDATA_TYPE_COMPARABLE, gdata_gcontact_calendar_comparable_init))
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_calendar_class_init (GDataGContactCalendarClass *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 (GDataGContactCalendarPrivate));
Packit 4b6dd7
Packit 4b6dd7
	gobject_class->get_property = gdata_gcontact_calendar_get_property;
Packit 4b6dd7
	gobject_class->set_property = gdata_gcontact_calendar_set_property;
Packit 4b6dd7
	gobject_class->finalize = gdata_gcontact_calendar_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 = "calendarLink";
Packit 4b6dd7
	parsable_class->element_namespace = "gContact";
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactCalendar:uri:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The URI of the calendar.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcCalendarLink">gContact specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_URI,
Packit 4b6dd7
	                                 g_param_spec_string ("uri",
Packit 4b6dd7
	                                                      "URI", "The URI of the calendar.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactCalendar:relation-type:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A programmatic value that identifies the type of calendar. It is mutually exclusive with #GDataGContactCalendar:label.
Packit 4b6dd7
	 * Examples are %GDATA_GCONTACT_CALENDAR_HOME or %GDATA_GCONTACT_CALENDAR_FREE_BUSY.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcCalendarLink">gContact specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_RELATION_TYPE,
Packit 4b6dd7
	                                 g_param_spec_string ("relation-type",
Packit 4b6dd7
	                                                      "Relation type", "A programmatic value that identifies the type of calendar.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactCalendar:label:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A free-form string that identifies the type of calendar. It is mutually exclusive with #GDataGContactCalendar:relation-type.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcCalendarLink">gContact specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_LABEL,
Packit 4b6dd7
	                                 g_param_spec_string ("label",
Packit 4b6dd7
	                                                      "Label", "A free-form string that identifies the type of calendar.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactCalendar:is-primary:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Indicates which calendar out of a group is primary.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the
Packit 4b6dd7
	 * <ulink type="http" url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcCalendarLink">gContact specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_IS_PRIMARY,
Packit 4b6dd7
	                                 g_param_spec_boolean ("is-primary",
Packit 4b6dd7
	                                                       "Primary?", "Indicates which calendar out of a group is primary.",
Packit 4b6dd7
	                                                       FALSE,
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
	GDataGContactCalendarPrivate *a = ((GDataGContactCalendar*) self)->priv, *b = ((GDataGContactCalendar*) other)->priv;
Packit 4b6dd7
Packit 4b6dd7
	if (g_strcmp0 (a->uri, b->uri) == 0 && g_strcmp0 (a->relation_type, b->relation_type) == 0 && g_strcmp0 (a->label, b->label) == 0)
Packit 4b6dd7
		return 0;
Packit 4b6dd7
	return 1;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_calendar_comparable_init (GDataComparableIface *iface)
Packit 4b6dd7
{
Packit 4b6dd7
	iface->compare_with = compare_with;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_calendar_init (GDataGContactCalendar *self)
Packit 4b6dd7
{
Packit 4b6dd7
	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_GCONTACT_CALENDAR, GDataGContactCalendarPrivate);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_calendar_finalize (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactCalendarPrivate *priv = GDATA_GCONTACT_CALENDAR (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_free (priv->uri);
Packit 4b6dd7
	g_free (priv->relation_type);
Packit 4b6dd7
	g_free (priv->label);
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	G_OBJECT_CLASS (gdata_gcontact_calendar_parent_class)->finalize (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_calendar_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactCalendarPrivate *priv = GDATA_GCONTACT_CALENDAR (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_URI:
Packit 4b6dd7
			g_value_set_string (value, priv->uri);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RELATION_TYPE:
Packit 4b6dd7
			g_value_set_string (value, priv->relation_type);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_LABEL:
Packit 4b6dd7
			g_value_set_string (value, priv->label);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_IS_PRIMARY:
Packit 4b6dd7
			g_value_set_boolean (value, priv->is_primary);
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_gcontact_calendar_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactCalendar *self = GDATA_GCONTACT_CALENDAR (object);
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_URI:
Packit 4b6dd7
			gdata_gcontact_calendar_set_uri (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RELATION_TYPE:
Packit 4b6dd7
			gdata_gcontact_calendar_set_relation_type (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_LABEL:
Packit 4b6dd7
			gdata_gcontact_calendar_set_label (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_IS_PRIMARY:
Packit 4b6dd7
			gdata_gcontact_calendar_set_is_primary (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
static gboolean
Packit 4b6dd7
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	xmlChar *uri, *rel, *label;
Packit 4b6dd7
	gboolean primary_bool;
Packit 4b6dd7
	GDataGContactCalendarPrivate *priv = GDATA_GCONTACT_CALENDAR (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	/* Is it the primary calendar? */
Packit 4b6dd7
	if (gdata_parser_boolean_from_property (root_node, "primary", &primary_bool, 0, error) == FALSE)
Packit 4b6dd7
		return FALSE;
Packit 4b6dd7
Packit 4b6dd7
	uri = xmlGetProp (root_node, (xmlChar*) "href");
Packit 4b6dd7
	if (uri == NULL || *uri == '\0') {
Packit 4b6dd7
		xmlFree (uri);
Packit 4b6dd7
		return gdata_parser_error_required_property_missing (root_node, "href", error);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	rel = xmlGetProp (root_node, (xmlChar*) "rel");
Packit 4b6dd7
	label = xmlGetProp (root_node, (xmlChar*) "label");
Packit 4b6dd7
	if ((rel == NULL || *rel == '\0') && (label == NULL || *label == '\0')) {
Packit 4b6dd7
		xmlFree (uri);
Packit 4b6dd7
		xmlFree (rel);
Packit 4b6dd7
		xmlFree (label);
Packit 4b6dd7
		return gdata_parser_error_required_property_missing (root_node, "rel", error);
Packit 4b6dd7
	} else if (rel != NULL && label != NULL) {
Packit 4b6dd7
		/* Can't have both set at once */
Packit 4b6dd7
		xmlFree (uri);
Packit 4b6dd7
		xmlFree (rel);
Packit 4b6dd7
		xmlFree (label);
Packit 4b6dd7
		return gdata_parser_error_mutexed_properties (root_node, "rel", "label", error);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	priv->uri = (gchar*) uri;
Packit 4b6dd7
	priv->relation_type = (gchar*) rel;
Packit 4b6dd7
	priv->label = (gchar*) label;
Packit 4b6dd7
	priv->is_primary = primary_bool;
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
	GDataGContactCalendarPrivate *priv = GDATA_GCONTACT_CALENDAR (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, " href='", priv->uri, "'");
Packit 4b6dd7
Packit 4b6dd7
	if (priv->relation_type != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " rel='", priv->relation_type, "'");
Packit 4b6dd7
	else if (priv->label != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
Packit 4b6dd7
	else
Packit 4b6dd7
		g_assert_not_reached ();
Packit 4b6dd7
Packit 4b6dd7
	if (priv->is_primary == TRUE)
Packit 4b6dd7
		g_string_append (xml_string, " primary='true'");
Packit 4b6dd7
	else
Packit 4b6dd7
		g_string_append (xml_string, " primary='false'");
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*) "gContact", (gchar*) "http://schemas.google.com/contact/2008");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_new:
Packit 4b6dd7
 * @uri: the URI of the calendar
Packit 4b6dd7
 * @relation_type: (allow-none): the type of calendar, or %NULL
Packit 4b6dd7
 * @label: (allow-none): a free-form label for the calendar, or %NULL
Packit 4b6dd7
 * @is_primary: %TRUE if this calendar is its owner's primary calendar, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataGContactCalendar. More information is available in the 
Packit 4b6dd7
 * url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcCalendarLink">gContact specification</ulink>.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Exactly one of @relation_type and @label should be provided; the other must be %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a new #GDataGContactCalendar; unref with g_object_unref()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGContactCalendar *
Packit 4b6dd7
gdata_gcontact_calendar_new (const gchar *uri, const gchar *relation_type, const gchar *label, gboolean is_primary)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (uri != NULL && *uri != '\0', NULL);
Packit 4b6dd7
	g_return_val_if_fail ((relation_type != NULL && *relation_type != '\0' && label == NULL) ||
Packit 4b6dd7
	                      (relation_type == NULL && label != NULL && *label != '\0'), NULL);
Packit 4b6dd7
Packit 4b6dd7
	return g_object_new (GDATA_TYPE_GCONTACT_CALENDAR,
Packit 4b6dd7
	                     "uri", uri, "relation-type", relation_type, "label", label, "is-primary", is_primary, NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_get_uri:
Packit 4b6dd7
 * @self: a #GDataGContactCalendar
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactCalendar:uri property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the calendar's URI
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gcontact_calendar_get_uri (GDataGContactCalendar *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_CALENDAR (self), NULL);
Packit 4b6dd7
	return self->priv->uri;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_set_uri:
Packit 4b6dd7
 * @self: a #GDataGContactCalendar
Packit 4b6dd7
 * @uri: the new URI for the calendar
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactCalendar:uri property to @uri.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_calendar_set_uri (GDataGContactCalendar *self, const gchar *uri)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_CALENDAR (self));
Packit 4b6dd7
	g_return_if_fail (uri != NULL && *uri != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->uri);
Packit 4b6dd7
	self->priv->uri = g_strdup (uri);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "uri");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_get_relation_type:
Packit 4b6dd7
 * @self: a #GDataGContactCalendar
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactCalendar:relation-type property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the type of the relation, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gcontact_calendar_get_relation_type (GDataGContactCalendar *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_CALENDAR (self), NULL);
Packit 4b6dd7
	return self->priv->relation_type;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_set_relation_type:
Packit 4b6dd7
 * @self: a #GDataGContactCalendar
Packit 4b6dd7
 * @relation_type: (allow-none): the new type for the calendar, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactCalendar:relation-type property to @relation_type,
Packit 4b6dd7
 * such as %GDATA_GCONTACT_CALENDAR_HOME or %GDATA_GCONTACT_CALENDAR_FREE_BUSY.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @relation_type is %NULL, the relation type will be unset. When the #GDataGContactCalendar is used in a query, however,
Packit 4b6dd7
 * exactly one of #GDataGContactCalendar:relation-type and #GDataGContactCalendar:label must be %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_calendar_set_relation_type (GDataGContactCalendar *self, const gchar *relation_type)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_CALENDAR (self));
Packit 4b6dd7
	g_return_if_fail (relation_type == NULL || *relation_type != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->relation_type);
Packit 4b6dd7
	self->priv->relation_type = g_strdup (relation_type);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "relation-type");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_get_label:
Packit 4b6dd7
 * @self: a #GDataGContactCalendar
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactCalendar:label property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a free-form label for the calendar, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gcontact_calendar_get_label (GDataGContactCalendar *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_CALENDAR (self), NULL);
Packit 4b6dd7
	return self->priv->label;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_set_label:
Packit 4b6dd7
 * @self: a #GDataGContactCalendar
Packit 4b6dd7
 * @label: (allow-none): the new free-form label for the calendar, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactCalendar:label property to @label.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @label is %NULL, the label will be unset. When the #GDataGContactCalendar is used in a query, however,
Packit 4b6dd7
 * exactly one of #GDataGContactCalendar:relation-type and #GDataGContactCalendar:label must be %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_calendar_set_label (GDataGContactCalendar *self, const gchar *label)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_CALENDAR (self));
Packit 4b6dd7
	g_return_if_fail (label == NULL || *label != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->label);
Packit 4b6dd7
	self->priv->label = g_strdup (label);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "label");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_is_primary:
Packit 4b6dd7
 * @self: a #GDataGContactCalendar
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactCalendar:is-primary property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if this is the contact's primary calendar, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_gcontact_calendar_is_primary (GDataGContactCalendar *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_CALENDAR (self), FALSE);
Packit 4b6dd7
	return self->priv->is_primary;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_calendar_set_is_primary:
Packit 4b6dd7
 * @self: a #GDataGContactCalendar
Packit 4b6dd7
 * @is_primary: %TRUE if this is the contact's primary calendar, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactCalendar:is-primary property to @is_primary.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_calendar_set_is_primary (GDataGContactCalendar *self, gboolean is_primary)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_CALENDAR (self));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->is_primary = is_primary;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "is-primary");
Packit 4b6dd7
}