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

#include "xmpp-vala.h"
#include <gee.h>
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.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  {
	XMPP_XMPP_STREAM_0_PROPERTY,
	XMPP_XMPP_STREAM_FLAGS_PROPERTY,
	XMPP_XMPP_STREAM_MODULES_PROPERTY,
	XMPP_XMPP_STREAM_FEATURES_PROPERTY,
	XMPP_XMPP_STREAM_NEGOTIATION_COMPLETE_PROPERTY,
	XMPP_XMPP_STREAM_NUM_PROPERTIES
};
static GParamSpec* xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_NUM_PROPERTIES];
#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 _xmpp_xmpp_log_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xmpp_log_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _XmppXmppStreamLoopData XmppXmppStreamLoopData;
typedef struct _XmppXmppStreamHandleStanzaData XmppXmppStreamHandleStanzaData;
enum  {
	XMPP_XMPP_STREAM_RECEIVED_NODE_SIGNAL,
	XMPP_XMPP_STREAM_RECEIVED_ROOT_NODE_SIGNAL,
	XMPP_XMPP_STREAM_RECEIVED_FEATURES_NODE_SIGNAL,
	XMPP_XMPP_STREAM_RECEIVED_MESSAGE_STANZA_SIGNAL,
	XMPP_XMPP_STREAM_RECEIVED_PRESENCE_STANZA_SIGNAL,
	XMPP_XMPP_STREAM_RECEIVED_IQ_STANZA_SIGNAL,
	XMPP_XMPP_STREAM_RECEIVED_NONZA_SIGNAL,
	XMPP_XMPP_STREAM_STREAM_NEGOTIATED_SIGNAL,
	XMPP_XMPP_STREAM_ATTACHED_MODULES_SIGNAL,
	XMPP_XMPP_STREAM_NUM_SIGNALS
};
static guint xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_NUM_SIGNALS] = {0};

struct _XmppXmppStreamPrivate {
	GeeList* _flags;
	GeeList* _modules;
	XmppStanzaNode* _features;
	gboolean _negotiation_complete;
};

struct _XmppXmppStreamLoopData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXmppStream* self;
	XmppStanzaNode* node;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GError* _inner_error0_;
};

struct _XmppXmppStreamHandleStanzaData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXmppStream* self;
	XmppStanzaNode* node;
	gboolean _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	GError* _inner_error0_;
};

static gint XmppXmppStream_private_offset;
static gpointer xmpp_xmpp_stream_parent_class = NULL;

static void xmpp_xmpp_stream_real_write (XmppXmppStream* self,
                                  XmppStanzaNode* node,
                                  gint io_priority) G_GNUC_DEPRECATED ;
static void xmpp_xmpp_stream_loop_data_free (gpointer _data);
static gboolean xmpp_xmpp_stream_loop_co (XmppXmppStreamLoopData* _data_);
static void xmpp_xmpp_stream_loop_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_);
static gboolean _xmpp_xmpp_stream_loop_co_gsource_func (gpointer self);
static void xmpp_xmpp_stream_handle_stanza (XmppXmppStream* self,
                                     XmppStanzaNode* node,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static void xmpp_xmpp_stream_handle_stanza_finish (XmppXmppStream* self,
                                            GAsyncResult* _res_);
static gboolean xmpp_xmpp_stream_negotiation_modules_done (XmppXmppStream* self,
                                                    GError** error);
static void xmpp_xmpp_stream_attach_non_negotation_modules (XmppXmppStream* self);
static void xmpp_xmpp_stream_handle_stanza_data_free (gpointer _data);
static gboolean xmpp_xmpp_stream_handle_stanza_co (XmppXmppStreamHandleStanzaData* _data_);
static void xmpp_xmpp_stream_set_features (XmppXmppStream* self,
                                    XmppStanzaNode* value);
static void xmpp_xmpp_stream_handle_stanza_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static void xmpp_xmpp_stream_set_flags (XmppXmppStream* self,
                                 GeeList* value);
static void xmpp_xmpp_stream_set_modules (XmppXmppStream* self,
                                   GeeList* value);
static void g_cclosure_user_marshal_VOID__OBJECT_XMPP_STANZA_ENTRY (GClosure * closure,
                                                             GValue * return_value,
                                                             guint n_param_values,
                                                             const GValue * param_values,
                                                             gpointer invocation_hint,
                                                             gpointer marshal_data);
static void xmpp_xmpp_stream_finalize (GObject * obj);
static GType xmpp_xmpp_stream_get_type_once (void);
static void _vala_xmpp_xmpp_stream_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_xmpp_xmpp_stream_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
xmpp_xmpp_stream_get_instance_private (XmppXmppStream* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXmppStream_private_offset);
}

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

XmppXmppStream*
xmpp_xmpp_stream_construct (GType object_type,
                            XmppJid* remote_name)
{
	XmppXmppStream * self = NULL;
	XmppJid* _tmp0_;
	g_return_val_if_fail (remote_name != NULL, NULL);
	self = (XmppXmppStream*) g_object_new (object_type, NULL);
	_tmp0_ = _xmpp_jid_ref0 (remote_name);
	_xmpp_jid_unref0 (self->remote_name);
	self->remote_name = _tmp0_;
	return self;
}

void
xmpp_xmpp_stream_connect (XmppXmppStream* self,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->connect) {
		_klass_->connect (self, _callback_, _user_data_);
	}
}

void
xmpp_xmpp_stream_connect_finish (XmppXmppStream* self,
                                 GAsyncResult* _res_,
                                 GError** error)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->connect_finish) {
		_klass_->connect_finish (self, _res_, error);
	}
}

