Blame gdata/services/contacts/gdata-contacts-contact.c

Packit 4b6dd7
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
Packit 4b6dd7
/*
Packit 4b6dd7
 * GData Client
Packit 4b6dd7
 * Copyright (C) Philip Withnall 2009, 2010, 2011 <philip@tecnocode.co.uk>
Packit 4b6dd7
 *
Packit 4b6dd7
 * GData Client is free software; you can redistribute it and/or
Packit 4b6dd7
 * modify it under the terms of the GNU Lesser General Public
Packit 4b6dd7
 * License as published by the Free Software Foundation; either
Packit 4b6dd7
 * version 2.1 of the License, or (at your option) any later version.
Packit 4b6dd7
 *
Packit 4b6dd7
 * GData Client is distributed in the hope that it will be useful,
Packit 4b6dd7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 4b6dd7
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 4b6dd7
 * Lesser General Public License for more details.
Packit 4b6dd7
 *
Packit 4b6dd7
 * You should have received a copy of the GNU Lesser General Public
Packit 4b6dd7
 * License along with GData Client.  If not, see <http://www.gnu.org/licenses/>.
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * SECTION:gdata-contacts-contact
Packit 4b6dd7
 * @short_description: GData Contacts contact object
Packit 4b6dd7
 * @stability: Stable
Packit 4b6dd7
 * @include: gdata/services/contacts/gdata-contacts-contact.h
Packit 4b6dd7
 *
Packit 4b6dd7
 * #GDataContactsContact is a subclass of #GDataEntry to represent a contact from a Google address book.
Packit 4b6dd7
 *
Packit 4b6dd7
 * For more details of Google Contacts' GData API, see the <ulink type="http" url="http://code.google.com/apis/contacts/docs/2.0/reference.html">
Packit 4b6dd7
 * online documentation</ulink>.
Packit 4b6dd7
 *
Packit 4b6dd7
 * In addition to all the standard properties available for a contact, #GDataContactsContact supports two kinds of additional property: extended
Packit 4b6dd7
 * properties and user-defined fields. Extended properties, set with gdata_contacts_contact_set_extended_property() and retrieved with
Packit 4b6dd7
 * gdata_contacts_contact_get_extended_property(), are provided as a method of storing client-specific data which shouldn't be seen  or be editable
Packit 4b6dd7
 * by the user, such as IDs and cache times. User-defined fields, set with gdata_contacts_contact_set_user_defined_field() and retrieved with
Packit 4b6dd7
 * gdata_contacts_contact_get_user_defined_field(), store fields defined by the user, and editable by them in the interface (both the interface of
Packit 4b6dd7
 * the appliation using libgdata, and the Google Contacts web interface).
Packit 4b6dd7
 *
Packit 4b6dd7
 * <example>
Packit 4b6dd7
 * 	<title>Getting a Contact's Photo</title>
Packit 4b6dd7
 * 	<programlisting>
Packit 4b6dd7
 *	GDataContactsService *service;
Packit 4b6dd7
 *	GDataContactsContact *contact;
Packit 4b6dd7
 *	guint8 *data;
Packit 4b6dd7
 *	gchar *content_type = NULL;
Packit 4b6dd7
 *	gsize length = 0;
Packit 4b6dd7
 *	GError *error = NULL;
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Create a service and return the contact whose photo we're getting. */
Packit 4b6dd7
 *	service = create_contacts_service ();
Packit 4b6dd7
 *	contact = query_user_for_contact (service);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Get the photo. This should almost always be done asynchronously. */
Packit 4b6dd7
 *	data = gdata_contacts_contact_get_photo (contact, service, &length, &content_type, NULL, &error);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	g_object_unref (contact);
Packit 4b6dd7
 *	g_object_unref (service);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	if (error != NULL) {
Packit 4b6dd7
 *		g_error ("Error getting a contact's photo: %s", error->message);
Packit 4b6dd7
 *		g_error_free (error);
Packit 4b6dd7
 *		return;
Packit 4b6dd7
 *	}
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Do something with the photo, stored in data, length and content_type. */
Packit 4b6dd7
 *
Packit 4b6dd7
 *	g_free (content_type);
Packit 4b6dd7
 *	g_free (data);
Packit 4b6dd7
 * 	</programlisting>
Packit 4b6dd7
 * </example>
Packit 4b6dd7
 *
Packit 4b6dd7
 * <example>
Packit 4b6dd7
 * 	<title>Setting a Contact's Photo</title>
Packit 4b6dd7
 * 	<programlisting>
Packit 4b6dd7
 *	GDataContactsService *service;
Packit 4b6dd7
 *	GDataContactsContact *contact;
Packit 4b6dd7
 *	guint8 *data;
Packit 4b6dd7
 *	gchar *content_type = NULL;
Packit 4b6dd7
 *	gsize length = 0;
Packit 4b6dd7
 *	GError *error = NULL;
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Create a service and return the contact whose photo we're getting, as well as the details of the new photo. */
Packit 4b6dd7
 *	service = create_contacts_service ();
Packit 4b6dd7
 *	contact = query_user_for_contact (service);
Packit 4b6dd7
 *	data = query_user_for_new_photo (contact, &content_type, &length);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Set the photo. This should almost always be done asynchronously. To delete the photo, just pass NULL as the photo data. */
Packit 4b6dd7
 *	gdata_contacts_contact_set_photo (contact, service, data, length, content_type, NULL, &error);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	g_free (data);
Packit 4b6dd7
 *	g_free (content_type);
Packit 4b6dd7
 *	g_object_unref (contact);
Packit 4b6dd7
 *	g_object_unref (service);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	if (error != NULL) {
Packit 4b6dd7
 *		g_error ("Error setting a contact's photo: %s", error->message);
Packit 4b6dd7
 *		g_error_free (error);
Packit 4b6dd7
 *		return;
Packit 4b6dd7
 *	}
Packit 4b6dd7
 * 	</programlisting>
Packit 4b6dd7
 * </example>
Packit 4b6dd7
 *
Packit 4b6dd7
 * <example>
Packit 4b6dd7
 * 	<title>Updating a Contact's Details</title>
Packit 4b6dd7
 * 	<programlisting>
Packit 4b6dd7
 *	GDataContactsService *service;
Packit 4b6dd7
 *	GDataContactsContact *contact, *updated_contact;
Packit 4b6dd7
 *	GDataGDEmailAddress *email_address;
Packit 4b6dd7
 *	GDataGDIMAddress *im_address;
Packit 4b6dd7
 *	GError *error = NULL;
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Create a service and return the contact whose details we're updating. */
Packit 4b6dd7
 *	service = create_contacts_service ();
Packit 4b6dd7
 *	contact = query_user_for_contact (service);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Update the contact's details. We set their nickname to "Fat Tony", add a new e-mail address, and replace all their existing IM
Packit 4b6dd7
 *	 * addresses with a single new one. */
Packit 4b6dd7
 *	gdata_contacts_contact_set_nickname (contact, "Fat Tony");
Packit 4b6dd7
 *
Packit 4b6dd7
 *	email_address = gdata_gd_email_address_new ("tony@gmail.com", GDATA_GD_EMAIL_ADDRESS_HOME, NULL, FALSE);
Packit 4b6dd7
 *	gdata_contacts_contact_add_email_address (contact, email_address);
Packit 4b6dd7
 *	g_object_unref (email_address);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	gdata_contacts_contact_remove_all_im_addresses (contact);
Packit 4b6dd7
 *	im_address = gdata_gd_im_address_new ("tony.work@gmail.com", GDATA_GD_IM_PROTOCOL_GOOGLE_TALK, GDATA_GD_IM_ADDRESS_WORK, NULL, TRUE);
Packit 4b6dd7
 *	gdata_contacts_contact_add_im_address (contact, im_address);
Packit 4b6dd7
 *	g_object_unref (im_address);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Send the updated contact to the server */
Packit 4b6dd7
 *	updated_contact = GDATA_CONTACTS_CONTACT (gdata_service_update_entry (GDATA_SERVICE (service), GDATA_ENTRY (contact), NULL, &error));
Packit 4b6dd7
 *
Packit 4b6dd7
 *	g_object_unref (contact);
Packit 4b6dd7
 *	g_object_unref (service);
Packit 4b6dd7
 *
Packit 4b6dd7
 *	if (error != NULL) {
Packit 4b6dd7
 *		g_error ("Error updating a contact's details: %s", error->message);
Packit 4b6dd7
 *		g_error_free (error);
Packit 4b6dd7
 *		return;
Packit 4b6dd7
 *	}
Packit 4b6dd7
 *
Packit 4b6dd7
 *	/* Do something with the updated contact, such as update them in the UI, or store their ID for future use. */
Packit 4b6dd7
 *
Packit 4b6dd7
 *	g_object_unref (updated_contact);
Packit 4b6dd7
 * 	</programlisting>
Packit 4b6dd7
 * </example>
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
Packit 4b6dd7
#include <config.h>
Packit 4b6dd7
#include <glib.h>
Packit 4b6dd7
#include <glib/gi18n-lib.h>
Packit 4b6dd7
#include <libxml/parser.h>
Packit 4b6dd7
#include <string.h>
Packit 4b6dd7
Packit 4b6dd7
#include "gdata-contacts-contact.h"
Packit 4b6dd7
#include "gdata-parser.h"
Packit 4b6dd7
#include "gdata-types.h"
Packit 4b6dd7
#include "gdata-private.h"
Packit 4b6dd7
#include "gdata-comparable.h"
Packit 4b6dd7
Packit 4b6dd7
/* The maximum number of extended properties the server allows us. See
Packit 4b6dd7
 * http://code.google.com/apis/contacts/docs/2.0/reference.html#ProjectionsAndExtended.
Packit 4b6dd7
 * When updating this, make sure to update the API documentation for gdata_contacts_contact_get_extended_property()
Packit 4b6dd7
 * and gdata_contacts_contact_set_extended_property(). */
