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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "xmpp-vala.h"
#include <glib-object.h>

#define XMPP_BIND_NS_URI "urn:ietf:params:xml:ns:xmpp-bind"
#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  {
	XMPP_BIND_MODULE_0_PROPERTY,
	XMPP_BIND_MODULE_REQUESTED_RESOURCE_PROPERTY,
	XMPP_BIND_MODULE_NUM_PROPERTIES
};
static GParamSpec* xmpp_bind_module_properties[XMPP_BIND_MODULE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
enum  {
	XMPP_BIND_MODULE_BOUND_TO_RESOURCE_SIGNAL,
	XMPP_BIND_MODULE_NUM_SIGNALS
};
static guint xmpp_bind_module_signals[XMPP_BIND_MODULE_NUM_SIGNALS] = {0};
enum  {
	XMPP_BIND_FLAG_0_PROPERTY,
	XMPP_BIND_FLAG_NUM_PROPERTIES
};
static GParamSpec* xmpp_bind_flag_properties[XMPP_BIND_FLAG_NUM_PROPERTIES];

struct _XmppBindModulePrivate {
	gchar* _requested_resource;
};

static gint XmppBindModule_private_offset;
static gpointer xmpp_bind_module_parent_class = NULL;
XmppModuleIdentity* xmpp_bind_module_IDENTITY = NULL;
static gpointer xmpp_bind_flag_parent_class = NULL;
XmppFlagIdentity* xmpp_bind_flag_IDENTITY = NULL;

static void _xmpp_bind_module_iq_response_stanza_xmpp_iq_module_on_result (XmppXmppStream* stream,
                                                                    XmppIqStanza* iq,
                                                                    gpointer self);
static void xmpp_bind_module_real_attach (XmppXmppStreamModule* base,
                                   XmppXmppStream* stream);
static void _xmpp_bind_module_received_features_node_xmpp_xmpp_stream_received_features_node (XmppXmppStream* _sender,
                                                                                       XmppXmppStream* stream,
                                                                                       gpointer self);
static void xmpp_bind_module_real_detach (XmppXmppStreamModule* base,
                                   XmppXmppStream* stream);
static gboolean xmpp_bind_module_real_mandatory_outstanding (XmppXmppStreamNegotiationModule* base,
                                                      XmppXmppStream* stream);
static gboolean xmpp_bind_module_real_negotiation_active (XmppXmppStreamNegotiationModule* base,
                                                   XmppXmppStream* stream);
static gchar* xmpp_bind_module_real_get_ns (XmppXmppStreamModule* base);
static gchar* xmpp_bind_module_real_get_id (XmppXmppStreamModule* base);
static void g_cclosure_user_marshal_VOID__OBJECT_XMPP_JID (GClosure * closure,
                                                    GValue * return_value,
                                                    guint n_param_values,
                                                    const GValue * param_values,
                                                    gpointer invocation_hint,
                                                    gpointer marshal_data);
static void xmpp_bind_module_finalize (GObject * obj);
static GType xmpp_bind_module_get_type_once (void);
static void _vala_xmpp_bind_module_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_xmpp_bind_module_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);
static gchar* xmpp_bind_flag_real_get_ns (XmppXmppStreamFlag* base);
static gchar* xmpp_bind_flag_real_get_id (XmppXmppStreamFlag* base);
static void xmpp_bind_flag_finalize (GObject * obj);
static GType xmpp_bind_flag_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
xmpp_bind_module_get_instance_private (XmppBindModule* self)
{
	return G_STRUCT_MEMBER_P (self, XmppBindModule_private_offset);
}

XmppBindModule*
xmpp_bind_module_construct (GType object_type,
                            const gchar* requested_resource)
{
	XmppBindModule * self = NULL;
	self = (XmppBindModule*) xmpp_xmpp_stream_negotiation_module_construct (object_type);
	xmpp_bind_module_set_requested_resource (self, requested_resource);
	return self;
}

XmppBindModule*
xmpp_bind_module_new (const gchar* requested_resource)
{
	return xmpp_bind_module_construct (XMPP_BIND_TYPE_MODULE, requested_resource);
}

