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

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

#define XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI "http://jabber.org/protocol/ibb"
#define XMPP_XEP_IN_BAND_BYTESTREAMS_SEQ_MODULUS 65536
#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_XEP_IN_BAND_BYTESTREAMS_MODULE_0_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_MODULE_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_in_band_bytestreams_module_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_MODULE_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_error_stanza_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_error_stanza_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _XmppXepInBandBytestreamsModuleOnIqSetData XmppXepInBandBytestreamsModuleOnIqSetData;
enum  {
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_0_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_INPUT_STREAM_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_OUTPUT_STREAM_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_SID_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_in_band_bytestreams_connection_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_NUM_PROPERTIES];
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
typedef struct _XmppXepInBandBytestreamsConnectionReadAsyncData XmppXepInBandBytestreamsConnectionReadAsyncData;
typedef struct _Block3Data Block3Data;
typedef struct _XmppXepInBandBytestreamsConnectionWriteAsyncData XmppXepInBandBytestreamsConnectionWriteAsyncData;
typedef struct _XmppXepInBandBytestreamsConnectionCloseReadAsyncData XmppXepInBandBytestreamsConnectionCloseReadAsyncData;
typedef struct _XmppXepInBandBytestreamsConnectionCloseWriteAsyncData XmppXepInBandBytestreamsConnectionCloseWriteAsyncData;
typedef void (*XmppXepInBandBytestreamsConnectionOnClose) (gboolean success, gpointer user_data);
typedef struct _Block4Data Block4Data;
typedef struct _Block5Data Block5Data;
typedef struct _XmppXepInBandBytestreamsConnectionCloseAsyncImplData XmppXepInBandBytestreamsConnectionCloseAsyncImplData;
typedef struct _Block6Data Block6Data;
enum  {
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_INPUT_0_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_INPUT_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_in_band_bytestreams_connection_input_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_INPUT_NUM_PROPERTIES];
typedef struct _XmppXepInBandBytestreamsConnectionInputReadAsyncData XmppXepInBandBytestreamsConnectionInputReadAsyncData;
typedef struct _XmppXepInBandBytestreamsConnectionInputCloseAsyncData XmppXepInBandBytestreamsConnectionInputCloseAsyncData;
enum  {
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_OUTPUT_0_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_OUTPUT_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_in_band_bytestreams_connection_output_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_OUTPUT_NUM_PROPERTIES];
typedef struct _XmppXepInBandBytestreamsConnectionOutputWriteAsyncData XmppXepInBandBytestreamsConnectionOutputWriteAsyncData;
typedef struct _XmppXepInBandBytestreamsConnectionOutputCloseAsyncData XmppXepInBandBytestreamsConnectionOutputCloseAsyncData;
enum  {
	XMPP_XEP_IN_BAND_BYTESTREAMS_FLAG_0_PROPERTY,
	XMPP_XEP_IN_BAND_BYTESTREAMS_FLAG_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_in_band_bytestreams_flag_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_FLAG_NUM_PROPERTIES];
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _XmppXepInBandBytestreamsModuleOnIqSetData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsModule* self;
	XmppXmppStream* stream;
	XmppIqStanza* iq;
	XmppStanzaNode* node;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	XmppStanzaNode* _tmp6_;
	XmppStanzaNode* _tmp7_;
	XmppStanzaNode* _tmp8_;
	XmppStanzaNode* _tmp9_;
	XmppStanzaNode* _tmp10_;
	XmppStanzaNode* _tmp11_;
	XmppStanzaNode* _tmp12_;
	XmppStanzaNode* _tmp13_;
	XmppStanzaNode* _tmp14_;
	XmppStanzaNode* _tmp15_;
	XmppStanzaNode* _tmp16_;
	XmppStanzaNode* _tmp17_;
	XmppStanzaNode* _tmp18_;
	XmppStanzaNode* _tmp19_;
	XmppStanzaNode* _tmp20_;
	XmppStanzaNode* _tmp21_;
	XmppModuleIdentity* _tmp22_;
	gpointer _tmp23_;
	XmppIqModule* _tmp24_;
	XmppErrorStanza* _tmp25_;
	XmppErrorStanza* _tmp26_;
	XmppJid* _tmp27_;
	XmppJid* _tmp28_;
	XmppIqStanza* _tmp29_;
	XmppIqStanza* _tmp30_;
	gchar* sid;
	XmppStanzaNode* _tmp31_;
	const gchar* _tmp32_;
	gchar* _tmp33_;
	const gchar* _tmp34_;
	XmppModuleIdentity* _tmp35_;
	gpointer _tmp36_;
	XmppIqModule* _tmp37_;
	XmppErrorStanza* _tmp38_;
	XmppErrorStanza* _tmp39_;
	XmppJid* _tmp40_;
	XmppJid* _tmp41_;
	XmppIqStanza* _tmp42_;
	XmppIqStanza* _tmp43_;
	XmppXepInBandBytestreamsConnection* conn;
	XmppFlagIdentity* _tmp44_;
	gpointer _tmp45_;
	XmppXepInBandBytestreamsFlag* _tmp46_;
	const gchar* _tmp47_;
	XmppXepInBandBytestreamsConnection* _tmp48_;
	XmppXepInBandBytestreamsConnection* _tmp49_;
	XmppStanzaNode* _tmp50_;
	const gchar* _tmp51_;
	XmppXepInBandBytestreamsConnection* _tmp52_;
	XmppModuleIdentity* _tmp53_;
	gpointer _tmp54_;
	XmppIqModule* _tmp55_;
	XmppErrorStanza* _tmp56_;
	XmppErrorStanza* _tmp57_;
	XmppJid* _tmp58_;
	XmppJid* _tmp59_;
	XmppIqStanza* _tmp60_;
	XmppIqStanza* _tmp61_;
	XmppXepInBandBytestreamsConnection* _tmp62_;
	XmppXepInBandBytestreamsConnectionState _tmp63_;
	XmppXepInBandBytestreamsConnectionState _tmp64_;
	XmppModuleIdentity* _tmp65_;
	gpointer _tmp66_;
	XmppIqModule* _tmp67_;
	XmppErrorStanza* _tmp68_;
	XmppErrorStanza* _tmp69_;
	XmppJid* _tmp70_;
	XmppJid* _tmp71_;
	XmppIqStanza* _tmp72_;
	XmppIqStanza* _tmp73_;
	XmppXepInBandBytestreamsConnection* _tmp74_;
	XmppStanzaNode* _tmp75_;
	gboolean _tmp76_;
	XmppXepInBandBytestreamsConnection* _tmp77_;
	XmppXepInBandBytestreamsConnection* _tmp78_;
	XmppXepInBandBytestreamsConnectionState _tmp79_;
	XmppXepInBandBytestreamsConnectionState _tmp80_;
	XmppModuleIdentity* _tmp81_;
	gpointer _tmp82_;
	XmppIqModule* _tmp83_;
	XmppErrorStanza* _tmp84_;
	XmppErrorStanza* _tmp85_;
	XmppJid* _tmp86_;
	XmppJid* _tmp87_;
	XmppIqStanza* _tmp88_;
	XmppIqStanza* _tmp89_;
	XmppStanzaNode* _tmp90_;
	const gchar* _tmp91_;
	XmppXepInBandBytestreamsConnection* _tmp92_;
	XmppStanzaNode* _tmp93_;
	XmppXepInBandBytestreamsConnection* _tmp94_;
	XmppStanzaNode* _tmp95_;
};

struct _XmppXepInBandBytestreamsConnectionPrivate {
	XmppXepInBandBytestreamsConnectionInput* input;
	XmppXepInBandBytestreamsConnectionOutput* output;
	XmppXepInBandBytestreamsConnectionState _state;
	XmppJid* receiver_full_jid;
	gchar* _sid;
	gint block_size;
	gint local_seq;
	gint remote_ack;
	gboolean input_closed;
	gboolean output_closed;
	gchar* error;
	XmppXmppStream* stream;
	gint read_callback_priority;
	GCancellable* read_callback_cancellable;
	gulong read_callback_cancellable_id;
	GSourceFunc read_callback;
	gpointer read_callback_target;
	GDestroyNotify read_callback_target_destroy_notify;
	gint write_callback_priority;
	GSourceFunc write_callback;
	gpointer write_callback_target;
	GDestroyNotify write_callback_target_destroy_notify;
	gulong write_callback_cancellable_id;
	GCancellable* write_callback_cancellable;
	GeeLinkedList* received;
};

struct _XmppXepInBandBytestreamsConnectionReadAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnection* self;
	guint8* buffer;
	gint buffer_length1;
	gint io_priority;
	GCancellable* cancellable;
	gssize result;
	GBytes* chunk;
	GeeLinkedList* _tmp0_;
	gpointer _tmp1_;
	GBytes* _tmp2_;
	gint read;
	GBytes* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gint i;
	gboolean _tmp6_;
	gint _tmp7_;
	GBytes* _tmp8_;
	GBytes* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	GeeLinkedList* _tmp12_;
	GBytes* _tmp13_;
	GBytes* _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	GBytes* _tmp17_;
	GBytes* _tmp18_;
	XmppXepInBandBytestreamsConnectionState _tmp19_;
	GError* _inner_error0_;
};

struct _Block3Data {
	int _ref_count_;
	XmppXepInBandBytestreamsConnection* self;
	gint seq;
	gpointer _async_data_;
};

struct _XmppXepInBandBytestreamsConnectionWriteAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnection* self;
	guint8* buffer;
	gint buffer_length1;
	gint io_priority;
	GCancellable* cancellable;
	gssize result;
	Block3Data* _data3_;
	gboolean _tmp0_;
	XmppXepInBandBytestreamsConnectionState _tmp1_;
	XmppXepInBandBytestreamsConnectionState _tmp2_;
	XmppXepInBandBytestreamsConnectionState _tmp3_;
	XmppStanzaNode* data;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	XmppStanzaNode* _tmp6_;
	XmppStanzaNode* _tmp7_;
	const gchar* _tmp8_;
	XmppStanzaNode* _tmp9_;
	XmppStanzaNode* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	XmppStanzaNode* _tmp13_;
	XmppStanzaNode* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	XmppStanzaNode* _tmp17_;
	XmppStanzaNode* _tmp18_;
	XmppStanzaNode* _tmp19_;
	XmppStanzaNode* _tmp20_;
	XmppIqStanza* iq;
	XmppStanzaNode* _tmp21_;
	XmppJid* _tmp22_;
	XmppJid* _tmp23_;
	XmppIqStanza* _tmp24_;
	XmppXmppStream* _tmp25_;
	XmppModuleIdentity* _tmp26_;
	gpointer _tmp27_;
	XmppIqModule* _tmp28_;
	XmppXmppStream* _tmp29_;
	XmppIqStanza* _tmp30_;
	GError* _inner_error0_;
};

struct _XmppXepInBandBytestreamsConnectionCloseReadAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnection* self;
	gint io_priority;
	GCancellable* cancellable;
	gboolean result;
	gboolean _tmp0_;
	GError* _inner_error0_;
};

struct _XmppXepInBandBytestreamsConnectionCloseWriteAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnection* self;
	gint io_priority;
	GCancellable* cancellable;
	gboolean result;
	gboolean _tmp0_;
	GError* _inner_error0_;
};

struct _Block4Data {
	int _ref_count_;
	XmppXepInBandBytestreamsConnection* self;
	XmppXepInBandBytestreamsConnectionOnClose on_close;
	gpointer on_close_target;
};

struct _Block5Data {
	int _ref_count_;
	XmppXepInBandBytestreamsConnection* self;
	GSourceFunc callback;
	gpointer callback_target;
	GDestroyNotify callback_target_destroy_notify;
	gpointer _async_data_;
};

struct _XmppXepInBandBytestreamsConnectionCloseAsyncImplData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnection* self;
	gint io_priority;
	GCancellable* cancellable;
	gboolean result;
	Block5Data* _data5_;
	GError* _inner_error0_;
};

struct _Block6Data {
	int _ref_count_;
	XmppXepInBandBytestreamsConnection* conn;
};

struct _XmppXepInBandBytestreamsConnectionInputPrivate {
	XmppXepInBandBytestreamsConnection* connection;
};

struct _XmppXepInBandBytestreamsConnectionInputReadAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnectionInput* self;
	guint8* buffer;
	gsize buffer_length1;
	gint io_priority;
	GCancellable* cancellable;
	gssize result;
	gssize _tmp0_;
	XmppXepInBandBytestreamsConnection* _tmp1_;
	GError* _inner_error0_;
};

struct _XmppXepInBandBytestreamsConnectionInputCloseAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnectionInput* self;
	gint io_priority;
	GCancellable* cancellable;
	gboolean result;
	gboolean _tmp0_;
	XmppXepInBandBytestreamsConnection* _tmp1_;
	GError* _inner_error0_;
};

struct _XmppXepInBandBytestreamsConnectionOutputPrivate {
	XmppXepInBandBytestreamsConnection* connection;
};

struct _XmppXepInBandBytestreamsConnectionOutputWriteAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnectionOutput* self;
	guint8* buffer;
	gsize buffer_length1;
	gint io_priority;
	GCancellable* cancellable;
	gssize result;
	gssize _tmp0_;
	XmppXepInBandBytestreamsConnection* _tmp1_;
	GError* _inner_error0_;
};

struct _XmppXepInBandBytestreamsConnectionOutputCloseAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppXepInBandBytestreamsConnectionOutput* self;
	gint io_priority;
	GCancellable* cancellable;
	gboolean result;
	gboolean _tmp0_;
	XmppXepInBandBytestreamsConnection* _tmp1_;
	GError* _inner_error0_;
};

struct _XmppXepInBandBytestreamsFlagPrivate {
	GeeHashMap* active;
};

static gpointer xmpp_xep_in_band_bytestreams_module_parent_class = NULL;
XmppModuleIdentity* xmpp_xep_in_band_bytestreams_module_IDENTITY = NULL;
static XmppIqHandlerIface * xmpp_xep_in_band_bytestreams_module_xmpp_iq_handler_parent_iface = NULL;
static gint XmppXepInBandBytestreamsConnection_private_offset;
static gpointer xmpp_xep_in_band_bytestreams_connection_parent_class = NULL;
static gint XmppXepInBandBytestreamsConnectionInput_private_offset;
static gpointer xmpp_xep_in_band_bytestreams_connection_input_parent_class = NULL;
static gint XmppXepInBandBytestreamsConnectionOutput_private_offset;
static gpointer xmpp_xep_in_band_bytestreams_connection_output_parent_class = NULL;
static gint XmppXepInBandBytestreamsFlag_private_offset;
static gpointer xmpp_xep_in_band_bytestreams_flag_parent_class = NULL;
XmppFlagIdentity* xmpp_xep_in_band_bytestreams_flag_IDENTITY = NULL;

static void xmpp_xep_in_band_bytestreams_module_real_attach (XmppXmppStreamModule* base,
                                                      XmppXmppStream* stream);
static void xmpp_xep_in_band_bytestreams_module_real_detach (XmppXmppStreamModule* base,
                                                      XmppXmppStream* stream);
