/* swf-persona.c generated by valac 0.26.2.1-1f25, the Vala compiler
 * generated from swf-persona.vala, do not modify */

/*
 * Copyright (C) 2010 Collabora Ltd.
 *
 * This library is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authors:
 *       Travis Reitter <travis.reitter@collabora.co.uk>
 *       Marco Barisione <marco.barisione@collabora.co.uk>
 */

#include <glib.h>
#include <glib-object.h>
#include <folks/folks.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <folks/small-set.h>
#include <gee.h>
#include <libsocialweb-client/libsocialweb-client-hack-for-vala.h>


#define SWF_TYPE_PERSONA (swf_persona_get_type ())
#define SWF_PERSONA(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWF_TYPE_PERSONA, SwfPersona))
#define SWF_PERSONA_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWF_TYPE_PERSONA, SwfPersonaClass))
#define SWF_IS_PERSONA(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWF_TYPE_PERSONA))
#define SWF_IS_PERSONA_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWF_TYPE_PERSONA))
#define SWF_PERSONA_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWF_TYPE_PERSONA, SwfPersonaClass))

typedef struct _SwfPersona SwfPersona;
typedef struct _SwfPersonaClass SwfPersonaClass;
typedef struct _SwfPersonaPrivate SwfPersonaPrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define __vala_SwContact_free0(var) ((var == NULL) ? NULL : (var = (_vala_SwContact_free (var), NULL)))
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define SWF_TYPE_PERSONA_STORE (swf_persona_store_get_type ())
#define SWF_PERSONA_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWF_TYPE_PERSONA_STORE, SwfPersonaStore))
#define SWF_PERSONA_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWF_TYPE_PERSONA_STORE, SwfPersonaStoreClass))
#define SWF_IS_PERSONA_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWF_TYPE_PERSONA_STORE))
#define SWF_IS_PERSONA_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWF_TYPE_PERSONA_STORE))
#define SWF_PERSONA_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SWF_TYPE_PERSONA_STORE, SwfPersonaStoreClass))

typedef struct _SwfPersonaStore SwfPersonaStore;
typedef struct _SwfPersonaStoreClass SwfPersonaStoreClass;

struct _SwfPersona {
	FolksPersona parent_instance;
	SwfPersonaPrivate * priv;
};

struct _SwfPersonaClass {
	FolksPersonaClass parent_class;
};

struct _SwfPersonaPrivate {
	GLoadableIcon* _avatar;
	FolksStructuredName* _structured_name;
	gchar* _full_name;
	gchar* _nickname;
	FolksGender _gender;
	FolksSmallSet* _urls;
	GeeSet* _urls_ro;
	GeeHashMultiMap* _im_addresses;
	GeeHashMultiMap* _web_service_addresses;
	SwContact* _lsw_contact;
};


static gpointer swf_persona_parent_class = NULL;
static gchar** swf_persona__writeable_properties;
static gint swf_persona__writeable_properties_length1;
static gchar** swf_persona__writeable_properties = NULL;
static gint swf_persona__writeable_properties_length1 = 0;
static gint _swf_persona__writeable_properties_size_ = 0;
static FolksAvatarDetailsIface* swf_persona_folks_avatar_details_parent_iface = NULL;
static FolksGenderDetailsIface* swf_persona_folks_gender_details_parent_iface = NULL;
static FolksImDetailsIface* swf_persona_folks_im_details_parent_iface = NULL;
static FolksNameDetailsIface* swf_persona_folks_name_details_parent_iface = NULL;
static FolksUrlDetailsIface* swf_persona_folks_url_details_parent_iface = NULL;
static FolksWebServiceDetailsIface* swf_persona_folks_web_service_details_parent_iface = NULL;

GType swf_persona_get_type (void) G_GNUC_CONST;
#define SWF_PERSONA_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), SWF_TYPE_PERSONA, SwfPersonaPrivate))
enum  {
	SWF_PERSONA_DUMMY_PROPERTY,
	SWF_PERSONA_LINKABLE_PROPERTIES,
	SWF_PERSONA_WRITEABLE_PROPERTIES,
	SWF_PERSONA_AVATAR,
	SWF_PERSONA_STRUCTURED_NAME,
	SWF_PERSONA_FULL_NAME,
	SWF_PERSONA_NICKNAME,
	SWF_PERSONA_GENDER,
	SWF_PERSONA_URLS,
	SWF_PERSONA_IM_ADDRESSES,
	SWF_PERSONA_WEB_SERVICE_ADDRESSES,
	SWF_PERSONA_LSW_CONTACT
};
static guint _folks_abstract_field_details_hash_static_gee_hash_data_func (gconstpointer v, gpointer self);
static gboolean _folks_abstract_field_details_equal_static_gee_equal_data_func (gconstpointer a, gconstpointer b, gpointer self);
static void _vala_SwContact_free (SwContact* self);
gchar* _swf_persona_build_facebook_jid (const gchar* store_id, const gchar* lsw_id);
gchar* _swf_persona_build_iid (const gchar* store_id, const gchar* lsw_id);
GType swf_persona_store_get_type (void) G_GNUC_CONST;
SwfPersona* swf_persona_new (SwfPersonaStore* store, SwContact* contact);
SwfPersona* swf_persona_construct (GType object_type, SwfPersonaStore* store, SwContact* contact);
gchar* swf_persona_get_contact_id (SwContact* contact);
void swf_persona_update (SwfPersona* self, SwContact* contact);
SwContact* swf_persona_get_lsw_contact (SwfPersona* self);
static void swf_persona_set_lsw_contact (SwfPersona* self, SwContact* value);
static SwContact* _vala_SwContact_copy (SwContact* self);
static GObject * swf_persona_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties);
static void swf_persona_finalize (GObject* obj);
static void _vala_swf_persona_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_swf_persona_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);

static const gchar* SWF_PERSONA__linkable_properties[3] = {"im-addresses", "web-service-addresses", NULL};

static guint _folks_abstract_field_details_hash_static_gee_hash_data_func (gconstpointer v, gpointer self) {
	guint result;
	result = folks_abstract_field_details_hash_static ((FolksAbstractFieldDetails*) v);
	return result;
}


