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

#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.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_IQ_STANZA_0_PROPERTY,
	XMPP_IQ_STANZA_NUM_PROPERTIES
};
static GParamSpec* xmpp_iq_stanza_properties[XMPP_IQ_STANZA_NUM_PROPERTIES];
#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))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))

static gpointer xmpp_iq_stanza_parent_class = NULL;

static XmppIqStanza* xmpp_iq_stanza_new (const gchar* id);
static XmppIqStanza* xmpp_iq_stanza_construct (GType object_type,
                                        const gchar* id);
static GType xmpp_iq_stanza_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static XmppIqStanza*
xmpp_iq_stanza_construct (GType object_type,
                          const gchar* id)
{
	XmppIqStanza * self = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	_tmp0_ = xmpp_stanza_node_new_build ("iq", "jabber:client", NULL, NULL);
	_tmp1_ = _tmp0_;
	self = (XmppIqStanza*) xmpp_stanza_construct_outgoing (object_type, _tmp1_);
	_xmpp_stanza_entry_unref0 (_tmp1_);
	_tmp3_ = g_strdup (id);
	_tmp2_ = _tmp3_;
	if (_tmp2_ == NULL) {
		gchar* _tmp4_;
		_tmp4_ = xmpp_random_uuid ();
		_g_free0 (_tmp2_);
		_tmp2_ = _tmp4_;
	}
	xmpp_stanza_set_id ((XmppStanza*) self, _tmp2_);
	_g_free0 (_tmp2_);
	return self;
}

static XmppIqStanza*
xmpp_iq_stanza_new (const gchar* id)
{
	return xmpp_iq_stanza_construct (XMPP_IQ_TYPE_STANZA, id);
}

XmppIqStanza*
xmpp_iq_stanza_construct_get (GType object_type,
                              XmppStanzaNode* stanza_node,
                              const gchar* id)
{
	XmppIqStanza * self = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	g_return_val_if_fail (stanza_node != NULL, NULL);
	self = (XmppIqStanza*) xmpp_iq_stanza_construct (object_type, id);
	xmpp_stanza_set_type_ ((XmppStanza*) self, XMPP_IQ_STANZA_TYPE_GET);
	_tmp0_ = ((XmppStanza*) self)->stanza;
	_tmp1_ = xmpp_stanza_node_put_node (_tmp0_, stanza_node);
	_tmp2_ = _tmp1_;
	_xmpp_stanza_entry_unref0 (_tmp2_);
	return self;
}

XmppIqStanza*
xmpp_iq_stanza_new_get (XmppStanzaNode* stanza_node,
                        const gchar* id)
{
	return xmpp_iq_stanza_construct_get (XMPP_IQ_TYPE_STANZA, stanza_node, id);
}

XmppIqStanza*
xmpp_iq_stanza_construct_result (GType object_type,
                                 XmppIqStanza* request,
                                 XmppStanzaNode* stanza_node)
{
	XmppIqStanza * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	XmppJid* _tmp2_;
	XmppJid* _tmp3_;
	XmppJid* _tmp4_;
	g_return_val_if_fail (request != NULL, NULL);
	_tmp0_ = xmpp_stanza_get_id ((XmppStanza*) request);
	_tmp1_ = _tmp0_;
	self = (XmppIqStanza*) xmpp_iq_stanza_construct (object_type, _tmp1_);
	_tmp2_ = xmpp_stanza_get_from ((XmppStanza*) request);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	xmpp_stanza_set_to ((XmppStanza*) self, _tmp4_);
	_xmpp_jid_unref0 (_tmp4_);
	xmpp_stanza_set_type_ ((XmppStanza*) self, XMPP_IQ_STANZA_TYPE_RESULT);
	if (stanza_node != NULL) {
		XmppStanzaNode* _tmp5_;
		XmppStanzaNode* _tmp6_;
		XmppStanzaNode* _tmp7_;
		_tmp5_ = ((XmppStanza*) self)->stanza;
		_tmp6_ = xmpp_stanza_node_put_node (_tmp5_, stanza_node);
		_tmp7_ = _tmp6_;
		_xmpp_stanza_entry_unref0 (_tmp7_);
	}
	return self;
}

XmppIqStanza*
xmpp_iq_stanza_new_result (XmppIqStanza* request,
                           XmppStanzaNode* stanza_node)
{
	return xmpp_iq_stanza_construct_result (XMPP_IQ_TYPE_STANZA, request, stanza_node);
}