void
xmpp_bind_module_iq_response_stanza (XmppBindModule* self,
                                     XmppXmppStream* stream,
                                     XmppIqStanza* iq)
{
	XmppBindFlag* flag = NULL;
	XmppFlagIdentity* _tmp0_;
	gpointer _tmp1_;
	gboolean _tmp2_ = FALSE;
	XmppBindFlag* _tmp3_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (iq != NULL);
	_tmp0_ = xmpp_bind_flag_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_flag (stream, XMPP_BIND_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	flag = (XmppBindFlag*) _tmp1_;
	_tmp3_ = flag;
	if (_tmp3_ == NULL) {
		_tmp2_ = TRUE;
	} else {
		XmppBindFlag* _tmp4_;
		_tmp4_ = flag;
		_tmp2_ = _tmp4_->finished;
	}
	if (_tmp2_) {
		_g_object_unref0 (flag);
		return;
	}
	_tmp5_ = xmpp_stanza_get_type_ ((XmppStanza*) iq);
	_tmp6_ = _tmp5_;
	if (g_strcmp0 (_tmp6_, XMPP_IQ_STANZA_TYPE_RESULT) == 0) {
		{
			XmppJid* _tmp7_ = NULL;
			XmppStanzaNode* _tmp8_;
			XmppStanzaNode* _tmp9_;
			XmppStanzaNode* _tmp10_;
			const gchar* _tmp11_;
			XmppJid* _tmp12_;
			XmppJid* _tmp13_;
			XmppBindFlag* _tmp14_;
			XmppJid* _tmp15_;
			XmppBindFlag* _tmp16_;
			XmppBindFlag* _tmp17_;
			XmppJid* _tmp18_;
			_tmp8_ = ((XmppStanza*) iq)->stanza;
			_tmp9_ = xmpp_stanza_node_get_subnode (_tmp8_, "jid", XMPP_BIND_NS_URI, TRUE);
			_tmp10_ = _tmp9_;
			_tmp11_ = xmpp_stanza_entry_get_string_content ((XmppStanzaEntry*) _tmp10_);
			_tmp12_ = xmpp_jid_new (_tmp11_, &_inner_error0_);
			_tmp13_ = _tmp12_;
			_xmpp_stanza_entry_unref0 (_tmp10_);
			_tmp7_ = _tmp13_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
					goto __catch0_xmpp_invalid_jid_error;
				}
				_g_object_unref0 (flag);
				g_critical ("file %s: line %d: unexpected 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;
			}
			_tmp14_ = flag;
			_tmp15_ = _tmp7_;
			_tmp7_ = NULL;
			_xmpp_jid_unref0 (_tmp14_->my_jid);
			_tmp14_->my_jid = _tmp15_;
			_tmp16_ = flag;
			_tmp16_->finished = TRUE;
			_tmp17_ = flag;
			_tmp18_ = _tmp17_->my_jid;
			g_signal_emit (self, xmpp_bind_module_signals[XMPP_BIND_MODULE_BOUND_TO_RESOURCE_SIGNAL], 0, stream, _tmp18_);
			_xmpp_jid_unref0 (_tmp7_);
		}
		goto __finally0;
		__catch0_xmpp_invalid_jid_error:
		{
			GError* e = NULL;
			GError* _tmp19_;
			const gchar* _tmp20_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp19_ = e;
			_tmp20_ = _tmp19_->message;
			g_warning ("bind.vala:26: Received invalid Jid when binding: %s", _tmp20_);
			_g_error_free0 (e);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (flag);
			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;
		}
	}
	_g_object_unref0 (flag);
}

static void
_xmpp_bind_module_iq_response_stanza_xmpp_iq_module_on_result (XmppXmppStream* stream,
                                                               XmppIqStanza* iq,
                                                               gpointer self)
{
	xmpp_bind_module_iq_response_stanza ((XmppBindModule*) self, stream, iq);
}

