/* 0428_fallback_indication.c generated by valac 0.56.19, the Vala compiler
 * generated from 0428_fallback_indication.vala, do not modify */

#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <gobject/gvaluecollector.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

#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _XmppXepFallbackIndicationParamSpecFallback XmppXepFallbackIndicationParamSpecFallback;
typedef struct _XmppXepFallbackIndicationParamSpecFallbackLocation XmppXepFallbackIndicationParamSpecFallbackLocation;
#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
#define _xmpp_xep_fallback_indication_fallback_location_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_fallback_indication_fallback_location_unref (var), NULL)))
#define _xmpp_xep_fallback_indication_fallback_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_fallback_indication_fallback_unref (var), NULL)))

struct _XmppXepFallbackIndicationFallbackPrivate {
	gchar* _ns_uri;
};

struct _XmppXepFallbackIndicationParamSpecFallback {
	GParamSpec parent_instance;
};

struct _XmppXepFallbackIndicationFallbackLocationPrivate {
	gint _from_char;
	gint _to_char;
};

struct _XmppXepFallbackIndicationParamSpecFallbackLocation {
	GParamSpec parent_instance;
};

static gint XmppXepFallbackIndicationFallback_private_offset;
static gpointer xmpp_xep_fallback_indication_fallback_parent_class = NULL;
static gint XmppXepFallbackIndicationFallbackLocation_private_offset;
static gpointer xmpp_xep_fallback_indication_fallback_location_parent_class = NULL;

static void xmpp_xep_fallback_indication_fallback_finalize (XmppXepFallbackIndicationFallback * obj);
static GType xmpp_xep_fallback_indication_fallback_get_type_once (void);
static void xmpp_xep_fallback_indication_fallback_location_finalize (XmppXepFallbackIndicationFallbackLocation * obj);
static GType xmpp_xep_fallback_indication_fallback_location_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
xmpp_xep_fallback_indication_fallback_get_instance_private (XmppXepFallbackIndicationFallback* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepFallbackIndicationFallback_private_offset);
}

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

XmppXepFallbackIndicationFallback*
xmpp_xep_fallback_indication_fallback_construct (GType object_type,
                                                 const gchar* ns_uri,
                                                 GeeList* locations)
{
	XmppXepFallbackIndicationFallback* self = NULL;
	GeeList* _tmp0_;
	g_return_val_if_fail (ns_uri != NULL, NULL);
	g_return_val_if_fail (locations != NULL, NULL);
	self = (XmppXepFallbackIndicationFallback*) g_type_create_instance (object_type);
	xmpp_xep_fallback_indication_fallback_set_ns_uri (self, ns_uri);
	_tmp0_ = _g_object_ref0 (locations);
	_g_object_unref0 (self->locations);
	self->locations = _tmp0_;
	return self;
}

XmppXepFallbackIndicationFallback*
xmpp_xep_fallback_indication_fallback_new (const gchar* ns_uri,
                                           GeeList* locations)
{
	return xmpp_xep_fallback_indication_fallback_construct (XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK, ns_uri, locations);
}

const gchar*
xmpp_xep_fallback_indication_fallback_get_ns_uri (XmppXepFallbackIndicationFallback* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_ns_uri;
	result = _tmp0_;
	return result;
}

void
xmpp_xep_fallback_indication_fallback_set_ns_uri (XmppXepFallbackIndicationFallback* self,
                                                  const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_ns_uri);
	self->priv->_ns_uri = _tmp0_;
}

static void
xmpp_xep_fallback_indication_value_fallback_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
xmpp_xep_fallback_indication_value_fallback_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		xmpp_xep_fallback_indication_fallback_unref (value->data[0].v_pointer);
	}
}