void
xmpp_xmpp_stream_disconnect (XmppXmppStream* self,
                             GAsyncReadyCallback _callback_,
                             gpointer _user_data_)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->disconnect) {
		_klass_->disconnect (self, _callback_, _user_data_);
	}
}

void
xmpp_xmpp_stream_disconnect_finish (XmppXmppStream* self,
                                    GAsyncResult* _res_,
                                    GError** error)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->disconnect_finish) {
		_klass_->disconnect_finish (self, _res_, error);
	}
}

void
xmpp_xmpp_stream_read (XmppXmppStream* self,
                       GAsyncReadyCallback _callback_,
                       gpointer _user_data_)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->read) {
		_klass_->read (self, _callback_, _user_data_);
	}
}

XmppStanzaNode*
xmpp_xmpp_stream_read_finish (XmppXmppStream* self,
                              GAsyncResult* _res_,
                              GError** error)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->read_finish) {
		return _klass_->read_finish (self, _res_, error);
	}
	return NULL;
}

static void
xmpp_xmpp_stream_real_write (XmppXmppStream* self,
                             XmppStanzaNode* node,
                             gint io_priority)
{
	g_critical ("Type `%s' does not implement abstract method `xmpp_xmpp_stream_write'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
xmpp_xmpp_stream_write (XmppXmppStream* self,
                        XmppStanzaNode* node,
                        gint io_priority)
{
	XmppXmppStreamClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->write) {
		_klass_->write (self, node, io_priority);
	}
}

void
xmpp_xmpp_stream_write_async (XmppXmppStream* self,
                              XmppStanzaNode* node,
                              gint io_priority,
                              GCancellable* cancellable,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->write_async) {
		_klass_->write_async (self, node, io_priority, cancellable, _callback_, _user_data_);
	}
}

void
xmpp_xmpp_stream_write_finish (XmppXmppStream* self,
                               GAsyncResult* _res_,
                               GError** error)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->write_finish) {
		_klass_->write_finish (self, _res_, error);
	}
}

void
xmpp_xmpp_stream_setup (XmppXmppStream* self,
                        GAsyncReadyCallback _callback_,
                        gpointer _user_data_)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->setup) {
		_klass_->setup (self, _callback_, _user_data_);
	}
}

void
xmpp_xmpp_stream_setup_finish (XmppXmppStream* self,
                               GAsyncResult* _res_,
                               GError** error)
{
	XmppXmppStreamClass* _klass_;
	_klass_ = XMPP_XMPP_STREAM_GET_CLASS (self);
	if (_klass_->setup_finish) {
		_klass_->setup_finish (self, _res_, error);
	}
}

void
xmpp_xmpp_stream_require_setup (XmppXmppStream* self)
{
	g_return_if_fail (self != NULL);
	self->setup_needed = TRUE;
}

gboolean
xmpp_xmpp_stream_is_setup_needed (XmppXmppStream* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->setup_needed;
	return result;
}

void
xmpp_xmpp_stream_add_flag (XmppXmppStream* self,
                           XmppXmppStreamFlag* flag)
{
	GeeList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (flag != NULL);
	_tmp0_ = self->priv->_flags;
	gee_collection_add ((GeeCollection*) _tmp0_, flag);
}

gboolean
xmpp_xmpp_stream_has_flag (XmppXmppStream* self,
                           GType t_type,
                           GBoxedCopyFunc t_dup_func,
                           GDestroyNotify t_destroy_func,
                           XmppFlagIdentity* identity)
{
	gpointer _tmp0_;
	gpointer _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = xmpp_xmpp_stream_get_flag (self, t_type, (GBoxedCopyFunc) t_dup_func, (GDestroyNotify) t_destroy_func, identity);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_ != NULL;
	((_tmp1_ == NULL) || (t_destroy_func == NULL)) ? NULL : (_tmp1_ = (t_destroy_func (_tmp1_), NULL));
	result = _tmp2_;
	return result;
}

gpointer
xmpp_xmpp_stream_get_flag (XmppXmppStream* self,
                           GType t_type,
                           GBoxedCopyFunc t_dup_func,
                           GDestroyNotify t_destroy_func,
                           XmppFlagIdentity* identity)
{
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	if (identity == NULL) {
		result = NULL;
		return result;
	}
	{
		GeeList* _flag_list = NULL;
		GeeList* _tmp0_;
		gint _flag_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _flag_index = 0;
		_tmp0_ = self->priv->_flags;
		_flag_list = _tmp0_;
		_tmp1_ = _flag_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_flag_size = _tmp3_;
		_flag_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXmppStreamFlag* flag = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			XmppXmppStreamFlag* _tmp8_;
			_flag_index = _flag_index + 1;
			_tmp4_ = _flag_index;
			_tmp5_ = _flag_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _flag_list;
			_tmp7_ = gee_list_get (_tmp6_, _flag_index);
			flag = (XmppXmppStreamFlag*) _tmp7_;
			_tmp8_ = flag;
			if (xmpp_flag_identity_matches (G_TYPE_CHECK_INSTANCE_CAST (identity, XMPP_TYPE_FLAG_IDENTITY, XmppFlagIdentity), _tmp8_)) {
				XmppXmppStreamFlag* _tmp9_;
				gpointer _tmp10_;
				_tmp9_ = flag;
				_tmp10_ = xmpp_flag_identity_cast (G_TYPE_CHECK_INSTANCE_CAST (identity, XMPP_TYPE_FLAG_IDENTITY, XmppFlagIdentity), _tmp9_);
				result = _tmp10_;
				_g_object_unref0 (flag);
				return result;
			}
			_g_object_unref0 (flag);
		}
	}
	result = NULL;
	return result;
}

