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

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

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

enum  {
	XMPP_XEP_MESSAGE_MARKUP_SPAN_0_PROPERTY,
	XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPES_PROPERTY,
	XMPP_XEP_MESSAGE_MARKUP_SPAN_START_CHAR_PROPERTY,
	XMPP_XEP_MESSAGE_MARKUP_SPAN_END_CHAR_PROPERTY,
	XMPP_XEP_MESSAGE_MARKUP_SPAN_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_message_markup_span_properties[XMPP_XEP_MESSAGE_MARKUP_SPAN_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 _g_free0(var) (var = (g_free (var), NULL))

struct _XmppXepMessageMarkupSpanPrivate {
	GeeList* _types;
	gint _start_char;
	gint _end_char;
};

static gint XmppXepMessageMarkupSpan_private_offset;
static gpointer xmpp_xep_message_markup_span_parent_class = NULL;

static void xmpp_xep_message_markup_span_finalize (GObject * obj);
static GType xmpp_xep_message_markup_span_get_type_once (void);
static void _vala_xmpp_xep_message_markup_span_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec);
static void _vala_xmpp_xep_message_markup_span_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
xmpp_xep_message_markup_span_type_get_type_once (void)
{
	static const GEnumValue values[] = {{XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_EMPHASIS, "XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_EMPHASIS", "emphasis"}, {XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_STRONG_EMPHASIS, "XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_STRONG_EMPHASIS", "strong-emphasis"}, {XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_DELETED, "XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_DELETED", "deleted"}, {0, NULL, NULL}};
	GType xmpp_xep_message_markup_span_type_type_id;
	xmpp_xep_message_markup_span_type_type_id = g_enum_register_static ("XmppXepMessageMarkupSpanType", values);
	return xmpp_xep_message_markup_span_type_type_id;
}

GType
xmpp_xep_message_markup_span_type_get_type (void)
{
	static volatile gsize xmpp_xep_message_markup_span_type_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_message_markup_span_type_type_id__once)) {
		GType xmpp_xep_message_markup_span_type_type_id;
		xmpp_xep_message_markup_span_type_type_id = xmpp_xep_message_markup_span_type_get_type_once ();
		g_once_init_leave (&xmpp_xep_message_markup_span_type_type_id__once, xmpp_xep_message_markup_span_type_type_id);
	}
	return xmpp_xep_message_markup_span_type_type_id__once;
}

static inline gpointer
xmpp_xep_message_markup_span_get_instance_private (XmppXepMessageMarkupSpan* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepMessageMarkupSpan_private_offset);
}

XmppXepMessageMarkupSpan*
xmpp_xep_message_markup_span_construct (GType object_type)
{
	XmppXepMessageMarkupSpan * self = NULL;
	self = (XmppXepMessageMarkupSpan*) g_object_new (object_type, NULL);
	return self;
}

XmppXepMessageMarkupSpan*
xmpp_xep_message_markup_span_new (void)
{
	return xmpp_xep_message_markup_span_construct (XMPP_XEP_MESSAGE_MARKUP_TYPE_SPAN);
}

GeeList*
xmpp_xep_message_markup_span_get_types (XmppXepMessageMarkupSpan* self)
{
	GeeList* result;
	GeeList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_types;
	result = _tmp0_;
	return result;
}

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

void
xmpp_xep_message_markup_span_set_types (XmppXepMessageMarkupSpan* self,
                                        GeeList* value)
{
	GeeList* old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xep_message_markup_span_get_types (self);
	if (old_value != value) {
		GeeList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_types);
		self->priv->_types = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xep_message_markup_span_properties[XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPES_PROPERTY]);
	}
}

gint
xmpp_xep_message_markup_span_get_start_char (XmppXepMessageMarkupSpan* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_start_char;
	return result;
}

void
xmpp_xep_message_markup_span_set_start_char (XmppXepMessageMarkupSpan* self,
                                             gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xep_message_markup_span_get_start_char (self);
	if (old_value != value) {
		self->priv->_start_char = value;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xep_message_markup_span_properties[XMPP_XEP_MESSAGE_MARKUP_SPAN_START_CHAR_PROPERTY]);
	}
}