static void xmpp_xep_in_band_bytestreams_module_real_on_iq_set_data_free (gpointer _data);
static void xmpp_xep_in_band_bytestreams_module_real_on_iq_set (XmppIqHandler* base,
                                                         XmppXmppStream* stream,
                                                         XmppIqStanza* iq,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_module_real_on_iq_set_co (XmppXepInBandBytestreamsModuleOnIqSetData* _data_);
static gchar* xmpp_xep_in_band_bytestreams_module_real_get_ns (XmppXmppStreamModule* base);
static gchar* xmpp_xep_in_band_bytestreams_module_real_get_id (XmppXmppStreamModule* base);
static void xmpp_xep_in_band_bytestreams_module_finalize (GObject * obj);
static GType xmpp_xep_in_band_bytestreams_module_get_type_once (void);
static XmppXepInBandBytestreamsConnection* xmpp_xep_in_band_bytestreams_connection_new (XmppXmppStream* stream,
                                                                                 XmppJid* receiver_full_jid,
                                                                                 const gchar* sid,
                                                                                 gint block_size,
                                                                                 gboolean initiate);
static XmppXepInBandBytestreamsConnection* xmpp_xep_in_band_bytestreams_connection_construct (GType object_type,
                                                                                       XmppXmppStream* stream,
                                                                                       XmppJid* receiver_full_jid,
                                                                                       const gchar* sid,
                                                                                       gint block_size,
                                                                                       gboolean initiate);
static void xmpp_xep_in_band_bytestreams_connection_set_sid (XmppXepInBandBytestreamsConnection* self,
                                                      const gchar* value);
static void xmpp_xep_in_band_bytestreams_connection_set_state (XmppXepInBandBytestreamsConnection* self,
                                                        XmppXepInBandBytestreamsConnectionState value);
static void _xmpp_xep_in_band_bytestreams_connection_trigger_read_callback_gfunc (gconstpointer data,
                                                                           gpointer self);
static void _xmpp_xep_in_band_bytestreams_connection_trigger_write_callback_gfunc (gconstpointer data,
                                                                            gpointer self);
static void xmpp_xep_in_band_bytestreams_connection_read_async_data_free (gpointer _data);
static gboolean xmpp_xep_in_band_bytestreams_connection_read_async_co (XmppXepInBandBytestreamsConnectionReadAsyncData* _data_);
static gboolean _xmpp_xep_in_band_bytestreams_connection_read_async_co_gsource_func (gpointer self);
static void xmpp_xep_in_band_bytestreams_connection_write_async_data_free (gpointer _data);
static gboolean xmpp_xep_in_band_bytestreams_connection_write_async_co (XmppXepInBandBytestreamsConnectionWriteAsyncData* _data_);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static gboolean _xmpp_xep_in_band_bytestreams_connection_write_async_co_gsource_func (gpointer self);
static void xmpp_xep_in_band_bytestreams_connection_throw_if_closed (XmppXepInBandBytestreamsConnection* self,
                                                              GError** error);
static void __lambda12_ (Block3Data* _data3_,
                  XmppXmppStream* stream,
                  XmppIqStanza* iq);
static void xmpp_xep_in_band_bytestreams_connection_set_error (XmppXepInBandBytestreamsConnection* self,
                                                        const gchar* _error_);
static void ___lambda12__xmpp_iq_module_on_result (XmppXmppStream* stream,
                                            XmppIqStanza* iq,
                                            gpointer self);
static void xmpp_xep_in_band_bytestreams_connection_throw_if_error (XmppXepInBandBytestreamsConnection* self,
                                                             GError** error);
static void xmpp_xep_in_band_bytestreams_connection_close_read_async_data_free (gpointer _data);
static gboolean xmpp_xep_in_band_bytestreams_connection_close_read_async_co (XmppXepInBandBytestreamsConnectionCloseReadAsyncData* _data_);
static void xmpp_xep_in_band_bytestreams_connection_close_async_impl (XmppXepInBandBytestreamsConnection* self,
                                                               gint io_priority,
                                                               GCancellable* cancellable,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_connection_close_async_impl_finish (XmppXepInBandBytestreamsConnection* self,
                                                                          GAsyncResult* _res_,
                                                                          GError** error);
static void xmpp_xep_in_band_bytestreams_connection_close_read_async_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_);
static void xmpp_xep_in_band_bytestreams_connection_close_write_async_data_free (gpointer _data);
static gboolean xmpp_xep_in_band_bytestreams_connection_close_write_async_co (XmppXepInBandBytestreamsConnectionCloseWriteAsyncData* _data_);
static void xmpp_xep_in_band_bytestreams_connection_close_write_async_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_connection_close_impl (XmppXepInBandBytestreamsConnection* self,
                                                             GCancellable* cancellable,
                                                             XmppXepInBandBytestreamsConnectionOnClose on_close,
                                                             gpointer on_close_target);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void __lambda10_ (Block4Data* _data4_,
                  XmppXmppStream* stream,
                  XmppIqStanza* iq);
static void ___lambda10__xmpp_iq_module_on_result (XmppXmppStream* stream,
                                            XmppIqStanza* iq,
                                            gpointer self);
static void xmpp_xep_in_band_bytestreams_connection_close_async_impl_data_free (gpointer _data);
static gboolean xmpp_xep_in_band_bytestreams_connection_close_async_impl_co (XmppXepInBandBytestreamsConnectionCloseAsyncImplData* _data_);
static Block5Data* block5_data_ref (Block5Data* _data5_);
static void block5_data_unref (void * _userdata_);
static gboolean _xmpp_xep_in_band_bytestreams_connection_close_async_impl_co_gsource_func (gpointer self);
static void __lambda11_ (Block5Data* _data5_);
static void ___lambda11__xmpp_xep_in_band_bytestreams_connection_on_close (gboolean success,
                                                                    gpointer self);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
static void ___lambda13_ (Block6Data* _data6_,
                   XmppXmppStream* stream,
                   XmppIqStanza* iq);
static void ____lambda13__xmpp_iq_module_on_result (XmppXmppStream* stream,
                                             XmppIqStanza* iq,
                                             gpointer self);
static guint8* _vala_array_dup7 (guint8* self,
                          gssize length);
static gssize xmpp_xep_in_band_bytestreams_connection_input_real_read (GInputStream* base,
                                                                guint8* buffer,
                                                                gsize buffer_length1,
                                                                GCancellable* cancellable,
                                                                GError** error);
static void xmpp_xep_in_band_bytestreams_connection_input_real_read_async_data_free (gpointer _data);
static void xmpp_xep_in_band_bytestreams_connection_input_real_read_async (GInputStream* base,
                                                                    guint8* buffer,
                                                                    gsize buffer_length1,
                                                                    gint io_priority,
                                                                    GCancellable* cancellable,
                                                                    GAsyncReadyCallback _callback_,
                                                                    gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_connection_input_real_read_async_co (XmppXepInBandBytestreamsConnectionInputReadAsyncData* _data_);
static void xmpp_xep_in_band_bytestreams_connection_input_read_async_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_connection_input_real_close (GInputStream* base,
                                                                   GCancellable* cancellable,
                                                                   GError** error);
static void xmpp_xep_in_band_bytestreams_connection_input_real_close_async_data_free (gpointer _data);
static void xmpp_xep_in_band_bytestreams_connection_input_real_close_async (GInputStream* base,
                                                                     gint io_priority,
                                                                     GCancellable* cancellable,
                                                                     GAsyncReadyCallback _callback_,
                                                                     gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_connection_input_real_close_async_co (XmppXepInBandBytestreamsConnectionInputCloseAsyncData* _data_);
static void xmpp_xep_in_band_bytestreams_connection_input_close_async_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_);
static void xmpp_xep_in_band_bytestreams_connection_input_finalize (GObject * obj);
static GType xmpp_xep_in_band_bytestreams_connection_input_get_type_once (void);
static gssize xmpp_xep_in_band_bytestreams_connection_output_real_write (GOutputStream* base,
                                                                  guint8* buffer,
                                                                  gsize buffer_length1,
                                                                  GCancellable* cancellable,
                                                                  GError** error);
static void xmpp_xep_in_band_bytestreams_connection_output_real_write_async_data_free (gpointer _data);
static void xmpp_xep_in_band_bytestreams_connection_output_real_write_async (GOutputStream* base,
                                                                      guint8* buffer,
                                                                      gsize buffer_length1,
                                                                      gint io_priority,
                                                                      GCancellable* cancellable,
                                                                      GAsyncReadyCallback _callback_,
                                                                      gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_connection_output_real_write_async_co (XmppXepInBandBytestreamsConnectionOutputWriteAsyncData* _data_);
static void xmpp_xep_in_band_bytestreams_connection_output_write_async_ready (GObject* source_object,
                                                                       GAsyncResult* _res_,
                                                                       gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_connection_output_real_close (GOutputStream* base,
                                                                    GCancellable* cancellable,
                                                                    GError** error);
static void xmpp_xep_in_band_bytestreams_connection_output_real_close_async_data_free (gpointer _data);
static void xmpp_xep_in_band_bytestreams_connection_output_real_close_async (GOutputStream* base,
                                                                      gint io_priority,
                                                                      GCancellable* cancellable,
                                                                      GAsyncReadyCallback _callback_,
                                                                      gpointer _user_data_);
static gboolean xmpp_xep_in_band_bytestreams_connection_output_real_close_async_co (XmppXepInBandBytestreamsConnectionOutputCloseAsyncData* _data_);
static void xmpp_xep_in_band_bytestreams_connection_output_close_async_ready (GObject* source_object,
                                                                       GAsyncResult* _res_,
                                                                       gpointer _user_data_);
static void xmpp_xep_in_band_bytestreams_connection_output_finalize (GObject * obj);
static GType xmpp_xep_in_band_bytestreams_connection_output_get_type_once (void);
static void xmpp_xep_in_band_bytestreams_connection_finalize (GObject * obj);
static GType xmpp_xep_in_band_bytestreams_connection_get_type_once (void);
static void _vala_xmpp_xep_in_band_bytestreams_connection_get_property (GObject * object,
                                                                 guint property_id,
                                                                 GValue * value,
                                                                 GParamSpec * pspec);
static void _vala_xmpp_xep_in_band_bytestreams_connection_set_property (GObject * object,
                                                                 guint property_id,
                                                                 const GValue * value,
                                                                 GParamSpec * pspec);
static gchar* xmpp_xep_in_band_bytestreams_flag_real_get_ns (XmppXmppStreamFlag* base);
static gchar* xmpp_xep_in_band_bytestreams_flag_real_get_id (XmppXmppStreamFlag* base);
static void xmpp_xep_in_band_bytestreams_flag_finalize (GObject * obj);
static GType xmpp_xep_in_band_bytestreams_flag_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
xmpp_xep_in_band_bytestreams_module_real_attach (XmppXmppStreamModule* base,
                                                 XmppXmppStream* stream)
{
	XmppXepInBandBytestreamsModule * self;
	XmppXepInBandBytestreamsFlag* _tmp0_;
	XmppXepInBandBytestreamsFlag* _tmp1_;
	XmppModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	XmppIqModule* _tmp4_;
	self = (XmppXepInBandBytestreamsModule*) base;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_xep_in_band_bytestreams_flag_new ();
	_tmp1_ = _tmp0_;
	xmpp_xmpp_stream_add_flag (stream, (XmppXmppStreamFlag*) _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = xmpp_iq_module_IDENTITY;
	_tmp3_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (XmppIqModule*) _tmp3_;
	xmpp_iq_module_register_for_namespace (_tmp4_, XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, (XmppIqHandler*) self);
	_g_object_unref0 (_tmp4_);
}

static void
xmpp_xep_in_band_bytestreams_module_real_detach (XmppXmppStreamModule* base,
                                                 XmppXmppStream* stream)
{
	XmppXepInBandBytestreamsModule * self;
	XmppModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppIqModule* _tmp2_;
	self = (XmppXepInBandBytestreamsModule*) base;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_iq_module_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppIqModule*) _tmp1_;
	xmpp_iq_module_unregister_from_namespace (_tmp2_, XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, (XmppIqHandler*) self);
	_g_object_unref0 (_tmp2_);
}

static void
xmpp_xep_in_band_bytestreams_module_real_on_iq_set_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsModuleOnIqSetData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_g_object_unref0 (_data_->iq);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsModuleOnIqSetData, _data_);
}

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

static void
xmpp_xep_in_band_bytestreams_module_real_on_iq_set (XmppIqHandler* base,
                                                    XmppXmppStream* stream,
                                                    XmppIqStanza* iq,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	XmppXepInBandBytestreamsModule * self;
	XmppXepInBandBytestreamsModuleOnIqSetData* _data_;
	XmppXepInBandBytestreamsModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppIqStanza* _tmp2_;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (iq != NULL);
	self = (XmppXepInBandBytestreamsModule*) base;
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsModuleOnIqSetData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_module_real_on_iq_set_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp1_;
	_tmp2_ = _g_object_ref0 (iq);
	_g_object_unref0 (_data_->iq);
	_data_->iq = _tmp2_;
	xmpp_xep_in_band_bytestreams_module_real_on_iq_set_co (_data_);
}

static void
xmpp_xep_in_band_bytestreams_module_on_iq_set_finish (XmppIqHandler* base,
                                                      GAsyncResult* _res_)
{
	XmppXepInBandBytestreamsModuleOnIqSetData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

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

static gboolean
xmpp_xep_in_band_bytestreams_module_real_on_iq_set_co (XmppXepInBandBytestreamsModuleOnIqSetData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->node = NULL;
	_data_->_tmp1_ = _data_->node;
	if (_data_->_tmp1_ != NULL) {
		_data_->_tmp2_ = _data_->node;
		_data_->_tmp3_ = _xmpp_stanza_entry_ref0 (_data_->_tmp2_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp3_;
	} else {
		_data_->_tmp4_ = ((XmppStanza*) _data_->iq)->stanza;
		_data_->_tmp5_ = xmpp_stanza_node_get_subnode (_data_->_tmp4_, "open", XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, FALSE);
		_xmpp_stanza_entry_unref0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp5_;
	}
	_data_->_tmp6_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_xmpp_stanza_entry_unref0 (_data_->node);
	_data_->node = _data_->_tmp6_;
	_data_->_tmp8_ = _data_->node;
	if (_data_->_tmp8_ != NULL) {
		_data_->_tmp9_ = _data_->node;
		_data_->_tmp10_ = _xmpp_stanza_entry_ref0 (_data_->_tmp9_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
		_data_->_tmp7_ = _data_->_tmp10_;
	} else {
		_data_->_tmp11_ = ((XmppStanza*) _data_->iq)->stanza;
		_data_->_tmp12_ = xmpp_stanza_node_get_subnode (_data_->_tmp11_, "data", XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, FALSE);
		_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
		_data_->_tmp7_ = _data_->_tmp12_;
	}
	_data_->_tmp13_ = _data_->_tmp7_;
	_data_->_tmp7_ = NULL;
	_xmpp_stanza_entry_unref0 (_data_->node);
	_data_->node = _data_->_tmp13_;
	_data_->_tmp15_ = _data_->node;
	if (_data_->_tmp15_ != NULL) {
		_data_->_tmp16_ = _data_->node;
		_data_->_tmp17_ = _xmpp_stanza_entry_ref0 (_data_->_tmp16_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
		_data_->_tmp14_ = _data_->_tmp17_;
	} else {
		_data_->_tmp18_ = ((XmppStanza*) _data_->iq)->stanza;
		_data_->_tmp19_ = xmpp_stanza_node_get_subnode (_data_->_tmp18_, "close", XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, FALSE);
		_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
		_data_->_tmp14_ = _data_->_tmp19_;
	}
	_data_->_tmp20_ = _data_->_tmp14_;
	_data_->_tmp14_ = NULL;
	_xmpp_stanza_entry_unref0 (_data_->node);
	_data_->node = _data_->_tmp20_;
	_data_->_tmp21_ = _data_->node;
	if (_data_->_tmp21_ == NULL) {
		_data_->_tmp22_ = xmpp_iq_module_IDENTITY;
		_data_->_tmp23_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp22_);
		_data_->_tmp24_ = (XmppIqModule*) _data_->_tmp23_;
		_data_->_tmp25_ = xmpp_error_stanza_new_bad_request ("unknown IBB action");
		_data_->_tmp26_ = _data_->_tmp25_;
		_data_->_tmp27_ = xmpp_stanza_get_from ((XmppStanza*) _data_->iq);
		_data_->_tmp28_ = _data_->_tmp27_;
		_data_->_tmp29_ = NULL;
		_data_->_tmp29_ = xmpp_iq_stanza_new_error (_data_->iq, _data_->_tmp26_);
		xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp29_, _data_->_tmp28_);
		_xmpp_jid_unref0 (_data_->_tmp28_);
		_data_->_tmp30_ = _data_->_tmp29_;
		xmpp_iq_module_send_iq (_data_->_tmp24_, _data_->stream, _data_->_tmp30_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_data_->_tmp30_);
		_xmpp_error_stanza_unref0 (_data_->_tmp26_);
		_g_object_unref0 (_data_->_tmp24_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp0_);
		_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;
	}
	_data_->_tmp31_ = _data_->node;
	_data_->_tmp32_ = xmpp_stanza_node_get_attribute (_data_->_tmp31_, "sid", NULL);
	_data_->_tmp33_ = g_strdup (_data_->_tmp32_);
	_data_->sid = _data_->_tmp33_;
	_data_->_tmp34_ = _data_->sid;
	if (_data_->_tmp34_ == NULL) {
		_data_->_tmp35_ = xmpp_iq_module_IDENTITY;
		_data_->_tmp36_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp35_);
		_data_->_tmp37_ = (XmppIqModule*) _data_->_tmp36_;
		_data_->_tmp38_ = xmpp_error_stanza_new_bad_request ("missing sid");
		_data_->_tmp39_ = _data_->_tmp38_;
		_data_->_tmp40_ = xmpp_stanza_get_from ((XmppStanza*) _data_->iq);
		_data_->_tmp41_ = _data_->_tmp40_;
		_data_->_tmp42_ = NULL;
		_data_->_tmp42_ = xmpp_iq_stanza_new_error (_data_->iq, _data_->_tmp39_);
		xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp42_, _data_->_tmp41_);
		_xmpp_jid_unref0 (_data_->_tmp41_);
		_data_->_tmp43_ = _data_->_tmp42_;
		xmpp_iq_module_send_iq (_data_->_tmp37_, _data_->stream, _data_->_tmp43_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_data_->_tmp43_);
		_xmpp_error_stanza_unref0 (_data_->_tmp39_);
		_g_object_unref0 (_data_->_tmp37_);
		_g_free0 (_data_->sid);
		_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
		_xmpp_stanza_entry_unref0 (_data_->_tmp0_);
		_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;
	}
	_data_->_tmp44_ = xmpp_xep_in_band_bytestreams_flag_IDENTITY;
	_data_->_tmp45_ = xmpp_xmpp_stream_get_flag (_data_->stream, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp44_);
	_data_->_tmp46_ = (XmppXepInBandBytestreamsFlag*) _data_->_tmp45_;
	_data_->_tmp47_ = _data_->sid;
	_data_->_tmp48_ = xmpp_xep_in_band_bytestreams_flag_get_connection (_data_->_tmp46_, _data_->_tmp47_);
	_data_->_tmp49_ = _data_->_tmp48_;
	_g_object_unref0 (_data_->_tmp46_);
	_data_->conn = _data_->_tmp49_;
	_data_->_tmp50_ = _data_->node;
	_data_->_tmp51_ = ((XmppStanzaEntry*) _data_->_tmp50_)->name;
	if (g_strcmp0 (_data_->_tmp51_, "open") == 0) {
		_data_->_tmp52_ = _data_->conn;
		if (_data_->_tmp52_ == NULL) {
			_data_->_tmp53_ = xmpp_iq_module_IDENTITY;
			_data_->_tmp54_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp53_);
			_data_->_tmp55_ = (XmppIqModule*) _data_->_tmp54_;
			_data_->_tmp56_ = xmpp_error_stanza_new_not_acceptable ("unexpected IBB connection");
			_data_->_tmp57_ = _data_->_tmp56_;
			_data_->_tmp58_ = xmpp_stanza_get_from ((XmppStanza*) _data_->iq);
			_data_->_tmp59_ = _data_->_tmp58_;
			_data_->_tmp60_ = NULL;
			_data_->_tmp60_ = xmpp_iq_stanza_new_error (_data_->iq, _data_->_tmp57_);
			xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp60_, _data_->_tmp59_);
			_xmpp_jid_unref0 (_data_->_tmp59_);
			_data_->_tmp61_ = _data_->_tmp60_;
			xmpp_iq_module_send_iq (_data_->_tmp55_, _data_->stream, _data_->_tmp61_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
			_g_object_unref0 (_data_->_tmp61_);
			_xmpp_error_stanza_unref0 (_data_->_tmp57_);
			_g_object_unref0 (_data_->_tmp55_);
			_g_object_unref0 (_data_->conn);
			_g_free0 (_data_->sid);
			_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp0_);
			_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;
		}
		_data_->_tmp62_ = _data_->conn;
		_data_->_tmp63_ = xmpp_xep_in_band_bytestreams_connection_get_state (_data_->_tmp62_);
		_data_->_tmp64_ = _data_->_tmp63_;
		if (_data_->_tmp64_ != XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_WAITING_FOR_CONNECT) {
			_data_->_tmp65_ = xmpp_iq_module_IDENTITY;
			_data_->_tmp66_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp65_);
			_data_->_tmp67_ = (XmppIqModule*) _data_->_tmp66_;
			_data_->_tmp68_ = xmpp_error_stanza_new_bad_request ("IBB open for already open connection");
			_data_->_tmp69_ = _data_->_tmp68_;
			_data_->_tmp70_ = xmpp_stanza_get_from ((XmppStanza*) _data_->iq);
			_data_->_tmp71_ = _data_->_tmp70_;
			_data_->_tmp72_ = NULL;
			_data_->_tmp72_ = xmpp_iq_stanza_new_error (_data_->iq, _data_->_tmp69_);
			xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp72_, _data_->_tmp71_);
			_xmpp_jid_unref0 (_data_->_tmp71_);
			_data_->_tmp73_ = _data_->_tmp72_;
			xmpp_iq_module_send_iq (_data_->_tmp67_, _data_->stream, _data_->_tmp73_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
			_g_object_unref0 (_data_->_tmp73_);
			_xmpp_error_stanza_unref0 (_data_->_tmp69_);
			_g_object_unref0 (_data_->_tmp67_);
			_g_object_unref0 (_data_->conn);
			_g_free0 (_data_->sid);
			_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp0_);
			_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;
		}
		_data_->_tmp74_ = _data_->conn;
		_data_->_tmp75_ = _data_->node;
		xmpp_xep_in_band_bytestreams_connection_handle_open (_data_->_tmp74_, _data_->stream, _data_->_tmp75_, _data_->iq);
	} else {
		_data_->_tmp77_ = _data_->conn;
		if (_data_->_tmp77_ == NULL) {
			_data_->_tmp76_ = TRUE;
		} else {
			_data_->_tmp78_ = _data_->conn;
			_data_->_tmp79_ = xmpp_xep_in_band_bytestreams_connection_get_state (_data_->_tmp78_);
			_data_->_tmp80_ = _data_->_tmp79_;
			_data_->_tmp76_ = _data_->_tmp80_ != XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED;
		}
		if (_data_->_tmp76_) {
			_data_->_tmp81_ = xmpp_iq_module_IDENTITY;
			_data_->_tmp82_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp81_);
			_data_->_tmp83_ = (XmppIqModule*) _data_->_tmp82_;
			_data_->_tmp84_ = xmpp_error_stanza_new_item_not_found (NULL);
			_data_->_tmp85_ = _data_->_tmp84_;
			_data_->_tmp86_ = xmpp_stanza_get_from ((XmppStanza*) _data_->iq);
			_data_->_tmp87_ = _data_->_tmp86_;
			_data_->_tmp88_ = NULL;
			_data_->_tmp88_ = xmpp_iq_stanza_new_error (_data_->iq, _data_->_tmp85_);
			xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp88_, _data_->_tmp87_);
			_xmpp_jid_unref0 (_data_->_tmp87_);
			_data_->_tmp89_ = _data_->_tmp88_;
			xmpp_iq_module_send_iq (_data_->_tmp83_, _data_->stream, _data_->_tmp89_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
			_g_object_unref0 (_data_->_tmp89_);
			_xmpp_error_stanza_unref0 (_data_->_tmp85_);
			_g_object_unref0 (_data_->_tmp83_);
			_g_object_unref0 (_data_->conn);
			_g_free0 (_data_->sid);
			_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp0_);
			_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;
		}
		_data_->_tmp90_ = _data_->node;
		_data_->_tmp91_ = ((XmppStanzaEntry*) _data_->_tmp90_)->name;
		if (g_strcmp0 (_data_->_tmp91_, "close") == 0) {
			_data_->_tmp92_ = _data_->conn;
			_data_->_tmp93_ = _data_->node;
			xmpp_xep_in_band_bytestreams_connection_handle_close (_data_->_tmp92_, _data_->stream, _data_->_tmp93_, _data_->iq);
		} else {
			_data_->_tmp94_ = _data_->conn;
			_data_->_tmp95_ = _data_->node;
			xmpp_xep_in_band_bytestreams_connection_handle_data (_data_->_tmp94_, _data_->stream, _data_->_tmp95_, _data_->iq);
		}
	}
	_g_object_unref0 (_data_->conn);
	_g_free0 (_data_->sid);
	_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp0_);
	_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 gchar*
