Blame gdata/gcontact/gdata-gcontact-website.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-website
Packit 4b6dd7
 * @short_description: gContact website element
Packit 4b6dd7
 * @stability: Stable
Packit 4b6dd7
 * @include: gdata/gcontact/gdata-gcontact-website.h
Packit 4b6dd7
 *
Packit 4b6dd7
 * #GDataGContactWebsite represents a "website" element from the
Packit 4b6dd7
 * <ulink type="http" url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcWebsite">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-website.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_website_comparable_init (GDataComparableIface *iface);
Packit 4b6dd7
static void gdata_gcontact_website_finalize (GObject *object);
Packit 4b6dd7
static void gdata_gcontact_website_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void gdata_gcontact_website_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 _GDataGContactWebsitePrivate {
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 (GDataGContactWebsite, gdata_gcontact_website, GDATA_TYPE_PARSABLE,
Packit 4b6dd7
                         G_IMPLEMENT_INTERFACE (GDATA_TYPE_COMPARABLE, gdata_gcontact_website_comparable_init))
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_website_class_init (GDataGContactWebsiteClass *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 (GDataGContactWebsitePrivate));
Packit 4b6dd7
Packit 4b6dd7
	gobject_class->get_property = gdata_gcontact_website_get_property;
Packit 4b6dd7
	gobject_class->set_property = gdata_gcontact_website_set_property;
Packit 4b6dd7
	gobject_class->finalize = gdata_gcontact_website_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 = "website";
Packit 4b6dd7
	parsable_class->element_namespace = "gContact";
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactWebsite:uri:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The URI of the website.
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#gcWebsite">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 website.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactWebsite:relation-type:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A programmatic value that identifies the type of website. Examples are %GDATA_GCONTACT_WEBSITE_HOME_PAGE or %GDATA_GCONTACT_WEBSITE_FTP.
Packit 4b6dd7
	 * It is mutually exclusive with #GDataGContactWebsite:label.
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#gcWebsite">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 website.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactWebsite:label:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A simple string value used to name this website. It allows UIs to display a label such as "Work", "Travel blog", "Personal blog", etc.
Packit 4b6dd7
	 * It is mutually exclusive with #GDataGContactWebsite: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#gcWebsite">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 simple string value used to name this website.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGContactWebsite:is-primary:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Indicates which website 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#gcWebsite">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 website 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
	GDataGContactWebsitePrivate *a = ((GDataGContactWebsite*) self)->priv, *b = ((GDataGContactWebsite*) 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_website_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_website_init (GDataGContactWebsite *self)
Packit 4b6dd7
{
Packit 4b6dd7
	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_GCONTACT_WEBSITE, GDataGContactWebsitePrivate);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_website_finalize (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactWebsitePrivate *priv = GDATA_GCONTACT_WEBSITE (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_website_parent_class)->finalize (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gcontact_website_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactWebsitePrivate *priv = GDATA_GCONTACT_WEBSITE (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_website_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGContactWebsite *self = GDATA_GCONTACT_WEBSITE (object);
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_URI:
Packit 4b6dd7
			gdata_gcontact_website_set_uri (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RELATION_TYPE:
Packit 4b6dd7
			gdata_gcontact_website_set_relation_type (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_LABEL:
Packit 4b6dd7
			gdata_gcontact_website_set_label (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_IS_PRIMARY:
Packit 4b6dd7
			gdata_gcontact_website_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
	GDataGContactWebsitePrivate *priv = GDATA_GCONTACT_WEBSITE (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	/* Is it the primary website? */
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
	/* NOTE: We allow both rel and label to be present when we should probably be asserting that they're mutually exclusive. See the comment in
Packit 4b6dd7
	 * pre_get_xml() for details. */
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
		xmlFree (uri);
Packit 4b6dd7
		return gdata_parser_error_required_property_missing (root_node, "rel", error);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	priv->relation_type = (gchar*) rel;
Packit 4b6dd7
	priv->label = (gchar*) label;
Packit 4b6dd7
	priv->uri = (gchar*) uri;
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
	GDataGContactWebsitePrivate *priv = GDATA_GCONTACT_WEBSITE (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, " href='", priv->uri, "'");
Packit 4b6dd7
Packit 4b6dd7
	/* NOTE: We previously allowed both rel and label to be set, making rel mandatory. Since bgo#659016, we treat rel and label as mutually
Packit 4b6dd7
	 * exclusive attributes when parsing. We should treat them as mutually exclusive here as well, and g_assert_not_reached() if neither or
Packit 4b6dd7
	 * both are set (as in gdata-gcontact-event.c:pre_get_xml()), but in order to maintain backwards compatibility, we don't.
Packit 4b6dd7
	 * Sigh, Google. */
Packit 4b6dd7
	if (priv->relation_type != NULL) {
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " rel='", priv->relation_type, "'");
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	if (priv->label != NULL) {
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
Packit 4b6dd7
	}
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_website_new:
Packit 4b6dd7
 * @uri: the website URI
Packit 4b6dd7
 * @relation_type: the relationship between the website and its owner, or %NULL
Packit 4b6dd7
 * @label: (allow-none): a human-readable label for the website, or %NULL
Packit 4b6dd7
 * @is_primary: %TRUE if this website is its owner's primary website, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataGContactWebsite. More information is available in the 
Packit 4b6dd7
 * url="http://code.google.com/apis/contacts/docs/3.0/reference.html#gcWebsite">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 #GDataGContactWebsite; unref with g_object_unref()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGContactWebsite *
Packit 4b6dd7
gdata_gcontact_website_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
	/* NOTE: As in pre_get_xml(), we should treat rel and label as mutually exclusive here, but we can't for backwards compatibility reasons. */
Packit 4b6dd7
Packit 4b6dd7
	return g_object_new (GDATA_TYPE_GCONTACT_WEBSITE, "uri", uri, "relation-type", relation_type, "label", label, "is-primary", is_primary, NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_website_get_uri:
Packit 4b6dd7
 * @self: a #GDataGContactWebsite
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactWebsite:uri property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the URI of the website
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gcontact_website_get_uri (GDataGContactWebsite *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_WEBSITE (self), NULL);
Packit 4b6dd7
	return self->priv->uri;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_website_set_uri:
Packit 4b6dd7
 * @self: a #GDataGContactWebsite
Packit 4b6dd7
 * @uri: the new website URI
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactWebsite:uri property to @uri.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_website_set_uri (GDataGContactWebsite *self, const gchar *uri)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_WEBSITE (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_website_get_relation_type:
Packit 4b6dd7
 * @self: a #GDataGContactWebsite
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactWebsite:relation-type property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the website's relation type
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gcontact_website_get_relation_type (GDataGContactWebsite *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_WEBSITE (self), NULL);
Packit 4b6dd7
	return self->priv->relation_type;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_website_set_relation_type:
Packit 4b6dd7
 * @self: a #GDataGContactWebsite
Packit 4b6dd7
 * @relation_type: the new relation type for the website
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactWebsite:relation-type property to @relation_type
Packit 4b6dd7
 * such as %GDATA_GCONTACT_WEBSITE_HOME_PAGE or %GDATA_GCONTACT_WEBSITE_FTP.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @relation_type is %NULL, the relation type will be unset. When the #GDataGContactWebsite is used in a query, however,
Packit 4b6dd7
 * exactly one of #GDataGContactWebsite:relation-type and #GDataGContactWebsite:label must be %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_website_set_relation_type (GDataGContactWebsite *self, const gchar *relation_type)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_WEBSITE (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_website_get_label:
Packit 4b6dd7
 * @self: a #GDataGContactWebsite
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactWebsite:label property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the website's label, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gcontact_website_get_label (GDataGContactWebsite *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_WEBSITE (self), NULL);
Packit 4b6dd7
	return self->priv->label;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_website_set_label:
Packit 4b6dd7
 * @self: a #GDataGContactWebsite
Packit 4b6dd7
 * @label: (allow-none): the new label for the website, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactWebsite:label property to @label.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @label is %NULL, the label will be unset. When the #GDataGContactWebsite is used in a query, however,
Packit 4b6dd7
 * exactly one of #GDataGContactWebsite:relation-type and #GDataGContactWebsite:label must be %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_website_set_label (GDataGContactWebsite *self, const gchar *label)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_WEBSITE (self));
Packit 4b6dd7
	/* NOTE: We should be validating using the code below, but we can't. See pre_get_xml() for details. */
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_website_is_primary:
Packit 4b6dd7
 * @self: a #GDataGContactWebsite
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGContactWebsite:is-primary property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if this is the primary website, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_gcontact_website_is_primary (GDataGContactWebsite *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GCONTACT_WEBSITE (self), FALSE);
Packit 4b6dd7
	return self->priv->is_primary;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gcontact_website_set_is_primary:
Packit 4b6dd7
 * @self: a #GDataGContactWebsite
Packit 4b6dd7
 * @is_primary: %TRUE if this is the primary website, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGContactWebsite:is-primary property to @is_primary.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gcontact_website_set_is_primary (GDataGContactWebsite *self, gboolean is_primary)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_WEBSITE (self));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->is_primary = is_primary;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "is-primary");
Packit 4b6dd7
}