void
xmpp_xmpp_stream_remove_flag (XmppXmppStream* self,
                              XmppXmppStreamFlag* flag)
{
	GeeList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (flag != NULL);
	_tmp0_ = self->priv->_flags;
	gee_collection_remove ((GeeCollection*) _tmp0_, flag);
}

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

XmppXmppStream*
xmpp_xmpp_stream_add_module (XmppXmppStream* self,
                             XmppXmppStreamModule* module)
{
	GeeList* _tmp23_;
	gboolean _tmp24_;
	XmppXmppStream* _tmp25_;
	XmppXmppStream* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (module != NULL, NULL);
	{
		GeeList* _m_list = NULL;
		GeeList* _tmp0_;
		gint _m_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _m_index = 0;
		_tmp0_ = self->priv->_modules;
		_m_list = _tmp0_;
		_tmp1_ = _m_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_m_size = _tmp3_;
		_m_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXmppStreamModule* m = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			gboolean _tmp8_ = FALSE;
			XmppXmppStreamModule* _tmp9_;
			gchar* _tmp10_;
			gchar* _tmp11_;
			gchar* _tmp12_;
			gchar* _tmp13_;
			gboolean _tmp14_;
			_m_index = _m_index + 1;
			_tmp4_ = _m_index;
			_tmp5_ = _m_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _m_list;
			_tmp7_ = gee_list_get (_tmp6_, _m_index);
			m = (XmppXmppStreamModule*) _tmp7_;
			_tmp9_ = m;
			_tmp10_ = xmpp_xmpp_stream_module_get_ns (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = xmpp_xmpp_stream_module_get_ns (module);
			_tmp13_ = _tmp12_;
			_tmp14_ = g_strcmp0 (_tmp11_, _tmp13_) == 0;
			_g_free0 (_tmp13_);
			_g_free0 (_tmp11_);
			if (_tmp14_) {
				XmppXmppStreamModule* _tmp15_;
				gchar* _tmp16_;
				gchar* _tmp17_;
				gchar* _tmp18_;
				gchar* _tmp19_;
				_tmp15_ = m;
				_tmp16_ = xmpp_xmpp_stream_module_get_id (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = xmpp_xmpp_stream_module_get_id (module);
				_tmp19_ = _tmp18_;
				_tmp8_ = g_strcmp0 (_tmp17_, _tmp19_) == 0;
				_g_free0 (_tmp19_);
				_g_free0 (_tmp17_);
			} else {
				_tmp8_ = FALSE;
			}
			if (_tmp8_) {
				gchar* _tmp20_;
				gchar* _tmp21_;
				XmppXmppStream* _tmp22_;
				_tmp20_ = xmpp_xmpp_stream_module_get_id (module);
				_tmp21_ = _tmp20_;
				g_warning ("xmpp_stream.vala:77: [%p] Adding already added module: %s\n", self, _tmp21_);
				_g_free0 (_tmp21_);
				_tmp22_ = _g_object_ref0 (self);
				result = _tmp22_;
				_g_object_unref0 (m);
				return result;
			}
			_g_object_unref0 (m);
		}
	}
	_tmp23_ = self->priv->_modules;
	gee_collection_add ((GeeCollection*) _tmp23_, module);
	_tmp24_ = self->priv->_negotiation_complete;
	if (_tmp24_) {
		xmpp_xmpp_stream_module_attach (module, self);
	}
	_tmp25_ = _g_object_ref0 (self);
	result = _tmp25_;
	return result;
}

void
xmpp_xmpp_stream_detach_modules (XmppXmppStream* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeList* _module_list = NULL;
		GeeList* _tmp0_;
		gint _module_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _module_index = 0;
		_tmp0_ = self->priv->_modules;
		_module_list = _tmp0_;
		_tmp1_ = _module_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_module_size = _tmp3_;
		_module_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXmppStreamModule* module = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			XmppXmppStreamModule* _tmp8_;
			_module_index = _module_index + 1;
			_tmp4_ = _module_index;
			_tmp5_ = _module_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _module_list;
			_tmp7_ = gee_list_get (_tmp6_, _module_index);
			module = (XmppXmppStreamModule*) _tmp7_;
			_tmp8_ = module;
			xmpp_xmpp_stream_module_detach (_tmp8_, self);
			_g_object_unref0 (module);
		}
	}
}

gpointer
xmpp_xmpp_stream_get_module (XmppXmppStream* self,
                             GType t_type,
                             GBoxedCopyFunc t_dup_func,
                             GDestroyNotify t_destroy_func,
                             XmppModuleIdentity* identity)
{
	gpointer result;
	g_return_val_if_fail (self != NULL, NULL);
	if (identity == NULL) {
		result = NULL;
		return result;
	}
	{
		GeeList* _module_list = NULL;
		GeeList* _tmp0_;
		gint _module_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _module_index = 0;
		_tmp0_ = self->priv->_modules;
		_module_list = _tmp0_;
		_tmp1_ = _module_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_module_size = _tmp3_;
		_module_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXmppStreamModule* module = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			XmppXmppStreamModule* _tmp8_;
			_module_index = _module_index + 1;
			_tmp4_ = _module_index;
			_tmp5_ = _module_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _module_list;
			_tmp7_ = gee_list_get (_tmp6_, _module_index);
			module = (XmppXmppStreamModule*) _tmp7_;
			_tmp8_ = module;
			if (xmpp_module_identity_matches (G_TYPE_CHECK_INSTANCE_CAST (identity, XMPP_TYPE_MODULE_IDENTITY, XmppModuleIdentity), _tmp8_)) {
				XmppXmppStreamModule* _tmp9_;
				gpointer _tmp10_;
				_tmp9_ = module;
				_tmp10_ = xmpp_module_identity_cast (G_TYPE_CHECK_INSTANCE_CAST (identity, XMPP_TYPE_MODULE_IDENTITY, XmppModuleIdentity), _tmp9_);
				result = _tmp10_;
				_g_object_unref0 (module);
				return result;
			}
			_g_object_unref0 (module);
		}
	}
	result = NULL;
	return result;
}

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