xmpp_xep_in_band_bytestreams_module_real_get_ns (XmppXmppStreamModule* base)
{
	XmppXepInBandBytestreamsModule * self;
	gchar* _tmp0_;
	gchar* result;
	self = (XmppXepInBandBytestreamsModule*) base;
	_tmp0_ = g_strdup (XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI);
	result = _tmp0_;
	return result;
}

static gchar*
xmpp_xep_in_band_bytestreams_module_real_get_id (XmppXmppStreamModule* base)
{
	XmppXepInBandBytestreamsModule * self;
	XmppModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (XmppXepInBandBytestreamsModule*) base;
	_tmp0_ = xmpp_xep_in_band_bytestreams_module_IDENTITY;
	_tmp1_ = xmpp_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

XmppXepInBandBytestreamsModule*
xmpp_xep_in_band_bytestreams_module_construct (GType object_type)
{
	XmppXepInBandBytestreamsModule * self = NULL;
	self = (XmppXepInBandBytestreamsModule*) xmpp_xmpp_stream_module_construct (object_type);
	return self;
}

XmppXepInBandBytestreamsModule*
xmpp_xep_in_band_bytestreams_module_new (void)
{
	return xmpp_xep_in_band_bytestreams_module_construct (XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_MODULE);
}

static void
xmpp_xep_in_band_bytestreams_module_class_init (XmppXepInBandBytestreamsModuleClass * klass,
                                                gpointer klass_data)
{
	XmppModuleIdentity* _tmp0_;
	xmpp_xep_in_band_bytestreams_module_parent_class = g_type_class_peek_parent (klass);
	((XmppXmppStreamModuleClass *) klass)->attach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) xmpp_xep_in_band_bytestreams_module_real_attach;
	((XmppXmppStreamModuleClass *) klass)->detach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) xmpp_xep_in_band_bytestreams_module_real_detach;
	((XmppXmppStreamModuleClass *) klass)->get_ns = (gchar* (*) (XmppXmppStreamModule*)) xmpp_xep_in_band_bytestreams_module_real_get_ns;
	((XmppXmppStreamModuleClass *) klass)->get_id = (gchar* (*) (XmppXmppStreamModule*)) xmpp_xep_in_band_bytestreams_module_real_get_id;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_in_band_bytestreams_module_finalize;
	_tmp0_ = xmpp_module_identity_new (XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, "0047_in_band_bytestreams");
	xmpp_xep_in_band_bytestreams_module_IDENTITY = _tmp0_;
}

static void
xmpp_xep_in_band_bytestreams_module_xmpp_iq_handler_interface_init (XmppIqHandlerIface * iface,
                                                                    gpointer iface_data)
{
	xmpp_xep_in_band_bytestreams_module_xmpp_iq_handler_parent_iface = g_type_interface_peek_parent (iface);
	iface->on_iq_set = (void (*) (XmppIqHandler*, XmppXmppStream*, XmppIqStanza*, GAsyncReadyCallback, gpointer)) xmpp_xep_in_band_bytestreams_module_real_on_iq_set;
	iface->on_iq_set_finish = (void (*) (XmppIqHandler*, GAsyncResult*)) xmpp_xep_in_band_bytestreams_module_on_iq_set_finish;
}

static void
xmpp_xep_in_band_bytestreams_module_instance_init (XmppXepInBandBytestreamsModule * self,
                                                   gpointer klass)
{
}

static void
xmpp_xep_in_band_bytestreams_module_finalize (GObject * obj)
{
	XmppXepInBandBytestreamsModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_MODULE, XmppXepInBandBytestreamsModule);
	G_OBJECT_CLASS (xmpp_xep_in_band_bytestreams_module_parent_class)->finalize (obj);
}

static GType
xmpp_xep_in_band_bytestreams_module_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepInBandBytestreamsModuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_in_band_bytestreams_module_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepInBandBytestreamsModule), 0, (GInstanceInitFunc) xmpp_xep_in_band_bytestreams_module_instance_init, NULL };
	static const GInterfaceInfo xmpp_iq_handler_info = { (GInterfaceInitFunc) xmpp_xep_in_band_bytestreams_module_xmpp_iq_handler_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType xmpp_xep_in_band_bytestreams_module_type_id;
	xmpp_xep_in_band_bytestreams_module_type_id = g_type_register_static (XMPP_TYPE_XMPP_STREAM_MODULE, "XmppXepInBandBytestreamsModule", &g_define_type_info, 0);
	g_type_add_interface_static (xmpp_xep_in_band_bytestreams_module_type_id, XMPP_IQ_TYPE_HANDLER, &xmpp_iq_handler_info);
	return xmpp_xep_in_band_bytestreams_module_type_id;
}

GType
xmpp_xep_in_band_bytestreams_module_get_type (void)
{
	static volatile gsize xmpp_xep_in_band_bytestreams_module_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_in_band_bytestreams_module_type_id__once)) {
		GType xmpp_xep_in_band_bytestreams_module_type_id;
		xmpp_xep_in_band_bytestreams_module_type_id = xmpp_xep_in_band_bytestreams_module_get_type_once ();
		g_once_init_leave (&xmpp_xep_in_band_bytestreams_module_type_id__once, xmpp_xep_in_band_bytestreams_module_type_id);
	}
	return xmpp_xep_in_band_bytestreams_module_type_id__once;
}

static inline gpointer
xmpp_xep_in_band_bytestreams_connection_get_instance_private (XmppXepInBandBytestreamsConnection* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepInBandBytestreamsConnection_private_offset);
}

static GType
xmpp_xep_in_band_bytestreams_connection_state_get_type_once (void)
{
	static const GEnumValue values[] = {{XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_WAITING_FOR_CONNECT, "XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_WAITING_FOR_CONNECT", "waiting-for-connect"}, {XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTING, "XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTING", "connecting"}, {XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED, "XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED", "connected"}, {XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTING, "XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTING", "disconnecting"}, {XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED, "XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED", "disconnected"}, {XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_ERROR, "XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_ERROR", "error"}, {0, NULL, NULL}};
	GType xmpp_xep_in_band_bytestreams_connection_state_type_id;
	xmpp_xep_in_band_bytestreams_connection_state_type_id = g_enum_register_static ("XmppXepInBandBytestreamsConnectionState", values);
	return xmpp_xep_in_band_bytestreams_connection_state_type_id;
}

GType
xmpp_xep_in_band_bytestreams_connection_state_get_type (void)
{
	static volatile gsize xmpp_xep_in_band_bytestreams_connection_state_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_in_band_bytestreams_connection_state_type_id__once)) {
		GType xmpp_xep_in_band_bytestreams_connection_state_type_id;
		xmpp_xep_in_band_bytestreams_connection_state_type_id = xmpp_xep_in_band_bytestreams_connection_state_get_type_once ();
		g_once_init_leave (&xmpp_xep_in_band_bytestreams_connection_state_type_id__once, xmpp_xep_in_band_bytestreams_connection_state_type_id);
	}
	return xmpp_xep_in_band_bytestreams_connection_state_type_id__once;
}

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

static XmppXepInBandBytestreamsConnection*
xmpp_xep_in_band_bytestreams_connection_construct (GType object_type,
                                                   XmppXmppStream* stream,
                                                   XmppJid* receiver_full_jid,
                                                   const gchar* sid,
                                                   gint block_size,
                                                   gboolean initiate)
{
	XmppXepInBandBytestreamsConnection * self = NULL;
	XmppXmppStream* _tmp0_;
	XmppJid* _tmp1_;
	XmppXepInBandBytestreamsConnectionState _tmp2_ = 0;
	XmppXepInBandBytestreamsConnectionInput* _tmp3_;
	XmppXepInBandBytestreamsConnectionOutput* _tmp4_;
	g_return_val_if_fail (stream != NULL, NULL);
	g_return_val_if_fail (receiver_full_jid != NULL, NULL);
	g_return_val_if_fail (sid != NULL, NULL);
	self = (XmppXepInBandBytestreamsConnection*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream);
	_g_object_unref0 (self->priv->stream);
	self->priv->stream = _tmp0_;
	_tmp1_ = _xmpp_jid_ref0 (receiver_full_jid);
	_xmpp_jid_unref0 (self->priv->receiver_full_jid);
	self->priv->receiver_full_jid = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_set_sid (self, sid);
	self->priv->block_size = block_size;
	if (initiate) {
		_tmp2_ = XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTING;
	} else {
		_tmp2_ = XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_WAITING_FOR_CONNECT;
	}
	xmpp_xep_in_band_bytestreams_connection_set_state (self, _tmp2_);
	_tmp3_ = xmpp_xep_in_band_bytestreams_connection_input_new (self);
	_g_object_unref0 (self->priv->input);
	self->priv->input = _tmp3_;
	_tmp4_ = xmpp_xep_in_band_bytestreams_connection_output_new (self);
	_g_object_unref0 (self->priv->output);
	self->priv->output = _tmp4_;
	return self;
}

static XmppXepInBandBytestreamsConnection*
xmpp_xep_in_band_bytestreams_connection_new (XmppXmppStream* stream,
                                             XmppJid* receiver_full_jid,
                                             const gchar* sid,
                                             gint block_size,
                                             gboolean initiate)
{
	return xmpp_xep_in_band_bytestreams_connection_construct (XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_CONNECTION, stream, receiver_full_jid, sid, block_size, initiate);
}

static void
_xmpp_xep_in_band_bytestreams_connection_trigger_read_callback_gfunc (gconstpointer data,
                                                                      gpointer self)
{
	xmpp_xep_in_band_bytestreams_connection_trigger_read_callback ((XmppXepInBandBytestreamsConnection*) self);
}

void
xmpp_xep_in_band_bytestreams_connection_set_read_callback (XmppXepInBandBytestreamsConnection* self,
                                                           GSourceFunc callback,
                                                           gpointer callback_target,
                                                           GDestroyNotify callback_target_destroy_notify,
                                                           GCancellable* cancellable,
                                                           gint io_priority,
                                                           GError** error)
{
	GSourceFunc _tmp0_;
	gpointer _tmp0__target;
	GSourceFunc _tmp2_;
	gpointer _tmp2__target;
	GDestroyNotify _tmp2__target_destroy_notify;
	GCancellable* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->read_callback;
	_tmp0__target = self->priv->read_callback_target;
	if (_tmp0_ != NULL) {
		GError* _tmp1_;
		_tmp1_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_PENDING, "only one async read is permitted at a time on an in-band bytestream");
		_inner_error0_ = _tmp1_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
			callback = NULL;
			callback_target = NULL;
			callback_target_destroy_notify = NULL;
			return;
		} else {
			(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
			callback = NULL;
			callback_target = NULL;
			callback_target_destroy_notify = NULL;
			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;
		}
	}
	if (cancellable != NULL) {
		self->priv->read_callback_cancellable_id = g_cancellable_connect (cancellable, (GCallback) _xmpp_xep_in_band_bytestreams_connection_trigger_read_callback_gfunc, g_object_ref (self), g_object_unref);
	}
	_tmp2_ = callback;
	_tmp2__target = callback_target;
	_tmp2__target_destroy_notify = callback_target_destroy_notify;
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	(self->priv->read_callback_target_destroy_notify == NULL) ? NULL : (self->priv->read_callback_target_destroy_notify (self->priv->read_callback_target), NULL);
	self->priv->read_callback = NULL;
	self->priv->read_callback_target = NULL;
	self->priv->read_callback_target_destroy_notify = NULL;
	self->priv->read_callback = _tmp2_;
	self->priv->read_callback_target = _tmp2__target;
	self->priv->read_callback_target_destroy_notify = _tmp2__target_destroy_notify;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (self->priv->read_callback_cancellable);
	self->priv->read_callback_cancellable = _tmp3_;
	self->priv->read_callback_priority = io_priority;
	(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
}

static void
_xmpp_xep_in_band_bytestreams_connection_trigger_write_callback_gfunc (gconstpointer data,
                                                                       gpointer self)
{
	xmpp_xep_in_band_bytestreams_connection_trigger_write_callback ((XmppXepInBandBytestreamsConnection*) self);
}

void
xmpp_xep_in_band_bytestreams_connection_set_write_callback (XmppXepInBandBytestreamsConnection* self,
                                                            GSourceFunc callback,
                                                            gpointer callback_target,
                                                            GDestroyNotify callback_target_destroy_notify,
                                                            GCancellable* cancellable,
                                                            gint io_priority,
                                                            GError** error)
{
	GSourceFunc _tmp0_;
	gpointer _tmp0__target;
	GSourceFunc _tmp2_;
	gpointer _tmp2__target;
	GDestroyNotify _tmp2__target_destroy_notify;
	GCancellable* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->write_callback;
	_tmp0__target = self->priv->write_callback_target;
	if (_tmp0_ != NULL) {
		GError* _tmp1_;
		_tmp1_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_PENDING, "only one async write is permitted at a time on an in-band bytestream");
		_inner_error0_ = _tmp1_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
			callback = NULL;
			callback_target = NULL;
			callback_target_destroy_notify = NULL;
			return;
		} else {
			(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
			callback = NULL;
			callback_target = NULL;
			callback_target_destroy_notify = NULL;
			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;
		}
	}
	if (cancellable != NULL) {
		self->priv->write_callback_cancellable_id = g_cancellable_connect (cancellable, (GCallback) _xmpp_xep_in_band_bytestreams_connection_trigger_write_callback_gfunc, g_object_ref (self), g_object_unref);
	}
	_tmp2_ = callback;
	_tmp2__target = callback_target;
	_tmp2__target_destroy_notify = callback_target_destroy_notify;
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	(self->priv->write_callback_target_destroy_notify == NULL) ? NULL : (self->priv->write_callback_target_destroy_notify (self->priv->write_callback_target), NULL);
	self->priv->write_callback = NULL;
	self->priv->write_callback_target = NULL;
	self->priv->write_callback_target_destroy_notify = NULL;
	self->priv->write_callback = _tmp2_;
	self->priv->write_callback_target = _tmp2__target;
	self->priv->write_callback_target_destroy_notify = _tmp2__target_destroy_notify;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (self->priv->write_callback_cancellable);
	self->priv->write_callback_cancellable = _tmp3_;
	self->priv->write_callback_priority = io_priority;
	(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
}

void
xmpp_xep_in_band_bytestreams_connection_trigger_read_callback (XmppXepInBandBytestreamsConnection* self)
{
	GSourceFunc _tmp0_;
	gpointer _tmp0__target;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->read_callback;
	_tmp0__target = self->priv->read_callback_target;
	if (_tmp0_ != NULL) {
		GSourceFunc _tmp1_;
		gpointer _tmp1__target;
		GDestroyNotify _tmp1__target_destroy_notify;
		GCancellable* _tmp2_;
		_tmp1_ = self->priv->read_callback;
		_tmp1__target = self->priv->read_callback_target;
		_tmp1__target_destroy_notify = self->priv->read_callback_target_destroy_notify;
		self->priv->read_callback = NULL;
		self->priv->read_callback_target = NULL;
		self->priv->read_callback_target_destroy_notify = NULL;
		g_idle_add_full (self->priv->read_callback_priority, _tmp1_, _tmp1__target, _tmp1__target_destroy_notify);
		(self->priv->read_callback_target_destroy_notify == NULL) ? NULL : (self->priv->read_callback_target_destroy_notify (self->priv->read_callback_target), NULL);
		self->priv->read_callback = NULL;
		self->priv->read_callback_target = NULL;
		self->priv->read_callback_target_destroy_notify = NULL;
		self->priv->read_callback = NULL;
		self->priv->read_callback_target = NULL;
		self->priv->read_callback_target_destroy_notify = NULL;
		_tmp2_ = self->priv->read_callback_cancellable;
		if (_tmp2_ != NULL) {
			GCancellable* _tmp3_;
			_tmp3_ = self->priv->read_callback_cancellable;
			g_cancellable_disconnect (_tmp3_, self->priv->read_callback_cancellable_id);
		}
		_g_object_unref0 (self->priv->read_callback_cancellable);
		self->priv->read_callback_cancellable = NULL;
	}
}

