Blame gdata/gd/gdata-gd-email-address.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-email-address
Packit 4b6dd7
 * @short_description: GData e-mail address element
Packit 4b6dd7
 * @stability: Stable
Packit 4b6dd7
 * @include: gdata/gd/gdata-gd-email-address.h
Packit 4b6dd7
 *
Packit 4b6dd7
 * #GDataGDEmailAddress represents an "email" element from the
Packit 4b6dd7
 * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdEmail">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-email-address.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_gd_email_address_comparable_init (GDataComparableIface *iface);
Packit 4b6dd7
static void gdata_gd_email_address_finalize (GObject *object);
Packit 4b6dd7
static void gdata_gd_email_address_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void gdata_gd_email_address_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 _GDataGDEmailAddressPrivate {
Packit 4b6dd7
	gchar *address;
Packit 4b6dd7
	gchar *relation_type;
Packit 4b6dd7
	gchar *label;
Packit 4b6dd7
	gboolean is_primary;
Packit 4b6dd7
	gchar *display_name;
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
enum {
Packit 4b6dd7
	PROP_ADDRESS = 1,
Packit 4b6dd7
	PROP_RELATION_TYPE,
Packit 4b6dd7
	PROP_LABEL,
Packit 4b6dd7
	PROP_IS_PRIMARY,
Packit 4b6dd7
	PROP_DISPLAY_NAME
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
G_DEFINE_TYPE_WITH_CODE (GDataGDEmailAddress, gdata_gd_email_address, GDATA_TYPE_PARSABLE,
Packit 4b6dd7
                         G_IMPLEMENT_INTERFACE (GDATA_TYPE_COMPARABLE, gdata_gd_email_address_comparable_init))
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_email_address_class_init (GDataGDEmailAddressClass *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 (GDataGDEmailAddressPrivate));
Packit 4b6dd7
Packit 4b6dd7
	gobject_class->get_property = gdata_gd_email_address_get_property;
Packit 4b6dd7
	gobject_class->set_property = gdata_gd_email_address_set_property;
Packit 4b6dd7
	gobject_class->finalize = gdata_gd_email_address_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 = "email";
Packit 4b6dd7
	parsable_class->element_namespace = "gd";
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDEmailAddress:address:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The e-mail address itself.
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#gdEmail">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_ADDRESS,
Packit 4b6dd7
	                                 g_param_spec_string ("address",
Packit 4b6dd7
	                                                      "Address", "The e-mail address itself.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDEmailAddress:relation-type:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A programmatic value that identifies the type of e-mail address. For example: %GDATA_GD_EMAIL_ADDRESS_HOME or %GDATA_GD_EMAIL_ADDRESS_WORK.
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#gdEmail">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.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 e-mail address.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDEmailAddress:label:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A simple string value used to name this e-mail address. It allows UIs to display a label such as "Work", "Personal", "Preferred", etc.
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#gdEmail">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.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 e-mail address.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDEmailAddress:is-primary:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Indicates which e-mail address 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/gdata/docs/2.0/elements.html#gdEmail">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.4.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 e-mail address out of a group is primary.",
Packit 4b6dd7
	                                                       FALSE,
Packit 4b6dd7
	                                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataGDEmailAddress:display-name:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A display name of the entity (e.g. a person) the e-mail address belongs to.
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#gdEmail">GData specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.6.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_DISPLAY_NAME,
Packit 4b6dd7
	                                 g_param_spec_string ("display-name",
Packit 4b6dd7
	                                                      "Display name", "A display name of the entity the e-mail address belongs to.",
Packit 4b6dd7
	                                                      NULL,
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
	return g_strcmp0 (((GDataGDEmailAddress*) self)->priv->address, ((GDataGDEmailAddress*) other)->priv->address);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_email_address_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_email_address_init (GDataGDEmailAddress *self)
Packit 4b6dd7
{
Packit 4b6dd7
	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_GD_EMAIL_ADDRESS, GDataGDEmailAddressPrivate);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_email_address_finalize (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGDEmailAddressPrivate *priv = GDATA_GD_EMAIL_ADDRESS (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_free (priv->address);
Packit 4b6dd7
	g_free (priv->relation_type);
Packit 4b6dd7
	g_free (priv->label);
Packit 4b6dd7
	g_free (priv->display_name);
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	G_OBJECT_CLASS (gdata_gd_email_address_parent_class)->finalize (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_gd_email_address_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGDEmailAddressPrivate *priv = GDATA_GD_EMAIL_ADDRESS (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_ADDRESS:
Packit 4b6dd7
			g_value_set_string (value, priv->address);
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
		case PROP_DISPLAY_NAME:
Packit 4b6dd7
			g_value_set_string (value, priv->display_name);
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_email_address_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataGDEmailAddress *self = GDATA_GD_EMAIL_ADDRESS (object);
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_ADDRESS:
Packit 4b6dd7
			gdata_gd_email_address_set_address (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_RELATION_TYPE:
Packit 4b6dd7
			gdata_gd_email_address_set_relation_type (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_LABEL:
Packit 4b6dd7
			gdata_gd_email_address_set_label (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_IS_PRIMARY:
Packit 4b6dd7
			gdata_gd_email_address_set_is_primary (self, g_value_get_boolean (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_DISPLAY_NAME:
Packit 4b6dd7
			gdata_gd_email_address_set_display_name (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 *address, *rel;
Packit 4b6dd7
	gboolean primary_bool;
Packit 4b6dd7
	GDataGDEmailAddressPrivate *priv = GDATA_GD_EMAIL_ADDRESS (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	/* Is it the primary e-mail address? */
Packit 4b6dd7
	if (gdata_parser_boolean_from_property (root_node, "primary", &primary_bool, 0, error) == FALSE)
Packit 4b6dd7
		return FALSE;
Packit 4b6dd7
Packit 4b6dd7
	address = xmlGetProp (root_node, (xmlChar*) "address");
Packit 4b6dd7
	if (address == NULL || *address == '\0') {
Packit 4b6dd7
		xmlFree (address);
Packit 4b6dd7
		return gdata_parser_error_required_property_missing (root_node, "address", error);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	rel = xmlGetProp (root_node, (xmlChar*) "rel");
Packit 4b6dd7
	if (rel != NULL && *rel == '\0') {
Packit 4b6dd7
		xmlFree (address);
Packit 4b6dd7
		xmlFree (rel);
Packit 4b6dd7
		return gdata_parser_error_required_property_missing (root_node, "rel", error);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	priv->address = (gchar*) address;
Packit 4b6dd7
	priv->relation_type = (gchar*) rel;
Packit 4b6dd7
	priv->label = (gchar*) xmlGetProp (root_node, (xmlChar*) "label");
Packit 4b6dd7
	priv->is_primary = primary_bool;
Packit 4b6dd7
	priv->display_name = (gchar*) xmlGetProp (root_node, (xmlChar*) "displayName");
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
	GDataGDEmailAddressPrivate *priv = GDATA_GD_EMAIL_ADDRESS (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, " address='", priv->address, "'");
Packit 4b6dd7
	if (priv->relation_type != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " rel='", priv->relation_type, "'");
Packit 4b6dd7
	if (priv->label != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
Packit 4b6dd7
	if (priv->display_name != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, " displayName='", priv->display_name, "'");
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*) "gd", (gchar*) "http://schemas.google.com/g/2005");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_new:
Packit 4b6dd7
 * @address: the e-mail address
Packit 4b6dd7
 * @relation_type: (allow-none): the relationship between the e-mail address and its owner, or %NULL
Packit 4b6dd7
 * @label: (allow-none): a human-readable label for the e-mail address, or %NULL
Packit 4b6dd7
 * @is_primary: %TRUE if this e-mail address is its owner's primary address, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataGDEmailAddress. More information is available in the 
Packit 4b6dd7
 * url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdEmail">GData specification</ulink>.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a new #GDataGDEmailAddress, or %NULL; unref with g_object_unref()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGDEmailAddress *
Packit 4b6dd7
gdata_gd_email_address_new (const gchar *address, const gchar *relation_type, const gchar *label, gboolean is_primary)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (address != NULL && *address != '\0', NULL);
Packit 4b6dd7
	g_return_val_if_fail (relation_type == NULL || *relation_type != '\0', NULL);
Packit 4b6dd7
	return g_object_new (GDATA_TYPE_GD_EMAIL_ADDRESS, "address", address, "relation-type", relation_type,
Packit 4b6dd7
	                     "label", label, "is-primary", is_primary, NULL);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_get_address:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGDEmailAddress:address property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the e-mail address itself, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gd_email_address_get_address (GDataGDEmailAddress *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self), NULL);
Packit 4b6dd7
	return self->priv->address;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_set_address:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 * @address: the new e-mail address
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGDEmailAddress:address property to @address.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gd_email_address_set_address (GDataGDEmailAddress *self, const gchar *address)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self));
Packit 4b6dd7
	g_return_if_fail (address != NULL && *address != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->address);
Packit 4b6dd7
	self->priv->address = g_strdup (address);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "address");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_get_relation_type:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGDEmailAddress:relation-type property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the e-mail address' relation type, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gd_email_address_get_relation_type (GDataGDEmailAddress *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self), NULL);
Packit 4b6dd7
	return self->priv->relation_type;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_set_relation_type:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 * @relation_type: (allow-none): the new relation type for the email_address, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGDEmailAddress:relation-type property to @relation_type.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @relation_type to %NULL to unset the property in the e-mail address.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gd_email_address_set_relation_type (GDataGDEmailAddress *self, const gchar *relation_type)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (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_gd_email_address_get_label:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGDEmailAddress:label property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the e-mail address' label, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gd_email_address_get_label (GDataGDEmailAddress *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self), NULL);
Packit 4b6dd7
	return self->priv->label;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_set_label:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 * @label: (allow-none): the new label for the e-mail address, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGDEmailAddress:label property to @label.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @label to %NULL to unset the property in the e-mail address.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gd_email_address_set_label (GDataGDEmailAddress *self, const gchar *label)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self));
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_gd_email_address_is_primary:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGDEmailAddress:is-primary property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if this is the primary e-mail address, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_gd_email_address_is_primary (GDataGDEmailAddress *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self), FALSE);
Packit 4b6dd7
	return self->priv->is_primary;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_set_is_primary:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 * @is_primary: %TRUE if this is the primary e-mail address, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGDEmailAddress:is-primary property to @is_primary.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gd_email_address_set_is_primary (GDataGDEmailAddress *self, gboolean is_primary)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->is_primary = is_primary;
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "is-primary");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_get_display_name:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataGDEmailAddress:display-name property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a display name for the e-mail address, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.6.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_gd_email_address_get_display_name (GDataGDEmailAddress *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self), NULL);
Packit 4b6dd7
	return self->priv->display_name;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_gd_email_address_set_display_name:
Packit 4b6dd7
 * @self: a #GDataGDEmailAddress
Packit 4b6dd7
 * @display_name: (allow-none): the new display name, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataGDEmailAddress:display-name property to @display_name.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Set @display_name to %NULL to unset the property in the e-mail address.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.6.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_gd_email_address_set_display_name (GDataGDEmailAddress *self, const gchar *display_name)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->display_name);
Packit 4b6dd7
	self->priv->display_name = g_strdup (display_name);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "display-name");
Packit 4b6dd7
}