void
xmpp_xmpp_stream_loop (XmppXmppStream* self,
                       GAsyncReadyCallback _callback_,
                       gpointer _user_data_)
{
	XmppXmppStreamLoopData* _data_;
	XmppXmppStream* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (XmppXmppStreamLoopData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xmpp_stream_loop_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	xmpp_xmpp_stream_loop_co (_data_);
}

void
xmpp_xmpp_stream_loop_finish (XmppXmppStream* self,
                              GAsyncResult* _res_,
                              GError** error)
{
	XmppXmppStreamLoopData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
xmpp_xmpp_stream_loop_ready (GObject* source_object,
                             GAsyncResult* _res_,
                             gpointer _user_data_)
{
	XmppXmppStreamLoopData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xmpp_stream_loop_co (_data_);
}

static gboolean
_xmpp_xmpp_stream_loop_co_gsource_func (gpointer self)
{
	gboolean result;
	result = xmpp_xmpp_stream_loop_co (self);
	return result;
}

static gboolean
xmpp_xmpp_stream_loop_co (XmppXmppStreamLoopData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	while (TRUE) {
		if (_data_->self->setup_needed) {
			_data_->_state_ = 1;
			xmpp_xmpp_stream_setup (_data_->self, xmpp_xmpp_stream_loop_ready, _data_);
			return FALSE;
			_state_1:
			xmpp_xmpp_stream_setup_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				if (_data_->_inner_error0_->domain == G_IO_ERROR) {
					g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
					g_object_unref (_data_->_async_result);
					return FALSE;
				} else {
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
					g_clear_error (&_data_->_inner_error0_);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
			}
		}
		_data_->_state_ = 2;
		xmpp_xmpp_stream_read (_data_->self, xmpp_xmpp_stream_loop_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp0_ = xmpp_xmpp_stream_read_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		_data_->node = _data_->_tmp0_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == G_IO_ERROR) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			} else {
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
				g_clear_error (&_data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
		g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _xmpp_xmpp_stream_loop_co_gsource_func, _data_, NULL);
		_data_->_state_ = 3;
		return FALSE;
		_state_3:
		;
		if (_data_->self->disconnected) {
			_xmpp_stanza_entry_unref0 (_data_->node);
			break;
		}
		_data_->_tmp1_ = _data_->node;
		_data_->_state_ = 4;
		xmpp_xmpp_stream_handle_stanza (_data_->self, _data_->_tmp1_, xmpp_xmpp_stream_loop_ready, _data_);
		return FALSE;
		_state_4:
		xmpp_xmpp_stream_handle_stanza_finish (_data_->self, _data_->_res_);
		if (!_data_->self->non_negotiation_modules_attached) {
			_data_->_tmp3_ = xmpp_xmpp_stream_negotiation_modules_done (_data_->self, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				if (_data_->_inner_error0_->domain == G_IO_ERROR) {
					g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
					_xmpp_stanza_entry_unref0 (_data_->node);
					g_object_unref (_data_->_async_result);
					return FALSE;
				} else {
					_xmpp_stanza_entry_unref0 (_data_->node);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
					g_clear_error (&_data_->_inner_error0_);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
			}
			_data_->_tmp2_ = _data_->_tmp3_;
		} else {
			_data_->_tmp2_ = FALSE;
		}
		if (_data_->_tmp2_) {
			xmpp_xmpp_stream_attach_non_negotation_modules (_data_->self);
			_data_->self->non_negotiation_modules_attached = TRUE;
			_data_->_tmp4_ = _data_->self->priv->_negotiation_complete;
			if (!_data_->_tmp4_) {
				g_signal_emit (_data_->self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_STREAM_NEGOTIATED_SIGNAL], 0, _data_->self);
				xmpp_xmpp_stream_set_negotiation_complete (_data_->self, TRUE);
			}
		}
		_xmpp_stanza_entry_unref0 (_data_->node);
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
xmpp_xmpp_stream_handle_stanza_data_free (gpointer _data)
{
	XmppXmppStreamHandleStanzaData* _data_;
	_data_ = _data;
	_xmpp_stanza_entry_unref0 (_data_->node);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXmppStreamHandleStanzaData, _data_);
}

static gpointer
_xmpp_stanza_entry_ref0 (gpointer self)
{
	return self ? xmpp_stanza_entry_ref (self) : NULL;
}

static void
xmpp_xmpp_stream_handle_stanza (XmppXmppStream* self,
                                XmppStanzaNode* node,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	XmppXmppStreamHandleStanzaData* _data_;
	XmppXmppStream* _tmp0_;
	XmppStanzaNode* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_data_ = g_slice_new0 (XmppXmppStreamHandleStanzaData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xmpp_stream_handle_stanza_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _xmpp_stanza_entry_ref0 (node);
	_xmpp_stanza_entry_unref0 (_data_->node);
	_data_->node = _tmp1_;
	xmpp_xmpp_stream_handle_stanza_co (_data_);
}

static void
xmpp_xmpp_stream_handle_stanza_finish (XmppXmppStream* self,
                                       GAsyncResult* _res_)
{
	XmppXmppStreamHandleStanzaData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
xmpp_xmpp_stream_handle_stanza_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	XmppXmppStreamHandleStanzaData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xmpp_stream_handle_stanza_co (_data_);
}

static gboolean
xmpp_xmpp_stream_handle_stanza_co (XmppXmppStreamHandleStanzaData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_signal_emit (_data_->self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_NODE_SIGNAL], 0, _data_->self, _data_->node);
	_data_->_tmp1_ = ((XmppStanzaEntry*) _data_->node)->ns_uri;
	if (g_strcmp0 (_data_->_tmp1_, XMPP_XMPP_STREAM_NS_URI) == 0) {
		_data_->_tmp2_ = ((XmppStanzaEntry*) _data_->node)->name;
		_data_->_tmp0_ = g_strcmp0 (_data_->_tmp2_, "features") == 0;
	} else {
		_data_->_tmp0_ = FALSE;
	}
	if (_data_->_tmp0_) {
		xmpp_xmpp_stream_set_features (_data_->self, _data_->node);
		g_signal_emit (_data_->self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_FEATURES_NODE_SIGNAL], 0, _data_->self);
	} else {
		_data_->_tmp5_ = ((XmppStanzaEntry*) _data_->node)->ns_uri;
		if (g_strcmp0 (_data_->_tmp5_, XMPP_XMPP_STREAM_NS_URI) == 0) {
			_data_->_tmp6_ = ((XmppStanzaEntry*) _data_->node)->name;
			_data_->_tmp4_ = g_strcmp0 (_data_->_tmp6_, "stream") == 0;
		} else {
			_data_->_tmp4_ = FALSE;
		}
		if (_data_->_tmp4_) {
			_data_->_tmp3_ = _data_->node->pseudo;
		} else {
			_data_->_tmp3_ = FALSE;
		}
		if (_data_->_tmp3_) {
			g_debug ("xmpp_stream.vala:133: [%p] Server closed stream", _data_->self);
			{
				_data_->_state_ = 1;
				xmpp_xmpp_stream_disconnect (_data_->self, xmpp_xmpp_stream_handle_stanza_ready, _data_);
				return FALSE;
				_state_1:
				xmpp_xmpp_stream_disconnect_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
			}
			goto __finally0;
			__catch0_g_error:
			{
				g_clear_error (&_data_->_inner_error0_);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
				g_clear_error (&_data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			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;
		} else {
			_data_->_tmp7_ = ((XmppStanzaEntry*) _data_->node)->ns_uri;
			if (g_strcmp0 (_data_->_tmp7_, XMPP_JABBER_URI) == 0) {
				_data_->_tmp8_ = ((XmppStanzaEntry*) _data_->node)->name;
				if (g_strcmp0 (_data_->_tmp8_, "message") == 0) {
					g_signal_emit (_data_->self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_MESSAGE_STANZA_SIGNAL], 0, _data_->self, _data_->node);
				} else {
					_data_->_tmp9_ = ((XmppStanzaEntry*) _data_->node)->name;
					if (g_strcmp0 (_data_->_tmp9_, "presence") == 0) {
						g_signal_emit (_data_->self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_PRESENCE_STANZA_SIGNAL], 0, _data_->self, _data_->node);
					} else {
						_data_->_tmp10_ = ((XmppStanzaEntry*) _data_->node)->name;
						if (g_strcmp0 (_data_->_tmp10_, "iq") == 0) {
							g_signal_emit (_data_->self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_IQ_STANZA_SIGNAL], 0, _data_->self, _data_->node);
						} else {
							g_signal_emit (_data_->self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_NONZA_SIGNAL], 0, _data_->self, _data_->node);
						}
					}
				}
			} else {
				g_signal_emit (_data_->self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_NONZA_SIGNAL], 0, _data_->self, _data_->node);
			}
		}
	}
	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;
}