static gboolean _folks_abstract_field_details_equal_static_gee_equal_data_func (gconstpointer a, gconstpointer b, gpointer self) {
	gboolean result;
	result = folks_abstract_field_details_equal_static ((FolksAbstractFieldDetails*) a, (FolksAbstractFieldDetails*) b);
	return result;
}


static void _vala_SwContact_free (SwContact* self) {
	g_boxed_free (sw_contact_get_type (), self);
}


/**
   * Build the Facebook JID.
   *
   * @param store_id the {@link PersonaStore.id}
   * @param lsw_id the lsw id
   * @return the Facebook JID or null if it is not a Facebook contact
   *
   * @since 0.5.0
   */
static gboolean string_contains (const gchar* self, const gchar* needle) {
	gboolean result = FALSE;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (needle != NULL, FALSE);
	_tmp0_ = needle;
	_tmp1_ = strstr ((gchar*) self, (gchar*) _tmp0_);
	result = _tmp1_ != NULL;
	return result;
}


static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
	gchar* result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	{
		GRegex* regex = NULL;
		const gchar* _tmp0_ = NULL;
		gchar* _tmp1_ = NULL;
		gchar* _tmp2_ = NULL;
		GRegex* _tmp3_ = NULL;
		GRegex* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		GRegex* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		_tmp0_ = old;
		_tmp1_ = g_regex_escape_string (_tmp0_, -1);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		regex = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp6_ = regex;
		_tmp7_ = replacement;
		_tmp8_ = g_regex_replace_literal (_tmp6_, self, (gssize) (-1), 0, _tmp7_, 0, &_inner_error_);
		_tmp5_ = _tmp8_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			_g_regex_unref0 (regex);
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
		_tmp9_ = _tmp5_;
		_tmp5_ = NULL;
		result = _tmp9_;
		_g_free0 (_tmp5_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return NULL;
	}
}


gchar* _swf_persona_build_facebook_jid (const gchar* store_id, const gchar* lsw_id) {
	gchar* result = NULL;
	gchar* facebook_jid = NULL;
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_ = NULL;
	g_return_val_if_fail (store_id != NULL, NULL);
	g_return_val_if_fail (lsw_id != NULL, NULL);
	facebook_jid = NULL;
	_tmp1_ = store_id;
	if (g_strcmp0 (_tmp1_, "facebook") == 0) {
		const gchar* _tmp2_ = NULL;
		gboolean _tmp3_ = FALSE;
		_tmp2_ = lsw_id;
		_tmp3_ = string_contains (_tmp2_, "facebook-");
		_tmp0_ = _tmp3_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		const gchar* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_ = NULL;
		gchar* _tmp7_ = NULL;
		_tmp4_ = lsw_id;
		_tmp5_ = string_replace (_tmp4_, "facebook", "");
		_tmp6_ = _tmp5_;
		_tmp7_ = g_strconcat (_tmp6_, "@chat.facebook.com", NULL);
		_g_free0 (facebook_jid);
		facebook_jid = _tmp7_;
		_g_free0 (_tmp6_);
	}
	result = facebook_jid;
	return result;
}


/**
   * Build a IID.
   *
   * @param store_id the {@link PersonaStore.id}
   * @param lsw_id the lsw id
   * @return a valid IID
   *
   * @since 0.5.0
   */
