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

#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.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 _xmpp_xep_jingle_ice_udp_candidate_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_jingle_ice_udp_candidate_unref (var), NULL)))
#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
typedef struct _XmppXepJingleIceUdpParamSpecCandidate XmppXepJingleIceUdpParamSpecCandidate;

struct _XmppXepJingleIceUdpParamSpecCandidate {
	GParamSpec parent_instance;
};

static gpointer xmpp_xep_jingle_ice_udp_candidate_parent_class = NULL;

static void xmpp_xep_jingle_ice_udp_candidate_finalize (XmppXepJingleIceUdpCandidate * obj);
static GType xmpp_xep_jingle_ice_udp_candidate_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

XmppXepJingleIceUdpCandidateType
xmpp_xep_jingle_ice_udp_candidate_type_parse (const gchar* str,
                                              GError** error)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	static GQuark _tmp1_label3 = 0;
	GError* _inner_error0_ = NULL;
	XmppXepJingleIceUdpCandidateType result;
	g_return_val_if_fail (str != NULL, 0);
	_tmp0_ = str;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("host")))) {
		switch (0) {
			default:
			{
				result = XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_HOST;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("prflx")))) {
		switch (0) {
			default:
			{
				result = XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_PRFLX;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("relay")))) {
		switch (0) {
			default:
			{
				result = XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_RELAY;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label3) ? _tmp1_label3 : (_tmp1_label3 = g_quark_from_static_string ("srflx")))) {
		switch (0) {
			default:
			{
				result = XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_SRFLX;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				GError* _tmp3_;
				_tmp3_ = g_error_new_literal (XMPP_XEP_JINGLE_IQ_ERROR, XMPP_XEP_JINGLE_IQ_ERROR_BAD_REQUEST, "Illegal ICE-UDP candidate type");
				_inner_error0_ = _tmp3_;
				if (_inner_error0_->domain == XMPP_XEP_JINGLE_IQ_ERROR) {
					g_propagate_error (error, _inner_error0_);
					return 0;
				} else {
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return 0;
				}
			}
		}
	}
}

gchar*
xmpp_xep_jingle_ice_udp_candidate_type_to_string (XmppXepJingleIceUdpCandidateType self)
{
	gchar* result;
	switch (self) {
		case XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_HOST:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("host");
			result = _tmp0_;
			return result;
		}
		case XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_PRFLX:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("prflx");
			result = _tmp1_;
			return result;
		}
		case XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_RELAY:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("relay");
			result = _tmp2_;
			return result;
		}
		case XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_SRFLX:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("srflx");
			result = _tmp3_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

static GType
xmpp_xep_jingle_ice_udp_candidate_type_get_type_once (void)
{
	static const GEnumValue values[] = {{XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_HOST, "XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_HOST", "host"}, {XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_PRFLX, "XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_PRFLX", "prflx"}, {XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_RELAY, "XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_RELAY", "relay"}, {XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_SRFLX, "XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_TYPE_SRFLX", "srflx"}, {0, NULL, NULL}};
	GType xmpp_xep_jingle_ice_udp_candidate_type_type_id;
	xmpp_xep_jingle_ice_udp_candidate_type_type_id = g_enum_register_static ("XmppXepJingleIceUdpCandidateType", values);
	return xmpp_xep_jingle_ice_udp_candidate_type_type_id;
}

GType
xmpp_xep_jingle_ice_udp_candidate_type_get_type (void)
{
	static volatile gsize xmpp_xep_jingle_ice_udp_candidate_type_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_jingle_ice_udp_candidate_type_type_id__once)) {
		GType xmpp_xep_jingle_ice_udp_candidate_type_type_id;
		xmpp_xep_jingle_ice_udp_candidate_type_type_id = xmpp_xep_jingle_ice_udp_candidate_type_get_type_once ();
		g_once_init_leave (&xmpp_xep_jingle_ice_udp_candidate_type_type_id__once, xmpp_xep_jingle_ice_udp_candidate_type_type_id);
	}
	return xmpp_xep_jingle_ice_udp_candidate_type_type_id__once;
}

