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

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

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _g_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_stanza_writer_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_writer_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _XmppStanzaWriterWriteNodeData XmppStanzaWriterWriteNodeData;
typedef struct _XmppStanzaWriterWriteNodesData XmppStanzaWriterWriteNodesData;
typedef struct _XmppStanzaWriterWriteData XmppStanzaWriterWriteData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _XmppStanzaWriterWriteDataData XmppStanzaWriterWriteDataData;
typedef struct _XmppParamSpecStanzaWriter XmppParamSpecStanzaWriter;
enum  {
	XMPP_SOURCE_FUNC_WRAPPER_0_PROPERTY,
	XMPP_SOURCE_FUNC_WRAPPER_NUM_PROPERTIES
};
static GParamSpec* xmpp_source_func_wrapper_properties[XMPP_SOURCE_FUNC_WRAPPER_NUM_PROPERTIES];

struct _XmppStanzaWriterPrivate {
	GCancellable* connection_cancellable;
	GOutputStream* output;
	GQueue* queue;
	gboolean running;
};

struct _XmppStanzaWriterWriteNodeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppStanzaWriter* self;
	XmppStanzaNode* node;
	gint io_priority;
	GCancellable* cancellable;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	GCancellable* _tmp3_;
	guint8* _tmp4_;
	gint _tmp4__length1;
	gint _tmp5_;
	guint8* _tmp6_;
	gint _tmp6__length1;
	guint8* _tmp7_;
	gint _tmp7__length1;
	GError* _inner_error0_;
};

struct _XmppStanzaWriterWriteNodesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppStanzaWriter* self;
	XmppStanzaNode* node1;
	XmppStanzaNode* node2;
	gint io_priority;
	GCancellable* cancellable;
	gchar* _tmp0_;
	gchar* _tmp1_;
	guint8* data1;
	guint8* _tmp2_;
	gint _tmp2__length1;
	gint _tmp3_;
	guint8* _tmp4_;
	gint _tmp4__length1;
	guint8* _tmp5_;
	gint _tmp5__length1;
	gint data1_length1;
	gint _data1_size_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	guint8* data2;
	guint8* _tmp8_;
	gint _tmp8__length1;
	gint _tmp9_;
	guint8* _tmp10_;
	gint _tmp10__length1;
	guint8* _tmp11_;
	gint _tmp11__length1;
	gint data2_length1;
	gint _data2_size_;
	guint8* concat;
	guint8* _tmp12_;
	gint _tmp12__length1;
	guint8* _tmp13_;
	gint _tmp13__length1;
	guint8* _tmp14_;
	gint concat_length1;
	gint _concat_size_;
	gint i;
	guint8* _tmp15_;
	gint _tmp15__length1;
	guint8* datum_collection;
	gint datum_collection_length1;
	gint _datum_collection_size_;
	gint datum_it;
	guint8 datum;
	guint8* _tmp16_;
	gint _tmp16__length1;
	gint _tmp17_;
	guint8 _tmp18_;
	guint8* _tmp19_;
	gint _tmp19__length1;
	guint8* _vala1_datum_collection;
	gint _vala1_datum_collection_length1;
	gint __vala1_datum_collection_size_;
	gint _vala1_datum_it;
	guint8 _vala1_datum;
	guint8* _tmp20_;
	gint _tmp20__length1;
	gint _tmp21_;
	guint8 _tmp22_;
	GCancellable* _tmp23_;
	GCancellable* _tmp24_;
	guint8* _tmp25_;
	gint _tmp25__length1;
	guint8* _tmp26_;
	gint _tmp26__length1;
	GError* _inner_error0_;
};

struct _XmppStanzaWriterWriteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppStanzaWriter* self;
	gchar* s;
	gint io_priority;
	GCancellable* cancellable;
	GCancellable* _tmp0_;
	GCancellable* _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	gint _tmp3_;
	guint8* _tmp4_;
	gint _tmp4__length1;
	guint8* _tmp5_;
	gint _tmp5__length1;
	GError* _inner_error0_;
};

struct _XmppStanzaWriterWriteDataData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	XmppStanzaWriter* self;
	guint8* data;
	gint data_length1;
	gint io_priority;
	GCancellable* cancellable;
	GQueue* _tmp0_;
	XmppSourceFuncWrapper* _tmp1_;
	GOutputStream* _tmp2_;
	GError* e;
	GError* _tmp3_;
	GCancellable* _tmp4_;
	GError* _tmp5_;
	GError* _tmp6_;
	GError* _vala1_e;
	GCancellable* _tmp7_;
	GError* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GError* _tmp12_;
	GError* _tmp13_;
	GError* _inner_error1_;
	XmppSourceFuncWrapper* sfw;
	GQueue* _tmp14_;
	gpointer _tmp15_;
	XmppSourceFuncWrapper* _tmp16_;
	XmppSourceFuncWrapper* _tmp17_;
	GSourceFunc _tmp18_;
	gpointer _tmp18__target;
	GError* _inner_error0_;
};