gchar* _swf_persona_build_iid (const gchar* store_id, const gchar* lsw_id) {
	gchar* result = NULL;
	gchar* facebook_jid = NULL;
	gchar* iid = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	g_return_val_if_fail (store_id != NULL, NULL);
	g_return_val_if_fail (lsw_id != NULL, NULL);
	facebook_jid = NULL;
	_tmp0_ = store_id;
	_tmp1_ = lsw_id;
	_tmp2_ = _swf_persona_build_facebook_jid (_tmp0_, _tmp1_);
	_g_free0 (facebook_jid);
	facebook_jid = _tmp2_;
	_tmp3_ = facebook_jid;
	if (_tmp3_ != NULL) {
		const gchar* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		_tmp4_ = facebook_jid;
		_tmp5_ = g_strconcat ("jabber:", _tmp4_, NULL);
		_g_free0 (iid);
		iid = _tmp5_;
	} else {
		const gchar* _tmp6_ = NULL;
		gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		const gchar* _tmp9_ = NULL;
		gchar* _tmp10_ = NULL;
		_tmp6_ = store_id;
		_tmp7_ = g_strconcat (_tmp6_, ":", NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = lsw_id;
		_tmp10_ = g_strconcat (_tmp8_, _tmp9_, NULL);
		_g_free0 (iid);
		iid = _tmp10_;
		_g_free0 (_tmp8_);
	}
	result = iid;
	_g_free0 (facebook_jid);
	return result;
}


/**
   * Create a new persona.
   *
   * Create a new persona for the {@link PersonaStore} ``store``, representing
   * the libsocialweb contact given by ``contact``.
   *
   * @param store the store which will contain the persona
   * @param contact the libsocialweb contact being represented by the new
   * persona
   */
SwfPersona* swf_persona_construct (GType object_type, SwfPersonaStore* store, SwContact* contact) {
	SwfPersona * self = NULL;
	gchar* id = NULL;
	SwContact* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	gchar* uid = NULL;
	SwfPersonaStore* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar* iid = NULL;
	SwfPersonaStore* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	gchar* _tmp9_ = NULL;
	SwfPersonaStore* _tmp10_ = NULL;
	SwContact* _tmp11_ = NULL;
	g_return_val_if_fail (store != NULL, NULL);
	g_return_val_if_fail (contact != NULL, NULL);
	_tmp0_ = contact;
	_tmp1_ = swf_persona_get_contact_id (_tmp0_);
	id = _tmp1_;
	_tmp2_ = store;
	_tmp3_ = folks_persona_store_get_id ((FolksPersonaStore*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = folks_persona_build_uid (BACKEND_NAME, _tmp4_, id);
	uid = _tmp5_;
	_tmp6_ = store;
	_tmp7_ = folks_persona_store_get_id ((FolksPersonaStore*) _tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = _swf_persona_build_iid (_tmp8_, id);
	iid = _tmp9_;
	_tmp10_ = store;
	_tmp11_ = contact;
	self = (SwfPersona*) g_object_new (object_type, "display-id", id, "uid", uid, "iid", iid, "store", _tmp10_, "is-user", FALSE, "lsw-contact", _tmp11_, NULL);
	_g_free0 (iid);
	_g_free0 (uid);
	_g_free0 (id);
	return self;
}


SwfPersona* swf_persona_new (SwfPersonaStore* store, SwContact* contact) {
	return swf_persona_construct (SWF_TYPE_PERSONA, store, contact);
}


/**
   * Get the ID of the libsocialweb contact.
   *
   * @param contact contact to return the ID from
   * @return ID of ``contact``
   *
   * @since 0.5.0
   */
gchar* swf_persona_get_contact_id (SwContact* contact) {
	gchar* result = NULL;
	SwContact* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	g_return_val_if_fail (contact != NULL, NULL);
	_tmp0_ = contact;
	_tmp1_ = sw_contact_get_value (_tmp0_, "id");
	_tmp2_ = g_strdup (_tmp1_);
	result = _tmp2_;
	return result;
}


/**
   * Update the persona from the given contact.
   *
   * This will update the values of all the persona's properties from the
   * properties of the given contact.
   *
   * @param contact contact to update the persona from
   *
   * @since 0.5.0
   */
static gpointer _g_object_ref0 (gpointer self) {
	return self ? g_object_ref (self) : NULL;
}


void swf_persona_update (SwfPersona* self, SwContact* contact) {
	gchar* nickname = NULL;
	SwContact* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	gchar* avatar_path = NULL;
	SwContact* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	gchar* _tmp11_ = NULL;
	const gchar* _tmp12_ = NULL;
	FolksStructuredName* structured_name = NULL;
	SwContact* _tmp25_ = NULL;
	const gchar* _tmp26_ = NULL;
	SwContact* _tmp27_ = NULL;
	const gchar* _tmp28_ = NULL;
	FolksStructuredName* _tmp29_ = NULL;
	FolksStructuredName* _tmp30_ = NULL;
	gboolean _tmp31_ = FALSE;
	gchar* full_name = NULL;
	SwContact* _tmp36_ = NULL;
	const gchar* _tmp37_ = NULL;
	gchar* _tmp38_ = NULL;
	const gchar* _tmp39_ = NULL;
	const gchar* _tmp41_ = NULL;
	const gchar* _tmp42_ = NULL;
	FolksSmallSet* urls = NULL;
	FolksSmallSet* _tmp45_ = NULL;
	gchar* website = NULL;
	SwContact* _tmp46_ = NULL;
	const gchar* _tmp47_ = NULL;
	gchar* _tmp48_ = NULL;
	const gchar* _tmp49_ = NULL;
	FolksSmallSet* _tmp54_ = NULL;
	FolksSmallSet* _tmp55_ = NULL;
	gchar* gender_string = NULL;
	SwContact* _tmp61_ = NULL;
	const gchar* _tmp62_ = NULL;
	gchar* _tmp63_ = NULL;
	FolksGender gender = 0;
	gboolean _tmp64_ = FALSE;
	const gchar* _tmp65_ = NULL;
	FolksGender _tmp74_ = 0;
	FolksGender _tmp75_ = 0;
	g_return_if_fail (self != NULL);
	g_return_if_fail (contact != NULL);
	_tmp0_ = contact;
	_tmp1_ = sw_contact_get_value (_tmp0_, "name");
	_tmp2_ = g_strdup (_tmp1_);
	nickname = _tmp2_;
	_tmp3_ = nickname;
	if (_tmp3_ == NULL) {
		gchar* _tmp4_ = NULL;
		_tmp4_ = g_strdup ("");
		_g_free0 (nickname);
		nickname = _tmp4_;
	}
	_tmp5_ = self->priv->_nickname;
	_tmp6_ = nickname;
	if (g_strcmp0 (_tmp5_, _tmp6_) != 0) {
		const gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		_tmp7_ = nickname;
		_tmp8_ = g_strdup (_tmp7_);
		_g_free0 (self->priv->_nickname);
		self->priv->_nickname = _tmp8_;
		g_object_notify ((GObject*) self, "nickname");
	}
	_tmp9_ = contact;
	_tmp10_ = sw_contact_get_value (_tmp9_, "icon");
	_tmp11_ = g_strdup (_tmp10_);
	avatar_path = _tmp11_;
	_tmp12_ = avatar_path;
	if (_tmp12_ != NULL) {
		GFileIcon* icon = NULL;
		const gchar* _tmp13_ = NULL;
		GFile* _tmp14_ = NULL;
		GFile* _tmp15_ = NULL;
		GFileIcon* _tmp16_ = NULL;
		GFileIcon* _tmp17_ = NULL;
		gboolean _tmp18_ = FALSE;
		GLoadableIcon* _tmp19_ = NULL;
		_tmp13_ = avatar_path;
		_tmp14_ = g_file_new_for_path (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = (GFileIcon*) g_file_icon_new (_tmp15_);
		_tmp17_ = _tmp16_;
		_g_object_unref0 (_tmp15_);
		icon = _tmp17_;
		_tmp19_ = self->priv->_avatar;
		if (_tmp19_ == NULL) {
			_tmp18_ = TRUE;
		} else {
			GLoadableIcon* _tmp20_ = NULL;
			GFileIcon* _tmp21_ = NULL;
			gboolean _tmp22_ = FALSE;
			_tmp20_ = self->priv->_avatar;
			_tmp21_ = icon;
			_tmp22_ = g_icon_equal ((GIcon*) _tmp20_, (GIcon*) _tmp21_);
			_tmp18_ = !_tmp22_;
		}
		if (_tmp18_) {
			GFileIcon* _tmp23_ = NULL;
			GLoadableIcon* _tmp24_ = NULL;
			_tmp23_ = icon;
			_tmp24_ = _g_object_ref0 ((GLoadableIcon*) _tmp23_);
			_g_object_unref0 (self->priv->_avatar);
			self->priv->_avatar = _tmp24_;
			g_object_notify ((GObject*) self, "avatar");
		}
		_g_object_unref0 (icon);
	} else {
		_g_object_unref0 (self->priv->_avatar);
		self->priv->_avatar = NULL;
		g_object_notify ((GObject*) self, "avatar");
	}
	_tmp25_ = contact;
	_tmp26_ = sw_contact_get_value (_tmp25_, "n.family");
	_tmp27_ = contact;
	_tmp28_ = sw_contact_get_value (_tmp27_, "n.given");
	_tmp29_ = folks_structured_name_new_simple (_tmp26_, _tmp28_);
	structured_name = _tmp29_;
	_tmp30_ = structured_name;
	_tmp31_ = folks_structured_name_is_empty (_tmp30_);
	if (!_tmp31_) {
		FolksStructuredName* _tmp32_ = NULL;
		FolksStructuredName* _tmp33_ = NULL;
		_tmp32_ = structured_name;
		_tmp33_ = _g_object_ref0 (_tmp32_);
		_g_object_unref0 (self->priv->_structured_name);
		self->priv->_structured_name = _tmp33_;
		g_object_notify ((GObject*) self, "structured-name");
	} else {
		FolksStructuredName* _tmp34_ = NULL;
		FolksStructuredName* _tmp35_ = NULL;
		_tmp34_ = folks_name_details_get_structured_name ((FolksNameDetails*) self);
		_tmp35_ = _tmp34_;
		if (_tmp35_ != NULL) {
			_g_object_unref0 (self->priv->_structured_name);
			self->priv->_structured_name = NULL;
			g_object_notify ((GObject*) self, "structured-name");
		}
	}
	_tmp36_ = contact;
	_tmp37_ = sw_contact_get_value (_tmp36_, "fn");
	_tmp38_ = g_strdup (_tmp37_);
	full_name = _tmp38_;
	_tmp39_ = full_name;
	if (_tmp39_ == NULL) {
		gchar* _tmp40_ = NULL;
		_tmp40_ = g_strdup ("");
		_g_free0 (full_name);
		full_name = _tmp40_;
	}
	_tmp41_ = self->priv->_full_name;
	_tmp42_ = full_name;
	if (g_strcmp0 (_tmp41_, _tmp42_) != 0) {
		const gchar* _tmp43_ = NULL;
		gchar* _tmp44_ = NULL;
		_tmp43_ = full_name;
		_tmp44_ = g_strdup (_tmp43_);
		_g_free0 (self->priv->_full_name);
		self->priv->_full_name = _tmp44_;
		g_object_notify ((GObject*) self, "full-name");
	}
	_tmp45_ = folks_small_set_new (FOLKS_TYPE_URL_FIELD_DETAILS, (GBoxedCopyFunc) g_object_ref, g_object_unref, _folks_abstract_field_details_hash_static_gee_hash_data_func, NULL, NULL, _folks_abstract_field_details_equal_static_gee_equal_data_func, NULL, NULL);
	urls = _tmp45_;
	_tmp46_ = contact;
	_tmp47_ = sw_contact_get_value (_tmp46_, "url");
	_tmp48_ = g_strdup (_tmp47_);
	website = _tmp48_;
	_tmp49_ = website;
	if (_tmp49_ != NULL) {
		FolksSmallSet* _tmp50_ = NULL;
		const gchar* _tmp51_ = NULL;
		FolksUrlFieldDetails* _tmp52_ = NULL;
		FolksUrlFieldDetails* _tmp53_ = NULL;
		_tmp50_ = urls;
		_tmp51_ = website;
		_tmp52_ = folks_url_field_details_new (_tmp51_, NULL);
		_tmp53_ = _tmp52_;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp50_, _tmp53_);
		_g_object_unref0 (_tmp53_);
	}
	_tmp54_ = self->priv->_urls;
	_tmp55_ = urls;
	if (_tmp54_ != _tmp55_) {
		FolksSmallSet* _tmp56_ = NULL;
		FolksSmallSet* _tmp57_ = NULL;
		FolksSmallSet* _tmp58_ = NULL;
		GeeSet* _tmp59_ = NULL;
		GeeSet* _tmp60_ = NULL;
		_tmp56_ = urls;
		_tmp57_ = _g_object_ref0 (_tmp56_);
		_g_object_unref0 (self->priv->_urls);
		self->priv->_urls = _tmp57_;
		_tmp58_ = urls;
		_tmp59_ = gee_abstract_set_get_read_only_view ((GeeAbstractSet*) _tmp58_);
		_tmp60_ = _tmp59_;
		_g_object_unref0 (self->priv->_urls_ro);
		self->priv->_urls_ro = _tmp60_;
		g_object_notify ((GObject*) self, "urls");
	}
	_tmp61_ = contact;
	_tmp62_ = sw_contact_get_value (_tmp61_, "x-gender");
	_tmp63_ = g_strdup (_tmp62_);
	gender_string = _tmp63_;
	_tmp65_ = gender_string;
	if (_tmp65_ != NULL) {
		const gchar* _tmp66_ = NULL;
		gchar* _tmp67_ = NULL;
		gchar* _tmp68_ = NULL;
		_tmp66_ = gender_string;
		_tmp67_ = g_utf8_strdown (_tmp66_, (gssize) (-1));
		_tmp68_ = _tmp67_;
		_tmp64_ = g_strcmp0 (_tmp68_, "male") == 0;
		_g_free0 (_tmp68_);
	} else {
		_tmp64_ = FALSE;
	}
	if (_tmp64_) {
		gender = FOLKS_GENDER_MALE;
	} else {
		gboolean _tmp69_ = FALSE;
		const gchar* _tmp70_ = NULL;
		_tmp70_ = gender_string;
		if (_tmp70_ != NULL) {
			const gchar* _tmp71_ = NULL;
			gchar* _tmp72_ = NULL;
			gchar* _tmp73_ = NULL;
			_tmp71_ = gender_string;
			_tmp72_ = g_utf8_strdown (_tmp71_, (gssize) (-1));
			_tmp73_ = _tmp72_;
			_tmp69_ = g_strcmp0 (_tmp73_, "female") == 0;
			_g_free0 (_tmp73_);
		} else {
			_tmp69_ = FALSE;
		}
		if (_tmp69_) {
			gender = FOLKS_GENDER_FEMALE;
		} else {
			gender = FOLKS_GENDER_UNSPECIFIED;
		}
	}
	_tmp74_ = self->priv->_gender;
	_tmp75_ = gender;
	if (_tmp74_ != _tmp75_) {
		FolksGender _tmp76_ = 0;
		_tmp76_ = gender;
		self->priv->_gender = _tmp76_;
		g_object_notify ((GObject*) self, "gender");
	}
	_g_free0 (gender_string);
	_g_free0 (website);
	_g_object_unref0 (urls);
	_g_free0 (full_name);
	_g_object_unref0 (structured_name);
	_g_free0 (avatar_path);
	_g_free0 (nickname);
}


static gchar** swf_persona_real_get_linkable_properties (FolksPersona* base, int* result_length1) {
	gchar** result;
	SwfPersona* self;
	gchar** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	self = (SwfPersona*) base;
	_tmp0_ = SWF_PERSONA__linkable_properties;
	_tmp0__length1 = G_N_ELEMENTS (SWF_PERSONA__linkable_properties);
	if (result_length1) {
		*result_length1 = _tmp0__length1;
	}
	result = _tmp0_;
	return result;
}


static gchar** swf_persona_real_get_writeable_properties (FolksPersona* base, int* result_length1) {
	gchar** result;
	SwfPersona* self;
	gchar** _tmp0_ = NULL;
	gint _tmp0__length1 = 0;
	gchar** _tmp1_ = NULL;
	gint _tmp1__length1 = 0;
	self = (SwfPersona*) base;
	_tmp0_ = swf_persona__writeable_properties;
	_tmp0__length1 = swf_persona__writeable_properties_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}


static GLoadableIcon* swf_persona_real_get_avatar (FolksAvatarDetails* base) {
	GLoadableIcon* result;
	SwfPersona* self;
	GLoadableIcon* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = self->priv->_avatar;
	result = _tmp0_;
	return result;
}


static void swf_persona_real_set_avatar (FolksAvatarDetails* base, GLoadableIcon* value) {
	SwfPersona* self;
	GLoadableIcon* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = value;
	folks_avatar_details_change_avatar ((FolksAvatarDetails*) self, _tmp0_, NULL, NULL);
}


static FolksStructuredName* swf_persona_real_get_structured_name (FolksNameDetails* base) {
	FolksStructuredName* result;
	SwfPersona* self;
	FolksStructuredName* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = self->priv->_structured_name;
	result = _tmp0_;
	return result;
}


static void swf_persona_real_set_structured_name (FolksNameDetails* base, FolksStructuredName* value) {
	SwfPersona* self;
	FolksStructuredName* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = value;
	folks_name_details_change_structured_name ((FolksNameDetails*) self, _tmp0_, NULL, NULL);
}


static const gchar* swf_persona_real_get_full_name (FolksNameDetails* base) {
	const gchar* result;
	SwfPersona* self;
	const gchar* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = self->priv->_full_name;
	result = _tmp0_;
	return result;
}


static void swf_persona_real_set_full_name (FolksNameDetails* base, const gchar* value) {
	SwfPersona* self;
	const gchar* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = value;
	folks_name_details_change_full_name ((FolksNameDetails*) self, _tmp0_, NULL, NULL);
}


static const gchar* swf_persona_real_get_nickname (FolksNameDetails* base) {
	const gchar* result;
	SwfPersona* self;
	const gchar* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = self->priv->_nickname;
	result = _tmp0_;
	return result;
}


static void swf_persona_real_set_nickname (FolksNameDetails* base, const gchar* value) {
	SwfPersona* self;
	const gchar* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = value;
	folks_name_details_change_nickname ((FolksNameDetails*) self, _tmp0_, NULL, NULL);
}


static FolksGender swf_persona_real_get_gender (FolksGenderDetails* base) {
	FolksGender result;
	SwfPersona* self;
	FolksGender _tmp0_ = 0;
	self = (SwfPersona*) base;
	_tmp0_ = self->priv->_gender;
	result = _tmp0_;
	return result;
}


static void swf_persona_real_set_gender (FolksGenderDetails* base, FolksGender value) {
	SwfPersona* self;
	FolksGender _tmp0_ = 0;
	self = (SwfPersona*) base;
	_tmp0_ = value;
	folks_gender_details_change_gender ((FolksGenderDetails*) self, _tmp0_, NULL, NULL);
}


static GeeSet* swf_persona_real_get_urls (FolksUrlDetails* base) {
	GeeSet* result;
	SwfPersona* self;
	GeeSet* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = self->priv->_urls_ro;
	result = _tmp0_;
	return result;
}


static void swf_persona_real_set_urls (FolksUrlDetails* base, GeeSet* value) {
	SwfPersona* self;
	GeeSet* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = value;
	folks_url_details_change_urls ((FolksUrlDetails*) self, _tmp0_, NULL, NULL);
}


static GeeMultiMap* swf_persona_real_get_im_addresses (FolksImDetails* base) {
	GeeMultiMap* result;
	SwfPersona* self;
	GeeHashMultiMap* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = self->priv->_im_addresses;
	result = (GeeMultiMap*) _tmp0_;
	return result;
}


static void swf_persona_real_set_im_addresses (FolksImDetails* base, GeeMultiMap* value) {
	SwfPersona* self;
	GeeMultiMap* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = value;
	folks_im_details_change_im_addresses ((FolksImDetails*) self, _tmp0_, NULL, NULL);
}


static GeeMultiMap* swf_persona_real_get_web_service_addresses (FolksWebServiceDetails* base) {
	GeeMultiMap* result;
	SwfPersona* self;
	GeeHashMultiMap* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = self->priv->_web_service_addresses;
	result = (GeeMultiMap*) _tmp0_;
	return result;
}


static void swf_persona_real_set_web_service_addresses (FolksWebServiceDetails* base, GeeMultiMap* value) {
	SwfPersona* self;
	GeeMultiMap* _tmp0_ = NULL;
	self = (SwfPersona*) base;
	_tmp0_ = value;
	folks_web_service_details_change_web_service_addresses ((FolksWebServiceDetails*) self, _tmp0_, NULL, NULL);
}


SwContact* swf_persona_get_lsw_contact (SwfPersona* self) {
	SwContact* result;
	SwContact* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_lsw_contact;
	result = _tmp0_;
	return result;
}


static SwContact* _vala_SwContact_copy (SwContact* self) {
	return g_boxed_copy (sw_contact_get_type (), self);
}


static gpointer __vala_SwContact_copy0 (gpointer self) {
	return self ? _vala_SwContact_copy (self) : NULL;
}


static void swf_persona_set_lsw_contact (SwfPersona* self, SwContact* value) {
	SwContact* _tmp0_ = NULL;
	SwContact* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = __vala_SwContact_copy0 (_tmp0_);
	__vala_SwContact_free0 (self->priv->_lsw_contact);
	self->priv->_lsw_contact = _tmp1_;
	g_object_notify ((GObject *) self, "lsw-contact");
}


static GObject * swf_persona_constructor (GType type, guint n_construct_properties, GObjectConstructParam * construct_properties) {
	GObject * obj;
	GObjectClass * parent_class;
	SwfPersona * self;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	FolksPersonaStore* _tmp2_ = NULL;
	FolksPersonaStore* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	const gchar* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	const gchar* _tmp7_ = NULL;
	gchar* facebook_jid = NULL;
	FolksPersonaStore* _tmp8_ = NULL;
	FolksPersonaStore* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	const gchar* _tmp11_ = NULL;
	const gchar* _tmp12_ = NULL;
	const gchar* _tmp13_ = NULL;
	gchar* _tmp14_ = NULL;
	const gchar* _tmp15_ = NULL;
	gchar* service = NULL;
	SwContact* _tmp26_ = NULL;
	SwContact* _tmp27_ = NULL;
	const gchar* _tmp28_ = NULL;
	gchar* _tmp29_ = NULL;
	GeeHashMultiMap* _tmp30_ = NULL;
	const gchar* _tmp31_ = NULL;
	const gchar* _tmp32_ = NULL;
	const gchar* _tmp33_ = NULL;
	FolksWebServiceFieldDetails* _tmp34_ = NULL;
	FolksWebServiceFieldDetails* _tmp35_ = NULL;
	SwContact* _tmp36_ = NULL;
	SwContact* _tmp37_ = NULL;
	GError * _inner_error_ = NULL;
	parent_class = G_OBJECT_CLASS (swf_persona_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWF_TYPE_PERSONA, SwfPersona);
	_tmp0_ = folks_persona_get_uid ((FolksPersona*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = folks_persona_get_store ((FolksPersona*) self);
	_tmp3_ = _tmp2_;
	_tmp4_ = folks_persona_store_get_display_name (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = folks_persona_get_display_id ((FolksPersona*) self);
	_tmp7_ = _tmp6_;
	g_debug ("swf-persona.vala:273: Creating new Sw.Persona '%s' for %s UID '%s': %p", _tmp1_, _tmp5_, _tmp7_, self);
	_tmp8_ = folks_persona_get_store ((FolksPersona*) self);
	_tmp9_ = _tmp8_;
	_tmp10_ = folks_persona_store_get_id (_tmp9_);
	_tmp11_ = _tmp10_;
	_tmp12_ = folks_persona_get_display_id ((FolksPersona*) self);
	_tmp13_ = _tmp12_;
	_tmp14_ = _swf_persona_build_facebook_jid (_tmp11_, _tmp13_);
	facebook_jid = _tmp14_;
	_tmp15_ = facebook_jid;
	if (_tmp15_ != NULL) {
		{
			gchar* normalised_addr = NULL;
			const gchar* _tmp16_ = NULL;
			gchar* _tmp17_ = NULL;
			gchar* im_proto = NULL;
			gchar* _tmp18_ = NULL;
			FolksImFieldDetails* im_fd = NULL;
			const gchar* _tmp19_ = NULL;
			FolksImFieldDetails* _tmp20_ = NULL;
			GeeHashMultiMap* _tmp21_ = NULL;
			const gchar* _tmp22_ = NULL;
			FolksImFieldDetails* _tmp23_ = NULL;
			_tmp16_ = facebook_jid;
			_tmp17_ = folks_im_details_normalise_im_address (_tmp16_, "jabber", &_inner_error_);
			normalised_addr = _tmp17_;
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				if (_inner_error_->domain == FOLKS_IM_DETAILS_ERROR) {
					goto __catch1_folks_im_details_error;
				}
				_g_free0 (facebook_jid);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
			}
			_tmp18_ = g_strdup ("jabber");
			im_proto = _tmp18_;
			_tmp19_ = normalised_addr;
			_tmp20_ = folks_im_field_details_new (_tmp19_, NULL);
			im_fd = _tmp20_;
			_tmp21_ = self->priv->_im_addresses;
			_tmp22_ = im_proto;
			_tmp23_ = im_fd;
			gee_multi_map_set ((GeeMultiMap*) _tmp21_, _tmp22_, _tmp23_);
			_g_object_unref0 (im_fd);
			_g_free0 (im_proto);
			_g_free0 (normalised_addr);
		}
		goto __finally1;
		__catch1_folks_im_details_error:
		{
			GError* e = NULL;
			GError* _tmp24_ = NULL;
			const gchar* _tmp25_ = NULL;
			e = _inner_error_;
			_inner_error_ = NULL;
			_tmp24_ = e;
			_tmp25_ = _tmp24_->message;
			g_warning ("swf-persona.vala:291: %s", _tmp25_);
			_g_error_free0 (e);
		}
		__finally1:
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_free0 (facebook_jid);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
		}
	}
	_tmp26_ = swf_persona_get_lsw_contact (self);
	_tmp27_ = _tmp26_;
	_tmp28_ = _tmp27_->service;
	_tmp29_ = g_strdup (_tmp28_);
	service = _tmp29_;
	_tmp30_ = self->priv->_web_service_addresses;
	_tmp31_ = service;
	_tmp32_ = folks_persona_get_display_id ((FolksPersona*) self);
	_tmp33_ = _tmp32_;
	_tmp34_ = folks_web_service_field_details_new (_tmp33_, NULL);
	_tmp35_ = _tmp34_;
	gee_multi_map_set ((GeeMultiMap*) _tmp30_, _tmp31_, _tmp35_);
	_g_object_unref0 (_tmp35_);
	_tmp36_ = swf_persona_get_lsw_contact (self);
	_tmp37_ = _tmp36_;
	swf_persona_update (self, _tmp37_);
	_g_free0 (service);
	_g_free0 (facebook_jid);
	return obj;
}


static void swf_persona_class_init (SwfPersonaClass * klass) {
	gchar** _tmp0_ = NULL;
	swf_persona_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (SwfPersonaPrivate));
	FOLKS_PERSONA_CLASS (klass)->get_linkable_properties = swf_persona_real_get_linkable_properties;
	FOLKS_PERSONA_CLASS (klass)->get_writeable_properties = swf_persona_real_get_writeable_properties;
	G_OBJECT_CLASS (klass)->get_property = _vala_swf_persona_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_swf_persona_set_property;
	G_OBJECT_CLASS (klass)->constructor = swf_persona_constructor;
	G_OBJECT_CLASS (klass)->finalize = swf_persona_finalize;
	/**
	   * The names of the Persona's linkable properties.
	   *
	   * See {@link Folks.Persona.linkable_properties}.
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_LINKABLE_PROPERTIES, g_param_spec_boxed ("linkable-properties", "linkable-properties", "linkable-properties", G_TYPE_STRV, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	   * {@inheritDoc}
	   *
	   * @since 0.6.0
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_WRITEABLE_PROPERTIES, g_param_spec_boxed ("writeable-properties", "writeable-properties", "writeable-properties", G_TYPE_STRV, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	/**
	   * An avatar for the Persona.
	   *
	   * See {@link Folks.AvatarDetails.avatar}.
	   *
	   * @since 0.6.0
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_AVATAR, g_param_spec_object ("avatar", "avatar", "avatar", g_loadable_icon_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * {@inheritDoc}
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_STRUCTURED_NAME, g_param_spec_object ("structured-name", "structured-name", "structured-name", FOLKS_TYPE_STRUCTURED_NAME, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * {@inheritDoc}
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_FULL_NAME, g_param_spec_string ("full-name", "full-name", "full-name", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * {@inheritDoc}
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_NICKNAME, g_param_spec_string ("nickname", "nickname", "nickname", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * {@inheritDoc}
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_GENDER, g_param_spec_enum ("gender", "gender", "gender", FOLKS_TYPE_GENDER, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * {@inheritDoc}
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_URLS, g_param_spec_object ("urls", "urls", "urls", GEE_TYPE_SET, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * {@inheritDoc}
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_IM_ADDRESSES, g_param_spec_object ("im-addresses", "im-addresses", "im-addresses", GEE_TYPE_MULTI_MAP, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * {@inheritDoc}
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_WEB_SERVICE_ADDRESSES, g_param_spec_object ("web-service-addresses", "web-service-addresses", "web-service-addresses", GEE_TYPE_MULTI_MAP, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	   * The Contact from libsocialweb
	   */
	g_object_class_install_property (G_OBJECT_CLASS (klass), SWF_PERSONA_LSW_CONTACT, g_param_spec_boxed ("lsw-contact", "lsw-contact", "lsw-contact", sw_contact_get_type (), G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	_tmp0_ = g_new0 (gchar*, 0 + 1);
	swf_persona__writeable_properties = _tmp0_;
	swf_persona__writeable_properties_length1 = 0;
}


static void swf_persona_folks_avatar_details_interface_init (FolksAvatarDetailsIface * iface) {
	swf_persona_folks_avatar_details_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_avatar = swf_persona_real_get_avatar;
	iface->set_avatar = swf_persona_real_set_avatar;
}


static void swf_persona_folks_gender_details_interface_init (FolksGenderDetailsIface * iface) {
	swf_persona_folks_gender_details_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_gender = swf_persona_real_get_gender;
	iface->set_gender = swf_persona_real_set_gender;
}


static void swf_persona_folks_im_details_interface_init (FolksImDetailsIface * iface) {
	swf_persona_folks_im_details_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_im_addresses = swf_persona_real_get_im_addresses;
	iface->set_im_addresses = swf_persona_real_set_im_addresses;
}


static void swf_persona_folks_name_details_interface_init (FolksNameDetailsIface * iface) {
	swf_persona_folks_name_details_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_structured_name = swf_persona_real_get_structured_name;
	iface->set_structured_name = swf_persona_real_set_structured_name;
	iface->get_full_name = swf_persona_real_get_full_name;
	iface->set_full_name = swf_persona_real_set_full_name;
	iface->get_nickname = swf_persona_real_get_nickname;
	iface->set_nickname = swf_persona_real_set_nickname;
}


static void swf_persona_folks_url_details_interface_init (FolksUrlDetailsIface * iface) {
	swf_persona_folks_url_details_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_urls = swf_persona_real_get_urls;
	iface->set_urls = swf_persona_real_set_urls;
}


static void swf_persona_folks_web_service_details_interface_init (FolksWebServiceDetailsIface * iface) {
	swf_persona_folks_web_service_details_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_web_service_addresses = swf_persona_real_get_web_service_addresses;
	iface->set_web_service_addresses = swf_persona_real_set_web_service_addresses;
}


static void swf_persona_instance_init (SwfPersona * self) {
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	GeeHashMultiMap* _tmp2_ = NULL;
	GeeHashMultiMap* _tmp3_ = NULL;
	self->priv = SWF_PERSONA_GET_PRIVATE (self);
	self->priv->_avatar = NULL;
	self->priv->_structured_name = NULL;
	_tmp0_ = g_strdup ("");
	self->priv->_full_name = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_nickname = _tmp1_;
	self->priv->_gender = FOLKS_GENDER_UNSPECIFIED;
	_tmp2_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, FOLKS_TYPE_IM_FIELD_DETAILS, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, _folks_abstract_field_details_hash_static_gee_hash_data_func, NULL, NULL, _folks_abstract_field_details_equal_static_gee_equal_data_func, NULL, NULL);
	self->priv->_im_addresses = _tmp2_;
	_tmp3_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, FOLKS_TYPE_WEB_SERVICE_FIELD_DETAILS, (GBoxedCopyFunc) g_object_ref, g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, _folks_abstract_field_details_hash_static_gee_hash_data_func, NULL, NULL, _folks_abstract_field_details_equal_static_gee_equal_data_func, NULL, NULL);
	self->priv->_web_service_addresses = _tmp3_;
	self->priv->_lsw_contact = NULL;
}


static void swf_persona_finalize (GObject* obj) {
	SwfPersona * self;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SWF_TYPE_PERSONA, SwfPersona);
	_tmp0_ = folks_persona_get_uid ((FolksPersona*) self);
	_tmp1_ = _tmp0_;
	g_debug ("swf-persona.vala:304: Destroying Sw.Persona '%s': %p", _tmp1_, self);
	_g_object_unref0 (self->priv->_avatar);
	_g_object_unref0 (self->priv->_structured_name);
	_g_free0 (self->priv->_full_name);
	_g_free0 (self->priv->_nickname);
	_g_object_unref0 (self->priv->_urls);
	_g_object_unref0 (self->priv->_urls_ro);
	_g_object_unref0 (self->priv->_im_addresses);
	_g_object_unref0 (self->priv->_web_service_addresses);
	__vala_SwContact_free0 (self->priv->_lsw_contact);
	G_OBJECT_CLASS (swf_persona_parent_class)->finalize (obj);
}


/**
 * A persona subclass which represents a single libsocialweb contact.
 *
 * There is a one-to-one correspondence between {@link Swf.Persona}s and
 * {@link SocialWebClient.Contact}s.
 */
GType swf_persona_get_type (void) {
	static volatile gsize swf_persona_type_id__volatile = 0;
	if (g_once_init_enter (&swf_persona_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (SwfPersonaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) swf_persona_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SwfPersona), 0, (GInstanceInitFunc) swf_persona_instance_init, NULL };
		static const GInterfaceInfo folks_avatar_details_info = { (GInterfaceInitFunc) swf_persona_folks_avatar_details_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		static const GInterfaceInfo folks_gender_details_info = { (GInterfaceInitFunc) swf_persona_folks_gender_details_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		static const GInterfaceInfo folks_im_details_info = { (GInterfaceInitFunc) swf_persona_folks_im_details_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		static const GInterfaceInfo folks_name_details_info = { (GInterfaceInitFunc) swf_persona_folks_name_details_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		static const GInterfaceInfo folks_url_details_info = { (GInterfaceInitFunc) swf_persona_folks_url_details_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		static const GInterfaceInfo folks_web_service_details_info = { (GInterfaceInitFunc) swf_persona_folks_web_service_details_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType swf_persona_type_id;
		swf_persona_type_id = g_type_register_static (FOLKS_TYPE_PERSONA, "SwfPersona", &g_define_type_info, 0);
		g_type_add_interface_static (swf_persona_type_id, FOLKS_TYPE_AVATAR_DETAILS, &folks_avatar_details_info);
		g_type_add_interface_static (swf_persona_type_id, FOLKS_TYPE_GENDER_DETAILS, &folks_gender_details_info);
		g_type_add_interface_static (swf_persona_type_id, FOLKS_TYPE_IM_DETAILS, &folks_im_details_info);
		g_type_add_interface_static (swf_persona_type_id, FOLKS_TYPE_NAME_DETAILS, &folks_name_details_info);
		g_type_add_interface_static (swf_persona_type_id, FOLKS_TYPE_URL_DETAILS, &folks_url_details_info);
		g_type_add_interface_static (swf_persona_type_id, FOLKS_TYPE_WEB_SERVICE_DETAILS, &folks_web_service_details_info);
		g_once_init_leave (&swf_persona_type_id__volatile, swf_persona_type_id);
	}
	return swf_persona_type_id__volatile;
}


static void _vala_swf_persona_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	SwfPersona * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SWF_TYPE_PERSONA, SwfPersona);
	switch (property_id) {
		case SWF_PERSONA_LINKABLE_PROPERTIES:
		{
			int length;
			g_value_set_boxed (value, folks_persona_get_linkable_properties ((FolksPersona*) self, &length));
		}
		break;
		case SWF_PERSONA_WRITEABLE_PROPERTIES:
		{
			int length;
			g_value_set_boxed (value, folks_persona_get_writeable_properties ((FolksPersona*) self, &length));
		}
		break;
		case SWF_PERSONA_AVATAR:
		g_value_set_object (value, folks_avatar_details_get_avatar ((FolksAvatarDetails*) self));
		break;
		case SWF_PERSONA_STRUCTURED_NAME:
		g_value_set_object (value, folks_name_details_get_structured_name ((FolksNameDetails*) self));
		break;
		case SWF_PERSONA_FULL_NAME:
		g_value_set_string (value, folks_name_details_get_full_name ((FolksNameDetails*) self));
		break;
		case SWF_PERSONA_NICKNAME:
		g_value_set_string (value, folks_name_details_get_nickname ((FolksNameDetails*) self));
		break;
		case SWF_PERSONA_GENDER:
		g_value_set_enum (value, folks_gender_details_get_gender ((FolksGenderDetails*) self));
		break;
		case SWF_PERSONA_URLS:
		g_value_set_object (value, folks_url_details_get_urls ((FolksUrlDetails*) self));
		break;
		case SWF_PERSONA_IM_ADDRESSES:
		g_value_set_object (value, folks_im_details_get_im_addresses ((FolksImDetails*) self));
		break;
		case SWF_PERSONA_WEB_SERVICE_ADDRESSES:
		g_value_set_object (value, folks_web_service_details_get_web_service_addresses ((FolksWebServiceDetails*) self));
		break;
		case SWF_PERSONA_LSW_CONTACT:
		g_value_set_boxed (value, swf_persona_get_lsw_contact (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_swf_persona_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	SwfPersona * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SWF_TYPE_PERSONA, SwfPersona);
	switch (property_id) {
		case SWF_PERSONA_AVATAR:
		folks_avatar_details_set_avatar ((FolksAvatarDetails*) self, g_value_get_object (value));
		break;
		case SWF_PERSONA_STRUCTURED_NAME:
		folks_name_details_set_structured_name ((FolksNameDetails*) self, g_value_get_object (value));
		break;
		case SWF_PERSONA_FULL_NAME:
		folks_name_details_set_full_name ((FolksNameDetails*) self, g_value_get_string (value));
		break;
		case SWF_PERSONA_NICKNAME:
		folks_name_details_set_nickname ((FolksNameDetails*) self, g_value_get_string (value));
		break;
		case SWF_PERSONA_GENDER:
		folks_gender_details_set_gender ((FolksGenderDetails*) self, g_value_get_enum (value));
		break;
		case SWF_PERSONA_URLS:
		folks_url_details_set_urls ((FolksUrlDetails*) self, g_value_get_object (value));
		break;
		case SWF_PERSONA_IM_ADDRESSES:
		folks_im_details_set_im_addresses ((FolksImDetails*) self, g_value_get_object (value));
		break;
		case SWF_PERSONA_WEB_SERVICE_ADDRESSES:
		folks_web_service_details_set_web_service_addresses ((FolksWebServiceDetails*) self, g_value_get_object (value));
		break;
		case SWF_PERSONA_LSW_CONTACT:
		swf_persona_set_lsw_contact (self, g_value_get_boxed (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