XmppXepJingleIceUdpCandidate*
xmpp_xep_jingle_ice_udp_candidate_parse (XmppStanzaNode* node,
                                         GError** error)
{
	XmppXepJingleIceUdpCandidate* candidate = NULL;
	XmppXepJingleIceUdpCandidate* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	XmppXepJingleIceUdpCandidateType _tmp11_ = 0;
	const gchar* _tmp12_;
	GError* _inner_error0_ = NULL;
	XmppXepJingleIceUdpCandidate* result;
	g_return_val_if_fail (node != NULL, NULL);
	_tmp0_ = xmpp_xep_jingle_ice_udp_candidate_new ();
	candidate = _tmp0_;
	candidate->component = (guint8) xmpp_stanza_node_get_attribute_uint (node, "component", (guint) 0, NULL);
	_tmp1_ = xmpp_stanza_node_get_attribute (node, "foundation", NULL);
	_tmp2_ = g_strdup ((const gchar*) _tmp1_);
	_g_free0 (candidate->foundation);
	candidate->foundation = _tmp2_;
	candidate->generation = (guint8) xmpp_stanza_node_get_attribute_uint (node, "generation", (guint) 0, NULL);
	_tmp3_ = xmpp_stanza_node_get_attribute (node, "id", NULL);
	_tmp4_ = g_strdup (_tmp3_);
	_g_free0 (candidate->id);
	candidate->id = _tmp4_;
	_tmp5_ = xmpp_stanza_node_get_attribute (node, "ip", NULL);
	_tmp6_ = g_strdup (_tmp5_);
	_g_free0 (candidate->ip);
	candidate->ip = _tmp6_;
	candidate->network = (guint8) xmpp_stanza_node_get_attribute_uint (node, "network", (guint) 0, NULL);
	candidate->port = (guint16) xmpp_stanza_node_get_attribute_uint (node, "port", (guint) 0, NULL);
	candidate->priority = (guint32) xmpp_stanza_node_get_attribute_uint (node, "priority", (guint) 0, NULL);
	_tmp7_ = xmpp_stanza_node_get_attribute (node, "protocol", NULL);
	_tmp8_ = g_strdup (_tmp7_);
	_g_free0 (candidate->protocol);
	candidate->protocol = _tmp8_;
	_tmp9_ = xmpp_stanza_node_get_attribute (node, "rel-addr", NULL);
	_tmp10_ = g_strdup (_tmp9_);
	_g_free0 (candidate->rel_addr);
	candidate->rel_addr = _tmp10_;
	candidate->rel_port = (guint16) xmpp_stanza_node_get_attribute_uint (node, "rel-port", (guint) 0, NULL);
	_tmp12_ = xmpp_stanza_node_get_attribute (node, "type", NULL);
	_tmp11_ = xmpp_xep_jingle_ice_udp_candidate_type_parse (_tmp12_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == XMPP_XEP_JINGLE_IQ_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_xmpp_xep_jingle_ice_udp_candidate_unref0 (candidate);
			return NULL;
		} else {
			_xmpp_xep_jingle_ice_udp_candidate_unref0 (candidate);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
	}
	candidate->type_ = _tmp11_;
	result = candidate;
	return result;
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

XmppStanzaNode*
xmpp_xep_jingle_ice_udp_candidate_to_xml (XmppXepJingleIceUdpCandidate* self)
{
	XmppStanzaNode* node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	XmppStanzaNode* _tmp8_;
	XmppStanzaNode* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	XmppStanzaNode* _tmp12_;
	XmppStanzaNode* _tmp13_;
	const gchar* _tmp14_;
	XmppStanzaNode* _tmp15_;
	XmppStanzaNode* _tmp16_;
	const gchar* _tmp17_;
	XmppStanzaNode* _tmp18_;
	XmppStanzaNode* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	XmppStanzaNode* _tmp22_;
	XmppStanzaNode* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	XmppStanzaNode* _tmp26_;
	XmppStanzaNode* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	XmppStanzaNode* _tmp30_;
	XmppStanzaNode* _tmp31_;
	const gchar* _tmp32_;
	XmppStanzaNode* _tmp33_;
	XmppStanzaNode* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	XmppStanzaNode* _tmp37_;
	XmppStanzaNode* _tmp38_;
	const gchar* _tmp39_;
	XmppStanzaNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = xmpp_stanza_node_new_build ("candidate", XMPP_XEP_JINGLE_ICE_UDP_NS_URI, NULL, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup_printf ("%hhu", self->component);
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_stanza_node_put_attribute (_tmp1_, "component", _tmp3_, NULL);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->foundation;
	_tmp7_ = string_to_string (_tmp6_);
	_tmp8_ = xmpp_stanza_node_put_attribute (_tmp5_, "foundation", _tmp7_, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strdup_printf ("%hhu", self->generation);
	_tmp11_ = _tmp10_;
	_tmp12_ = xmpp_stanza_node_put_attribute (_tmp9_, "generation", _tmp11_, NULL);
	_tmp13_ = _tmp12_;
	_tmp14_ = self->id;
	_tmp15_ = xmpp_stanza_node_put_attribute (_tmp13_, "id", _tmp14_, NULL);
	_tmp16_ = _tmp15_;
	_tmp17_ = self->ip;
	_tmp18_ = xmpp_stanza_node_put_attribute (_tmp16_, "ip", _tmp17_, NULL);
	_tmp19_ = _tmp18_;
	_tmp20_ = g_strdup_printf ("%hhu", self->network);
	_tmp21_ = _tmp20_;
	_tmp22_ = xmpp_stanza_node_put_attribute (_tmp19_, "network", _tmp21_, NULL);
	_tmp23_ = _tmp22_;
	_tmp24_ = g_strdup_printf ("%hu", self->port);
	_tmp25_ = _tmp24_;
	_tmp26_ = xmpp_stanza_node_put_attribute (_tmp23_, "port", _tmp25_, NULL);
	_tmp27_ = _tmp26_;
	_tmp28_ = g_strdup_printf ("%u", self->priority);
	_tmp29_ = _tmp28_;
	_tmp30_ = xmpp_stanza_node_put_attribute (_tmp27_, "priority", _tmp29_, NULL);
	_tmp31_ = _tmp30_;
	_tmp32_ = self->protocol;
	_tmp33_ = xmpp_stanza_node_put_attribute (_tmp31_, "protocol", _tmp32_, NULL);
	_tmp34_ = _tmp33_;
	_tmp35_ = xmpp_xep_jingle_ice_udp_candidate_type_to_string (self->type_);
	_tmp36_ = _tmp35_;
	_tmp37_ = xmpp_stanza_node_put_attribute (_tmp34_, "type", _tmp36_, NULL);
	_tmp38_ = _tmp37_;
	_g_free0 (_tmp36_);
	_xmpp_stanza_entry_unref0 (_tmp34_);
	_xmpp_stanza_entry_unref0 (_tmp31_);
	_g_free0 (_tmp29_);
	_xmpp_stanza_entry_unref0 (_tmp27_);
	_g_free0 (_tmp25_);
	_xmpp_stanza_entry_unref0 (_tmp23_);
	_g_free0 (_tmp21_);
	_xmpp_stanza_entry_unref0 (_tmp19_);
	_xmpp_stanza_entry_unref0 (_tmp16_);
	_xmpp_stanza_entry_unref0 (_tmp13_);
	_g_free0 (_tmp11_);
	_xmpp_stanza_entry_unref0 (_tmp9_);
	_xmpp_stanza_entry_unref0 (_tmp5_);
	_g_free0 (_tmp3_);
	_xmpp_stanza_entry_unref0 (_tmp1_);
	node = _tmp38_;
	_tmp39_ = self->rel_addr;
	if (_tmp39_ != NULL) {
		XmppStanzaNode* _tmp40_;
		const gchar* _tmp41_;
		XmppStanzaNode* _tmp42_;
		XmppStanzaNode* _tmp43_;
		_tmp40_ = node;
		_tmp41_ = self->rel_addr;
		_tmp42_ = xmpp_stanza_node_put_attribute (_tmp40_, "rel-addr", _tmp41_, NULL);
		_tmp43_ = _tmp42_;
		_xmpp_stanza_entry_unref0 (_tmp43_);
	}
	if (((gint) self->rel_port) != 0) {
		XmppStanzaNode* _tmp44_;
		gchar* _tmp45_;
		gchar* _tmp46_;
		XmppStanzaNode* _tmp47_;
		XmppStanzaNode* _tmp48_;
		_tmp44_ = node;
		_tmp45_ = g_strdup_printf ("%hu", self->rel_port);
		_tmp46_ = _tmp45_;
		_tmp47_ = xmpp_stanza_node_put_attribute (_tmp44_, "rel-port", _tmp46_, NULL);
		_tmp48_ = _tmp47_;
		_xmpp_stanza_entry_unref0 (_tmp48_);
		_g_free0 (_tmp46_);
	}
	result = node;
	return result;
}

gboolean
xmpp_xep_jingle_ice_udp_candidate_equals (XmppXepJingleIceUdpCandidate* self,
                                          XmppXepJingleIceUdpCandidate* c)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (c != NULL, FALSE);
	result = xmpp_xep_jingle_ice_udp_candidate_equals_func (self, c);
	return result;
}

gboolean
xmpp_xep_jingle_ice_udp_candidate_equals_func (XmppXepJingleIceUdpCandidate* c1,
                                               XmppXepJingleIceUdpCandidate* c2)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	gboolean _tmp7_ = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp10_ = FALSE;
	gboolean result;
	g_return_val_if_fail (c1 != NULL, FALSE);
	g_return_val_if_fail (c2 != NULL, FALSE);
	if (c1->component == c2->component) {
		const gchar* _tmp11_;
		const gchar* _tmp12_;
		_tmp11_ = c1->foundation;
		_tmp12_ = c2->foundation;
		_tmp10_ = g_strcmp0 (_tmp11_, _tmp12_) == 0;
	} else {
		_tmp10_ = FALSE;
	}
	if (_tmp10_) {
		_tmp9_ = c1->generation == c2->generation;
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		_tmp13_ = c1->id;
		_tmp14_ = c2->id;
		_tmp8_ = g_strcmp0 (_tmp13_, _tmp14_) == 0;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		_tmp15_ = c1->ip;
		_tmp16_ = c2->ip;
		_tmp7_ = g_strcmp0 (_tmp15_, _tmp16_) == 0;
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		_tmp6_ = c1->network == c2->network;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		_tmp5_ = c1->port == c2->port;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		_tmp4_ = c1->priority == c2->priority;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		_tmp17_ = c1->protocol;
		_tmp18_ = c2->protocol;
		_tmp3_ = g_strcmp0 (_tmp17_, _tmp18_) == 0;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		_tmp19_ = c1->rel_addr;
		_tmp20_ = c2->rel_addr;
		_tmp2_ = g_strcmp0 (_tmp19_, _tmp20_) == 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = c1->rel_port == c2->rel_port;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = c1->type_ == c2->type_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

XmppXepJingleIceUdpCandidate*
xmpp_xep_jingle_ice_udp_candidate_construct (GType object_type)
{
	XmppXepJingleIceUdpCandidate* self = NULL;
	self = (XmppXepJingleIceUdpCandidate*) g_type_create_instance (object_type);
	return self;
}

XmppXepJingleIceUdpCandidate*
xmpp_xep_jingle_ice_udp_candidate_new (void)
{
	return xmpp_xep_jingle_ice_udp_candidate_construct (XMPP_XEP_JINGLE_ICE_UDP_TYPE_CANDIDATE);
}

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

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

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

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

static gchar*
xmpp_xep_jingle_ice_udp_value_candidate_collect_value (GValue* value,
                                                       guint n_collect_values,
                                                       GTypeCValue* collect_values,
                                                       guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		XmppXepJingleIceUdpCandidate * 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_jingle_ice_udp_candidate_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
xmpp_xep_jingle_ice_udp_value_candidate_lcopy_value (const GValue* value,
                                                     guint n_collect_values,
                                                     GTypeCValue* collect_values,
                                                     guint collect_flags)
{
	XmppXepJingleIceUdpCandidate ** 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_jingle_ice_udp_candidate_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
xmpp_xep_jingle_ice_udp_param_spec_candidate (const gchar* name,
                                              const gchar* nick,
                                              const gchar* blurb,
                                              GType object_type,
                                              GParamFlags flags)
{
	XmppXepJingleIceUdpParamSpecCandidate* spec;
	g_return_val_if_fail (g_type_is_a (object_type, XMPP_XEP_JINGLE_ICE_UDP_TYPE_CANDIDATE), 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_jingle_ice_udp_value_get_candidate (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_JINGLE_ICE_UDP_TYPE_CANDIDATE), NULL);
	return value->data[0].v_pointer;
}

void
xmpp_xep_jingle_ice_udp_value_set_candidate (GValue* value,
                                             gpointer v_object)
{
	XmppXepJingleIceUdpCandidate * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_JINGLE_ICE_UDP_TYPE_CANDIDATE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_JINGLE_ICE_UDP_TYPE_CANDIDATE));
		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_jingle_ice_udp_candidate_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_jingle_ice_udp_candidate_unref (old);
	}
}

void
xmpp_xep_jingle_ice_udp_value_take_candidate (GValue* value,
                                              gpointer v_object)
{
	XmppXepJingleIceUdpCandidate * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_JINGLE_ICE_UDP_TYPE_CANDIDATE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_JINGLE_ICE_UDP_TYPE_CANDIDATE));
		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_jingle_ice_udp_candidate_unref (old);
	}
}

