Blame gdata/gcontact/gdata-gcontact-relation.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-relation
Packit 4b6dd7
 * @short_description: gContact relation element
Packit 4b6dd7
 * @stability: Stable
Packit 4b6dd7
 * @include: gdata/gcontact/gdata-gcontact-relation.h
Packit 4b6dd7
 *
Packit 4b6dd7
 * #GDataGContactRelation represents a "relation" element from the
Packit 4b6dd7
 * <ulink type="http" url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcJot">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-relation.h"
Packit 4b6dd7
#include "gdata-parsable.h"
Packit 4b6dd7
#include "gdata-parser.h"
Packit 4b6dd7
Packit 4b6dd7
static void gdata_gcontact_relation_finalize (GObject *object);
Packit 4b6dd7
static void gdata_gcontact_relation_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void gdata_gcontact_relation_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 gboolean 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_xml (GDataParsable *parsable, GString *xml_string);
Packit 4b6dd7
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
Packit 4b6dd7
Packit 4b6dd7
struct _GDataGContactRelationPrivate {
Packit 4b6dd7
	gchar *name;
Packit 4b6dd7
	gchar *relation_type;
Packit 4b6dd7
	gchar *label;
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
enum {
Packit 4b6dd7
	PROP_NAME = 1,
Packit 4b6dd7
	PROP_RELATION_TYPE,
Packit 4b6dd7
	PROP_LABEL
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
G_DEFINE_TYPE (GDataGContactRelation, gdata_gcontact_relation, GDATA_TYPE_PARSABLE)
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_relation_class_init (GDataGContactRelationClass *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 (GDataGContactRelationPrivate));
Packit 4b6dd7
Packit 4b6dd7
	gobject_class->get_property = gdata_gcontact_relation_get_property;
Packit 4b6dd7
	gobject_class->set_property = gdata_gcontact_relation_set_property;
Packit 4b6dd7
	gobject_class->finalize = gdata_gcontact_relation_finalize;
Packit 4b6dd7
Packit 4b6dd7
	parsable_class->pre_parse_xml = pre_parse_xml;
Packit 4b6dd7
	parsable_class->parse_xml = parse_xml;
Packit 4b6dd7
	parsable_class->pre_get_xml = pre_get_xml;
Packit 4b6dd7
	parsable_class->get_xml = get_xml;
Packit 4b6dd7
	parsable_class->get_namespaces = get_namespaces;
Packit 4b6dd7
	parsable_class->element_name = "relation";
Packit 4b6dd7
	parsable_class->element_namespace = "gContact";
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactRelation:name:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The name of the relation. It need not be a full name, and there need not be a contact representing the name.
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#gcRelation">gContact specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_NAME,
Packit 4b6dd7
	                                 g_param_spec_string ("name",
Packit 4b6dd7
	                                                      "Name", "The name of the relation.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactRelation:relation-type:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A programmatic value that identifies the type of relation. It is mutually exclusive with #GDataGContactRelation:label.
Packit 4b6dd7
	 * Examples are %GDATA_GCONTACT_RELATION_MANAGER or %GDATA_GCONTACT_RELATION_CHILD.
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#gcRelation">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 relation.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactRelation:label:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A free-form string that identifies the type of relation. It is mutually exclusive with #GDataGContactRelation: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#gcRelation">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 relation.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_relation_init (GDataGContactRelation *self)
Packit 4b6dd7
{
Packit 4b6dd7
	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_GCONTACT_RELATION, GDataGContactRelationPrivate);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_relation_finalize (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactRelationPrivate *priv = GDATA_GCONTACT_RELATION (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_free (priv->name);
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_relation_parent_class)->finalize (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_relation_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactRelationPrivate *priv = GDATA_GCONTACT_RELATION (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_NAME:
Packit 4b6dd7
			g_value_set_string (value, priv->name);
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
		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_relation_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactRelation *self = GDATA_GCONTACT_RELATION (object);
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_NAME:
Packit 4b6dd7
			gdata_gcontact_relation_set_name (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RELATION_TYPE:
Packit 4b6dd7
			gdata_gcontact_relation_set_relation_type (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_LABEL:
Packit 4b6dd7
			gdata_gcontact_relation_set_label (self, g_value_get_string (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 *rel, *label, *name;
Packit 4b6dd7
	GDataGContactRelationPrivate *priv = GDATA_GCONTACT_RELATION (parsable)->priv;
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 (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 (rel);
Packit 4b6dd7
		xmlFree (label);
Packit 4b6dd7
		return gdata_parser_error_mutexed_properties (root_node, "rel", "label", error);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Get the name */
Packit 4b6dd7
	name = xmlNodeListGetString (doc, root_node->children, TRUE);
Packit 4b6dd7
	if (name == NULL || *name == '\0') {
Packit 4b6dd7
		xmlFree (rel);
Packit 4b6dd7
		xmlFree (label);
Packit 4b6dd7
		xmlFree (name);
Packit 4b6dd7
		return gdata_parser_error_required_content_missing (root_node, error);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	priv->name = (gchar*) name;
Packit 4b6dd7
	priv->relation_type = (gchar*) rel;
Packit 4b6dd7
	priv->label = (gchar*) label;
Packit 4b6dd7
Packit 4b6dd7
	return TRUE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gboolean
Packit 4b6dd7
parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	/* Textual content's handled in pre_parse_xml */
Packit 4b6dd7
	if (node->type != XML_ELEMENT_NODE)
Packit 4b6dd7
		return TRUE;
Packit 4b6dd7
Packit 4b6dd7
	return GDATA_PARSABLE_CLASS (gdata_gcontact_relation_parent_class)->parse_xml (parsable, doc, node, user_data, error);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
pre_get_xml (GDataParsable *parsable, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactRelationPrivate *priv = GDATA_GCONTACT_RELATION (parsable)->priv;
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
Packit 4b6dd7
static void
Packit 4b6dd7
get_xml (GDataParsable *parsable, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, NULL, GDATA_GCONTACT_RELATION (parsable)->priv->name, NULL);
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_relation_new:
Packit 4b6dd7
 * @name: the name of the relation
Packit 4b6dd7
 * @relation_type: (allow-none): the type of relation, or %NULL
Packit 4b6dd7
 * @label: (allow-none): a free-form label for the type of relation, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataGContactRelation. More information is available in the 
Packit 4b6dd7
 * url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcRelation">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 #GDataGContactRelation; unref with g_object_unref()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGContactRelation *
Packit 4b6dd7
gdata_gcontact_relation_new (const gchar *name, const gchar *relation_type, const gchar *label)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (name != NULL && *name != '\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_RELATION, "name", name, "relation-type", relation_type, "label", label, NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_relation_get_name:
Packit 4b6dd7
 * @self: a #GDataGContactRelation
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactRelation:name property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the relation's name
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gcontact_relation_get_name (GDataGContactRelation *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_RELATION (self), NULL);
Packit 4b6dd7
	return self->priv->name;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_relation_set_name:
Packit 4b6dd7
 * @self: a #GDataGContactRelation
Packit 4b6dd7
 * @name: (allow-none): the new name for the relation
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactRelation:name property to @name.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_relation_set_name (GDataGContactRelation *self, const gchar *name)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_RELATION (self));
Packit 4b6dd7
	g_return_if_fail (name != NULL && *name != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->name);
Packit 4b6dd7
	self->priv->name = g_strdup (name);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "name");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_relation_get_relation_type:
Packit 4b6dd7
 * @self: a #GDataGContactRelation
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactRelation: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_relation_get_relation_type (GDataGContactRelation *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_RELATION (self), NULL);
Packit 4b6dd7
	return self->priv->relation_type;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_relation_set_relation_type:
Packit 4b6dd7
 * @self: a #GDataGContactRelation
Packit 4b6dd7
 * @relation_type: (allow-none): the new type for the relation, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactRelation:relation-type property to @relation_type,
Packit 4b6dd7
 * such as %GDATA_GCONTACT_RELATION_MANAGER or %GDATA_GCONTACT_RELATION_CHILD.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @relation_type is %NULL, the relation type will be unset. When the #GDataGContactRelation is used in a query, however,
Packit 4b6dd7
 * exactly one of #GDataGContactRelation:relation-type and #GDataGContactRelation:label must be %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_relation_set_relation_type (GDataGContactRelation *self, const gchar *relation_type)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_RELATION (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_relation_get_label:
Packit 4b6dd7
 * @self: a #GDataGContactRelation
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactRelation:label property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a free-form label for 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_relation_get_label (GDataGContactRelation *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_RELATION (self), NULL);
Packit 4b6dd7
	return self->priv->label;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_relation_set_label:
Packit 4b6dd7
 * @self: a #GDataGContactRelation
Packit 4b6dd7
 * @label: (allow-none): the new free-form type for the relation, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactRelation:label property to @label.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @label is %NULL, the label will be unset. When the #GDataGContactRelation is used in a query, however,
Packit 4b6dd7
 * exactly one of #GDataGContactRelation:relation-type and #GDataGContactRelation:label must be %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_relation_set_label (GDataGContactRelation *self, const gchar *label)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_RELATION (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
}