/* 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_PRESENCE_STANZA_0_PROPERTY,
	XMPP_PRESENCE_STANZA_PRIORITY_PROPERTY,
	XMPP_PRESENCE_STANZA_STATUS_PROPERTY,
	XMPP_PRESENCE_STANZA_SHOW_PROPERTY,
	XMPP_PRESENCE_STANZA_TYPE__PROPERTY,
	XMPP_PRESENCE_STANZA_NUM_PROPERTIES
};
static GParamSpec* xmpp_presence_stanza_properties[XMPP_PRESENCE_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))

static gpointer xmpp_presence_stanza_parent_class = NULL;

static GType xmpp_presence_stanza_get_type_once (void);
static void _vala_xmpp_presence_stanza_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_xmpp_presence_stanza_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

XmppPresenceStanza*
xmpp_presence_stanza_construct (GType object_type,
                                const gchar* id)
{
	XmppPresenceStanza * self = NULL;
	XmppStanzaNode* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	self = (XmppPresenceStanza*) xmpp_stanza_construct (object_type);
	_tmp0_ = xmpp_stanza_node_new_build ("presence", "jabber:client", NULL, NULL);
	_xmpp_stanza_entry_unref0 (((XmppStanza*) self)->stanza);
	((XmppStanza*) self)->stanza = _tmp0_;
	_tmp2_ = g_strdup (id);
	_tmp1_ = _tmp2_;
	if (_tmp1_ == NULL) {
		gchar* _tmp3_;
		_tmp3_ = xmpp_random_uuid ();
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp3_;
	}
	xmpp_stanza_set_id ((XmppStanza*) self, _tmp1_);
	_g_free0 (_tmp1_);
	return self;
}

XmppPresenceStanza*
xmpp_presence_stanza_new (const gchar* id)
{
	return xmpp_presence_stanza_construct (XMPP_PRESENCE_TYPE_STANZA, id);
}

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

XmppPresenceStanza*
xmpp_presence_stanza_new_from_stanza (XmppStanzaNode* stanza_node,
                                      XmppJid* my_jid)
{
	return xmpp_presence_stanza_construct_from_stanza (XMPP_PRESENCE_TYPE_STANZA, stanza_node, my_jid);
}

gint
xmpp_presence_stanza_get_priority (XmppPresenceStanza* self)
{
	gint result;
	XmppStanzaNode* priority_node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = ((XmppStanza*) self)->stanza;
	_tmp1_ = xmpp_stanza_node_get_subnode (_tmp0_, XMPP_PRESENCE_STANZA_NODE_PRIORITY, NULL, FALSE);
	priority_node = _tmp1_;
	_tmp2_ = priority_node;
	if (_tmp2_ == NULL) {
		result = 0;
		_xmpp_stanza_entry_unref0 (priority_node);
		return result;
	} else {
		XmppStanzaNode* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = priority_node;
		_tmp4_ = xmpp_stanza_entry_get_string_content ((XmppStanzaEntry*) _tmp3_);
		result = atoi (_tmp4_);
		_xmpp_stanza_entry_unref0 (priority_node);
		return result;
	}
}

void
xmpp_presence_stanza_set_priority (XmppPresenceStanza* self,
                                   gint value)
{
	XmppStanzaNode* priority_node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp8_;
	gchar* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ((XmppStanza*) self)->stanza;
	_tmp1_ = xmpp_stanza_node_get_subnode (_tmp0_, XMPP_PRESENCE_STANZA_NODE_PRIORITY, NULL, FALSE);
	priority_node = _tmp1_;
	_tmp2_ = priority_node;
	if (_tmp2_ == NULL) {
		XmppStanzaNode* _tmp3_;
		XmppStanzaNode* _tmp4_;
		XmppStanzaNode* _tmp5_;
		XmppStanzaNode* _tmp6_;
		XmppStanzaNode* _tmp7_;
		_tmp3_ = xmpp_stanza_node_new_build (XMPP_PRESENCE_STANZA_NODE_PRIORITY, "jabber:client", NULL, NULL);
		_xmpp_stanza_entry_unref0 (priority_node);
		priority_node = _tmp3_;
		_tmp4_ = ((XmppStanza*) self)->stanza;
		_tmp5_ = priority_node;
		_tmp6_ = xmpp_stanza_node_put_node (_tmp4_, _tmp5_);
		_tmp7_ = _tmp6_;
		_xmpp_stanza_entry_unref0 (_tmp7_);
	}
	_tmp8_ = priority_node;
	_tmp9_ = g_strdup_printf ("%i", value);
	_g_free0 (((XmppStanzaEntry*) _tmp8_)->val);
	((XmppStanzaEntry*) _tmp8_)->val = _tmp9_;
	_xmpp_stanza_entry_unref0 (priority_node);
	g_object_notify_by_pspec ((GObject *) self, xmpp_presence_stanza_properties[XMPP_PRESENCE_STANZA_PRIORITY_PROPERTY]);
}

const gchar*
xmpp_presence_stanza_get_status (XmppPresenceStanza* self)
{
	const gchar* result;
	XmppStanzaNode* status_node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	const gchar* _tmp2_ = NULL;
	XmppStanzaNode* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ((XmppStanza*) self)->stanza;
	_tmp1_ = xmpp_stanza_node_get_subnode (_tmp0_, XMPP_PRESENCE_STANZA_NODE_STATUS, NULL, FALSE);
	status_node = _tmp1_;
	_tmp3_ = status_node;
	if (_tmp3_ != NULL) {
		XmppStanzaNode* _tmp4_;
		const gchar* _tmp5_;
		_tmp4_ = status_node;
		_tmp5_ = xmpp_stanza_entry_get_string_content ((XmppStanzaEntry*) _tmp4_);
		_tmp2_ = _tmp5_;
	} else {
		_tmp2_ = NULL;
	}
	result = _tmp2_;
	_xmpp_stanza_entry_unref0 (status_node);
	return result;
}

void
xmpp_presence_stanza_set_status (XmppPresenceStanza* self,
                                 const gchar* value)
{
	XmppStanzaNode* status_node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp8_;
	gchar* _tmp9_;
	g_return_if_fail (self != NULL);
	_tmp0_ = ((XmppStanza*) self)->stanza;
	_tmp1_ = xmpp_stanza_node_get_subnode (_tmp0_, XMPP_PRESENCE_STANZA_NODE_STATUS, NULL, FALSE);
	status_node = _tmp1_;
	_tmp2_ = status_node;
	if (_tmp2_ == NULL) {
		XmppStanzaNode* _tmp3_;
		XmppStanzaNode* _tmp4_;
		XmppStanzaNode* _tmp5_;
		XmppStanzaNode* _tmp6_;
		XmppStanzaNode* _tmp7_;
		_tmp3_ = xmpp_stanza_node_new_build (XMPP_PRESENCE_STANZA_NODE_STATUS, "jabber:client", NULL, NULL);
		_xmpp_stanza_entry_unref0 (status_node);
		status_node = _tmp3_;
		_tmp4_ = ((XmppStanza*) self)->stanza;
		_tmp5_ = status_node;
		_tmp6_ = xmpp_stanza_node_put_node (_tmp4_, _tmp5_);
		_tmp7_ = _tmp6_;
		_xmpp_stanza_entry_unref0 (_tmp7_);
	}
	_tmp8_ = status_node;
	_tmp9_ = g_strdup (value);
	_g_free0 (((XmppStanzaEntry*) _tmp8_)->val);
	((XmppStanzaEntry*) _tmp8_)->val = _tmp9_;
	_xmpp_stanza_entry_unref0 (status_node);
	g_object_notify_by_pspec ((GObject *) self, xmpp_presence_stanza_properties[XMPP_PRESENCE_STANZA_STATUS_PROPERTY]);
}

const gchar*
xmpp_presence_stanza_get_show (XmppPresenceStanza* self)
{
	const gchar* result;
	XmppStanzaNode* show_node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	const gchar* _tmp3_ = NULL;
	XmppStanzaNode* _tmp4_;
	const gchar* _tmp5_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = ((XmppStanza*) self)->stanza;
	_tmp1_ = xmpp_stanza_node_get_subnode (_tmp0_, XMPP_PRESENCE_STANZA_NODE_SHOW, NULL, FALSE);
	show_node = _tmp1_;
	_tmp2_ = show_node;
	if (_tmp2_ == NULL) {
		result = XMPP_PRESENCE_STANZA_SHOW_ONLINE;
		_xmpp_stanza_entry_unref0 (show_node);
		return result;
	}
	_tmp4_ = show_node;
	_tmp5_ = xmpp_stanza_entry_get_string_content ((XmppStanzaEntry*) _tmp4_);
	_tmp3_ = _tmp5_;
	if (_tmp3_ == NULL) {
		_tmp3_ = XMPP_PRESENCE_STANZA_SHOW_ONLINE;
	}
	result = _tmp3_;
	_xmpp_stanza_entry_unref0 (show_node);
	return result;
}

void
xmpp_presence_stanza_set_show (XmppPresenceStanza* self,
                               const gchar* value)
{
	g_return_if_fail (self != NULL);
	if (g_strcmp0 (value, XMPP_PRESENCE_STANZA_SHOW_ONLINE) != 0) {
		XmppStanzaNode* show_node = NULL;
		XmppStanzaNode* _tmp0_;
		XmppStanzaNode* _tmp1_;
		XmppStanzaNode* _tmp2_;
		XmppStanzaNode* _tmp8_;
		gchar* _tmp9_;
		_tmp0_ = ((XmppStanza*) self)->stanza;
		_tmp1_ = xmpp_stanza_node_get_subnode (_tmp0_, XMPP_PRESENCE_STANZA_NODE_SHOW, NULL, FALSE);
		show_node = _tmp1_;
		_tmp2_ = show_node;
		if (_tmp2_ == NULL) {
			XmppStanzaNode* _tmp3_;
			XmppStanzaNode* _tmp4_;
			XmppStanzaNode* _tmp5_;
			XmppStanzaNode* _tmp6_;
			XmppStanzaNode* _tmp7_;
			_tmp3_ = xmpp_stanza_node_new_build (XMPP_PRESENCE_STANZA_NODE_SHOW, "jabber:client", NULL, NULL);
			_xmpp_stanza_entry_unref0 (show_node);
			show_node = _tmp3_;
			_tmp4_ = ((XmppStanza*) self)->stanza;
			_tmp5_ = show_node;
			_tmp6_ = xmpp_stanza_node_put_node (_tmp4_, _tmp5_);
			_tmp7_ = _tmp6_;
			_xmpp_stanza_entry_unref0 (_tmp7_);
		}
		_tmp8_ = show_node;
		_tmp9_ = g_strdup (value);
		_g_free0 (((XmppStanzaEntry*) _tmp8_)->val);
		((XmppStanzaEntry*) _tmp8_)->val = _tmp9_;
		_xmpp_stanza_entry_unref0 (show_node);
	}
	g_object_notify_by_pspec ((GObject *) self, xmpp_presence_stanza_properties[XMPP_PRESENCE_STANZA_SHOW_PROPERTY]);
}

static const gchar*
xmpp_presence_stanza_real_get_type_ (XmppStanza* base)
{
	const gchar* result;
	XmppPresenceStanza* self;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	self = (XmppPresenceStanza*) base;
	_tmp1_ = XMPP_STANZA_CLASS (xmpp_presence_stanza_parent_class)->get_type_ (G_TYPE_CHECK_INSTANCE_CAST (self, XMPP_TYPE_STANZA, XmppStanza));
	_tmp0_ = _tmp1_;
	if (_tmp0_ == NULL) {
		_tmp0_ = XMPP_PRESENCE_STANZA_TYPE_AVAILABLE;
	}
	result = _tmp0_;
	return result;
}

static void
xmpp_presence_stanza_real_set_type_ (XmppStanza* base,
                                     const gchar* value)
{
	XmppPresenceStanza* self;
	self = (XmppPresenceStanza*) base;
	XMPP_STANZA_CLASS (xmpp_presence_stanza_parent_class)->set_type_ (G_TYPE_CHECK_INSTANCE_CAST (self, XMPP_TYPE_STANZA, XmppStanza), value);
	g_object_notify_by_pspec ((GObject *) self, xmpp_presence_stanza_properties[XMPP_PRESENCE_STANZA_TYPE__PROPERTY]);
}

static void
xmpp_presence_stanza_class_init (XmppPresenceStanzaClass * klass,
                                 gpointer klass_data)
{
	xmpp_presence_stanza_parent_class = g_type_class_peek_parent (klass);
	XMPP_STANZA_CLASS (klass)->get_type_ = (const gchar* (*) (XmppStanza*)) xmpp_presence_stanza_real_get_type_;
	XMPP_STANZA_CLASS (klass)->set_type_ = (void (*) (XmppStanza*, const gchar*)) xmpp_presence_stanza_real_set_type_;
	G_OBJECT_CLASS (klass)->get_property = _vala_xmpp_presence_stanza_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_xmpp_presence_stanza_set_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_PRESENCE_STANZA_PRIORITY_PROPERTY, xmpp_presence_stanza_properties[XMPP_PRESENCE_STANZA_PRIORITY_PROPERTY] = g_param_spec_int ("priority", "priority", "priority", 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_PRESENCE_STANZA_STATUS_PROPERTY, xmpp_presence_stanza_properties[XMPP_PRESENCE_STANZA_STATUS_PROPERTY] = g_param_spec_string ("status", "status", "status", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_PRESENCE_STANZA_SHOW_PROPERTY, xmpp_presence_stanza_properties[XMPP_PRESENCE_STANZA_SHOW_PROPERTY] = g_param_spec_string ("show", "show", "show", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_PRESENCE_STANZA_TYPE__PROPERTY, xmpp_presence_stanza_properties[XMPP_PRESENCE_STANZA_TYPE__PROPERTY] = g_param_spec_string ("type-", "type-", "type-", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
xmpp_presence_stanza_instance_init (XmppPresenceStanza * self,
                                    gpointer klass)
{
}

static GType
xmpp_presence_stanza_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppPresenceStanzaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_presence_stanza_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppPresenceStanza), 0, (GInstanceInitFunc) xmpp_presence_stanza_instance_init, NULL };
	GType xmpp_presence_stanza_type_id;
	xmpp_presence_stanza_type_id = g_type_register_static (XMPP_TYPE_STANZA, "XmppPresenceStanza", &g_define_type_info, 0);
	return xmpp_presence_stanza_type_id;
}

GType
xmpp_presence_stanza_get_type (void)
{
	static volatile gsize xmpp_presence_stanza_type_id__once = 0;
	if (g_once_init_enter (&xmpp_presence_stanza_type_id__once)) {
		GType xmpp_presence_stanza_type_id;
		xmpp_presence_stanza_type_id = xmpp_presence_stanza_get_type_once ();
		g_once_init_leave (&xmpp_presence_stanza_type_id__once, xmpp_presence_stanza_type_id);
	}
	return xmpp_presence_stanza_type_id__once;
}

static void
_vala_xmpp_presence_stanza_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	XmppPresenceStanza * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_PRESENCE_TYPE_STANZA, XmppPresenceStanza);
	switch (property_id) {
		case XMPP_PRESENCE_STANZA_PRIORITY_PROPERTY:
		g_value_set_int (value, xmpp_presence_stanza_get_priority (self));
		break;
		case XMPP_PRESENCE_STANZA_STATUS_PROPERTY:
		g_value_set_string (value, xmpp_presence_stanza_get_status (self));
		break;
		case XMPP_PRESENCE_STANZA_SHOW_PROPERTY:
		g_value_set_string (value, xmpp_presence_stanza_get_show (self));
		break;
		case XMPP_PRESENCE_STANZA_TYPE__PROPERTY:
		g_value_set_string (value, xmpp_stanza_get_type_ ((XmppStanza*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_xmpp_presence_stanza_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	XmppPresenceStanza * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_PRESENCE_TYPE_STANZA, XmppPresenceStanza);
	switch (property_id) {
		case XMPP_PRESENCE_STANZA_PRIORITY_PROPERTY:
		xmpp_presence_stanza_set_priority (self, g_value_get_int (value));
		break;
		case XMPP_PRESENCE_STANZA_STATUS_PROPERTY:
		xmpp_presence_stanza_set_status (self, g_value_get_string (value));
		break;
		case XMPP_PRESENCE_STANZA_SHOW_PROPERTY:
		xmpp_presence_stanza_set_show (self, g_value_get_string (value));
		break;
		case XMPP_PRESENCE_STANZA_TYPE__PROPERTY:
		xmpp_stanza_set_type_ ((XmppStanza*) self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