void
xmpp_bind_module_received_features_node (XmppBindModule* self,
                                         XmppXmppStream* stream)
{
	XmppStanzaNode* bind = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	if (xmpp_xmpp_stream_is_setup_needed (stream)) {
		return;
	}
	if (xmpp_xmpp_stream_is_negotiation_active (stream)) {
		return;
	}
	_tmp0_ = xmpp_xmpp_stream_get_features (stream);
	_tmp1_ = _tmp0_;
	_tmp2_ = xmpp_stanza_node_get_subnode (_tmp1_, "bind", XMPP_BIND_NS_URI, FALSE);
	bind = _tmp2_;
	_tmp3_ = bind;
	if (_tmp3_ != NULL) {
		XmppBindFlag* flag = NULL;
		XmppBindFlag* _tmp4_;
		XmppStanzaNode* bind_node = NULL;
		XmppStanzaNode* _tmp5_;
		XmppStanzaNode* _tmp6_;
		XmppStanzaNode* _tmp7_;
		XmppStanzaNode* _tmp8_;
		const gchar* _tmp9_;
		XmppModuleIdentity* _tmp20_;
		gpointer _tmp21_;
		XmppIqModule* _tmp22_;
		XmppStanzaNode* _tmp23_;
		XmppIqStanza* _tmp24_;
		XmppIqStanza* _tmp25_;
		XmppBindFlag* _tmp26_;
		_tmp4_ = xmpp_bind_flag_new ();
		flag = _tmp4_;
		_tmp5_ = xmpp_stanza_node_new_build ("bind", XMPP_BIND_NS_URI, NULL, NULL);
		_tmp6_ = _tmp5_;
		_tmp7_ = xmpp_stanza_node_add_self_xmlns (_tmp6_);
		_tmp8_ = _tmp7_;
		_xmpp_stanza_entry_unref0 (_tmp6_);
		bind_node = _tmp8_;
		_tmp9_ = self->priv->_requested_resource;
		if (_tmp9_ != NULL) {
			XmppStanzaNode* _tmp10_;
			XmppStanzaNode* _tmp11_;
			XmppStanzaNode* _tmp12_;
			const gchar* _tmp13_;
			XmppStanzaNode* _tmp14_;
			XmppStanzaNode* _tmp15_;
			XmppStanzaNode* _tmp16_;
			XmppStanzaNode* _tmp17_;
			XmppStanzaNode* _tmp18_;
			XmppStanzaNode* _tmp19_;
			_tmp10_ = bind_node;
			_tmp11_ = xmpp_stanza_node_new_build ("resource", XMPP_BIND_NS_URI, NULL, NULL);
			_tmp12_ = _tmp11_;
			_tmp13_ = self->priv->_requested_resource;
			_tmp14_ = xmpp_stanza_node_new_text (_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp16_ = xmpp_stanza_node_put_node (_tmp12_, _tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = xmpp_stanza_node_put_node (_tmp10_, _tmp17_);
			_tmp19_ = _tmp18_;
			_xmpp_stanza_entry_unref0 (_tmp19_);
			_xmpp_stanza_entry_unref0 (_tmp17_);
			_xmpp_stanza_entry_unref0 (_tmp15_);
			_xmpp_stanza_entry_unref0 (_tmp12_);
		}
		_tmp20_ = xmpp_iq_module_IDENTITY;
		_tmp21_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp20_);
		_tmp22_ = (XmppIqModule*) _tmp21_;
		_tmp23_ = bind_node;
		_tmp24_ = xmpp_iq_stanza_new_set (_tmp23_, NULL);
		_tmp25_ = _tmp24_;
		xmpp_iq_module_send_iq (_tmp22_, stream, _tmp25_, _xmpp_bind_module_iq_response_stanza_xmpp_iq_module_on_result, g_object_ref (self), g_object_unref, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_tmp25_);
		_g_object_unref0 (_tmp22_);
		_tmp26_ = flag;
		xmpp_xmpp_stream_add_flag (stream, (XmppXmppStreamFlag*) _tmp26_);
		_xmpp_stanza_entry_unref0 (bind_node);
		_g_object_unref0 (flag);
	}
	_xmpp_stanza_entry_unref0 (bind);
}

static void
_xmpp_bind_module_received_features_node_xmpp_xmpp_stream_received_features_node (XmppXmppStream* _sender,
                                                                                  XmppXmppStream* stream,
                                                                                  gpointer self)
{
	xmpp_bind_module_received_features_node ((XmppBindModule*) self, stream);
}

static void
xmpp_bind_module_real_attach (XmppXmppStreamModule* base,
                              XmppXmppStream* stream)
{
	XmppBindModule * self;
	self = (XmppBindModule*) base;
	g_return_if_fail (stream != NULL);
	g_signal_connect_object (stream, "received-features-node", (GCallback) _xmpp_bind_module_received_features_node_xmpp_xmpp_stream_received_features_node, self, 0);
}

static void
xmpp_bind_module_real_detach (XmppXmppStreamModule* base,
                              XmppXmppStream* stream)
{
	XmppBindModule * self;
	guint _tmp0_;
	self = (XmppBindModule*) base;
	g_return_if_fail (stream != NULL);
	g_signal_parse_name ("received-features-node", XMPP_TYPE_XMPP_STREAM, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (stream, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _xmpp_bind_module_received_features_node_xmpp_xmpp_stream_received_features_node, self);
}

static gboolean
xmpp_bind_module_real_mandatory_outstanding (XmppXmppStreamNegotiationModule* base,
                                             XmppXmppStream* stream)
{
	XmppBindModule * self;
	gboolean _tmp0_ = FALSE;
	XmppFlagIdentity* _tmp1_;
	gboolean result;
	self = (XmppBindModule*) base;
	g_return_val_if_fail (stream != NULL, FALSE);
	_tmp1_ = xmpp_bind_flag_IDENTITY;
	if (!xmpp_xmpp_stream_has_flag (stream, XMPP_BIND_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_)) {
		_tmp0_ = TRUE;
	} else {
		XmppFlagIdentity* _tmp2_;
		gpointer _tmp3_;
		XmppBindFlag* _tmp4_;
		_tmp2_ = xmpp_bind_flag_IDENTITY;
		_tmp3_ = xmpp_xmpp_stream_get_flag (stream, XMPP_BIND_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
		_tmp4_ = (XmppBindFlag*) _tmp3_;
		_tmp0_ = !_tmp4_->finished;
		_g_object_unref0 (_tmp4_);
	}
	result = _tmp0_;
	return result;
}

static gboolean
xmpp_bind_module_real_negotiation_active (XmppXmppStreamNegotiationModule* base,
                                          XmppXmppStream* stream)
{
	XmppBindModule * self;
	gboolean _tmp0_ = FALSE;
	XmppFlagIdentity* _tmp1_;
	gboolean result;
	self = (XmppBindModule*) base;
	g_return_val_if_fail (stream != NULL, FALSE);
	_tmp1_ = xmpp_bind_flag_IDENTITY;
	if (xmpp_xmpp_stream_has_flag (stream, XMPP_BIND_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_)) {
		XmppFlagIdentity* _tmp2_;
		gpointer _tmp3_;
		XmppBindFlag* _tmp4_;
		_tmp2_ = xmpp_bind_flag_IDENTITY;
		_tmp3_ = xmpp_xmpp_stream_get_flag (stream, XMPP_BIND_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
		_tmp4_ = (XmppBindFlag*) _tmp3_;
		_tmp0_ = !_tmp4_->finished;
		_g_object_unref0 (_tmp4_);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gchar*
xmpp_bind_module_real_get_ns (XmppXmppStreamModule* base)
{
	XmppBindModule * self;
	gchar* _tmp0_;
	gchar* result;
	self = (XmppBindModule*) base;
	_tmp0_ = g_strdup (XMPP_BIND_NS_URI);
	result = _tmp0_;
	return result;
}

static gchar*
xmpp_bind_module_real_get_id (XmppXmppStreamModule* base)
{
	XmppBindModule * self;
	XmppModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (XmppBindModule*) base;
	_tmp0_ = xmpp_bind_module_IDENTITY;
	_tmp1_ = xmpp_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

const gchar*
xmpp_bind_module_get_requested_resource (XmppBindModule* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_requested_resource;
	result = _tmp0_;
	return result;
}

void
xmpp_bind_module_set_requested_resource (XmppBindModule* self,
                                         const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_bind_module_get_requested_resource (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_requested_resource);
		self->priv->_requested_resource = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, xmpp_bind_module_properties[XMPP_BIND_MODULE_REQUESTED_RESOURCE_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__OBJECT_XMPP_JID (GClosure * closure,
                                               GValue * return_value,
                                               guint n_param_values,
                                               const GValue * param_values,
                                               gpointer invocation_hint,
                                               gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__OBJECT_XMPP_JID) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_XMPP_JID callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__OBJECT_XMPP_JID) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), xmpp_value_get_jid (param_values + 2), data2);
}

static void
xmpp_bind_module_class_init (XmppBindModuleClass * klass,
                             gpointer klass_data)
{
	XmppModuleIdentity* _tmp0_;
	xmpp_bind_module_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppBindModule_private_offset);
	((XmppXmppStreamModuleClass *) klass)->attach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) xmpp_bind_module_real_attach;
	((XmppXmppStreamModuleClass *) klass)->detach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) xmpp_bind_module_real_detach;
	((XmppXmppStreamNegotiationModuleClass *) klass)->mandatory_outstanding = (gboolean (*) (XmppXmppStreamNegotiationModule*, XmppXmppStream*)) xmpp_bind_module_real_mandatory_outstanding;
	((XmppXmppStreamNegotiationModuleClass *) klass)->negotiation_active = (gboolean (*) (XmppXmppStreamNegotiationModule*, XmppXmppStream*)) xmpp_bind_module_real_negotiation_active;
	((XmppXmppStreamModuleClass *) klass)->get_ns = (gchar* (*) (XmppXmppStreamModule*)) xmpp_bind_module_real_get_ns;
	((XmppXmppStreamModuleClass *) klass)->get_id = (gchar* (*) (XmppXmppStreamModule*)) xmpp_bind_module_real_get_id;
	G_OBJECT_CLASS (klass)->get_property = _vala_xmpp_bind_module_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_xmpp_bind_module_set_property;
	G_OBJECT_CLASS (klass)->finalize = xmpp_bind_module_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_BIND_MODULE_REQUESTED_RESOURCE_PROPERTY, xmpp_bind_module_properties[XMPP_BIND_MODULE_REQUESTED_RESOURCE_PROPERTY] = g_param_spec_string ("requested-resource", "requested-resource", "requested-resource", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	xmpp_bind_module_signals[XMPP_BIND_MODULE_BOUND_TO_RESOURCE_SIGNAL] = g_signal_new ("bound-to-resource", XMPP_BIND_TYPE_MODULE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_XMPP_JID, G_TYPE_NONE, 2, XMPP_TYPE_XMPP_STREAM, XMPP_TYPE_JID);
	_tmp0_ = xmpp_module_identity_new (XMPP_BIND_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, XMPP_BIND_NS_URI, "bind_module");
	xmpp_bind_module_IDENTITY = _tmp0_;
}

static void
xmpp_bind_module_instance_init (XmppBindModule * self,
                                gpointer klass)
{
	self->priv = xmpp_bind_module_get_instance_private (self);
}

static void
xmpp_bind_module_finalize (GObject * obj)
{
	XmppBindModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_BIND_TYPE_MODULE, XmppBindModule);
	_g_free0 (self->priv->_requested_resource);
	G_OBJECT_CLASS (xmpp_bind_module_parent_class)->finalize (obj);
}

/** The parties to a stream MUST consider resource binding as mandatory-to-negotiate. (RFC6120 7.3.1) */
static GType
xmpp_bind_module_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppBindModuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_bind_module_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppBindModule), 0, (GInstanceInitFunc) xmpp_bind_module_instance_init, NULL };
	GType xmpp_bind_module_type_id;
	xmpp_bind_module_type_id = g_type_register_static (XMPP_TYPE_XMPP_STREAM_NEGOTIATION_MODULE, "XmppBindModule", &g_define_type_info, 0);
	XmppBindModule_private_offset = g_type_add_instance_private (xmpp_bind_module_type_id, sizeof (XmppBindModulePrivate));
	return xmpp_bind_module_type_id;
}