void
xmpp_xep_in_band_bytestreams_connection_trigger_write_callback (XmppXepInBandBytestreamsConnection* self)
{
	GSourceFunc _tmp0_;
	gpointer _tmp0__target;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->write_callback;
	_tmp0__target = self->priv->write_callback_target;
	if (_tmp0_ != NULL) {
		GSourceFunc _tmp1_;
		gpointer _tmp1__target;
		GDestroyNotify _tmp1__target_destroy_notify;
		GCancellable* _tmp2_;
		_tmp1_ = self->priv->write_callback;
		_tmp1__target = self->priv->write_callback_target;
		_tmp1__target_destroy_notify = self->priv->write_callback_target_destroy_notify;
		self->priv->write_callback = NULL;
		self->priv->write_callback_target = NULL;
		self->priv->write_callback_target_destroy_notify = NULL;
		g_idle_add_full (self->priv->write_callback_priority, _tmp1_, _tmp1__target, _tmp1__target_destroy_notify);
		(self->priv->write_callback_target_destroy_notify == NULL) ? NULL : (self->priv->write_callback_target_destroy_notify (self->priv->write_callback_target), NULL);
		self->priv->write_callback = NULL;
		self->priv->write_callback_target = NULL;
		self->priv->write_callback_target_destroy_notify = NULL;
		self->priv->write_callback = NULL;
		self->priv->write_callback_target = NULL;
		self->priv->write_callback_target_destroy_notify = NULL;
		_tmp2_ = self->priv->write_callback_cancellable;
		if (_tmp2_ != NULL) {
			GCancellable* _tmp3_;
			_tmp3_ = self->priv->write_callback_cancellable;
			g_cancellable_disconnect (_tmp3_, self->priv->write_callback_cancellable_id);
		}
		_g_object_unref0 (self->priv->write_callback_cancellable);
		self->priv->write_callback_cancellable = NULL;
	}
}

static void
xmpp_xep_in_band_bytestreams_connection_read_async_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionReadAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionReadAsyncData, _data_);
}

void
xmpp_xep_in_band_bytestreams_connection_read_async (XmppXepInBandBytestreamsConnection* self,
                                                    guint8* buffer,
                                                    gint buffer_length1,
                                                    gint io_priority,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionReadAsyncData* _data_;
	XmppXepInBandBytestreamsConnection* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionReadAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_read_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->buffer = buffer;
	_data_->buffer_length1 = buffer_length1;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_read_async_co (_data_);
}

gssize
xmpp_xep_in_band_bytestreams_connection_read_finish (XmppXepInBandBytestreamsConnection* self,
                                                     GAsyncResult* _res_,
                                                     GError** error)
{
	gssize result;
	XmppXepInBandBytestreamsConnectionReadAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gssize _tmp0_ = 0L;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static gint
_vala_g_bytes_get_length (GBytes* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = (gint) g_bytes_get_size (self);
	return result;
}

static guint8
_vala_g_bytes_get (GBytes* self,
                   gint index)
{
	gboolean _tmp0_ = FALSE;
	guint8* data = NULL;
	gsize _tmp1_ = 0;
	guint8* _tmp2_;
	gint data_length1;
	gint _data_size_;
	guint8 _tmp3_;
	guint8 result;
	g_return_val_if_fail (self != NULL, 0U);
	if (index >= 0) {
		_tmp0_ = index < ((gint) g_bytes_get_size (self));
	} else {
		_tmp0_ = FALSE;
	}
	_vala_assert (_tmp0_, "index >= 0 && index < (int) this.get_size ()");
	_tmp2_ = g_bytes_get_data (self, &_tmp1_);
	data = (guint8*) _tmp2_;
	data_length1 = (_tmp1_ * sizeof (guint8)) / sizeof (guint8);
	_data_size_ = data_length1;
	_tmp3_ = data[index];
	result = _tmp3_;
	return result;
}

static GBytes*
_vala_g_bytes_slice (GBytes* self,
                     gsize start,
                     gsize end)
{
	GBytes* _tmp0_;
	GBytes* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_bytes_new_from_bytes (self, start, end - start);
	result = _tmp0_;
	return result;
}

static gboolean
_xmpp_xep_in_band_bytestreams_connection_read_async_co_gsource_func (gpointer self)
{
	gboolean result;
	result = xmpp_xep_in_band_bytestreams_connection_read_async_co (self);
	return result;
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_read_async_co (XmppXepInBandBytestreamsConnectionReadAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	while (TRUE) {
		if (_data_->cancellable != NULL) {
			g_cancellable_set_error_if_cancelled (_data_->cancellable, &_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;
				}
			}
		}
		if (_data_->self->priv->input_closed) {
			_data_->result = (gssize) 0;
			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;
		}
		_data_->_tmp0_ = _data_->self->priv->received;
		_data_->_tmp1_ = gee_queue_poll ((GeeQueue*) _data_->_tmp0_);
		_data_->chunk = (GBytes*) _data_->_tmp1_;
		_data_->_tmp2_ = _data_->chunk;
		if (_data_->_tmp2_ != NULL) {
			_data_->_tmp3_ = _data_->chunk;
			_data_->_tmp4_ = _vala_g_bytes_get_length (_data_->_tmp3_);
			_data_->_tmp5_ = _data_->_tmp4_;
			_data_->read = MIN (_data_->buffer_length1, _data_->_tmp5_);
			{
				_data_->i = 0;
				{
					_data_->_tmp6_ = TRUE;
					while (TRUE) {
						if (!_data_->_tmp6_) {
							_data_->_tmp7_ = _data_->i;
							_data_->i = _data_->_tmp7_ + 1;
						}
						_data_->_tmp6_ = FALSE;
						if (!(_data_->i < _data_->read)) {
							break;
						}
						_data_->_tmp8_ = _data_->chunk;
						_data_->buffer[_data_->i] = _vala_g_bytes_get (_data_->_tmp8_, _data_->i);
					}
				}
			}
			_data_->_tmp9_ = _data_->chunk;
			_data_->_tmp10_ = _vala_g_bytes_get_length (_data_->_tmp9_);
			_data_->_tmp11_ = _data_->_tmp10_;
			if (_data_->buffer_length1 < _data_->_tmp11_) {
				_data_->_tmp12_ = _data_->self->priv->received;
				_data_->_tmp13_ = _data_->chunk;
				_data_->_tmp14_ = _data_->chunk;
				_data_->_tmp15_ = _vala_g_bytes_get_length (_data_->_tmp14_);
				_data_->_tmp16_ = _data_->_tmp15_;
				_data_->_tmp17_ = _vala_g_bytes_slice (_data_->_tmp13_, (gsize) _data_->buffer_length1, (gsize) _data_->_tmp16_);
				_data_->_tmp18_ = _data_->_tmp17_;
				gee_deque_offer_head ((GeeDeque*) _data_->_tmp12_, _data_->_tmp18_);
				_g_bytes_unref0 (_data_->_tmp18_);
			}
			_data_->result = (gssize) _data_->read;
			_g_bytes_unref0 (_data_->chunk);
			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;
		}
		_data_->_tmp19_ = _data_->self->priv->_state;
		if (_data_->_tmp19_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED) {
			_data_->result = (gssize) 0;
			_g_bytes_unref0 (_data_->chunk);
			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;
		}
		xmpp_xep_in_band_bytestreams_connection_set_read_callback (_data_->self, _xmpp_xep_in_band_bytestreams_connection_read_async_co_gsource_func, _data_, NULL, _data_->cancellable, _data_->io_priority, &_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_bytes_unref0 (_data_->chunk);
				g_object_unref (_data_->_async_result);
				return FALSE;
			} else {
				_g_bytes_unref0 (_data_->chunk);
				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_ = 1;
		return FALSE;
		_state_1:
		;
		_g_bytes_unref0 (_data_->chunk);
	}
}

static void
xmpp_xep_in_band_bytestreams_connection_write_async_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionWriteAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionWriteAsyncData, _data_);
}

void
xmpp_xep_in_band_bytestreams_connection_write_async (XmppXepInBandBytestreamsConnection* self,
                                                     guint8* buffer,
                                                     gint buffer_length1,
                                                     gint io_priority,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionWriteAsyncData* _data_;
	XmppXepInBandBytestreamsConnection* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionWriteAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_write_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->buffer = buffer;
	_data_->buffer_length1 = buffer_length1;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_write_async_co (_data_);
}

gssize
xmpp_xep_in_band_bytestreams_connection_write_finish (XmppXepInBandBytestreamsConnection* self,
                                                      GAsyncResult* _res_,
                                                      GError** error)
{
	gssize result;
	XmppXepInBandBytestreamsConnectionWriteAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gssize _tmp0_ = 0L;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		XmppXepInBandBytestreamsConnection* self;
		self = _data3_->self;
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static gboolean
_xmpp_xep_in_band_bytestreams_connection_write_async_co_gsource_func (gpointer self)
{
	gboolean result;
	result = xmpp_xep_in_band_bytestreams_connection_write_async_co (self);
	return result;
}

static void
__lambda12_ (Block3Data* _data3_,
             XmppXmppStream* stream,
             XmppIqStanza* iq)
{
	XmppXepInBandBytestreamsConnection* self;
	self = _data3_->self;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (iq != NULL);
	if (xmpp_stanza_is_error ((XmppStanza*) iq)) {
		xmpp_xep_in_band_bytestreams_connection_set_error (self, "sending failed");
	} else {
		if (self->priv->remote_ack != _data3_->seq) {
			xmpp_xep_in_band_bytestreams_connection_set_error (self, "out of order acks");
		} else {
			self->priv->remote_ack = (self->priv->remote_ack + 1) % XMPP_XEP_IN_BAND_BYTESTREAMS_SEQ_MODULUS;
			if (self->priv->local_seq == self->priv->remote_ack) {
				xmpp_xep_in_band_bytestreams_connection_trigger_write_callback (self);
			}
		}
	}
}

static void
___lambda12__xmpp_iq_module_on_result (XmppXmppStream* stream,
                                       XmppIqStanza* iq,
                                       gpointer self)
{
	__lambda12_ (self, stream, iq);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_write_async_co (XmppXepInBandBytestreamsConnectionWriteAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data3_ = g_slice_new0 (Block3Data);
	_data_->_data3_->_ref_count_ = 1;
	_data_->_data3_->self = g_object_ref (_data_->self);
	_data_->_data3_->_async_data_ = _data_;
	while (TRUE) {
		_data_->_tmp1_ = _data_->self->priv->_state;
		if (_data_->_tmp1_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_WAITING_FOR_CONNECT) {
			_data_->_tmp0_ = TRUE;
		} else {
			_data_->_tmp2_ = _data_->self->priv->_state;
			_data_->_tmp0_ = _data_->_tmp2_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTING;
		}
		if (!_data_->_tmp0_) {
			break;
		}
		if (_data_->cancellable != NULL) {
			g_cancellable_set_error_if_cancelled (_data_->cancellable, &_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_);
					block3_data_unref (_data_->_data3_);
					_data_->_data3_ = NULL;
					g_object_unref (_data_->_async_result);
					return FALSE;
				} else {
					block3_data_unref (_data_->_data3_);
					_data_->_data3_ = 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;
				}
			}
		}
		xmpp_xep_in_band_bytestreams_connection_set_write_callback (_data_->self, _xmpp_xep_in_band_bytestreams_connection_write_async_co_gsource_func, _data_, NULL, _data_->cancellable, _data_->io_priority, &_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_);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				g_object_unref (_data_->_async_result);
				return FALSE;
			} else {
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = 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;
			}
		}
		_data_->_state_ = 1;
		return FALSE;
		_state_1:
		;
	}
	xmpp_xep_in_band_bytestreams_connection_throw_if_closed (_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_);
			block3_data_unref (_data_->_data3_);
			_data_->_data3_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			block3_data_unref (_data_->_data3_);
			_data_->_data3_ = 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;
		}
	}
	_data_->_tmp3_ = _data_->self->priv->_state;
	_vala_assert (_data_->_tmp3_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED, "state == State.CONNECTED");
	_data_->_data3_->seq = _data_->self->priv->local_seq;
	_data_->self->priv->local_seq = (_data_->self->priv->local_seq + 1) % XMPP_XEP_IN_BAND_BYTESTREAMS_SEQ_MODULUS;
	if (_data_->buffer_length1 > _data_->self->priv->block_size) {
		_data_->buffer = _data_->buffer + 0;
		_data_->buffer_length1 = _data_->self->priv->block_size - 0;
	}
	_data_->_tmp4_ = xmpp_stanza_node_new_build ("data", XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, NULL, NULL);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = xmpp_stanza_node_add_self_xmlns (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = _data_->self->priv->_sid;
	_data_->_tmp9_ = xmpp_stanza_node_put_attribute (_data_->_tmp7_, "sid", _data_->_tmp8_, NULL);
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_tmp11_ = g_strdup_printf ("%i", _data_->_data3_->seq);
	_data_->_tmp12_ = _data_->_tmp11_;
	_data_->_tmp13_ = xmpp_stanza_node_put_attribute (_data_->_tmp10_, "seq", _data_->_tmp12_, NULL);
	_data_->_tmp14_ = _data_->_tmp13_;
	_data_->_tmp15_ = g_base64_encode (_data_->buffer, (gint) _data_->buffer_length1);
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = xmpp_stanza_node_new_text (_data_->_tmp16_);
	_data_->_tmp18_ = _data_->_tmp17_;
	_data_->_tmp19_ = xmpp_stanza_node_put_node (_data_->_tmp14_, _data_->_tmp18_);
	_data_->_tmp20_ = _data_->_tmp19_;
	_xmpp_stanza_entry_unref0 (_data_->_tmp18_);
	_g_free0 (_data_->_tmp16_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp14_);
	_g_free0 (_data_->_tmp12_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp10_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp7_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp5_);
	_data_->data = _data_->_tmp20_;
	_data_->_tmp21_ = _data_->data;
	_data_->_tmp22_ = _data_->self->priv->receiver_full_jid;
	_data_->_tmp23_ = _xmpp_jid_ref0 (_data_->_tmp22_);
	_data_->_tmp24_ = NULL;
	_data_->_tmp24_ = xmpp_iq_stanza_new_set (_data_->_tmp21_, NULL);
	xmpp_stanza_set_to ((XmppStanza*) _data_->_tmp24_, _data_->_tmp23_);
	_xmpp_jid_unref0 (_data_->_tmp23_);
	_data_->iq = _data_->_tmp24_;
	xmpp_xep_in_band_bytestreams_connection_set_write_callback (_data_->self, _xmpp_xep_in_band_bytestreams_connection_write_async_co_gsource_func, _data_, NULL, _data_->cancellable, _data_->io_priority, &_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_unref0 (_data_->iq);
			_xmpp_stanza_entry_unref0 (_data_->data);
			block3_data_unref (_data_->_data3_);
			_data_->_data3_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->iq);
			_xmpp_stanza_entry_unref0 (_data_->data);
			block3_data_unref (_data_->_data3_);
			_data_->_data3_ = 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;
		}
	}
	_data_->_tmp25_ = _data_->self->priv->stream;
	_data_->_tmp26_ = xmpp_iq_module_IDENTITY;
	_data_->_tmp27_ = xmpp_xmpp_stream_get_module (_data_->_tmp25_, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp26_);
	_data_->_tmp28_ = (XmppIqModule*) _data_->_tmp27_;
	_data_->_tmp29_ = _data_->self->priv->stream;
	_data_->_tmp30_ = _data_->iq;
	xmpp_iq_module_send_iq (_data_->_tmp28_, _data_->_tmp29_, _data_->_tmp30_, ___lambda12__xmpp_iq_module_on_result, block3_data_ref (_data_->_data3_), block3_data_unref, G_PRIORITY_DEFAULT);
	_g_object_unref0 (_data_->_tmp28_);
	_data_->_state_ = 2;
	return FALSE;
	_state_2:
	;
	if (_data_->cancellable != NULL) {
		g_cancellable_set_error_if_cancelled (_data_->cancellable, &_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_unref0 (_data_->iq);
				_xmpp_stanza_entry_unref0 (_data_->data);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				g_object_unref (_data_->_async_result);
				return FALSE;
			} else {
				_g_object_unref0 (_data_->iq);
				_xmpp_stanza_entry_unref0 (_data_->data);
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = 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;
			}
		}
	}
	xmpp_xep_in_band_bytestreams_connection_throw_if_error (_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_);
			_g_object_unref0 (_data_->iq);
			_xmpp_stanza_entry_unref0 (_data_->data);
			block3_data_unref (_data_->_data3_);
			_data_->_data3_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_object_unref0 (_data_->iq);
			_xmpp_stanza_entry_unref0 (_data_->data);
			block3_data_unref (_data_->_data3_);
			_data_->_data3_ = 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;
		}
	}
	_data_->result = (gssize) _data_->buffer_length1;
	_g_object_unref0 (_data_->iq);
	_xmpp_stanza_entry_unref0 (_data_->data);
	block3_data_unref (_data_->_data3_);
	_data_->_data3_ = NULL;
	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_xep_in_band_bytestreams_connection_close_read_async_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionCloseReadAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionCloseReadAsyncData, _data_);
}

void
xmpp_xep_in_band_bytestreams_connection_close_read_async (XmppXepInBandBytestreamsConnection* self,
                                                          gint io_priority,
                                                          GCancellable* cancellable,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionCloseReadAsyncData* _data_;
	XmppXepInBandBytestreamsConnection* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionCloseReadAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_close_read_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_close_read_async_co (_data_);
}