XmppIqStanza*
xmpp_iq_stanza_construct_set (GType object_type,
                              XmppStanzaNode* stanza_node,
                              const gchar* id)
{
	XmppIqStanza * self = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	g_return_val_if_fail (stanza_node != NULL, NULL);
	self = (XmppIqStanza*) xmpp_iq_stanza_construct (object_type, id);
	xmpp_stanza_set_type_ ((XmppStanza*) self, XMPP_IQ_STANZA_TYPE_SET);
	_tmp0_ = ((XmppStanza*) self)->stanza;
	_tmp1_ = xmpp_stanza_node_put_node (_tmp0_, stanza_node);
	_tmp2_ = _tmp1_;
	_xmpp_stanza_entry_unref0 (_tmp2_);
	return self;
}

XmppIqStanza*
xmpp_iq_stanza_new_set (XmppStanzaNode* stanza_node,
                        const gchar* id)
{
	return xmpp_iq_stanza_construct_set (XMPP_IQ_TYPE_STANZA, stanza_node, id);
}

XmppIqStanza*
xmpp_iq_stanza_construct_error (GType object_type,
                                XmppIqStanza* request,
                                XmppErrorStanza* error_stanza)
{
	XmppIqStanza * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	g_return_val_if_fail (request != NULL, NULL);
	g_return_val_if_fail (error_stanza != NULL, NULL);
	_tmp0_ = xmpp_stanza_get_id ((XmppStanza*) request);
	_tmp1_ = _tmp0_;
	self = (XmppIqStanza*) xmpp_iq_stanza_construct (object_type, _tmp1_);
	xmpp_stanza_set_type_ ((XmppStanza*) self, XMPP_STANZA_TYPE_ERROR);
	_tmp2_ = ((XmppStanza*) self)->stanza;
	_tmp3_ = error_stanza->error_node;
	_tmp4_ = xmpp_stanza_node_put_node (_tmp2_, _tmp3_);
	_tmp5_ = _tmp4_;
	_xmpp_stanza_entry_unref0 (_tmp5_);
	return self;
}

XmppIqStanza*
xmpp_iq_stanza_new_error (XmppIqStanza* request,
                          XmppErrorStanza* error_stanza)
{
	return xmpp_iq_stanza_construct_error (XMPP_IQ_TYPE_STANZA, request, error_stanza);
}

XmppIqStanza*
xmpp_iq_stanza_construct_from_stanza (GType object_type,
                                      XmppStanzaNode* stanza_node,
                                      XmppJid* my_jid)
{
	XmppIqStanza * self = NULL;
	g_return_val_if_fail (stanza_node != NULL, NULL);
	self = (XmppIqStanza*) xmpp_stanza_construct_incoming (object_type, stanza_node, my_jid);
	return self;
}

XmppIqStanza*
xmpp_iq_stanza_new_from_stanza (XmppStanzaNode* stanza_node,
                                XmppJid* my_jid)
{
	return xmpp_iq_stanza_construct_from_stanza (XMPP_IQ_TYPE_STANZA, stanza_node, my_jid);
}

static void
xmpp_iq_stanza_class_init (XmppIqStanzaClass * klass,
                           gpointer klass_data)
{
	xmpp_iq_stanza_parent_class = g_type_class_peek_parent (klass);
}

static void
xmpp_iq_stanza_instance_init (XmppIqStanza * self,
                              gpointer klass)
{
}

static GType
xmpp_iq_stanza_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppIqStanzaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_iq_stanza_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppIqStanza), 0, (GInstanceInitFunc) xmpp_iq_stanza_instance_init, NULL };
	GType xmpp_iq_stanza_type_id;
	xmpp_iq_stanza_type_id = g_type_register_static (XMPP_TYPE_STANZA, "XmppIqStanza", &g_define_type_info, 0);
	return xmpp_iq_stanza_type_id;
}

GType
xmpp_iq_stanza_get_type (void)
{
	static volatile gsize xmpp_iq_stanza_type_id__once = 0;
	if (g_once_init_enter (&xmpp_iq_stanza_type_id__once)) {
		GType xmpp_iq_stanza_type_id;
		xmpp_iq_stanza_type_id = xmpp_iq_stanza_get_type_once ();
		g_once_init_leave (&xmpp_iq_stanza_type_id__once, xmpp_iq_stanza_type_id);
	}
	return xmpp_iq_stanza_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;
}

