/* contacts-notes-chunk.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from contacts-notes-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 <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <folks/folks.h>
#include <gee.h>
#include <glib-object.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_NOTES_CHUNK_0_PROPERTY,
	CONTACTS_NOTES_CHUNK_PROPERTY_NAME_PROPERTY,
	CONTACTS_NOTES_CHUNK_DISPLAY_NAME_PROPERTY,
	CONTACTS_NOTES_CHUNK_ICON_NAME_PROPERTY,
	CONTACTS_NOTES_CHUNK_NUM_PROPERTIES
};
static GParamSpec* contacts_notes_chunk_properties[CONTACTS_NOTES_CHUNK_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _ContactsNotesChunkSaveToPersonaData ContactsNotesChunkSaveToPersonaData;
enum  {
	CONTACTS_NOTE_0_PROPERTY,
	CONTACTS_NOTE_TEXT_PROPERTY,
	CONTACTS_NOTE_IS_EMPTY_PROPERTY,
	CONTACTS_NOTE_ICON_NAME_PROPERTY,
	CONTACTS_NOTE_NUM_PROPERTIES
};
static GParamSpec* contacts_note_properties[CONTACTS_NOTE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (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 _ContactsNotesChunkSaveToPersonaData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ContactsNotesChunk* self;
	FolksPersona* _tmp0_;
	FolksPersona* _tmp1_;
	GeeSet* afds;
	GeeSet* _tmp2_;
	FolksPersona* _tmp3_;
	FolksPersona* _tmp4_;
	GError* _inner_error0_;
};

struct _ContactsNotePrivate {
	gchar* _text;
};

static gpointer contacts_notes_chunk_parent_class = NULL;
static gint ContactsNote_private_offset;
static gpointer contacts_note_parent_class = NULL;

static ContactsBinChunkChild* contacts_notes_chunk_real_create_empty_child (ContactsBinChunk* base);
static void contacts_notes_chunk_real_save_to_persona_data_free (gpointer _data);
static void contacts_notes_chunk_real_save_to_persona (ContactsChunk* base,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
static gboolean contacts_notes_chunk_real_save_to_persona_co (ContactsNotesChunkSaveToPersonaData* _data_);
static void contacts_notes_chunk_save_to_persona_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
static GObject * contacts_notes_chunk_constructor (GType type,
                                            guint n_construct_properties,
                                            GObjectConstructParam * construct_properties);
static GType contacts_notes_chunk_get_type_once (void);
static void _vala_contacts_notes_chunk_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static gint contacts_note_real_compare_internal (ContactsBinChunkChild* base,
                                          ContactsBinChunkChild* other);
static FolksAbstractFieldDetails* contacts_note_real_create_afd (ContactsBinChunkChild* base);
static ContactsBinChunkChild* contacts_note_real_copy (ContactsBinChunkChild* base);
static GVariant* contacts_note_real_to_gvariant_internal (ContactsBinChunkChild* base);
static void contacts_note_real_apply_gvariant (ContactsBinChunkChild* base,
                                        GVariant* variant);
static void contacts_note_finalize (GObject * obj);
static GType contacts_note_get_type_once (void);
static void _vala_contacts_note_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec);
static void _vala_contacts_note_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec);

static ContactsBinChunkChild*
contacts_notes_chunk_real_create_empty_child (ContactsBinChunk* base)
{
	ContactsNotesChunk * self;
	ContactsNote* _tmp0_;
	ContactsBinChunkChild* result;
	self = (ContactsNotesChunk*) base;
	_tmp0_ = contacts_note_new ();
	result = (ContactsBinChunkChild*) _tmp0_;
	return result;
}

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

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

static void
contacts_notes_chunk_real_save_to_persona (ContactsChunk* base,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	ContactsNotesChunk * self;
	ContactsNotesChunkSaveToPersonaData* _data_;
	ContactsNotesChunk* _tmp0_;
	self = (ContactsNotesChunk*) base;
	_data_ = g_slice_new0 (ContactsNotesChunkSaveToPersonaData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, contacts_notes_chunk_real_save_to_persona_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	contacts_notes_chunk_real_save_to_persona_co (_data_);
}

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

static void
contacts_notes_chunk_save_to_persona_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	ContactsNotesChunkSaveToPersonaData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	contacts_notes_chunk_real_save_to_persona_co (_data_);
}

static gboolean
contacts_notes_chunk_real_save_to_persona_co (ContactsNotesChunkSaveToPersonaData* _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_PHONE_DETAILS), "this.persona is PhoneDetails", FALSE);
	_data_->_tmp2_ = contacts_bin_chunk_get_abstract_field_details ((ContactsBinChunk*) _data_->self);
	_data_->afds = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEE_TYPE_SET, GeeSet);
	_data_->_tmp3_ = contacts_chunk_get_persona ((ContactsChunk*) _data_->self);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_state_ = 1;
	folks_note_details_change_notes (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, FOLKS_TYPE_NOTE_DETAILS, FolksNoteDetails), _data_->afds, contacts_notes_chunk_save_to_persona_ready, _data_);
	return FALSE;
	_state_1:
	folks_note_details_change_notes_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, FOLKS_TYPE_NOTE_DETAILS, FolksNoteDetails), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->afds);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	contacts_bin_chunk_update_original_elements ((ContactsBinChunk*) _data_->self);
	_g_object_unref0 (_data_->afds);
	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;
}

ContactsNotesChunk*
contacts_notes_chunk_construct (GType object_type)
{
	ContactsNotesChunk * self = NULL;
	self = (ContactsNotesChunk*) contacts_bin_chunk_construct (object_type);
	return self;
}

ContactsNotesChunk*
contacts_notes_chunk_new (void)
{
	return contacts_notes_chunk_construct (CONTACTS_TYPE_NOTES_CHUNK);
}

static const gchar*
contacts_notes_chunk_real_get_property_name (ContactsChunk* base)
{
	const gchar* result;
	ContactsNotesChunk* self;
	self = (ContactsNotesChunk*) base;
	result = "notes";
	return result;
}

static const gchar*
contacts_notes_chunk_real_get_display_name (ContactsChunk* base)
{
	const gchar* result;
	ContactsNotesChunk* self;
	self = (ContactsNotesChunk*) base;
	result = _ ("Notes");
	return result;
}

static const gchar*
contacts_notes_chunk_real_get_icon_name (ContactsChunk* base)
{
	const gchar* result;
	ContactsNotesChunk* self;
	self = (ContactsNotesChunk*) base;
	result = "note-symbolic";
	return result;
}

static GObject *
contacts_notes_chunk_constructor (GType type,
                                  guint n_construct_properties,
                                  GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ContactsNotesChunk * self;
	FolksPersona* _tmp0_;
	FolksPersona* _tmp1_;
	parent_class = G_OBJECT_CLASS (contacts_notes_chunk_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_NOTES_CHUNK, ContactsNotesChunk);
	_tmp0_ = contacts_chunk_get_persona ((ContactsChunk*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		FolksPersona* _tmp2_;
		FolksPersona* _tmp3_;
		FolksNoteDetails* note_details = NULL;
		FolksPersona* _tmp4_;
		FolksPersona* _tmp5_;
		_tmp2_ = contacts_chunk_get_persona ((ContactsChunk*) self);
		_tmp3_ = _tmp2_;
		_vala_assert (G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, FOLKS_TYPE_NOTE_DETAILS), "persona is NoteDetails");
		_tmp4_ = contacts_chunk_get_persona ((ContactsChunk*) self);
		_tmp5_ = _tmp4_;
		note_details = G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, FOLKS_TYPE_NOTE_DETAILS, FolksNoteDetails);
		{
			GeeIterator* _note_field_it = NULL;
			FolksNoteDetails* _tmp6_;
			GeeSet* _tmp7_;
			GeeSet* _tmp8_;
			GeeIterator* _tmp9_;
			_tmp6_ = note_details;
			_tmp7_ = folks_note_details_get_notes (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = gee_iterable_iterator ((GeeIterable*) _tmp8_);
			_note_field_it = _tmp9_;
			while (TRUE) {
				GeeIterator* _tmp10_;
				FolksNoteFieldDetails* note_field = NULL;
				GeeIterator* _tmp11_;
				gpointer _tmp12_;
				ContactsNote* note = NULL;
				FolksNoteFieldDetails* _tmp13_;
				ContactsNote* _tmp14_;
				ContactsNote* _tmp15_;
				_tmp10_ = _note_field_it;
				if (!gee_iterator_next (_tmp10_)) {
					break;
				}
				_tmp11_ = _note_field_it;
				_tmp12_ = gee_iterator_get (_tmp11_);
				note_field = (FolksNoteFieldDetails*) _tmp12_;
				_tmp13_ = note_field;
				_tmp14_ = contacts_note_new_from_field_details (_tmp13_);
				note = _tmp14_;
				_tmp15_ = note;
				contacts_bin_chunk_add_child ((ContactsBinChunk*) self, (ContactsBinChunkChild*) _tmp15_);
				_g_object_unref0 (note);
				_g_object_unref0 (note_field);
			}
			_g_object_unref0 (_note_field_it);
		}
	}
	contacts_bin_chunk_finish_initialization ((ContactsBinChunk*) self);
	return obj;
}

static void
contacts_notes_chunk_class_init (ContactsNotesChunkClass * klass,
                                 gpointer klass_data)
{
	contacts_notes_chunk_parent_class = g_type_class_peek_parent (klass);
	((ContactsBinChunkClass *) klass)->create_empty_child = (ContactsBinChunkChild* (*) (ContactsBinChunk*)) contacts_notes_chunk_real_create_empty_child;
	((ContactsChunkClass *) klass)->save_to_persona = (void (*) (ContactsChunk*, GAsyncReadyCallback, gpointer)) contacts_notes_chunk_real_save_to_persona;
	((ContactsChunkClass *) klass)->save_to_persona_finish = (void (*) (ContactsChunk*, GAsyncResult*, GError**)) contacts_notes_chunk_save_to_persona_finish;
	CONTACTS_CHUNK_CLASS (klass)->get_property_name = (const gchar* (*) (ContactsChunk*)) contacts_notes_chunk_real_get_property_name;
	CONTACTS_CHUNK_CLASS (klass)->get_display_name = (const gchar* (*) (ContactsChunk*)) contacts_notes_chunk_real_get_display_name;
	CONTACTS_CHUNK_CLASS (klass)->get_icon_name = (const gchar* (*) (ContactsChunk*)) contacts_notes_chunk_real_get_icon_name;
	G_OBJECT_CLASS (klass)->get_property = _vala_contacts_notes_chunk_get_property;
	G_OBJECT_CLASS (klass)->constructor = contacts_notes_chunk_constructor;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_NOTES_CHUNK_PROPERTY_NAME_PROPERTY, contacts_notes_chunk_properties[CONTACTS_NOTES_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_NOTES_CHUNK_DISPLAY_NAME_PROPERTY, contacts_notes_chunk_properties[CONTACTS_NOTES_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_NOTES_CHUNK_ICON_NAME_PROPERTY, contacts_notes_chunk_properties[CONTACTS_NOTES_CHUNK_ICON_NAME_PROPERTY] = g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
contacts_notes_chunk_instance_init (ContactsNotesChunk * self,
                                    gpointer klass)
{
}

/**
 * A {@link Chunk} that represents the freeform notes attached to a contact
 * (similar to {@link Folks.NoteDetails}. Each element is a {@link Note}.
 */
 G_GNUC_NO_INLINE static GType