gboolean
xmpp_xep_in_band_bytestreams_connection_close_read_finish (XmppXepInBandBytestreamsConnection* self,
                                                           GAsyncResult* _res_,
                                                           GError** error)
{
	gboolean result;
	XmppXepInBandBytestreamsConnectionCloseReadAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_close_read_async_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionCloseReadAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_in_band_bytestreams_connection_close_read_async_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_close_read_async_co (XmppXepInBandBytestreamsConnectionCloseReadAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->self->priv->input_closed = TRUE;
	if (!_data_->self->priv->output_closed) {
		_data_->result = TRUE;
		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;
	}
	_data_->_state_ = 1;
	xmpp_xep_in_band_bytestreams_connection_close_async_impl (_data_->self, _data_->io_priority, _data_->cancellable, xmpp_xep_in_band_bytestreams_connection_close_read_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = xmpp_xep_in_band_bytestreams_connection_close_async_impl_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_->result = _data_->_tmp0_;
	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_xep_in_band_bytestreams_connection_close_write_async_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionCloseWriteAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionCloseWriteAsyncData, _data_);
}

void
xmpp_xep_in_band_bytestreams_connection_close_write_async (XmppXepInBandBytestreamsConnection* self,
                                                           gint io_priority,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionCloseWriteAsyncData* _data_;
	XmppXepInBandBytestreamsConnection* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionCloseWriteAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_close_write_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_close_write_async_co (_data_);
}

gboolean
xmpp_xep_in_band_bytestreams_connection_close_write_finish (XmppXepInBandBytestreamsConnection* self,
                                                            GAsyncResult* _res_,
                                                            GError** error)
{
	gboolean result;
	XmppXepInBandBytestreamsConnectionCloseWriteAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_close_write_async_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionCloseWriteAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_in_band_bytestreams_connection_close_write_async_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_close_write_async_co (XmppXepInBandBytestreamsConnectionCloseWriteAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->self->priv->output_closed = TRUE;
	if (!_data_->self->priv->input_closed) {
		_data_->result = TRUE;
		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;
	}
	_data_->_state_ = 1;
	xmpp_xep_in_band_bytestreams_connection_close_async_impl (_data_->self, _data_->io_priority, _data_->cancellable, xmpp_xep_in_band_bytestreams_connection_close_write_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = xmpp_xep_in_band_bytestreams_connection_close_async_impl_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_->result = _data_->_tmp0_;
	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 Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		XmppXepInBandBytestreamsConnection* self;
		self = _data4_->self;
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

static void
__lambda10_ (Block4Data* _data4_,
             XmppXmppStream* stream,
             XmppIqStanza* iq)
{
	XmppXepInBandBytestreamsConnection* self;
	XmppXepInBandBytestreamsConnectionState _tmp0_;
	XmppFlagIdentity* _tmp1_;
	gpointer _tmp2_;
	XmppXepInBandBytestreamsFlag* _tmp3_;
	self = _data4_->self;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (iq != NULL);
	_tmp0_ = self->priv->_state;
	_vala_assert (_tmp0_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTING, "state == State.DISCONNECTING");
	if (xmpp_stanza_is_error ((XmppStanza*) iq)) {
		xmpp_xep_in_band_bytestreams_connection_set_error (self, "disconnecting failed");
	} else {
		xmpp_xep_in_band_bytestreams_connection_set_state (self, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED);
	}
	_tmp1_ = xmpp_xep_in_band_bytestreams_flag_IDENTITY;
	_tmp2_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (XmppXepInBandBytestreamsFlag*) _tmp2_;
	xmpp_xep_in_band_bytestreams_flag_remove_connection (_tmp3_, self);
	_g_object_unref0 (_tmp3_);
	xmpp_xep_in_band_bytestreams_connection_trigger_read_callback (self);
	_data4_->on_close (!xmpp_stanza_is_error ((XmppStanza*) iq), _data4_->on_close_target);
}

static void
___lambda10__xmpp_iq_module_on_result (XmppXmppStream* stream,
                                       XmppIqStanza* iq,
                                       gpointer self)
{
	__lambda10_ (self, stream, iq);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_close_impl (XmppXepInBandBytestreamsConnection* self,
                                                    GCancellable* cancellable,
                                                    XmppXepInBandBytestreamsConnectionOnClose on_close,
                                                    gpointer on_close_target)
{
	Block4Data* _data4_;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	XmppXepInBandBytestreamsConnectionState _tmp2_;
	XmppXepInBandBytestreamsConnectionState _tmp5_;
	XmppStanzaNode* close = NULL;
	XmppStanzaNode* _tmp10_;
	XmppStanzaNode* _tmp11_;
	XmppStanzaNode* _tmp12_;
	XmppStanzaNode* _tmp13_;
	const gchar* _tmp14_;
	XmppStanzaNode* _tmp15_;
	XmppStanzaNode* _tmp16_;
	XmppIqStanza* iq = NULL;
	XmppStanzaNode* _tmp17_;
	XmppJid* _tmp18_;
	XmppJid* _tmp19_;
	XmppIqStanza* _tmp20_ = NULL;
	XmppXmppStream* _tmp21_;
	XmppModuleIdentity* _tmp22_;
	gpointer _tmp23_;
	XmppIqModule* _tmp24_;
	XmppXmppStream* _tmp25_;
	XmppIqStanza* _tmp26_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_data4_ = g_slice_new0 (Block4Data);
	_data4_->_ref_count_ = 1;
	_data4_->self = g_object_ref (self);
	_data4_->on_close = on_close;
	_data4_->on_close_target = on_close_target;
	_tmp2_ = self->priv->_state;
	if (_tmp2_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTING) {
		_tmp1_ = TRUE;
	} else {
		XmppXepInBandBytestreamsConnectionState _tmp3_;
		_tmp3_ = self->priv->_state;
		_tmp1_ = _tmp3_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		XmppXepInBandBytestreamsConnectionState _tmp4_;
		_tmp4_ = self->priv->_state;
		_tmp0_ = _tmp4_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_ERROR;
	}
	if (_tmp0_) {
		_data4_->on_close (TRUE, _data4_->on_close_target);
		result = TRUE;
		block4_data_unref (_data4_);
		_data4_ = NULL;
		return result;
	}
	_tmp5_ = self->priv->_state;
	if (_tmp5_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_WAITING_FOR_CONNECT) {
		XmppXmppStream* _tmp6_;
		XmppFlagIdentity* _tmp7_;
		gpointer _tmp8_;
		XmppXepInBandBytestreamsFlag* _tmp9_;
		xmpp_xep_in_band_bytestreams_connection_set_state (self, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED);
		_tmp6_ = self->priv->stream;
		_tmp7_ = xmpp_xep_in_band_bytestreams_flag_IDENTITY;
		_tmp8_ = xmpp_xmpp_stream_get_flag (_tmp6_, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp7_);
		_tmp9_ = (XmppXepInBandBytestreamsFlag*) _tmp8_;
		xmpp_xep_in_band_bytestreams_flag_remove_connection (_tmp9_, self);
		_g_object_unref0 (_tmp9_);
		xmpp_xep_in_band_bytestreams_connection_trigger_read_callback (self);
		_data4_->on_close (TRUE, _data4_->on_close_target);
		result = TRUE;
		block4_data_unref (_data4_);
		_data4_ = NULL;
		return result;
	}
	xmpp_xep_in_band_bytestreams_connection_set_state (self, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTING);
	_tmp10_ = xmpp_stanza_node_new_build ("close", XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, NULL, NULL);
	_tmp11_ = _tmp10_;
	_tmp12_ = xmpp_stanza_node_add_self_xmlns (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = self->priv->_sid;
	_tmp15_ = xmpp_stanza_node_put_attribute (_tmp13_, "sid", _tmp14_, NULL);
	_tmp16_ = _tmp15_;
	_xmpp_stanza_entry_unref0 (_tmp13_);
	_xmpp_stanza_entry_unref0 (_tmp11_);
	close = _tmp16_;
	_tmp17_ = close;
	_tmp18_ = self->priv->receiver_full_jid;
	_tmp19_ = _xmpp_jid_ref0 (_tmp18_);
	_tmp20_ = xmpp_iq_stanza_new_set (_tmp17_, NULL);
	xmpp_stanza_set_to ((XmppStanza*) _tmp20_, _tmp19_);
	_xmpp_jid_unref0 (_tmp19_);
	iq = _tmp20_;
	_tmp21_ = self->priv->stream;
	_tmp22_ = xmpp_iq_module_IDENTITY;
	_tmp23_ = xmpp_xmpp_stream_get_module (_tmp21_, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp22_);
	_tmp24_ = (XmppIqModule*) _tmp23_;
	_tmp25_ = self->priv->stream;
	_tmp26_ = iq;
	xmpp_iq_module_send_iq (_tmp24_, _tmp25_, _tmp26_, ___lambda10__xmpp_iq_module_on_result, block4_data_ref (_data4_), block4_data_unref, G_PRIORITY_DEFAULT);
	_g_object_unref0 (_tmp24_);
	result = TRUE;
	_g_object_unref0 (iq);
	_xmpp_stanza_entry_unref0 (close);
	block4_data_unref (_data4_);
	_data4_ = NULL;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_close_async_impl_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionCloseAsyncImplData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionCloseAsyncImplData, _data_);
}

static void
xmpp_xep_in_band_bytestreams_connection_close_async_impl (XmppXepInBandBytestreamsConnection* self,
                                                          gint io_priority,
                                                          GCancellable* cancellable,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionCloseAsyncImplData* _data_;
	XmppXepInBandBytestreamsConnection* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionCloseAsyncImplData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_close_async_impl_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_close_async_impl_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_close_async_impl_finish (XmppXepInBandBytestreamsConnection* self,
                                                                 GAsyncResult* _res_,
                                                                 GError** error)
{
	gboolean result;
	XmppXepInBandBytestreamsConnectionCloseAsyncImplData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static Block5Data*
block5_data_ref (Block5Data* _data5_)
{
	g_atomic_int_inc (&_data5_->_ref_count_);
	return _data5_;
}

static void
block5_data_unref (void * _userdata_)
{
	Block5Data* _data5_;
	_data5_ = (Block5Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data5_->_ref_count_)) {
		XmppXepInBandBytestreamsConnection* self;
		self = _data5_->self;
		(_data5_->callback_target_destroy_notify == NULL) ? NULL : (_data5_->callback_target_destroy_notify (_data5_->callback_target), NULL);
		_data5_->callback = NULL;
		_data5_->callback_target = NULL;
		_data5_->callback_target_destroy_notify = NULL;
		_g_object_unref0 (self);
		g_slice_free (Block5Data, _data5_);
	}
}

static gboolean
_xmpp_xep_in_band_bytestreams_connection_close_async_impl_co_gsource_func (gpointer self)
{
	gboolean result;
	result = xmpp_xep_in_band_bytestreams_connection_close_async_impl_co (self);
	return result;
}

static void
__lambda11_ (Block5Data* _data5_)
{
	XmppXepInBandBytestreamsConnection* self;
	GSourceFunc _tmp0_;
	gpointer _tmp0__target;
	GDestroyNotify _tmp0__target_destroy_notify;
	self = _data5_->self;
	_tmp0_ = _data5_->callback;
	_tmp0__target = _data5_->callback_target;
	_tmp0__target_destroy_notify = _data5_->callback_target_destroy_notify;
	_data5_->callback = NULL;
	_data5_->callback_target = NULL;
	_data5_->callback_target_destroy_notify = NULL;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _tmp0_, _tmp0__target, _tmp0__target_destroy_notify);
}

static void
___lambda11__xmpp_xep_in_band_bytestreams_connection_on_close (gboolean success,
                                                               gpointer self)
{
	__lambda11_ (self);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_close_async_impl_co (XmppXepInBandBytestreamsConnectionCloseAsyncImplData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data5_ = g_slice_new0 (Block5Data);
	_data_->_data5_->_ref_count_ = 1;
	_data_->_data5_->self = g_object_ref (_data_->self);
	_data_->_data5_->_async_data_ = _data_;
	_data_->_data5_->callback = _xmpp_xep_in_band_bytestreams_connection_close_async_impl_co_gsource_func;
	_data_->_data5_->callback_target = _data_;
	_data_->_data5_->callback_target_destroy_notify = NULL;
	xmpp_xep_in_band_bytestreams_connection_close_impl (_data_->self, _data_->cancellable, ___lambda11__xmpp_xep_in_band_bytestreams_connection_on_close, _data_->_data5_);
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	xmpp_xep_in_band_bytestreams_connection_throw_if_error (_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_);
			block5_data_unref (_data_->_data5_);
			_data_->_data5_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			block5_data_unref (_data_->_data5_);
			_data_->_data5_ = 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;
		}
	}
	_data_->result = TRUE;
	block5_data_unref (_data_->_data5_);
	_data_->_data5_ = NULL;
	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 Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		_g_object_unref0 (_data6_->conn);
		g_slice_free (Block6Data, _data6_);
	}
}

static void
___lambda13_ (Block6Data* _data6_,
              XmppXmppStream* stream,
              XmppIqStanza* iq)
{
	XmppXepInBandBytestreamsConnection* _tmp0_;
	XmppXepInBandBytestreamsConnectionState _tmp1_;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (iq != NULL);
	_tmp0_ = _data6_->conn;
	_tmp1_ = _tmp0_->priv->_state;
	if (_tmp1_ != XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTING) {
		XmppXepInBandBytestreamsConnection* _tmp2_;
		XmppXepInBandBytestreamsConnectionState _tmp3_;
		_tmp2_ = _data6_->conn;
		_tmp3_ = _tmp2_->priv->_state;
		_vala_assert (_tmp3_ != XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED, "conn.state != State.CONNECTED");
		return;
	}
	if (!xmpp_stanza_is_error ((XmppStanza*) iq)) {
		XmppXepInBandBytestreamsConnection* _tmp4_;
		XmppFlagIdentity* _tmp5_;
		gpointer _tmp6_;
		XmppXepInBandBytestreamsFlag* _tmp7_;
		XmppXepInBandBytestreamsConnection* _tmp8_;
		XmppXepInBandBytestreamsConnection* _tmp9_;
		_tmp4_ = _data6_->conn;
		xmpp_xep_in_band_bytestreams_connection_set_state (_tmp4_, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED);
		_tmp5_ = xmpp_xep_in_band_bytestreams_flag_IDENTITY;
		_tmp6_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp5_);
		_tmp7_ = (XmppXepInBandBytestreamsFlag*) _tmp6_;
		_tmp8_ = _data6_->conn;
		xmpp_xep_in_band_bytestreams_flag_add_connection (_tmp7_, _tmp8_);
		_g_object_unref0 (_tmp7_);
		_tmp9_ = _data6_->conn;
		xmpp_xep_in_band_bytestreams_connection_trigger_write_callback (_tmp9_);
	} else {
		XmppXepInBandBytestreamsConnection* _tmp10_;
		_tmp10_ = _data6_->conn;
		xmpp_xep_in_band_bytestreams_connection_set_error (_tmp10_, "connection failed");
	}
}

static void
____lambda13__xmpp_iq_module_on_result (XmppXmppStream* stream,
                                        XmppIqStanza* iq,
                                        gpointer self)
{
	___lambda13_ (self, stream, iq);
}

XmppXepInBandBytestreamsConnection*
xmpp_xep_in_band_bytestreams_connection_create (XmppXmppStream* stream,
                                                XmppJid* receiver_full_jid,
                                                const gchar* sid,
                                                gint block_size,
                                                gboolean initiate)
{
	Block6Data* _data6_;
	XmppXepInBandBytestreamsConnection* _tmp0_;
	XmppXepInBandBytestreamsConnection* _tmp22_;
	XmppXepInBandBytestreamsConnection* _tmp23_;
	XmppXepInBandBytestreamsConnection* result;
	g_return_val_if_fail (stream != NULL, NULL);
	g_return_val_if_fail (receiver_full_jid != NULL, NULL);
	g_return_val_if_fail (sid != NULL, NULL);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_tmp0_ = xmpp_xep_in_band_bytestreams_connection_new (stream, receiver_full_jid, sid, block_size, initiate);
	_data6_->conn = _tmp0_;
	if (initiate) {
		XmppStanzaNode* open = NULL;
		XmppStanzaNode* _tmp1_;
		XmppStanzaNode* _tmp2_;
		XmppStanzaNode* _tmp3_;
		XmppStanzaNode* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		XmppStanzaNode* _tmp7_;
		XmppStanzaNode* _tmp8_;
		XmppStanzaNode* _tmp9_;
		XmppStanzaNode* _tmp10_;
		XmppIqStanza* iq = NULL;
		XmppStanzaNode* _tmp11_;
		XmppJid* _tmp12_;
		XmppIqStanza* _tmp13_ = NULL;
		XmppModuleIdentity* _tmp14_;
		gpointer _tmp15_;
		XmppIqModule* _tmp16_;
		XmppIqStanza* _tmp17_;
		_tmp1_ = xmpp_stanza_node_new_build ("open", XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, NULL, NULL);
		_tmp2_ = _tmp1_;
		_tmp3_ = xmpp_stanza_node_add_self_xmlns (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_strdup_printf ("%i", block_size);
		_tmp6_ = _tmp5_;
		_tmp7_ = xmpp_stanza_node_put_attribute (_tmp4_, "block-size", _tmp6_, NULL);
		_tmp8_ = _tmp7_;
		_tmp9_ = xmpp_stanza_node_put_attribute (_tmp8_, "sid", sid, NULL);
		_tmp10_ = _tmp9_;
		_xmpp_stanza_entry_unref0 (_tmp8_);
		_g_free0 (_tmp6_);
		_xmpp_stanza_entry_unref0 (_tmp4_);
		_xmpp_stanza_entry_unref0 (_tmp2_);
		open = _tmp10_;
		_tmp11_ = open;
		_tmp12_ = _xmpp_jid_ref0 (receiver_full_jid);
		_tmp13_ = xmpp_iq_stanza_new_set (_tmp11_, NULL);
		xmpp_stanza_set_to ((XmppStanza*) _tmp13_, _tmp12_);
		_xmpp_jid_unref0 (_tmp12_);
		iq = _tmp13_;
		_tmp14_ = xmpp_iq_module_IDENTITY;
		_tmp15_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp14_);
		_tmp16_ = (XmppIqModule*) _tmp15_;
		_tmp17_ = iq;
		xmpp_iq_module_send_iq (_tmp16_, stream, _tmp17_, ____lambda13__xmpp_iq_module_on_result, block6_data_ref (_data6_), block6_data_unref, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_tmp16_);
		_g_object_unref0 (iq);
		_xmpp_stanza_entry_unref0 (open);
	} else {
		XmppFlagIdentity* _tmp18_;
		gpointer _tmp19_;
		XmppXepInBandBytestreamsFlag* _tmp20_;
		XmppXepInBandBytestreamsConnection* _tmp21_;
		_tmp18_ = xmpp_xep_in_band_bytestreams_flag_IDENTITY;
		_tmp19_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp18_);
		_tmp20_ = (XmppXepInBandBytestreamsFlag*) _tmp19_;
		_tmp21_ = _data6_->conn;
		xmpp_xep_in_band_bytestreams_flag_add_connection (_tmp20_, _tmp21_);
		_g_object_unref0 (_tmp20_);
	}
	_tmp22_ = _data6_->conn;
	_tmp23_ = _g_object_ref0 (_tmp22_);
	result = _tmp23_;
	block6_data_unref (_data6_);
	_data6_ = NULL;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_throw_if_error (XmppXepInBandBytestreamsConnection* self,
                                                        GError** error)
{
	XmppXepInBandBytestreamsConnectionState _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_state;
	if (_tmp0_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_ERROR) {
		const gchar* _tmp1_;
		GError* _tmp2_;
		_tmp1_ = self->priv->error;
		_tmp2_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _tmp1_);
		_inner_error0_ = _tmp2_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} 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;
		}
	}
}