gboolean
xmpp_xmpp_stream_is_negotiation_active (XmppXmppStream* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		GeeList* _module_list = NULL;
		GeeList* _tmp0_;
		gint _module_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _module_index = 0;
		_tmp0_ = self->priv->_modules;
		_module_list = _tmp0_;
		_tmp1_ = _module_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_module_size = _tmp3_;
		_module_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXmppStreamModule* module = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			XmppXmppStreamModule* _tmp8_;
			_module_index = _module_index + 1;
			_tmp4_ = _module_index;
			_tmp5_ = _module_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _module_list;
			_tmp7_ = gee_list_get (_tmp6_, _module_index);
			module = (XmppXmppStreamModule*) _tmp7_;
			_tmp8_ = module;
			if (XMPP_IS_XMPP_STREAM_NEGOTIATION_MODULE (_tmp8_)) {
				XmppXmppStreamNegotiationModule* negotiation_module = NULL;
				XmppXmppStreamModule* _tmp9_;
				XmppXmppStreamNegotiationModule* _tmp10_;
				XmppXmppStreamNegotiationModule* _tmp11_;
				_tmp9_ = module;
				_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, XMPP_TYPE_XMPP_STREAM_NEGOTIATION_MODULE, XmppXmppStreamNegotiationModule));
				negotiation_module = _tmp10_;
				_tmp11_ = negotiation_module;
				if (xmpp_xmpp_stream_negotiation_module_negotiation_active (_tmp11_, self)) {
					result = TRUE;
					_g_object_unref0 (negotiation_module);
					_g_object_unref0 (module);
					return result;
				}
				_g_object_unref0 (negotiation_module);
			}
			_g_object_unref0 (module);
		}
	}
	result = FALSE;
	return result;
}