static void
xmpp_xep_fallback_indication_value_fallback_copy_value (const GValue* src_value,
                                                        GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = xmpp_xep_fallback_indication_fallback_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
xmpp_xep_fallback_indication_value_fallback_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
xmpp_xep_fallback_indication_value_fallback_collect_value (GValue* value,
                                                           guint n_collect_values,
                                                           GTypeCValue* collect_values,
                                                           guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		XmppXepFallbackIndicationFallback * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = xmpp_xep_fallback_indication_fallback_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
xmpp_xep_fallback_indication_value_fallback_lcopy_value (const GValue* value,
                                                         guint n_collect_values,
                                                         GTypeCValue* collect_values,
                                                         guint collect_flags)
{
	XmppXepFallbackIndicationFallback ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = xmpp_xep_fallback_indication_fallback_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
xmpp_xep_fallback_indication_param_spec_fallback (const gchar* name,
                                                  const gchar* nick,
                                                  const gchar* blurb,
                                                  GType object_type,
                                                  GParamFlags flags)
{
	XmppXepFallbackIndicationParamSpecFallback* spec;
	g_return_val_if_fail (g_type_is_a (object_type, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
xmpp_xep_fallback_indication_value_get_fallback (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK), NULL);
	return value->data[0].v_pointer;
}

void
xmpp_xep_fallback_indication_value_set_fallback (GValue* value,
                                                 gpointer v_object)
{
	XmppXepFallbackIndicationFallback * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		xmpp_xep_fallback_indication_fallback_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_fallback_indication_fallback_unref (old);
	}
}

void
xmpp_xep_fallback_indication_value_take_fallback (GValue* value,
                                                  gpointer v_object)
{
	XmppXepFallbackIndicationFallback * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_fallback_indication_fallback_unref (old);
	}
}

static void
xmpp_xep_fallback_indication_fallback_class_init (XmppXepFallbackIndicationFallbackClass * klass,
                                                  gpointer klass_data)
{
	xmpp_xep_fallback_indication_fallback_parent_class = g_type_class_peek_parent (klass);
	((XmppXepFallbackIndicationFallbackClass *) klass)->finalize = xmpp_xep_fallback_indication_fallback_finalize;
	g_type_class_adjust_private_offset (klass, &XmppXepFallbackIndicationFallback_private_offset);
}

static void
xmpp_xep_fallback_indication_fallback_instance_init (XmppXepFallbackIndicationFallback * self,
                                                     gpointer klass)
{
	self->priv = xmpp_xep_fallback_indication_fallback_get_instance_private (self);
	self->ref_count = 1;
}

static void
xmpp_xep_fallback_indication_fallback_finalize (XmppXepFallbackIndicationFallback * obj)
{
	XmppXepFallbackIndicationFallback * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK, XmppXepFallbackIndicationFallback);
	g_signal_handlers_destroy (self);
	_g_free0 (self->priv->_ns_uri);
	_g_object_unref0 (self->locations);
}

static GType
xmpp_xep_fallback_indication_fallback_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_xep_fallback_indication_value_fallback_init, xmpp_xep_fallback_indication_value_fallback_free_value, xmpp_xep_fallback_indication_value_fallback_copy_value, xmpp_xep_fallback_indication_value_fallback_peek_pointer, "p", xmpp_xep_fallback_indication_value_fallback_collect_value, "p", xmpp_xep_fallback_indication_value_fallback_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepFallbackIndicationFallbackClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_fallback_indication_fallback_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepFallbackIndicationFallback), 0, (GInstanceInitFunc) xmpp_xep_fallback_indication_fallback_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType xmpp_xep_fallback_indication_fallback_type_id;
	xmpp_xep_fallback_indication_fallback_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppXepFallbackIndicationFallback", &g_define_type_info, &g_define_type_fundamental_info, 0);
	XmppXepFallbackIndicationFallback_private_offset = g_type_add_instance_private (xmpp_xep_fallback_indication_fallback_type_id, sizeof (XmppXepFallbackIndicationFallbackPrivate));
	return xmpp_xep_fallback_indication_fallback_type_id;
}

GType
xmpp_xep_fallback_indication_fallback_get_type (void)
{
	static volatile gsize xmpp_xep_fallback_indication_fallback_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_fallback_indication_fallback_type_id__once)) {
		GType xmpp_xep_fallback_indication_fallback_type_id;
		xmpp_xep_fallback_indication_fallback_type_id = xmpp_xep_fallback_indication_fallback_get_type_once ();
		g_once_init_leave (&xmpp_xep_fallback_indication_fallback_type_id__once, xmpp_xep_fallback_indication_fallback_type_id);
	}
	return xmpp_xep_fallback_indication_fallback_type_id__once;
}