Packit 4b6dd7
#define MAX_N_EXTENDED_PROPERTIES 10
Packit 4b6dd7
Packit 4b6dd7
static GObject *gdata_contacts_contact_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params);
Packit 4b6dd7
static void gdata_contacts_contact_dispose (GObject *object);
Packit 4b6dd7
static void gdata_contacts_contact_finalize (GObject *object);
Packit 4b6dd7
static void gdata_contacts_contact_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void gdata_contacts_contact_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);
Packit 4b6dd7
static void get_xml (GDataParsable *parsable, GString *xml_string);
Packit 4b6dd7
static gboolean parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error);
Packit 4b6dd7
static void get_namespaces (GDataParsable *parsable, GHashTable *namespaces);
Packit 4b6dd7
static gchar *get_entry_uri (const gchar *id) G_GNUC_WARN_UNUSED_RESULT;
Packit 4b6dd7
Packit 4b6dd7
struct _GDataContactsContactPrivate {
Packit 4b6dd7
	gint64 edited;
Packit 4b6dd7
	GDataGDName *name;
Packit 4b6dd7
	GList *email_addresses; /* GDataGDEmailAddress */
Packit 4b6dd7
	GList *im_addresses; /* GDataGDIMAddress */
Packit 4b6dd7
	GList *phone_numbers; /* GDataGDPhoneNumber */
Packit 4b6dd7
	GList *postal_addresses; /* GDataGDPostalAddress */
Packit 4b6dd7
	GList *organizations; /* GDataGDOrganization */
Packit 4b6dd7
	GHashTable *extended_properties;
Packit 4b6dd7
	GHashTable *user_defined_fields;
Packit 4b6dd7
	GHashTable *groups;
Packit 4b6dd7
	gboolean deleted;
Packit 4b6dd7
	gchar *photo_etag;
Packit 4b6dd7
	GList *jots; /* GDataGContactJot */
Packit 4b6dd7
	gchar *nickname;
Packit 4b6dd7
	gchar *file_as;
Packit 4b6dd7
	GDate birthday;
Packit 4b6dd7
	gboolean birthday_has_year; /* contacts can choose to just give the month and day of their birth */
Packit 4b6dd7
	GList *relations; /* GDataGContactRelation */
Packit 4b6dd7
	GList *websites; /* GDataGContactWebsite */
Packit 4b6dd7
	GList *events; /* GDataGContactEvent */
Packit 4b6dd7
	GList *calendars; /* GDataGContactCalendar */
Packit 4b6dd7
	GList *external_ids; /* GDataGContactExternalID */
Packit 4b6dd7
	gchar *billing_information;
Packit 4b6dd7
	gchar *directory_server;
Packit 4b6dd7
	gchar *gender;
Packit 4b6dd7
	gchar *initials;
Packit 4b6dd7
	gchar *maiden_name;
Packit 4b6dd7
	gchar *mileage;
Packit 4b6dd7
	gchar *occupation;
Packit 4b6dd7
	gchar *priority;
Packit 4b6dd7
	gchar *sensitivity;
Packit 4b6dd7
	gchar *short_name;
Packit 4b6dd7
	gchar *subject;
Packit 4b6dd7
	GList *hobbies; /* gchar* */
Packit 4b6dd7
	GList *languages; /* GDataGContactLanguage */
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
enum {
Packit 4b6dd7
	PROP_EDITED = 1,
Packit 4b6dd7
	PROP_DELETED,
Packit 4b6dd7
	PROP_NAME,
Packit 4b6dd7
	PROP_NICKNAME,
Packit 4b6dd7
	PROP_BIRTHDAY,
Packit 4b6dd7
	PROP_BIRTHDAY_HAS_YEAR,
Packit 4b6dd7
	PROP_BILLING_INFORMATION,
Packit 4b6dd7
	PROP_DIRECTORY_SERVER,
Packit 4b6dd7
	PROP_GENDER,
Packit 4b6dd7
	PROP_INITIALS,
Packit 4b6dd7
	PROP_MAIDEN_NAME,
Packit 4b6dd7
	PROP_MILEAGE,
Packit 4b6dd7
	PROP_OCCUPATION,
Packit 4b6dd7
	PROP_PRIORITY,
Packit 4b6dd7
	PROP_SENSITIVITY,
Packit 4b6dd7
	PROP_SHORT_NAME,
Packit 4b6dd7
	PROP_SUBJECT,
Packit 4b6dd7
	PROP_PHOTO_ETAG,
Packit 4b6dd7
	PROP_FILE_AS,
Packit 4b6dd7
};
Packit 4b6dd7
Packit 4b6dd7
G_DEFINE_TYPE (GDataContactsContact, gdata_contacts_contact, GDATA_TYPE_ENTRY)
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_contacts_contact_class_init (GDataContactsContactClass *klass)
Packit 4b6dd7
{
Packit 4b6dd7
	GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
Packit 4b6dd7
	GDataParsableClass *parsable_class = GDATA_PARSABLE_CLASS (klass);
Packit 4b6dd7
	GDataEntryClass *entry_class = GDATA_ENTRY_CLASS (klass);
Packit 4b6dd7
Packit 4b6dd7
	g_type_class_add_private (klass, sizeof (GDataContactsContactPrivate));
Packit 4b6dd7
Packit 4b6dd7
	gobject_class->constructor = gdata_contacts_contact_constructor;
Packit 4b6dd7
	gobject_class->get_property = gdata_contacts_contact_get_property;
Packit 4b6dd7
	gobject_class->set_property = gdata_contacts_contact_set_property;
Packit 4b6dd7
	gobject_class->dispose = gdata_contacts_contact_dispose;
Packit 4b6dd7
	gobject_class->finalize = gdata_contacts_contact_finalize;
Packit 4b6dd7
Packit 4b6dd7
	parsable_class->parse_xml = parse_xml;
Packit 4b6dd7
	parsable_class->get_xml = get_xml;
Packit 4b6dd7
	parsable_class->get_namespaces = get_namespaces;
Packit 4b6dd7
Packit 4b6dd7
	entry_class->get_entry_uri = get_entry_uri;
Packit 4b6dd7
	entry_class->kind_term = "http://schemas.google.com/contact/2008#contact";
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:edited:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The last time the contact was edited. If the contact has not been edited yet, the content indicates the time it was created.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * For more information, see the <ulink type="http" url="http://www.atomenabled.org/developers/protocol/#appEdited">
Packit 4b6dd7
	 * Atom Publishing Protocol specification</ulink>.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.2.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_EDITED,
Packit 4b6dd7
	                                 g_param_spec_int64 ("edited",
Packit 4b6dd7
	                                                     "Edited", "The last time the contact was edited.",
Packit 4b6dd7
	                                                     -1, G_MAXINT64, -1,
Packit 4b6dd7
	                                                     G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:deleted:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Whether the entry has been deleted.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.2.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_DELETED,
Packit 4b6dd7
	                                 g_param_spec_boolean ("deleted",
Packit 4b6dd7
	                                                       "Deleted", "Whether the entry has been deleted.",
Packit 4b6dd7
	                                                       FALSE,
Packit 4b6dd7
	                                                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:photo-etag:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The ETag of the contact's photo, if the contact has a photo; %NULL otherwise.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.9.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_PHOTO_ETAG,
Packit 4b6dd7
	                                 g_param_spec_string ("photo-etag",
Packit 4b6dd7
	                                                       "Photo ETag", "The ETag of the contact's photo.",
Packit 4b6dd7
	                                                       NULL,
Packit 4b6dd7
	                                                       G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:name:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The contact's name in a structured representation.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.5.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_NAME,
Packit 4b6dd7
	                                 g_param_spec_object ("name",
Packit 4b6dd7
	                                                      "Name", "The contact's name in a structured representation.",
Packit 4b6dd7
	                                                      GDATA_TYPE_GD_NAME,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:nickname:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The contact's chosen nickname.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_NICKNAME,
Packit 4b6dd7
	                                 g_param_spec_string ("nickname",
Packit 4b6dd7
	                                                      "Nickname", "The contact's chosen nickname.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:file-as:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The name to file the contact under for sorting purposes.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.11.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_FILE_AS,
Packit 4b6dd7
	                                 g_param_spec_string ("file-as",
Packit 4b6dd7
	                                                      "File As", "The name to file the contact under for sorting purposes.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:birthday:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The contact's birthday.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_BIRTHDAY,
Packit 4b6dd7
	                                 g_param_spec_boxed ("birthday",
Packit 4b6dd7
	                                                     "Birthday", "The contact's birthday.",
Packit 4b6dd7
	                                                     G_TYPE_DATE,
Packit 4b6dd7
	                                                     G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:birthday-has-year:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Whether the contact's birthday includes their year of birth.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_BIRTHDAY_HAS_YEAR,
Packit 4b6dd7
	                                 g_param_spec_boolean ("birthday-has-year",
Packit 4b6dd7
	                                                       "Birthday has year?", "Whether the contact's birthday includes their year of birth.",
Packit 4b6dd7
	                                                       FALSE,
Packit 4b6dd7
	                                                       G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:billing-information:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Billing information for the contact, such as their billing name and address.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_BILLING_INFORMATION,
Packit 4b6dd7
	                                 g_param_spec_string ("billing-information",
Packit 4b6dd7
	                                                      "Billing information", "Billing information for the contact.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:directory-server:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The name or address of a directory server associated with the contact.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_DIRECTORY_SERVER,
Packit 4b6dd7
	                                 g_param_spec_string ("directory-server",
Packit 4b6dd7
	                                                      "Directory server", "The name or address of an associated directory server.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:gender:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The gender of the contact. For example: %GDATA_CONTACTS_GENDER_MALE or %GDATA_CONTACTS_GENDER_FEMALE.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_GENDER,
Packit 4b6dd7
	                                 g_param_spec_string ("gender",
Packit 4b6dd7
	                                                      "Gender", "The gender of the contact.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:initials:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The initials of the contact.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_INITIALS,
Packit 4b6dd7
	                                 g_param_spec_string ("initials",
Packit 4b6dd7
	                                                      "Initials", "The initials of the contact.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:maiden-name:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The maiden name of the contact.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_MAIDEN_NAME,
Packit 4b6dd7
	                                 g_param_spec_string ("maiden-name",
Packit 4b6dd7
	                                                      "Maiden name", "The maiden name of the contact.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:mileage:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A mileage associated with the contact, such as one for reimbursement purposes. It can be in any format.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_MILEAGE,
Packit 4b6dd7
	                                 g_param_spec_string ("mileage",
Packit 4b6dd7
	                                                      "Mileage", "A mileage associated with the contact.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:occupation:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The contact's occupation.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_OCCUPATION,
Packit 4b6dd7
	                                 g_param_spec_string ("occupation",
Packit 4b6dd7
	                                                      "Occupation", "The contact's occupation.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:priority:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The contact's importance. For example: %GDATA_CONTACTS_PRIORITY_NORMAL or %GDATA_CONTACTS_PRIORITY_HIGH.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_PRIORITY,
Packit 4b6dd7
	                                 g_param_spec_string ("priority",
Packit 4b6dd7
	                                                      "Priority", "The contact's importance.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:sensitivity:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The sensitivity of the contact's data. For example: %GDATA_CONTACTS_SENSITIVITY_NORMAL or %GDATA_CONTACTS_SENSITIVITY_PRIVATE.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_SENSITIVITY,
Packit 4b6dd7
	                                 g_param_spec_string ("sensitivity",
Packit 4b6dd7
	                                                      "Sensitivity", "The sensitivity of the contact's data.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:short-name:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * A short name for the contact. This should be used for contracted versions of the contact's actual name,
Packit 4b6dd7
	 * whereas #GDataContactsContact:nickname should be used for nicknames.
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_SHORT_NAME,
Packit 4b6dd7
	                                 g_param_spec_string ("short-name",
Packit 4b6dd7
	                                                      "Short name", "A short name for the contact.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
Packit 4b6dd7
	/**
Packit 4b6dd7
	 * GDataContactsContact:subject:
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * The subject of the contact. (i.e. The contact's relevance to the address book.)
Packit 4b6dd7
	 *
Packit 4b6dd7
	 * Since: 0.7.0
Packit 4b6dd7
	 */
Packit 4b6dd7
	g_object_class_install_property (gobject_class, PROP_SUBJECT,
Packit 4b6dd7
	                                 g_param_spec_string ("subject",
Packit 4b6dd7
	                                                      "Subject", "The subject of the contact.",
Packit 4b6dd7
	                                                      NULL,
Packit 4b6dd7
	                                                      G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void notify_full_name_cb (GObject *gobject, GParamSpec *pspec, GDataContactsContact *self);
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
notify_title_cb (GObject *gobject, GParamSpec *pspec, GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	/* Update GDataGDName:full-name */
Packit 4b6dd7
	g_signal_handlers_block_by_func (self->priv->name, notify_full_name_cb, self);
Packit 4b6dd7
	gdata_gd_name_set_full_name (self->priv->name, gdata_entry_get_title (GDATA_ENTRY (self)));
Packit 4b6dd7
	g_signal_handlers_unblock_by_func (self->priv->name, notify_full_name_cb, self);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
notify_full_name_cb (GObject *gobject, GParamSpec *pspec, GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	/* Update GDataEntry:title */
Packit 4b6dd7
	g_signal_handlers_block_by_func (self, notify_title_cb, self);
Packit 4b6dd7
	gdata_entry_set_title (GDATA_ENTRY (self), gdata_gd_name_get_full_name (self->priv->name));
Packit 4b6dd7
	g_signal_handlers_unblock_by_func (self, notify_title_cb, self);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_contacts_contact_init (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GDATA_TYPE_CONTACTS_CONTACT, GDataContactsContactPrivate);
Packit 4b6dd7
	self->priv->extended_properties = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
Packit 4b6dd7
	self->priv->user_defined_fields = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
Packit 4b6dd7
	self->priv->groups = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
Packit 4b6dd7
	self->priv->edited = -1;
Packit 4b6dd7
Packit 4b6dd7
	/* Create a default name, so the name's properties can be set for a blank contact */
Packit 4b6dd7
	self->priv->name = gdata_gd_name_new (NULL, NULL);
Packit 4b6dd7
Packit 4b6dd7
	/* Listen to change notifications for the entry's title, since it's linked to GDataGDName:full-name */
Packit 4b6dd7
	g_signal_connect (self, "notify::title", (GCallback) notify_title_cb, self);
Packit 4b6dd7
	g_signal_connect (self->priv->name, "notify::full-name", (GCallback) notify_full_name_cb, self);
Packit 4b6dd7
Packit 4b6dd7
	/* Initialise the contact's birthday to a sane but invalid date */
Packit 4b6dd7
	g_date_clear (&(self->priv->birthday), 1);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static GObject *
Packit 4b6dd7
gdata_contacts_contact_constructor (GType type, guint n_construct_params, GObjectConstructParam *construct_params)
Packit 4b6dd7
{
Packit 4b6dd7
	GObject *object;
Packit 4b6dd7
	guint i;
Packit 4b6dd7
Packit 4b6dd7
	/* Find the "id" property and ensure it's sane */
Packit 4b6dd7
	for (i = 0; i < n_construct_params; i++) {
Packit 4b6dd7
		GParamSpec *pspec = construct_params[i].pspec;
Packit 4b6dd7
		GValue *value = construct_params[i].value;
Packit 4b6dd7
Packit 4b6dd7
		if (strcmp (g_param_spec_get_name (pspec), "id") == 0) {
Packit 4b6dd7
			gchar *base, *id;
Packit 4b6dd7
Packit 4b6dd7
			id = g_value_dup_string (value);
Packit 4b6dd7
Packit 4b6dd7
			/* Fix the ID to refer to the full projection, rather than the base projection. */
Packit 4b6dd7
			if (id != NULL) {
Packit 4b6dd7
				base = strstr (id, "/base/");
Packit 4b6dd7
				if (base != NULL)
Packit 4b6dd7
					memcpy (base, "/full/", 6);
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			g_value_take_string (value, id);
Packit 4b6dd7
Packit 4b6dd7
			break;
Packit 4b6dd7
		}
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	object = G_OBJECT_CLASS (gdata_contacts_contact_parent_class)->constructor (type, n_construct_params, construct_params);
Packit 4b6dd7
Packit 4b6dd7
	if (_gdata_parsable_is_constructed_from_xml (GDATA_PARSABLE (object)) == FALSE) {
Packit 4b6dd7
		GDataContactsContactPrivate *priv = GDATA_CONTACTS_CONTACT (object)->priv;
Packit 4b6dd7
		GTimeVal time_val;
Packit 4b6dd7
Packit 4b6dd7
		/* Set the edited property to the current time (creation time). We don't do this in *_init() since that would cause
Packit 4b6dd7
		 * setting it from parse_xml() to fail (duplicate element). */
Packit 4b6dd7
		g_get_current_time (&time_val);
Packit 4b6dd7
		priv->edited = time_val.tv_sec;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return object;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_contacts_contact_dispose (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContact *self = GDATA_CONTACTS_CONTACT (object);
Packit 4b6dd7
Packit 4b6dd7
	if (self->priv->name != NULL)
Packit 4b6dd7
		g_object_unref (self->priv->name);
Packit 4b6dd7
	self->priv->name = NULL;
Packit 4b6dd7
Packit 4b6dd7
	gdata_contacts_contact_remove_all_organizations (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_email_addresses (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_im_addresses (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_postal_addresses (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_phone_numbers (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_jots (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_relations (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_websites (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_events (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_calendars (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_external_ids (self);
Packit 4b6dd7
	gdata_contacts_contact_remove_all_languages (self);
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	G_OBJECT_CLASS (gdata_contacts_contact_parent_class)->dispose (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_contacts_contact_finalize (GObject *object)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = GDATA_CONTACTS_CONTACT (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_hash_table_destroy (priv->extended_properties);
Packit 4b6dd7
	g_hash_table_destroy (priv->user_defined_fields);
Packit 4b6dd7
	g_hash_table_destroy (priv->groups);
Packit 4b6dd7
	g_free (priv->photo_etag);
Packit 4b6dd7
	g_free (priv->nickname);
Packit 4b6dd7
	g_free (priv->file_as);
Packit 4b6dd7
	g_free (priv->billing_information);
Packit 4b6dd7
	g_free (priv->directory_server);
Packit 4b6dd7
	g_free (priv->gender);
Packit 4b6dd7
	g_free (priv->initials);
Packit 4b6dd7
	g_free (priv->maiden_name);
Packit 4b6dd7
	g_free (priv->mileage);
Packit 4b6dd7
	g_free (priv->occupation);
Packit 4b6dd7
	g_free (priv->priority);
Packit 4b6dd7
	g_free (priv->sensitivity);
Packit 4b6dd7
	g_free (priv->short_name);
Packit 4b6dd7
	g_free (priv->subject);
Packit 4b6dd7
Packit 4b6dd7
	if (priv->hobbies != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->hobbies, (GFunc) g_free, NULL);
Packit 4b6dd7
		g_list_free (priv->hobbies);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	G_OBJECT_CLASS (gdata_contacts_contact_parent_class)->finalize (object);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_contacts_contact_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = GDATA_CONTACTS_CONTACT (object)->priv;
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_EDITED:
Packit 4b6dd7
			g_value_set_int64 (value, priv->edited);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_DELETED:
Packit 4b6dd7
			g_value_set_boolean (value, priv->deleted);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_PHOTO_ETAG:
Packit 4b6dd7
			g_value_set_string (value, priv->photo_etag);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_NAME:
Packit 4b6dd7
			g_value_set_object (value, priv->name);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_NICKNAME:
Packit 4b6dd7
			g_value_set_string (value, priv->nickname);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_FILE_AS:
Packit 4b6dd7
			g_value_set_string (value, priv->file_as);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_BIRTHDAY:
Packit 4b6dd7
			g_value_set_boxed (value, &(priv->birthday));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_BIRTHDAY_HAS_YEAR:
Packit 4b6dd7
			g_value_set_boolean (value, priv->birthday_has_year);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_BILLING_INFORMATION:
Packit 4b6dd7
			g_value_set_string (value, priv->billing_information);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_DIRECTORY_SERVER:
Packit 4b6dd7
			g_value_set_string (value, priv->directory_server);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_GENDER:
Packit 4b6dd7
			g_value_set_string (value, priv->gender);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_INITIALS:
Packit 4b6dd7
			g_value_set_string (value, priv->initials);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_MAIDEN_NAME:
Packit 4b6dd7
			g_value_set_string (value, priv->maiden_name);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_MILEAGE:
Packit 4b6dd7
			g_value_set_string (value, priv->mileage);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_OCCUPATION:
Packit 4b6dd7
			g_value_set_string (value, priv->occupation);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_PRIORITY:
Packit 4b6dd7
			g_value_set_string (value, priv->priority);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SENSITIVITY:
Packit 4b6dd7
			g_value_set_string (value, priv->sensitivity);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SHORT_NAME:
Packit 4b6dd7
			g_value_set_string (value, priv->short_name);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SUBJECT:
Packit 4b6dd7
			g_value_set_string (value, priv->subject);
Packit 4b6dd7
			break;
Packit 4b6dd7
		default:
Packit 4b6dd7
			/* We don't have any other property... */
Packit 4b6dd7
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
Packit 4b6dd7
			break;
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
gdata_contacts_contact_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContact *self = GDATA_CONTACTS_CONTACT (object);
Packit 4b6dd7
Packit 4b6dd7
	switch (property_id) {
Packit 4b6dd7
		case PROP_NAME:
Packit 4b6dd7
			gdata_contacts_contact_set_name (self, g_value_get_object (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_NICKNAME:
Packit 4b6dd7
			gdata_contacts_contact_set_nickname (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_FILE_AS:
Packit 4b6dd7
			gdata_contacts_contact_set_file_as (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_BIRTHDAY:
Packit 4b6dd7
			gdata_contacts_contact_set_birthday (self, g_value_get_boxed (value), self->priv->birthday_has_year);
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_BIRTHDAY_HAS_YEAR:
Packit 4b6dd7
			gdata_contacts_contact_set_birthday (self, &(self->priv->birthday), g_value_get_boolean (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_BILLING_INFORMATION:
Packit 4b6dd7
			gdata_contacts_contact_set_billing_information (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_DIRECTORY_SERVER:
Packit 4b6dd7
			gdata_contacts_contact_set_directory_server (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_GENDER:
Packit 4b6dd7
			gdata_contacts_contact_set_gender (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_INITIALS:
Packit 4b6dd7
			gdata_contacts_contact_set_initials (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_MAIDEN_NAME:
Packit 4b6dd7
			gdata_contacts_contact_set_maiden_name (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_MILEAGE:
Packit 4b6dd7
			gdata_contacts_contact_set_mileage (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_OCCUPATION:
Packit 4b6dd7
			gdata_contacts_contact_set_occupation (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_PRIORITY:
Packit 4b6dd7
			gdata_contacts_contact_set_priority (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SENSITIVITY:
Packit 4b6dd7
			gdata_contacts_contact_set_sensitivity (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SHORT_NAME:
Packit 4b6dd7
			gdata_contacts_contact_set_short_name (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		case PROP_SUBJECT:
Packit 4b6dd7
			gdata_contacts_contact_set_subject (self, g_value_get_string (value));
Packit 4b6dd7
			break;
Packit 4b6dd7
		default:
Packit 4b6dd7
			/* We don't have any other property... */
Packit 4b6dd7
			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
Packit 4b6dd7
			break;
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gboolean
Packit 4b6dd7
parse_xml (GDataParsable *parsable, xmlDoc *doc, xmlNode *node, gpointer user_data, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	gboolean success;
Packit 4b6dd7
	GDataContactsContact *self = GDATA_CONTACTS_CONTACT (parsable);
Packit 4b6dd7
Packit 4b6dd7
	if (gdata_parser_is_namespace (node, "http://www.w3.org/2007/app") == TRUE &&
Packit 4b6dd7
	    gdata_parser_int64_time_from_element (node, "edited", P_REQUIRED | P_NO_DUPES, &(self->priv->edited), &success, error) == TRUE) {
Packit 4b6dd7
		return success;
Packit 4b6dd7
	} else if (gdata_parser_is_namespace (node, "http://www.w3.org/2005/Atom") == TRUE && xmlStrcmp (node->name, (xmlChar*) "id") == 0) {
Packit 4b6dd7
		/* We have to override <id> parsing to fix the projection. Modify it in-place so that the parser in GDataEntry will pick up
Packit 4b6dd7
		 * the changes. This fixes bugs caused by referring to contacts by the base projection, rather than the full projection;
Packit 4b6dd7
		 * such as http://code.google.com/p/gdata-issues/issues/detail?id=2129. */
Packit 4b6dd7
		gchar *base;
Packit 4b6dd7
		gchar *id = (gchar*) xmlNodeListGetString (doc, node->children, TRUE);
Packit 4b6dd7
Packit 4b6dd7
		if (id != NULL) {
Packit 4b6dd7
			base = strstr (id, "/base/");
Packit 4b6dd7
			if (base != NULL) {
Packit 4b6dd7
				memcpy (base, "/full/", 6);
Packit 4b6dd7
				xmlNodeSetContent (node, (xmlChar*) id);
Packit 4b6dd7
			}
Packit 4b6dd7
		}
Packit 4b6dd7
Packit 4b6dd7
		xmlFree (id);
Packit 4b6dd7
Packit 4b6dd7
		return GDATA_PARSABLE_CLASS (gdata_contacts_contact_parent_class)->parse_xml (parsable, doc, node, user_data, error);
Packit 4b6dd7
	} else if (gdata_parser_is_namespace (node, "http://schemas.google.com/g/2005") == TRUE) {
Packit 4b6dd7
		if (gdata_parser_object_from_element_setter (node, "im", P_REQUIRED, GDATA_TYPE_GD_IM_ADDRESS,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_im_address, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "phoneNumber", P_REQUIRED, GDATA_TYPE_GD_PHONE_NUMBER,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_phone_number, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "structuredPostalAddress", P_REQUIRED, GDATA_TYPE_GD_POSTAL_ADDRESS,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_postal_address, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "organization", P_REQUIRED, GDATA_TYPE_GD_ORGANIZATION,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_organization, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element (node, "name", P_REQUIRED, GDATA_TYPE_GD_NAME, &(self->priv->name), &success, error) == TRUE) {
Packit 4b6dd7
			return success;
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "email") == 0) {
Packit 4b6dd7
			/* gd:email */
Packit 4b6dd7
			GDataParsable *_parsable;
Packit 4b6dd7
			xmlChar *address;
Packit 4b6dd7
Packit 4b6dd7
			/* Check its address attribute is non-empty. Empty address attributes are apparently allowed, and make the
Packit 4b6dd7
			 * gd:email element a no-op. See: https://bugzilla.gnome.org/show_bug.cgi?id=734863 */
Packit 4b6dd7
			address = xmlGetProp (node, (xmlChar *) "address");
Packit 4b6dd7
			if (address == NULL) {
Packit 4b6dd7
				return gdata_parser_error_required_property_missing (node, "address", error);
Packit 4b6dd7
			} else if (*address == '\0') {
Packit 4b6dd7
				xmlFree (address);
Packit 4b6dd7
				success = TRUE;
Packit 4b6dd7
				return TRUE;
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			xmlFree (address);
Packit 4b6dd7
Packit 4b6dd7
			/* Parse the e-mail address. */
Packit 4b6dd7
			_parsable = _gdata_parsable_new_from_xml_node (GDATA_TYPE_GD_EMAIL_ADDRESS, node->doc, node, NULL, error);
Packit 4b6dd7
			if (_parsable == NULL) {
Packit 4b6dd7
				/* The error has already been set by _gdata_parsable_new_from_xml_node() */
Packit 4b6dd7
				success = FALSE;
Packit 4b6dd7
				return TRUE;
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			/* Success! */
Packit 4b6dd7
			gdata_contacts_contact_add_email_address (self, GDATA_GD_EMAIL_ADDRESS (_parsable));
Packit 4b6dd7
			g_object_unref (_parsable);
Packit 4b6dd7
			success = TRUE;
Packit 4b6dd7
Packit 4b6dd7
			return TRUE;
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "extendedProperty") == 0) {
Packit 4b6dd7
			/* gd:extendedProperty */
Packit 4b6dd7
			xmlChar *name, *value;
Packit 4b6dd7
			xmlBuffer *buffer = NULL;
Packit 4b6dd7
Packit 4b6dd7
			name = xmlGetProp (node, (xmlChar*) "name");
Packit 4b6dd7
			if (name == NULL)
Packit 4b6dd7
				return gdata_parser_error_required_property_missing (node, "name", error);
Packit 4b6dd7
Packit 4b6dd7
			/* Get either the value property, or the element's content */
Packit 4b6dd7
			value = xmlGetProp (node, (xmlChar*) "value");
Packit 4b6dd7
			if (value == NULL) {
Packit 4b6dd7
				xmlNode *child_node;
Packit 4b6dd7
Packit 4b6dd7
				/* Use the element's content instead (arbitrary XML) */
Packit 4b6dd7
				buffer = xmlBufferCreate ();
Packit 4b6dd7
				for (child_node = node->children; child_node != NULL; child_node = child_node->next)
Packit 4b6dd7
					xmlNodeDump (buffer, doc, child_node, 0, 0);
Packit 4b6dd7
				value = (xmlChar*) xmlBufferContent (buffer);
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			gdata_contacts_contact_set_extended_property (self, (gchar*) name, (gchar*) value);
Packit 4b6dd7
Packit 4b6dd7
			xmlFree (name);
Packit 4b6dd7
			if (buffer != NULL)
Packit 4b6dd7
				xmlBufferFree (buffer);
Packit 4b6dd7
			else
Packit 4b6dd7
				xmlFree (value);
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "deleted") == 0) {
Packit 4b6dd7
			/* gd:deleted */
Packit 4b6dd7
			self->priv->deleted = TRUE;
Packit 4b6dd7
		} else {
Packit 4b6dd7
			return GDATA_PARSABLE_CLASS (gdata_contacts_contact_parent_class)->parse_xml (parsable, doc, node, user_data, error);
Packit 4b6dd7
		}
Packit 4b6dd7
	} else if (gdata_parser_is_namespace (node, "http://schemas.google.com/contact/2008") == TRUE) {
Packit 4b6dd7
		if (gdata_parser_object_from_element_setter (node, "jot", P_REQUIRED, GDATA_TYPE_GCONTACT_JOT,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_jot, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "relation", P_REQUIRED, GDATA_TYPE_GCONTACT_RELATION,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_relation, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "event", P_REQUIRED, GDATA_TYPE_GCONTACT_EVENT,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_event, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "website", P_REQUIRED, GDATA_TYPE_GCONTACT_WEBSITE,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_website, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "calendarLink", P_REQUIRED, GDATA_TYPE_GCONTACT_CALENDAR,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_calendar, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "externalId", P_REQUIRED, GDATA_TYPE_GCONTACT_EXTERNAL_ID,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_external_id, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_object_from_element_setter (node, "language", P_REQUIRED, GDATA_TYPE_GCONTACT_LANGUAGE,
Packit 4b6dd7
		                                             gdata_contacts_contact_add_language, self, &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "nickname", P_REQUIRED | P_NO_DUPES, &(self->priv->nickname), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "fileAs", P_REQUIRED | P_NO_DUPES, &(self->priv->file_as), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "billingInformation", P_REQUIRED | P_NO_DUPES | P_NON_EMPTY,
Packit 4b6dd7
		                                      &(self->priv->billing_information), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "directoryServer", P_REQUIRED | P_NO_DUPES | P_NON_EMPTY,
Packit 4b6dd7
		                                      &(self->priv->directory_server), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "initials", P_REQUIRED | P_NO_DUPES, &(self->priv->initials), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "maidenName", P_REQUIRED | P_NO_DUPES,
Packit 4b6dd7
		                                      &(self->priv->maiden_name), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "mileage", P_REQUIRED | P_NO_DUPES, &(self->priv->mileage), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "occupation", P_REQUIRED | P_NO_DUPES,
Packit 4b6dd7
		                                      &(self->priv->occupation), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "shortName", P_REQUIRED | P_NO_DUPES,
Packit 4b6dd7
		                                      &(self->priv->short_name), &success, error) == TRUE ||
Packit 4b6dd7
		    gdata_parser_string_from_element (node, "subject", P_REQUIRED | P_NO_DUPES, &(self->priv->subject), &success, error) == TRUE) {
Packit 4b6dd7
			return success;
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "gender") == 0) {
Packit 4b6dd7
			/* gContact:gender */
Packit 4b6dd7
			xmlChar *value;
Packit 4b6dd7
Packit 4b6dd7
			if (self->priv->gender != NULL)
Packit 4b6dd7
				return gdata_parser_error_duplicate_element (node, error);
Packit 4b6dd7
Packit 4b6dd7
			value = xmlGetProp (node, (xmlChar*) "value");
Packit 4b6dd7
			if (value == NULL || *value == '\0') {
Packit 4b6dd7
				xmlFree (value);
Packit 4b6dd7
				return gdata_parser_error_required_content_missing (node, error);
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			self->priv->gender = (gchar*) value;
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "hobby") == 0) {
Packit 4b6dd7
			/* gContact:hobby */
Packit 4b6dd7
			xmlChar *hobby;
Packit 4b6dd7
Packit 4b6dd7
			hobby = xmlNodeListGetString (doc, node->children, TRUE);
Packit 4b6dd7
			if (hobby == NULL || *hobby == '\0') {
Packit 4b6dd7
				xmlFree (hobby);
Packit 4b6dd7
				return gdata_parser_error_required_content_missing (node, error);
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			gdata_contacts_contact_add_hobby (self, (gchar*) hobby);
Packit 4b6dd7
			xmlFree (hobby);
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "userDefinedField") == 0) {
Packit 4b6dd7
			/* gContact:userDefinedField */
Packit 4b6dd7
			xmlChar *name, *value;
Packit 4b6dd7
Packit 4b6dd7
			/* Note that while we require the property to be present, we don't require it to be non-empty. See bgo#648058 */
Packit 4b6dd7
			name = xmlGetProp (node, (xmlChar*) "key");
Packit 4b6dd7
			if (name == NULL) {
Packit 4b6dd7
				return gdata_parser_error_required_property_missing (node, "key", error);
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			/* Get either the value property, or the element's content */
Packit 4b6dd7
			value = xmlGetProp (node, (xmlChar*) "value");
Packit 4b6dd7
			if (value == NULL) {
Packit 4b6dd7
				xmlFree (name);
Packit 4b6dd7
				return gdata_parser_error_required_property_missing (node, "value", error);
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			gdata_contacts_contact_set_user_defined_field (self, (gchar*) name, (gchar*) value);
Packit 4b6dd7
Packit 4b6dd7
			xmlFree (name);
Packit 4b6dd7
			xmlFree (value);
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "priority") == 0) {
Packit 4b6dd7
			/* gContact:priority */
Packit 4b6dd7
			xmlChar *rel;
Packit 4b6dd7
Packit 4b6dd7
			if (self->priv->priority != NULL)
Packit 4b6dd7
				return gdata_parser_error_duplicate_element (node, error);
Packit 4b6dd7
Packit 4b6dd7
			rel = xmlGetProp (node, (xmlChar*) "rel");
Packit 4b6dd7
			if (rel == NULL || *rel == '\0') {
Packit 4b6dd7
				xmlFree (rel);
Packit 4b6dd7
				return gdata_parser_error_required_content_missing (node, error);
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			self->priv->priority = (gchar*) rel;
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "sensitivity") == 0) {
Packit 4b6dd7
			/* gContact:sensitivity */
Packit 4b6dd7
			xmlChar *rel;
Packit 4b6dd7
Packit 4b6dd7
			if (self->priv->sensitivity != NULL)
Packit 4b6dd7
				return gdata_parser_error_duplicate_element (node, error);
Packit 4b6dd7
Packit 4b6dd7
			rel = xmlGetProp (node, (xmlChar*) "rel");
Packit 4b6dd7
			if (rel == NULL || *rel == '\0') {
Packit 4b6dd7
				xmlFree (rel);
Packit 4b6dd7
				return gdata_parser_error_required_content_missing (node, error);
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			self->priv->sensitivity = (gchar*) rel;
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "groupMembershipInfo") == 0) {
Packit 4b6dd7
			/* gContact:groupMembershipInfo */
Packit 4b6dd7
			xmlChar *href;
Packit 4b6dd7
			gboolean deleted_bool;
Packit 4b6dd7
Packit 4b6dd7
			href = xmlGetProp (node, (xmlChar*) "href");
Packit 4b6dd7
			if (href == NULL)
Packit 4b6dd7
				return gdata_parser_error_required_property_missing (node, "href", error);
Packit 4b6dd7
Packit 4b6dd7
			/* Has it been deleted? */
Packit 4b6dd7
			if (gdata_parser_boolean_from_property (node, "deleted", &deleted_bool, 0, error) == FALSE) {
Packit 4b6dd7
				xmlFree (href);
Packit 4b6dd7
				return FALSE;
Packit 4b6dd7
			}
Packit 4b6dd7
Packit 4b6dd7
			/* Insert it into the hash table */
Packit 4b6dd7
			g_hash_table_insert (self->priv->groups, (gchar*) href, GUINT_TO_POINTER (deleted_bool));
Packit 4b6dd7
		} else if (xmlStrcmp (node->name, (xmlChar*) "birthday") == 0) {
Packit 4b6dd7
			/* gContact:birthday */
Packit 4b6dd7
			xmlChar *birthday;
Packit 4b6dd7
			guint length = 0, year = 666, month, day;
Packit 4b6dd7
Packit 4b6dd7
			if (g_date_valid (&(self->priv->birthday)) == TRUE)
Packit 4b6dd7
				return gdata_parser_error_duplicate_element (node, error);
Packit 4b6dd7
Packit 4b6dd7
			birthday = xmlGetProp (node, (xmlChar*) "when");
Packit 4b6dd7
			if (birthday == NULL)
Packit 4b6dd7
				return gdata_parser_error_required_property_missing (node, "when", error);
Packit 4b6dd7
			length = strlen ((char*) birthday);
Packit 4b6dd7
Packit 4b6dd7
			/* Try parsing the two possible formats: YYYY-MM-DD and --MM-DD */
Packit 4b6dd7
			if (((length == 10 && sscanf ((char*) birthday, "%4u-%2u-%2u", &year, &month, &day) == 3) ||
Packit 4b6dd7
			     (length == 7 && sscanf ((char*) birthday, "--%2u-%2u", &month, &day) == 2)) &&
Packit 4b6dd7
			    g_date_valid_dmy (day, month, year) == TRUE) {
Packit 4b6dd7
				/* Store the values in the GDate */
Packit 4b6dd7
				g_date_set_dmy (&(self->priv->birthday), day, month, year);
Packit 4b6dd7
				self->priv->birthday_has_year = (length == 10) ? TRUE : FALSE;
Packit 4b6dd7
				xmlFree (birthday);
Packit 4b6dd7
			} else {
Packit 4b6dd7
				/* Parsing failed */
Packit 4b6dd7
				gdata_parser_error_not_iso8601_format (node, (gchar*) birthday, error);
Packit 4b6dd7
				xmlFree (birthday);
Packit 4b6dd7
				return FALSE;
Packit 4b6dd7
			}
Packit 4b6dd7
		} else {
Packit 4b6dd7
			return GDATA_PARSABLE_CLASS (gdata_contacts_contact_parent_class)->parse_xml (parsable, doc, node, user_data, error);
Packit 4b6dd7
		}
Packit 4b6dd7
	} else {
Packit 4b6dd7
		/* If we haven't yet found a photo, check to see if it's a photo <link> element */
Packit 4b6dd7
		if (self->priv->photo_etag == NULL && xmlStrcmp (node->name, (xmlChar*) "link") == 0) {
Packit 4b6dd7
			xmlChar *rel = xmlGetProp (node, (xmlChar*) "rel");
Packit 4b6dd7
			if (xmlStrcmp (rel, (xmlChar*) "http://schemas.google.com/contacts/2008/rel#photo") == 0) {
Packit 4b6dd7
				/* It's the photo link (http://code.google.com/apis/contacts/docs/2.0/reference.html#Photos), whose ETag we should
Packit 4b6dd7
				 * note down, then pass onto the parent class to parse properly */
Packit 4b6dd7
				self->priv->photo_etag = (gchar*) xmlGetProp (node, (xmlChar*) "etag");
Packit 4b6dd7
			}
Packit 4b6dd7
			xmlFree (rel);
Packit 4b6dd7
		}
Packit 4b6dd7
Packit 4b6dd7
		return GDATA_PARSABLE_CLASS (gdata_contacts_contact_parent_class)->parse_xml (parsable, doc, node, user_data, error);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return TRUE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_child_xml (GList *list, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	for (i = list; i != NULL; i = i->next)
Packit 4b6dd7
		_gdata_parsable_get_xml (GDATA_PARSABLE (i->data), xml_string, FALSE);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_extended_property_xml_cb (const gchar *name, const gchar *value, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	/* Note that the value *isn't* escaped (see http://code.google.com/apis/gdata/docs/2.0/elements.html#gdExtendedProperty) */
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, "<gd:extendedProperty name='", name, "'>");
Packit 4b6dd7
	g_string_append_printf (xml_string, "%s</gd:extendedProperty>", value);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_user_defined_field_xml_cb (const gchar *name, const gchar *value, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, "
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, "value='", value, "'/>");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_group_xml_cb (const gchar *href, gpointer deleted, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	gchar *full_pos, *uri = g_strdup (href);
Packit 4b6dd7
Packit 4b6dd7
	/* The service API sometimes stubbornly insists on using the "full" view instead of the "base" view, which we have
Packit 4b6dd7
	 * to fix, or it complains about an invalid group ID. */
Packit 4b6dd7
	full_pos = strstr (uri, "/full/");
Packit 4b6dd7
	if (full_pos != NULL)
Packit 4b6dd7
		memcpy ((char*) full_pos, "/base/", 6);
Packit 4b6dd7
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, "<gContact:groupMembershipInfo href='", uri, "'/>");
Packit 4b6dd7
Packit 4b6dd7
	g_free (uri);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_hobby_xml_cb (const gchar *hobby, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	gdata_parser_string_append_escaped (xml_string, "<gContact:hobby>", hobby, "</gContact:hobby>");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_xml (GDataParsable *parsable, GString *xml_string)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = GDATA_CONTACTS_CONTACT (parsable)->priv;
Packit 4b6dd7
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	GDATA_PARSABLE_CLASS (gdata_contacts_contact_parent_class)->get_xml (parsable, xml_string);
Packit 4b6dd7
Packit 4b6dd7
	/* Name */
Packit 4b6dd7
	_gdata_parsable_get_xml (GDATA_PARSABLE (priv->name), xml_string, FALSE);
Packit 4b6dd7
Packit 4b6dd7
	/* Lists of stuff */
Packit 4b6dd7
	get_child_xml (priv->email_addresses, xml_string);
Packit 4b6dd7
	get_child_xml (priv->im_addresses, xml_string);
Packit 4b6dd7
	get_child_xml (priv->phone_numbers, xml_string);
Packit 4b6dd7
	get_child_xml (priv->postal_addresses, xml_string);
Packit 4b6dd7
	get_child_xml (priv->organizations, xml_string);
Packit 4b6dd7
	get_child_xml (priv->jots, xml_string);
Packit 4b6dd7
	get_child_xml (priv->relations, xml_string);
Packit 4b6dd7
	get_child_xml (priv->websites, xml_string);
Packit 4b6dd7
	get_child_xml (priv->events, xml_string);
Packit 4b6dd7
	get_child_xml (priv->calendars, xml_string);
Packit 4b6dd7
	get_child_xml (priv->external_ids, xml_string);
Packit 4b6dd7
	get_child_xml (priv->languages, xml_string);
Packit 4b6dd7
Packit 4b6dd7
	/* Extended properties */
Packit 4b6dd7
	g_hash_table_foreach (priv->extended_properties, (GHFunc) get_extended_property_xml_cb, xml_string);
Packit 4b6dd7
Packit 4b6dd7
	/* User defined fields */
Packit 4b6dd7
	g_hash_table_foreach (priv->user_defined_fields, (GHFunc) get_user_defined_field_xml_cb, xml_string);
Packit 4b6dd7
Packit 4b6dd7
	/* Group membership info */
Packit 4b6dd7
	g_hash_table_foreach (priv->groups, (GHFunc) get_group_xml_cb, xml_string);
Packit 4b6dd7
Packit 4b6dd7
	/* Hobbies */
Packit 4b6dd7
	g_list_foreach (priv->hobbies, (GFunc) get_hobby_xml_cb, xml_string);
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:nickname */
Packit 4b6dd7
	if (priv->nickname != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:nickname>", priv->nickname, "</gContact:nickname>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:fileAs */
Packit 4b6dd7
	if (priv->file_as != NULL) {
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:fileAs>", priv->file_as, "</gContact:fileAs>");
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:birthday */
Packit 4b6dd7
	if (g_date_valid (&(priv->birthday)) == TRUE) {
Packit 4b6dd7
		if (priv->birthday_has_year == TRUE) {
Packit 4b6dd7
			g_string_append_printf (xml_string, "<gContact:birthday when='%04u-%02u-%02u'/>",
Packit 4b6dd7
			                        g_date_get_year (&(priv->birthday)),
Packit 4b6dd7
			                        g_date_get_month (&(priv->birthday)),
Packit 4b6dd7
			                        g_date_get_day (&(priv->birthday)));
Packit 4b6dd7
		} else {
Packit 4b6dd7
			g_string_append_printf (xml_string, "<gContact:birthday when='--%02u-%02u'/>",
Packit 4b6dd7
			                        g_date_get_month (&(priv->birthday)),
Packit 4b6dd7
			                        g_date_get_day (&(priv->birthday)));
Packit 4b6dd7
		}
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:billingInformation */
Packit 4b6dd7
	if (priv->billing_information != NULL) {
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string,
Packit 4b6dd7
		                                    "<gContact:billingInformation>", priv->billing_information, "</gContact:billingInformation>");
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:directoryServer */
Packit 4b6dd7
	if (priv->directory_server != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:directoryServer>", priv->directory_server, "</gContact:directoryServer>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:gender */
Packit 4b6dd7
	if (priv->gender != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:gender value='", priv->gender, "'/>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:initials */
Packit 4b6dd7
	if (priv->initials != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:initials>", priv->initials, "</gContact:initials>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:maidenName */
Packit 4b6dd7
	if (priv->maiden_name != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:maidenName>", priv->maiden_name, "</gContact:maidenName>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:mileage */
Packit 4b6dd7
	if (priv->mileage != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:mileage>", priv->mileage, "</gContact:mileage>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:occupation */
Packit 4b6dd7
	if (priv->occupation != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:occupation>", priv->occupation, "</gContact:occupation>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:priority */
Packit 4b6dd7
	if (priv->priority != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:priority rel='", priv->priority, "'/>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:sensitivity */
Packit 4b6dd7
	if (priv->sensitivity != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:sensitivity rel='", priv->sensitivity, "'/>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:shortName */
Packit 4b6dd7
	if (priv->short_name != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:shortName>", priv->short_name, "</gContact:shortName>");
Packit 4b6dd7
Packit 4b6dd7
	/* gContact:subject */
Packit 4b6dd7
	if (priv->subject != NULL)
Packit 4b6dd7
		gdata_parser_string_append_escaped (xml_string, "<gContact:subject>", priv->subject, "</gContact:subject>");
Packit 4b6dd7
Packit 4b6dd7
	/* TODO:
Packit 4b6dd7
	 * - Finish supporting all tags
Packit 4b6dd7
	 */
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_namespaces (GDataParsable *parsable, GHashTable *namespaces)
Packit 4b6dd7
{
Packit 4b6dd7
	/* Chain up to the parent class */
Packit 4b6dd7
	GDATA_PARSABLE_CLASS (gdata_contacts_contact_parent_class)->get_namespaces (parsable, namespaces);
Packit 4b6dd7
Packit 4b6dd7
	g_hash_table_insert (namespaces, (gchar*) "gd", (gchar*) "http://schemas.google.com/g/2005");
Packit 4b6dd7
	g_hash_table_insert (namespaces, (gchar*) "gContact", (gchar*) "http://schemas.google.com/contact/2008");
Packit 4b6dd7
	g_hash_table_insert (namespaces, (gchar*) "app", (gchar*) "http://www.w3.org/2007/app");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
static gchar *
Packit 4b6dd7
get_entry_uri (const gchar *id)
Packit 4b6dd7
{
Packit 4b6dd7
	const gchar *base_pos;
Packit 4b6dd7
	gchar *uri;
Packit 4b6dd7
Packit 4b6dd7
	/* Ensure it uses the HTTPS protocol */
Packit 4b6dd7
	if (g_str_has_prefix (id, "http://") == TRUE) {
Packit 4b6dd7
		guint id_length = strlen (id);
Packit 4b6dd7
Packit 4b6dd7
		uri = g_malloc (id_length + 2);
Packit 4b6dd7
		strcpy (uri, "https://");
Packit 4b6dd7
		strcpy (uri + strlen ("https://"), id + strlen ("http://"));
Packit 4b6dd7
	} else {
Packit 4b6dd7
		uri = g_strdup (id);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* The service API sometimes stubbornly insists on using the "base" view instead of the "full" view, which we have
Packit 4b6dd7
	 * to fix, or our extended attributes are never visible */
Packit 4b6dd7
	base_pos = strstr (uri, "/base/");
Packit 4b6dd7
	if (base_pos != NULL)
Packit 4b6dd7
		memcpy ((char*) base_pos, "/full/", 6);
Packit 4b6dd7
Packit 4b6dd7
	return uri;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_new:
Packit 4b6dd7
 * @id: (allow-none): the contact's ID, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Creates a new #GDataContactsContact with the given ID and default properties.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a new #GDataContactsContact; unref with g_object_unref()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataContactsContact *
Packit 4b6dd7
gdata_contacts_contact_new (const gchar *id)
Packit 4b6dd7
{
Packit 4b6dd7
	return GDATA_CONTACTS_CONTACT (g_object_new (GDATA_TYPE_CONTACTS_CONTACT, "id", id, NULL));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_edited:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:edited property. If the property is unset, -1 will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the UNIX timestamp for the time the contact was last edited, or -1
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
gint64
Packit 4b6dd7
gdata_contacts_contact_get_edited (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), -1);
Packit 4b6dd7
	return self->priv->edited;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_name:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:name property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): the contact's name, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.5.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGDName *
Packit 4b6dd7
gdata_contacts_contact_get_name (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->name;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_name:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @name: the new #GDataGDName
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:name property to @name, and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * @name must not be %NULL, though all its properties may be %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_name (GDataContactsContact *self, GDataGDName *name)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_NAME (name));
Packit 4b6dd7
Packit 4b6dd7
	if (self->priv->name != NULL)
Packit 4b6dd7
		g_object_unref (self->priv->name);
Packit 4b6dd7
	self->priv->name = g_object_ref (name);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "name");
Packit 4b6dd7
Packit 4b6dd7
	/* Notify the change in #GDataGDName:full-name explicitly, so that our #GDataEntry:title gets updated */
Packit 4b6dd7
	notify_full_name_cb (G_OBJECT (name), NULL, self);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_nickname:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:nickname property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the contact's nickname, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_nickname (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->nickname;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_nickname:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @nickname: (allow-none): the new nickname, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:nickname property to @nickname.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @nickname is %NULL, the contact's nickname will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_nickname (GDataContactsContact *self, const gchar *nickname)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->nickname);
Packit 4b6dd7
	self->priv->nickname = g_strdup (nickname);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "nickname");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_file_as:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:file-as property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the name the contact's filed under, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.11.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_file_as (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->file_as;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_file_as:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @file_as: (allow-none): the new name to file the contact under, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:file-as property to @file_as.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @file_as is %NULL, the contact will be filed under their full name.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_file_as (GDataContactsContact *self, const gchar *file_as)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->file_as);
Packit 4b6dd7
	self->priv->file_as = g_strdup (file_as);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "file-as");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_birthday:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @birthday: (allow-none) (out caller-allocates): return location for the birthday, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:birthday and #GDataContactsContact:birthday-has-year properties. If @birthday is non-%NULL,
Packit 4b6dd7
 * #GDataContactsContact:birthday is returned in it. The function returns the value of #GDataContactsContact:birthday-has-year,
Packit 4b6dd7
 * which specifies whether the year in @birthday is meaningful. Contacts may not have the year of their birth set, in which
Packit 4b6dd7
 * case, the function would return %FALSE, and the year in @birthday should be ignored.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: whether the contact's birthday has the year set
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_contacts_contact_get_birthday (GDataContactsContact *self, GDate *birthday)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), FALSE);
Packit 4b6dd7
Packit 4b6dd7
	if (birthday != NULL)
Packit 4b6dd7
		*birthday = self->priv->birthday;
Packit 4b6dd7
	return self->priv->birthday_has_year;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_birthday:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @birthday: (allow-none): the new birthday, or %NULL
Packit 4b6dd7
 * @birthday_has_year: %TRUE if @birthday's year is relevant, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:birthday property to @birthday and the #GDataContactsContact:birthday-has-year property to @birthday_has_year.
Packit 4b6dd7
 * See gdata_contacts_contact_get_birthday() for an explanation of the interation between these two properties.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @birthday is %NULL, the contact's birthday will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_birthday (GDataContactsContact *self, GDate *birthday, gboolean birthday_has_year)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (birthday == NULL || g_date_valid (birthday));
Packit 4b6dd7
Packit 4b6dd7
	if (birthday != NULL)
Packit 4b6dd7
		self->priv->birthday = *birthday;
Packit 4b6dd7
	else
Packit 4b6dd7
		g_date_clear (&(self->priv->birthday), 1);
Packit 4b6dd7
Packit 4b6dd7
	self->priv->birthday_has_year = birthday_has_year;
Packit 4b6dd7
Packit 4b6dd7
	g_object_freeze_notify (G_OBJECT (self));
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "birthday");
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "birthday-has-year");
Packit 4b6dd7
	g_object_thaw_notify (G_OBJECT (self));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_billing_information:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:billing-information property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the contact's billing information, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_billing_information (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->billing_information;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_billing_information:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @billing_information: (allow-none): the new billing information for the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:billing-information property to @billing_information.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @billing_information is %NULL, the contact's billing information will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_billing_information (GDataContactsContact *self, const gchar *billing_information)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (billing_information == NULL || *billing_information != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->billing_information);
Packit 4b6dd7
	self->priv->billing_information = g_strdup (billing_information);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "billing-information");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_directory_server:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:directory-server property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the name or address of a directory server associated with the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_directory_server (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->directory_server;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_directory_server:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @directory_server: (allow-none): the new name or address of a directory server associated with the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:directory-server property to @directory_server.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @directory_server is %NULL, the contact's directory server will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_directory_server (GDataContactsContact *self, const gchar *directory_server)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (directory_server == NULL || *directory_server != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->directory_server);
Packit 4b6dd7
	self->priv->directory_server = g_strdup (directory_server);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "directory-server");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_gender:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:gender property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the gender of the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_gender (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->gender;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_gender:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @gender: (allow-none): the new gender of the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:gender property to @gender.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @gender is %NULL, the contact's gender will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_gender (GDataContactsContact *self, const gchar *gender)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (gender == NULL || *gender != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->gender);
Packit 4b6dd7
	self->priv->gender = g_strdup (gender);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "gender");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_initials:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:initials property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the initials of the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_initials (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->initials;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_initials:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @initials: (allow-none): the new initials of the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:initials property to @initials.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @initials is %NULL, the contact's initials will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_initials (GDataContactsContact *self, const gchar *initials)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->initials);
Packit 4b6dd7
	self->priv->initials = g_strdup (initials);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "initials");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_maiden_name:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:maiden-name property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the maiden name of the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_maiden_name (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->maiden_name;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_maiden_name:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @maiden_name: (allow-none): the new maiden name of the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:maiden-name property to @maiden_name.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @maiden_name is %NULL, the contact's maiden name will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_maiden_name (GDataContactsContact *self, const gchar *maiden_name)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->maiden_name);
Packit 4b6dd7
	self->priv->maiden_name = g_strdup (maiden_name);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "maiden-name");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_mileage:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:mileage property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: a mileage associated with the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_mileage (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->mileage;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_mileage:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @mileage: (allow-none): the new mileage associated with the contact, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:mileage property to @mileage.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @mileage is %NULL, the contact's mileage will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_mileage (GDataContactsContact *self, const gchar *mileage)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->mileage);
Packit 4b6dd7
	self->priv->mileage = g_strdup (mileage);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "mileage");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_occupation:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:occupation property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the contact's occupation, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_occupation (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->occupation;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_occupation:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @occupation: (allow-none): the contact's new occupation, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:occupation property to @occupation.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @occupation is %NULL, the contact's occupation will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_occupation (GDataContactsContact *self, const gchar *occupation)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->occupation);
Packit 4b6dd7
	self->priv->occupation = g_strdup (occupation);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "occupation");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_priority:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:priority property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the contact's priority, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_priority (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->priority;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_priority:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @priority: (allow-none): the contact's new priority, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:priority property to @priority.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @priority is %NULL, the contact's priority will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_priority (GDataContactsContact *self, const gchar *priority)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (priority == NULL || *priority != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->priority);
Packit 4b6dd7
	self->priv->priority = g_strdup (priority);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "priority");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_sensitivity:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:sensitivity property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the contact's sensitivity, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_sensitivity (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->sensitivity;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_sensitivity:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @sensitivity: (allow-none): the contact's new sensitivity, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:sensitivity property to @sensitivity.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @sensitivity is %NULL, the contact's sensitivity will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_sensitivity (GDataContactsContact *self, const gchar *sensitivity)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (sensitivity == NULL || *sensitivity != '\0');
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->sensitivity);
Packit 4b6dd7
	self->priv->sensitivity = g_strdup (sensitivity);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "sensitivity");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_short_name:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:short-name property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the contact's short name, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_short_name (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->short_name;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_short_name:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @short_name: (allow-none): the contact's new short name, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:short-name property to @short_name.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @short_name is %NULL, the contact's short name will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_short_name (GDataContactsContact *self, const gchar *short_name)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->short_name);
Packit 4b6dd7
	self->priv->short_name = g_strdup (short_name);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "short-name");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_subject:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the #GDataContactsContact:subject property.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the contact's subject, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_subject (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->subject;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_subject:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @subject: (allow-none): the contact's new subject, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the #GDataContactsContact:subject property to @subject.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @subject is %NULL, the contact's subject will be removed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_subject (GDataContactsContact *self, const gchar *subject)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	g_free (self->priv->subject);
Packit 4b6dd7
	self->priv->subject = g_strdup (subject);
Packit 4b6dd7
	g_object_notify (G_OBJECT (self), "subject");
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_email_address:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @email_address: a #GDataGDEmailAddress to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds an e-mail address to the contact's list of e-mail addresses and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Note that only one e-mail address per contact may be marked as "primary". Insertion and update operations
Packit 4b6dd7
 * (with gdata_contacts_service_insert_contact()) will return an error if more than one e-mail address
Packit 4b6dd7
 * is marked as primary.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate e-mail addresses will not be added to the list.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_email_address (GDataContactsContact *self, GDataGDEmailAddress *email_address)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_EMAIL_ADDRESS (email_address));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->email_addresses, email_address, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->email_addresses = g_list_append (self->priv->email_addresses, g_object_ref (email_address));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_email_addresses:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the e-mail addresses owned by the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GDEmailAddress) (transfer none): a #GList of #GDataGDEmailAddresses, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_email_addresses (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->email_addresses;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_primary_email_address:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the contact's primary e-mail address, if one exists.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GDataGDEmailAddress, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGDEmailAddress *
Packit 4b6dd7
gdata_contacts_contact_get_primary_email_address (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	for (i = self->priv->email_addresses; i != NULL; i = i->next) {
Packit 4b6dd7
		if (gdata_gd_email_address_is_primary (GDATA_GD_EMAIL_ADDRESS (i->data)) == TRUE)
Packit 4b6dd7
			return GDATA_GD_EMAIL_ADDRESS (i->data);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_email_addresses:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all e-mail addresses from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_email_addresses (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->email_addresses != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->email_addresses, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->email_addresses);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->email_addresses = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_im_address:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @im_address: a #GDataGDIMAddress to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds an IM (instant messaging) address to the contact's list of IM addresses and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Note that only one IM address per contact may be marked as "primary". Insertion and update operations
Packit 4b6dd7
 * (with gdata_contacts_service_insert_contact()) will return an error if more than one IM address
Packit 4b6dd7
 * is marked as primary.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate IM addresses will not be added to the list.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_im_address (GDataContactsContact *self, GDataGDIMAddress *im_address)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_IM_ADDRESS (im_address));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->im_addresses, im_address, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->im_addresses = g_list_append (self->priv->im_addresses, g_object_ref (im_address));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_im_addresses:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the IM addresses owned by the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GDIMAddress) (transfer none): a #GList of #GDataGDIMAddresses, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_im_addresses (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->im_addresses;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_primary_im_address:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the contact's primary IM address, if one exists.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GDataGDIMAddress, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGDIMAddress *
Packit 4b6dd7
gdata_contacts_contact_get_primary_im_address (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	for (i = self->priv->im_addresses; i != NULL; i = i->next) {
Packit 4b6dd7
		if (gdata_gd_im_address_is_primary (GDATA_GD_IM_ADDRESS (i->data)) == TRUE)
Packit 4b6dd7
			return GDATA_GD_IM_ADDRESS (i->data);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_im_addresses:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all IM addresses from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_im_addresses (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->im_addresses != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->im_addresses, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->im_addresses);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->im_addresses = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_phone_number:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @phone_number: a #GDataGDPhoneNumber to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds a phone number to the contact's list of phone numbers and increments its reference count
Packit 4b6dd7
 *
Packit 4b6dd7
 * Note that only one phone number per contact may be marked as "primary". Insertion and update operations
Packit 4b6dd7
 * (with gdata_contacts_service_insert_contact()) will return an error if more than one phone number
Packit 4b6dd7
 * is marked as primary.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate phone numbers will not be added to the list.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_phone_number (GDataContactsContact *self, GDataGDPhoneNumber *phone_number)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_PHONE_NUMBER (phone_number));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->phone_numbers, phone_number, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->phone_numbers = g_list_append (self->priv->phone_numbers, g_object_ref (phone_number));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_phone_numbers:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the phone numbers owned by the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GDPhoneNumber) (transfer none): a #GList of #GDataGDPhoneNumbers, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_phone_numbers (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->phone_numbers;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_primary_phone_number:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the contact's primary phone number, if one exists.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GDataGDPhoneNumber, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGDPhoneNumber *
Packit 4b6dd7
gdata_contacts_contact_get_primary_phone_number (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	for (i = self->priv->phone_numbers; i != NULL; i = i->next) {
Packit 4b6dd7
		if (gdata_gd_phone_number_is_primary (GDATA_GD_PHONE_NUMBER (i->data)) == TRUE)
Packit 4b6dd7
			return GDATA_GD_PHONE_NUMBER (i->data);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_phone_numbers:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all phone numbers from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_phone_numbers (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->phone_numbers != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->phone_numbers, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->phone_numbers);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->phone_numbers = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_postal_address:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @postal_address: a #GDataGDPostalAddress to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds a postal address to the contact's list of postal addresses and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Note that only one postal address per contact may be marked as "primary". Insertion and update operations
Packit 4b6dd7
 * (with gdata_contacts_service_insert_contact()) will return an error if more than one postal address
Packit 4b6dd7
 * is marked as primary.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate postal addresses will not be added to the list.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_postal_address (GDataContactsContact *self, GDataGDPostalAddress *postal_address)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GD_POSTAL_ADDRESS (postal_address));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->postal_addresses, postal_address, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->postal_addresses = g_list_append (self->priv->postal_addresses, g_object_ref (postal_address));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_postal_addresses:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the postal addresses owned by the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GDPostalAddress) (transfer none): a #GList of #GDataGDPostalAddresses, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_postal_addresses (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->postal_addresses;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_primary_postal_address:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the contact's primary postal address, if one exists.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GDataGDPostalAddress, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGDPostalAddress *
Packit 4b6dd7
gdata_contacts_contact_get_primary_postal_address (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	for (i = self->priv->postal_addresses; i != NULL; i = i->next) {
Packit 4b6dd7
		if (gdata_gd_postal_address_is_primary (GDATA_GD_POSTAL_ADDRESS (i->data)) == TRUE)
Packit 4b6dd7
			return GDATA_GD_POSTAL_ADDRESS (i->data);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_postal_addresses:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all postal addresses from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_postal_addresses (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->postal_addresses != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->postal_addresses, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->postal_addresses);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->postal_addresses = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_organization:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @organization: a #GDataGDOrganization to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds an organization to the contact's list of organizations (e.g. employers) and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Note that only one organization per contact may be marked as "primary". Insertion and update operations
Packit 4b6dd7
 * (with gdata_contacts_service_insert_contact()) will return an error if more than one organization
Packit 4b6dd7
 * is marked as primary.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate organizations will not be added to the list.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_organization (GDataContactsContact *self, GDataGDOrganization *organization)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (organization != NULL);
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->organizations, organization, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->organizations = g_list_append (self->priv->organizations, g_object_ref (organization));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_organizations:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the organizations to which the contact belongs.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GDOrganization) (transfer none): a #GList of #GDataGDOrganizations, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_organizations (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->organizations;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_primary_organization:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the contact's primary organization, if one exists.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GDataGDOrganization, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGDOrganization *
Packit 4b6dd7
gdata_contacts_contact_get_primary_organization (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	for (i = self->priv->organizations; i != NULL; i = i->next) {
Packit 4b6dd7
		if (gdata_gd_organization_is_primary (GDATA_GD_ORGANIZATION (i->data)) == TRUE)
Packit 4b6dd7
			return GDATA_GD_ORGANIZATION (i->data);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_organizations:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all organizations from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_organizations (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->organizations != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->organizations, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->organizations);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->organizations = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_jot:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @jot: a #GDataGContactJot to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds a jot to the contact's list of jots and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate jots will be added to the list, and multiple jots with the same relation type can be added to a single contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_jot (GDataContactsContact *self, GDataGContactJot *jot)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_JOT (jot));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->jots = g_list_append (self->priv->jots, g_object_ref (jot));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_jots:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the jots attached to the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GContactJot) (transfer none): a #GList of #GDataGContactJots, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_jots (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->jots;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_jots:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all jots from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_jots (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->jots != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->jots, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->jots);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->jots = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_relation:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @relation: a #GDataGContactRelation to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds a relation to the contact's list of relations and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate relations will be added to the list, and multiple relations with the same relation type can be added to a single contact.
Packit 4b6dd7
 * Though it may not make sense for some relation types to be repeated, adding them is allowed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_relation (GDataContactsContact *self, GDataGContactRelation *relation)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_RELATION (relation));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->relations = g_list_append (self->priv->relations, g_object_ref (relation));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_relations:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the relations of the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GContactRelation) (transfer none): a #GList of #GDataGContactRelations, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_relations (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->relations;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_relations:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all relations from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_relations (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->relations != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->relations, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->relations);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->relations = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_website:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @website: a #GDataGContactWebsite to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds a website to the contact's list of websites and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate websites will not be added to the list, though the same URI may appear in several #GDataGContactWebsites with different
Packit 4b6dd7
 * relation types or labels.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_website (GDataContactsContact *self, GDataGContactWebsite *website)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_WEBSITE (website));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->websites, website, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->websites = g_list_append (self->priv->websites, g_object_ref (website));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_websites:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the websites of the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GContactWebsite) (transfer none): a #GList of #GDataGContactWebsites, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_websites (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->websites;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_primary_website:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the contact's primary website, if one exists.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GDataGContactWebsite, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGContactWebsite *
Packit 4b6dd7
gdata_contacts_contact_get_primary_website (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	for (i = self->priv->websites; i != NULL; i = i->next) {
Packit 4b6dd7
		if (gdata_gcontact_website_is_primary (GDATA_GCONTACT_WEBSITE (i->data)) == TRUE)
Packit 4b6dd7
			return GDATA_GCONTACT_WEBSITE (i->data);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_websites:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all websites from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_websites (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->websites != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->websites, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->websites);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->websites = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_event:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @event: a #GDataGContactEvent to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds an event to the contact's list of events and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate events will be added to the list, and multiple events with the same event type can be added to a single contact.
Packit 4b6dd7
 * Though it may not make sense for some event types to be repeated, adding them is allowed.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_event (GDataContactsContact *self, GDataGContactEvent *event)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_EVENT (event));
Packit 4b6dd7
Packit 4b6dd7
	self->priv->events = g_list_append (self->priv->events, g_object_ref (event));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_events:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the events of the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GContactEvent) (transfer none): a #GList of #GDataGContactEvents, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_events (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->events;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_events:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all events from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_events (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->events != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->events, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->events);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->events = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_calendar:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @calendar: a #GDataGContactCalendar to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds a calendar to the contact's list of calendars and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate calendars will not be added to the list, though the same URI may appear in several #GDataGContactCalendars with different
Packit 4b6dd7
 * relation types or labels.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_calendar (GDataContactsContact *self, GDataGContactCalendar *calendar)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_CALENDAR (calendar));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->calendars, calendar, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->calendars = g_list_append (self->priv->calendars, g_object_ref (calendar));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_calendars:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the calendars of the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GContactCalendar) (transfer none): a #GList of #GDataGContactCalendars, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_calendars (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->calendars;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_primary_calendar:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the contact's primary calendar, if one exists.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GDataGContactCalendar, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GDataGContactCalendar *
Packit 4b6dd7
gdata_contacts_contact_get_primary_calendar (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GList *i;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	for (i = self->priv->calendars; i != NULL; i = i->next) {
Packit 4b6dd7
		if (gdata_gcontact_calendar_is_primary (GDATA_GCONTACT_CALENDAR (i->data)) == TRUE)
Packit 4b6dd7
			return GDATA_GCONTACT_CALENDAR (i->data);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_calendars:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all calendars from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_calendars (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->calendars != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->calendars, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->calendars);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->calendars = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_external_id:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @external_id: a #GDataGContactExternalID to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds an external ID to the contact's list of external IDs and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate IDs will not be added to the list.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_external_id (GDataContactsContact *self, GDataGContactExternalID *external_id)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_EXTERNAL_ID (external_id));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->external_ids, external_id, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->external_ids = g_list_append (self->priv->external_ids, g_object_ref (external_id));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_external_ids:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the external IDs of the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GContactExternalID) (transfer none): a #GList of #GDataGContactExternalIDs, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_external_ids (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->external_ids;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_external_ids:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all external IDs from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_external_ids (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->external_ids != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->external_ids, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->external_ids);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->external_ids = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_hobby:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @hobby: a hobby to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds a hobby to the contact's list of hobbies, copying it in the process.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate hobbies will not be added to the list.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_hobby (GDataContactsContact *self, const gchar *hobby)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (hobby != NULL && *hobby != '\0');
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->hobbies, hobby, (GCompareFunc) g_strcmp0) == NULL)
Packit 4b6dd7
		self->priv->hobbies = g_list_append (self->priv->hobbies, g_strdup (hobby));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_hobbies:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the hobbies of the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type utf8) (transfer none): a #GList of hobby strings, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_hobbies (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->hobbies;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_hobbies:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all hobbies from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_hobbies (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->hobbies != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->hobbies, (GFunc) g_free, NULL);
Packit 4b6dd7
		g_list_free (priv->hobbies);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->hobbies = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_language:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @language: a #GDataGContactLanguage to add
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds a language to the contact's list of languages and increments its reference count.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Duplicate languages will not be added to the list.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_language (GDataContactsContact *self, GDataGContactLanguage *language)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_GCONTACT_LANGUAGE (language));
Packit 4b6dd7
Packit 4b6dd7
	if (g_list_find_custom (self->priv->languages, language, (GCompareFunc) gdata_comparable_compare) == NULL)
Packit 4b6dd7
		self->priv->languages = g_list_append (self->priv->languages, g_object_ref (language));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_languages:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the languages of the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type GData.GContactLanguage) (transfer none): a #GList of #GDataGContactLanguages, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_languages (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->languages;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_all_languages:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes all languages from the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_all_languages (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContactPrivate *priv = self->priv;
Packit 4b6dd7
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
Packit 4b6dd7
	if (priv->languages != NULL) {
Packit 4b6dd7
		g_list_foreach (priv->languages, (GFunc) g_object_unref, NULL);
Packit 4b6dd7
		g_list_free (priv->languages);
Packit 4b6dd7
	}
Packit 4b6dd7
	priv->languages = NULL;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_extended_property:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @name: the property name; an arbitrary, unique string
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the value of an extended property of the contact. Each contact can have up to 10 client-set extended
Packit 4b6dd7
 * properties to store data of the client's choosing.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the property's value, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_extended_property (GDataContactsContact *self, const gchar *name)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	g_return_val_if_fail (name != NULL && *name != '\0', NULL);
Packit 4b6dd7
	return g_hash_table_lookup (self->priv->extended_properties, name);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_extended_properties:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the full list of extended properties of the contact; a hash table mapping property name to value.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GHashTable of extended properties
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.4.0
Packit 4b6dd7
 */
Packit 4b6dd7
GHashTable *
Packit 4b6dd7
gdata_contacts_contact_get_extended_properties (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->extended_properties;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_extended_property:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @name: the property name; an arbitrary, unique string
Packit 4b6dd7
 * @value: (allow-none): the property value, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the value of a contact's extended property. Extended property names are unique (but of the client's choosing),
Packit 4b6dd7
 * and reusing the same property name will result in the old value of that property being overwritten.
Packit 4b6dd7
 *
Packit 4b6dd7
 * To unset a property, set @value to %NULL or an empty string.
Packit 4b6dd7
 *
Packit 4b6dd7
 * A contact may have up to 10 extended properties, and each should be reasonably small (i.e. not a photo or ringtone).
Packit 4b6dd7
 * For more information, see the 
Packit 4b6dd7
 * url="http://code.google.com/apis/contacts/docs/2.0/reference.html#ProjectionsAndExtended">online documentation</ulink>.
Packit 4b6dd7
 * %FALSE will be returned if you attempt to add more than 10 extended properties.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if the property was updated or deleted successfully, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_contacts_contact_set_extended_property (GDataContactsContact *self, const gchar *name, const gchar *value)
Packit 4b6dd7
{
Packit 4b6dd7
	GHashTable *extended_properties = self->priv->extended_properties;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), FALSE);
Packit 4b6dd7
	g_return_val_if_fail (name != NULL && *name != '\0', FALSE);
Packit 4b6dd7
Packit 4b6dd7
	if (value == NULL || *value == '\0') {
Packit 4b6dd7
		/* Removing a property */
Packit 4b6dd7
		g_hash_table_remove (extended_properties, name);
Packit 4b6dd7
		return TRUE;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	/* We can't add more than MAX_N_EXTENDED_PROPERTIES */
Packit 4b6dd7
	if (g_hash_table_lookup (extended_properties, name) == NULL &&
Packit 4b6dd7
	    g_hash_table_size (extended_properties) >= MAX_N_EXTENDED_PROPERTIES)
Packit 4b6dd7
		return FALSE;
Packit 4b6dd7
Packit 4b6dd7
	/* Updating an existing property or adding a new one */
Packit 4b6dd7
	g_hash_table_insert (extended_properties, g_strdup (name), g_strdup (value));
Packit 4b6dd7
Packit 4b6dd7
	return TRUE;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_user_defined_field:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @name: the field name; an arbitrary, case-sensitive, unique string
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the value of a user-defined field of the contact. User-defined fields are settable by the user through the Google Contacts web interface,
Packit 4b6dd7
 * in contrast to extended properties, which are visible and settable only through the GData interface.
Packit 4b6dd7
 *
Packit 4b6dd7
 * The @name of the field may not be %NULL, but may be an empty string.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the field's value, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_user_defined_field (GDataContactsContact *self, const gchar *name)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	g_return_val_if_fail (name != NULL, NULL);
Packit 4b6dd7
	return g_hash_table_lookup (self->priv->user_defined_fields, name);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_user_defined_fields:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets the full list of user-defined fields of the contact; a hash table mapping field name to value.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer none): a #GHashTable of user-defined fields
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
GHashTable *
Packit 4b6dd7
gdata_contacts_contact_get_user_defined_fields (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->user_defined_fields;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_set_user_defined_field:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @name: the field name; an arbitrary, case-sensitive, unique string
Packit 4b6dd7
 * @value: (allow-none): the field value, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Sets the value of a contact's user-defined field. User-defined field names are unique (but of the client's choosing),
Packit 4b6dd7
 * and reusing the same field name will result in the old value of that field being overwritten.
Packit 4b6dd7
 *
Packit 4b6dd7
 * The @name of the field may not be %NULL, but may be an empty string.
Packit 4b6dd7
 *
Packit 4b6dd7
 * To unset a field, set @value to %NULL.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.7.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_set_user_defined_field (GDataContactsContact *self, const gchar *name, const gchar *value)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (name != NULL);
Packit 4b6dd7
Packit 4b6dd7
	if (value == NULL) {
Packit 4b6dd7
		/* Removing a field */
Packit 4b6dd7
		g_hash_table_remove (self->priv->user_defined_fields, name);
Packit 4b6dd7
	} else {
Packit 4b6dd7
		/* Updating an existing field or adding a new one */
Packit 4b6dd7
		g_hash_table_insert (self->priv->user_defined_fields, g_strdup (name), g_strdup (value));
Packit 4b6dd7
	}
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_add_group:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @href: the group's ID URI
Packit 4b6dd7
 *
Packit 4b6dd7
 * Adds the contact to the given group. @href should be a URI.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_add_group (GDataContactsContact *self, const gchar *href)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (href != NULL);
Packit 4b6dd7
	g_hash_table_insert (self->priv->groups, g_strdup (href), GUINT_TO_POINTER (FALSE));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_remove_group:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @href: the group's ID URI
Packit 4b6dd7
 *
Packit 4b6dd7
 * Removes the contact from the given group. @href should be a URI.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_remove_group (GDataContactsContact *self, const gchar *href)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_if_fail (GDATA_IS_CONTACTS_CONTACT (self));
Packit 4b6dd7
	g_return_if_fail (href != NULL);
Packit 4b6dd7
	g_hash_table_remove (self->priv->groups, href);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_is_group_deleted:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @href: the group's ID URI
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns whether the contact has recently been removed from the given group on the server. This
Packit 4b6dd7
 * will always return %FALSE unless #GDataContactsQuery:show-deleted has been set to
Packit 4b6dd7
 * %TRUE for the query which returned the contact.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If you've just removed a contact from a group locally using gdata_contacts_contact_remove_group(), %FALSE will still be returned by this function,
Packit 4b6dd7
 * as the change hasn't been sent to the server.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if the contact has recently been removed from the group, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_contacts_contact_is_group_deleted (GDataContactsContact *self, const gchar *href)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), FALSE);
Packit 4b6dd7
	g_return_val_if_fail (href != NULL, FALSE);
Packit 4b6dd7
	return GPOINTER_TO_UINT (g_hash_table_lookup (self->priv->groups, href));
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_groups:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Gets a list of the groups to which the contact belongs.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (element-type utf8) (transfer container): a #GList of constant group ID URIs, or %NULL; free with g_list_free()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
GList *
Packit 4b6dd7
gdata_contacts_contact_get_groups (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	GHashTableIter iter;
Packit 4b6dd7
	const gchar *href;
Packit 4b6dd7
	gpointer value;
Packit 4b6dd7
	GList *groups = NULL;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
Packit 4b6dd7
	g_hash_table_iter_init (&iter, self->priv->groups);
Packit 4b6dd7
	while (g_hash_table_iter_next (&iter, (gpointer*) &href, &value) == TRUE) {
Packit 4b6dd7
		/* Add the group to the list as long as it hasn't been deleted */
Packit 4b6dd7
		if (GPOINTER_TO_UINT (value) == FALSE)
Packit 4b6dd7
			groups = g_list_prepend (groups, (gpointer) href);
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	return g_list_reverse (groups);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_is_deleted:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns whether the contact has recently been deleted. This will always return
Packit 4b6dd7
 * %FALSE unless #GDataContactsQuery:show-deleted has been set to
Packit 4b6dd7
 * %TRUE for the query which returned the contact; then this function will return
Packit 4b6dd7
 * %TRUE only if the contact has been deleted.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If a contact has been deleted, no other information is available about it. This
Packit 4b6dd7
 * is designed to allow contacts to be deleted from local address books using
Packit 4b6dd7
 * incremental updates from the server (e.g. with #GDataQuery:updated-min and
Packit 4b6dd7
 * #GDataContactsQuery:show-deleted).
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: %TRUE if the contact has been deleted, %FALSE otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.2.0
Packit 4b6dd7
 */
Packit 4b6dd7
gboolean
Packit 4b6dd7
gdata_contacts_contact_is_deleted (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), FALSE);
Packit 4b6dd7
	return self->priv->deleted;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_photo_etag:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 *
Packit 4b6dd7
 * Returns the ETag for the contact's attached photo, if it exists. If it does exist, the contact's photo can be retrieved using
Packit 4b6dd7
 * gdata_contacts_contact_get_photo(). If it doesn't exist, %NULL will be returned, and the contact doesn't have a photo (so calling
Packit 4b6dd7
 * gdata_contacts_contact_get_photo() will also return %NULL)
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: the contact's photo's ETag if it exists, %NULL otherwise
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.9.0
Packit 4b6dd7
 */
Packit 4b6dd7
const gchar *
Packit 4b6dd7
gdata_contacts_contact_get_photo_etag (GDataContactsContact *self)
Packit 4b6dd7
{
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	return self->priv->photo_etag;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_photo:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @service: a #GDataContactsService
Packit 4b6dd7
 * @length: (out caller-allocates): return location for the image length, in bytes
Packit 4b6dd7
 * @content_type: (out callee-allocates) (transfer full) (allow-none): return location for the image's content type, or %NULL; free with g_free()
Packit 4b6dd7
 * @cancellable: (allow-none): optional #GCancellable object, or %NULL
Packit 4b6dd7
 * @error: a #GError, or %NULL
Packit 4b6dd7
 *
Packit 4b6dd7
 * Downloads and returns the contact's photo, if they have one. If the contact doesn't
Packit 4b6dd7
 * have a photo (i.e. gdata_contacts_contact_get_photo_etag() returns %NULL), %NULL is returned, but
Packit 4b6dd7
 * no error is set in @error.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread.
Packit 4b6dd7
 * If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If there is an error getting the photo, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned.
Packit 4b6dd7
 *
Packit 4b6dd7
 * Return value: (transfer full) (array length=length): the image data, or %NULL; free with g_free()
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.8.0
Packit 4b6dd7
 */
Packit 4b6dd7
guint8 *
Packit 4b6dd7
gdata_contacts_contact_get_photo (GDataContactsContact *self, GDataContactsService *service, gsize *length, gchar **content_type,
Packit 4b6dd7
                                  GCancellable *cancellable, GError **error)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataLink *_link;
Packit 4b6dd7
	SoupMessage *message;
Packit 4b6dd7
	guint status;
Packit 4b6dd7
	guint8 *data;
Packit 4b6dd7
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_CONTACT (self), NULL);
Packit 4b6dd7
	g_return_val_if_fail (GDATA_IS_CONTACTS_SERVICE (service), NULL);
Packit 4b6dd7
	g_return_val_if_fail (length != NULL, NULL);
Packit 4b6dd7
	g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL);
Packit 4b6dd7
	g_return_val_if_fail (error == NULL || *error == NULL, NULL);
Packit 4b6dd7
Packit 4b6dd7
	/* Return if there is no photo */
Packit 4b6dd7
	if (gdata_contacts_contact_get_photo_etag (self) == NULL)
Packit 4b6dd7
		return NULL;
Packit 4b6dd7
Packit 4b6dd7
	/* Get the photo URI */
Packit 4b6dd7
	/* TODO: ETag support */
Packit 4b6dd7
	_link = gdata_entry_look_up_link (GDATA_ENTRY (self), "http://schemas.google.com/contacts/2008/rel#photo");
Packit 4b6dd7
	g_assert (_link != NULL);
Packit 4b6dd7
	message = _gdata_service_build_message (GDATA_SERVICE (service), gdata_contacts_service_get_primary_authorization_domain (),
Packit 4b6dd7
	                                        SOUP_METHOD_GET, gdata_link_get_uri (_link), NULL, FALSE);
Packit 4b6dd7
Packit 4b6dd7
	/* Send the message */
Packit 4b6dd7
	status = _gdata_service_send_message (GDATA_SERVICE (service), message, cancellable, error);
Packit 4b6dd7
Packit 4b6dd7
	if (status == SOUP_STATUS_NONE || status == SOUP_STATUS_CANCELLED) {
Packit 4b6dd7
		/* Redirect error or cancelled */
Packit 4b6dd7
		g_object_unref (message);
Packit 4b6dd7
		return NULL;
Packit 4b6dd7
	} else if (status != SOUP_STATUS_OK) {
Packit 4b6dd7
		/* Error */
Packit 4b6dd7
		GDataServiceClass *klass = GDATA_SERVICE_GET_CLASS (service);
Packit 4b6dd7
		g_assert (klass->parse_error_response != NULL);
Packit 4b6dd7
		klass->parse_error_response (GDATA_SERVICE (service), GDATA_OPERATION_DOWNLOAD, status, message->reason_phrase,
Packit 4b6dd7
		                             message->response_body->data, message->response_body->length, error);
Packit 4b6dd7
		g_object_unref (message);
Packit 4b6dd7
		return NULL;
Packit 4b6dd7
	}
Packit 4b6dd7
Packit 4b6dd7
	g_assert (message->response_body->data != NULL);
Packit 4b6dd7
Packit 4b6dd7
	/* Sort out the return values */
Packit 4b6dd7
	if (content_type != NULL)
Packit 4b6dd7
		*content_type = g_strdup (soup_message_headers_get_content_type (message->response_headers, NULL));
Packit 4b6dd7
	*length = message->response_body->length;
Packit 4b6dd7
	data = g_memdup (message->response_body->data, message->response_body->length);
Packit 4b6dd7
Packit 4b6dd7
	/* Update the stored photo ETag */
Packit 4b6dd7
	g_free (self->priv->photo_etag);
Packit 4b6dd7
	self->priv->photo_etag = g_strdup (soup_message_headers_get_one (message->response_headers, "ETag"));
Packit 4b6dd7
	g_object_unref (message);
Packit 4b6dd7
Packit 4b6dd7
	return data;
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
typedef struct {
Packit 4b6dd7
	GDataContactsService *service;
Packit 4b6dd7
	guint8 *data;
Packit 4b6dd7
	gsize length;
Packit 4b6dd7
	gchar *content_type;
Packit 4b6dd7
} PhotoData;
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
photo_data_free (PhotoData *data)
Packit 4b6dd7
{
Packit 4b6dd7
	if (data->service != NULL)
Packit 4b6dd7
		g_object_unref (data->service);
Packit 4b6dd7
	g_free (data->data);
Packit 4b6dd7
	g_free (data->content_type);
Packit 4b6dd7
	g_slice_free (PhotoData, data);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PhotoData, photo_data_free)
Packit 4b6dd7
Packit 4b6dd7
static void
Packit 4b6dd7
get_photo_thread (GTask *task, gpointer source_object, gpointer task_data, GCancellable *cancellable)
Packit 4b6dd7
{
Packit 4b6dd7
	GDataContactsContact *contact = GDATA_CONTACTS_CONTACT (source_object);
Packit 4b6dd7
	GDataContactsService *service = GDATA_CONTACTS_SERVICE (task_data);
Packit 4b6dd7
	g_autoptr(PhotoData) data = NULL;
Packit 4b6dd7
	g_autoptr(GError) error = NULL;
Packit 4b6dd7
Packit 4b6dd7
	/* Input and output */
Packit 4b6dd7
	data = g_slice_new0 (PhotoData);
Packit 4b6dd7
Packit 4b6dd7
	/* Get the photo */
Packit 4b6dd7
	data->data = gdata_contacts_contact_get_photo (contact, service, &(data->length), &(data->content_type), cancellable, &error);
Packit 4b6dd7
	if (error != NULL)
Packit 4b6dd7
		g_task_return_error (task, g_steal_pointer (&error));
Packit 4b6dd7
	else
Packit 4b6dd7
		g_task_return_pointer (task, g_steal_pointer (&data), (GDestroyNotify) photo_data_free);
Packit 4b6dd7
}
Packit 4b6dd7
Packit 4b6dd7
/**
Packit 4b6dd7
 * gdata_contacts_contact_get_photo_async:
Packit 4b6dd7
 * @self: a #GDataContactsContact
Packit 4b6dd7
 * @service: a #GDataContactsService
Packit 4b6dd7
 * @cancellable: (allow-none): optional #GCancellable object, or %NULL
Packit 4b6dd7
 * @callback: a #GAsyncReadyCallback to call when the photo has been retrieved, or %NULL
Packit 4b6dd7
 * @user_data: (closure): data to pass to the @callback function
Packit 4b6dd7
 *
Packit 4b6dd7
 * Downloads and returns the contact's photo, if they have one, asynchronously. @self and @service are both reffed when this function is called, so
Packit 4b6dd7
 * can safely be unreffed after this function returns.
Packit 4b6dd7
 *
Packit 4b6dd7
 * When the operation is finished, @callback will be called. You can then call gdata_contacts_contact_get_photo_finish() to get the results of the
Packit 4b6dd7
 * operation.
Packit 4b6dd7
 *
Packit 4b6dd7
 * For more details, see gdata_contacts_contact_get_photo(), which is the synchronous version of this function.
Packit 4b6dd7
 *
Packit 4b6dd7
 * If @cancellable is not %NULL, then the operation can be cancelled by triggering the @cancellable object from another thread.
Packit 4b6dd7
 * If the operation was cancelled, the error %G_IO_ERROR_CANCELLED will be returned by gdata_contacts_contact_get_photo_finish().
Packit 4b6dd7
 *
Packit 4b6dd7
 * If there is an error getting the photo, a %GDATA_SERVICE_ERROR_PROTOCOL_ERROR error will be returned by gdata_contacts_contact_get_photo_finish().
Packit 4b6dd7
 *
Packit 4b6dd7
 * Since: 0.8.0
Packit 4b6dd7
 */
Packit 4b6dd7
void
Packit 4b6dd7
gdata_contacts_contact_get_photo_async (GDataContactsContact *self, GDataContactsService *service, GCancellable *cancellable,
Packit