static gboolean
xmpp_xmpp_stream_negotiation_modules_done (XmppXmppStream* self,
                                           GError** error)
{
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (self->setup_needed) {
		result = FALSE;
		return result;
	}
	if (xmpp_xmpp_stream_is_negotiation_active (self)) {
		result = FALSE;
		return result;
	}
	{
		GeeList* _module_list = NULL;
		GeeList* _tmp0_;
		gint _module_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _module_index = 0;
		_tmp0_ = self->priv->_modules;
		_module_list = _tmp0_;
		_tmp1_ = _module_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_module_size = _tmp3_;
		_module_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXmppStreamModule* module = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			XmppXmppStreamModule* _tmp8_;
			_module_index = _module_index + 1;
			_tmp4_ = _module_index;
			_tmp5_ = _module_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _module_list;
			_tmp7_ = gee_list_get (_tmp6_, _module_index);
			module = (XmppXmppStreamModule*) _tmp7_;
			_tmp8_ = module;
			if (XMPP_IS_XMPP_STREAM_NEGOTIATION_MODULE (_tmp8_)) {
				XmppXmppStreamNegotiationModule* negotiation_module = NULL;
				XmppXmppStreamModule* _tmp9_;
				XmppXmppStreamNegotiationModule* _tmp10_;
				XmppXmppStreamNegotiationModule* _tmp11_;
				_tmp9_ = module;
				_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, XMPP_TYPE_XMPP_STREAM_NEGOTIATION_MODULE, XmppXmppStreamNegotiationModule));
				negotiation_module = _tmp10_;
				_tmp11_ = negotiation_module;
				if (xmpp_xmpp_stream_negotiation_module_mandatory_outstanding (_tmp11_, self)) {
					XmppXmppStreamNegotiationModule* _tmp12_;
					gchar* _tmp13_;
					gchar* _tmp14_;
					gchar* _tmp15_;
					gchar* _tmp16_;
					GError* _tmp17_;
					GError* _tmp18_;
					_tmp12_ = negotiation_module;
					_tmp13_ = xmpp_xmpp_stream_module_get_id ((XmppXmppStreamModule*) _tmp12_);
					_tmp14_ = _tmp13_;
					_tmp15_ = g_strconcat ("mandatory-to-negotiate feature not negotiated: ", _tmp14_, NULL);
					_tmp16_ = _tmp15_;
					_tmp17_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _tmp16_);
					_tmp18_ = _tmp17_;
					_g_free0 (_tmp16_);
					_g_free0 (_tmp14_);
					_inner_error0_ = _tmp18_;
					if (_inner_error0_->domain == G_IO_ERROR) {
						gboolean _tmp19_ = FALSE;
						g_propagate_error (error, _inner_error0_);
						_g_object_unref0 (negotiation_module);
						_g_object_unref0 (module);
						return _tmp19_;
					} else {
						gboolean _tmp20_ = FALSE;
						_g_object_unref0 (negotiation_module);
						_g_object_unref0 (module);
						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 _tmp20_;
					}
				}
				_g_object_unref0 (negotiation_module);
			}
			_g_object_unref0 (module);
		}
	}
	result = TRUE;
	return result;
}

static void
xmpp_xmpp_stream_attach_non_negotation_modules (XmppXmppStream* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeList* _module_list = NULL;
		GeeList* _tmp0_;
		gint _module_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _module_index = 0;
		_tmp0_ = self->priv->_modules;
		_module_list = _tmp0_;
		_tmp1_ = _module_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_module_size = _tmp3_;
		_module_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXmppStreamModule* module = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			XmppXmppStreamModule* _tmp8_;
			_module_index = _module_index + 1;
			_tmp4_ = _module_index;
			_tmp5_ = _module_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _module_list;
			_tmp7_ = gee_list_get (_tmp6_, _module_index);
			module = (XmppXmppStreamModule*) _tmp7_;
			_tmp8_ = module;
			if ((XMPP_IS_XMPP_STREAM_NEGOTIATION_MODULE (_tmp8_) ? ((XmppXmppStreamNegotiationModule*) _tmp8_) : NULL) == NULL) {
				XmppXmppStreamModule* _tmp9_;
				_tmp9_ = module;
				xmpp_xmpp_stream_module_attach (_tmp9_, self);
			}
			_g_object_unref0 (module);
		}
	}
	g_signal_emit (self, xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_ATTACHED_MODULES_SIGNAL], 0, self);
}

