[libgdata] [gd] Updated the GData namespace to version 3
- From: Philip Withnall <pwithnall src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgdata] [gd] Updated the GData namespace to version 3
- Date: Mon, 10 Aug 2009 19:58:28 +0000 (UTC)
commit 0a8e11dbbc4208acebbbdbc21588f8cfd06bf4d7
Author: Philip Withnall <philip tecnocode co uk>
Date: Mon Aug 10 20:53:06 2009 +0100
[gd] Updated the GData namespace to version 3
Added structured name and postal address handling from version 3 of the
GData namespace, including updated test cases.
docs/reference/gdata-sections.txt | 69 ++
gdata/gd/Makefile.am | 6 +-
gdata/gd/gdata-gd-name.c | 598 ++++++++++++++
gdata/gd/gdata-gd-name.h | 88 ++
gdata/gd/gdata-gd-organization.c | 241 ++++++-
gdata/gd/gdata-gd-organization.h | 9 +
gdata/gd/gdata-gd-postal-address.c | 929 +++++++++++++++++++++-
gdata/gd/gdata-gd-postal-address.h | 94 +++-
gdata/gdata-parser.c | 2 +-
gdata/gdata-service.c | 3 +-
gdata/gdata-service.h | 2 +
gdata/gdata.h | 1 +
gdata/gdata.symbols | 47 ++
gdata/services/contacts/gdata-contacts-contact.c | 86 ++-
gdata/services/contacts/gdata-contacts-contact.h | 3 +
gdata/services/contacts/gdata-contacts-service.c | 1 +
gdata/tests/contacts.c | 14 +-
gdata/tests/general.c | 172 ++++-
18 files changed, 2264 insertions(+), 101 deletions(-)
---
diff --git a/docs/reference/gdata-sections.txt b/docs/reference/gdata-sections.txt
index 599b849..d8c0e68 100644
--- a/docs/reference/gdata-sections.txt
+++ b/docs/reference/gdata-sections.txt
@@ -310,6 +310,7 @@ GDataContactsQueryPrivate
GDataContactsContact
GDataContactsContactClass
gdata_contacts_contact_new
+gdata_contacts_contact_get_name
gdata_contacts_contact_get_email_addresses
gdata_contacts_contact_get_primary_email_address
gdata_contacts_contact_add_email_address
@@ -760,6 +761,12 @@ gdata_gd_organization_get_label
gdata_gd_organization_set_label
gdata_gd_organization_is_primary
gdata_gd_organization_set_is_primary
+gdata_gd_organization_get_department
+gdata_gd_organization_set_department
+gdata_gd_organization_get_job_description
+gdata_gd_organization_set_job_description
+gdata_gd_organization_get_symbol
+gdata_gd_organization_set_symbol
<SUBSECTION Standard>
gdata_gd_organization_get_type
GDATA_GD_ORGANIZATION
@@ -911,6 +918,12 @@ GDataGDIMAddressPrivate
<TITLE>GDataGDPostalAddress</TITLE>
GDataGDPostalAddress
GDataGDPostalAddressClass
+GDATA_GD_ADDRESS_USAGE_GENERAL
+GDATA_GD_ADDRESS_USAGE_LOCAL
+GDATA_GD_MAIL_CLASS_BOTH
+GDATA_GD_MAIL_CLASS_LETTERS
+GDATA_GD_MAIL_CLASS_NEITHER
+GDATA_GD_MAIL_CLASS_PARCELS
gdata_gd_postal_address_new
gdata_gd_postal_address_compare
gdata_gd_postal_address_get_address
@@ -921,6 +934,31 @@ gdata_gd_postal_address_get_label
gdata_gd_postal_address_set_label
gdata_gd_postal_address_is_primary
gdata_gd_postal_address_set_is_primary
+gdata_gd_postal_address_get_mail_class
+gdata_gd_postal_address_set_mail_class
+gdata_gd_postal_address_get_usage
+gdata_gd_postal_address_set_usage
+gdata_gd_postal_address_get_agent
+gdata_gd_postal_address_set_agent
+gdata_gd_postal_address_get_house_name
+gdata_gd_postal_address_set_house_name
+gdata_gd_postal_address_get_street
+gdata_gd_postal_address_set_street
+gdata_gd_postal_address_get_po_box
+gdata_gd_postal_address_set_po_box
+gdata_gd_postal_address_get_neighborhood
+gdata_gd_postal_address_set_neighborhood
+gdata_gd_postal_address_get_city
+gdata_gd_postal_address_set_city
+gdata_gd_postal_address_get_subregion
+gdata_gd_postal_address_set_subregion
+gdata_gd_postal_address_get_region
+gdata_gd_postal_address_set_region
+gdata_gd_postal_address_get_postcode
+gdata_gd_postal_address_set_postcode
+gdata_gd_postal_address_get_country
+gdata_gd_postal_address_get_country_code
+gdata_gd_postal_address_set_country
<SUBSECTION Standard>
gdata_gd_postal_address_get_type
GDATA_GD_POSTAL_ADDRESS
@@ -1524,3 +1562,34 @@ GDATA_TYPE_UPLOAD_STREAM
<SUBSECTION Private>
GDataUploadStreamPrivate
</SECTION>
+
+<SECTION>
+<FILE>gdata-gd-name</FILE>
+<TITLE>GDataGDName</TITLE>
+GDataGDName
+GDataGDNameClass
+gdata_gd_name_new
+gdata_gd_name_compare
+gdata_gd_name_get_given_name
+gdata_gd_name_set_given_name
+gdata_gd_name_get_additional_name
+gdata_gd_name_set_additional_name
+gdata_gd_name_get_family_name
+gdata_gd_name_set_family_name
+gdata_gd_name_get_prefix
+gdata_gd_name_set_prefix
+gdata_gd_name_get_suffix
+gdata_gd_name_set_suffix
+gdata_gd_name_get_full_name
+gdata_gd_name_set_full_name
+<SUBSECTION Standard>
+gdata_gd_name_get_type
+GDATA_GD_NAME
+GDATA_GD_NAME_CLASS
+GDATA_GD_NAME_GET_CLASS
+GDATA_IS_GD_NAME
+GDATA_IS_GD_NAME_CLASS
+GDATA_TYPE_GD_NAME
+<SUBSECTION Private>
+GDataGDNamePrivate
+</SECTION>
diff --git a/gdata/gd/Makefile.am b/gdata/gd/Makefile.am
index 3612f39..7ece991 100644
--- a/gdata/gd/Makefile.am
+++ b/gdata/gd/Makefile.am
@@ -8,7 +8,8 @@ gdatagdinclude_HEADERS = \
gdata-gd-reminder.h \
gdata-gd-when.h \
gdata-gd-where.h \
- gdata-gd-who.h
+ gdata-gd-who.h \
+ gdata-gd-name.h
noinst_LTLIBRARIES = libgdatagd.la
@@ -21,7 +22,8 @@ libgdatagd_la_SOURCES = \
gdata-gd-reminder.c \
gdata-gd-when.c \
gdata-gd-where.c \
- gdata-gd-who.c
+ gdata-gd-who.c \
+ gdata-gd-name.c
libgdatagd_la_CPPFLAGS = \
-I$(top_srcdir) \
diff --git a/gdata/gd/gdata-gd-name.c b/gdata/gd/gdata-gd-name.c
new file mode 100644
index 0000000..bc5d840
--- /dev/null
+++ b/gdata/gd/gdata-gd-name.c
@@ -0,0 +1,598 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Philip Withnall 2009 <philip tecnocode co uk>
+ *
+ * GData Client is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GData Client is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GData Client. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * SECTION:gdata-gd-name
+ * @short_description: GData name element
+ * @stability: Unstable
+ * @include: gdata/gd/gdata-gd-name.h
+ *
+ * #GDataGDName represents a "name" element from the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
+ *
+ * Given a name such as <literal>Sir Winston Leonard Spencer-Churchill, KG</literal>, the properties of the #GDataGDName should be
+ * set as follows:
+ * <variablelist>
+ * <varlistentry><term>#GDataGDName:given-name</term><listitem><para>Winston</para></listitem></varlistentry>
+ * <varlistentry><term>#GDataGDName:additional-name</term><listitem><para>Leonard</para></listitem></varlistentry>
+ * <varlistentry><term>#GDataGDName:family-name</term><listitem><para>Spencer-Churchill</para></listitem></varlistentry>
+ * <varlistentry><term>#GDataGDName:prefix</term><listitem><para>Sir</para></listitem></varlistentry>
+ * <varlistentry><term>#GDataGDName:suffix</term><listitem><para>KG</para></listitem></varlistentry>
+ * </variablelist>
+ **/
+
+#include <glib.h>
+#include <libxml/parser.h>
+
+#include "gdata-gd-name.h"
+#include "gdata-parsable.h"
+#include "gdata-parser.h"
+
+static void gdata_gd_name_finalize (GObject *object);
+static void gdata_gd_name_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
+static void gdata_gd_name_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
+static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
+static void get_xml (GDataParsable *parsable, GString *xml_string);
+static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
+
+struct _GDataGDNamePrivate {
+ gchar *given_name;
+ gchar *additional_name;
+ gchar *family_name;
+ gchar *prefix;
+ gchar *suffix;
+ gchar *full_name;
+};
+
+enum {
+ PROP_GIVEN_NAME = 1,
+ PROP_ADDITIONAL_NAME,
+ PROP_FAMILY_NAME,
+ PROP_PREFIX,
+ PROP_SUFFIX,
+ PROP_FULL_NAME
+};
+
+G_DEFINE_TYPE (GDataGDName, gdata_gd_name, GDATA_TYPE_PARSABLE)
+#define GDATA_GD_NAME_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GDATA_TYPE_GD_NAME, GDataGDNamePrivate))
+
+static void
+gdata_gd_name_class_init (GDataGDNameClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+ GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (GDataGDNamePrivate));
+
+ gobject_class->get_property = gdata_gd_name_get_property;
+ gobject_class->set_property = gdata_gd_name_set_property;
+ gobject_class->finalize = gdata_gd_name_finalize;
+
+ parsable_class->parse_xml = parse_xml;
+ parsable_class->get_xml = get_xml;
+ parsable_class->get_namespaces = get_namespaces;
+ parsable_class->element_name = "name";
+ parsable_class->element_namespace = "gd";
+
+ /**
+ * GDataGDName:given-name:
+ *
+ * The person's given name.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_GIVEN_NAME,
+ g_param_spec_string ("given-name",
+ "Given name", "The person's given name.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDName:additional-name:
+ *
+ * An additional name for the person (e.g. a middle name).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_ADDITIONAL_NAME,
+ g_param_spec_string ("additional-name",
+ "Additional name", "An additional name for the person (e.g. a middle name).",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDName:family-name:
+ *
+ * The person's family name.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_FAMILY_NAME,
+ g_param_spec_string ("family-name",
+ "Family name", "The person's family name.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDName:prefix:
+ *
+ * An honorific prefix (e.g. <literal>Mr</literal> or <literal>Mrs</literal>).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_PREFIX,
+ g_param_spec_string ("prefix",
+ "Prefix", "An honorific prefix.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDName:suffix:
+ *
+ * An honorific suffix (e.g. <literal>san</literal> or <literal>III</literal>).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_SUFFIX,
+ g_param_spec_string ("suffix",
+ "Suffix", "An honorific suffix.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDName:full-name:
+ *
+ * An unstructured representation of the person's full name. It's generally advised to use the other individual properties in preference
+ * to this one, which can fall out of synchronisation with the other properties.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_FULL_NAME,
+ g_param_spec_string ("full-name",
+ "Full name", "An unstructured representation of the person's full name.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+}
+
+static void
+gdata_gd_name_init (GDataGDName *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_GD_NAME, GDataGDNamePrivate);
+}
+
+static void
+gdata_gd_name_finalize (GObject *object)
+{
+ GDataGDNamePrivate *priv = GDATA_GD_NAME (object)->priv;
+
+ g_free (priv->given_name);
+ g_free (priv->additional_name);
+ g_free (priv->family_name);
+ g_free (priv->prefix);
+ g_free (priv->suffix);
+ g_free (priv->full_name);
+
+ /* Chain up to the parent class */
+ G_OBJECT_CLASS (gdata_gd_name_parent_class)->finalize (object);
+}
+
+static void
+gdata_gd_name_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
+{
+ GDataGDNamePrivate *priv = GDATA_GD_NAME (object)->priv;
+
+ switch (property_id) {
+ case PROP_GIVEN_NAME:
+ g_value_set_string (value, priv->given_name);
+ break;
+ case PROP_ADDITIONAL_NAME:
+ g_value_set_string (value, priv->additional_name);
+ break;
+ case PROP_FAMILY_NAME:
+ g_value_set_string (value, priv->family_name);
+ break;
+ case PROP_PREFIX:
+ g_value_set_string (value, priv->prefix);
+ break;
+ case PROP_SUFFIX:
+ g_value_set_string (value, priv->suffix);
+ break;
+ case PROP_FULL_NAME:
+ g_value_set_string (value, priv->full_name);
+ break;
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+static void
+gdata_gd_name_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
+{
+ GDataGDName *self = GDATA_GD_NAME (object);
+
+ switch (property_id) {
+ case PROP_GIVEN_NAME:
+ gdata_gd_name_set_given_name (self, g_value_get_string (value));
+ break;
+ case PROP_ADDITIONAL_NAME:
+ gdata_gd_name_set_additional_name (self, g_value_get_string (value));
+ break;
+ case PROP_FAMILY_NAME:
+ gdata_gd_name_set_family_name (self, g_value_get_string (value));
+ break;
+ case PROP_PREFIX:
+ gdata_gd_name_set_prefix (self, g_value_get_string (value));
+ break;
+ case PROP_SUFFIX:
+ gdata_gd_name_set_suffix (self, g_value_get_string (value));
+ break;
+ case PROP_FULL_NAME:
+ gdata_gd_name_set_full_name (self, g_value_get_string (value));
+ break;
+ default:
+ /* We don't have any other property... */
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+ break;
+ }
+}
+
+#define PARSE_STRING_ELEMENT(E,F) \
+ if (xmlStrcmp (node->name, (xmlChar*) (E)) == 0) { \
+ /* gd:##E */ \
+ xmlChar *name; \
+ \
+ if (priv->F != NULL) \
+ return gdata_parser_error_duplicate_element (node, error); \
+ \
+ name = xmlNodeListGetString (doc, node->children, TRUE); \
+ priv->F = g_strdup ((gchar*) name); \
+ xmlFree (name); \
+ }
+
+static gboolean
+parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
+{
+ GDataGDNamePrivate *priv = GDATA_GD_NAME (parsable)->priv;
+
+ PARSE_STRING_ELEMENT ("givenName", given_name)
+ else PARSE_STRING_ELEMENT ("additionalName", additional_name)
+ else PARSE_STRING_ELEMENT ("familyName", family_name)
+ else PARSE_STRING_ELEMENT ("namePrefix", prefix)
+ else PARSE_STRING_ELEMENT ("nameSuffix", suffix)
+ else PARSE_STRING_ELEMENT ("fullName", full_name)
+ else if (GDATA_PARSABLE_CLASS (gdata_gd_name_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
+ /* Error! */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+#define OUTPUT_STRING_ELEMENT(E,F) \
+ if (priv->F != NULL) \
+ gdata_parser_string_append_escaped (xml_string, "<gd:" E ">", priv->F, "</gd:" E ">");
+
+static void
+get_xml (GDataParsable *parsable, GString *xml_string)
+{
+ GDataGDNamePrivate *priv = GDATA_GD_NAME (parsable)->priv;
+
+ OUTPUT_STRING_ELEMENT ("givenName", given_name)
+ OUTPUT_STRING_ELEMENT ("additionalName", additional_name)
+ OUTPUT_STRING_ELEMENT ("familyName", family_name)
+ OUTPUT_STRING_ELEMENT ("namePrefix", prefix)
+ OUTPUT_STRING_ELEMENT ("nameSuffix", suffix)
+ OUTPUT_STRING_ELEMENT ("fullName", full_name)
+}
+
+static void
+get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
+{
+ g_hash_table_insert (namespaces, (gchar*) "gd", (gchar*) "http://schemas.google.com/g/2005");
+}
+
+/**
+ * gdata_gd_name_new:
+ * @given_name: the person's given name, or %NULL
+ * @family_name: the person's family name, or %NULL
+ *
+ * Creates a new #GDataGDName. More information is available in the <ulink type="http"
+ * url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdName">GData specification</ulink>.
+ *
+ * Return value: a new #GDataGDName, or %NULL; unref with g_object_unref()
+ *
+ * Since: 0.5.0
+ **/
+GDataGDName *
+gdata_gd_name_new (const gchar *given_name, const gchar *family_name)
+{
+ return g_object_new (GDATA_TYPE_GD_NAME, "given-name", given_name, "family-name", family_name, NULL);
+}
+
+/**
+ * gdata_gd_name_compare:
+ * @a: a #GDataGDName, or %NULL
+ * @b: another #GDataGDName, or %NULL
+ *
+ * Compares the two names in a strcmp() fashion. %NULL values are handled gracefully, with
+ * %0 returned if both @a and @b are %NULL, %-1 if @a is %NULL and %1 if @b is %NULL.
+ *
+ * The comparison of non-%NULL values is done on the basis of the @given_name, @additional_name and @family_name properties of the
+ * #GDataGDName<!-- -->s.
+ *
+ * Return value: %0 if @a equals @b, %-1 or %1 as appropriate otherwise
+ *
+ * Since: 0.5.0
+ **/
+gint
+gdata_gd_name_compare (const GDataGDName *a, const GDataGDName *b)
+{
+ if (a == NULL && b != NULL)
+ return -1;
+ else if (b == NULL)
+ return 1;
+
+ if (a == b)
+ return 0;
+ if (g_strcmp0 (a->priv->given_name, b->priv->given_name) == 0 && g_strcmp0 (a->priv->additional_name, b->priv->additional_name) == 0 &&
+ g_strcmp0 (a->priv->family_name, b->priv->family_name) == 0 && g_strcmp0 (a->priv->prefix, b->priv->prefix) == 0)
+ return 0;
+ return 1;
+}
+
+/**
+ * gdata_gd_name_get_given_name:
+ * @self: a #GDataGDName
+ *
+ * Gets the #GDataGDName:given-name property.
+ *
+ * Return value: the person's given name, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_name_get_given_name (GDataGDName *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
+ return self->priv->given_name;
+}
+
+/**
+ * gdata_gd_name_set_given_name:
+ * @self: a #GDataGDName
+ * @given_name: the new given name, or %NULL
+ *
+ * Sets the #GDataGDName:given-name property to @given_name.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_name_set_given_name (GDataGDName *self, const gchar *given_name)
+{
+ g_return_if_fail (GDATA_IS_GD_NAME (self));
+ g_return_if_fail (given_name == NULL || *given_name != '\0');
+
+ g_free (self->priv->given_name);
+ self->priv->given_name = g_strdup (given_name);
+ g_object_notify (G_OBJECT (self), "given-name");
+}
+
+/**
+ * gdata_gd_name_get_additional_name:
+ * @self: a #GDataGDName
+ *
+ * Gets the #GDataGDName:additional-name property.
+ *
+ * Return value: the person's additional name, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_name_get_additional_name (GDataGDName *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
+ return self->priv->additional_name;
+}
+
+/**
+ * gdata_gd_name_set_additional_name:
+ * @self: a #GDataGDName
+ * @additional_name: the new additional name, or %NULL
+ *
+ * Sets the #GDataGDName:additional-name property to @additional_name.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_name_set_additional_name (GDataGDName *self, const gchar *additional_name)
+{
+ g_return_if_fail (GDATA_IS_GD_NAME (self));
+ g_return_if_fail (additional_name == NULL || *additional_name != '\0');
+
+ g_free (self->priv->additional_name);
+ self->priv->additional_name = g_strdup (additional_name);
+ g_object_notify (G_OBJECT (self), "additional-name");
+}
+
+/**
+ * gdata_gd_name_get_family_name:
+ * @self: a #GDataGDName
+ *
+ * Gets the #GDataGDName:family-name property.
+ *
+ * Return value: the person's family name, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_name_get_family_name (GDataGDName *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
+ return self->priv->family_name;
+}
+
+/**
+ * gdata_gd_name_set_family_name:
+ * @self: a #GDataGDName
+ * @family_name: the new family name, or %NULL
+ *
+ * Sets the #GDataGDName:family-name property to @family_name.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_name_set_family_name (GDataGDName *self, const gchar *family_name)
+{
+ g_return_if_fail (GDATA_IS_GD_NAME (self));
+ g_return_if_fail (family_name == NULL || *family_name != '\0');
+
+ g_free (self->priv->family_name);
+ self->priv->family_name = g_strdup (family_name);
+ g_object_notify (G_OBJECT (self), "family-name");
+}
+
+/**
+ * gdata_gd_name_get_prefix:
+ * @self: a #GDataGDName
+ *
+ * Gets the #GDataGDName:prefix property.
+ *
+ * Return value: the person's name prefix, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_name_get_prefix (GDataGDName *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
+ return self->priv->prefix;
+}
+
+/**
+ * gdata_gd_name_set_prefix:
+ * @self: a #GDataGDName
+ * @prefix: the new prefix, or %NULL
+ *
+ * Sets the #GDataGDName:prefix property to @prefix.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_name_set_prefix (GDataGDName *self, const gchar *prefix)
+{
+ g_return_if_fail (GDATA_IS_GD_NAME (self));
+ g_return_if_fail (prefix == NULL || *prefix != '\0');
+
+ g_free (self->priv->prefix);
+ self->priv->prefix = g_strdup (prefix);
+ g_object_notify (G_OBJECT (self), "prefix");
+}
+
+/**
+ * gdata_gd_name_get_suffix:
+ * @self: a #GDataGDName
+ *
+ * Gets the #GDataGDName:suffix property.
+ *
+ * Return value: the person's name suffix, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_name_get_suffix (GDataGDName *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
+ return self->priv->suffix;
+}
+
+/**
+ * gdata_gd_name_set_suffix:
+ * @self: a #GDataGDName
+ * @suffix: the new suffix, or %NULL
+ *
+ * Sets the #GDataGDName:suffix property to @suffix.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_name_set_suffix (GDataGDName *self, const gchar *suffix)
+{
+ g_return_if_fail (GDATA_IS_GD_NAME (self));
+ g_return_if_fail (suffix == NULL || *suffix != '\0');
+
+ g_free (self->priv->suffix);
+ self->priv->suffix = g_strdup (suffix);
+ g_object_notify (G_OBJECT (self), "suffix");
+}
+
+/**
+ * gdata_gd_name_get_full_name:
+ * @self: a #GDataGDName
+ *
+ * Gets the #GDataGDName:full-name property.
+ *
+ * Return value: the person's full name, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_name_get_full_name (GDataGDName *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_NAME (self), NULL);
+ return self->priv->full_name;
+}
+
+/**
+ * gdata_gd_name_set_full_name:
+ * @self: a #GDataGDName
+ * @full_name: the new full name, or %NULL
+ *
+ * Sets the #GDataGDName:full-name property to @full_name.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_name_set_full_name (GDataGDName *self, const gchar *full_name)
+{
+ g_return_if_fail (GDATA_IS_GD_NAME (self));
+
+ g_free (self->priv->full_name);
+ self->priv->full_name = g_strdup (full_name);
+ g_object_notify (G_OBJECT (self), "full-name");
+}
diff --git a/gdata/gd/gdata-gd-name.h b/gdata/gd/gdata-gd-name.h
new file mode 100644
index 0000000..361414c
--- /dev/null
+++ b/gdata/gd/gdata-gd-name.h
@@ -0,0 +1,88 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * GData Client
+ * Copyright (C) Philip Withnall 2009 <philip tecnocode co uk>
+ *
+ * GData Client is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * GData Client is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GData Client. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GDATA_GD_NAME_H
+#define GDATA_GD_NAME_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdata/gdata-parsable.h>
+
+G_BEGIN_DECLS
+
+#define GDATA_TYPE_GD_NAME (gdata_gd_name_get_type ())
+#define GDATA_GD_NAME(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_GD_NAME, GDataGDName))
+#define GDATA_GD_NAME_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDATA_TYPE_GD_NAME, GDataGDNameClass))
+#define GDATA_IS_GD_NAME(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDATA_TYPE_GD_NAME))
+#define GDATA_IS_GD_NAME_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GDATA_TYPE_GD_NAME))
+#define GDATA_GD_NAME_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GDATA_TYPE_GD_NAME, GDataGDNameClass))
+
+typedef struct _GDataGDNamePrivate GDataGDNamePrivate;
+
+/**
+ * GDataGDName:
+ *
+ * All the fields in the #GDataGDName structure are private and should never be accessed directly.
+ *
+ * Since: 0.5.0
+ **/
+typedef struct {
+ GDataParsable parent;
+ GDataGDNamePrivate *priv;
+} GDataGDName;
+
+/**
+ * GDataGDNameClass:
+ *
+ * All the fields in the #GDataGDNameClass structure are private and should never be accessed directly.
+ *
+ * Since: 0.5.0
+ **/
+typedef struct {
+ /*< private >*/
+ GDataParsableClass parent;
+} GDataGDNameClass;
+
+GType gdata_gd_name_get_type (void) G_GNUC_CONST;
+
+GDataGDName *gdata_gd_name_new (const gchar *given_name, const gchar *family_name) G_GNUC_WARN_UNUSED_RESULT;
+gint gdata_gd_name_compare (const GDataGDName *a, const GDataGDName *b);
+
+const gchar *gdata_gd_name_get_given_name (GDataGDName *self);
+void gdata_gd_name_set_given_name (GDataGDName *self, const gchar *given_name);
+
+const gchar *gdata_gd_name_get_additional_name (GDataGDName *self);
+void gdata_gd_name_set_additional_name (GDataGDName *self, const gchar *additional_name);
+
+const gchar *gdata_gd_name_get_family_name (GDataGDName *self);
+void gdata_gd_name_set_family_name (GDataGDName *self, const gchar *family_name);
+
+const gchar *gdata_gd_name_get_prefix (GDataGDName *self);
+void gdata_gd_name_set_prefix (GDataGDName *self, const gchar *prefix);
+
+const gchar *gdata_gd_name_get_suffix (GDataGDName *self);
+void gdata_gd_name_set_suffix (GDataGDName *self, const gchar *suffix);
+
+const gchar *gdata_gd_name_get_full_name (GDataGDName *self);
+void gdata_gd_name_set_full_name (GDataGDName *self, const gchar *full_name);
+
+G_END_DECLS
+
+#endif /* !GDATA_GD_NAME_H */
diff --git a/gdata/gd/gdata-gd-organization.c b/gdata/gd/gdata-gd-organization.c
index 9942623..29c3eb4 100644
--- a/gdata/gd/gdata-gd-organization.c
+++ b/gdata/gd/gdata-gd-organization.c
@@ -49,6 +49,9 @@ struct _GDataGDOrganizationPrivate {
gchar *relation_type;
gchar *label;
gboolean is_primary;
+ gchar *department;
+ gchar *job_description;
+ gchar *symbol;
};
enum {
@@ -56,7 +59,10 @@ enum {
PROP_TITLE,
PROP_RELATION_TYPE,
PROP_LABEL,
- PROP_IS_PRIMARY
+ PROP_IS_PRIMARY,
+ PROP_DEPARTMENT,
+ PROP_JOB_DESCRIPTION,
+ PROP_SYMBOL
};
G_DEFINE_TYPE (GDataGDOrganization, gdata_gd_organization, GDATA_TYPE_PARSABLE)
@@ -88,7 +94,7 @@ gdata_gd_organization_class_init (GDataGDOrganizationClass *klass)
* The name of the organization.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdOrganization">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdOrganization">GData specification</ulink>.
*
* Since: 0.4.0
**/
@@ -104,7 +110,7 @@ gdata_gd_organization_class_init (GDataGDOrganizationClass *klass)
* The title of a person within the organization.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdOrganization">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdOrganization">GData specification</ulink>.
*
* Since: 0.4.0
**/
@@ -120,7 +126,7 @@ gdata_gd_organization_class_init (GDataGDOrganizationClass *klass)
* A programmatic value that identifies the type of organization.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdOrganization">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdOrganization">GData specification</ulink>.
*
* Since: 0.4.0
**/
@@ -137,7 +143,7 @@ gdata_gd_organization_class_init (GDataGDOrganizationClass *klass)
* "Professional Society", etc.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdOrganization">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdOrganization">GData specification</ulink>.
*
* Since: 0.4.0
**/
@@ -153,7 +159,7 @@ gdata_gd_organization_class_init (GDataGDOrganizationClass *klass)
* Indicates which organization out of a group is primary.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdOrganization">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdOrganization">GData specification</ulink>.
*
* Since: 0.4.0
**/
@@ -162,6 +168,54 @@ gdata_gd_organization_class_init (GDataGDOrganizationClass *klass)
"Primary?", "Indicates which organization out of a group is primary.",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDOrganization:department:
+ *
+ * Specifies a department within the organization.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdOrganization">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_DEPARTMENT,
+ g_param_spec_string ("department",
+ "Department", "Specifies a department within the organization.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDOrganization:job-description:
+ *
+ * Description of a job within the organization.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdOrganization">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_JOB_DESCRIPTION,
+ g_param_spec_string ("job-description",
+ "Job description", "Description of a job within the organization.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDOrganization:symbol:
+ *
+ * Stock symbol of the organization.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdOrganization">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_SYMBOL,
+ g_param_spec_string ("symbol",
+ "Symbol", "Symbol of the organization.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
@@ -179,6 +233,9 @@ gdata_gd_organization_finalize (GObject *object)
g_free (priv->title);
g_free (priv->relation_type);
g_free (priv->label);
+ g_free (priv->department);
+ g_free (priv->job_description);
+ g_free (priv->symbol);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_gd_organization_parent_class)->finalize (object);
@@ -205,6 +262,15 @@ gdata_gd_organization_get_property (GObject *object, guint property_id, GValue *
case PROP_IS_PRIMARY:
g_value_set_boolean (value, priv->is_primary);
break;
+ case PROP_DEPARTMENT:
+ g_value_set_string (value, priv->department);
+ break;
+ case PROP_JOB_DESCRIPTION:
+ g_value_set_string (value, priv->job_description);
+ break;
+ case PROP_SYMBOL:
+ g_value_set_string (value, priv->symbol);
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -233,6 +299,15 @@ gdata_gd_organization_set_property (GObject *object, guint property_id, const GV
case PROP_IS_PRIMARY:
gdata_gd_organization_set_is_primary (self, g_value_get_boolean (value));
break;
+ case PROP_DEPARTMENT:
+ gdata_gd_organization_set_department (self, g_value_get_string (value));
+ break;
+ case PROP_JOB_DESCRIPTION:
+ gdata_gd_organization_set_job_description (self, g_value_get_string (value));
+ break;
+ case PROP_SYMBOL:
+ gdata_gd_organization_set_symbol (self, g_value_get_string (value));
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -305,6 +380,36 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
title = xmlNodeListGetString (doc, node->children, TRUE);
priv->title = g_strdup ((gchar*) title);
xmlFree (title);
+ } else if (xmlStrcmp (node->name, (xmlChar*) "orgDepartment") == 0) {
+ /* gd:orgDepartment */
+ xmlChar *department;
+
+ if (priv->department != NULL)
+ return gdata_parser_error_duplicate_element (node, error);
+
+ department = xmlNodeListGetString (doc, node->children, TRUE);
+ priv->department = g_strdup ((gchar*) department);
+ xmlFree (department);
+ } else if (xmlStrcmp (node->name, (xmlChar*) "orgJobDescription") == 0) {
+ /* gd:orgJobDescription */
+ xmlChar *job_description;
+
+ if (priv->job_description != NULL)
+ return gdata_parser_error_duplicate_element (node, error);
+
+ job_description = xmlNodeListGetString (doc, node->children, TRUE);
+ priv->job_description = g_strdup ((gchar*) job_description);
+ xmlFree (job_description);
+ } else if (xmlStrcmp (node->name, (xmlChar*) "orgSymbol") == 0) {
+ /* gd:orgSymbol */
+ xmlChar *symbol;
+
+ if (priv->symbol != NULL)
+ return gdata_parser_error_duplicate_element (node, error);
+
+ symbol = xmlNodeListGetString (doc, node->children, TRUE);
+ priv->symbol = g_strdup ((gchar*) symbol);
+ xmlFree (symbol);
} else if (GDATA_PARSABLE_CLASS (gdata_gd_organization_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
@@ -336,9 +441,14 @@ get_xml (GDataParsable *parsable, GString *xml_string)
if (priv->name != NULL)
gdata_parser_string_append_escaped (xml_string, "<gd:orgName>", priv->name, "</gd:orgName>");
-
if (priv->title != NULL)
gdata_parser_string_append_escaped (xml_string, "<gd:orgTitle>", priv->title, "</gd:orgTitle>");
+ if (priv->department != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gd:orgDepartment>", priv->department, "</gd:orgDepartment>");
+ if (priv->job_description != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gd:orgJobDescription>", priv->job_description, "</gd:orgJobDescription>");
+ if (priv->symbol != NULL)
+ gdata_parser_string_append_escaped (xml_string, "<gd:orgSymbol>", priv->symbol, "</gd:orgSymbol>");
}
static void
@@ -394,7 +504,8 @@ gdata_gd_organization_compare (const GDataGDOrganization *a, const GDataGDOrgani
if (a == b)
return 0;
- if (g_strcmp0 (a->priv->name, b->priv->name) == 0 && g_strcmp0 (a->priv->title, b->priv->title) == 0)
+ if (g_strcmp0 (a->priv->name, b->priv->name) == 0 && g_strcmp0 (a->priv->title, b->priv->title) == 0 &&
+ g_strcmp0 (a->priv->department, b->priv->department) == 0)
return 0;
return 1;
}
@@ -586,3 +697,117 @@ gdata_gd_organization_set_is_primary (GDataGDOrganization *self, gboolean is_pri
self->priv->is_primary = is_primary;
g_object_notify (G_OBJECT (self), "is-primary");
}
+
+/**
+ * gdata_gd_organization_get_department:
+ * @self: a #GDataGDOrganization
+ *
+ * Gets the #GDataGDOrganization:department property.
+ *
+ * Return value: the department in which the person works in this organization, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_organization_get_department (GDataGDOrganization *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_ORGANIZATION (self), NULL);
+ return self->priv->department;
+}
+
+/**
+ * gdata_gd_organization_set_department:
+ * @self: a #GDataGDOrganization
+ * @department: the new department for the person working in the organization
+ *
+ * Sets the #GDataGDOrganization:department property to @department.
+ *
+ * Set @department to %NULL to unset the property in the organization.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_organization_set_department (GDataGDOrganization *self, const gchar *department)
+{
+ g_return_if_fail (GDATA_IS_GD_ORGANIZATION (self));
+
+ g_free (self->priv->department);
+ self->priv->department = g_strdup (department);
+ g_object_notify (G_OBJECT (self), "department");
+}
+
+/**
+ * gdata_gd_organization_get_job_description:
+ * @self: a #GDataGDOrganization
+ *
+ * Gets the #GDataGDOrganization:job-description property.
+ *
+ * Return value: the job description of the person in the organization, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_organization_get_job_description (GDataGDOrganization *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_ORGANIZATION (self), NULL);
+ return self->priv->job_description;
+}
+
+/**
+ * gdata_gd_organization_set_job_description:
+ * @self: a #GDataGDOrganization
+ * @job_description: the new job description for the person in the organization
+ *
+ * Sets the #GDataGDOrganization:job-description property to @job_description.
+ *
+ * Set @job_description to %NULL to unset the property in the organization.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_organization_set_job_description (GDataGDOrganization *self, const gchar *job_description)
+{
+ g_return_if_fail (GDATA_IS_GD_ORGANIZATION (self));
+
+ g_free (self->priv->job_description);
+ self->priv->job_description = g_strdup (job_description);
+ g_object_notify (G_OBJECT (self), "job-description");
+}
+
+/**
+ * gdata_gd_organization_get_symbol:
+ * @self: a #GDataGDOrganization
+ *
+ * Gets the #GDataGDOrganization:symbol property.
+ *
+ * Return value: the organization's stock symbol, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_organization_get_symbol (GDataGDOrganization *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_ORGANIZATION (self), NULL);
+ return self->priv->symbol;
+}
+
+/**
+ * gdata_gd_organization_set_symbol:
+ * @self: a #GDataGDOrganization
+ * @symbol: the new stock symbol for the organization
+ *
+ * Sets the #GDataGDOrganization:symbol property to @symbol.
+ *
+ * Set @symbol to %NULL to unset the property in the organization.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_organization_set_symbol (GDataGDOrganization *self, const gchar *symbol)
+{
+ g_return_if_fail (GDATA_IS_GD_ORGANIZATION (self));
+
+ g_free (self->priv->symbol);
+ self->priv->symbol = g_strdup (symbol);
+ g_object_notify (G_OBJECT (self), "symbol");
+}
diff --git a/gdata/gd/gdata-gd-organization.h b/gdata/gd/gdata-gd-organization.h
index c89e122..1351ce8 100644
--- a/gdata/gd/gdata-gd-organization.h
+++ b/gdata/gd/gdata-gd-organization.h
@@ -79,6 +79,15 @@ void gdata_gd_organization_set_label (GDataGDOrganization *self, const gchar *la
gboolean gdata_gd_organization_is_primary (GDataGDOrganization *self);
void gdata_gd_organization_set_is_primary (GDataGDOrganization *self, gboolean is_primary);
+const gchar *gdata_gd_organization_get_department (GDataGDOrganization *self);
+void gdata_gd_organization_set_department (GDataGDOrganization *self, const gchar *department);
+
+const gchar *gdata_gd_organization_get_job_description (GDataGDOrganization *self);
+void gdata_gd_organization_set_job_description (GDataGDOrganization *self, const gchar *job_description);
+
+const gchar *gdata_gd_organization_get_symbol (GDataGDOrganization *self);
+void gdata_gd_organization_set_symbol (GDataGDOrganization *self, const gchar *symbol);
+
G_END_DECLS
#endif /* !GDATA_GD_ORGANIZATION_H */
diff --git a/gdata/gd/gdata-gd-postal-address.c b/gdata/gd/gdata-gd-postal-address.c
index b8308ab..e306c66 100644
--- a/gdata/gd/gdata-gd-postal-address.c
+++ b/gdata/gd/gdata-gd-postal-address.c
@@ -45,17 +45,43 @@ static void get_xml (GDataParsable *parsable, GString *xml_string);
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
struct _GDataGDPostalAddressPrivate {
- gchar *address;
+ gchar *formatted_address;
gchar *relation_type;
gchar *label;
gboolean is_primary;
+ gchar *mail_class;
+ gchar *usage;
+ gchar *agent;
+ gchar *house_name;
+ gchar *street;
+ gchar *po_box;
+ gchar *neighborhood;
+ gchar *city;
+ gchar *subregion;
+ gchar *region;
+ gchar *postcode;
+ gchar *country;
+ gchar *country_code;
};
enum {
- PROP_ADDRESS = 1,
+ PROP_FORMATTED_ADDRESS = 1,
PROP_RELATION_TYPE,
PROP_LABEL,
- PROP_IS_PRIMARY
+ PROP_IS_PRIMARY,
+ PROP_MAIL_CLASS,
+ PROP_USAGE,
+ PROP_AGENT,
+ PROP_HOUSE_NAME,
+ PROP_STREET,
+ PROP_PO_BOX,
+ PROP_NEIGHBORHOOD,
+ PROP_CITY,
+ PROP_SUBREGION,
+ PROP_REGION,
+ PROP_POSTCODE,
+ PROP_COUNTRY,
+ PROP_COUNTRY_CODE
};
G_DEFINE_TYPE (GDataGDPostalAddress, gdata_gd_postal_address, GDATA_TYPE_PARSABLE)
@@ -78,20 +104,20 @@ gdata_gd_postal_address_class_init (GDataGDPostalAddressClass *klass)
parsable_class->pre_get_xml = pre_get_xml;
parsable_class->get_xml = get_xml;
parsable_class->get_namespaces = get_namespaces;
- parsable_class->element_name = "postalAddress";
+ parsable_class->element_name = "structuredPostalAddress";
parsable_class->element_namespace = "gd";
/**
* GDataGDPostalAddress:address:
*
- * The postal address itself.
+ * The postal address itself, formatted and unstructured. It is preferred to use the other, structured properties rather than this one.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPostalAddress">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
*
* Since: 0.4.0
**/
- g_object_class_install_property (gobject_class, PROP_ADDRESS,
+ g_object_class_install_property (gobject_class, PROP_FORMATTED_ADDRESS,
g_param_spec_string ("address",
"Address", "The postal address itself.",
NULL,
@@ -103,7 +129,7 @@ gdata_gd_postal_address_class_init (GDataGDPostalAddressClass *klass)
* A programmatic value that identifies the type of postal address.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPostalAddress">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
*
* Since: 0.4.0
**/
@@ -119,7 +145,7 @@ gdata_gd_postal_address_class_init (GDataGDPostalAddressClass *klass)
* A simple string value used to name this postal address. It allows UIs to display a label such as "Work", "Personal", "Preferred", etc.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPostalAddress">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
*
* Since: 0.4.0
**/
@@ -135,7 +161,7 @@ gdata_gd_postal_address_class_init (GDataGDPostalAddressClass *klass)
* Indicates which postal address out of a group is primary.
*
* For more information, see the
- * <ulink type="http" url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPostalAddress">GData specification</ulink>.
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
*
* Since: 0.4.0
**/
@@ -144,6 +170,220 @@ gdata_gd_postal_address_class_init (GDataGDPostalAddressClass *klass)
"Primary?", "Indicates which postal address out of a group is primary.",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:mail-class:
+ *
+ * Classes of mail accepted at this address.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_MAIL_CLASS,
+ g_param_spec_string ("mail-class",
+ "Mail class", "Classes of mail accepted at this address.",
+ GDATA_GD_MAIL_CLASS_BOTH,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:usage:
+ *
+ * The context in which this addess can be used.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_USAGE,
+ g_param_spec_string ("usage",
+ "Usage", "The context in which this addess can be used.",
+ GDATA_GD_ADDRESS_USAGE_GENERAL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:agent:
+ *
+ * The agent who actually receives the mail. Used in work addresses. Also for "in care of" or "c/o".
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_AGENT,
+ g_param_spec_string ("agent",
+ "Agent", "The agent who actually receives the mail.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:house-name:
+ *
+ * Used in places where houses or buildings have names (and not necessarily numbers).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_HOUSE_NAME,
+ g_param_spec_string ("house-name",
+ "House name", "Used in places where houses or buildings have names (and not necessarily numbers).",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:street:
+ *
+ * Can be street, avenue, road, etc. This element also includes the house number and room/apartment/flat/floor number.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_STREET,
+ g_param_spec_string ("street",
+ "Street", "Can be street, avenue, road, etc.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:po-box:
+ *
+ * Covers actual P.O. boxes, drawers, locked bags, etc. This is usually but not always mutually exclusive with #GDataGDPostalAddress:street.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_PO_BOX,
+ g_param_spec_string ("po-box",
+ "PO box", "Covers actual P.O. boxes, drawers, locked bags, etc.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:neighborhood:
+ *
+ * This is used to disambiguate a street address when a city contains more than one street with the same name, or to specify a small place
+ * whose mail is routed through a larger postal town. In China it could be a county or a minor city.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_NEIGHBORHOOD,
+ g_param_spec_string ("neighborhood",
+ "Neighborhood", "This is used to disambiguate a street address.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:city:
+ *
+ * Can be city, village, town, borough, etc. This is the postal town and not necessarily the place of residence or place of business.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_CITY,
+ g_param_spec_string ("city",
+ "City", "Can be city, village, town, borough, etc.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:subregion:
+ *
+ * Handles administrative districts such as U.S. or U.K. counties that are not used for mail addressing purposes.
+ * Subregion is not intended for delivery addresses.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_SUBREGION,
+ g_param_spec_string ("subregion",
+ "Subregion", "Handles administrative districts such as U.S. or U.K. counties.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:region:
+ *
+ * A state, province, county (in Ireland), Land (in Germany), departement (in France), etc.
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_REGION,
+ g_param_spec_string ("region",
+ "Region", "A state, province, county (in Ireland), Land (in Germany), departement (in France), etc.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:postcode:
+ *
+ * Postal code. Usually country-wide, but sometimes specific to the city (e.g. "2" in "Dublin 2, Ireland" addresses).
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_POSTCODE,
+ g_param_spec_string ("postcode",
+ "Postcode", "Postal code.",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataGDPostalAddress:country:
+ *
+ * The name of the country. Since this is paired with #GDataGDPostalAddress:country-code, they must both be set with
+ * gdata_gd_postal_address_set_country().
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_COUNTRY,
+ g_param_spec_string ("country",
+ "Country", "The name of the country.",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ /* TODO: Should be an enum? */
+ /**
+ * GDataGDPostalAddress:country-code:
+ *
+ * The ISO 3166-1 alpha-2 country code for the country in #GDataGDPostalAddress:country. Since this is paired with
+ * #GDataGDPostalAddress:country, they must both be set with gdata_gd_postal_address_set_country().
+ *
+ * For more information, see the
+ * <ulink type="http" url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>
+ * or <ulink type="http" url="http://www.iso.org/iso/iso-3166-1_decoding_table">ISO 3166-1 alpha-2</ulink>.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_COUNTRY_CODE,
+ g_param_spec_string ("country-code",
+ "Country code", "The ISO 3166-1 alpha-2 country code for the country.",
+ NULL,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}
static void
@@ -157,9 +397,22 @@ gdata_gd_postal_address_finalize (GObject *object)
{
GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (object)->priv;
- g_free (priv->address);
+ g_free (priv->formatted_address);
g_free (priv->relation_type);
g_free (priv->label);
+ g_free (priv->mail_class);
+ g_free (priv->usage);
+ g_free (priv->agent);
+ g_free (priv->house_name);
+ g_free (priv->street);
+ g_free (priv->po_box);
+ g_free (priv->neighborhood);
+ g_free (priv->city);
+ g_free (priv->subregion);
+ g_free (priv->region);
+ g_free (priv->postcode);
+ g_free (priv->country);
+ g_free (priv->country_code);
/* Chain up to the parent class */
G_OBJECT_CLASS (gdata_gd_postal_address_parent_class)->finalize (object);
@@ -171,8 +424,8 @@ gdata_gd_postal_address_get_property (GObject *object, guint property_id, GValue
GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (object)->priv;
switch (property_id) {
- case PROP_ADDRESS:
- g_value_set_string (value, priv->address);
+ case PROP_FORMATTED_ADDRESS:
+ g_value_set_string (value, priv->formatted_address);
break;
case PROP_RELATION_TYPE:
g_value_set_string (value, priv->relation_type);
@@ -183,6 +436,45 @@ gdata_gd_postal_address_get_property (GObject *object, guint property_id, GValue
case PROP_IS_PRIMARY:
g_value_set_boolean (value, priv->is_primary);
break;
+ case PROP_MAIL_CLASS:
+ g_value_set_string (value, priv->mail_class);
+ break;
+ case PROP_USAGE:
+ g_value_set_string (value, priv->usage);
+ break;
+ case PROP_AGENT:
+ g_value_set_string (value, priv->agent);
+ break;
+ case PROP_HOUSE_NAME:
+ g_value_set_string (value, priv->house_name);
+ break;
+ case PROP_STREET:
+ g_value_set_string (value, priv->street);
+ break;
+ case PROP_PO_BOX:
+ g_value_set_string (value, priv->po_box);
+ break;
+ case PROP_NEIGHBORHOOD:
+ g_value_set_string (value, priv->neighborhood);
+ break;
+ case PROP_CITY:
+ g_value_set_string (value, priv->city);
+ break;
+ case PROP_SUBREGION:
+ g_value_set_string (value, priv->subregion);
+ break;
+ case PROP_REGION:
+ g_value_set_string (value, priv->region);
+ break;
+ case PROP_POSTCODE:
+ g_value_set_string (value, priv->postcode);
+ break;
+ case PROP_COUNTRY:
+ g_value_set_string (value, priv->country);
+ break;
+ case PROP_COUNTRY_CODE:
+ g_value_set_string (value, priv->country_code);
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -196,7 +488,7 @@ gdata_gd_postal_address_set_property (GObject *object, guint property_id, const
GDataGDPostalAddress *self = GDATA_GD_POSTAL_ADDRESS (object);
switch (property_id) {
- case PROP_ADDRESS:
+ case PROP_FORMATTED_ADDRESS:
gdata_gd_postal_address_set_address (self, g_value_get_string (value));
break;
case PROP_RELATION_TYPE:
@@ -208,6 +500,39 @@ gdata_gd_postal_address_set_property (GObject *object, guint property_id, const
case PROP_IS_PRIMARY:
gdata_gd_postal_address_set_is_primary (self, g_value_get_boolean (value));
break;
+ case PROP_MAIL_CLASS:
+ gdata_gd_postal_address_set_mail_class (self, g_value_get_string (value));
+ break;
+ case PROP_USAGE:
+ gdata_gd_postal_address_set_usage (self, g_value_get_string (value));
+ break;
+ case PROP_AGENT:
+ gdata_gd_postal_address_set_agent (self, g_value_get_string (value));
+ break;
+ case PROP_HOUSE_NAME:
+ gdata_gd_postal_address_set_house_name (self, g_value_get_string (value));
+ break;
+ case PROP_STREET:
+ gdata_gd_postal_address_set_street (self, g_value_get_string (value));
+ break;
+ case PROP_PO_BOX:
+ gdata_gd_postal_address_set_po_box (self, g_value_get_string (value));
+ break;
+ case PROP_NEIGHBORHOOD:
+ gdata_gd_postal_address_set_neighborhood (self, g_value_get_string (value));
+ break;
+ case PROP_CITY:
+ gdata_gd_postal_address_set_city (self, g_value_get_string (value));
+ break;
+ case PROP_SUBREGION:
+ gdata_gd_postal_address_set_subregion (self, g_value_get_string (value));
+ break;
+ case PROP_REGION:
+ gdata_gd_postal_address_set_region (self, g_value_get_string (value));
+ break;
+ case PROP_POSTCODE:
+ gdata_gd_postal_address_set_postcode (self, g_value_get_string (value));
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -218,21 +543,13 @@ gdata_gd_postal_address_set_property (GObject *object, guint property_id, const
static gboolean
pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointer user_data, GError **error)
{
- xmlChar *address, *rel, *label, *primary;
+ xmlChar *rel, *label, *primary, *mail_class, *usage;
gboolean primary_bool;
GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (parsable)->priv;
- address = xmlNodeListGetString (doc, root_node->children, TRUE);
- if (address == NULL || *address == '\0') {
- xmlFree (address);
- return gdata_parser_error_required_content_missing (root_node, error);
- }
-
rel = xmlGetProp (root_node, (xmlChar*) "rel");
- if (rel != NULL && *rel == '\0') {
- xmlFree (address);
+ if (rel != NULL && *rel == '\0')
return gdata_parser_error_required_property_missing (root_node, "rel", error);
- }
/* Is it the primary postal address? */
primary = xmlGetProp (root_node, (xmlChar*) "primary");
@@ -243,7 +560,6 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
else {
gdata_parser_error_unknown_property_value (root_node, "primary", (gchar*) primary, error);
xmlFree (primary);
- xmlFree (address);
xmlFree (rel);
return FALSE;
}
@@ -251,27 +567,53 @@ pre_parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *root_node, gpointe
/* Other properties */
label = xmlGetProp (root_node, (xmlChar*) "label");
+ mail_class = xmlGetProp (root_node, (xmlChar*) "mailClass");
+ usage = xmlGetProp (root_node, (xmlChar*) "usage");
- gdata_gd_postal_address_set_address (GDATA_GD_POSTAL_ADDRESS (parsable), (const gchar*) address);
priv->relation_type = g_strdup ((gchar*) rel);
priv->label = g_strdup ((gchar*) label);
+ priv->mail_class = g_strdup ((gchar*) mail_class);
+ priv->usage = g_strdup ((gchar*) usage);
priv->is_primary = primary_bool;
- xmlFree (address);
xmlFree (rel);
xmlFree (label);
+ xmlFree (mail_class);
+ xmlFree (usage);
return TRUE;
}
+#define PARSE_STRING_ELEMENT(E,F) \
+ if (xmlStrcmp (node->name, (xmlChar*) (E)) == 0) { \
+ /* gd:##E */ \
+ xmlChar *name; \
+ \
+ if (priv->F != NULL) \
+ return gdata_parser_error_duplicate_element (node, error); \
+ \
+ name = xmlNodeListGetString (doc, node->children, TRUE); \
+ priv->F = g_strdup ((gchar*) name); \
+ xmlFree (name); \
+ }
+
static gboolean
parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
{
- /* Textual content's handled in pre_parse_xml */
- if (node->type != XML_ELEMENT_NODE)
- return TRUE;
+ GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (parsable)->priv;
- if (GDATA_PARSABLE_CLASS (gdata_gd_postal_address_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
+ PARSE_STRING_ELEMENT ("agent", agent)
+ else PARSE_STRING_ELEMENT ("housename", house_name)
+ else PARSE_STRING_ELEMENT ("pobox", po_box)
+ else PARSE_STRING_ELEMENT ("street", street)
+ else PARSE_STRING_ELEMENT ("neighborhood", neighborhood)
+ else PARSE_STRING_ELEMENT ("city", city)
+ else PARSE_STRING_ELEMENT ("subregion", subregion)
+ else PARSE_STRING_ELEMENT ("region", region)
+ else PARSE_STRING_ELEMENT ("postcode", postcode)
+ else PARSE_STRING_ELEMENT ("country", country)
+ else PARSE_STRING_ELEMENT ("formattedAddress", formatted_address)
+ else if (GDATA_PARSABLE_CLASS (gdata_gd_postal_address_parent_class)->parse_xml (parsable, doc, node, user_data, error) == FALSE) {
/* Error! */
return FALSE;
}
@@ -288,6 +630,10 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
g_string_append_printf (xml_string, " rel='%s'", priv->relation_type);
if (priv->label != NULL)
gdata_parser_string_append_escaped (xml_string, " label='", priv->label, "'");
+ if (priv->mail_class != NULL)
+ gdata_parser_string_append_escaped (xml_string, " mailClass='", priv->mail_class, "'");
+ if (priv->usage != NULL)
+ gdata_parser_string_append_escaped (xml_string, " usage='", priv->usage, "'");
if (priv->is_primary == TRUE)
g_string_append (xml_string, " primary='true'");
@@ -295,12 +641,26 @@ pre_get_xml (GDataParsable *parsable, GString *xml_string)
g_string_append (xml_string, " primary='false'");
}
+#define OUTPUT_STRING_ELEMENT(E,F) \
+ if (priv->F != NULL) \
+ gdata_parser_string_append_escaped (xml_string, "<gd:" E ">", priv->F, "</gd:" E ">");
+
static void
get_xml (GDataParsable *parsable, GString *xml_string)
{
GDataGDPostalAddressPrivate *priv = GDATA_GD_POSTAL_ADDRESS (parsable)->priv;
- g_string_append (xml_string, priv->address);
+ OUTPUT_STRING_ELEMENT ("agent", agent)
+ OUTPUT_STRING_ELEMENT ("housename", house_name)
+ OUTPUT_STRING_ELEMENT ("street", street)
+ OUTPUT_STRING_ELEMENT ("pobox", po_box)
+ OUTPUT_STRING_ELEMENT ("neighborhood", neighborhood)
+ OUTPUT_STRING_ELEMENT ("city", city)
+ OUTPUT_STRING_ELEMENT ("subregion", subregion)
+ OUTPUT_STRING_ELEMENT ("region", region)
+ OUTPUT_STRING_ELEMENT ("postcode", postcode)
+ OUTPUT_STRING_ELEMENT ("country", country)
+ OUTPUT_STRING_ELEMENT ("formattedAddress", formatted_address)
}
static void
@@ -311,25 +671,22 @@ get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
/**
* gdata_gd_postal_address_new:
- * @address: the postal address, in human-readable format (new lines are significant)
* @relation_type: the relationship between the address and its owner, or %NULL
* @label: a human-readable label for the address, or %NULL
* @is_primary: %TRUE if this phone number is its owner's primary number, %FALSE otherwise
*
* Creates a new #GDataGDPostalAddress. More information is available in the <ulink type="http"
- * url="http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPostalAddress">GData specification</ulink>.
+ * url="http://code.google.com/apis/gdata/docs/2.0/elements.html#gdStructuredPostalAddress">GData specification</ulink>.
*
* Return value: a new #GDataGDPostalAddress, or %NULL; unref with g_object_unref()
*
* Since: 0.2.0
**/
GDataGDPostalAddress *
-gdata_gd_postal_address_new (const gchar *address, const gchar *relation_type, const gchar *label, gboolean is_primary)
+gdata_gd_postal_address_new (const gchar *relation_type, const gchar *label, gboolean is_primary)
{
- g_return_val_if_fail (address != NULL && *address != '\0', NULL);
g_return_val_if_fail (relation_type == NULL || *relation_type != '\0', NULL);
- return g_object_new (GDATA_TYPE_GD_POSTAL_ADDRESS, "address", address, "relation-type", relation_type,
- "label", label, "is-primary", is_primary, NULL);
+ return g_object_new (GDATA_TYPE_GD_POSTAL_ADDRESS, "relation-type", relation_type, "label", label, "is-primary", is_primary, NULL);
}
/**
@@ -340,7 +697,8 @@ gdata_gd_postal_address_new (const gchar *address, const gchar *relation_type, c
* Compares the two postal addresses in a strcmp() fashion. %NULL values are handled gracefully, with
* %0 returned if both @a and @b are %NULL, %-1 if @a is %NULL and %1 if @b is %NULL.
*
- * The comparison of non-%NULL values is done on the basis of the @address property of the #GDataGDPostalAddress<!-- -->es.
+ * The comparison of non-%NULL values is done on the basis of the @street, @po_box, @city and @postcode properties of
+ * the #GDataGDPostalAddress<!-- -->es.
*
* Return value: %0 if @a equals @b, %-1 or %1 as appropriate otherwise
*
@@ -356,7 +714,10 @@ gdata_gd_postal_address_compare (const GDataGDPostalAddress *a, const GDataGDPos
if (a == b)
return 0;
- return g_strcmp0 (a->priv->address, b->priv->address);
+ if (g_strcmp0 (a->priv->street, b->priv->street) == 0 && g_strcmp0 (a->priv->po_box, b->priv->po_box) == 0 &&
+ g_strcmp0 (a->priv->city, b->priv->city) == 0 && g_strcmp0 (a->priv->postcode, b->priv->postcode) == 0)
+ return 0;
+ return 1;
}
/**
@@ -373,7 +734,7 @@ const gchar *
gdata_gd_postal_address_get_address (GDataGDPostalAddress *self)
{
g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
- return self->priv->address;
+ return self->priv->formatted_address;
}
/**
@@ -393,7 +754,7 @@ gdata_gd_postal_address_set_address (GDataGDPostalAddress *self, const gchar *ad
g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
g_return_if_fail (address != NULL && *address != '\0');
- g_free (self->priv->address);
+ g_free (self->priv->formatted_address);
/* Trim leading and trailing whitespace from the address.
* See here: http://code.google.com/apis/gdata/docs/1.0/elements.html#gdPostalAddress */
@@ -404,7 +765,7 @@ gdata_gd_postal_address_set_address (GDataGDPostalAddress *self, const gchar *ad
while (len > 0 && g_ascii_isspace (address[len - 1]))
len--;
- self->priv->address = g_strndup (address, len);
+ self->priv->formatted_address = g_strndup (address, len);
g_object_notify (G_OBJECT (self), "address");
}
@@ -519,3 +880,485 @@ gdata_gd_postal_address_set_is_primary (GDataGDPostalAddress *self, gboolean is_
self->priv->is_primary = is_primary;
g_object_notify (G_OBJECT (self), "is-primary");
}
+
+/**
+ * gdata_gd_postal_address_get_mail_class:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:mail-class property.
+ *
+ * Return value: the postal address' mail class, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_mail_class (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->mail_class;
+}
+
+/**
+ * gdata_gd_postal_address_set_mail_class:
+ * @self: a #GDataGDPostalAddress
+ * @mail_class: the new mail class for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:mail-class property to @mail_class.
+ *
+ * Set @mail_class to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_mail_class (GDataGDPostalAddress *self, const gchar *mail_class)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->mail_class);
+ self->priv->mail_class = g_strdup (mail_class);
+ g_object_notify (G_OBJECT (self), "mail-class");
+}
+
+/**
+ * gdata_gd_postal_address_get_usage:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:usage property.
+ *
+ * Return value: the postal address' usage, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_usage (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->usage;
+}
+
+/**
+ * gdata_gd_postal_address_set_usage:
+ * @self: a #GDataGDPostalAddress
+ * @usage: the new usage for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:usage property to @usage.
+ *
+ * Set @usage to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_usage (GDataGDPostalAddress *self, const gchar *usage)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->usage);
+ self->priv->usage = g_strdup (usage);
+ g_object_notify (G_OBJECT (self), "usage");
+}
+
+/**
+ * gdata_gd_postal_address_get_agent:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:agent property.
+ *
+ * Return value: the postal address' agent, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_agent (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->agent;
+}
+
+/**
+ * gdata_gd_postal_address_set_agent:
+ * @self: a #GDataGDPostalAddress
+ * @agent: the new agent for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:agent property to @agent.
+ *
+ * Set @agent to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_agent (GDataGDPostalAddress *self, const gchar *agent)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->agent);
+ self->priv->agent = g_strdup (agent);
+ g_object_notify (G_OBJECT (self), "agent");
+}
+
+/**
+ * gdata_gd_postal_address_get_house_name:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:house-name property.
+ *
+ * Return value: the postal address' house name, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_house_name (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->house_name;
+}
+
+/**
+ * gdata_gd_postal_address_set_house_name:
+ * @self: a #GDataGDPostalAddress
+ * @house_name: the new house name for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:house-name property to @house_name.
+ *
+ * Set @house_name to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_house_name (GDataGDPostalAddress *self, const gchar *house_name)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->house_name);
+ self->priv->house_name = g_strdup (house_name);
+ g_object_notify (G_OBJECT (self), "house-name");
+}
+
+/**
+ * gdata_gd_postal_address_get_street:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:street property.
+ *
+ * Return value: the postal address' street, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_street (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->street;
+}
+
+/**
+ * gdata_gd_postal_address_set_street:
+ * @self: a #GDataGDPostalAddress
+ * @street: the new street for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:street property to @street.
+ *
+ * Set @street to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_street (GDataGDPostalAddress *self, const gchar *street)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->street);
+ self->priv->street = g_strdup (street);
+ g_object_notify (G_OBJECT (self), "street");
+}
+
+/**
+ * gdata_gd_postal_address_get_po_box:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:po-box property.
+ *
+ * Return value: the postal address' P.O. box, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_po_box (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->po_box;
+}
+
+/**
+ * gdata_gd_postal_address_set_po_box:
+ * @self: a #GDataGDPostalAddress
+ * @po_box: the new P.O. box for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:po-box property to @po_box.
+ *
+ * Set @po_box to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_po_box (GDataGDPostalAddress *self, const gchar *po_box)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->po_box);
+ self->priv->po_box = g_strdup (po_box);
+ g_object_notify (G_OBJECT (self), "po-box");
+}
+
+/**
+ * gdata_gd_postal_address_get_neighborhood:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:neighborhood property.
+ *
+ * Return value: the postal address' neighborhood, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_neighborhood (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->neighborhood;
+}
+
+/**
+ * gdata_gd_postal_address_set_neighborhood:
+ * @self: a #GDataGDPostalAddress
+ * @neighborhood: the new neighborhood for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:neighborhood property to @neighborhood.
+ *
+ * Set @neighborhood to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_neighborhood (GDataGDPostalAddress *self, const gchar *neighborhood)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->neighborhood);
+ self->priv->neighborhood = g_strdup (neighborhood);
+ g_object_notify (G_OBJECT (self), "neighborhood");
+}
+
+/**
+ * gdata_gd_postal_address_get_city:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:city property.
+ *
+ * Return value: the postal address' city, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_city (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->city;
+}
+
+/**
+ * gdata_gd_postal_address_set_city:
+ * @self: a #GDataGDPostalAddress
+ * @city: the new city for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:city property to @city.
+ *
+ * Set @city to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_city (GDataGDPostalAddress *self, const gchar *city)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->city);
+ self->priv->city = g_strdup (city);
+ g_object_notify (G_OBJECT (self), "city");
+}
+
+/**
+ * gdata_gd_postal_address_get_subregion:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:subregion property.
+ *
+ * Return value: the postal address' subregion, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_subregion (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->subregion;
+}
+
+/**
+ * gdata_gd_postal_address_set_subregion:
+ * @self: a #GDataGDPostalAddress
+ * @subregion: the new subregion for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:subregion property to @subregion.
+ *
+ * Set @subregion to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_subregion (GDataGDPostalAddress *self, const gchar *subregion)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->subregion);
+ self->priv->subregion = g_strdup (subregion);
+ g_object_notify (G_OBJECT (self), "subregion");
+}
+
+/**
+ * gdata_gd_postal_address_get_region:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:region property.
+ *
+ * Return value: the postal address' region, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_region (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->region;
+}
+
+/**
+ * gdata_gd_postal_address_set_region:
+ * @self: a #GDataGDPostalAddress
+ * @region: the new region for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:region property to @region.
+ *
+ * Set @region to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_region (GDataGDPostalAddress *self, const gchar *region)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->region);
+ self->priv->region = g_strdup (region);
+ g_object_notify (G_OBJECT (self), "region");
+}
+
+/**
+ * gdata_gd_postal_address_get_postcode:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:postcode property.
+ *
+ * Return value: the postal address' postcode, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_postcode (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->postcode;
+}
+
+/**
+ * gdata_gd_postal_address_set_postcode:
+ * @self: a #GDataGDPostalAddress
+ * @postcode: the new postcode for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:postcode property to @postcode.
+ *
+ * Set @postcode to %NULL to unset the property in the postal address.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_postcode (GDataGDPostalAddress *self, const gchar *postcode)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+
+ g_free (self->priv->postcode);
+ self->priv->postcode = g_strdup (postcode);
+ g_object_notify (G_OBJECT (self), "postcode");
+}
+
+/**
+ * gdata_gd_postal_address_get_country:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:country property.
+ *
+ * Return value: the postal address' country, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_country (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->country;
+}
+
+/**
+ * gdata_gd_postal_address_get_country_code:
+ * @self: a #GDataGDPostalAddress
+ *
+ * Gets the #GDataGDPostalAddress:country-code property.
+ *
+ * Return value: the postal address' ISO 3166-1 alpha-2 country code, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+const gchar *
+gdata_gd_postal_address_get_country_code (GDataGDPostalAddress *self)
+{
+ g_return_val_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self), NULL);
+ return self->priv->country_code;
+}
+
+/**
+ * gdata_gd_postal_address_set_country:
+ * @self: a #GDataGDPostalAddress
+ * @country: the new country for the postal address, or %NULL
+ * @country_code: the new country code for the postal address, or %NULL
+ *
+ * Sets the #GDataGDPostalAddress:country property to @country, and #GDataGDPostalAddress:country-code to @country_code.
+ *
+ * Set @country or @country_code to %NULL to unset the relevant property in the postal address. If a @country_code is provided, a @country must
+ * also be provided.
+ *
+ * Since: 0.5.0
+ **/
+void
+gdata_gd_postal_address_set_country (GDataGDPostalAddress *self, const gchar *country, const gchar *country_code)
+{
+ g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (self));
+ g_return_if_fail (country != NULL || country_code == NULL);
+
+ g_free (self->priv->country);
+ g_free (self->priv->country_code);
+ self->priv->country = g_strdup (country);
+ self->priv->country_code = g_strdup (country_code);
+
+ g_object_freeze_notify (G_OBJECT (self));
+ g_object_notify (G_OBJECT (self), "country");
+ g_object_notify (G_OBJECT (self), "country-code");
+ g_object_thaw_notify (G_OBJECT (self));
+}
diff --git a/gdata/gd/gdata-gd-postal-address.h b/gdata/gd/gdata-gd-postal-address.h
index ca09c59..a5ca30c 100644
--- a/gdata/gd/gdata-gd-postal-address.h
+++ b/gdata/gd/gdata-gd-postal-address.h
@@ -27,6 +27,60 @@
G_BEGIN_DECLS
+/**
+ * GDATA_GD_MAIL_CLASS_BOTH:
+ *
+ * Parcels and letters can be sent to the address. Value for #GDataGDPostalAddress:mail-class.
+ *
+ * Since: 0.5.0
+ **/
+#define GDATA_GD_MAIL_CLASS_BOTH "http://schemas.google.com/g/2005#both"
+
+/**
+ * GDATA_GD_MAIL_CLASS_LETTERS:
+ *
+ * Only letters can be sent to the address. Value for #GDataGDPostalAddress:mail-class.
+ *
+ * Since: 0.5.0
+ **/
+#define GDATA_GD_MAIL_CLASS_LETTERS "http://schemas.google.com/g/2005#letters"
+
+/**
+ * GDATA_GD_MAIL_CLASS_PARCELS:
+ *
+ * Only parcels can be sent to the address. Value for #GDataGDPostalAddress:mail-class.
+ *
+ * Since: 0.5.0
+ **/
+#define GDATA_GD_MAIL_CLASS_PARCELS "http://schemas.google.com/g/2005#parcels"
+
+/**
+ * GDATA_GD_MAIL_CLASS_NEITHER:
+ *
+ * Address is purely locational and cannot be used for mail. Value for #GDataGDPostalAddress:mail-class.
+ *
+ * Since: 0.5.0
+ **/
+#define GDATA_GD_MAIL_CLASS_NEITHER "http://schemas.google.com/g/2005#neither"
+
+/**
+ * GDATA_GD_ADDRESS_USAGE_GENERAL:
+ *
+ * The address is for general usage. Value for #GDataGDPostalAddress:usage.
+ *
+ * Since: 0.5.0
+ **/
+#define GDATA_GD_ADDRESS_USAGE_GENERAL "http://schemas.google.com/g/2005#general"
+
+/**
+ * GDATA_GD_ADDRESS_USAGE_LOCAL:
+ *
+ * The address is for local usage. Value for #GDataGDPostalAddress:usage.
+ *
+ * Since: 0.5.0
+ **/
+#define GDATA_GD_ADDRESS_USAGE_LOCAL "http://schemas.google.com/g/2005#local"
+
#define GDATA_TYPE_GD_POSTAL_ADDRESS (gdata_gd_postal_address_get_type ())
#define GDATA_GD_POSTAL_ADDRESS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDATA_TYPE_GD_POSTAL_ADDRESS, GDataGDPostalAddress))
#define GDATA_GD_POSTAL_ADDRESS_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GDATA_TYPE_GD_POSTAL_ADDRESS, GDataGDPostalAddressClass))
@@ -60,8 +114,7 @@ typedef struct {
GType gdata_gd_postal_address_get_type (void) G_GNUC_CONST;
-GDataGDPostalAddress *gdata_gd_postal_address_new (const gchar *address, const gchar *relation_type,
- const gchar *label, gboolean is_primary) G_GNUC_WARN_UNUSED_RESULT;
+GDataGDPostalAddress *gdata_gd_postal_address_new (const gchar *relation_type, const gchar *label, gboolean is_primary) G_GNUC_WARN_UNUSED_RESULT;
gint gdata_gd_postal_address_compare (const GDataGDPostalAddress *a, const GDataGDPostalAddress *b);
const gchar *gdata_gd_postal_address_get_address (GDataGDPostalAddress *self);
@@ -76,6 +129,43 @@ void gdata_gd_postal_address_set_label (GDataGDPostalAddress *self, const gchar
gboolean gdata_gd_postal_address_is_primary (GDataGDPostalAddress *self);
void gdata_gd_postal_address_set_is_primary (GDataGDPostalAddress *self, gboolean is_primary);
+const gchar *gdata_gd_postal_address_get_mail_class (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_mail_class (GDataGDPostalAddress *self, const gchar *mail_class);
+
+const gchar *gdata_gd_postal_address_get_usage (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_usage (GDataGDPostalAddress *self, const gchar *usage);
+
+const gchar *gdata_gd_postal_address_get_agent (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_agent (GDataGDPostalAddress *self, const gchar *agent);
+
+const gchar *gdata_gd_postal_address_get_house_name (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_house_name (GDataGDPostalAddress *self, const gchar *house_name);
+
+const gchar *gdata_gd_postal_address_get_street (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_street (GDataGDPostalAddress *self, const gchar *street);
+
+const gchar *gdata_gd_postal_address_get_po_box (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_po_box (GDataGDPostalAddress *self, const gchar *po_box);
+
+const gchar *gdata_gd_postal_address_get_neighborhood (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_neighborhood (GDataGDPostalAddress *self, const gchar *neighborhood);
+
+const gchar *gdata_gd_postal_address_get_city (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_city (GDataGDPostalAddress *self, const gchar *city);
+
+const gchar *gdata_gd_postal_address_get_subregion (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_subregion (GDataGDPostalAddress *self, const gchar *subregion);
+
+const gchar *gdata_gd_postal_address_get_region (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_region (GDataGDPostalAddress *self, const gchar *region);
+
+const gchar *gdata_gd_postal_address_get_postcode (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_postcode (GDataGDPostalAddress *self, const gchar *postcode);
+
+const gchar *gdata_gd_postal_address_get_country (GDataGDPostalAddress *self);
+const gchar *gdata_gd_postal_address_get_country_code (GDataGDPostalAddress *self);
+void gdata_gd_postal_address_set_country (GDataGDPostalAddress *self, const gchar *country, const gchar *country_code);
+
G_END_DECLS
#endif /* !GDATA_GD_POSTAL_ADDRESS_H */
diff --git a/gdata/gdata-parser.c b/gdata/gdata-parser.c
index 8d136e1..250c5ac 100644
--- a/gdata/gdata-parser.c
+++ b/gdata/gdata-parser.c
@@ -230,7 +230,7 @@ gdata_parser_string_append_escaped (GString *xml_string, const gchar *pre, const
* Copyright 2007, 2008 Ryan Lortie <desrt desrt ca>
*/
p = element_content;
- while (*p != '\0') {
+ while (p != NULL && *p != '\0') {
const gchar *next = g_utf8_next_char (p);
switch (*p) {
diff --git a/gdata/gdata-service.c b/gdata/gdata-service.c
index a01921f..dd66abb 100644
--- a/gdata/gdata-service.c
+++ b/gdata/gdata-service.c
@@ -110,6 +110,7 @@ gdata_service_class_init (GDataServiceClass *klass)
klass->service_name = "xapi";
klass->authentication_uri = "https://www.google.com/accounts/ClientLogin";
+ klass->api_version = "2";
klass->feed_type = GDATA_TYPE_FEED;
klass->parse_authentication_response = real_parse_authentication_response;
klass->append_query_headers = real_append_query_headers;
@@ -324,7 +325,7 @@ real_append_query_headers (GDataService *self, SoupMessage *message)
}
/* Set the GData-Version header to tell it we want to use the v2 API */
- soup_message_headers_append (message->request_headers, "GData-Version", "2");
+ soup_message_headers_append (message->request_headers, "GData-Version", GDATA_SERVICE_GET_CLASS (self)->api_version);
}
static void
diff --git a/gdata/gdata-service.h b/gdata/gdata-service.h
index cbadcfe..fde1164 100644
--- a/gdata/gdata-service.h
+++ b/gdata/gdata-service.h
@@ -132,6 +132,7 @@ typedef struct {
* @parent: the parent class
* @service_name: the name of the service (for subclasses) as given in the service's GData API documentation
* @authentication_uri: the authentication URI (for subclasses) if different from the Google ClientLogin default
+ * @api_version: the version of the GData API used by the service (typically %2)
* @feed_type: the #GType of the feed class (subclass of #GDataFeed) to use for query results from this service
* @parse_authentication_response: a function to parse the response from the online service to an authentication request as
* issued by gdata_service_authenticate(). It should return %TRUE if authentication was successful, and %FALSE if there was
@@ -148,6 +149,7 @@ typedef struct {
const gchar *service_name;
const gchar *authentication_uri;
+ const gchar *api_version;
GType feed_type;
gboolean (*parse_authentication_response) (GDataService *self, guint status, const gchar *response_body, gint length, GError **error);
diff --git a/gdata/gdata.h b/gdata/gdata.h
index 2bb1f49..c5830be 100644
--- a/gdata/gdata.h
+++ b/gdata/gdata.h
@@ -44,6 +44,7 @@
/* GData */
#include <gdata/gd/gdata-gd-email-address.h>
#include <gdata/gd/gdata-gd-im-address.h>
+#include <gdata/gd/gdata-gd-name.h>
#include <gdata/gd/gdata-gd-organization.h>
#include <gdata/gd/gdata-gd-phone-number.h>
#include <gdata/gd/gdata-gd-postal-address.h>
diff --git a/gdata/gdata.symbols b/gdata/gdata.symbols
index 1ab37fd..cd4e81c 100644
--- a/gdata/gdata.symbols
+++ b/gdata/gdata.symbols
@@ -272,6 +272,7 @@ gdata_contacts_query_set_group
gdata_contacts_contact_get_type
gdata_contacts_contact_new
gdata_contacts_contact_get_edited
+gdata_contacts_contact_get_name
gdata_contacts_contact_add_email_address
gdata_contacts_contact_get_email_addresses
gdata_contacts_contact_get_primary_email_address
@@ -371,6 +372,12 @@ gdata_gd_organization_get_label
gdata_gd_organization_set_label
gdata_gd_organization_is_primary
gdata_gd_organization_set_is_primary
+gdata_gd_organization_get_department
+gdata_gd_organization_set_department
+gdata_gd_organization_get_job_description
+gdata_gd_organization_set_job_description
+gdata_gd_organization_get_symbol
+gdata_gd_organization_set_symbol
gdata_gd_when_get_type
gdata_gd_when_new
gdata_gd_when_compare
@@ -436,6 +443,31 @@ gdata_gd_postal_address_get_label
gdata_gd_postal_address_set_label
gdata_gd_postal_address_is_primary
gdata_gd_postal_address_set_is_primary
+gdata_gd_postal_address_get_mail_class
+gdata_gd_postal_address_set_mail_class
+gdata_gd_postal_address_get_usage
+gdata_gd_postal_address_set_usage
+gdata_gd_postal_address_get_agent
+gdata_gd_postal_address_set_agent
+gdata_gd_postal_address_get_house_name
+gdata_gd_postal_address_set_house_name
+gdata_gd_postal_address_get_street
+gdata_gd_postal_address_set_street
+gdata_gd_postal_address_get_po_box
+gdata_gd_postal_address_set_po_box
+gdata_gd_postal_address_get_neighborhood
+gdata_gd_postal_address_set_neighborhood
+gdata_gd_postal_address_get_city
+gdata_gd_postal_address_set_city
+gdata_gd_postal_address_get_subregion
+gdata_gd_postal_address_set_subregion
+gdata_gd_postal_address_get_region
+gdata_gd_postal_address_set_region
+gdata_gd_postal_address_get_postcode
+gdata_gd_postal_address_set_postcode
+gdata_gd_postal_address_get_country
+gdata_gd_postal_address_get_country_code
+gdata_gd_postal_address_set_country
gdata_gd_phone_number_get_type
gdata_gd_phone_number_new
gdata_gd_phone_number_compare
@@ -652,3 +684,18 @@ gdata_upload_stream_get_upload_uri
gdata_upload_stream_get_entry
gdata_upload_stream_get_slug
gdata_upload_stream_get_content_type
+gdata_gd_name_get_type
+gdata_gd_name_new
+gdata_gd_name_compare
+gdata_gd_name_get_given_name
+gdata_gd_name_set_given_name
+gdata_gd_name_get_additional_name
+gdata_gd_name_set_additional_name
+gdata_gd_name_get_family_name
+gdata_gd_name_set_family_name
+gdata_gd_name_get_prefix
+gdata_gd_name_set_prefix
+gdata_gd_name_get_suffix
+gdata_gd_name_set_suffix
+gdata_gd_name_get_full_name
+gdata_gd_name_set_full_name
diff --git a/gdata/services/contacts/gdata-contacts-contact.c b/gdata/services/contacts/gdata-contacts-contact.c
index 5f58af5..11081b8 100644
--- a/gdata/services/contacts/gdata-contacts-contact.c
+++ b/gdata/services/contacts/gdata-contacts-contact.c
@@ -55,6 +55,7 @@ static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
struct _GDataContactsContactPrivate {
GTimeVal edited;
+ GDataGDName *name;
GList *email_addresses; /* GDataGDEmailAddress */
GList *im_addresses; /* GDataGDIMAddress */
GList *phone_numbers; /* GDataGDPhoneNumber */
@@ -69,7 +70,8 @@ struct _GDataContactsContactPrivate {
enum {
PROP_EDITED = 1,
PROP_DELETED,
- PROP_HAS_PHOTO
+ PROP_HAS_PHOTO,
+ PROP_NAME
};
G_DEFINE_TYPE (GDataContactsContact, gdata_contacts_contact, GDATA_TYPE_ENTRY)
@@ -132,6 +134,39 @@ gdata_contacts_contact_class_init (GDataContactsContactClass *klass)
"Has photo?", "Whether the contact has a photo.",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * GDataContactsContact:name:
+ *
+ * The contact's name in a structured representation.
+ *
+ * Since: 0.5.0
+ **/
+ g_object_class_install_property (gobject_class, PROP_NAME,
+ g_param_spec_object ("name",
+ "Name", "The contact's name in a structured representation.",
+ GDATA_TYPE_GD_NAME,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+}
+
+static void notify_full_name_cb (GObject *gobject, GParamSpec *pspec, GDataContactsContact *self);
+
+static void
+notify_title_cb (GObject *gobject, GParamSpec *pspec, GDataContactsContact *self)
+{
+ /* Update GDataGDName:full-name */
+ g_signal_handlers_block_by_func (self->priv->name, notify_full_name_cb, self);
+ gdata_gd_name_set_full_name (self->priv->name, gdata_entry_get_title (GDATA_ENTRY (self)));
+ g_signal_handlers_unblock_by_func (self->priv->name, notify_full_name_cb, self);
+}
+
+static void
+notify_full_name_cb (GObject *gobject, GParamSpec *pspec, GDataContactsContact *self)
+{
+ /* Update GDataEntry:title */
+ g_signal_handlers_block_by_func (self, notify_title_cb, self);
+ gdata_entry_set_title (GDATA_ENTRY (self), gdata_gd_name_get_full_name (self->priv->name));
+ g_signal_handlers_unblock_by_func (self, notify_title_cb, self);
}
static void
@@ -140,6 +175,13 @@ gdata_contacts_contact_init (GDataContactsContact *self)
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_CONTACTS_CONTACT, GDataContactsContactPrivate);
self->priv->extended_properties = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
self->priv->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+ /* Create a default name, so the name's properties can be set for a blank contact */
+ self->priv->name = gdata_gd_name_new (NULL, NULL);
+
+ /* Listen to change notifications for the entry's title, since it's linked to GDataGDName:fullName */
+ g_signal_connect (self, "notify::title", (GCallback) notify_title_cb, self);
+ g_signal_connect (self->priv->name, "notify::fullName", (GCallback) notify_full_name_cb, self);
}
static void
@@ -147,6 +189,10 @@ gdata_contacts_contact_dispose (GObject *object)
{
GDataContactsContact *self = GDATA_CONTACTS_CONTACT (object);
+ if (self->priv->name != NULL)
+ g_object_unref (self->priv->name);
+ self->priv->name = NULL;
+
gdata_contacts_contact_remove_all_organizations (self);
gdata_contacts_contact_remove_all_email_addresses (self);
gdata_contacts_contact_remove_all_im_addresses (self);
@@ -185,6 +231,9 @@ gdata_contacts_contact_get_property (GObject *object, guint property_id, GValue
case PROP_HAS_PHOTO:
g_value_set_boolean (value, (priv->photo_etag != NULL) ? TRUE : FALSE);
break;
+ case PROP_NAME:
+ g_value_set_object (value, priv->name);
+ break;
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -230,6 +279,17 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
return FALSE;
}
xmlFree (edited);
+ } else if (xmlStrcmp (node->name, (xmlChar*) "name") == 0) {
+ /* gd:name */
+ GDataGDName *name = GDATA_GD_NAME (_gdata_parsable_new_from_xml_node (GDATA_TYPE_GD_NAME, doc, node, NULL, error));
+
+ if (name == NULL)
+ return FALSE;
+
+ if (self->priv->name != NULL)
+ g_object_unref (self->priv->name);
+ self->priv->name = name;
+ g_object_notify (G_OBJECT (self), "name");
} else if (xmlStrcmp (node->name, (xmlChar*) "email") == 0) {
/* gd:email */
GDataGDEmailAddress *email = GDATA_GD_EMAIL_ADDRESS (_gdata_parsable_new_from_xml_node (GDATA_TYPE_GD_EMAIL_ADDRESS, doc,
@@ -253,8 +313,8 @@ parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_da
return FALSE;
gdata_contacts_contact_add_phone_number (self, number);
- } else if (xmlStrcmp (node->name, (xmlChar*) "postalAddress") == 0) {
- /* gd:postalAddress */
+ } else if (xmlStrcmp (node->name, (xmlChar*) "structuredPostalAddress") == 0) {
+ /* gd:structuredPostalAddress â?? deprecates gd:postalAddress */
GDataGDPostalAddress *address = GDATA_GD_POSTAL_ADDRESS (_gdata_parsable_new_from_xml_node (GDATA_TYPE_GD_POSTAL_ADDRESS,
doc, node, NULL, error));
if (address == NULL)
@@ -374,6 +434,9 @@ get_xml (GDataParsable *parsable, GString *xml_string)
/* Chain up to the parent class */
GDATA_PARSABLE_CLASS (gdata_contacts_contact_parent_class)->get_xml (parsable, xml_string);
+ /* Name */
+ _gdata_parsable_get_xml (GDATA_PARSABLE (priv->name), xml_string, FALSE);
+
/* Lists of stuff */
get_child_xml (priv->email_addresses, xml_string);
get_child_xml (priv->im_addresses, xml_string);
@@ -423,6 +486,23 @@ gdata_contacts_contact_get_edited (GDataContactsContact *self, GTimeVal *edited)
}
/**
+ * gdata_contacts_contact_get_name:
+ * @self: a #GDataContactsContact
+ *
+ * Gets the #GDataContactsContact:name property.
+ *
+ * Return value: the contact's name, or %NULL
+ *
+ * Since: 0.5.0
+ **/
+GDataGDName *
+gdata_contacts_contact_get_name (GDataContactsContact *self)
+{
+ g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
+ return self->priv->name;
+}
+
+/**
* gdata_contacts_contact_add_email_address:
* @self: a #GDataContactsContact
* @email_address: a #GDataGDEmailAddress to add
diff --git a/gdata/services/contacts/gdata-contacts-contact.h b/gdata/services/contacts/gdata-contacts-contact.h
index 11e89f4..8230c23 100644
--- a/gdata/services/contacts/gdata-contacts-contact.h
+++ b/gdata/services/contacts/gdata-contacts-contact.h
@@ -24,6 +24,7 @@
#include <glib-object.h>
#include <gdata/gdata-entry.h>
+#include <gdata/gd/gdata-gd-name.h>
#include <gdata/gd/gdata-gd-email-address.h>
#include <gdata/gd/gdata-gd-im-address.h>
#include <gdata/gd/gdata-gd-organization.h>
@@ -68,6 +69,8 @@ GDataContactsContact *gdata_contacts_contact_new (const gchar *id) G_GNUC_WARN_U
void gdata_contacts_contact_get_edited (GDataContactsContact *self, GTimeVal *edited);
gboolean gdata_contacts_contact_is_deleted (GDataContactsContact *self);
+GDataGDName *gdata_contacts_contact_get_name (GDataContactsContact *self);
+
void gdata_contacts_contact_add_email_address (GDataContactsContact *self, GDataGDEmailAddress *email_address);
GList *gdata_contacts_contact_get_email_addresses (GDataContactsContact *self);
GDataGDEmailAddress *gdata_contacts_contact_get_primary_email_address (GDataContactsContact *self);
diff --git a/gdata/services/contacts/gdata-contacts-service.c b/gdata/services/contacts/gdata-contacts-service.c
index 3ab26d0..bafee17 100644
--- a/gdata/services/contacts/gdata-contacts-service.c
+++ b/gdata/services/contacts/gdata-contacts-service.c
@@ -49,6 +49,7 @@ gdata_contacts_service_class_init (GDataContactsServiceClass *klass)
{
GDataServiceClass *service_class = GDATA_SERVICE_CLASS (klass);
service_class->service_name = "cp";
+ service_class->api_version = "3";
}
static void
diff --git a/gdata/tests/contacts.c b/gdata/tests/contacts.c
index 5cee6f0..da79a36 100644
--- a/gdata/tests/contacts.c
+++ b/gdata/tests/contacts.c
@@ -156,7 +156,8 @@ test_insert_simple (GDataService *service)
NULL, FALSE);
gdata_contacts_contact_add_im_address (contact, im_address);
g_object_unref (im_address);
- postal_address = gdata_gd_postal_address_new ("1600 Amphitheatre Pkwy Mountain View", "http://schemas.google.com/g/2005#work", NULL, TRUE);
+ postal_address = gdata_gd_postal_address_new ("http://schemas.google.com/g/2005#work", NULL, TRUE);
+ gdata_gd_postal_address_set_street (postal_address, "1600 Amphitheatre Pkwy Mountain View");
gdata_contacts_contact_add_postal_address (contact, postal_address);
g_object_unref (postal_address);
@@ -175,15 +176,16 @@ test_insert_simple (GDataService *service)
"<title type='text'>Elizabeth Bennet</title>"
"<content type='text'>Notes</content>"
"<category term='http://schemas.google.com/contact/2008#contact' scheme='http://schemas.google.com/g/2005#kind'/>"
+ "<gd:name><gd:fullName>Elizabeth Bennet</gd:fullName></gd:name>"
"<gd:email address='liz gmail com' rel='http://schemas.google.com/g/2005#work' primary='false'/>"
"<gd:email address='liz example org' rel='http://schemas.google.com/g/2005#home' primary='false'/>"
"<gd:im address='liz gmail com' protocol='http://schemas.google.com/g/2005#GOOGLE_TALK' "
"rel='http://schemas.google.com/g/2005#home' primary='false'/>"
"<gd:phoneNumber rel='http://schemas.google.com/g/2005#work' primary='true'>(206)555-1212</gd:phoneNumber>"
"<gd:phoneNumber rel='http://schemas.google.com/g/2005#home' primary='false'>(206)555-1213</gd:phoneNumber>"
- "<gd:postalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>"
- "1600 Amphitheatre Pkwy Mountain View"
- "</gd:postalAddress>"
+ "<gd:structuredPostalAddress rel='http://schemas.google.com/g/2005#work' primary='true'>"
+ "<gd:street>1600 Amphitheatre Pkwy Mountain View</gd:street>"
+ "</gd:structuredPostalAddress>"
"<gd:extendedProperty name='CALURI'>http://example.com/</gd:extendedProperty>"
"</entry>");
g_free (xml);
@@ -410,11 +412,11 @@ main (int argc, char *argv[])
gdata_service_authenticate (service, USERNAME, PASSWORD, NULL, NULL);
g_test_add_data_func ("/contacts/authentication", service, test_authentication);
+ if (g_test_slow () == TRUE)
+ g_test_add_data_func ("/contacts/insert/simple", service, test_insert_simple);
g_test_add_data_func ("/contacts/query/all_contacts", service, test_query_all_contacts);
if (g_test_thorough () == TRUE)
g_test_add_data_func ("/contacts/query/all_contacts_async", service, test_query_all_contacts_async);
- if (g_test_slow () == TRUE)
- g_test_add_data_func ("/contacts/insert/simple", service, test_insert_simple);
g_test_add_data_func ("/contacts/query/uri", service, test_query_uri);
g_test_add_data_func ("/contacts/parser/minimal", service, test_parser_minimal);
g_test_add_data_func ("/contacts/photo/has_photo", service, test_photo_has_photo);
diff --git a/gdata/tests/general.c b/gdata/tests/general.c
index a0787f9..18afe20 100644
--- a/gdata/tests/general.c
+++ b/gdata/tests/general.c
@@ -390,7 +390,7 @@ test_atom_category (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
g_assert_cmpstr (xml, ==,
"<category xmlns='http://www.w3.org/2005/Atom' "
- "term='jokes' scheme='http://foobar.com#categories' label='Jokes & Trivia'/>");
+ "term='jokes' scheme='http://foobar.com#categories' label='Jokes & Trivia'/>");
g_free (xml);
g_object_unref (category);
@@ -421,8 +421,8 @@ test_atom_category (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (category));
g_assert_cmpstr (xml, ==,
"<category xmlns='http://www.w3.org/2005/Atom' term='documentary'>"
- "<foobar/>"
- "<shizzle/>"
+ "<foobar/>"
+ "<shizzle/>"
"</category>");
g_free (xml);
g_object_unref (category);
@@ -500,7 +500,7 @@ test_atom_link (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (link));
g_assert_cmpstr (xml, ==,
"<link xmlns='http://www.w3.org/2005/Atom' href='http://example.com/' title='All About Angle Brackets: <, >' "
- "rel='http://test.com#link-type' type='text/plain' hreflang='de' length='2000'/>");
+ "rel='http://test.com#link-type' type='text/plain' hreflang='de' length='2000'/>");
g_free (xml);
g_object_unref (link);
@@ -523,7 +523,7 @@ test_atom_link (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (link));
g_assert_cmpstr (xml, ==,
"<link xmlns='http://www.w3.org/2005/Atom' href='http://shizzle.com' rel='http://www.iana.org/assignments/relation/alternate'>"
- "Test Content<foobar/></link>");
+ "Test Content<foobar/></link>");
g_free (xml);
g_object_unref (link);
}
@@ -561,7 +561,7 @@ test_gd_email_address (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (email));
g_assert_cmpstr (xml, ==,
"<gd:email xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' address='fubar gmail com' "
- "rel='http://schemas.google.com/g/2005#home' label='Personal & Private' primary='true'/>");
+ "rel='http://schemas.google.com/g/2005#home' label='Personal & Private' primary='true'/>");
g_free (xml);
g_object_unref (email);
@@ -582,7 +582,7 @@ test_gd_email_address (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (email));
g_assert_cmpstr (xml, ==,
"<gd:email xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' address='test example com' "
- "primary='false'/>");
+ "primary='false'/>");
g_free (xml);
g_object_unref (email);
}
@@ -621,7 +621,7 @@ test_gd_im_address (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (im));
g_assert_cmpstr (xml, ==,
"<gd:im xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
- "address='foo bar msn com' protocol='http://schemas.google.com/g/2005#MSN' "
+ "address='foo bar msn com' protocol='http://schemas.google.com/g/2005#MSN' "
"rel='http://schemas.google.com/g/2005#home' primary='true'/>");
g_free (xml);
g_object_unref (im);
@@ -644,12 +644,91 @@ test_gd_im_address (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (im));
g_assert_cmpstr (xml, ==,
"<gd:im xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' address='foo baz example com' "
- "label='Other & Miscellaneous' primary='false'/>");
+ "label='Other & Miscellaneous' primary='false'/>");
g_free (xml);
g_object_unref (im);
}
static void
+test_gd_name (void)
+{
+ GDataGDName *name, *name2;
+ gchar *xml;
+ GError *error = NULL;
+
+ name = GDATA_GD_NAME (gdata_parsable_new_from_xml (GDATA_TYPE_GD_NAME,
+ "<gd:name xmlns:gd='http://schemas.google.com/g/2005'>"
+ "<gd:givenName>Brian</gd:givenName>"
+ "<gd:additionalName>Charles</gd:additionalName>"
+ "<gd:familyName>Blessed</gd:familyName>"
+ "<gd:namePrefix>Mr</gd:namePrefix>"
+ "<gd:nameSuffix>ABC</gd:nameSuffix>"
+ "<gd:fullName>Mr Brian Charles Blessed, ABC</gd:fullName>"
+ "</gd:name>", -1, &error));
+ g_assert_no_error (error);
+ g_assert (GDATA_IS_GD_NAME (name));
+ g_clear_error (&error);
+
+ /* Check the properties */
+ g_assert_cmpstr (gdata_gd_name_get_given_name (name), ==, "Brian");
+ g_assert_cmpstr (gdata_gd_name_get_additional_name (name), ==, "Charles");
+ g_assert_cmpstr (gdata_gd_name_get_family_name (name), ==, "Blessed");
+ g_assert_cmpstr (gdata_gd_name_get_prefix (name), ==, "Mr");
+ g_assert_cmpstr (gdata_gd_name_get_suffix (name), ==, "ABC");
+ g_assert_cmpstr (gdata_gd_name_get_full_name (name), ==, "Mr Brian Charles Blessed, ABC");
+
+ /* Compare it against another identical name */
+ name2 = gdata_gd_name_new ("Brian", "Blessed");
+ gdata_gd_name_set_additional_name (name2, "Charles");
+ gdata_gd_name_set_prefix (name2, "Mr");
+ gdata_gd_name_set_suffix (name2, "ABC");
+ g_assert_cmpint (gdata_gd_name_compare (name, name2), ==, 0);
+
+ /* â?¦and a different one */
+ gdata_gd_name_set_prefix (name2, "Mrs");
+ g_assert_cmpint (gdata_gd_name_compare (name, name2), !=, 0);
+ g_object_unref (name2);
+
+ /* Check the outputted XML is the same */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (name));
+ g_assert_cmpstr (xml, ==,
+ "<gd:name xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>"
+ "<gd:givenName>Brian</gd:givenName>"
+ "<gd:additionalName>Charles</gd:additionalName>"
+ "<gd:familyName>Blessed</gd:familyName>"
+ "<gd:namePrefix>Mr</gd:namePrefix>"
+ "<gd:nameSuffix>ABC</gd:nameSuffix>"
+ "<gd:fullName>Mr Brian Charles Blessed, ABC</gd:fullName>"
+ "</gd:name>");
+ g_free (xml);
+ g_object_unref (name);
+
+ /* Now parse an address with less information available */
+ name = GDATA_GD_NAME (gdata_parsable_new_from_xml (GDATA_TYPE_GD_NAME,
+ "<gd:name xmlns:gd='http://schemas.google.com/g/2005'><gd:givenName>Bob</gd:givenName></gd:name>", -1, &error));
+ g_assert_no_error (error);
+ g_assert (GDATA_IS_GD_NAME (name));
+ g_clear_error (&error);
+
+ /* Check the properties */
+ g_assert_cmpstr (gdata_gd_name_get_given_name (name), ==, "Bob");
+ g_assert (gdata_gd_name_get_additional_name (name) == NULL);
+ g_assert (gdata_gd_name_get_family_name (name) == NULL);
+ g_assert (gdata_gd_name_get_prefix (name) == NULL);
+ g_assert (gdata_gd_name_get_suffix (name) == NULL);
+ g_assert (gdata_gd_name_get_full_name (name) == NULL);
+
+ /* Check the outputted XML is still correct */
+ xml = gdata_parsable_get_xml (GDATA_PARSABLE (name));
+ g_assert_cmpstr (xml, ==,
+ "<gd:name xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005'>"
+ "<gd:givenName>Bob</gd:givenName>"
+ "</gd:name>");
+ g_free (xml);
+ g_object_unref (name);
+}
+
+static void
test_gd_organization (void)
{
GDataGDOrganization *org, *org2;
@@ -661,6 +740,9 @@ test_gd_organization (void)
"primary='true'>"
"<gd:orgName>Google, Inc.</gd:orgName>"
"<gd:orgTitle><Angle Bracketeer></gd:orgTitle>"
+ "<gd:orgDepartment>Finance</gd:orgDepartment>"
+ "<gd:orgJobDescription>Doing stuff.</gd:orgJobDescription>"
+ "<gd:orgSymbol>FOO</gd:orgSymbol>"
"</gd:organization>", -1, &error));
g_assert_no_error (error);
g_assert (GDATA_IS_GD_ORGANIZATION (org));
@@ -671,10 +753,14 @@ test_gd_organization (void)
g_assert_cmpstr (gdata_gd_organization_get_title (org), ==, "<Angle Bracketeer>");
g_assert_cmpstr (gdata_gd_organization_get_relation_type (org), ==, "http://schemas.google.com/g/2005#work");
g_assert_cmpstr (gdata_gd_organization_get_label (org), ==, "Work & Occupation");
+ g_assert_cmpstr (gdata_gd_organization_get_department (org), ==, "Finance");
+ g_assert_cmpstr (gdata_gd_organization_get_job_description (org), ==, "Doing stuff.");
+ g_assert_cmpstr (gdata_gd_organization_get_symbol (org), ==, "FOO");
g_assert (gdata_gd_organization_is_primary (org) == TRUE);
/* Compare it against another identical organization */
org2 = gdata_gd_organization_new ("Google, Inc.", "<Angle Bracketeer>", "http://schemas.google.com/g/2005#work", "Work & Occupation", TRUE);
+ gdata_gd_organization_set_department (org2, "Finance");
g_assert_cmpint (gdata_gd_organization_compare (org, org2), ==, 0);
/* â?¦and a different one */
@@ -686,9 +772,12 @@ test_gd_organization (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (org));
g_assert_cmpstr (xml, ==,
"<gd:organization xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
- "rel='http://schemas.google.com/g/2005#work' label='Work & Occupation' primary='true'>"
+ "rel='http://schemas.google.com/g/2005#work' label='Work & Occupation' primary='true'>"
"<gd:orgName>Google, Inc.</gd:orgName>"
"<gd:orgTitle><Angle Bracketeer></gd:orgTitle>"
+ "<gd:orgDepartment>Finance</gd:orgDepartment>"
+ "<gd:orgJobDescription>Doing stuff.</gd:orgJobDescription>"
+ "<gd:orgSymbol>FOO</gd:orgSymbol>"
"</gd:organization>");
g_free (xml);
g_object_unref (org);
@@ -706,6 +795,9 @@ test_gd_organization (void)
g_assert (gdata_gd_organization_get_relation_type (org) == NULL);
g_assert (gdata_gd_organization_get_label (org) == NULL);
g_assert (gdata_gd_organization_is_primary (org) == FALSE);
+ g_assert (gdata_gd_organization_get_department (org) == NULL);
+ g_assert (gdata_gd_organization_get_job_description (org) == NULL);
+ g_assert (gdata_gd_organization_get_symbol (org) == NULL);
/* Check the outputted XML contains the unknown XML */
xml = gdata_parsable_get_xml (GDATA_PARSABLE (org));
@@ -750,8 +842,8 @@ test_gd_phone_number (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (phone));
g_assert_cmpstr (xml, ==,
"<gd:phoneNumber xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
- "uri='tel:+12065551212' rel='http://schemas.google.com/g/2005#mobile' label='Personal & business calls only' "
- "primary='false'>+1 206 555 1212</gd:phoneNumber>");
+ "uri='tel:+12065551212' rel='http://schemas.google.com/g/2005#mobile' label='Personal & business calls only' "
+ "primary='false'>+1 206 555 1212</gd:phoneNumber>");
g_free (xml);
g_object_unref (phone);
@@ -773,7 +865,7 @@ test_gd_phone_number (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (phone));
g_assert_cmpstr (xml, ==,
"<gd:phoneNumber xmlns='http://www.w3.org/2005/Atom' "
- "xmlns:gd='http://schemas.google.com/g/2005' primary='false'>(425) 555-8080 ext. 72585</gd:phoneNumber>");
+ "xmlns:gd='http://schemas.google.com/g/2005' primary='false'>(425) 555-8080 ext. 72585</gd:phoneNumber>");
g_free (xml);
g_object_unref (phone);
}
@@ -786,49 +878,58 @@ test_gd_postal_address (void)
GError *error = NULL;
postal = GDATA_GD_POSTAL_ADDRESS (gdata_parsable_new_from_xml (GDATA_TYPE_GD_POSTAL_ADDRESS,
- "<gd:postalAddress xmlns:gd='http://schemas.google.com/g/2005' label='Home & Safe House' "
+ "<gd:structuredPostalAddress xmlns:gd='http://schemas.google.com/g/2005' label='Home & Safe House' "
"rel='http://schemas.google.com/g/2005#home' primary='true'>"
- " \t 500 West 45th Street\nNew York, NY 10036 \n "
- "</gd:postalAddress>", -1, &error));
+ "<gd:street>500 West 45th Street</gd:street>"
+ "<gd:city>New York</gd:city>"
+ "<gd:postcode>NY 10036</gd:postcode>"
+ "</gd:structuredPostalAddress>", -1, &error));
g_assert_no_error (error);
g_assert (GDATA_IS_GD_POSTAL_ADDRESS (postal));
g_clear_error (&error);
/* Check the properties */
- g_assert_cmpstr (gdata_gd_postal_address_get_address (postal), ==, "500 West 45th Street\nNew York, NY 10036");
+ g_assert_cmpstr (gdata_gd_postal_address_get_street (postal), ==, "500 West 45th Street");
+ g_assert_cmpstr (gdata_gd_postal_address_get_city (postal), ==, "New York");
+ g_assert_cmpstr (gdata_gd_postal_address_get_postcode (postal), ==, "NY 10036");
g_assert_cmpstr (gdata_gd_postal_address_get_relation_type (postal), ==, "http://schemas.google.com/g/2005#home");
g_assert_cmpstr (gdata_gd_postal_address_get_label (postal), ==, "Home & Safe House");
g_assert (gdata_gd_postal_address_is_primary (postal) == TRUE);
/* Compare it against another identical address */
- postal2 = gdata_gd_postal_address_new ("500 West 45th Street\nNew York, NY 10036", "http://schemas.google.com/g/2005#home",
- "Home & Safe House", TRUE);
+ postal2 = gdata_gd_postal_address_new ("http://schemas.google.com/g/2005#home", "Home & Safe House", TRUE);
+ gdata_gd_postal_address_set_street (postal2, "500 West 45th Street");
+ gdata_gd_postal_address_set_city (postal2, "New York");
+ gdata_gd_postal_address_set_postcode (postal2, "NY 10036");
g_assert_cmpint (gdata_gd_postal_address_compare (postal, postal2), ==, 0);
/* â?¦and a different one */
- gdata_gd_postal_address_set_address (postal2, "Atlas Mountains");
+ gdata_gd_postal_address_set_city (postal2, "Atlas Mountains");
g_assert_cmpint (gdata_gd_postal_address_compare (postal, postal2), !=, 0);
g_object_unref (postal2);
/* Check the outputted XML is the same */
xml = gdata_parsable_get_xml (GDATA_PARSABLE (postal));
g_assert_cmpstr (xml, ==,
- "<gd:postalAddress xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
- "rel='http://schemas.google.com/g/2005#home' label='Home & Safe House' primary='true'>"
- "500 West 45th Street\nNew York, NY 10036"
- "</gd:postalAddress>");
+ "<gd:structuredPostalAddress xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
+ "rel='http://schemas.google.com/g/2005#home' label='Home & Safe House' primary='true'>"
+ "<gd:street>500 West 45th Street</gd:street>"
+ "<gd:city>New York</gd:city>"
+ "<gd:postcode>NY 10036</gd:postcode>"
+ "</gd:structuredPostalAddress>");
g_free (xml);
g_object_unref (postal);
/* Now parse an address with less information available */
postal = GDATA_GD_POSTAL_ADDRESS (gdata_parsable_new_from_xml (GDATA_TYPE_GD_POSTAL_ADDRESS,
- "<gd:postalAddress xmlns:gd='http://schemas.google.com/g/2005'>f</gd:postalAddress>", -1, &error));
+ "<gd:structuredPostalAddress xmlns:gd='http://schemas.google.com/g/2005'><gd:street>f</gd:street></gd:structuredPostalAddress>",
+ -1, &error));
g_assert_no_error (error);
g_assert (GDATA_IS_GD_POSTAL_ADDRESS (postal));
g_clear_error (&error);
/* Check the properties */
- g_assert_cmpstr (gdata_gd_postal_address_get_address (postal), ==, "f");
+ g_assert_cmpstr (gdata_gd_postal_address_get_street (postal), ==, "f");
g_assert (gdata_gd_postal_address_get_relation_type (postal) == NULL);
g_assert (gdata_gd_postal_address_get_label (postal) == NULL);
g_assert (gdata_gd_postal_address_is_primary (postal) == FALSE);
@@ -836,8 +937,8 @@ test_gd_postal_address (void)
/* Check the outputted XML contains the unknown XML */
xml = gdata_parsable_get_xml (GDATA_PARSABLE (postal));
g_assert_cmpstr (xml, ==,
- "<gd:postalAddress xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' primary='false'>"
- "f</gd:postalAddress>");
+ "<gd:structuredPostalAddress xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' primary='false'>"
+ "<gd:street>f</gd:street></gd:structuredPostalAddress>");
g_free (xml);
g_object_unref (postal);
}
@@ -922,7 +1023,7 @@ test_gd_reminder (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (reminder));
g_assert_cmpstr (xml, ==,
"<gd:reminder xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
- "absoluteTime='2005-06-07T00:55:00Z' method='alert'/>");
+ "absoluteTime='2005-06-07T00:55:00Z' method='alert'/>");
g_free (xml);
g_object_unref (reminder);
}
@@ -968,7 +1069,7 @@ test_gd_when (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (when));
g_assert_cmpstr (xml, ==,
"<gd:when xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' startTime='2005-06-07T01:00:00Z' "
- "endTime='2005-06-07T02:00:00Z'/>");
+ "endTime='2005-06-07T02:00:00Z'/>");
g_free (xml);
g_object_unref (when);
@@ -1003,7 +1104,7 @@ test_gd_when (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (when));
g_assert_cmpstr (xml, ==,
"<gd:when xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' startTime='2005-06-06' "
- "endTime='2005-06-08' valueString='This weekend'>"
+ "endTime='2005-06-08' valueString='This weekend'>"
"<gd:reminder minutes='15'/>"
"<foobar/>"
"</gd:when>");
@@ -1043,8 +1144,8 @@ test_gd_where (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (where));
g_assert_cmpstr (xml, ==,
"<gd:where xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
- "label='New York Location <videoconference>' rel='http://schemas.google.com/g/2005#event.alternate' "
- "valueString='Metropolis'/>");
+ "label='New York Location <videoconference>' rel='http://schemas.google.com/g/2005#event.alternate' "
+ "valueString='Metropolis'/>");
g_free (xml);
g_object_unref (where);
@@ -1064,7 +1165,7 @@ test_gd_where (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (where));
g_assert_cmpstr (xml, ==,
"<gd:where xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' "
- "valueString='Google Cafeteria <Building 40>'/>");
+ "valueString='Google Cafeteria <Building 40>'/>");
g_free (xml);
g_object_unref (where);
}
@@ -1101,7 +1202,7 @@ test_gd_who (void)
xml = gdata_parsable_get_xml (GDATA_PARSABLE (who));
g_assert_cmpstr (xml, ==,
"<gd:who xmlns='http://www.w3.org/2005/Atom' xmlns:gd='http://schemas.google.com/g/2005' email='liz example com' "
- "rel='http://schemas.google.com/g/2005#message.to' valueString='Elizabeth'/>");
+ "rel='http://schemas.google.com/g/2005#message.to' valueString='Elizabeth'/>");
g_free (xml);
g_object_unref (who);
@@ -1145,6 +1246,7 @@ main (int argc, char *argv[])
g_test_add_func ("/gd/email_address", test_gd_email_address);
g_test_add_func ("/gd/im_address", test_gd_im_address);
+ g_test_add_func ("/gd/name", test_gd_name);
g_test_add_func ("/gd/organization", test_gd_organization);
g_test_add_func ("/gd/phone_number", test_gd_phone_number);
g_test_add_func ("/gd/postal_address", test_gd_postal_address);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]