contacts_notes_chunk_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsNotesChunkClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_notes_chunk_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsNotesChunk), 0, (GInstanceInitFunc) contacts_notes_chunk_instance_init, NULL };
	GType contacts_notes_chunk_type_id;
	contacts_notes_chunk_type_id = g_type_register_static (CONTACTS_TYPE_BIN_CHUNK, "ContactsNotesChunk", &g_define_type_info, 0);
	return contacts_notes_chunk_type_id;
}

GType
contacts_notes_chunk_get_type (void)
{
	static volatile gsize contacts_notes_chunk_type_id__once = 0;
	if (g_once_init_enter (&contacts_notes_chunk_type_id__once)) {
		GType contacts_notes_chunk_type_id;
		contacts_notes_chunk_type_id = contacts_notes_chunk_get_type_once ();
		g_once_init_leave (&contacts_notes_chunk_type_id__once, contacts_notes_chunk_type_id);
	}
	return contacts_notes_chunk_type_id__once;
}

static void
_vala_contacts_notes_chunk_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	ContactsNotesChunk * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_NOTES_CHUNK, ContactsNotesChunk);
	switch (property_id) {
		case CONTACTS_NOTES_CHUNK_PROPERTY_NAME_PROPERTY:
		g_value_set_string (value, contacts_chunk_get_property_name ((ContactsChunk*) self));
		break;
		case CONTACTS_NOTES_CHUNK_DISPLAY_NAME_PROPERTY:
		g_value_set_string (value, contacts_chunk_get_display_name ((ContactsChunk*) self));
		break;
		case CONTACTS_NOTES_CHUNK_ICON_NAME_PROPERTY:
		g_value_set_string (value, contacts_chunk_get_icon_name ((ContactsChunk*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
contacts_note_get_instance_private (ContactsNote* self)
{
	return G_STRUCT_MEMBER_P (self, ContactsNote_private_offset);
}

ContactsNote*
contacts_note_construct (GType object_type)
{
	ContactsNote * self = NULL;
	GeeHashMultiMap* _tmp0_;
	GeeHashMultiMap* _tmp1_;
	GeeMultiMap* _tmp2_;
	GeeMultiMap* _tmp3_;
	self = (ContactsNote*) contacts_bin_chunk_child_construct (object_type);
	_tmp0_ = gee_hash_multi_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_tmp1_ = _tmp0_;
	contacts_bin_chunk_child_set_parameters ((ContactsBinChunkChild*) self, (GeeMultiMap*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = contacts_bin_chunk_child_get_parameters ((ContactsBinChunkChild*) self);
	_tmp3_ = _tmp2_;
	gee_multi_map_set (_tmp3_, "type", "PERSONAL");
	return self;
}

ContactsNote*
contacts_note_new (void)
{
	return contacts_note_construct (CONTACTS_TYPE_NOTE);
}

ContactsNote*
contacts_note_construct_from_field_details (GType object_type,
                                            FolksNoteFieldDetails* note_field)
{
	ContactsNote * self = NULL;
	gconstpointer _tmp0_;
	gconstpointer _tmp1_;
	GeeMultiMap* _tmp2_;
	GeeMultiMap* _tmp3_;
	g_return_val_if_fail (note_field != NULL, NULL);
	self = (ContactsNote*) contacts_bin_chunk_child_construct (object_type);
	_tmp0_ = folks_abstract_field_details_get_value ((FolksAbstractFieldDetails*) note_field);
	_tmp1_ = _tmp0_;
	contacts_note_set_text (self, (const gchar*) _tmp1_);
	_tmp2_ = folks_abstract_field_details_get_parameters ((FolksAbstractFieldDetails*) note_field);
	_tmp3_ = _tmp2_;
	contacts_bin_chunk_child_set_parameters ((ContactsBinChunkChild*) self, _tmp3_);
	return self;
}

ContactsNote*
contacts_note_new_from_field_details (FolksNoteFieldDetails* note_field)
{
	return contacts_note_construct_from_field_details (CONTACTS_TYPE_NOTE, note_field);
}

static gint
contacts_note_real_compare_internal (ContactsBinChunkChild* base,
                                     ContactsBinChunkChild* other)
{
	ContactsNote * self;
	GCompareFunc _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	gint result;
	self = (ContactsNote*) base;
	g_return_val_if_fail (other != NULL, 0);
	_vala_return_val_if_fail (CONTACTS_IS_NOTE (other), "other is Note", 0);
	_tmp0_ = ((GCompareFunc) g_strcmp0);
	_tmp1_ = contacts_note_get_text (self);
	_tmp2_ = _tmp1_;
	_tmp3_ = contacts_note_get_text (G_TYPE_CHECK_INSTANCE_CAST (other, CONTACTS_TYPE_NOTE, ContactsNote));
	_tmp4_ = _tmp3_;
	result = _tmp0_ (_tmp2_, _tmp4_);
	return result;
}

static FolksAbstractFieldDetails*
contacts_note_real_create_afd (ContactsBinChunkChild* base)
{
	ContactsNote * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GeeMultiMap* _tmp4_;
	GeeMultiMap* _tmp5_;
	FolksNoteFieldDetails* _tmp6_;
	FolksAbstractFieldDetails* result;
	self = (ContactsNote*) base;
	_tmp0_ = contacts_bin_chunk_child_get_is_empty ((ContactsBinChunkChild*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		result = NULL;
		return result;
	}
	_tmp2_ = contacts_note_get_text (self);
	_tmp3_ = _tmp2_;
	_tmp4_ = contacts_bin_chunk_child_get_parameters ((ContactsBinChunkChild*) self);
	_tmp5_ = _tmp4_;
	_tmp6_ = folks_note_field_details_new (_tmp3_, _tmp5_, NULL);
	result = (FolksAbstractFieldDetails*) _tmp6_;
	return result;
}

static ContactsBinChunkChild*
contacts_note_real_copy (ContactsBinChunkChild* base)
{
	ContactsNote * self;
	ContactsNote* note = NULL;
	ContactsNote* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	ContactsBinChunkChild* result;
	self = (ContactsNote*) base;
	_tmp0_ = contacts_note_new ();
	note = _tmp0_;
	_tmp1_ = contacts_note_get_text (self);
	_tmp2_ = _tmp1_;
	contacts_note_set_text (note, _tmp2_);
	contacts_bin_chunk_child_copy_parameters ((ContactsBinChunkChild*) self, (ContactsBinChunkChild*) note);
	result = (ContactsBinChunkChild*) note;
	return result;
}

static GVariant*
contacts_note_real_to_gvariant_internal (ContactsBinChunkChild* base)
{
	ContactsNote * self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	GVariant* _tmp4_;
	GVariant* _tmp5_;
	GVariant* result;
	self = (ContactsNote*) base;
	_tmp0_ = contacts_note_get_text (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = contacts_bin_chunk_child_parameters_to_gvariant ((ContactsBinChunkChild*) self);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_variant_new ("(sv)", _tmp1_, _tmp3_, NULL);
	g_variant_ref_sink (_tmp4_);
	_tmp5_ = _tmp4_;
	_g_variant_unref0 (_tmp3_);
	result = _tmp5_;
	return result;
}

static void
contacts_note_real_apply_gvariant (ContactsBinChunkChild* base,
                                   GVariant* variant)
{
	ContactsNote * self;
	const GVariantType* _tmp0_;
	GVariantType* _tmp1_;
	GVariantType* _tmp2_;
	gchar* note = NULL;
	GVariant* params_variant = NULL;
	gchar* _tmp3_ = NULL;
	GVariant* _tmp4_ = NULL;
	self = (ContactsNote*) base;
	g_return_if_fail (variant != NULL);
	_tmp0_ = g_variant_get_type (variant);
	_tmp1_ = g_variant_type_new ("(sv)");
	_tmp2_ = _tmp1_;
	_vala_return_if_fail (g_variant_type_equal (_tmp0_, _tmp2_), "variant.get_type ().equal (new VariantType (\"(sv)\"))");
	g_variant_get (variant, "(sv)", &_tmp3_, &_tmp4_, NULL);
	_g_free0 (note);
	note = _tmp3_;
	_g_variant_unref0 (params_variant);
	params_variant = _tmp4_;
	_g_variant_type_free0 (_tmp2_);
	contacts_note_set_text (self, note);
	contacts_bin_chunk_child_apply_gvariant_parameters ((ContactsBinChunkChild*) self, params_variant);
	_g_variant_unref0 (params_variant);
	_g_free0 (note);
}

const gchar*
contacts_note_get_text (ContactsNote* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_text;
	result = _tmp0_;
	return result;
}

void
contacts_note_set_text (ContactsNote* self,
                        const gchar* value)
{
	g_return_if_fail (self != NULL);
	contacts_bin_chunk_child_change_string_prop ((ContactsBinChunkChild*) self, "text", &self->priv->_text, value);
	g_object_notify_by_pspec ((GObject *) self, contacts_note_properties[CONTACTS_NOTE_TEXT_PROPERTY]);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static gboolean
contacts_note_real_get_is_empty (ContactsBinChunkChild* base)
{
	gboolean result;
	ContactsNote* self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	self = (ContactsNote*) base;
	_tmp0_ = contacts_note_get_text (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = string_strip (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strcmp0 (_tmp3_, "") == 0;
	_g_free0 (_tmp3_);
	result = _tmp4_;
	return result;
}

static const gchar*
contacts_note_real_get_icon_name (ContactsBinChunkChild* base)
{
	const gchar* result;
	ContactsNote* self;
	self = (ContactsNote*) base;
	result = "note-symbolic";
	return result;
}

static void
contacts_note_class_init (ContactsNoteClass * klass,
                          gpointer klass_data)
{
	contacts_note_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ContactsNote_private_offset);
	((ContactsBinChunkChildClass *) klass)->compare_internal = (gint (*) (ContactsBinChunkChild*, ContactsBinChunkChild*)) contacts_note_real_compare_internal;
	((ContactsBinChunkChildClass *) klass)->create_afd = (FolksAbstractFieldDetails* (*) (ContactsBinChunkChild*)) contacts_note_real_create_afd;
	((ContactsBinChunkChildClass *) klass)->copy = (ContactsBinChunkChild* (*) (ContactsBinChunkChild*)) contacts_note_real_copy;
	((ContactsBinChunkChildClass *) klass)->to_gvariant_internal = (GVariant* (*) (ContactsBinChunkChild*)) contacts_note_real_to_gvariant_internal;
	((ContactsBinChunkChildClass *) klass)->apply_gvariant = (void (*) (ContactsBinChunkChild*, GVariant*)) contacts_note_real_apply_gvariant;
	CONTACTS_BIN_CHUNK_CHILD_CLASS (klass)->get_is_empty = (gboolean (*) (ContactsBinChunkChild*)) contacts_note_real_get_is_empty;
	CONTACTS_BIN_CHUNK_CHILD_CLASS (klass)->get_icon_name = (const gchar* (*) (ContactsBinChunkChild*)) contacts_note_real_get_icon_name;
	G_OBJECT_CLASS (klass)->get_property = _vala_contacts_note_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_contacts_note_set_property;
	G_OBJECT_CLASS (klass)->finalize = contacts_note_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_NOTE_TEXT_PROPERTY, contacts_note_properties[CONTACTS_NOTE_TEXT_PROPERTY] = g_param_spec_string ("text", "text", "text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), CONTACTS_NOTE_IS_EMPTY_PROPERTY, contacts_note_properties[CONTACTS_NOTE_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_NOTE_ICON_NAME_PROPERTY, contacts_note_properties[CONTACTS_NOTE_ICON_NAME_PROPERTY] = g_param_spec_string ("icon-name", "icon-name", "icon-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
contacts_note_instance_init (ContactsNote * self,
                             gpointer klass)
{
	gchar* _tmp0_;
	self->priv = contacts_note_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_text = _tmp0_;
}

static void
contacts_note_finalize (GObject * obj)
{
	ContactsNote * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, CONTACTS_TYPE_NOTE, ContactsNote);
	_g_free0 (self->priv->_text);
	G_OBJECT_CLASS (contacts_note_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
contacts_note_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ContactsNoteClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) contacts_note_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ContactsNote), 0, (GInstanceInitFunc) contacts_note_instance_init, NULL };
	GType contacts_note_type_id;
	contacts_note_type_id = g_type_register_static (CONTACTS_TYPE_BIN_CHUNK_CHILD, "ContactsNote", &g_define_type_info, 0);
	ContactsNote_private_offset = g_type_add_instance_private (contacts_note_type_id, sizeof (ContactsNotePrivate));
	return contacts_note_type_id;
}

GType
contacts_note_get_type (void)
{
	static volatile gsize contacts_note_type_id__once = 0;
	if (g_once_init_enter (&contacts_note_type_id__once)) {
		GType contacts_note_type_id;
		contacts_note_type_id = contacts_note_get_type_once ();
		g_once_init_leave (&contacts_note_type_id__once, contacts_note_type_id);
	}
	return contacts_note_type_id__once;
}

static void
_vala_contacts_note_get_property (GObject * object,
                                  guint property_id,
                                  GValue * value,
                                  GParamSpec * pspec)
{
	ContactsNote * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_NOTE, ContactsNote);
	switch (property_id) {
		case CONTACTS_NOTE_TEXT_PROPERTY:
		g_value_set_string (value, contacts_note_get_text (self));
		break;
		case CONTACTS_NOTE_IS_EMPTY_PROPERTY:
		g_value_set_boolean (value, contacts_bin_chunk_child_get_is_empty ((ContactsBinChunkChild*) self));
		break;
		case CONTACTS_NOTE_ICON_NAME_PROPERTY:
		g_value_set_string (value, contacts_bin_chunk_child_get_icon_name ((ContactsBinChunkChild*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_contacts_note_set_property (GObject * object,
                                  guint property_id,
                                  const GValue * value,
                                  GParamSpec * pspec)
{
	ContactsNote * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, CONTACTS_TYPE_NOTE, ContactsNote);
	switch (property_id) {
		case CONTACTS_NOTE_TEXT_PROPERTY:
		contacts_note_set_text (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