static void
xmpp_xep_in_band_bytestreams_connection_throw_if_closed (XmppXepInBandBytestreamsConnection* self,
                                                         GError** error)
{
	gboolean _tmp0_ = FALSE;
	XmppXepInBandBytestreamsConnectionState _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	xmpp_xep_in_band_bytestreams_connection_throw_if_error (self, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} 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;
		}
	}
	_tmp1_ = self->priv->_state;
	if (_tmp1_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTING) {
		_tmp0_ = TRUE;
	} else {
		XmppXepInBandBytestreamsConnectionState _tmp2_;
		_tmp2_ = self->priv->_state;
		_tmp0_ = _tmp2_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED;
	}
	if (_tmp0_) {
		GError* _tmp3_;
		_tmp3_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "can't read/write on a closed connection");
		_inner_error0_ = _tmp3_;
		if (_inner_error0_->domain == G_IO_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} 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;
		}
	}
}

static void
xmpp_xep_in_band_bytestreams_connection_set_error (XmppXepInBandBytestreamsConnection* self,
                                                   const gchar* _error_)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	XmppXepInBandBytestreamsConnectionState _tmp3_;
	gchar* _tmp7_;
	XmppXmppStream* _tmp8_;
	XmppFlagIdentity* _tmp9_;
	gpointer _tmp10_;
	XmppXepInBandBytestreamsFlag* _tmp11_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (_error_ != NULL);
	_tmp3_ = self->priv->_state;
	if (_tmp3_ != XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_WAITING_FOR_CONNECT) {
		XmppXepInBandBytestreamsConnectionState _tmp4_;
		_tmp4_ = self->priv->_state;
		_tmp2_ = _tmp4_ != XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTING;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		XmppXepInBandBytestreamsConnectionState _tmp5_;
		_tmp5_ = self->priv->_state;
		_tmp1_ = _tmp5_ != XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		XmppXepInBandBytestreamsConnectionState _tmp6_;
		_tmp6_ = self->priv->_state;
		_tmp0_ = _tmp6_ != XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_ERROR;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		g_io_stream_close_async ((GIOStream*) self, G_PRIORITY_DEFAULT, NULL, NULL, NULL);
	}
	xmpp_xep_in_band_bytestreams_connection_set_state (self, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_ERROR);
	_tmp7_ = g_strdup (_error_);
	_g_free0 (self->priv->error);
	self->priv->error = _tmp7_;
	_tmp8_ = self->priv->stream;
	_tmp9_ = xmpp_xep_in_band_bytestreams_flag_IDENTITY;
	_tmp10_ = xmpp_xmpp_stream_get_flag (_tmp8_, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp9_);
	_tmp11_ = (XmppXepInBandBytestreamsFlag*) _tmp10_;
	xmpp_xep_in_band_bytestreams_flag_remove_connection (_tmp11_, self);
	_g_object_unref0 (_tmp11_);
}

void
xmpp_xep_in_band_bytestreams_connection_handle_open (XmppXepInBandBytestreamsConnection* self,
                                                     XmppXmppStream* stream,
                                                     XmppStanzaNode* open,
                                                     XmppIqStanza* iq)
{
	XmppXepInBandBytestreamsConnectionState _tmp0_;
	gint block_size = 0;
	gchar* stanza = NULL;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp18_ = FALSE;
	const gchar* _tmp19_;
	XmppModuleIdentity* _tmp39_;
	gpointer _tmp40_;
	XmppIqModule* _tmp41_;
	XmppIqStanza* _tmp42_;
	XmppIqStanza* _tmp43_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (open != NULL);
	g_return_if_fail (iq != NULL);
	_tmp0_ = self->priv->_state;
	_vala_assert (_tmp0_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_WAITING_FOR_CONNECT, "state == State.WAITING_FOR_CONNECT");
	block_size = xmpp_stanza_node_get_attribute_int (open, "block-size", -1, NULL);
	_tmp1_ = xmpp_stanza_node_get_attribute (open, "stanza", NULL);
	_tmp2_ = g_strdup (_tmp1_);
	stanza = _tmp2_;
	if (block_size < 0) {
		_tmp3_ = TRUE;
	} else {
		gboolean _tmp4_ = FALSE;
		gboolean _tmp5_ = FALSE;
		const gchar* _tmp6_;
		_tmp6_ = stanza;
		if (_tmp6_ != NULL) {
			const gchar* _tmp7_;
			_tmp7_ = stanza;
			_tmp5_ = g_strcmp0 (_tmp7_, "iq") != 0;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			const gchar* _tmp8_;
			_tmp8_ = stanza;
			_tmp4_ = g_strcmp0 (_tmp8_, "message") != 0;
		} else {
			_tmp4_ = FALSE;
		}
		_tmp3_ = _tmp4_;
	}
	if (_tmp3_) {
		XmppModuleIdentity* _tmp9_;
		gpointer _tmp10_;
		XmppIqModule* _tmp11_;
		XmppErrorStanza* _tmp12_;
		XmppErrorStanza* _tmp13_;
		XmppJid* _tmp14_;
		XmppJid* _tmp15_;
		XmppIqStanza* _tmp16_ = NULL;
		XmppIqStanza* _tmp17_;
		xmpp_xep_in_band_bytestreams_connection_set_error (self, "invalid open");
		_tmp9_ = xmpp_iq_module_IDENTITY;
		_tmp10_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp9_);
		_tmp11_ = (XmppIqModule*) _tmp10_;
		_tmp12_ = xmpp_error_stanza_new_bad_request ("missing block_size or invalid stanza");
		_tmp13_ = _tmp12_;
		_tmp14_ = xmpp_stanza_get_from ((XmppStanza*) iq);
		_tmp15_ = _tmp14_;
		_tmp16_ = xmpp_iq_stanza_new_error (iq, _tmp13_);
		xmpp_stanza_set_to ((XmppStanza*) _tmp16_, _tmp15_);
		_xmpp_jid_unref0 (_tmp15_);
		_tmp17_ = _tmp16_;
		xmpp_iq_module_send_iq (_tmp11_, stream, _tmp17_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_tmp17_);
		_xmpp_error_stanza_unref0 (_tmp13_);
		_g_object_unref0 (_tmp11_);
		_g_free0 (stanza);
		return;
	}
	_tmp19_ = stanza;
	if (_tmp19_ != NULL) {
		const gchar* _tmp20_;
		_tmp20_ = stanza;
		_tmp18_ = g_strcmp0 (_tmp20_, "iq") != 0;
	} else {
		_tmp18_ = FALSE;
	}
	if (_tmp18_) {
		XmppModuleIdentity* _tmp21_;
		gpointer _tmp22_;
		XmppIqModule* _tmp23_;
		XmppErrorStanza* _tmp24_;
		XmppErrorStanza* _tmp25_;
		XmppJid* _tmp26_;
		XmppJid* _tmp27_;
		XmppIqStanza* _tmp28_ = NULL;
		XmppIqStanza* _tmp29_;
		xmpp_xep_in_band_bytestreams_connection_set_error (self, "invalid open");
		_tmp21_ = xmpp_iq_module_IDENTITY;
		_tmp22_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp21_);
		_tmp23_ = (XmppIqModule*) _tmp22_;
		_tmp24_ = xmpp_error_stanza_new_feature_not_implemented ("cannot use message stanzas for IBB");
		_tmp25_ = _tmp24_;
		_tmp26_ = xmpp_stanza_get_from ((XmppStanza*) iq);
		_tmp27_ = _tmp26_;
		_tmp28_ = xmpp_iq_stanza_new_error (iq, _tmp25_);
		xmpp_stanza_set_to ((XmppStanza*) _tmp28_, _tmp27_);
		_xmpp_jid_unref0 (_tmp27_);
		_tmp29_ = _tmp28_;
		xmpp_iq_module_send_iq (_tmp23_, stream, _tmp29_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_tmp29_);
		_xmpp_error_stanza_unref0 (_tmp25_);
		_g_object_unref0 (_tmp23_);
		_g_free0 (stanza);
		return;
	}
	if (block_size > self->priv->block_size) {
		XmppModuleIdentity* _tmp30_;
		gpointer _tmp31_;
		XmppIqModule* _tmp32_;
		XmppErrorStanza* _tmp33_;
		XmppErrorStanza* _tmp34_;
		XmppJid* _tmp35_;
		XmppJid* _tmp36_;
		XmppIqStanza* _tmp37_ = NULL;
		XmppIqStanza* _tmp38_;
		xmpp_xep_in_band_bytestreams_connection_set_error (self, "invalid open");
		_tmp30_ = xmpp_iq_module_IDENTITY;
		_tmp31_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp30_);
		_tmp32_ = (XmppIqModule*) _tmp31_;
		_tmp33_ = xmpp_error_stanza_new_build (XMPP_ERROR_STANZA_TYPE_CANCEL, XMPP_ERROR_STANZA_CONDITION_RESOURCE_CONSTRAINT, "opening a connection with a greater than negotiated/acceptable block s" \
"ize", NULL);
		_tmp34_ = _tmp33_;
		_tmp35_ = xmpp_stanza_get_from ((XmppStanza*) iq);
		_tmp36_ = _tmp35_;
		_tmp37_ = xmpp_iq_stanza_new_error (iq, _tmp34_);
		xmpp_stanza_set_to ((XmppStanza*) _tmp37_, _tmp36_);
		_xmpp_jid_unref0 (_tmp36_);
		_tmp38_ = _tmp37_;
		xmpp_iq_module_send_iq (_tmp32_, stream, _tmp38_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_tmp38_);
		_xmpp_error_stanza_unref0 (_tmp34_);
		_g_object_unref0 (_tmp32_);
		_g_free0 (stanza);
		return;
	}
	self->priv->block_size = block_size;
	xmpp_xep_in_band_bytestreams_connection_set_state (self, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED);
	_tmp39_ = xmpp_iq_module_IDENTITY;
	_tmp40_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp39_);
	_tmp41_ = (XmppIqModule*) _tmp40_;
	_tmp42_ = xmpp_iq_stanza_new_result (iq, NULL);
	_tmp43_ = _tmp42_;
	xmpp_iq_module_send_iq (_tmp41_, stream, _tmp43_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
	_g_object_unref0 (_tmp43_);
	_g_object_unref0 (_tmp41_);
	xmpp_xep_in_band_bytestreams_connection_trigger_write_callback (self);
	_g_free0 (stanza);
}

static guint8*
_vala_array_dup7 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

void
xmpp_xep_in_band_bytestreams_connection_handle_data (XmppXepInBandBytestreamsConnection* self,
                                                     XmppXmppStream* stream,
                                                     XmppStanzaNode* data,
                                                     XmppIqStanza* iq)
{
	XmppXepInBandBytestreamsConnectionState _tmp0_;
	gint seq = 0;
	guint8* content = NULL;
	const gchar* _tmp10_;
	gsize _tmp11_ = 0;
	guchar* _tmp12_;
	gint content_length1;
	gint _content_size_;
	guint8* _tmp13_;
	gint _tmp13__length1;
	gboolean _tmp23_ = FALSE;
	XmppModuleIdentity* _tmp33_;
	gpointer _tmp34_;
	XmppIqModule* _tmp35_;
	XmppIqStanza* _tmp36_;
	XmppIqStanza* _tmp37_;
	guint8* _tmp38_;
	gint _tmp38__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (data != NULL);
	g_return_if_fail (iq != NULL);
	_tmp0_ = self->priv->_state;
	_vala_assert (_tmp0_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED, "state == State.CONNECTED");
	if (self->priv->input_closed) {
		XmppModuleIdentity* _tmp1_;
		gpointer _tmp2_;
		XmppIqModule* _tmp3_;
		XmppErrorStanza* _tmp4_;
		XmppErrorStanza* _tmp5_;
		XmppJid* _tmp6_;
		XmppJid* _tmp7_;
		XmppIqStanza* _tmp8_ = NULL;
		XmppIqStanza* _tmp9_;
		xmpp_xep_in_band_bytestreams_connection_set_error (self, "unexpected data");
		_tmp1_ = xmpp_iq_module_IDENTITY;
		_tmp2_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
		_tmp3_ = (XmppIqModule*) _tmp2_;
		_tmp4_ = xmpp_error_stanza_new_not_allowed ("unexpected data");
		_tmp5_ = _tmp4_;
		_tmp6_ = xmpp_stanza_get_from ((XmppStanza*) iq);
		_tmp7_ = _tmp6_;
		_tmp8_ = xmpp_iq_stanza_new_error (iq, _tmp5_);
		xmpp_stanza_set_to ((XmppStanza*) _tmp8_, _tmp7_);
		_xmpp_jid_unref0 (_tmp7_);
		_tmp9_ = _tmp8_;
		xmpp_iq_module_send_iq (_tmp3_, stream, _tmp9_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_tmp9_);
		_xmpp_error_stanza_unref0 (_tmp5_);
		_g_object_unref0 (_tmp3_);
		return;
	}
	seq = xmpp_stanza_node_get_attribute_int (data, "seq", -1, NULL);
	_tmp10_ = xmpp_stanza_entry_get_string_content ((XmppStanzaEntry*) data);
	_tmp12_ = g_base64_decode (_tmp10_, &_tmp11_);
	content = _tmp12_;
	content_length1 = _tmp11_;
	_content_size_ = content_length1;
	_tmp13_ = content;
	_tmp13__length1 = content_length1;
	if (_tmp13__length1 > self->priv->block_size) {
		XmppModuleIdentity* _tmp14_;
		gpointer _tmp15_;
		XmppIqModule* _tmp16_;
		XmppErrorStanza* _tmp17_;
		XmppErrorStanza* _tmp18_;
		XmppJid* _tmp19_;
		XmppJid* _tmp20_;
		XmppIqStanza* _tmp21_ = NULL;
		XmppIqStanza* _tmp22_;
		xmpp_xep_in_band_bytestreams_connection_set_error (self, "data longer than negotiated block size");
		_tmp14_ = xmpp_iq_module_IDENTITY;
		_tmp15_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp14_);
		_tmp16_ = (XmppIqModule*) _tmp15_;
		_tmp17_ = xmpp_error_stanza_new_bad_request ("data longer than negotiated block size");
		_tmp18_ = _tmp17_;
		_tmp19_ = xmpp_stanza_get_from ((XmppStanza*) iq);
		_tmp20_ = _tmp19_;
		_tmp21_ = xmpp_iq_stanza_new_error (iq, _tmp18_);
		xmpp_stanza_set_to ((XmppStanza*) _tmp21_, _tmp20_);
		_xmpp_jid_unref0 (_tmp20_);
		_tmp22_ = _tmp21_;
		xmpp_iq_module_send_iq (_tmp16_, stream, _tmp22_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_tmp22_);
		_xmpp_error_stanza_unref0 (_tmp18_);
		_g_object_unref0 (_tmp16_);
		content = (g_free (content), NULL);
		return;
	}
	if (seq < 0) {
		_tmp23_ = TRUE;
	} else {
		_tmp23_ = seq != self->remote_seq;
	}
	if (_tmp23_) {
		XmppModuleIdentity* _tmp24_;
		gpointer _tmp25_;
		XmppIqModule* _tmp26_;
		XmppErrorStanza* _tmp27_;
		XmppErrorStanza* _tmp28_;
		XmppJid* _tmp29_;
		XmppJid* _tmp30_;
		XmppIqStanza* _tmp31_ = NULL;
		XmppIqStanza* _tmp32_;
		xmpp_xep_in_band_bytestreams_connection_set_error (self, "out of order data packets");
		_tmp24_ = xmpp_iq_module_IDENTITY;
		_tmp25_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp24_);
		_tmp26_ = (XmppIqModule*) _tmp25_;
		_tmp27_ = xmpp_error_stanza_new_build (XMPP_ERROR_STANZA_TYPE_CANCEL, XMPP_ERROR_STANZA_CONDITION_UNEXPECTED_REQUEST, "out of order data packets", NULL);
		_tmp28_ = _tmp27_;
		_tmp29_ = xmpp_stanza_get_from ((XmppStanza*) iq);
		_tmp30_ = _tmp29_;
		_tmp31_ = xmpp_iq_stanza_new_error (iq, _tmp28_);
		xmpp_stanza_set_to ((XmppStanza*) _tmp31_, _tmp30_);
		_xmpp_jid_unref0 (_tmp30_);
		_tmp32_ = _tmp31_;
		xmpp_iq_module_send_iq (_tmp26_, stream, _tmp32_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
		_g_object_unref0 (_tmp32_);
		_xmpp_error_stanza_unref0 (_tmp28_);
		_g_object_unref0 (_tmp26_);
		content = (g_free (content), NULL);
		return;
	}
	self->remote_seq = (self->remote_seq + 1) % XMPP_XEP_IN_BAND_BYTESTREAMS_SEQ_MODULUS;
	_tmp33_ = xmpp_iq_module_IDENTITY;
	_tmp34_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp33_);
	_tmp35_ = (XmppIqModule*) _tmp34_;
	_tmp36_ = xmpp_iq_stanza_new_result (iq, NULL);
	_tmp37_ = _tmp36_;
	xmpp_iq_module_send_iq (_tmp35_, stream, _tmp37_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
	_g_object_unref0 (_tmp37_);
	_g_object_unref0 (_tmp35_);
	_tmp38_ = content;
	_tmp38__length1 = content_length1;
	if (_tmp38__length1 != 0) {
		GeeLinkedList* _tmp39_;
		guint8* _tmp40_;
		gint _tmp40__length1;
		guint8* _tmp41_;
		gint _tmp41__length1;
		GBytes* _tmp42_;
		GBytes* _tmp43_;
		_tmp39_ = self->priv->received;
		_tmp40_ = content;
		_tmp40__length1 = content_length1;
		_tmp41_ = (_tmp40_ != NULL) ? _vala_array_dup7 (_tmp40_, _tmp40__length1) : _tmp40_;
		_tmp41__length1 = _tmp40__length1;
		_tmp42_ = g_bytes_new_take (_tmp41_, _tmp41__length1);
		_tmp43_ = _tmp42_;
		gee_queue_offer ((GeeQueue*) _tmp39_, _tmp43_);
		_g_bytes_unref0 (_tmp43_);
		xmpp_xep_in_band_bytestreams_connection_trigger_read_callback (self);
	}
	content = (g_free (content), NULL);
}