void
xmpp_xmpp_stream_attach_negotation_modules (XmppXmppStream* self)
{
	g_return_if_fail (self != NULL);
	{
		GeeList* _module_list = NULL;
		GeeList* _tmp0_;
		gint _module_size = 0;
		GeeList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _module_index = 0;
		_tmp0_ = self->priv->_modules;
		_module_list = _tmp0_;
		_tmp1_ = _module_list;
		_tmp2_ = gee_collection_get_size ((GeeCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_module_size = _tmp3_;
		_module_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			XmppXmppStreamModule* module = NULL;
			GeeList* _tmp6_;
			gpointer _tmp7_;
			XmppXmppStreamModule* _tmp8_;
			_module_index = _module_index + 1;
			_tmp4_ = _module_index;
			_tmp5_ = _module_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _module_list;
			_tmp7_ = gee_list_get (_tmp6_, _module_index);
			module = (XmppXmppStreamModule*) _tmp7_;
			_tmp8_ = module;
			if ((XMPP_IS_XMPP_STREAM_NEGOTIATION_MODULE (_tmp8_) ? ((XmppXmppStreamNegotiationModule*) _tmp8_) : NULL) != NULL) {
				XmppXmppStreamModule* _tmp9_;
				_tmp9_ = module;
				xmpp_xmpp_stream_module_attach (_tmp9_, self);
			}
			_g_object_unref0 (module);
		}
	}
}

GeeList*
xmpp_xmpp_stream_get_flags (XmppXmppStream* self)
{
	GeeList* result;
	GeeList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_flags;
	result = _tmp0_;
	return result;
}

static void
xmpp_xmpp_stream_set_flags (XmppXmppStream* self,
                            GeeList* value)
{
	GeeList* old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xmpp_stream_get_flags (self);
	if (old_value != value) {
		GeeList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_flags);
		self->priv->_flags = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_FLAGS_PROPERTY]);
	}
}

GeeList*
xmpp_xmpp_stream_get_modules (XmppXmppStream* self)
{
	GeeList* result;
	GeeList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_modules;
	result = _tmp0_;
	return result;
}

static void
xmpp_xmpp_stream_set_modules (XmppXmppStream* self,
                              GeeList* value)
{
	GeeList* old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xmpp_stream_get_modules (self);
	if (old_value != value) {
		GeeList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_modules);
		self->priv->_modules = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_MODULES_PROPERTY]);
	}
}

XmppStanzaNode*
xmpp_xmpp_stream_get_features (XmppXmppStream* self)
{
	XmppStanzaNode* result;
	XmppStanzaNode* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_features;
	result = _tmp0_;
	return result;
}

static void
xmpp_xmpp_stream_set_features (XmppXmppStream* self,
                               XmppStanzaNode* value)
{
	XmppStanzaNode* old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xmpp_stream_get_features (self);
	if (old_value != value) {
		XmppStanzaNode* _tmp0_;
		_tmp0_ = _xmpp_stanza_entry_ref0 (value);
		_xmpp_stanza_entry_unref0 (self->priv->_features);
		self->priv->_features = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_FEATURES_PROPERTY]);
	}
}

gboolean
xmpp_xmpp_stream_get_negotiation_complete (XmppXmppStream* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_negotiation_complete;
	return result;
}

void
xmpp_xmpp_stream_set_negotiation_complete (XmppXmppStream* self,
                                           gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xmpp_stream_get_negotiation_complete (self);
	if (old_value != value) {
		self->priv->_negotiation_complete = value;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_NEGOTIATION_COMPLETE_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__OBJECT_XMPP_STANZA_ENTRY (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_STANZA_ENTRY) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__OBJECT_XMPP_STANZA_ENTRY 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_STANZA_ENTRY) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_object (param_values + 1), xmpp_value_get_stanza_entry (param_values + 2), data2);
}

static void
xmpp_xmpp_stream_class_init (XmppXmppStreamClass * klass,
                             gpointer klass_data)
{
	xmpp_xmpp_stream_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXmppStream_private_offset);
	((XmppXmppStreamClass *) klass)->write = (void (*) (XmppXmppStream*, XmppStanzaNode*, gint)) xmpp_xmpp_stream_real_write;
	G_OBJECT_CLASS (klass)->get_property = _vala_xmpp_xmpp_stream_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_xmpp_xmpp_stream_set_property;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xmpp_stream_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XMPP_STREAM_FLAGS_PROPERTY, xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_FLAGS_PROPERTY] = g_param_spec_object ("flags", "flags", "flags", GEE_TYPE_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XMPP_STREAM_MODULES_PROPERTY, xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_MODULES_PROPERTY] = g_param_spec_object ("modules", "modules", "modules", GEE_TYPE_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XMPP_STREAM_FEATURES_PROPERTY, xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_FEATURES_PROPERTY] = xmpp_param_spec_stanza_entry ("features", "features", "features", XMPP_TYPE_STANZA_NODE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XMPP_STREAM_NEGOTIATION_COMPLETE_PROPERTY, xmpp_xmpp_stream_properties[XMPP_XMPP_STREAM_NEGOTIATION_COMPLETE_PROPERTY] = g_param_spec_boolean ("negotiation-complete", "negotiation-complete", "negotiation-complete", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_NODE_SIGNAL] = g_signal_new ("received-node", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_XMPP_STANZA_ENTRY, G_TYPE_NONE, 2, XMPP_TYPE_XMPP_STREAM, XMPP_TYPE_STANZA_NODE);
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_ROOT_NODE_SIGNAL] = g_signal_new ("received-root-node", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_XMPP_STANZA_ENTRY, G_TYPE_NONE, 2, XMPP_TYPE_XMPP_STREAM, XMPP_TYPE_STANZA_NODE);
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_FEATURES_NODE_SIGNAL] = g_signal_new ("received-features-node", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, XMPP_TYPE_XMPP_STREAM);
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_MESSAGE_STANZA_SIGNAL] = g_signal_new ("received-message-stanza", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_XMPP_STANZA_ENTRY, G_TYPE_NONE, 2, XMPP_TYPE_XMPP_STREAM, XMPP_TYPE_STANZA_NODE);
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_PRESENCE_STANZA_SIGNAL] = g_signal_new ("received-presence-stanza", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_XMPP_STANZA_ENTRY, G_TYPE_NONE, 2, XMPP_TYPE_XMPP_STREAM, XMPP_TYPE_STANZA_NODE);
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_IQ_STANZA_SIGNAL] = g_signal_new ("received-iq-stanza", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_XMPP_STANZA_ENTRY, G_TYPE_NONE, 2, XMPP_TYPE_XMPP_STREAM, XMPP_TYPE_STANZA_NODE);
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_RECEIVED_NONZA_SIGNAL] = g_signal_new ("received-nonza", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OBJECT_XMPP_STANZA_ENTRY, G_TYPE_NONE, 2, XMPP_TYPE_XMPP_STREAM, XMPP_TYPE_STANZA_NODE);
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_STREAM_NEGOTIATED_SIGNAL] = g_signal_new ("stream-negotiated", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, XMPP_TYPE_XMPP_STREAM);
	xmpp_xmpp_stream_signals[XMPP_XMPP_STREAM_ATTACHED_MODULES_SIGNAL] = g_signal_new ("attached-modules", XMPP_TYPE_XMPP_STREAM, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, XMPP_TYPE_XMPP_STREAM);
}