struct _XmppParamSpecStanzaWriter {
	GParamSpec parent_instance;
};

static gint XmppStanzaWriter_private_offset;
static gpointer xmpp_stanza_writer_parent_class = NULL;
static gpointer xmpp_source_func_wrapper_parent_class = NULL;

static void _g_object_unref0_ (gpointer var);
static inline void _g_queue_free__g_object_unref0_ (GQueue* self);
static void xmpp_stanza_writer_write_node_data_free (gpointer _data);
static gboolean xmpp_stanza_writer_write_node_co (XmppStanzaWriterWriteNodeData* _data_);
static void xmpp_stanza_writer_write_data (XmppStanzaWriter* self,
                                    guint8* data,
                                    gint data_length1,
                                    gint io_priority,
                                    GCancellable* cancellable,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void xmpp_stanza_writer_write_data_finish (XmppStanzaWriter* self,
                                           GAsyncResult* _res_,
                                           GError** error);
static guint8* _vala_array_dup2 (guint8* self,
                          gssize length);
static void xmpp_stanza_writer_write_node_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void xmpp_stanza_writer_write_nodes_data_free (gpointer _data);
static gboolean xmpp_stanza_writer_write_nodes_co (XmppStanzaWriterWriteNodesData* _data_);
static guint8* _vala_array_dup3 (guint8* self,
                          gssize length);
static guint8* _vala_array_dup4 (guint8* self,
                          gssize length);
static guint8* _vala_array_dup5 (guint8* self,
                          gssize length);
static void xmpp_stanza_writer_write_nodes_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static void xmpp_stanza_writer_write_data_free (gpointer _data);
static gboolean xmpp_stanza_writer_write_co (XmppStanzaWriterWriteData* _data_);
static guint8* _vala_array_dup6 (guint8* self,
                          gssize length);
static void xmpp_stanza_writer_write_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_);
static void xmpp_stanza_writer_write_data_data_free (gpointer _data);
static gboolean xmpp_stanza_writer_write_data_co (XmppStanzaWriterWriteDataData* _data_);
static gboolean _xmpp_stanza_writer_write_data_co_gsource_func (gpointer self);
static void xmpp_stanza_writer_write_data_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void xmpp_stanza_writer_finalize (XmppStanzaWriter * obj);
static GType xmpp_stanza_writer_get_type_once (void);
static void xmpp_source_func_wrapper_finalize (GObject * obj);
static GType xmpp_source_func_wrapper_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
xmpp_stanza_writer_get_instance_private (XmppStanzaWriter* self)
{
	return G_STRUCT_MEMBER_P (self, XmppStanzaWriter_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_queue_free__g_object_unref0_ (GQueue* self)
{
	g_queue_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

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

XmppStanzaWriter*
xmpp_stanza_writer_construct_for_stream (GType object_type,
                                         GOutputStream* output,
                                         GCancellable* cancellable)
{
	XmppStanzaWriter* self = NULL;
	GOutputStream* _tmp0_;
	GCancellable* _tmp1_;
	g_return_val_if_fail (output != NULL, NULL);
	self = (XmppStanzaWriter*) g_type_create_instance (object_type);
	_tmp0_ = _g_object_ref0 (output);
	_g_object_unref0 (self->priv->output);
	self->priv->output = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (self->priv->connection_cancellable);
	self->priv->connection_cancellable = _tmp1_;
	return self;
}

XmppStanzaWriter*
xmpp_stanza_writer_new_for_stream (GOutputStream* output,
                                   GCancellable* cancellable)
{
	return xmpp_stanza_writer_construct_for_stream (XMPP_TYPE_STANZA_WRITER, output, cancellable);
}

static void
xmpp_stanza_writer_write_node_data_free (gpointer _data)
{
	XmppStanzaWriterWriteNodeData* _data_;
	_data_ = _data;
	_xmpp_stanza_entry_unref0 (_data_->node);
	_g_object_unref0 (_data_->cancellable);
	_xmpp_stanza_writer_unref0 (_data_->self);
	g_slice_free (XmppStanzaWriterWriteNodeData, _data_);
}

static gpointer
_xmpp_stanza_writer_ref0 (gpointer self)
{
	return self ? xmpp_stanza_writer_ref (self) : NULL;
}

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

void
xmpp_stanza_writer_write_node (XmppStanzaWriter* self,
                               XmppStanzaNode* node,
                               gint io_priority,
                               GCancellable* cancellable,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	XmppStanzaWriterWriteNodeData* _data_;
	XmppStanzaWriter* _tmp0_;
	XmppStanzaNode* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node != NULL);
	_data_ = g_slice_new0 (XmppStanzaWriterWriteNodeData);
	_data_->_async_result = g_task_new (NULL, cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_stanza_writer_write_node_data_free);
	_tmp0_ = _xmpp_stanza_writer_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _xmpp_stanza_entry_ref0 (node);
	_xmpp_stanza_entry_unref0 (_data_->node);
	_data_->node = _tmp1_;
	_data_->io_priority = io_priority;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	xmpp_stanza_writer_write_node_co (_data_);
}

void
xmpp_stanza_writer_write_node_finish (XmppStanzaWriter* self,
                                      GAsyncResult* _res_,
                                      GError** error)
{
	XmppStanzaWriterWriteNodeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

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

static void
xmpp_stanza_writer_write_node_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	XmppStanzaWriterWriteNodeData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_stanza_writer_write_node_co (_data_);
}

static gboolean
xmpp_stanza_writer_write_node_co (XmppStanzaWriterWriteNodeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = xmpp_stanza_node_to_xml (_data_->node, NULL, &_data_->_inner_error0_);
	_data_->_tmp0_ = _data_->_tmp1_;
	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_->_tmp2_ = _data_->cancellable;
	if (_data_->_tmp2_ == NULL) {
		_data_->_tmp3_ = _data_->self->priv->connection_cancellable;
		_data_->_tmp2_ = _data_->_tmp3_;
	}
	_data_->_tmp5_ = 0;
	_data_->_tmp4_ = string_get_data (_data_->_tmp0_, &_data_->_tmp5_);
	_data_->_tmp4__length1 = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->_tmp4_;
	_data_->_tmp6__length1 = _data_->_tmp4__length1;
	_data_->_tmp7_ = (_data_->_tmp6_ != NULL) ? _vala_array_dup2 (_data_->_tmp6_, _data_->_tmp6__length1) : _data_->_tmp6_;
	_data_->_tmp7__length1 = _data_->_tmp6__length1;
	_data_->_state_ = 1;
	xmpp_stanza_writer_write_data (_data_->self, _data_->_tmp7_, (gint) _data_->_tmp7__length1, _data_->io_priority, _data_->_tmp2_, xmpp_stanza_writer_write_node_ready, _data_);
	return FALSE;
	_state_1:
	xmpp_stanza_writer_write_data_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_free0 (_data_->_tmp0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_g_free0 (_data_->_tmp0_);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_g_free0 (_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_stanza_writer_write_nodes_data_free (gpointer _data)
{
	XmppStanzaWriterWriteNodesData* _data_;
	_data_ = _data;
	_xmpp_stanza_entry_unref0 (_data_->node1);
	_xmpp_stanza_entry_unref0 (_data_->node2);
	_g_object_unref0 (_data_->cancellable);
	_xmpp_stanza_writer_unref0 (_data_->self);
	g_slice_free (XmppStanzaWriterWriteNodesData, _data_);
}

void
xmpp_stanza_writer_write_nodes (XmppStanzaWriter* self,
                                XmppStanzaNode* node1,
                                XmppStanzaNode* node2,
                                gint io_priority,
                                GCancellable* cancellable,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	XmppStanzaWriterWriteNodesData* _data_;
	XmppStanzaWriter* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (node1 != NULL);
	g_return_if_fail (node2 != NULL);
	_data_ = g_slice_new0 (XmppStanzaWriterWriteNodesData);
	_data_->_async_result = g_task_new (NULL, cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_stanza_writer_write_nodes_data_free);
	_tmp0_ = _xmpp_stanza_writer_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _xmpp_stanza_entry_ref0 (node1);
	_xmpp_stanza_entry_unref0 (_data_->node1);
	_data_->node1 = _tmp1_;
	_tmp2_ = _xmpp_stanza_entry_ref0 (node2);
	_xmpp_stanza_entry_unref0 (_data_->node2);
	_data_->node2 = _tmp2_;
	_data_->io_priority = io_priority;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp3_;
	xmpp_stanza_writer_write_nodes_co (_data_);
}

void
xmpp_stanza_writer_write_nodes_finish (XmppStanzaWriter* self,
                                       GAsyncResult* _res_,
                                       GError** error)
{
	XmppStanzaWriterWriteNodesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

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

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

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

static void
xmpp_stanza_writer_write_nodes_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	XmppStanzaWriterWriteNodesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_stanza_writer_write_nodes_co (_data_);
}

static gboolean
xmpp_stanza_writer_write_nodes_co (XmppStanzaWriterWriteNodesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = xmpp_stanza_node_to_xml (_data_->node1, NULL, &_data_->_inner_error0_);
	_data_->_tmp0_ = _data_->_tmp1_;
	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_->_tmp3_ = 0;
	_data_->_tmp2_ = string_get_data (_data_->_tmp0_, &_data_->_tmp3_);
	_data_->_tmp2__length1 = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->_tmp2_;
	_data_->_tmp4__length1 = _data_->_tmp2__length1;
	_data_->_tmp5_ = (_data_->_tmp4_ != NULL) ? _vala_array_dup3 (_data_->_tmp4_, _data_->_tmp4__length1) : _data_->_tmp4_;
	_data_->_tmp5__length1 = _data_->_tmp4__length1;
	_data_->data1 = _data_->_tmp5_;
	_data_->data1_length1 = _data_->_tmp5__length1;
	_data_->_data1_size_ = _data_->data1_length1;
	_data_->_tmp7_ = xmpp_stanza_node_to_xml (_data_->node2, NULL, &_data_->_inner_error0_);
	_data_->_tmp6_ = _data_->_tmp7_;
	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_);
			_data_->data1 = (g_free (_data_->data1), NULL);
			_g_free0 (_data_->_tmp0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_data_->data1 = (g_free (_data_->data1), NULL);
			_g_free0 (_data_->_tmp0_);
			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_->_tmp9_ = 0;
	_data_->_tmp8_ = string_get_data (_data_->_tmp6_, &_data_->_tmp9_);
	_data_->_tmp8__length1 = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->_tmp8_;
	_data_->_tmp10__length1 = _data_->_tmp8__length1;
	_data_->_tmp11_ = (_data_->_tmp10_ != NULL) ? _vala_array_dup4 (_data_->_tmp10_, _data_->_tmp10__length1) : _data_->_tmp10_;
	_data_->_tmp11__length1 = _data_->_tmp10__length1;
	_data_->data2 = _data_->_tmp11_;
	_data_->data2_length1 = _data_->_tmp11__length1;
	_data_->_data2_size_ = _data_->data2_length1;
	_data_->_tmp12_ = _data_->data1;
	_data_->_tmp12__length1 = _data_->data1_length1;
	_data_->_tmp13_ = _data_->data2;
	_data_->_tmp13__length1 = _data_->data2_length1;
	_data_->_tmp14_ = g_new0 (guint8, _data_->_tmp12__length1 + _data_->_tmp13__length1);
	_data_->concat = _data_->_tmp14_;
	_data_->concat_length1 = _data_->_tmp12__length1 + _data_->_tmp13__length1;
	_data_->_concat_size_ = _data_->concat_length1;
	_data_->i = 0;
	_data_->_tmp15_ = _data_->data1;
	_data_->_tmp15__length1 = _data_->data1_length1;
	{
		_data_->datum_collection_length1 = 0;
		_data_->_datum_collection_size_ = 0;
		_data_->datum_collection = _data_->_tmp15_;
		_data_->datum_collection_length1 = _data_->_tmp15__length1;
		for (_data_->datum_it = 0; _data_->datum_it < _data_->datum_collection_length1; _data_->datum_it = _data_->datum_it + 1) {
			_data_->datum = _data_->datum_collection[_data_->datum_it];
			{
				_data_->_tmp16_ = _data_->concat;
				_data_->_tmp16__length1 = _data_->concat_length1;
				_data_->_tmp17_ = _data_->i;
				_data_->i = _data_->_tmp17_ + 1;
				_data_->_tmp18_ = _data_->datum;
				_data_->_tmp16_[_data_->_tmp17_] = _data_->_tmp18_;
			}
		}
	}
	_data_->_tmp19_ = _data_->data2;
	_data_->_tmp19__length1 = _data_->data2_length1;
	{
		_data_->_vala1_datum_collection_length1 = 0;
		_data_->__vala1_datum_collection_size_ = 0;
		_data_->_vala1_datum_collection = _data_->_tmp19_;
		_data_->_vala1_datum_collection_length1 = _data_->_tmp19__length1;
		for (_data_->_vala1_datum_it = 0; _data_->_vala1_datum_it < _data_->_vala1_datum_collection_length1; _data_->_vala1_datum_it = _data_->_vala1_datum_it + 1) {
			_data_->_vala1_datum = _data_->_vala1_datum_collection[_data_->_vala1_datum_it];
			{
				_data_->_tmp20_ = _data_->concat;
				_data_->_tmp20__length1 = _data_->concat_length1;
				_data_->_tmp21_ = _data_->i;
				_data_->i = _data_->_tmp21_ + 1;
				_data_->_tmp22_ = _data_->_vala1_datum;
				_data_->_tmp20_[_data_->_tmp21_] = _data_->_tmp22_;
			}
		}
	}
	_data_->_tmp23_ = _data_->cancellable;
	if (_data_->_tmp23_ == NULL) {
		_data_->_tmp24_ = _data_->self->priv->connection_cancellable;
		_data_->_tmp23_ = _data_->_tmp24_;
	}
	_data_->_tmp25_ = _data_->concat;
	_data_->_tmp25__length1 = _data_->concat_length1;
	_data_->_tmp26_ = (_data_->_tmp25_ != NULL) ? _vala_array_dup5 (_data_->_tmp25_, _data_->_tmp25__length1) : _data_->_tmp25_;
	_data_->_tmp26__length1 = _data_->_tmp25__length1;
	_data_->_state_ = 1;
	xmpp_stanza_writer_write_data (_data_->self, _data_->_tmp26_, (gint) _data_->_tmp26__length1, _data_->io_priority, _data_->_tmp23_, xmpp_stanza_writer_write_nodes_ready, _data_);
	return FALSE;
	_state_1:
	xmpp_stanza_writer_write_data_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_);
			_data_->concat = (g_free (_data_->concat), NULL);
			_data_->data2 = (g_free (_data_->data2), NULL);
			_g_free0 (_data_->_tmp6_);
			_data_->data1 = (g_free (_data_->data1), NULL);
			_g_free0 (_data_->_tmp0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_data_->concat = (g_free (_data_->concat), NULL);
			_data_->data2 = (g_free (_data_->data2), NULL);
			_g_free0 (_data_->_tmp6_);
			_data_->data1 = (g_free (_data_->data1), NULL);
			_g_free0 (_data_->_tmp0_);
			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_->concat = (g_free (_data_->concat), NULL);
	_data_->data2 = (g_free (_data_->data2), NULL);
	_g_free0 (_data_->_tmp6_);
	_data_->data1 = (g_free (_data_->data1), NULL);
	_g_free0 (_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_stanza_writer_write_data_free (gpointer _data)
{
	XmppStanzaWriterWriteData* _data_;
	_data_ = _data;
	_g_free0 (_data_->s);
	_g_object_unref0 (_data_->cancellable);
	_xmpp_stanza_writer_unref0 (_data_->self);
	g_slice_free (XmppStanzaWriterWriteData, _data_);
}

void
xmpp_stanza_writer_write (XmppStanzaWriter* self,
                          const gchar* s,
                          gint io_priority,
                          GCancellable* cancellable,
                          GAsyncReadyCallback _callback_,
                          gpointer _user_data_)
{
	XmppStanzaWriterWriteData* _data_;
	XmppStanzaWriter* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (s != NULL);
	_data_ = g_slice_new0 (XmppStanzaWriterWriteData);
	_data_->_async_result = g_task_new (NULL, cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_stanza_writer_write_data_free);
	_tmp0_ = _xmpp_stanza_writer_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (s);
	_g_free0 (_data_->s);
	_data_->s = _tmp1_;
	_data_->io_priority = io_priority;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	xmpp_stanza_writer_write_co (_data_);
}

void
xmpp_stanza_writer_write_finish (XmppStanzaWriter* self,
                                 GAsyncResult* _res_,
                                 GError** error)
{
	XmppStanzaWriterWriteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

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

static void
xmpp_stanza_writer_write_ready (GObject* source_object,
                                GAsyncResult* _res_,
                                gpointer _user_data_)
{
	XmppStanzaWriterWriteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_stanza_writer_write_co (_data_);
}

static gboolean
xmpp_stanza_writer_write_co (XmppStanzaWriterWriteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->cancellable;
	if (_data_->_tmp0_ == NULL) {
		_data_->_tmp1_ = _data_->self->priv->connection_cancellable;
		_data_->_tmp0_ = _data_->_tmp1_;
	}
	_data_->_tmp3_ = 0;
	_data_->_tmp2_ = string_get_data (_data_->s, &_data_->_tmp3_);
	_data_->_tmp2__length1 = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->_tmp2_;
	_data_->_tmp4__length1 = _data_->_tmp2__length1;
	_data_->_tmp5_ = (_data_->_tmp4_ != NULL) ? _vala_array_dup6 (_data_->_tmp4_, _data_->_tmp4__length1) : _data_->_tmp4_;
	_data_->_tmp5__length1 = _data_->_tmp4__length1;
	_data_->_state_ = 1;
	xmpp_stanza_writer_write_data (_data_->self, _data_->_tmp5_, (gint) _data_->_tmp5__length1, _data_->io_priority, _data_->_tmp0_, xmpp_stanza_writer_write_ready, _data_);
	return FALSE;
	_state_1:
	xmpp_stanza_writer_write_data_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;
		}
	}
	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_stanza_writer_write_data_data_free (gpointer _data)
{
	XmppStanzaWriterWriteDataData* _data_;
	_data_ = _data;
	_data_->data = (g_free (_data_->data), NULL);
	_g_object_unref0 (_data_->cancellable);
	_xmpp_stanza_writer_unref0 (_data_->self);
	g_slice_free (XmppStanzaWriterWriteDataData, _data_);
}

static void
xmpp_stanza_writer_write_data (XmppStanzaWriter* self,
                               guint8* data,
                               gint data_length1,
                               gint io_priority,
                               GCancellable* cancellable,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	XmppStanzaWriterWriteDataData* _data_;
	XmppStanzaWriter* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (XmppStanzaWriterWriteDataData);
	_data_->_async_result = g_task_new (NULL, cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, xmpp_stanza_writer_write_data_data_free);
	_tmp0_ = _xmpp_stanza_writer_ref0 (self);
	_data_->self = _tmp0_;
	_data_->data = (g_free (_data_->data), NULL);
	_data_->data = data;
	_data_->data_length1 = data_length1;
	_data_->io_priority = io_priority;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	xmpp_stanza_writer_write_data_co (_data_);
}

static void
xmpp_stanza_writer_write_data_finish (XmppStanzaWriter* self,
                                      GAsyncResult* _res_,
                                      GError** error)
{
	XmppStanzaWriterWriteDataData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
_xmpp_stanza_writer_write_data_co_gsource_func (gpointer self)
{
	gboolean result;
	result = xmpp_stanza_writer_write_data_co (self);
	return result;
}

static void
xmpp_stanza_writer_write_data_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	XmppStanzaWriterWriteDataData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	xmpp_stanza_writer_write_data_co (_data_);
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

static gboolean
xmpp_stanza_writer_write_data_co (XmppStanzaWriterWriteDataData* _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:
	if (_data_->self->priv->running) {
		_data_->_tmp0_ = _data_->self->priv->queue;
		_data_->_tmp1_ = xmpp_source_func_wrapper_new (_xmpp_stanza_writer_write_data_co_gsource_func, _data_, NULL);
		g_queue_push_tail (_data_->_tmp0_, _data_->_tmp1_);
		_data_->_state_ = 1;
		return FALSE;
		_state_1:
		;
	}
	_data_->self->priv->running = TRUE;
	{
		_data_->_tmp2_ = _data_->self->priv->output;
		_data_->_state_ = 2;
		g_output_stream_write_all_async (_data_->_tmp2_, _data_->data, (gsize) _data_->data_length1, _data_->io_priority, _data_->cancellable, xmpp_stanza_writer_write_data_ready, _data_);
		return FALSE;
		_state_2:
		g_output_stream_write_all_finish (_data_->_tmp2_, _data_->_res_, NULL, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp3_ = _data_->e;
		if (!g_error_matches (_data_->_tmp3_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
			_data_->_tmp4_ = _data_->self->priv->connection_cancellable;
			g_cancellable_cancel (_data_->_tmp4_);
		}
		_data_->_tmp5_ = _data_->e;
		_data_->_tmp6_ = _g_error_copy0 (_data_->_tmp5_);
		_data_->_inner_error0_ = _data_->_tmp6_;
		_g_error_free0 (_data_->e);
		goto __finally0;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_vala1_e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp7_ = _data_->self->priv->connection_cancellable;
		g_cancellable_cancel (_data_->_tmp7_);
		_data_->_tmp8_ = _data_->_vala1_e;
		_data_->_tmp9_ = _data_->_tmp8_->message;
		_data_->_tmp10_ = g_strdup_printf ("Error in GLib: %s", _data_->_tmp9_);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_FAILED, _data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		_g_free0 (_data_->_tmp11_);
		_data_->_inner_error0_ = _data_->_tmp13_;
		_g_error_free0 (_data_->_vala1_e);
		goto __finally0;
	}
	__finally0:
	{
		_data_->_tmp14_ = _data_->self->priv->queue;
		_data_->_tmp15_ = g_queue_pop_head (_data_->_tmp14_);
		_data_->sfw = (XmppSourceFuncWrapper*) _data_->_tmp15_;
		_data_->_tmp16_ = _data_->sfw;
		if (_data_->_tmp16_ != NULL) {
			_data_->_tmp17_ = _data_->sfw;
			_data_->_tmp18_ = _data_->_tmp17_->sfun;
			_data_->_tmp18__target = _data_->_tmp17_->sfun_target;
			_data_->_tmp18_ (_data_->_tmp18__target);
		} else {
			_data_->self->priv->running = FALSE;
		}
		_g_object_unref0 (_data_->sfw);
	}
	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_);
			_data_->data = (g_free (_data_->data), NULL);
			g_object_unref (_data_->_async_result);
			return FALSE;
		} else {
			_data_->data = (g_free (_data_->data), 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_->data = (g_free (_data_->data), 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;
}

XmppStanzaWriter*
xmpp_stanza_writer_construct (GType object_type)
{
	XmppStanzaWriter* self = NULL;
	self = (XmppStanzaWriter*) g_type_create_instance (object_type);
	return self;
}

XmppStanzaWriter*
xmpp_stanza_writer_new (void)
{
	return xmpp_stanza_writer_construct (XMPP_TYPE_STANZA_WRITER);
}

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

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

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

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

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

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

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

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

void
xmpp_value_set_stanza_writer (GValue* value,
                              gpointer v_object)
{
	XmppStanzaWriter * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_TYPE_STANZA_WRITER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_TYPE_STANZA_WRITER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		xmpp_stanza_writer_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_stanza_writer_unref (old);
	}
}

void
xmpp_value_take_stanza_writer (GValue* value,
                               gpointer v_object)
{
	XmppStanzaWriter * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_TYPE_STANZA_WRITER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_TYPE_STANZA_WRITER));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_stanza_writer_unref (old);
	}
}

static void
xmpp_stanza_writer_class_init (XmppStanzaWriterClass * klass,
                               gpointer klass_data)
{
	xmpp_stanza_writer_parent_class = g_type_class_peek_parent (klass);
	((XmppStanzaWriterClass *) klass)->finalize = xmpp_stanza_writer_finalize;
	g_type_class_adjust_private_offset (klass, &XmppStanzaWriter_private_offset);
}

static void
xmpp_stanza_writer_instance_init (XmppStanzaWriter * self,
                                  gpointer klass)
{
	GQueue* _tmp0_;
	self->priv = xmpp_stanza_writer_get_instance_private (self);
	_tmp0_ = g_queue_new ();
	self->priv->queue = _tmp0_;
	self->priv->running = FALSE;
	self->ref_count = 1;
}

static void
xmpp_stanza_writer_finalize (XmppStanzaWriter * obj)
{
	XmppStanzaWriter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_TYPE_STANZA_WRITER, XmppStanzaWriter);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->connection_cancellable);
	_g_object_unref0 (self->priv->output);
	(self->priv->queue == NULL) ? NULL : (self->priv->queue = (_g_queue_free__g_object_unref0_ (self->priv->queue), NULL));
}

static GType
xmpp_stanza_writer_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_value_stanza_writer_init, xmpp_value_stanza_writer_free_value, xmpp_value_stanza_writer_copy_value, xmpp_value_stanza_writer_peek_pointer, "p", xmpp_value_stanza_writer_collect_value, "p", xmpp_value_stanza_writer_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppStanzaWriterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_stanza_writer_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppStanzaWriter), 0, (GInstanceInitFunc) xmpp_stanza_writer_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType xmpp_stanza_writer_type_id;
	xmpp_stanza_writer_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppStanzaWriter", &g_define_type_info, &g_define_type_fundamental_info, 0);
	XmppStanzaWriter_private_offset = g_type_add_instance_private (xmpp_stanza_writer_type_id, sizeof (XmppStanzaWriterPrivate));
	return xmpp_stanza_writer_type_id;
}

GType
xmpp_stanza_writer_get_type (void)
{
	static volatile gsize xmpp_stanza_writer_type_id__once = 0;
	if (g_once_init_enter (&xmpp_stanza_writer_type_id__once)) {
		GType xmpp_stanza_writer_type_id;
		xmpp_stanza_writer_type_id = xmpp_stanza_writer_get_type_once ();
		g_once_init_leave (&xmpp_stanza_writer_type_id__once, xmpp_stanza_writer_type_id);
	}
	return xmpp_stanza_writer_type_id__once;
}

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

void
xmpp_stanza_writer_unref (gpointer instance)
{
	XmppStanzaWriter * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_STANZA_WRITER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

XmppSourceFuncWrapper*
xmpp_source_func_wrapper_construct (GType object_type,
                                    GSourceFunc sfun,
                                    gpointer sfun_target,
                                    GDestroyNotify sfun_target_destroy_notify)
{
	XmppSourceFuncWrapper * self = NULL;
	GSourceFunc _tmp0_;
	gpointer _tmp0__target;
	GDestroyNotify _tmp0__target_destroy_notify;
	self = (XmppSourceFuncWrapper*) g_object_new (object_type, NULL);
	_tmp0_ = sfun;
	_tmp0__target = sfun_target;
	_tmp0__target_destroy_notify = sfun_target_destroy_notify;
	sfun = NULL;
	sfun_target = NULL;
	sfun_target_destroy_notify = NULL;
	(self->sfun_target_destroy_notify == NULL) ? NULL : (self->sfun_target_destroy_notify (self->sfun_target), NULL);
	self->sfun = NULL;
	self->sfun_target = NULL;
	self->sfun_target_destroy_notify = NULL;
	self->sfun = _tmp0_;
	self->sfun_target = _tmp0__target;
	self->sfun_target_destroy_notify = _tmp0__target_destroy_notify;
	(sfun_target_destroy_notify == NULL) ? NULL : (sfun_target_destroy_notify (sfun_target), NULL);
	sfun = NULL;
	sfun_target = NULL;
	sfun_target_destroy_notify = NULL;
	return self;
}

XmppSourceFuncWrapper*
xmpp_source_func_wrapper_new (GSourceFunc sfun,
                              gpointer sfun_target,
                              GDestroyNotify sfun_target_destroy_notify)
{
	return xmpp_source_func_wrapper_construct (XMPP_TYPE_SOURCE_FUNC_WRAPPER, sfun, sfun_target, sfun_target_destroy_notify);
}

static void
xmpp_source_func_wrapper_class_init (XmppSourceFuncWrapperClass * klass,
                                     gpointer klass_data)
{
	xmpp_source_func_wrapper_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = xmpp_source_func_wrapper_finalize;
}

static void
xmpp_source_func_wrapper_instance_init (XmppSourceFuncWrapper * self,
                                        gpointer klass)
{
}

static void
xmpp_source_func_wrapper_finalize (GObject * obj)
{
	XmppSourceFuncWrapper * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_TYPE_SOURCE_FUNC_WRAPPER, XmppSourceFuncWrapper);
	(self->sfun_target_destroy_notify == NULL) ? NULL : (self->sfun_target_destroy_notify (self->sfun_target), NULL);
	self->sfun = NULL;
	self->sfun_target = NULL;
	self->sfun_target_destroy_notify = NULL;
	G_OBJECT_CLASS (xmpp_source_func_wrapper_parent_class)->finalize (obj);
}

static GType
xmpp_source_func_wrapper_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppSourceFuncWrapperClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_source_func_wrapper_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppSourceFuncWrapper), 0, (GInstanceInitFunc) xmpp_source_func_wrapper_instance_init, NULL };
	GType xmpp_source_func_wrapper_type_id;
	xmpp_source_func_wrapper_type_id = g_type_register_static (G_TYPE_OBJECT, "XmppSourceFuncWrapper", &g_define_type_info, 0);
	return xmpp_source_func_wrapper_type_id;
}

GType
xmpp_source_func_wrapper_get_type (void)
{
	static volatile gsize xmpp_source_func_wrapper_type_id__once = 0;
	if (g_once_init_enter (&xmpp_source_func_wrapper_type_id__once)) {
		GType xmpp_source_func_wrapper_type_id;
		xmpp_source_func_wrapper_type_id = xmpp_source_func_wrapper_get_type_once ();
		g_once_init_leave (&xmpp_source_func_wrapper_type_id__once, xmpp_source_func_wrapper_type_id);
	}
	return xmpp_source_func_wrapper_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;
}