void
xmpp_xep_in_band_bytestreams_connection_handle_close (XmppXepInBandBytestreamsConnection* self,
                                                      XmppXmppStream* stream,
                                                      XmppStanzaNode* close,
                                                      XmppIqStanza* iq)
{
	XmppXepInBandBytestreamsConnectionState _tmp0_;
	XmppModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	XmppIqModule* _tmp3_;
	XmppIqStanza* _tmp4_;
	XmppIqStanza* _tmp5_;
	XmppFlagIdentity* _tmp6_;
	gpointer _tmp7_;
	XmppXepInBandBytestreamsFlag* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (close != NULL);
	g_return_if_fail (iq != NULL);
	_tmp0_ = self->priv->_state;
	_vala_assert (_tmp0_ == XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_CONNECTED, "state == State.CONNECTED");
	_tmp1_ = xmpp_iq_module_IDENTITY;
	_tmp2_ = xmpp_xmpp_stream_get_module (stream, XMPP_IQ_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (XmppIqModule*) _tmp2_;
	_tmp4_ = xmpp_iq_stanza_new_result (iq, NULL);
	_tmp5_ = _tmp4_;
	xmpp_iq_module_send_iq (_tmp3_, stream, _tmp5_, NULL, NULL, NULL, G_PRIORITY_DEFAULT);
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp3_);
	_tmp6_ = xmpp_xep_in_band_bytestreams_flag_IDENTITY;
	_tmp7_ = xmpp_xmpp_stream_get_flag (stream, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp6_);
	_tmp8_ = (XmppXepInBandBytestreamsFlag*) _tmp7_;
	xmpp_xep_in_band_bytestreams_flag_remove_connection (_tmp8_, self);
	_g_object_unref0 (_tmp8_);
	self->priv->input_closed = TRUE;
	self->priv->output_closed = TRUE;
	xmpp_xep_in_band_bytestreams_connection_set_state (self, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_DISCONNECTED);
	xmpp_xep_in_band_bytestreams_connection_trigger_read_callback (self);
}

static GInputStream*
xmpp_xep_in_band_bytestreams_connection_real_get_input_stream (GIOStream* base)
{
	GInputStream* result;
	XmppXepInBandBytestreamsConnection* self;
	XmppXepInBandBytestreamsConnectionInput* _tmp0_;
	self = (XmppXepInBandBytestreamsConnection*) base;
	_tmp0_ = self->priv->input;
	result = (GInputStream*) _tmp0_;
	return result;
}

static GOutputStream*
xmpp_xep_in_band_bytestreams_connection_real_get_output_stream (GIOStream* base)
{
	GOutputStream* result;
	XmppXepInBandBytestreamsConnection* self;
	XmppXepInBandBytestreamsConnectionOutput* _tmp0_;
	self = (XmppXepInBandBytestreamsConnection*) base;
	_tmp0_ = self->priv->output;
	result = (GOutputStream*) _tmp0_;
	return result;
}

XmppXepInBandBytestreamsConnectionState
xmpp_xep_in_band_bytestreams_connection_get_state (XmppXepInBandBytestreamsConnection* self)
{
	XmppXepInBandBytestreamsConnectionState result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_state;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_set_state (XmppXepInBandBytestreamsConnection* self,
                                                   XmppXepInBandBytestreamsConnectionState value)
{
	XmppXepInBandBytestreamsConnectionState old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xep_in_band_bytestreams_connection_get_state (self);
	if (old_value != value) {
		self->priv->_state = value;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xep_in_band_bytestreams_connection_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_PROPERTY]);
	}
}

const gchar*
xmpp_xep_in_band_bytestreams_connection_get_sid (XmppXepInBandBytestreamsConnection* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_sid;
	result = _tmp0_;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_set_sid (XmppXepInBandBytestreamsConnection* self,
                                                 const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xep_in_band_bytestreams_connection_get_sid (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_sid);
		self->priv->_sid = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xep_in_band_bytestreams_connection_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_SID_PROPERTY]);
	}
}

static inline gpointer
xmpp_xep_in_band_bytestreams_connection_input_get_instance_private (XmppXepInBandBytestreamsConnectionInput* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepInBandBytestreamsConnectionInput_private_offset);
}

XmppXepInBandBytestreamsConnectionInput*
xmpp_xep_in_band_bytestreams_connection_input_construct (GType object_type,
                                                         XmppXepInBandBytestreamsConnection* connection)
{
	XmppXepInBandBytestreamsConnectionInput * self = NULL;
	g_return_val_if_fail (connection != NULL, NULL);
	self = (XmppXepInBandBytestreamsConnectionInput*) g_object_new (object_type, NULL);
	self->priv->connection = connection;
	return self;
}

XmppXepInBandBytestreamsConnectionInput*
xmpp_xep_in_band_bytestreams_connection_input_new (XmppXepInBandBytestreamsConnection* connection)
{
	return xmpp_xep_in_band_bytestreams_connection_input_construct (XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_TYPE_INPUT, connection);
}

static gssize
xmpp_xep_in_band_bytestreams_connection_input_real_read (GInputStream* base,
                                                         guint8* buffer,
                                                         gsize buffer_length1,
                                                         GCancellable* cancellable,
                                                         GError** error)
{
	XmppXepInBandBytestreamsConnectionInput * self;
	GError* _tmp0_;
	GError* _inner_error0_ = NULL;
	self = (XmppXepInBandBytestreamsConnectionInput*) base;
	_tmp0_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "can't do non-async reads on in-band bytestreams");
	_inner_error0_ = _tmp0_;
	if (_inner_error0_->domain == G_IO_ERROR) {
		gssize _tmp1_ = -1L;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	} else {
		gssize _tmp2_ = -1L;
		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 _tmp2_;
	}
}

static void
xmpp_xep_in_band_bytestreams_connection_input_real_read_async_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionInputReadAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionInputReadAsyncData, _data_);
}

static void
xmpp_xep_in_band_bytestreams_connection_input_real_read_async (GInputStream* base,
                                                               guint8* buffer,
                                                               gsize buffer_length1,
                                                               gint io_priority,
                                                               GCancellable* cancellable,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionInput * self;
	XmppXepInBandBytestreamsConnectionInputReadAsyncData* _data_;
	XmppXepInBandBytestreamsConnectionInput* _tmp0_;
	GCancellable* _tmp1_;
	self = (XmppXepInBandBytestreamsConnectionInput*) base;
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionInputReadAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_input_real_read_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->buffer = buffer;
	_data_->buffer_length1 = buffer_length1;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_input_real_read_async_co (_data_);
}

static gssize
xmpp_xep_in_band_bytestreams_connection_input_read_finish (GInputStream* base,
                                                           GAsyncResult* _res_,
                                                           GError** error)
{
	gssize result;
	XmppXepInBandBytestreamsConnectionInputReadAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gssize _tmp0_ = 0L;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_input_read_async_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionInputReadAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_in_band_bytestreams_connection_input_real_read_async_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_input_real_read_async_co (XmppXepInBandBytestreamsConnectionInputReadAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->connection;
	_data_->_state_ = 1;
	xmpp_xep_in_band_bytestreams_connection_read_async (_data_->_tmp1_, _data_->buffer, (gint) _data_->buffer_length1, _data_->io_priority, _data_->cancellable, xmpp_xep_in_band_bytestreams_connection_input_read_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = xmpp_xep_in_band_bytestreams_connection_read_finish (_data_->_tmp1_, _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_->result = _data_->_tmp0_;
	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 gboolean
xmpp_xep_in_band_bytestreams_connection_input_real_close (GInputStream* base,
                                                          GCancellable* cancellable,
                                                          GError** error)
{
	XmppXepInBandBytestreamsConnectionInput * self;
	GError* _tmp0_;
	GError* _inner_error0_ = NULL;
	self = (XmppXepInBandBytestreamsConnectionInput*) base;
	_tmp0_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "can't do non-async closes on in-band bytestreams");
	_inner_error0_ = _tmp0_;
	if (_inner_error0_->domain == G_IO_ERROR) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	} else {
		gboolean _tmp2_ = FALSE;
		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 _tmp2_;
	}
}

static void
xmpp_xep_in_band_bytestreams_connection_input_real_close_async_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionInputCloseAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionInputCloseAsyncData, _data_);
}

static void
xmpp_xep_in_band_bytestreams_connection_input_real_close_async (GInputStream* base,
                                                                gint io_priority,
                                                                GCancellable* cancellable,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionInput * self;
	XmppXepInBandBytestreamsConnectionInputCloseAsyncData* _data_;
	XmppXepInBandBytestreamsConnectionInput* _tmp0_;
	GCancellable* _tmp1_;
	self = (XmppXepInBandBytestreamsConnectionInput*) base;
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionInputCloseAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_input_real_close_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_input_real_close_async_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_input_close_finish (GInputStream* base,
                                                            GAsyncResult* _res_,
                                                            GError** error)
{
	gboolean result;
	XmppXepInBandBytestreamsConnectionInputCloseAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_input_close_async_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionInputCloseAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_in_band_bytestreams_connection_input_real_close_async_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_input_real_close_async_co (XmppXepInBandBytestreamsConnectionInputCloseAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->connection;
	_data_->_state_ = 1;
	xmpp_xep_in_band_bytestreams_connection_close_read_async (_data_->_tmp1_, _data_->io_priority, _data_->cancellable, xmpp_xep_in_band_bytestreams_connection_input_close_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = xmpp_xep_in_band_bytestreams_connection_close_read_finish (_data_->_tmp1_, _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_->result = _data_->_tmp0_;
	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_xep_in_band_bytestreams_connection_input_class_init (XmppXepInBandBytestreamsConnectionInputClass * klass,
                                                          gpointer klass_data)
{
	xmpp_xep_in_band_bytestreams_connection_input_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXepInBandBytestreamsConnectionInput_private_offset);
	((GInputStreamClass *) klass)->read_fn = (gssize (*) (GInputStream*, guint8*, gsize, GCancellable*, GError**)) xmpp_xep_in_band_bytestreams_connection_input_real_read;
	((GInputStreamClass *) klass)->read_async = (void (*) (GInputStream*, guint8*, gsize, gint, GCancellable*, GAsyncReadyCallback, gpointer)) xmpp_xep_in_band_bytestreams_connection_input_real_read_async;
	((GInputStreamClass *) klass)->read_finish = (gssize (*) (GInputStream*, GAsyncResult*, GError**)) xmpp_xep_in_band_bytestreams_connection_input_read_finish;
	((GInputStreamClass *) klass)->close_fn = (gboolean (*) (GInputStream*, GCancellable*, GError**)) xmpp_xep_in_band_bytestreams_connection_input_real_close;
	((GInputStreamClass *) klass)->close_async = (void (*) (GInputStream*, gint, GCancellable*, GAsyncReadyCallback, gpointer)) xmpp_xep_in_band_bytestreams_connection_input_real_close_async;
	((GInputStreamClass *) klass)->close_finish = (gboolean (*) (GInputStream*, GAsyncResult*, GError**)) xmpp_xep_in_band_bytestreams_connection_input_close_finish;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_in_band_bytestreams_connection_input_finalize;
}

static void
xmpp_xep_in_band_bytestreams_connection_input_instance_init (XmppXepInBandBytestreamsConnectionInput * self,
                                                             gpointer klass)
{
	self->priv = xmpp_xep_in_band_bytestreams_connection_input_get_instance_private (self);
}

static void
xmpp_xep_in_band_bytestreams_connection_input_finalize (GObject * obj)
{
	XmppXepInBandBytestreamsConnectionInput * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_TYPE_INPUT, XmppXepInBandBytestreamsConnectionInput);
	G_OBJECT_CLASS (xmpp_xep_in_band_bytestreams_connection_input_parent_class)->finalize (obj);
}

static GType
xmpp_xep_in_band_bytestreams_connection_input_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepInBandBytestreamsConnectionInputClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_in_band_bytestreams_connection_input_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepInBandBytestreamsConnectionInput), 0, (GInstanceInitFunc) xmpp_xep_in_band_bytestreams_connection_input_instance_init, NULL };
	GType xmpp_xep_in_band_bytestreams_connection_input_type_id;
	xmpp_xep_in_band_bytestreams_connection_input_type_id = g_type_register_static (g_input_stream_get_type (), "XmppXepInBandBytestreamsConnectionInput", &g_define_type_info, 0);
	XmppXepInBandBytestreamsConnectionInput_private_offset = g_type_add_instance_private (xmpp_xep_in_band_bytestreams_connection_input_type_id, sizeof (XmppXepInBandBytestreamsConnectionInputPrivate));
	return xmpp_xep_in_band_bytestreams_connection_input_type_id;
}

GType
xmpp_xep_in_band_bytestreams_connection_input_get_type (void)
{
	static volatile gsize xmpp_xep_in_band_bytestreams_connection_input_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_in_band_bytestreams_connection_input_type_id__once)) {
		GType xmpp_xep_in_band_bytestreams_connection_input_type_id;
		xmpp_xep_in_band_bytestreams_connection_input_type_id = xmpp_xep_in_band_bytestreams_connection_input_get_type_once ();
		g_once_init_leave (&xmpp_xep_in_band_bytestreams_connection_input_type_id__once, xmpp_xep_in_band_bytestreams_connection_input_type_id);
	}
	return xmpp_xep_in_band_bytestreams_connection_input_type_id__once;
}

static inline gpointer
xmpp_xep_in_band_bytestreams_connection_output_get_instance_private (XmppXepInBandBytestreamsConnectionOutput* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepInBandBytestreamsConnectionOutput_private_offset);
}

XmppXepInBandBytestreamsConnectionOutput*
xmpp_xep_in_band_bytestreams_connection_output_construct (GType object_type,
                                                          XmppXepInBandBytestreamsConnection* connection)
{
	XmppXepInBandBytestreamsConnectionOutput * self = NULL;
	g_return_val_if_fail (connection != NULL, NULL);
	self = (XmppXepInBandBytestreamsConnectionOutput*) g_object_new (object_type, NULL);
	self->priv->connection = connection;
	return self;
}

XmppXepInBandBytestreamsConnectionOutput*
xmpp_xep_in_band_bytestreams_connection_output_new (XmppXepInBandBytestreamsConnection* connection)
{
	return xmpp_xep_in_band_bytestreams_connection_output_construct (XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_TYPE_OUTPUT, connection);
}

static gssize
xmpp_xep_in_band_bytestreams_connection_output_real_write (GOutputStream* base,
                                                           guint8* buffer,
                                                           gsize buffer_length1,
                                                           GCancellable* cancellable,
                                                           GError** error)
{
	XmppXepInBandBytestreamsConnectionOutput * self;
	GError* _tmp0_;
	GError* _inner_error0_ = NULL;
	self = (XmppXepInBandBytestreamsConnectionOutput*) base;
	_tmp0_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "can't do non-async writes on in-band bytestreams");
	_inner_error0_ = _tmp0_;
	if (_inner_error0_->domain == G_IO_ERROR) {
		gssize _tmp1_ = -1L;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	} else {
		gssize _tmp2_ = -1L;
		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 _tmp2_;
	}
}

static void
xmpp_xep_in_band_bytestreams_connection_output_real_write_async_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionOutputWriteAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionOutputWriteAsyncData, _data_);
}

static void
xmpp_xep_in_band_bytestreams_connection_output_real_write_async (GOutputStream* base,
                                                                 guint8* buffer,
                                                                 gsize buffer_length1,
                                                                 gint io_priority,
                                                                 GCancellable* cancellable,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionOutput * self;
	XmppXepInBandBytestreamsConnectionOutputWriteAsyncData* _data_;
	XmppXepInBandBytestreamsConnectionOutput* _tmp0_;
	GCancellable* _tmp1_;
	self = (XmppXepInBandBytestreamsConnectionOutput*) base;
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionOutputWriteAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_output_real_write_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->buffer = buffer;
	_data_->buffer_length1 = buffer_length1;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_output_real_write_async_co (_data_);
}