gpointer
xmpp_xep_fallback_indication_fallback_ref (gpointer instance)
{
	XmppXepFallbackIndicationFallback * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
xmpp_xep_fallback_indication_fallback_unref (gpointer instance)
{
	XmppXepFallbackIndicationFallback * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_XEP_FALLBACK_INDICATION_FALLBACK_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static inline gpointer
xmpp_xep_fallback_indication_fallback_location_get_instance_private (XmppXepFallbackIndicationFallbackLocation* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepFallbackIndicationFallbackLocation_private_offset);
}

XmppXepFallbackIndicationFallbackLocation*
xmpp_xep_fallback_indication_fallback_location_construct_partial_body (GType object_type,
                                                                       gint from_char,
                                                                       gint to_char)
{
	XmppXepFallbackIndicationFallbackLocation* self = NULL;
	self = (XmppXepFallbackIndicationFallbackLocation*) g_type_create_instance (object_type);
	xmpp_xep_fallback_indication_fallback_location_set_from_char (self, from_char);
	xmpp_xep_fallback_indication_fallback_location_set_to_char (self, to_char);
	return self;
}

XmppXepFallbackIndicationFallbackLocation*
xmpp_xep_fallback_indication_fallback_location_new_partial_body (gint from_char,
                                                                 gint to_char)
{
	return xmpp_xep_fallback_indication_fallback_location_construct_partial_body (XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION, from_char, to_char);
}

XmppXepFallbackIndicationFallbackLocation*
xmpp_xep_fallback_indication_fallback_location_construct_whole_body (GType object_type)
{
	XmppXepFallbackIndicationFallbackLocation* self = NULL;
	self = (XmppXepFallbackIndicationFallbackLocation*) g_type_create_instance (object_type);
	xmpp_xep_fallback_indication_fallback_location_set_from_char (self, -1);
	xmpp_xep_fallback_indication_fallback_location_set_to_char (self, -1);
	return self;
}

XmppXepFallbackIndicationFallbackLocation*
xmpp_xep_fallback_indication_fallback_location_new_whole_body (void)
{
	return xmpp_xep_fallback_indication_fallback_location_construct_whole_body (XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION);
}

XmppXepFallbackIndicationFallbackLocation*
xmpp_xep_fallback_indication_fallback_location_construct (GType object_type)
{
	XmppXepFallbackIndicationFallbackLocation* self = NULL;
	self = (XmppXepFallbackIndicationFallbackLocation*) g_type_create_instance (object_type);
	return self;
}

XmppXepFallbackIndicationFallbackLocation*
xmpp_xep_fallback_indication_fallback_location_new (void)
{
	return xmpp_xep_fallback_indication_fallback_location_construct (XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION);
}

gboolean
xmpp_xep_fallback_indication_fallback_location_get_is_whole (XmppXepFallbackIndicationFallbackLocation* self)
{
	gboolean result;
	gboolean _tmp0_ = FALSE;
	gint _tmp1_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = self->priv->_from_char;
	if (_tmp1_ == -1) {
		gint _tmp2_;
		_tmp2_ = self->priv->_to_char;
		_tmp0_ = _tmp2_ == -1;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

gint
xmpp_xep_fallback_indication_fallback_location_get_from_char (XmppXepFallbackIndicationFallbackLocation* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_from_char;
	return result;
}

void
xmpp_xep_fallback_indication_fallback_location_set_from_char (XmppXepFallbackIndicationFallbackLocation* self,
                                                              gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_from_char = value;
}

gint
xmpp_xep_fallback_indication_fallback_location_get_to_char (XmppXepFallbackIndicationFallbackLocation* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_to_char;
	return result;
}

void
xmpp_xep_fallback_indication_fallback_location_set_to_char (XmppXepFallbackIndicationFallbackLocation* self,
                                                            gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_to_char = value;
}

static void
xmpp_xep_fallback_indication_value_fallback_location_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
xmpp_xep_fallback_indication_value_fallback_location_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		xmpp_xep_fallback_indication_fallback_location_unref (value->data[0].v_pointer);
	}
}

static void
xmpp_xep_fallback_indication_value_fallback_location_copy_value (const GValue* src_value,
                                                                 GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = xmpp_xep_fallback_indication_fallback_location_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
xmpp_xep_fallback_indication_value_fallback_location_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
xmpp_xep_fallback_indication_value_fallback_location_collect_value (GValue* value,
                                                                    guint n_collect_values,
                                                                    GTypeCValue* collect_values,
                                                                    guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		XmppXepFallbackIndicationFallbackLocation * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = xmpp_xep_fallback_indication_fallback_location_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
xmpp_xep_fallback_indication_value_fallback_location_lcopy_value (const GValue* value,
                                                                  guint n_collect_values,
                                                                  GTypeCValue* collect_values,
                                                                  guint collect_flags)
{
	XmppXepFallbackIndicationFallbackLocation ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = xmpp_xep_fallback_indication_fallback_location_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
xmpp_xep_fallback_indication_param_spec_fallback_location (const gchar* name,
                                                           const gchar* nick,
                                                           const gchar* blurb,
                                                           GType object_type,
                                                           GParamFlags flags)
{
	XmppXepFallbackIndicationParamSpecFallbackLocation* spec;
	g_return_val_if_fail (g_type_is_a (object_type, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
xmpp_xep_fallback_indication_value_get_fallback_location (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION), NULL);
	return value->data[0].v_pointer;
}

void
xmpp_xep_fallback_indication_value_set_fallback_location (GValue* value,
                                                          gpointer v_object)
{
	XmppXepFallbackIndicationFallbackLocation * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		xmpp_xep_fallback_indication_fallback_location_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_fallback_indication_fallback_location_unref (old);
	}
}

void
xmpp_xep_fallback_indication_value_take_fallback_location (GValue* value,
                                                           gpointer v_object)
{
	XmppXepFallbackIndicationFallbackLocation * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_fallback_indication_fallback_location_unref (old);
	}
}

static void
xmpp_xep_fallback_indication_fallback_location_class_init (XmppXepFallbackIndicationFallbackLocationClass * klass,
                                                           gpointer klass_data)
{
	xmpp_xep_fallback_indication_fallback_location_parent_class = g_type_class_peek_parent (klass);
	((XmppXepFallbackIndicationFallbackLocationClass *) klass)->finalize = xmpp_xep_fallback_indication_fallback_location_finalize;
	g_type_class_adjust_private_offset (klass, &XmppXepFallbackIndicationFallbackLocation_private_offset);
}

static void
xmpp_xep_fallback_indication_fallback_location_instance_init (XmppXepFallbackIndicationFallbackLocation * self,
                                                              gpointer klass)
{
	self->priv = xmpp_xep_fallback_indication_fallback_location_get_instance_private (self);
	self->ref_count = 1;
}

static void
xmpp_xep_fallback_indication_fallback_location_finalize (XmppXepFallbackIndicationFallbackLocation * obj)
{
	XmppXepFallbackIndicationFallbackLocation * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION, XmppXepFallbackIndicationFallbackLocation);
	g_signal_handlers_destroy (self);
}

static GType
xmpp_xep_fallback_indication_fallback_location_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_xep_fallback_indication_value_fallback_location_init, xmpp_xep_fallback_indication_value_fallback_location_free_value, xmpp_xep_fallback_indication_value_fallback_location_copy_value, xmpp_xep_fallback_indication_value_fallback_location_peek_pointer, "p", xmpp_xep_fallback_indication_value_fallback_location_collect_value, "p", xmpp_xep_fallback_indication_value_fallback_location_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepFallbackIndicationFallbackLocationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_fallback_indication_fallback_location_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepFallbackIndicationFallbackLocation), 0, (GInstanceInitFunc) xmpp_xep_fallback_indication_fallback_location_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType xmpp_xep_fallback_indication_fallback_location_type_id;
	xmpp_xep_fallback_indication_fallback_location_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppXepFallbackIndicationFallbackLocation", &g_define_type_info, &g_define_type_fundamental_info, 0);
	XmppXepFallbackIndicationFallbackLocation_private_offset = g_type_add_instance_private (xmpp_xep_fallback_indication_fallback_location_type_id, sizeof (XmppXepFallbackIndicationFallbackLocationPrivate));
	return xmpp_xep_fallback_indication_fallback_location_type_id;
}