gint
xmpp_xep_message_markup_span_get_end_char (XmppXepMessageMarkupSpan* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_end_char;
	return result;
}

void
xmpp_xep_message_markup_span_set_end_char (XmppXepMessageMarkupSpan* self,
                                           gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = xmpp_xep_message_markup_span_get_end_char (self);
	if (old_value != value) {
		self->priv->_end_char = value;
		g_object_notify_by_pspec ((GObject *) self, xmpp_xep_message_markup_span_properties[XMPP_XEP_MESSAGE_MARKUP_SPAN_END_CHAR_PROPERTY]);
	}
}

static void
xmpp_xep_message_markup_span_class_init (XmppXepMessageMarkupSpanClass * klass,
                                         gpointer klass_data)
{
	xmpp_xep_message_markup_span_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXepMessageMarkupSpan_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_xmpp_xep_message_markup_span_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_xmpp_xep_message_markup_span_set_property;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_message_markup_span_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPES_PROPERTY, xmpp_xep_message_markup_span_properties[XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPES_PROPERTY] = g_param_spec_object ("types", "types", "types", GEE_TYPE_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_MESSAGE_MARKUP_SPAN_START_CHAR_PROPERTY, xmpp_xep_message_markup_span_properties[XMPP_XEP_MESSAGE_MARKUP_SPAN_START_CHAR_PROPERTY] = g_param_spec_int ("start-char", "start-char", "start-char", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_MESSAGE_MARKUP_SPAN_END_CHAR_PROPERTY, xmpp_xep_message_markup_span_properties[XMPP_XEP_MESSAGE_MARKUP_SPAN_END_CHAR_PROPERTY] = g_param_spec_int ("end-char", "end-char", "end-char", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
xmpp_xep_message_markup_span_instance_init (XmppXepMessageMarkupSpan * self,
                                            gpointer klass)
{
	self->priv = xmpp_xep_message_markup_span_get_instance_private (self);
}

static void
xmpp_xep_message_markup_span_finalize (GObject * obj)
{
	XmppXepMessageMarkupSpan * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_MESSAGE_MARKUP_TYPE_SPAN, XmppXepMessageMarkupSpan);
	_g_object_unref0 (self->priv->_types);
	G_OBJECT_CLASS (xmpp_xep_message_markup_span_parent_class)->finalize (obj);
}

static GType
xmpp_xep_message_markup_span_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepMessageMarkupSpanClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_message_markup_span_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepMessageMarkupSpan), 0, (GInstanceInitFunc) xmpp_xep_message_markup_span_instance_init, NULL };
	GType xmpp_xep_message_markup_span_type_id;
	xmpp_xep_message_markup_span_type_id = g_type_register_static (G_TYPE_OBJECT, "XmppXepMessageMarkupSpan", &g_define_type_info, 0);
	XmppXepMessageMarkupSpan_private_offset = g_type_add_instance_private (xmpp_xep_message_markup_span_type_id, sizeof (XmppXepMessageMarkupSpanPrivate));
	return xmpp_xep_message_markup_span_type_id;
}

GType
xmpp_xep_message_markup_span_get_type (void)
{
	static volatile gsize xmpp_xep_message_markup_span_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_message_markup_span_type_id__once)) {
		GType xmpp_xep_message_markup_span_type_id;
		xmpp_xep_message_markup_span_type_id = xmpp_xep_message_markup_span_get_type_once ();
		g_once_init_leave (&xmpp_xep_message_markup_span_type_id__once, xmpp_xep_message_markup_span_type_id);
	}
	return xmpp_xep_message_markup_span_type_id__once;
}