static gssize
xmpp_xep_in_band_bytestreams_connection_output_write_finish (GOutputStream* base,
                                                             GAsyncResult* _res_,
                                                             GError** error)
{
	gssize result;
	XmppXepInBandBytestreamsConnectionOutputWriteAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gssize _tmp0_ = 0L;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_output_write_async_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionOutputWriteAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_in_band_bytestreams_connection_output_real_write_async_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_output_real_write_async_co (XmppXepInBandBytestreamsConnectionOutputWriteAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->connection;
	_data_->_state_ = 1;
	xmpp_xep_in_band_bytestreams_connection_write_async (_data_->_tmp1_, _data_->buffer, (gint) _data_->buffer_length1, _data_->io_priority, _data_->cancellable, xmpp_xep_in_band_bytestreams_connection_output_write_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = xmpp_xep_in_band_bytestreams_connection_write_finish (_data_->_tmp1_, _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_->result = _data_->_tmp0_;
	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 gboolean
xmpp_xep_in_band_bytestreams_connection_output_real_close (GOutputStream* base,
                                                           GCancellable* cancellable,
                                                           GError** error)
{
	XmppXepInBandBytestreamsConnectionOutput * self;
	GError* _tmp0_;
	GError* _inner_error0_ = NULL;
	self = (XmppXepInBandBytestreamsConnectionOutput*) base;
	_tmp0_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, "can't do non-async closes on in-band bytestreams");
	_inner_error0_ = _tmp0_;
	if (_inner_error0_->domain == G_IO_ERROR) {
		gboolean _tmp1_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	} else {
		gboolean _tmp2_ = FALSE;
		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 _tmp2_;
	}
}

static void
xmpp_xep_in_band_bytestreams_connection_output_real_close_async_data_free (gpointer _data)
{
	XmppXepInBandBytestreamsConnectionOutputCloseAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (XmppXepInBandBytestreamsConnectionOutputCloseAsyncData, _data_);
}

static void
xmpp_xep_in_band_bytestreams_connection_output_real_close_async (GOutputStream* base,
                                                                 gint io_priority,
                                                                 GCancellable* cancellable,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionOutput * self;
	XmppXepInBandBytestreamsConnectionOutputCloseAsyncData* _data_;
	XmppXepInBandBytestreamsConnectionOutput* _tmp0_;
	GCancellable* _tmp1_;
	self = (XmppXepInBandBytestreamsConnectionOutput*) base;
	_data_ = g_slice_new0 (XmppXepInBandBytestreamsConnectionOutputCloseAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_xep_in_band_bytestreams_connection_output_real_close_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_xep_in_band_bytestreams_connection_output_real_close_async_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_output_close_finish (GOutputStream* base,
                                                             GAsyncResult* _res_,
                                                             GError** error)
{
	gboolean result;
	XmppXepInBandBytestreamsConnectionOutputCloseAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
xmpp_xep_in_band_bytestreams_connection_output_close_async_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_)
{
	XmppXepInBandBytestreamsConnectionOutputCloseAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_xep_in_band_bytestreams_connection_output_real_close_async_co (_data_);
}

static gboolean
xmpp_xep_in_band_bytestreams_connection_output_real_close_async_co (XmppXepInBandBytestreamsConnectionOutputCloseAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->connection;
	_data_->_state_ = 1;
	xmpp_xep_in_band_bytestreams_connection_close_write_async (_data_->_tmp1_, _data_->io_priority, _data_->cancellable, xmpp_xep_in_band_bytestreams_connection_output_close_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = xmpp_xep_in_band_bytestreams_connection_close_write_finish (_data_->_tmp1_, _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_->result = _data_->_tmp0_;
	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_xep_in_band_bytestreams_connection_output_class_init (XmppXepInBandBytestreamsConnectionOutputClass * klass,
                                                           gpointer klass_data)
{
	xmpp_xep_in_band_bytestreams_connection_output_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXepInBandBytestreamsConnectionOutput_private_offset);
	((GOutputStreamClass *) klass)->write_fn = (gssize (*) (GOutputStream*, guint8*, gsize, GCancellable*, GError**)) xmpp_xep_in_band_bytestreams_connection_output_real_write;
	((GOutputStreamClass *) klass)->write_async = (void (*) (GOutputStream*, guint8*, gsize, gint, GCancellable*, GAsyncReadyCallback, gpointer)) xmpp_xep_in_band_bytestreams_connection_output_real_write_async;
	((GOutputStreamClass *) klass)->write_finish = (gssize (*) (GOutputStream*, GAsyncResult*, GError**)) xmpp_xep_in_band_bytestreams_connection_output_write_finish;
	((GOutputStreamClass *) klass)->close_fn = (gboolean (*) (GOutputStream*, GCancellable*, GError**)) xmpp_xep_in_band_bytestreams_connection_output_real_close;
	((GOutputStreamClass *) klass)->close_async = (void (*) (GOutputStream*, gint, GCancellable*, GAsyncReadyCallback, gpointer)) xmpp_xep_in_band_bytestreams_connection_output_real_close_async;
	((GOutputStreamClass *) klass)->close_finish = (gboolean (*) (GOutputStream*, GAsyncResult*, GError**)) xmpp_xep_in_band_bytestreams_connection_output_close_finish;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_in_band_bytestreams_connection_output_finalize;
}

static void
xmpp_xep_in_band_bytestreams_connection_output_instance_init (XmppXepInBandBytestreamsConnectionOutput * self,
                                                              gpointer klass)
{
	self->priv = xmpp_xep_in_band_bytestreams_connection_output_get_instance_private (self);
}

static void
xmpp_xep_in_band_bytestreams_connection_output_finalize (GObject * obj)
{
	XmppXepInBandBytestreamsConnectionOutput * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_TYPE_OUTPUT, XmppXepInBandBytestreamsConnectionOutput);
	G_OBJECT_CLASS (xmpp_xep_in_band_bytestreams_connection_output_parent_class)->finalize (obj);
}

static GType
xmpp_xep_in_band_bytestreams_connection_output_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepInBandBytestreamsConnectionOutputClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_in_band_bytestreams_connection_output_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepInBandBytestreamsConnectionOutput), 0, (GInstanceInitFunc) xmpp_xep_in_band_bytestreams_connection_output_instance_init, NULL };
	GType xmpp_xep_in_band_bytestreams_connection_output_type_id;
	xmpp_xep_in_band_bytestreams_connection_output_type_id = g_type_register_static (g_output_stream_get_type (), "XmppXepInBandBytestreamsConnectionOutput", &g_define_type_info, 0);
	XmppXepInBandBytestreamsConnectionOutput_private_offset = g_type_add_instance_private (xmpp_xep_in_band_bytestreams_connection_output_type_id, sizeof (XmppXepInBandBytestreamsConnectionOutputPrivate));
	return xmpp_xep_in_band_bytestreams_connection_output_type_id;
}

GType
xmpp_xep_in_band_bytestreams_connection_output_get_type (void)
{
	static volatile gsize xmpp_xep_in_band_bytestreams_connection_output_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_in_band_bytestreams_connection_output_type_id__once)) {
		GType xmpp_xep_in_band_bytestreams_connection_output_type_id;
		xmpp_xep_in_band_bytestreams_connection_output_type_id = xmpp_xep_in_band_bytestreams_connection_output_get_type_once ();
		g_once_init_leave (&xmpp_xep_in_band_bytestreams_connection_output_type_id__once, xmpp_xep_in_band_bytestreams_connection_output_type_id);
	}
	return xmpp_xep_in_band_bytestreams_connection_output_type_id__once;
}

static void
xmpp_xep_in_band_bytestreams_connection_class_init (XmppXepInBandBytestreamsConnectionClass * klass,
                                                    gpointer klass_data)
{
	xmpp_xep_in_band_bytestreams_connection_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXepInBandBytestreamsConnection_private_offset);
	G_IO_STREAM_CLASS (klass)->get_input_stream = (GInputStream* (*) (GIOStream*)) xmpp_xep_in_band_bytestreams_connection_real_get_input_stream;
	G_IO_STREAM_CLASS (klass)->get_output_stream = (GOutputStream* (*) (GIOStream*)) xmpp_xep_in_band_bytestreams_connection_real_get_output_stream;
	G_OBJECT_CLASS (klass)->get_property = _vala_xmpp_xep_in_band_bytestreams_connection_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_xmpp_xep_in_band_bytestreams_connection_set_property;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_in_band_bytestreams_connection_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_INPUT_STREAM_PROPERTY, xmpp_xep_in_band_bytestreams_connection_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_INPUT_STREAM_PROPERTY] = g_param_spec_object ("input-stream", "input-stream", "input-stream", g_input_stream_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_OUTPUT_STREAM_PROPERTY, xmpp_xep_in_band_bytestreams_connection_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_OUTPUT_STREAM_PROPERTY] = g_param_spec_object ("output-stream", "output-stream", "output-stream", g_output_stream_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_PROPERTY, xmpp_xep_in_band_bytestreams_connection_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_PROPERTY] = g_param_spec_enum ("state", "state", "state", XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_TYPE_STATE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_SID_PROPERTY, xmpp_xep_in_band_bytestreams_connection_properties[XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_SID_PROPERTY] = g_param_spec_string ("sid", "sid", "sid", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
xmpp_xep_in_band_bytestreams_connection_instance_init (XmppXepInBandBytestreamsConnection * self,
                                                       gpointer klass)
{
	GeeLinkedList* _tmp0_;
	self->priv = xmpp_xep_in_band_bytestreams_connection_get_instance_private (self);
	self->priv->local_seq = 0;
	self->priv->remote_ack = 0;
	self->remote_seq = 0;
	self->priv->input_closed = FALSE;
	self->priv->output_closed = FALSE;
	self->priv->error = NULL;
	self->priv->read_callback_cancellable = NULL;
	self->priv->read_callback = NULL;
	self->priv->read_callback_target = NULL;
	self->priv->read_callback_target_destroy_notify = NULL;
	self->priv->write_callback = NULL;
	self->priv->write_callback_target = NULL;
	self->priv->write_callback_target_destroy_notify = NULL;
	self->priv->write_callback_cancellable = NULL;
	_tmp0_ = gee_linked_list_new (G_TYPE_BYTES, (GBoxedCopyFunc) g_bytes_ref, (GDestroyNotify) g_bytes_unref, NULL, NULL, NULL);
	self->priv->received = _tmp0_;
}

static void
xmpp_xep_in_band_bytestreams_connection_finalize (GObject * obj)
{
	XmppXepInBandBytestreamsConnection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_CONNECTION, XmppXepInBandBytestreamsConnection);
	_g_object_unref0 (self->priv->input);
	_g_object_unref0 (self->priv->output);
	_xmpp_jid_unref0 (self->priv->receiver_full_jid);
	_g_free0 (self->priv->_sid);
	_g_free0 (self->priv->error);
	_g_object_unref0 (self->priv->stream);
	_g_object_unref0 (self->priv->read_callback_cancellable);
	(self->priv->read_callback_target_destroy_notify == NULL) ? NULL : (self->priv->read_callback_target_destroy_notify (self->priv->read_callback_target), NULL);
	self->priv->read_callback = NULL;
	self->priv->read_callback_target = NULL;
	self->priv->read_callback_target_destroy_notify = NULL;
	(self->priv->write_callback_target_destroy_notify == NULL) ? NULL : (self->priv->write_callback_target_destroy_notify (self->priv->write_callback_target), NULL);
	self->priv->write_callback = NULL;
	self->priv->write_callback_target = NULL;
	self->priv->write_callback_target_destroy_notify = NULL;
	_g_object_unref0 (self->priv->write_callback_cancellable);
	_g_object_unref0 (self->priv->received);
	G_OBJECT_CLASS (xmpp_xep_in_band_bytestreams_connection_parent_class)->finalize (obj);
}

static GType
xmpp_xep_in_band_bytestreams_connection_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepInBandBytestreamsConnectionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_in_band_bytestreams_connection_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepInBandBytestreamsConnection), 0, (GInstanceInitFunc) xmpp_xep_in_band_bytestreams_connection_instance_init, NULL };
	GType xmpp_xep_in_band_bytestreams_connection_type_id;
	xmpp_xep_in_band_bytestreams_connection_type_id = g_type_register_static (g_io_stream_get_type (), "XmppXepInBandBytestreamsConnection", &g_define_type_info, 0);
	XmppXepInBandBytestreamsConnection_private_offset = g_type_add_instance_private (xmpp_xep_in_band_bytestreams_connection_type_id, sizeof (XmppXepInBandBytestreamsConnectionPrivate));
	return xmpp_xep_in_band_bytestreams_connection_type_id;
}

GType
xmpp_xep_in_band_bytestreams_connection_get_type (void)
{
	static volatile gsize xmpp_xep_in_band_bytestreams_connection_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_in_band_bytestreams_connection_type_id__once)) {
		GType xmpp_xep_in_band_bytestreams_connection_type_id;
		xmpp_xep_in_band_bytestreams_connection_type_id = xmpp_xep_in_band_bytestreams_connection_get_type_once ();
		g_once_init_leave (&xmpp_xep_in_band_bytestreams_connection_type_id__once, xmpp_xep_in_band_bytestreams_connection_type_id);
	}
	return xmpp_xep_in_band_bytestreams_connection_type_id__once;
}

static void
_vala_xmpp_xep_in_band_bytestreams_connection_get_property (GObject * object,
                                                            guint property_id,
                                                            GValue * value,
                                                            GParamSpec * pspec)
{
	XmppXepInBandBytestreamsConnection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_CONNECTION, XmppXepInBandBytestreamsConnection);
	switch (property_id) {
		case XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_INPUT_STREAM_PROPERTY:
		g_value_set_object (value, g_io_stream_get_input_stream ((GIOStream*) self));
		break;
		case XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_OUTPUT_STREAM_PROPERTY:
		g_value_set_object (value, g_io_stream_get_output_stream ((GIOStream*) self));
		break;
		case XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_PROPERTY:
		g_value_set_enum (value, xmpp_xep_in_band_bytestreams_connection_get_state (self));
		break;
		case XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_SID_PROPERTY:
		g_value_set_string (value, xmpp_xep_in_band_bytestreams_connection_get_sid (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_xmpp_xep_in_band_bytestreams_connection_set_property (GObject * object,
                                                            guint property_id,
                                                            const GValue * value,
                                                            GParamSpec * pspec)
{
	XmppXepInBandBytestreamsConnection * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_CONNECTION, XmppXepInBandBytestreamsConnection);
	switch (property_id) {
		case XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_STATE_PROPERTY:
		xmpp_xep_in_band_bytestreams_connection_set_state (self, g_value_get_enum (value));
		break;
		case XMPP_XEP_IN_BAND_BYTESTREAMS_CONNECTION_SID_PROPERTY:
		xmpp_xep_in_band_bytestreams_connection_set_sid (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
xmpp_xep_in_band_bytestreams_flag_get_instance_private (XmppXepInBandBytestreamsFlag* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepInBandBytestreamsFlag_private_offset);
}

void
xmpp_xep_in_band_bytestreams_flag_add_connection (XmppXepInBandBytestreamsFlag* self,
                                                  XmppXepInBandBytestreamsConnection* conn)
{
	GeeHashMap* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conn != NULL);
	_tmp0_ = self->priv->active;
	_tmp1_ = xmpp_xep_in_band_bytestreams_connection_get_sid (conn);
	_tmp2_ = _tmp1_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp0_, _tmp2_, conn);
}

XmppXepInBandBytestreamsConnection*
xmpp_xep_in_band_bytestreams_flag_get_connection (XmppXepInBandBytestreamsFlag* self,
                                                  const gchar* sid)
{
	XmppXepInBandBytestreamsConnection* _tmp0_ = NULL;
	GeeHashMap* _tmp1_;
	XmppXepInBandBytestreamsConnection* _tmp4_;
	XmppXepInBandBytestreamsConnection* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (sid != NULL, NULL);
	_tmp1_ = self->priv->active;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp1_, sid)) {
		GeeHashMap* _tmp2_;
		gpointer _tmp3_;
		_tmp2_ = self->priv->active;
		_tmp3_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp2_, sid);
		_g_object_unref0 (_tmp0_);
		_tmp0_ = (XmppXepInBandBytestreamsConnection*) _tmp3_;
	} else {
		_g_object_unref0 (_tmp0_);
		_tmp0_ = NULL;
	}
	_tmp4_ = _tmp0_;
	_tmp0_ = NULL;
	result = _tmp4_;
	_g_object_unref0 (_tmp0_);
	return result;
}

void
xmpp_xep_in_band_bytestreams_flag_remove_connection (XmppXepInBandBytestreamsFlag* self,
                                                     XmppXepInBandBytestreamsConnection* conn)
{
	GeeHashMap* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conn != NULL);
	_tmp0_ = self->priv->active;
	_tmp1_ = xmpp_xep_in_band_bytestreams_connection_get_sid (conn);
	_tmp2_ = _tmp1_;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, _tmp2_, NULL);
}

static gchar*
xmpp_xep_in_band_bytestreams_flag_real_get_ns (XmppXmppStreamFlag* base)
{
	XmppXepInBandBytestreamsFlag * self;
	gchar* _tmp0_;
	gchar* result;
	self = (XmppXepInBandBytestreamsFlag*) base;
	_tmp0_ = g_strdup (XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI);
	result = _tmp0_;
	return result;
}

static gchar*
xmpp_xep_in_band_bytestreams_flag_real_get_id (XmppXmppStreamFlag* base)
{
	XmppXepInBandBytestreamsFlag * self;
	XmppFlagIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (XmppXepInBandBytestreamsFlag*) base;
	_tmp0_ = xmpp_xep_in_band_bytestreams_flag_IDENTITY;
	_tmp1_ = xmpp_flag_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

XmppXepInBandBytestreamsFlag*
xmpp_xep_in_band_bytestreams_flag_construct (GType object_type)
{
	XmppXepInBandBytestreamsFlag * self = NULL;
	self = (XmppXepInBandBytestreamsFlag*) xmpp_xmpp_stream_flag_construct (object_type);
	return self;
}

XmppXepInBandBytestreamsFlag*
xmpp_xep_in_band_bytestreams_flag_new (void)
{
	return xmpp_xep_in_band_bytestreams_flag_construct (XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG);
}

static void
xmpp_xep_in_band_bytestreams_flag_class_init (XmppXepInBandBytestreamsFlagClass * klass,
                                              gpointer klass_data)
{
	XmppFlagIdentity* _tmp0_;
	xmpp_xep_in_band_bytestreams_flag_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXepInBandBytestreamsFlag_private_offset);
	((XmppXmppStreamFlagClass *) klass)->get_ns = (gchar* (*) (XmppXmppStreamFlag*)) xmpp_xep_in_band_bytestreams_flag_real_get_ns;
	((XmppXmppStreamFlagClass *) klass)->get_id = (gchar* (*) (XmppXmppStreamFlag*)) xmpp_xep_in_band_bytestreams_flag_real_get_id;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_in_band_bytestreams_flag_finalize;
	_tmp0_ = xmpp_flag_identity_new (XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, XMPP_XEP_IN_BAND_BYTESTREAMS_NS_URI, "in_band_bytestreams");
	xmpp_xep_in_band_bytestreams_flag_IDENTITY = _tmp0_;
}

static void
xmpp_xep_in_band_bytestreams_flag_instance_init (XmppXepInBandBytestreamsFlag * self,
                                                 gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = xmpp_xep_in_band_bytestreams_flag_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_CONNECTION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->active = _tmp0_;
}

static void
xmpp_xep_in_band_bytestreams_flag_finalize (GObject * obj)
{
	XmppXepInBandBytestreamsFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_IN_BAND_BYTESTREAMS_TYPE_FLAG, XmppXepInBandBytestreamsFlag);
	_g_object_unref0 (self->priv->active);
	G_OBJECT_CLASS (xmpp_xep_in_band_bytestreams_flag_parent_class)->finalize (obj);
}

static GType
xmpp_xep_in_band_bytestreams_flag_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepInBandBytestreamsFlagClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_in_band_bytestreams_flag_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepInBandBytestreamsFlag), 0, (GInstanceInitFunc) xmpp_xep_in_band_bytestreams_flag_instance_init, NULL };
	GType xmpp_xep_in_band_bytestreams_flag_type_id;
	xmpp_xep_in_band_bytestreams_flag_type_id = g_type_register_static (XMPP_TYPE_XMPP_STREAM_FLAG, "XmppXepInBandBytestreamsFlag", &g_define_type_info, 0);
	XmppXepInBandBytestreamsFlag_private_offset = g_type_add_instance_private (xmpp_xep_in_band_bytestreams_flag_type_id, sizeof (XmppXepInBandBytestreamsFlagPrivate));
	return xmpp_xep_in_band_bytestreams_flag_type_id;
}

GType
xmpp_xep_in_band_bytestreams_flag_get_type (void)
{
	static volatile gsize xmpp_xep_in_band_bytestreams_flag_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_in_band_bytestreams_flag_type_id__once)) {
		GType xmpp_xep_in_band_bytestreams_flag_type_id;
		xmpp_xep_in_band_bytestreams_flag_type_id = xmpp_xep_in_band_bytestreams_flag_get_type_once ();
		g_once_init_leave (&xmpp_xep_in_band_bytestreams_flag_type_id__once, xmpp_xep_in_band_bytestreams_flag_type_id);
	}
	return xmpp_xep_in_band_bytestreams_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;
}