GType
xmpp_xep_fallback_indication_fallback_location_get_type (void)
{
	static volatile gsize xmpp_xep_fallback_indication_fallback_location_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_fallback_indication_fallback_location_type_id__once)) {
		GType xmpp_xep_fallback_indication_fallback_location_type_id;
		xmpp_xep_fallback_indication_fallback_location_type_id = xmpp_xep_fallback_indication_fallback_location_get_type_once ();
		g_once_init_leave (&xmpp_xep_fallback_indication_fallback_location_type_id__once, xmpp_xep_fallback_indication_fallback_location_type_id);
	}
	return xmpp_xep_fallback_indication_fallback_location_type_id__once;
}

gpointer
xmpp_xep_fallback_indication_fallback_location_ref (gpointer instance)
{
	XmppXepFallbackIndicationFallbackLocation * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
xmpp_xep_fallback_indication_fallback_location_unref (gpointer instance)
{
	XmppXepFallbackIndicationFallbackLocation * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_XEP_FALLBACK_INDICATION_FALLBACK_LOCATION_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

void
xmpp_xep_fallback_indication_set_fallback (XmppMessageStanza* message,
                                           XmppXepFallbackIndicationFallback* fallback)
{
	XmppStanzaNode* fallback_node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	XmppStanzaNode* _tmp6_;
	XmppStanzaNode* _tmp7_;
	XmppStanzaNode* _tmp42_;
	XmppStanzaNode* _tmp43_;
	XmppStanzaNode* _tmp44_;
	XmppStanzaNode* _tmp45_;
	g_return_if_fail (message != NULL);
	g_return_if_fail (fallback != NULL);
	_tmp0_ = xmpp_stanza_node_new_build ("fallback", XMPP_XEP_FALLBACK_INDICATION_NS_URI, NULL, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = xmpp_stanza_node_add_self_xmlns (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_xep_fallback_indication_fallback_get_ns_uri (fallback);
	_tmp5_ = _tmp4_;
	_tmp6_ = xmpp_stanza_node_put_attribute (_tmp3_, "for", _tmp5_, NULL);
	_tmp7_ = _tmp6_;
	_xmpp_stanza_entry_unref0 (_tmp3_);
	_xmpp_stanza_entry_unref0 (_tmp1_);
	fallback_node = _tmp7_;
	{
		GeeList* _location_list = NULL;
		GeeList* _tmp8_;
		gint _location_size = 0;
		GeeList* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		gint _location_index = 0;
		_tmp8_ = fallback->locations;
		_location_list = _tmp8_;
		_tmp9_ = _location_list;
		_tmp10_ = gee_collection_get_size ((GeeCollection*) _tmp9_);
		_tmp11_ = _tmp10_;
		_location_size = _tmp11_;
		_location_index = -1;
		while (TRUE) {
			gint _tmp12_;
			gint _tmp13_;
			XmppXepFallbackIndicationFallbackLocation* location = NULL;
			GeeList* _tmp14_;
			gpointer _tmp15_;
			XmppStanzaNode* node = NULL;
			XmppStanzaNode* _tmp16_;
			XmppStanzaNode* _tmp17_;
			XmppStanzaNode* _tmp18_;
			XmppStanzaNode* _tmp19_;
			XmppXepFallbackIndicationFallbackLocation* _tmp20_;
			gboolean _tmp21_;
			gboolean _tmp22_;
			XmppStanzaNode* _tmp38_;
			XmppStanzaNode* _tmp39_;
			XmppStanzaNode* _tmp40_;
			XmppStanzaNode* _tmp41_;
			_location_index = _location_index + 1;
			_tmp12_ = _location_index;
			_tmp13_ = _location_size;
			if (!(_tmp12_ < _tmp13_)) {
				break;
			}
			_tmp14_ = _location_list;
			_tmp15_ = gee_list_get (_tmp14_, _location_index);
			location = (XmppXepFallbackIndicationFallbackLocation*) _tmp15_;
			_tmp16_ = xmpp_stanza_node_new_build ("body", XMPP_XEP_FALLBACK_INDICATION_NS_URI, NULL, NULL);
			_tmp17_ = _tmp16_;
			_tmp18_ = xmpp_stanza_node_add_self_xmlns (_tmp17_);
			_tmp19_ = _tmp18_;
			_xmpp_stanza_entry_unref0 (_tmp17_);
			node = _tmp19_;
			_tmp20_ = location;
			_tmp21_ = xmpp_xep_fallback_indication_fallback_location_get_is_whole (_tmp20_);
			_tmp22_ = _tmp21_;
			if (!_tmp22_) {
				XmppStanzaNode* _tmp23_;
				XmppXepFallbackIndicationFallbackLocation* _tmp24_;
				gint _tmp25_;
				gint _tmp26_;
				gchar* _tmp27_;
				gchar* _tmp28_;
				XmppStanzaNode* _tmp29_;
				XmppStanzaNode* _tmp30_;
				XmppXepFallbackIndicationFallbackLocation* _tmp31_;
				gint _tmp32_;
				gint _tmp33_;
				gchar* _tmp34_;
				gchar* _tmp35_;
				XmppStanzaNode* _tmp36_;
				XmppStanzaNode* _tmp37_;
				_tmp23_ = node;
				_tmp24_ = location;
				_tmp25_ = xmpp_xep_fallback_indication_fallback_location_get_from_char (_tmp24_);
				_tmp26_ = _tmp25_;
				_tmp27_ = g_strdup_printf ("%i", _tmp26_);
				_tmp28_ = _tmp27_;
				_tmp29_ = xmpp_stanza_node_put_attribute (_tmp23_, "start", _tmp28_, NULL);
				_tmp30_ = _tmp29_;
				_tmp31_ = location;
				_tmp32_ = xmpp_xep_fallback_indication_fallback_location_get_to_char (_tmp31_);
				_tmp33_ = _tmp32_;
				_tmp34_ = g_strdup_printf ("%i", _tmp33_);
				_tmp35_ = _tmp34_;
				_tmp36_ = xmpp_stanza_node_put_attribute (_tmp30_, "end", _tmp35_, NULL);
				_tmp37_ = _tmp36_;
				_xmpp_stanza_entry_unref0 (_tmp37_);
				_g_free0 (_tmp35_);
				_xmpp_stanza_entry_unref0 (_tmp30_);
				_g_free0 (_tmp28_);
			}
			_tmp38_ = fallback_node;
			_tmp39_ = node;
			_tmp40_ = xmpp_stanza_node_put_node (_tmp38_, _tmp39_);
			_tmp41_ = _tmp40_;
			_xmpp_stanza_entry_unref0 (_tmp41_);
			_xmpp_stanza_entry_unref0 (node);
			_xmpp_xep_fallback_indication_fallback_location_unref0 (location);
		}
	}
	_tmp42_ = ((XmppStanza*) message)->stanza;
	_tmp43_ = fallback_node;
	_tmp44_ = xmpp_stanza_node_put_node (_tmp42_, _tmp43_);
	_tmp45_ = _tmp44_;
	_xmpp_stanza_entry_unref0 (_tmp45_);
	_xmpp_stanza_entry_unref0 (fallback_node);
}

GeeList*
xmpp_xep_fallback_indication_get_fallbacks (XmppMessageStanza* message)
{
	GeeArrayList* ret = NULL;
	GeeArrayList* _tmp0_;
	GeeList* fallback_nodes = NULL;
	XmppStanzaNode* _tmp1_;
	GeeList* _tmp2_;
	GeeList* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	GeeList* result;
	g_return_val_if_fail (message != NULL, NULL);
	_tmp0_ = gee_array_list_new (XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK, (GBoxedCopyFunc) xmpp_xep_fallback_indication_fallback_ref, (GDestroyNotify) xmpp_xep_fallback_indication_fallback_unref, NULL, NULL, NULL);
	ret = _tmp0_;
	_tmp1_ = ((XmppStanza*) message)->stanza;
	_tmp2_ = xmpp_stanza_node_get_subnodes (_tmp1_, "fallback", XMPP_XEP_FALLBACK_INDICATION_NS_URI, FALSE);
	fallback_nodes = _tmp2_;
	_tmp3_ = fallback_nodes;
	_tmp4_ = gee_collection_get_is_empty ((GeeCollection*) _tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		result = (GeeList*) ret;
		_g_object_unref0 (fallback_nodes);
		return result;
	}
	{
		GeeList* _fallback_node_list = NULL;
		GeeList* _tmp6_;
		gint _fallback_node_size = 0;
		GeeList* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		gint _fallback_node_index = 0;
		_tmp6_ = fallback_nodes;
		_fallback_node_list = _tmp6_;
		_tmp7_ = _fallback_node_list;
		_tmp8_ = gee_collection_get_size ((GeeCollection*) _tmp7_);
		_tmp9_ = _tmp8_;
		_fallback_node_size = _tmp9_;
		_fallback_node_index = -1;
		while (TRUE) {
			gint _tmp10_;
			gint _tmp11_;
			XmppStanzaNode* fallback_node = NULL;
			GeeList* _tmp12_;
			gpointer _tmp13_;
			gchar* ns_uri = NULL;
			XmppStanzaNode* _tmp14_;
			const gchar* _tmp15_;
			gchar* _tmp16_;
			const gchar* _tmp17_;
			GeeArrayList* locations = NULL;
			GeeArrayList* _tmp18_;
			XmppStanzaNode* _tmp19_;
			GeeList* _tmp20_;
			GeeList* _tmp21_;
			gboolean _tmp22_;
			gboolean _tmp23_;
			gboolean _tmp24_;
			GeeArrayList* _tmp48_;
			gboolean _tmp49_;
			gboolean _tmp50_;
			GeeArrayList* _tmp51_;
			const gchar* _tmp52_;
			GeeArrayList* _tmp53_;
			XmppXepFallbackIndicationFallback* _tmp54_;
			XmppXepFallbackIndicationFallback* _tmp55_;
			_fallback_node_index = _fallback_node_index + 1;
			_tmp10_ = _fallback_node_index;
			_tmp11_ = _fallback_node_size;
			if (!(_tmp10_ < _tmp11_)) {
				break;
			}
			_tmp12_ = _fallback_node_list;
			_tmp13_ = gee_list_get (_tmp12_, _fallback_node_index);
			fallback_node = (XmppStanzaNode*) _tmp13_;
			_tmp14_ = fallback_node;
			_tmp15_ = xmpp_stanza_node_get_attribute (_tmp14_, "for", NULL);
			_tmp16_ = g_strdup (_tmp15_);
			ns_uri = _tmp16_;
			_tmp17_ = ns_uri;
			if (_tmp17_ == NULL) {
				_g_free0 (ns_uri);
				_xmpp_stanza_entry_unref0 (fallback_node);
				continue;
			}
			_tmp18_ = gee_array_list_new (XMPP_XEP_FALLBACK_INDICATION_TYPE_FALLBACK_LOCATION, (GBoxedCopyFunc) xmpp_xep_fallback_indication_fallback_location_ref, (GDestroyNotify) xmpp_xep_fallback_indication_fallback_location_unref, NULL, NULL, NULL);
			locations = _tmp18_;
			_tmp19_ = fallback_node;
			_tmp20_ = xmpp_stanza_node_get_all_subnodes (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = gee_collection_get_is_empty ((GeeCollection*) _tmp21_);
			_tmp23_ = _tmp22_;
			_tmp24_ = _tmp23_;
			_g_object_unref0 (_tmp21_);
			if (_tmp24_) {
				GeeArrayList* _tmp25_;
				XmppXepFallbackIndicationFallbackLocation* _tmp26_;
				XmppXepFallbackIndicationFallbackLocation* _tmp27_;
				_tmp25_ = locations;
				_tmp26_ = xmpp_xep_fallback_indication_fallback_location_new_whole_body ();
				_tmp27_ = _tmp26_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp25_, _tmp27_);
				_xmpp_xep_fallback_indication_fallback_location_unref0 (_tmp27_);
			} else {
				GeeList* body_nodes = NULL;
				XmppStanzaNode* _tmp28_;
				GeeList* _tmp29_;
				_tmp28_ = fallback_node;
				_tmp29_ = xmpp_stanza_node_get_subnodes (_tmp28_, "body", XMPP_XEP_FALLBACK_INDICATION_NS_URI, FALSE);
				body_nodes = _tmp29_;
				{
					GeeList* _body_node_list = NULL;
					GeeList* _tmp30_;
					gint _body_node_size = 0;
					GeeList* _tmp31_;
					gint _tmp32_;
					gint _tmp33_;
					gint _body_node_index = 0;
					_tmp30_ = body_nodes;
					_body_node_list = _tmp30_;
					_tmp31_ = _body_node_list;
					_tmp32_ = gee_collection_get_size ((GeeCollection*) _tmp31_);
					_tmp33_ = _tmp32_;
					_body_node_size = _tmp33_;
					_body_node_index = -1;
					while (TRUE) {
						gint _tmp34_;
						gint _tmp35_;
						XmppStanzaNode* body_node = NULL;
						GeeList* _tmp36_;
						gpointer _tmp37_;
						gint start_char = 0;
						XmppStanzaNode* _tmp38_;
						gint end_char = 0;
						XmppStanzaNode* _tmp39_;
						gboolean _tmp40_ = FALSE;
						gboolean _tmp44_ = FALSE;
						GeeArrayList* _tmp45_;
						XmppXepFallbackIndicationFallbackLocation* _tmp46_;
						XmppXepFallbackIndicationFallbackLocation* _tmp47_;
						_body_node_index = _body_node_index + 1;
						_tmp34_ = _body_node_index;
						_tmp35_ = _body_node_size;
						if (!(_tmp34_ < _tmp35_)) {
							break;
						}
						_tmp36_ = _body_node_list;
						_tmp37_ = gee_list_get (_tmp36_, _body_node_index);
						body_node = (XmppStanzaNode*) _tmp37_;
						_tmp38_ = body_node;
						start_char = xmpp_stanza_node_get_attribute_int (_tmp38_, "start", -1, NULL);
						_tmp39_ = body_node;
						end_char = xmpp_stanza_node_get_attribute_int (_tmp39_, "end", -1, NULL);
						if (start_char == -1) {
							_tmp40_ = end_char == -1;
						} else {
							_tmp40_ = FALSE;
						}
						if (_tmp40_) {
							GeeArrayList* _tmp41_;
							XmppXepFallbackIndicationFallbackLocation* _tmp42_;
							XmppXepFallbackIndicationFallbackLocation* _tmp43_;
							_tmp41_ = locations;
							_tmp42_ = xmpp_xep_fallback_indication_fallback_location_new_whole_body ();
							_tmp43_ = _tmp42_;
							gee_abstract_collection_add ((GeeAbstractCollection*) _tmp41_, _tmp43_);
							_xmpp_xep_fallback_indication_fallback_location_unref0 (_tmp43_);
							_xmpp_stanza_entry_unref0 (body_node);
							continue;
						}
						if (start_char == -1) {
							_tmp44_ = TRUE;
						} else {
							_tmp44_ = end_char == -1;
						}
						if (_tmp44_) {
							_xmpp_stanza_entry_unref0 (body_node);
							continue;
						}
						_tmp45_ = locations;
						_tmp46_ = xmpp_xep_fallback_indication_fallback_location_new_partial_body (start_char, end_char);
						_tmp47_ = _tmp46_;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp45_, _tmp47_);
						_xmpp_xep_fallback_indication_fallback_location_unref0 (_tmp47_);
						_xmpp_stanza_entry_unref0 (body_node);
					}
				}
				_g_object_unref0 (body_nodes);
			}
			_tmp48_ = locations;
			_tmp49_ = gee_collection_get_is_empty ((GeeCollection*) _tmp48_);
			_tmp50_ = _tmp49_;
			if (_tmp50_) {
				_g_object_unref0 (locations);
				_g_free0 (ns_uri);
				_xmpp_stanza_entry_unref0 (fallback_node);
				continue;
			}
			_tmp51_ = ret;
			_tmp52_ = ns_uri;
			_tmp53_ = locations;
			_tmp54_ = xmpp_xep_fallback_indication_fallback_new (_tmp52_, (GeeList*) _tmp53_);
			_tmp55_ = _tmp54_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp51_, _tmp55_);
			_xmpp_xep_fallback_indication_fallback_unref0 (_tmp55_);
			_g_object_unref0 (locations);
			_g_free0 (ns_uri);
			_xmpp_stanza_entry_unref0 (fallback_node);
		}
	}
	result = (GeeList*) ret;
	_g_object_unref0 (fallback_nodes);
	return result;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