static void
_vala_xmpp_xep_message_markup_span_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec)
{
	XmppXepMessageMarkupSpan * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_XEP_MESSAGE_MARKUP_TYPE_SPAN, XmppXepMessageMarkupSpan);
	switch (property_id) {
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPES_PROPERTY:
		g_value_set_object (value, xmpp_xep_message_markup_span_get_types (self));
		break;
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_START_CHAR_PROPERTY:
		g_value_set_int (value, xmpp_xep_message_markup_span_get_start_char (self));
		break;
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_END_CHAR_PROPERTY:
		g_value_set_int (value, xmpp_xep_message_markup_span_get_end_char (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_xmpp_xep_message_markup_span_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec)
{
	XmppXepMessageMarkupSpan * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_XEP_MESSAGE_MARKUP_TYPE_SPAN, XmppXepMessageMarkupSpan);
	switch (property_id) {
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPES_PROPERTY:
		xmpp_xep_message_markup_span_set_types (self, g_value_get_object (value));
		break;
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_START_CHAR_PROPERTY:
		xmpp_xep_message_markup_span_set_start_char (self, g_value_get_int (value));
		break;
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_END_CHAR_PROPERTY:
		xmpp_xep_message_markup_span_set_end_char (self, g_value_get_int (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

GeeList*
xmpp_xep_message_markup_get_spans (XmppMessageStanza* stanza)
{
	GeeArrayList* ret = NULL;
	GeeArrayList* _tmp0_;
	GeeList* result;
	g_return_val_if_fail (stanza != NULL, NULL);
	_tmp0_ = gee_array_list_new (XMPP_XEP_MESSAGE_MARKUP_TYPE_SPAN, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	ret = _tmp0_;
	{
		GeeList* _span_node_list = NULL;
		XmppStanzaNode* _tmp1_;
		GeeList* _tmp2_;
		gint _span_node_size = 0;
		GeeList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _span_node_index = 0;
		_tmp1_ = ((XmppStanza*) stanza)->stanza;
		_tmp2_ = xmpp_stanza_node_get_deep_subnodes (_tmp1_, XMPP_XEP_MESSAGE_MARKUP_NS_URI ":markup", XMPP_XEP_MESSAGE_MARKUP_NS_URI ":span", NULL);
		_span_node_list = _tmp2_;
		_tmp3_ = _span_node_list;
		_tmp4_ = gee_collection_get_size ((GeeCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_span_node_size = _tmp5_;
		_span_node_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			XmppStanzaNode* span_node = NULL;
			GeeList* _tmp8_;
			gpointer _tmp9_;
			gint start_char = 0;
			XmppStanzaNode* _tmp10_;
			gint end_char = 0;
			XmppStanzaNode* _tmp11_;
			gboolean _tmp12_ = FALSE;
			GeeArrayList* types = NULL;
			GeeArrayList* _tmp13_;
			GeeArrayList* _tmp26_;
			GeeArrayList* _tmp27_;
			GeeList* _tmp28_;
			XmppXepMessageMarkupSpan* _tmp29_ = NULL;
			XmppXepMessageMarkupSpan* _tmp30_;
			_span_node_index = _span_node_index + 1;
			_tmp6_ = _span_node_index;
			_tmp7_ = _span_node_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _span_node_list;
			_tmp9_ = gee_list_get (_tmp8_, _span_node_index);
			span_node = (XmppStanzaNode*) _tmp9_;
			_tmp10_ = span_node;
			start_char = xmpp_stanza_node_get_attribute_int (_tmp10_, "start", -1, XMPP_XEP_MESSAGE_MARKUP_NS_URI);
			_tmp11_ = span_node;
			end_char = xmpp_stanza_node_get_attribute_int (_tmp11_, "end", -1, XMPP_XEP_MESSAGE_MARKUP_NS_URI);
			if (start_char == -1) {
				_tmp12_ = TRUE;
			} else {
				_tmp12_ = end_char == -1;
			}
			if (_tmp12_) {
				_xmpp_stanza_entry_unref0 (span_node);
				continue;
			}
			_tmp13_ = gee_array_list_new (XMPP_XEP_MESSAGE_MARKUP_TYPE_SPAN_TYPE, NULL, NULL, NULL, NULL, NULL);
			types = _tmp13_;
			{
				GeeList* _span_subnode_list = NULL;
				XmppStanzaNode* _tmp14_;
				GeeList* _tmp15_;
				gint _span_subnode_size = 0;
				GeeList* _tmp16_;
				gint _tmp17_;
				gint _tmp18_;
				gint _span_subnode_index = 0;
				_tmp14_ = span_node;
				_tmp15_ = xmpp_stanza_node_get_all_subnodes (_tmp14_);
				_span_subnode_list = _tmp15_;
				_tmp16_ = _span_subnode_list;
				_tmp17_ = gee_collection_get_size ((GeeCollection*) _tmp16_);
				_tmp18_ = _tmp17_;
				_span_subnode_size = _tmp18_;
				_span_subnode_index = -1;
				while (TRUE) {
					gint _tmp19_;
					gint _tmp20_;
					XmppStanzaNode* span_subnode = NULL;
					GeeList* _tmp21_;
					gpointer _tmp22_;
					GeeArrayList* _tmp23_;
					XmppStanzaNode* _tmp24_;
					const gchar* _tmp25_;
					_span_subnode_index = _span_subnode_index + 1;
					_tmp19_ = _span_subnode_index;
					_tmp20_ = _span_subnode_size;
					if (!(_tmp19_ < _tmp20_)) {
						break;
					}
					_tmp21_ = _span_subnode_list;
					_tmp22_ = gee_list_get (_tmp21_, _span_subnode_index);
					span_subnode = (XmppStanzaNode*) _tmp22_;
					_tmp23_ = types;
					_tmp24_ = span_subnode;
					_tmp25_ = ((XmppStanzaEntry*) _tmp24_)->name;
					gee_abstract_collection_add ((GeeAbstractCollection*) _tmp23_, (gpointer) ((gintptr) xmpp_xep_message_markup_str_to_span_type (_tmp25_)));
					_xmpp_stanza_entry_unref0 (span_subnode);
				}
				_g_object_unref0 (_span_subnode_list);
			}
			_tmp26_ = ret;
			_tmp27_ = types;
			_tmp28_ = _g_object_ref0 ((GeeList*) _tmp27_);
			_tmp29_ = xmpp_xep_message_markup_span_new ();
			xmpp_xep_message_markup_span_set_types (_tmp29_, _tmp28_);
			_g_object_unref0 (_tmp28_);
			xmpp_xep_message_markup_span_set_start_char (_tmp29_, start_char);
			xmpp_xep_message_markup_span_set_end_char (_tmp29_, end_char);
			_tmp30_ = _tmp29_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp26_, _tmp30_);
			_g_object_unref0 (_tmp30_);
			_g_object_unref0 (types);
			_xmpp_stanza_entry_unref0 (span_node);
		}
		_g_object_unref0 (_span_node_list);
	}
	result = (GeeList*) ret;
	return result;
}

void
xmpp_xep_message_markup_add_spans (XmppMessageStanza* stanza,
                                   GeeList* spans)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	XmppStanzaNode* markup_node = NULL;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	XmppStanzaNode* _tmp50_;
	XmppStanzaNode* _tmp51_;
	XmppStanzaNode* _tmp52_;
	XmppStanzaNode* _tmp53_;
	g_return_if_fail (stanza != NULL);
	g_return_if_fail (spans != NULL);
	_tmp0_ = gee_collection_get_is_empty ((GeeCollection*) spans);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		return;
	}
	_tmp2_ = xmpp_stanza_node_new_build ("markup", XMPP_XEP_MESSAGE_MARKUP_NS_URI, NULL, NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_stanza_node_add_self_xmlns (_tmp3_);
	_tmp5_ = _tmp4_;
	_xmpp_stanza_entry_unref0 (_tmp3_);
	markup_node = _tmp5_;
	{
		GeeList* _span_list = NULL;
		gint _span_size = 0;
		GeeList* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		gint _span_index = 0;
		_span_list = spans;
		_tmp6_ = _span_list;
		_tmp7_ = gee_collection_get_size ((GeeCollection*) _tmp6_);
		_tmp8_ = _tmp7_;
		_span_size = _tmp8_;
		_span_index = -1;
		while (TRUE) {
			gint _tmp9_;
			gint _tmp10_;
			XmppXepMessageMarkupSpan* span = NULL;
			GeeList* _tmp11_;
			gpointer _tmp12_;
			XmppStanzaNode* span_node = NULL;
			XmppStanzaNode* _tmp13_;
			XmppStanzaNode* _tmp14_;
			XmppXepMessageMarkupSpan* _tmp15_;
			gint _tmp16_;
			gint _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			XmppStanzaNode* _tmp20_;
			XmppStanzaNode* _tmp21_;
			XmppXepMessageMarkupSpan* _tmp22_;
			gint _tmp23_;
			gint _tmp24_;
			gchar* _tmp25_;
			gchar* _tmp26_;
			XmppStanzaNode* _tmp27_;
			XmppStanzaNode* _tmp28_;
			XmppStanzaNode* _tmp46_;
			XmppStanzaNode* _tmp47_;
			XmppStanzaNode* _tmp48_;
			XmppStanzaNode* _tmp49_;
			_span_index = _span_index + 1;
			_tmp9_ = _span_index;
			_tmp10_ = _span_size;
			if (!(_tmp9_ < _tmp10_)) {
				break;
			}
			_tmp11_ = _span_list;
			_tmp12_ = gee_list_get (_tmp11_, _span_index);
			span = (XmppXepMessageMarkupSpan*) _tmp12_;
			_tmp13_ = xmpp_stanza_node_new_build ("span", XMPP_XEP_MESSAGE_MARKUP_NS_URI, NULL, NULL);
			_tmp14_ = _tmp13_;
			_tmp15_ = span;
			_tmp16_ = xmpp_xep_message_markup_span_get_start_char (_tmp15_);
			_tmp17_ = _tmp16_;
			_tmp18_ = g_strdup_printf ("%i", _tmp17_);
			_tmp19_ = _tmp18_;
			_tmp20_ = xmpp_stanza_node_put_attribute (_tmp14_, "start", _tmp19_, XMPP_XEP_MESSAGE_MARKUP_NS_URI);
			_tmp21_ = _tmp20_;
			_tmp22_ = span;
			_tmp23_ = xmpp_xep_message_markup_span_get_end_char (_tmp22_);
			_tmp24_ = _tmp23_;
			_tmp25_ = g_strdup_printf ("%i", _tmp24_);
			_tmp26_ = _tmp25_;
			_tmp27_ = xmpp_stanza_node_put_attribute (_tmp21_, "end", _tmp26_, XMPP_XEP_MESSAGE_MARKUP_NS_URI);
			_tmp28_ = _tmp27_;
			_g_free0 (_tmp26_);
			_xmpp_stanza_entry_unref0 (_tmp21_);
			_g_free0 (_tmp19_);
			_xmpp_stanza_entry_unref0 (_tmp14_);
			span_node = _tmp28_;
			{
				GeeList* _type_list = NULL;
				XmppXepMessageMarkupSpan* _tmp29_;
				GeeList* _tmp30_;
				GeeList* _tmp31_;
				gint _type_size = 0;
				GeeList* _tmp32_;
				gint _tmp33_;
				gint _tmp34_;
				gint _type_index = 0;
				_tmp29_ = span;
				_tmp30_ = xmpp_xep_message_markup_span_get_types (_tmp29_);
				_tmp31_ = _tmp30_;
				_type_list = _tmp31_;
				_tmp32_ = _type_list;
				_tmp33_ = gee_collection_get_size ((GeeCollection*) _tmp32_);
				_tmp34_ = _tmp33_;
				_type_size = _tmp34_;
				_type_index = -1;
				while (TRUE) {
					gint _tmp35_;
					gint _tmp36_;
					XmppXepMessageMarkupSpanType type = 0;
					GeeList* _tmp37_;
					gpointer _tmp38_;
					XmppStanzaNode* _tmp39_;
					gchar* _tmp40_;
					gchar* _tmp41_;
					XmppStanzaNode* _tmp42_;
					XmppStanzaNode* _tmp43_;
					XmppStanzaNode* _tmp44_;
					XmppStanzaNode* _tmp45_;
					_type_index = _type_index + 1;
					_tmp35_ = _type_index;
					_tmp36_ = _type_size;
					if (!(_tmp35_ < _tmp36_)) {
						break;
					}
					_tmp37_ = _type_list;
					_tmp38_ = gee_list_get (_tmp37_, _type_index);
					type = (XmppXepMessageMarkupSpanType) ((gintptr) _tmp38_);
					_tmp39_ = span_node;
					_tmp40_ = xmpp_xep_message_markup_span_type_to_str (type);
					_tmp41_ = _tmp40_;
					_tmp42_ = xmpp_stanza_node_new_build (_tmp41_, XMPP_XEP_MESSAGE_MARKUP_NS_URI, NULL, NULL);
					_tmp43_ = _tmp42_;
					_tmp44_ = xmpp_stanza_node_put_node (_tmp39_, _tmp43_);
					_tmp45_ = _tmp44_;
					_xmpp_stanza_entry_unref0 (_tmp45_);
					_xmpp_stanza_entry_unref0 (_tmp43_);
					_g_free0 (_tmp41_);
				}
			}
			_tmp46_ = markup_node;
			_tmp47_ = span_node;
			_tmp48_ = xmpp_stanza_node_put_node (_tmp46_, _tmp47_);
			_tmp49_ = _tmp48_;
			_xmpp_stanza_entry_unref0 (_tmp49_);
			_xmpp_stanza_entry_unref0 (span_node);
			_g_object_unref0 (span);
		}
	}
	_tmp50_ = ((XmppStanza*) stanza)->stanza;
	_tmp51_ = markup_node;
	_tmp52_ = xmpp_stanza_node_put_node (_tmp50_, _tmp51_);
	_tmp53_ = _tmp52_;
	_xmpp_stanza_entry_unref0 (_tmp53_);
	_xmpp_stanza_entry_unref0 (markup_node);
}

gchar*
xmpp_xep_message_markup_span_type_to_str (XmppXepMessageMarkupSpanType span_type)
{
	gchar* result;
	switch (span_type) {
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_EMPHASIS:
		{
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("emphasis");
			result = _tmp0_;
			return result;
		}
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_STRONG_EMPHASIS:
		{
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("strong");
			result = _tmp1_;
			return result;
		}
		case XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_DELETED:
		{
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("deleted");
			result = _tmp2_;
			return result;
		}
		default:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("");
			result = _tmp3_;
			return result;
		}
	}
}

XmppXepMessageMarkupSpanType
xmpp_xep_message_markup_str_to_span_type (const gchar* span_str)
{
	const gchar* _tmp0_;
	GQuark _tmp2_ = 0U;
	static GQuark _tmp1_label0 = 0;
	static GQuark _tmp1_label1 = 0;
	static GQuark _tmp1_label2 = 0;
	XmppXepMessageMarkupSpanType result;
	g_return_val_if_fail (span_str != NULL, 0);
	_tmp0_ = span_str;
	_tmp2_ = (NULL == _tmp0_) ? 0 : g_quark_from_string (_tmp0_);
	if (_tmp2_ == ((0 != _tmp1_label0) ? _tmp1_label0 : (_tmp1_label0 = g_quark_from_static_string ("emphasis")))) {
		switch (0) {
			default:
			{
				result = XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_EMPHASIS;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label1) ? _tmp1_label1 : (_tmp1_label1 = g_quark_from_static_string ("strong")))) {
		switch (0) {
			default:
			{
				result = XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_STRONG_EMPHASIS;
				return result;
			}
		}
	} else if (_tmp2_ == ((0 != _tmp1_label2) ? _tmp1_label2 : (_tmp1_label2 = g_quark_from_static_string ("deleted")))) {
		switch (0) {
			default:
			{
				result = XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_DELETED;
				return result;
			}
		}
	} else {
		switch (0) {
			default:
			{
				result = XMPP_XEP_MESSAGE_MARKUP_SPAN_TYPE_EMPHASIS;
				return result;
			}
		}
	}
}

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