static void
xmpp_xmpp_stream_instance_init (XmppXmppStream * self,
                                gpointer klass)
{
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppXmppLog* _tmp3_;
	self->priv = xmpp_xmpp_stream_get_instance_private (self);
	_tmp0_ = gee_array_list_new (XMPP_TYPE_XMPP_STREAM_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->_flags = (GeeList*) _tmp0_;
	_tmp1_ = gee_array_list_new (XMPP_TYPE_XMPP_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->_modules = (GeeList*) _tmp1_;
	_tmp2_ = xmpp_stanza_node_new_build ("features", XMPP_XMPP_STREAM_NS_URI, NULL, NULL);
	self->priv->_features = _tmp2_;
	_tmp3_ = xmpp_xmpp_log_new (NULL, NULL);
	self->log = _tmp3_;
	self->priv->_negotiation_complete = FALSE;
	self->non_negotiation_modules_attached = FALSE;
	self->setup_needed = FALSE;
	self->disconnected = FALSE;
}

static void
xmpp_xmpp_stream_finalize (GObject * obj)
{
	XmppXmppStream * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_TYPE_XMPP_STREAM, XmppXmppStream);
	_g_object_unref0 (self->priv->_flags);
	_g_object_unref0 (self->priv->_modules);
	_xmpp_stanza_entry_unref0 (self->priv->_features);
	_xmpp_jid_unref0 (self->remote_name);
	_xmpp_xmpp_log_unref0 (self->log);
	G_OBJECT_CLASS (xmpp_xmpp_stream_parent_class)->finalize (obj);
}

static GType
xmpp_xmpp_stream_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXmppStreamClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xmpp_stream_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXmppStream), 0, (GInstanceInitFunc) xmpp_xmpp_stream_instance_init, NULL };
	GType xmpp_xmpp_stream_type_id;
	xmpp_xmpp_stream_type_id = g_type_register_static (G_TYPE_OBJECT, "XmppXmppStream", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	XmppXmppStream_private_offset = g_type_add_instance_private (xmpp_xmpp_stream_type_id, sizeof (XmppXmppStreamPrivate));
	return xmpp_xmpp_stream_type_id;
}

GType
xmpp_xmpp_stream_get_type (void)
{
	static volatile gsize xmpp_xmpp_stream_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xmpp_stream_type_id__once)) {
		GType xmpp_xmpp_stream_type_id;
		xmpp_xmpp_stream_type_id = xmpp_xmpp_stream_get_type_once ();
		g_once_init_leave (&xmpp_xmpp_stream_type_id__once, xmpp_xmpp_stream_type_id);
	}
	return xmpp_xmpp_stream_type_id__once;
}

static void
_vala_xmpp_xmpp_stream_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	XmppXmppStream * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_TYPE_XMPP_STREAM, XmppXmppStream);
	switch (property_id) {
		case XMPP_XMPP_STREAM_FLAGS_PROPERTY:
		g_value_set_object (value, xmpp_xmpp_stream_get_flags (self));
		break;
		case XMPP_XMPP_STREAM_MODULES_PROPERTY:
		g_value_set_object (value, xmpp_xmpp_stream_get_modules (self));
		break;
		case XMPP_XMPP_STREAM_FEATURES_PROPERTY:
		xmpp_value_set_stanza_entry (value, xmpp_xmpp_stream_get_features (self));
		break;
		case XMPP_XMPP_STREAM_NEGOTIATION_COMPLETE_PROPERTY:
		g_value_set_boolean (value, xmpp_xmpp_stream_get_negotiation_complete (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_xmpp_xmpp_stream_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	XmppXmppStream * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_TYPE_XMPP_STREAM, XmppXmppStream);
	switch (property_id) {
		case XMPP_XMPP_STREAM_FLAGS_PROPERTY:
		xmpp_xmpp_stream_set_flags (self, g_value_get_object (value));
		break;
		case XMPP_XMPP_STREAM_MODULES_PROPERTY:
		xmpp_xmpp_stream_set_modules (self, g_value_get_object (value));
		break;
		case XMPP_XMPP_STREAM_FEATURES_PROPERTY:
		xmpp_xmpp_stream_set_features (self, xmpp_value_get_stanza_entry (value));
		break;
		case XMPP_XMPP_STREAM_NEGOTIATION_COMPLETE_PROPERTY:
		xmpp_xmpp_stream_set_negotiation_complete (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