static void
xmpp_xep_jingle_ice_udp_candidate_class_init (XmppXepJingleIceUdpCandidateClass * klass,
                                              gpointer klass_data)
{
	xmpp_xep_jingle_ice_udp_candidate_parent_class = g_type_class_peek_parent (klass);
	((XmppXepJingleIceUdpCandidateClass *) klass)->finalize = xmpp_xep_jingle_ice_udp_candidate_finalize;
}

static void
xmpp_xep_jingle_ice_udp_candidate_instance_init (XmppXepJingleIceUdpCandidate * self,
                                                 gpointer klass)
{
	self->ref_count = 1;
}

static void
xmpp_xep_jingle_ice_udp_candidate_finalize (XmppXepJingleIceUdpCandidate * obj)
{
	XmppXepJingleIceUdpCandidate * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_JINGLE_ICE_UDP_TYPE_CANDIDATE, XmppXepJingleIceUdpCandidate);
	g_signal_handlers_destroy (self);
	_g_free0 (self->foundation);
	_g_free0 (self->id);
	_g_free0 (self->ip);
	_g_free0 (self->protocol);
	_g_free0 (self->rel_addr);
}

static GType
xmpp_xep_jingle_ice_udp_candidate_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_xep_jingle_ice_udp_value_candidate_init, xmpp_xep_jingle_ice_udp_value_candidate_free_value, xmpp_xep_jingle_ice_udp_value_candidate_copy_value, xmpp_xep_jingle_ice_udp_value_candidate_peek_pointer, "p", xmpp_xep_jingle_ice_udp_value_candidate_collect_value, "p", xmpp_xep_jingle_ice_udp_value_candidate_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepJingleIceUdpCandidateClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_jingle_ice_udp_candidate_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepJingleIceUdpCandidate), 0, (GInstanceInitFunc) xmpp_xep_jingle_ice_udp_candidate_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_jingle_ice_udp_candidate_type_id;
	xmpp_xep_jingle_ice_udp_candidate_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppXepJingleIceUdpCandidate", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return xmpp_xep_jingle_ice_udp_candidate_type_id;
}

GType
xmpp_xep_jingle_ice_udp_candidate_get_type (void)
{
	static volatile gsize xmpp_xep_jingle_ice_udp_candidate_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_jingle_ice_udp_candidate_type_id__once)) {
		GType xmpp_xep_jingle_ice_udp_candidate_type_id;
		xmpp_xep_jingle_ice_udp_candidate_type_id = xmpp_xep_jingle_ice_udp_candidate_get_type_once ();
		g_once_init_leave (&xmpp_xep_jingle_ice_udp_candidate_type_id__once, xmpp_xep_jingle_ice_udp_candidate_type_id);
	}
	return xmpp_xep_jingle_ice_udp_candidate_type_id__once;
}

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

void
xmpp_xep_jingle_ice_udp_candidate_unref (gpointer instance)
{
	XmppXepJingleIceUdpCandidate * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_XEP_JINGLE_ICE_UDP_CANDIDATE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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;
}

