/* contacts-structured-name-chunk.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from contacts-structured-name-chunk.vala, do not modify */

/*
 * Copyright (C) 2022 Niels De Graef <nielsdegraef@gmail.com>
 *
 * SPDX-License-Identifier: GPL-2.0-or-later
 */

#include "contactscore.h"
#include <folks/folks.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	CONTACTS_STRUCTURED_NAME_CHUNK_0_PROPERTY,
	CONTACTS_STRUCTURED_NAME_CHUNK_STRUCTURED_NAME_PROPERTY,
	CONTACTS_STRUCTURED_NAME_CHUNK_PROPERTY_NAME_PROPERTY,
	CONTACTS_STRUCTURED_NAME_CHUNK_DISPLAY_NAME_PROPERTY,
	CONTACTS_STRUCTURED_NAME_CHUNK_ICON_NAME_PROPERTY,
	CONTACTS_STRUCTURED_NAME_CHUNK_IS_EMPTY_PROPERTY,
	CONTACTS_STRUCTURED_NAME_CHUNK_DIRTY_PROPERTY,
	CONTACTS_STRUCTURED_NAME_CHUNK_NUM_PROPERTIES
};
static GParamSpec* contacts_structured_name_chunk_properties[CONTACTS_STRUCTURED_NAME_CHUNK_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ContactsStructuredNameChunkSaveToPersonaData ContactsStructuredNameChunkSaveToPersonaData;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_variant_type_free0(var) ((var == NULL) ? NULL : (var = (g_variant_type_free (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _ContactsStructuredNameChunkPrivate {
	FolksStructuredName* original_structured_name;
	FolksStructuredName* _structured_name;
};

struct _ContactsStructuredNameChunkSaveToPersonaData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ContactsStructuredNameChunk* self;
	FolksPersona* _tmp0_;
	FolksPersona* _tmp1_;
	FolksPersona* _tmp2_;
	FolksPersona* _tmp3_;
	FolksStructuredName* _tmp4_;
	FolksStructuredName* _tmp5_;
	FolksStructuredName* _tmp6_;
	FolksStructuredName* _tmp7_;
	FolksStructuredName* _tmp8_;
	GError* _inner_error0_;
};

static gint ContactsStructuredNameChunk_private_offset;
static gpointer contacts_structured_name_chunk_parent_class = NULL;

static GValue* contacts_structured_name_chunk_real_to_value (ContactsChunk* base);
static void contacts_structured_name_chunk_real_save_to_persona_data_free (gpointer _data);
static void contacts_structured_name_chunk_real_save_to_persona (ContactsChunk* base,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_);
static gboolean contacts_structured_name_chunk_real_save_to_persona_co (ContactsStructuredNameChunkSaveToPersonaData* _data_);
static void contacts_structured_name_chunk_save_to_persona_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_);
static GVariant* contacts_structured_name_chunk_real_to_gvariant (ContactsChunk* base);
static void contacts_structured_name_chunk_real_apply_gvariant (ContactsChunk* base,
                                                         GVariant* variant,
                                                         gboolean mark_dirty);
static GObject * contacts_structured_name_chunk_constructor (GType type,
                                                      guint n_construct_properties,
                                                      GObjectConstructParam * construct_properties);
static void contacts_structured_name_chunk_finalize (GObject * obj);
static GType contacts_structured_name_chunk_get_type_once (void);
static void _vala_contacts_structured_name_chunk_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
static void _vala_contacts_structured_name_chunk_set_property (GObject * object,
                                                        guint property_id,
                                                        const GValue * value,
                                                        GParamSpec * pspec);

static inline gpointer
contacts_structured_name_chunk_get_instance_private (ContactsStructuredNameChunk* self)
{
	return G_STRUCT_MEMBER_P (self, ContactsStructuredNameChunk_private_offset);
}

static GValue*
contacts_structured_name_chunk_real_to_value (ContactsChunk* base)
{
	ContactsStructuredNameChunk * self;
	FolksStructuredName* _tmp0_ = NULL;
	gboolean _tmp1_;
	gboolean _tmp2_;
	GValue* _tmp5_ = NULL;
	GValue* result;
	self = (ContactsStructuredNameChunk*) base;
	_tmp1_ = contacts_chunk_get_is_empty ((ContactsChunk*) self);
	_tmp2_ = _tmp1_;
	if (_tmp2_) {
		_tmp0_ = NULL;
	} else {
		FolksStructuredName* _tmp3_;
		FolksStructuredName* _tmp4_;
		_tmp3_ = contacts_structured_name_chunk_get_structured_name (self);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	}
	_tmp5_ = g_new0 (GValue, 1);
	g_value_init (_tmp5_, FOLKS_TYPE_STRUCTURED_NAME);
	g_value_set_object (_tmp5_, _tmp0_);
	result = _tmp5_;
	return result;
}

static void
contacts_structured_name_chunk_real_save_to_persona_data_free (gpointer _data)
{
	ContactsStructuredNameChunkSaveToPersonaData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (ContactsStructuredNameChunkSaveToPersonaData, _data_);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
contacts_structured_name_chunk_real_save_to_persona (ContactsChunk* base,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_)
{
	ContactsStructuredNameChunk * self;
	ContactsStructuredNameChunkSaveToPersonaData* _data_;
	ContactsStructuredNameChunk* _tmp0_;
	self = (ContactsStructuredNameChunk*) base;
	_data_ = g_slice_new0 (ContactsStructuredNameChunkSaveToPersonaData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, contacts_structured_name_chunk_real_save_to_persona_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	contacts_structured_name_chunk_real_save_to_persona_co (_data_);
}

static void
contacts_structured_name_chunk_save_to_persona_finish (ContactsChunk* base,
                                                       GAsyncResult* _res_,
                                                       GError** error)
{
	ContactsStructuredNameChunkSaveToPersonaData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
contacts_structured_name_chunk_save_to_persona_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_)
{
	ContactsStructuredNameChunkSaveToPersonaData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	contacts_structured_name_chunk_real_save_to_persona_co (_data_);
}

static gboolean
contacts_structured_name_chunk_real_save_to_persona_co (ContactsStructuredNameChunkSaveToPersonaData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = contacts_chunk_get_persona ((ContactsChunk*) _data_->self);
	_data_->_tmp1_ = _data_->_tmp0_;
	_vala_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp1_, FOLKS_TYPE_NAME_DETAILS), "this.persona is NameDetails", FALSE);
	_data_->_tmp2_ = contacts_chunk_get_persona ((ContactsChunk*) _data_->self);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = contacts_structured_name_chunk_get_structured_name (_data_->self);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_state_ = 1;
	folks_name_details_change_structured_name (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, FOLKS_TYPE_NAME_DETAILS, FolksNameDetails), _data_->_tmp5_, contacts_structured_name_chunk_save_to_persona_ready, _data_);
	return FALSE;
	_state_1:
	folks_name_details_change_structured_name_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, FOLKS_TYPE_NAME_DETAILS, FolksNameDetails), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp6_ = contacts_structured_name_chunk_get_structured_name (_data_->self);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = _g_object_ref0 (_data_->_tmp7_);
	_g_object_unref0 (_data_->self->priv->original_structured_name);
	_data_->self->priv->original_structured_name = _data_->_tmp8_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static GVariant*
contacts_structured_name_chunk_real_to_gvariant (ContactsChunk* base)
{
	ContactsStructuredNameChunk * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	FolksStructuredName* _tmp2_;
	FolksStructuredName* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	FolksStructuredName* _tmp6_;
	FolksStructuredName* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	FolksStructuredName* _tmp10_;
	FolksStructuredName* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	FolksStructuredName* _tmp14_;
	FolksStructuredName* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	FolksStructuredName* _tmp18_;
	FolksStructuredName* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	GVariant* _tmp22_;
	GVariant* result;
	self = (ContactsStructuredNameChunk*) base;
	_tmp0_ = contacts_chunk_get_is_empty ((ContactsChunk*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		result = NULL;
		return result;
	}
	_tmp2_ = contacts_structured_name_chunk_get_structured_name (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = folks_structured_name_get_family_name (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = contacts_structured_name_chunk_get_structured_name (self);
	_tmp7_ = _tmp6_;
	_tmp8_ = folks_structured_name_get_given_name (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = contacts_structured_name_chunk_get_structured_name (self);
	_tmp11_ = _tmp10_;
	_tmp12_ = folks_structured_name_get_additional_names (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = contacts_structured_name_chunk_get_structured_name (self);
	_tmp15_ = _tmp14_;
	_tmp16_ = folks_structured_name_get_prefixes (_tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = contacts_structured_name_chunk_get_structured_name (self);
	_tmp19_ = _tmp18_;
	_tmp20_ = folks_structured_name_get_suffixes (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = g_variant_new ("(sssss)", _tmp5_, _tmp9_, _tmp13_, _tmp17_, _tmp21_, NULL);
	g_variant_ref_sink (_tmp22_);
	result = _tmp22_;
	return result;
}

static void
contacts_structured_name_chunk_real_apply_gvariant (ContactsChunk* base,
                                                    GVariant* variant,
                                                    gboolean mark_dirty)
{
	ContactsStructuredNameChunk * self;
	const GVariantType* _tmp0_;
	GVariantType* _tmp1_;
	GVariantType* _tmp2_;
	gchar* family_name = NULL;
	gchar* given_name = NULL;
	gchar* additional_names = NULL;
	gchar* prefixes = NULL;
	gchar* suffixes = NULL;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	gchar* _tmp5_ = NULL;
	gchar* _tmp6_ = NULL;
	gchar* _tmp7_ = NULL;
	FolksStructuredName* structured_name = NULL;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	FolksStructuredName* _tmp13_;
	FolksStructuredName* _tmp16_;
	self = (ContactsStructuredNameChunk*) base;
	g_return_if_fail (variant != NULL);
	_tmp0_ = g_variant_get_type (variant);
	_tmp1_ = g_variant_type_new ("(sssss)");
	_tmp2_ = _tmp1_;
	_vala_return_if_fail (g_variant_type_equal (_tmp0_, _tmp2_), "variant.get_type ().equal (new VariantType (\"(sssss)\"))");
	g_variant_get (variant, "(sssss)", &_tmp3_, &_tmp4_, &_tmp5_, &_tmp6_, &_tmp7_, NULL);
	_g_free0 (family_name);
	family_name = _tmp3_;
	_g_free0 (given_name);
	given_name = _tmp4_;
	_g_free0 (additional_names);
	additional_names = _tmp5_;
	_g_free0 (prefixes);
	prefixes = _tmp6_;
	_g_free0 (suffixes);
	suffixes = _tmp7_;
	_g_variant_type_free0 (_tmp2_);
	_tmp8_ = family_name;
	_tmp9_ = given_name;
	_tmp10_ = additional_names;
	_tmp11_ = prefixes;
	_tmp12_ = suffixes;
	_tmp13_ = folks_structured_name_new (_tmp8_, _tmp9_, _tmp10_, _tmp11_, _tmp12_);
	structured_name = _tmp13_;
	if (!mark_dirty) {
		FolksStructuredName* _tmp14_;
		FolksStructuredName* _tmp15_;
		_tmp14_ = structured_name;
		_tmp15_ = _g_object_ref0 (_tmp14_);
		_g_object_unref0 (self->priv->original_structured_name);
		self->priv->original_structured_name = _tmp15_;
	}
	_tmp16_ = structured_name;
	contacts_structured_name_chunk_set_structured_name (self, _tmp16_);
	_g_object_unref0 (structured_name);
	_g_free0 (suffixes);
	_g_free0 (prefixes);
	_g_free0 (additional_names);
	_g_free0 (given_name);
	_g_free0 (family_name);
}

ContactsStructuredNameChunk*
contacts_structured_name_chunk_construct (GType object_type)
{
	ContactsStructuredNameChunk * self = NULL;
	self = (ContactsStructuredNameChunk*) contacts_chunk_construct (object_type);
	return self;
}

ContactsStructuredNameChunk*
contacts_structured_name_chunk_new (void)
{
	return contacts_structured_name_chunk_construct (CONTACTS_TYPE_STRUCTURED_NAME_CHUNK);
}

FolksStructuredName*
contacts_structured_name_chunk_get_structured_name (ContactsStructuredNameChunk* self)
{
	FolksStructuredName* result;
	FolksStructuredName* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_structured_name;
	result = _tmp0_;
	return result;
}

void
contacts_structured_name_chunk_set_structured_name (ContactsStructuredNameChunk* self,
                                                    FolksStructuredName* value)
{
	FolksStructuredName* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	FolksStructuredName* _tmp3_;
	gboolean was_empty = FALSE;
	gboolean _tmp5_;
	gboolean _tmp6_;
	FolksStructuredName* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_structured_name;
	if (_tmp0_ == value) {
		return;
	}
	_tmp3_ = self->priv->_structured_name;
	if (_tmp3_ != NULL) {
		_tmp2_ = value != NULL;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		FolksStructuredName* _tmp4_;
		_tmp4_ = self->priv->_structured_name;
		_tmp1_ = folks_structured_name_equal (_tmp4_, value);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		return;
	}
	_tmp5_ = contacts_chunk_get_is_empty ((ContactsChunk*) self);
	_tmp6_ = _tmp5_;
	was_empty = _tmp6_;
	_tmp7_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_structured_name);
	self->priv->_structured_name = _tmp7_;
	g_object_notify ((GObject*) self, "structured-name");
	_tmp8_ = contacts_chunk_get_is_empty ((ContactsChunk*) self);
	_tmp9_ = _tmp8_;
	if (_tmp9_ != was_empty) {
		g_object_notify ((GObject*) self, "is-empty");
	}
	g_object_notify_by_pspec ((GObject *) self, contacts_structured_name_chunk_properties[CONTACTS_STRUCTURED_NAME_CHUNK_STRUCTURED_NAME_PROPERTY]);
}

static const gchar*
contacts_structured_name_chunk_real_get_property_name (ContactsChunk* base)
{
	const gchar* result;
	ContactsStructuredNameChunk* self;
	self = (ContactsStructuredNameChunk*) base;
	result = "structured-name";
	return result;
}

static const gchar*
contacts_structured_name_chunk_real_get_display_name (ContactsChunk* base)
{
	const gchar* result;
	ContactsStructuredNameChunk* self;
	self = (ContactsStructuredNameChunk*) base;
	result = _ ("Structured name");
	return result;
}

static const gchar*
contacts_structured_name_chunk_real_get_icon_name (ContactsChunk* base)
{
	const gchar* result;
	ContactsStructuredNameChunk* self;
	self = (ContactsStructuredNameChunk*) base;
	result = NULL;
	return result;
}

static gboolean
contacts_structured_name_chunk_real_get_is_empty (ContactsChunk* base)
{
	gboolean result;
	ContactsStructuredNameChunk* self;
	gboolean _tmp0_ = FALSE;
	FolksStructuredName* _tmp1_;
	self = (ContactsStructuredNameChunk*) base;
	_tmp1_ = self->priv->_structured_name;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		FolksStructuredName* _tmp2_;
		_tmp2_ = self->priv->_structured_name;
		_tmp0_ = folks_structured_name_is_empty (_tmp2_);
	}
	result = _tmp0_;
	return result;
}

static gboolean
contacts_structured_name_chunk_real_get_dirty (ContactsChunk* base)
{
	gboolean result;
	ContactsStructuredNameChunk* self;
	FolksStructuredName* _tmp0_;
	FolksStructuredName* _tmp1_;
	self = (ContactsStructuredNameChunk*) base;
	_tmp0_ = self->priv->original_structured_name;
	_tmp1_ = self->priv->_structured_name;
	result = !folks_structured_name_equal (_tmp0_, _tmp1_);
	return result;
}

static GObject *
contacts_structured_name_chunk_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ContactsStructuredNameChunk * self;
	FolksPersona* _tmp0_;
	FolksPersona* _tmp1_;
	FolksStructuredName* _tmp11_;
	FolksStructuredName* _tmp12_;
	FolksStructuredName* _tmp13_;
	parent_class = G_OBJECT_CLASS (contacts_structured_name_chunk_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_STRUCTURED_NAME_CHUNK, ContactsStructuredNameChunk);
	_tmp0_ = contacts_chunk_get_persona ((ContactsChunk*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		FolksPersona* _tmp2_;
		FolksPersona* _tmp3_;
		FolksPersona* _tmp4_;
		FolksPersona* _tmp5_;
		FolksPersona* _tmp6_;
		FolksPersona* _tmp7_;
		FolksStructuredName* _tmp8_;
		FolksStructuredName* _tmp9_;
		FolksStructuredName* _tmp10_;
		_tmp2_ = contacts_chunk_get_persona ((ContactsChunk*) self);
		_tmp3_ = _tmp2_;
		_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, FOLKS_TYPE_NAME_DETAILS), "persona is NameDetails");
		_tmp4_ = contacts_chunk_get_persona ((ContactsChunk*) self);
		_tmp5_ = _tmp4_;
		g_object_bind_property_with_closures ((GObject*) _tmp5_, "structured-name", (GObject*) self, "structured-name", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
		_tmp6_ = contacts_chunk_get_persona ((ContactsChunk*) self);
		_tmp7_ = _tmp6_;
		_tmp8_ = folks_name_details_get_structured_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, FOLKS_TYPE_NAME_DETAILS, FolksNameDetails));
		_tmp9_ = _tmp8_;
		_tmp10_ = _g_object_ref0 (_tmp9_);
		_g_object_unref0 (self->priv->_structured_name);
		self->priv->_structured_name = _tmp10_;
	}
	_tmp11_ = contacts_structured_name_chunk_get_structured_name (self);
	_tmp12_ = _tmp11_;
	_tmp13_ = _g_object_ref0 (_tmp12_);
	_g_object_unref0 (self->priv->original_structured_name);
	self->priv->original_structured_name = _tmp13_;
	return obj;
}

static void
contacts_structured_name_chunk_class_init (ContactsStructuredNameChunkClass * klass,
                                           gpointer klass_data)
{
	contacts_structured_name_chunk_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ContactsStructuredNameChunk_private_offset);
	((ContactsChunkClass *) klass)->to_value = (GValue* (*) (ContactsChunk*)) contacts_structured_name_chunk_real_to_value;
	((ContactsChunkClass *) klass)->save_to_persona = (void (*) (ContactsChunk*, GAsyncReadyCallback, gpointer)) contacts_structured_name_chunk_real_save_to_persona;
	((ContactsChunkClass *) klass)->save_to_persona_finish = (void (*) (ContactsChunk*, GAsyncResult*, GError**)) contacts_structured_name_chunk_save_to_persona_finish;
	((ContactsChunkClass *) klass)->to_gvariant = (GVariant* (*) (ContactsChunk*)) contacts_structured_name_chunk_real_to_gvariant;
	((ContactsChunkClass *) klass)->apply_gvariant = (void (*) (ContactsChunk*, GVariant*, gboolean)) contacts_structured_name_chunk_real_apply_gvariant;
	CONTACTS_CHUNK_CLASS (klass)->get_property_name = (const gchar* (*) (ContactsChunk*)) contacts_structured_name_chunk_real_get_property_name;
	CONTACTS_CHUNK_CLASS (klass)->get_display_name = (const gchar* (*) (ContactsChunk*)) contacts_structured_name_chunk_real_get_display_name;
	CONTACTS_CHUNK_CLASS (klass)->get_icon_name = (const gchar* (*) (ContactsChunk*)) contacts_structured_name_chunk_real_get_icon_name;
	CONTACTS_CHUNK_CLASS (klass)->get_is_empty = (gboolean (*) (ContactsChunk*)) contacts_structured_name_chunk_real_get_is_empty;
	CONTACTS_CHUNK_CLASS (klass)->get_dirty = (gboolean (*) (ContactsChunk*)) contacts_structured_name_chunk_real_get_dirty;
	G_OBJECT_CLASS (klass)->get_property = _vala_contacts_structured_name_chunk_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_contacts_structured_name_chunk_set_property;
	G_OBJECT_CLASS (klass)->constructor = contacts_structured_name_chunk_constructor;
	G_OBJECT_CLASS (klass)->finalize = contacts_structured_name_chunk_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_STRUCTURED_NAME_CHUNK_STRUCTURED_NAME_PROPERTY, contacts_structured_name_chunk_properties[CONTACTS_STRUCTURED_NAME_CHUNK_STRUCTURED_NAME_PROPERTY] = g_param_spec_object ("structured-name", "structured-name", "structured-name", FOLKS_TYPE_STRUCTURED_NAME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_STRUCTURED_NAME_CHUNK_PROPERTY_NAME_PROPERTY, contacts_structured_name_chunk_properties[CONTACTS_STRUCTURED_NAME_CHUNK_PROPERTY_NAME_PROPERTY] = g_param_spec_string ("property-name", "property-name", "property-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_STRUCTURED_NAME_CHUNK_DISPLAY_NAME_PROPERTY, contacts_structured_name_chunk_properties[CONTACTS_STRUCTURED_NAME_CHUNK_DISPLAY_NAME_PROPERTY] = g_param_spec_string ("display-name", "display-name", "display-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_STRUCTURED_NAME_CHUNK_ICON_NAME_PROPERTY, contacts_structured_name_chunk_properties[CONTACTS_STRUCTURED_NAME_CHUNK_ICON_NAME_PROPERTY] = g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_STRUCTURED_NAME_CHUNK_IS_EMPTY_PROPERTY, contacts_structured_name_chunk_properties[CONTACTS_STRUCTURED_NAME_CHUNK_IS_EMPTY_PROPERTY] = g_param_spec_boolean ("is-empty", "is-empty", "is-empty", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_STRUCTURED_NAME_CHUNK_DIRTY_PROPERTY, contacts_structured_name_chunk_properties[CONTACTS_STRUCTURED_NAME_CHUNK_DIRTY_PROPERTY] = g_param_spec_boolean ("dirty", "dirty", "dirty", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
contacts_structured_name_chunk_instance_init (ContactsStructuredNameChunk * self,
                                              gpointer klass)
{
	FolksStructuredName* _tmp0_;
	self->priv = contacts_structured_name_chunk_get_instance_private (self);
	_tmp0_ = folks_structured_name_new_simple (NULL, NULL);
	self->priv->_structured_name = _tmp0_;
}

static void
contacts_structured_name_chunk_finalize (GObject * obj)
{
	ContactsStructuredNameChunk * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_STRUCTURED_NAME_CHUNK, ContactsStructuredNameChunk);
	_g_object_unref0 (self->priv->original_structured_name);
	_g_object_unref0 (self->priv->_structured_name);
	G_OBJECT_CLASS (contacts_structured_name_chunk_parent_class)->finalize (obj);
}

/**
 * A {@link Chunk} that represents the structured name of a contact.
 *
 * The structured represents a full name split in its constituent parts (given
 * name, family name, etc.)
 */
 G_GNUC_NO_INLINE static GType
contacts_structured_name_chunk_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsStructuredNameChunkClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_structured_name_chunk_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsStructuredNameChunk), 0, (GInstanceInitFunc) contacts_structured_name_chunk_instance_init, NULL };
	GType contacts_structured_name_chunk_type_id;
	contacts_structured_name_chunk_type_id = g_type_register_static (CONTACTS_TYPE_CHUNK, "ContactsStructuredNameChunk", &g_define_type_info, 0);
	ContactsStructuredNameChunk_private_offset = g_type_add_instance_private (contacts_structured_name_chunk_type_id, sizeof (ContactsStructuredNameChunkPrivate));
	return contacts_structured_name_chunk_type_id;
}

GType
contacts_structured_name_chunk_get_type (void)
{
	static volatile gsize contacts_structured_name_chunk_type_id__once = 0;
	if (g_once_init_enter (&contacts_structured_name_chunk_type_id__once)) {
		GType contacts_structured_name_chunk_type_id;
		contacts_structured_name_chunk_type_id = contacts_structured_name_chunk_get_type_once ();
		g_once_init_leave (&contacts_structured_name_chunk_type_id__once, contacts_structured_name_chunk_type_id);
	}
	return contacts_structured_name_chunk_type_id__once;
}

static void
_vala_contacts_structured_name_chunk_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	ContactsStructuredNameChunk * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_STRUCTURED_NAME_CHUNK, ContactsStructuredNameChunk);
	switch (property_id) {
		case CONTACTS_STRUCTURED_NAME_CHUNK_STRUCTURED_NAME_PROPERTY:
		g_value_set_object (value, contacts_structured_name_chunk_get_structured_name (self));
		break;
		case CONTACTS_STRUCTURED_NAME_CHUNK_PROPERTY_NAME_PROPERTY:
		g_value_set_string (value, contacts_chunk_get_property_name ((ContactsChunk*) self));
		break;
		case CONTACTS_STRUCTURED_NAME_CHUNK_DISPLAY_NAME_PROPERTY:
		g_value_set_string (value, contacts_chunk_get_display_name ((ContactsChunk*) self));
		break;
		case CONTACTS_STRUCTURED_NAME_CHUNK_ICON_NAME_PROPERTY:
		g_value_set_string (value, contacts_chunk_get_icon_name ((ContactsChunk*) self));
		break;
		case CONTACTS_STRUCTURED_NAME_CHUNK_IS_EMPTY_PROPERTY:
		g_value_set_boolean (value, contacts_chunk_get_is_empty ((ContactsChunk*) self));
		break;
		case CONTACTS_STRUCTURED_NAME_CHUNK_DIRTY_PROPERTY:
		g_value_set_boolean (value, contacts_chunk_get_dirty ((ContactsChunk*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_contacts_structured_name_chunk_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec)
{
	ContactsStructuredNameChunk * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_STRUCTURED_NAME_CHUNK, ContactsStructuredNameChunk);
	switch (property_id) {
		case CONTACTS_STRUCTURED_NAME_CHUNK_STRUCTURED_NAME_PROPERTY:
		contacts_structured_name_chunk_set_structured_name (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

