|
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-name
|
|
Packit |
4b6dd7 |
* @short_description: GData name element
|
|
Packit |
4b6dd7 |
* @stability: Stable
|
|
Packit |
4b6dd7 |
* @include: gdata/gd/gdata-gd-name.h
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* #GDataGDName represents a "name" element from the
|
|
Packit |
4b6dd7 |
* <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Given a name such as <literal>Sir Winston Leonard Spencer-Churchill, KG</literal>, the properties of the #GDataGDName should be
|
|
Packit |
4b6dd7 |
* set as follows:
|
|
Packit |
4b6dd7 |
* <variablelist>
|
|
Packit |
4b6dd7 |
* <varlistentry><term>#GDataGDName:given-name</term><listitem><para>Winston</para></listitem></varlistentry>
|
|
Packit |
4b6dd7 |
* <varlistentry><term>#GDataGDName:additional-name</term><listitem><para>Leonard</para></listitem></varlistentry>
|
|
Packit |
4b6dd7 |
* <varlistentry><term>#GDataGDName:family-name</term><listitem><para>Spencer-Churchill</para></listitem></varlistentry>
|
|
Packit |
4b6dd7 |
* <varlistentry><term>#GDataGDName:prefix</term><listitem><para>Sir</para></listitem></varlistentry>
|
|
Packit |
4b6dd7 |
* <varlistentry><term>#GDataGDName:suffix</term><listitem><para>KG</para></listitem></varlistentry>
|
|
Packit |
4b6dd7 |
* </variablelist>
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
#include <glib.h>
|
|
Packit |
4b6dd7 |
#include <libxml/parser.h>
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
#include "gdata-gd-name.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_name_comparable_init (GDataComparableIface *iface);
|
|
Packit |
4b6dd7 |
static void gdata_gd_name_finalize (GObject *object);
|
|
Packit |
4b6dd7 |
static void gdata_gd_name_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
|
|
Packit |
4b6dd7 |
static void gdata_gd_name_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
|
|
Packit |
4b6dd7 |
static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
|
|
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 _GDataGDNamePrivate {
|
|
Packit |
4b6dd7 |
gchar *given_name;
|
|
Packit |
4b6dd7 |
gchar *additional_name;
|
|
Packit |
4b6dd7 |
gchar *family_name;
|
|
Packit |
4b6dd7 |
gchar *prefix;
|
|
Packit |
4b6dd7 |
gchar *suffix;
|
|
Packit |
4b6dd7 |
gchar *full_name;
|
|
Packit |
4b6dd7 |
};
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
enum {
|
|
Packit |
4b6dd7 |
PROP_GIVEN_NAME = 1,
|
|
Packit |
4b6dd7 |
PROP_ADDITIONAL_NAME,
|
|
Packit |
4b6dd7 |
PROP_FAMILY_NAME,
|
|
Packit |
4b6dd7 |
PROP_PREFIX,
|
|
Packit |
4b6dd7 |
PROP_SUFFIX,
|
|
Packit |
4b6dd7 |
PROP_FULL_NAME
|
|
Packit |
4b6dd7 |
};
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
G_DEFINE_TYPE_WITH_CODE (GDataGDName, gdata_gd_name, GDATA_TYPE_PARSABLE,
|
|
Packit |
4b6dd7 |
G_IMPLEMENT_INTERFACE (GDATA_TYPE_COMPARABLE, gdata_gd_name_comparable_init))
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
static void
|
|
Packit |
4b6dd7 |
gdata_gd_name_class_init (GDataGDNameClass *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 (GDataGDNamePrivate));
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
gobject_class->get_property = gdata_gd_name_get_property;
|
|
Packit |
4b6dd7 |
gobject_class->set_property = gdata_gd_name_set_property;
|
|
Packit |
4b6dd7 |
gobject_class->finalize = gdata_gd_name_finalize;
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
parsable_class->parse_xml = parse_xml;
|
|
Packit |
4b6dd7 |
parsable_class->get_xml = get_xml;
|
|
Packit |
4b6dd7 |
parsable_class->get_namespaces = get_namespaces;
|
|
Packit |
4b6dd7 |
parsable_class->element_name = "name";
|
|
Packit |
4b6dd7 |
parsable_class->element_namespace = "gd";
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* GDataGDName:given-name:
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* The person's given name.
|
|
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#gdName">GData specification</ulink>.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
g_object_class_install_property (gobject_class, PROP_GIVEN_NAME,
|
|
Packit |
4b6dd7 |
g_param_spec_string ("given-name",
|
|
Packit |
4b6dd7 |
"Given name", "The person's given name.",
|
|
Packit |
4b6dd7 |
NULL,
|
|
Packit |
4b6dd7 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* GDataGDName:additional-name:
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* An additional name for the person (e.g. a middle name).
|
|
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#gdName">GData specification</ulink>.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
g_object_class_install_property (gobject_class, PROP_ADDITIONAL_NAME,
|
|
Packit |
4b6dd7 |
g_param_spec_string ("additional-name",
|
|
Packit |
4b6dd7 |
"Additional name", "An additional name for the person (e.g. a middle name).",
|
|
Packit |
4b6dd7 |
NULL,
|
|
Packit |
4b6dd7 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* GDataGDName:family-name:
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* The person's family name.
|
|
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#gdName">GData specification</ulink>.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
g_object_class_install_property (gobject_class, PROP_FAMILY_NAME,
|
|
Packit |
4b6dd7 |
g_param_spec_string ("family-name",
|
|
Packit |
4b6dd7 |
"Family name", "The person's family name.",
|
|
Packit |
4b6dd7 |
NULL,
|
|
Packit |
4b6dd7 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* GDataGDName:prefix:
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* An honorific prefix (e.g. <literal>Mr</literal> or <literal>Mrs</literal>).
|
|
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#gdName">GData specification</ulink>.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
g_object_class_install_property (gobject_class, PROP_PREFIX,
|
|
Packit |
4b6dd7 |
g_param_spec_string ("prefix",
|
|
Packit |
4b6dd7 |
"Prefix", "An honorific prefix.",
|
|
Packit |
4b6dd7 |
NULL,
|
|
Packit |
4b6dd7 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* GDataGDName:suffix:
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* An honorific suffix (e.g. <literal>san</literal> or <literal>III</literal>).
|
|
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#gdName">GData specification</ulink>.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
g_object_class_install_property (gobject_class, PROP_SUFFIX,
|
|
Packit |
4b6dd7 |
g_param_spec_string ("suffix",
|
|
Packit |
4b6dd7 |
"Suffix", "An honorific suffix.",
|
|
Packit |
4b6dd7 |
NULL,
|
|
Packit |
4b6dd7 |
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* GDataGDName:full-name:
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* An unstructured representation of the person's full name. It's generally advised to use the other individual properties in preference
|
|
Packit |
4b6dd7 |
* to this one, which can fall out of synchronisation with the other properties.
|
|
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#gdName">GData specification</ulink>.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
g_object_class_install_property (gobject_class, PROP_FULL_NAME,
|
|
Packit |
4b6dd7 |
g_param_spec_string ("full-name",
|
|
Packit |
4b6dd7 |
"Full name", "An unstructured representation of the person's full name.",
|
|
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 |
GDataGDNamePrivate *a = ((GDataGDName*) self)->priv, *b = ((GDataGDName*) other)->priv;
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
if (g_strcmp0 (a->given_name, b->given_name) == 0 && g_strcmp0 (a->additional_name, b->additional_name) == 0 &&
|
|
Packit |
4b6dd7 |
g_strcmp0 (a->family_name, b->family_name) == 0 && g_strcmp0 (a->prefix, b->prefix) == 0)
|
|
Packit |
4b6dd7 |
return 0;
|
|
Packit |
4b6dd7 |
return 1;
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
static void
|
|
Packit |
4b6dd7 |
gdata_gd_name_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_name_init (GDataGDName *self)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_GD_NAME, GDataGDNamePrivate);
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
static void
|
|
Packit |
4b6dd7 |
gdata_gd_name_finalize (GObject *object)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
GDataGDNamePrivate *priv = GDATA_GD_NAME (object)->priv;
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
g_free (priv->given_name);
|
|
Packit |
4b6dd7 |
g_free (priv->additional_name);
|
|
Packit |
4b6dd7 |
g_free (priv->family_name);
|
|
Packit |
4b6dd7 |
g_free (priv->prefix);
|
|
Packit |
4b6dd7 |
g_free (priv->suffix);
|
|
Packit |
4b6dd7 |
g_free (priv->full_name);
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/* Chain up to the parent class */
|
|
Packit |
4b6dd7 |
G_OBJECT_CLASS (gdata_gd_name_parent_class)->finalize (object);
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
static void
|
|
Packit |
4b6dd7 |
gdata_gd_name_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
GDataGDNamePrivate *priv = GDATA_GD_NAME (object)->priv;
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
switch (property_id) {
|
|
Packit |
4b6dd7 |
case PROP_GIVEN_NAME:
|
|
Packit |
4b6dd7 |
g_value_set_string (value, priv->given_name);
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_ADDITIONAL_NAME:
|
|
Packit |
4b6dd7 |
g_value_set_string (value, priv->additional_name);
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_FAMILY_NAME:
|
|
Packit |
4b6dd7 |
g_value_set_string (value, priv->family_name);
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_PREFIX:
|
|
Packit |
4b6dd7 |
g_value_set_string (value, priv->prefix);
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_SUFFIX:
|
|
Packit |
4b6dd7 |
g_value_set_string (value, priv->suffix);
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_FULL_NAME:
|
|
Packit |
4b6dd7 |
g_value_set_string (value, priv->full_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_name_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
GDataGDName *self = GDATA_GD_NAME (object);
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
switch (property_id) {
|
|
Packit |
4b6dd7 |
case PROP_GIVEN_NAME:
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_given_name (self, g_value_get_string (value));
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_ADDITIONAL_NAME:
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_additional_name (self, g_value_get_string (value));
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_FAMILY_NAME:
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_family_name (self, g_value_get_string (value));
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_PREFIX:
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_prefix (self, g_value_get_string (value));
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_SUFFIX:
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_suffix (self, g_value_get_string (value));
|
|
Packit |
4b6dd7 |
break;
|
|
Packit |
4b6dd7 |
case PROP_FULL_NAME:
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_full_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 |
parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
gboolean success;
|
|
Packit |
4b6dd7 |
GDataGDNamePrivate *priv = GDATA_GD_NAME (parsable)->priv;
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
if (gdata_parser_is_namespace (node, "http://schemas.google.com/g/2005") == TRUE && (
|
|
Packit |
4b6dd7 |
gdata_parser_string_from_element (node, "givenName", P_NO_DUPES, &(priv->given_name), &success, error) == TRUE ||
|
|
Packit |
4b6dd7 |
gdata_parser_string_from_element (node, "additionalName", P_NO_DUPES, &(priv->additional_name), &success, error) == TRUE ||
|
|
Packit |
4b6dd7 |
gdata_parser_string_from_element (node, "familyName", P_NO_DUPES, &(priv->family_name), &success, error) == TRUE ||
|
|
Packit |
4b6dd7 |
gdata_parser_string_from_element (node, "namePrefix", P_NO_DUPES, &(priv->prefix), &success, error) == TRUE ||
|
|
Packit |
4b6dd7 |
gdata_parser_string_from_element (node, "nameSuffix", P_NO_DUPES, &(priv->suffix), &success, error) == TRUE ||
|
|
Packit |
4b6dd7 |
gdata_parser_string_from_element (node, "fullName", P_NO_DUPES, &(priv->full_name), &success, error) == TRUE)) {
|
|
Packit |
4b6dd7 |
return success;
|
|
Packit |
4b6dd7 |
} else {
|
|
Packit |
4b6dd7 |
return GDATA_PARSABLE_CLASS (gdata_gd_name_parent_class)->parse_xml (parsable, doc, node, user_data, error);
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
static void
|
|
Packit |
4b6dd7 |
get_xml (GDataParsable *parsable, GString *xml_string)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
GDataGDNamePrivate *priv = GDATA_GD_NAME (parsable)->priv;
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
#define OUTPUT_STRING_ELEMENT(E,F) \
|
|
Packit |
4b6dd7 |
if (priv->F != NULL) \
|
|
Packit |
4b6dd7 |
gdata_parser_string_append_escaped (xml_string, "<gd:" E ">", priv->F, "</gd:" E ">");
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
OUTPUT_STRING_ELEMENT ("givenName", given_name)
|
|
Packit |
4b6dd7 |
OUTPUT_STRING_ELEMENT ("additionalName", additional_name)
|
|
Packit |
4b6dd7 |
OUTPUT_STRING_ELEMENT ("familyName", family_name)
|
|
Packit |
4b6dd7 |
OUTPUT_STRING_ELEMENT ("namePrefix", prefix)
|
|
Packit |
4b6dd7 |
OUTPUT_STRING_ELEMENT ("nameSuffix", suffix)
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/* We can't guarantee that priv->full_name is non-empty without breaking API. */
|
|
Packit |
4b6dd7 |
if (priv->full_name != NULL && *(priv->full_name) != '\0') {
|
|
Packit |
4b6dd7 |
gdata_parser_string_append_escaped (xml_string, "<gd:fullName>", priv->full_name, "</gd:fullName>");
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
#undef OUTPUT_STRING_ELEMENT
|
|
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_name_new:
|
|
Packit |
4b6dd7 |
* @given_name: (allow-none): the person's given name, or %NULL
|
|
Packit |
4b6dd7 |
* @family_name: (allow-none): the person's family name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Creates a new #GDataGDName. More information is available in the
|
|
Packit |
4b6dd7 |
* url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Return value: a new #GDataGDName, or %NULL; unref with g_object_unref()
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
GDataGDName *
|
|
Packit |
4b6dd7 |
gdata_gd_name_new (const gchar *given_name, const gchar *family_name)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_val_if_fail (given_name == NULL || *given_name != '\0', NULL);
|
|
Packit |
4b6dd7 |
g_return_val_if_fail (family_name == NULL || *family_name != '\0', NULL);
|
|
Packit |
4b6dd7 |
return g_object_new (GDATA_TYPE_GD_NAME, "given-name", given_name, "family-name", family_name, NULL);
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_get_given_name:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Gets the #GDataGDName:given-name property.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Return value: the person's given name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
const gchar *
|
|
Packit |
4b6dd7 |
gdata_gd_name_get_given_name (GDataGDName *self)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
|
|
Packit |
4b6dd7 |
return self->priv->given_name;
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_set_given_name:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
* @given_name: (allow-none): the new given name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Sets the #GDataGDName:given-name property to @given_name.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
void
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_given_name (GDataGDName *self, const gchar *given_name)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_if_fail (GDATA_IS_GD_NAME (self));
|
|
Packit |
4b6dd7 |
g_return_if_fail (given_name == NULL || *given_name != '\0');
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
g_free (self->priv->given_name);
|
|
Packit |
4b6dd7 |
self->priv->given_name = g_strdup (given_name);
|
|
Packit |
4b6dd7 |
g_object_notify (G_OBJECT (self), "given-name");
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_get_additional_name:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Gets the #GDataGDName:additional-name property.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Return value: the person's additional name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
const gchar *
|
|
Packit |
4b6dd7 |
gdata_gd_name_get_additional_name (GDataGDName *self)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
|
|
Packit |
4b6dd7 |
return self->priv->additional_name;
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_set_additional_name:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
* @additional_name: (allow-none): the new additional name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Sets the #GDataGDName:additional-name property to @additional_name.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
void
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_additional_name (GDataGDName *self, const gchar *additional_name)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_if_fail (GDATA_IS_GD_NAME (self));
|
|
Packit |
4b6dd7 |
g_return_if_fail (additional_name == NULL || *additional_name != '\0');
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
g_free (self->priv->additional_name);
|
|
Packit |
4b6dd7 |
self->priv->additional_name = g_strdup (additional_name);
|
|
Packit |
4b6dd7 |
g_object_notify (G_OBJECT (self), "additional-name");
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_get_family_name:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Gets the #GDataGDName:family-name property.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Return value: the person's family name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
const gchar *
|
|
Packit |
4b6dd7 |
gdata_gd_name_get_family_name (GDataGDName *self)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
|
|
Packit |
4b6dd7 |
return self->priv->family_name;
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_set_family_name:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
* @family_name: (allow-none): the new family name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Sets the #GDataGDName:family-name property to @family_name.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
void
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_family_name (GDataGDName *self, const gchar *family_name)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_if_fail (GDATA_IS_GD_NAME (self));
|
|
Packit |
4b6dd7 |
g_return_if_fail (family_name == NULL || *family_name != '\0');
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
g_free (self->priv->family_name);
|
|
Packit |
4b6dd7 |
self->priv->family_name = g_strdup (family_name);
|
|
Packit |
4b6dd7 |
g_object_notify (G_OBJECT (self), "family-name");
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_get_prefix:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Gets the #GDataGDName:prefix property.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Return value: the person's name prefix, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
const gchar *
|
|
Packit |
4b6dd7 |
gdata_gd_name_get_prefix (GDataGDName *self)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
|
|
Packit |
4b6dd7 |
return self->priv->prefix;
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_set_prefix:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
* @prefix: (allow-none): the new prefix, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Sets the #GDataGDName:prefix property to @prefix.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
void
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_prefix (GDataGDName *self, const gchar *prefix)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_if_fail (GDATA_IS_GD_NAME (self));
|
|
Packit |
4b6dd7 |
g_return_if_fail (prefix == NULL || *prefix != '\0');
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
g_free (self->priv->prefix);
|
|
Packit |
4b6dd7 |
self->priv->prefix = g_strdup (prefix);
|
|
Packit |
4b6dd7 |
g_object_notify (G_OBJECT (self), "prefix");
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_get_suffix:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Gets the #GDataGDName:suffix property.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Return value: the person's name suffix, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
const gchar *
|
|
Packit |
4b6dd7 |
gdata_gd_name_get_suffix (GDataGDName *self)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
|
|
Packit |
4b6dd7 |
return self->priv->suffix;
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_set_suffix:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
* @suffix: (allow-none): the new suffix, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Sets the #GDataGDName:suffix property to @suffix.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
void
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_suffix (GDataGDName *self, const gchar *suffix)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_if_fail (GDATA_IS_GD_NAME (self));
|
|
Packit |
4b6dd7 |
g_return_if_fail (suffix == NULL || *suffix != '\0');
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
g_free (self->priv->suffix);
|
|
Packit |
4b6dd7 |
self->priv->suffix = g_strdup (suffix);
|
|
Packit |
4b6dd7 |
g_object_notify (G_OBJECT (self), "suffix");
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_get_full_name:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Gets the #GDataGDName:full-name property.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Return value: the person's full name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
const gchar *
|
|
Packit |
4b6dd7 |
gdata_gd_name_get_full_name (GDataGDName *self)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
|
|
Packit |
4b6dd7 |
return self->priv->full_name;
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/**
|
|
Packit |
4b6dd7 |
* gdata_gd_name_set_full_name:
|
|
Packit |
4b6dd7 |
* @self: a #GDataGDName
|
|
Packit |
4b6dd7 |
* @full_name: (allow-none): the new full name, or %NULL
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Sets the #GDataGDName:full-name property to @full_name.
|
|
Packit |
4b6dd7 |
*
|
|
Packit |
4b6dd7 |
* Since: 0.5.0
|
|
Packit |
4b6dd7 |
*/
|
|
Packit |
4b6dd7 |
void
|
|
Packit |
4b6dd7 |
gdata_gd_name_set_full_name (GDataGDName *self, const gchar *full_name)
|
|
Packit |
4b6dd7 |
{
|
|
Packit |
4b6dd7 |
g_return_if_fail (GDATA_IS_GD_NAME (self));
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
/* Coerce empty strings to NULL. Ideally, we should have this as a precondition (as all the other setters in GDataGDName have) but that would
|
|
Packit |
4b6dd7 |
* break API. */
|
|
Packit |
4b6dd7 |
if (full_name != NULL && *full_name == '\0') {
|
|
Packit |
4b6dd7 |
full_name = NULL;
|
|
Packit |
4b6dd7 |
}
|
|
Packit |
4b6dd7 |
|
|
Packit |
4b6dd7 |
g_free (self->priv->full_name);
|
|
Packit |
4b6dd7 |
self->priv->full_name = g_strdup (full_name);
|
|
Packit |
4b6dd7 |
g_object_notify (G_OBJECT (self), "full-name");
|
|
Packit |
4b6dd7 |
}
|