GType
xmpp_bind_module_get_type (void)
{
	static volatile gsize xmpp_bind_module_type_id__once = 0;
	if (g_once_init_enter (&xmpp_bind_module_type_id__once)) {
		GType xmpp_bind_module_type_id;
		xmpp_bind_module_type_id = xmpp_bind_module_get_type_once ();
		g_once_init_leave (&xmpp_bind_module_type_id__once, xmpp_bind_module_type_id);
	}
	return xmpp_bind_module_type_id__once;
}

static void
_vala_xmpp_bind_module_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	XmppBindModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_BIND_TYPE_MODULE, XmppBindModule);
	switch (property_id) {
		case XMPP_BIND_MODULE_REQUESTED_RESOURCE_PROPERTY:
		g_value_set_string (value, xmpp_bind_module_get_requested_resource (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_xmpp_bind_module_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	XmppBindModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_BIND_TYPE_MODULE, XmppBindModule);
	switch (property_id) {
		case XMPP_BIND_MODULE_REQUESTED_RESOURCE_PROPERTY:
		xmpp_bind_module_set_requested_resource (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static gpointer
_xmpp_jid_ref0 (gpointer self)
{
	return self ? xmpp_jid_ref (self) : NULL;
}

XmppJid*
xmpp_bind_flag_get_my_jid (XmppXmppStream* stream)
{
	XmppFlagIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppBindFlag* _tmp2_;
	XmppJid* _tmp3_;
	XmppJid* _tmp4_;
	XmppJid* _tmp5_;
	XmppJid* result;
	g_return_val_if_fail (stream != NULL, NULL);
	_tmp0_ = xmpp_bind_flag_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_flag (stream, XMPP_BIND_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppBindFlag*) _tmp1_;
	_tmp3_ = _tmp2_->my_jid;
	_tmp4_ = _xmpp_jid_ref0 (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp2_);
	result = _tmp5_;
	return result;
}

static gchar*
xmpp_bind_flag_real_get_ns (XmppXmppStreamFlag* base)
{
	XmppBindFlag * self;
	gchar* _tmp0_;
	gchar* result;
	self = (XmppBindFlag*) base;
	_tmp0_ = g_strdup (XMPP_BIND_NS_URI);
	result = _tmp0_;
	return result;
}

static gchar*
xmpp_bind_flag_real_get_id (XmppXmppStreamFlag* base)
{
	XmppBindFlag * self;
	XmppFlagIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (XmppBindFlag*) base;
	_tmp0_ = xmpp_bind_flag_IDENTITY;
	_tmp1_ = xmpp_flag_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

XmppBindFlag*
xmpp_bind_flag_construct (GType object_type)
{
	XmppBindFlag * self = NULL;
	self = (XmppBindFlag*) xmpp_xmpp_stream_flag_construct (object_type);
	return self;
}

XmppBindFlag*
xmpp_bind_flag_new (void)
{
	return xmpp_bind_flag_construct (XMPP_BIND_TYPE_FLAG);
}

static void
xmpp_bind_flag_class_init (XmppBindFlagClass * klass,
                           gpointer klass_data)
{
	XmppFlagIdentity* _tmp0_;
	xmpp_bind_flag_parent_class = g_type_class_peek_parent (klass);
	((XmppXmppStreamFlagClass *) klass)->get_ns = (gchar* (*) (XmppXmppStreamFlag*)) xmpp_bind_flag_real_get_ns;
	((XmppXmppStreamFlagClass *) klass)->get_id = (gchar* (*) (XmppXmppStreamFlag*)) xmpp_bind_flag_real_get_id;
	G_OBJECT_CLASS (klass)->finalize = xmpp_bind_flag_finalize;
	_tmp0_ = xmpp_flag_identity_new (XMPP_BIND_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, XMPP_BIND_NS_URI, "bind");
	xmpp_bind_flag_IDENTITY = _tmp0_;
}

static void
xmpp_bind_flag_instance_init (XmppBindFlag * self,
                              gpointer klass)
{
	self->finished = FALSE;
}

static void
xmpp_bind_flag_finalize (GObject * obj)
{
	XmppBindFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_BIND_TYPE_FLAG, XmppBindFlag);
	_xmpp_jid_unref0 (self->my_jid);
	G_OBJECT_CLASS (xmpp_bind_flag_parent_class)->finalize (obj);
}

static GType
xmpp_bind_flag_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppBindFlagClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_bind_flag_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppBindFlag), 0, (GInstanceInitFunc) xmpp_bind_flag_instance_init, NULL };
	GType xmpp_bind_flag_type_id;
	xmpp_bind_flag_type_id = g_type_register_static (XMPP_TYPE_XMPP_STREAM_FLAG, "XmppBindFlag", &g_define_type_info, 0);
	return xmpp_bind_flag_type_id;
}

GType
xmpp_bind_flag_get_type (void)
{
	static volatile gsize xmpp_bind_flag_type_id__once = 0;
	if (g_once_init_enter (&xmpp_bind_flag_type_id__once)) {
		GType xmpp_bind_flag_type_id;
		xmpp_bind_flag_type_id = xmpp_bind_flag_get_type_once ();
		g_once_init_leave (&xmpp_bind_flag_type_id__once, xmpp_bind_flag_type_id);
	}
	return xmpp_bind_flag_type_id__once;
}

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

