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

#include "xmpp-vala.h"
#include <gee.h>
#include <glib-object.h>
#include <glib.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 _xmpp_xep_jingle_content_thumbnails_thumbnail_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_jingle_content_thumbnails_thumbnail_unref (var), NULL)))
#define _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _XmppXepJingleContentThumbnailsParamSpecThumbnail XmppXepJingleContentThumbnailsParamSpecThumbnail;

struct _XmppXepJingleContentThumbnailsParamSpecThumbnail {
	GParamSpec parent_instance;
};

static gpointer xmpp_xep_jingle_content_thumbnails_thumbnail_parent_class = NULL;

static void xmpp_xep_jingle_content_thumbnails_thumbnail_finalize (XmppXepJingleContentThumbnailsThumbnail * obj);
static GType xmpp_xep_jingle_content_thumbnails_thumbnail_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

GeeList*
xmpp_xep_jingle_content_thumbnails_get_thumbnails (XmppStanzaNode* node)
{
	GeeArrayList* thumbnails = NULL;
	GeeArrayList* _tmp0_;
	GeeList* result;
	g_return_val_if_fail (node != NULL, NULL);
	_tmp0_ = gee_array_list_new (XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL, (GBoxedCopyFunc) xmpp_xep_jingle_content_thumbnails_thumbnail_ref, (GDestroyNotify) xmpp_xep_jingle_content_thumbnails_thumbnail_unref, NULL, NULL, NULL);
	thumbnails = _tmp0_;
	{
		GeeList* _thumbnail_node_list = NULL;
		GeeList* _tmp1_;
		gint _thumbnail_node_size = 0;
		GeeList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _thumbnail_node_index = 0;
		_tmp1_ = xmpp_stanza_node_get_subnodes (node, "thumbnail", XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_NS_URI, FALSE);
		_thumbnail_node_list = _tmp1_;
		_tmp2_ = _thumbnail_node_list;
		_tmp3_ = gee_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_thumbnail_node_size = _tmp4_;
		_thumbnail_node_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			XmppStanzaNode* thumbnail_node = NULL;
			GeeList* _tmp7_;
			gpointer _tmp8_;
			XmppXepJingleContentThumbnailsThumbnail* thumbnail = NULL;
			XmppStanzaNode* _tmp9_;
			XmppXepJingleContentThumbnailsThumbnail* _tmp10_;
			XmppXepJingleContentThumbnailsThumbnail* _tmp11_;
			_thumbnail_node_index = _thumbnail_node_index + 1;
			_tmp5_ = _thumbnail_node_index;
			_tmp6_ = _thumbnail_node_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _thumbnail_node_list;
			_tmp8_ = gee_list_get (_tmp7_, _thumbnail_node_index);
			thumbnail_node = (XmppStanzaNode*) _tmp8_;
			_tmp9_ = thumbnail_node;
			_tmp10_ = xmpp_xep_jingle_content_thumbnails_thumbnail_from_stanza_node (_tmp9_);
			thumbnail = _tmp10_;
			_tmp11_ = thumbnail;
			if (_tmp11_ != NULL) {
				GeeArrayList* _tmp12_;
				XmppXepJingleContentThumbnailsThumbnail* _tmp13_;
				_tmp12_ = thumbnails;
				_tmp13_ = thumbnail;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, _tmp13_);
			}
			_xmpp_xep_jingle_content_thumbnails_thumbnail_unref0 (thumbnail);
			_xmpp_stanza_entry_unref0 (thumbnail_node);
		}
		_g_object_unref0 (_thumbnail_node_list);
	}
	result = (GeeList*) thumbnails;
	return result;
}

XmppStanzaNode*
xmpp_xep_jingle_content_thumbnails_thumbnail_to_stanza_node (XmppXepJingleContentThumbnailsThumbnail* self)
{
	XmppStanzaNode* node = NULL;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	const gchar* _tmp4_;
	XmppStanzaNode* _tmp5_;
	XmppStanzaNode* _tmp6_;
	const gchar* _tmp7_;
	XmppStanzaNode* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = xmpp_stanza_node_new_build ("thumbnail", XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_NS_URI, NULL, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = xmpp_stanza_node_add_self_xmlns (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = self->uri;
	_tmp5_ = xmpp_stanza_node_put_attribute (_tmp3_, "uri", _tmp4_, NULL);
	_tmp6_ = _tmp5_;
	_xmpp_stanza_entry_unref0 (_tmp3_);
	_xmpp_stanza_entry_unref0 (_tmp1_);
	node = _tmp6_;
	_tmp7_ = self->media_type;
	if (_tmp7_ != NULL) {
		XmppStanzaNode* _tmp8_;
		const gchar* _tmp9_;
		XmppStanzaNode* _tmp10_;
		XmppStanzaNode* _tmp11_;
		_tmp8_ = node;
		_tmp9_ = self->media_type;
		_tmp10_ = xmpp_stanza_node_put_attribute (_tmp8_, "media-type", _tmp9_, NULL);
		_tmp11_ = _tmp10_;
		_xmpp_stanza_entry_unref0 (_tmp11_);
	}
	if (self->width != -1) {
		XmppStanzaNode* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		XmppStanzaNode* _tmp15_;
		XmppStanzaNode* _tmp16_;
		_tmp12_ = node;
		_tmp13_ = g_strdup_printf ("%i", self->width);
		_tmp14_ = _tmp13_;
		_tmp15_ = xmpp_stanza_node_put_attribute (_tmp12_, "width", _tmp14_, NULL);
		_tmp16_ = _tmp15_;
		_xmpp_stanza_entry_unref0 (_tmp16_);
		_g_free0 (_tmp14_);
	}
	if (self->height != -1) {
		XmppStanzaNode* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		XmppStanzaNode* _tmp20_;
		XmppStanzaNode* _tmp21_;
		_tmp17_ = node;
		_tmp18_ = g_strdup_printf ("%i", self->height);
		_tmp19_ = _tmp18_;
		_tmp20_ = xmpp_stanza_node_put_attribute (_tmp17_, "height", _tmp19_, NULL);
		_tmp21_ = _tmp20_;
		_xmpp_stanza_entry_unref0 (_tmp21_);
		_g_free0 (_tmp19_);
	}
	result = node;
	return result;
}

XmppXepJingleContentThumbnailsThumbnail*
xmpp_xep_jingle_content_thumbnails_thumbnail_from_stanza_node (XmppStanzaNode* node)
{
	XmppXepJingleContentThumbnailsThumbnail* thumbnail = NULL;
	XmppXepJingleContentThumbnailsThumbnail* _tmp0_;
	XmppXepJingleContentThumbnailsThumbnail* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	XmppXepJingleContentThumbnailsThumbnail* _tmp4_;
	const gchar* _tmp5_;
	XmppXepJingleContentThumbnailsThumbnail* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	XmppXepJingleContentThumbnailsThumbnail* _tmp9_;
	XmppXepJingleContentThumbnailsThumbnail* _tmp10_;
	XmppXepJingleContentThumbnailsThumbnail* result;
	g_return_val_if_fail (node != NULL, NULL);
	_tmp0_ = xmpp_xep_jingle_content_thumbnails_thumbnail_new ();
	thumbnail = _tmp0_;
	_tmp1_ = thumbnail;
	_tmp2_ = xmpp_stanza_node_get_attribute (node, "uri", NULL);
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (_tmp1_->uri);
	_tmp1_->uri = _tmp3_;
	_tmp4_ = thumbnail;
	_tmp5_ = _tmp4_->uri;
	if (_tmp5_ == NULL) {
		result = NULL;
		_xmpp_xep_jingle_content_thumbnails_thumbnail_unref0 (thumbnail);
		return result;
	}
	_tmp6_ = thumbnail;
	_tmp7_ = xmpp_stanza_node_get_attribute (node, "media-type", NULL);
	_tmp8_ = g_strdup (_tmp7_);
	_g_free0 (_tmp6_->media_type);
	_tmp6_->media_type = _tmp8_;
	_tmp9_ = thumbnail;
	_tmp9_->width = xmpp_stanza_node_get_attribute_int (node, "width", -1, NULL);
	_tmp10_ = thumbnail;
	_tmp10_->height = xmpp_stanza_node_get_attribute_int (node, "height", -1, NULL);
	result = thumbnail;
	return result;
}

XmppXepJingleContentThumbnailsThumbnail*
xmpp_xep_jingle_content_thumbnails_thumbnail_construct (GType object_type)
{
	XmppXepJingleContentThumbnailsThumbnail* self = NULL;
	self = (XmppXepJingleContentThumbnailsThumbnail*) g_type_create_instance (object_type);
	return self;
}

XmppXepJingleContentThumbnailsThumbnail*
xmpp_xep_jingle_content_thumbnails_thumbnail_new (void)
{
	return xmpp_xep_jingle_content_thumbnails_thumbnail_construct (XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL);
}

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

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

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

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

static gchar*
xmpp_xep_jingle_content_thumbnails_value_thumbnail_collect_value (GValue* value,
                                                                  guint n_collect_values,
                                                                  GTypeCValue* collect_values,
                                                                  guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		XmppXepJingleContentThumbnailsThumbnail * 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_xep_jingle_content_thumbnails_thumbnail_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
xmpp_xep_jingle_content_thumbnails_value_thumbnail_lcopy_value (const GValue* value,
                                                                guint n_collect_values,
                                                                GTypeCValue* collect_values,
                                                                guint collect_flags)
{
	XmppXepJingleContentThumbnailsThumbnail ** 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_xep_jingle_content_thumbnails_thumbnail_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
xmpp_xep_jingle_content_thumbnails_param_spec_thumbnail (const gchar* name,
                                                         const gchar* nick,
                                                         const gchar* blurb,
                                                         GType object_type,
                                                         GParamFlags flags)
{
	XmppXepJingleContentThumbnailsParamSpecThumbnail* spec;
	g_return_val_if_fail (g_type_is_a (object_type, XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL), 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_xep_jingle_content_thumbnails_value_get_thumbnail (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL), NULL);
	return value->data[0].v_pointer;
}

void
xmpp_xep_jingle_content_thumbnails_value_set_thumbnail (GValue* value,
                                                        gpointer v_object)
{
	XmppXepJingleContentThumbnailsThumbnail * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL));
		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_xep_jingle_content_thumbnails_thumbnail_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_xep_jingle_content_thumbnails_thumbnail_unref (old);
	}
}

void
xmpp_xep_jingle_content_thumbnails_value_take_thumbnail (GValue* value,
                                                         gpointer v_object)
{
	XmppXepJingleContentThumbnailsThumbnail * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL));
		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_xep_jingle_content_thumbnails_thumbnail_unref (old);
	}
}

static void
xmpp_xep_jingle_content_thumbnails_thumbnail_class_init (XmppXepJingleContentThumbnailsThumbnailClass * klass,
                                                         gpointer klass_data)
{
	xmpp_xep_jingle_content_thumbnails_thumbnail_parent_class = g_type_class_peek_parent (klass);
	((XmppXepJingleContentThumbnailsThumbnailClass *) klass)->finalize = xmpp_xep_jingle_content_thumbnails_thumbnail_finalize;
}

static void
xmpp_xep_jingle_content_thumbnails_thumbnail_instance_init (XmppXepJingleContentThumbnailsThumbnail * self,
                                                            gpointer klass)
{
	self->ref_count = 1;
}

static void
xmpp_xep_jingle_content_thumbnails_thumbnail_finalize (XmppXepJingleContentThumbnailsThumbnail * obj)
{
	XmppXepJingleContentThumbnailsThumbnail * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_TYPE_THUMBNAIL, XmppXepJingleContentThumbnailsThumbnail);
	g_signal_handlers_destroy (self);
	_g_free0 (self->uri);
	_g_free0 (self->media_type);
}

static GType
xmpp_xep_jingle_content_thumbnails_thumbnail_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_xep_jingle_content_thumbnails_value_thumbnail_init, xmpp_xep_jingle_content_thumbnails_value_thumbnail_free_value, xmpp_xep_jingle_content_thumbnails_value_thumbnail_copy_value, xmpp_xep_jingle_content_thumbnails_value_thumbnail_peek_pointer, "p", xmpp_xep_jingle_content_thumbnails_value_thumbnail_collect_value, "p", xmpp_xep_jingle_content_thumbnails_value_thumbnail_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepJingleContentThumbnailsThumbnailClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_jingle_content_thumbnails_thumbnail_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepJingleContentThumbnailsThumbnail), 0, (GInstanceInitFunc) xmpp_xep_jingle_content_thumbnails_thumbnail_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_xep_jingle_content_thumbnails_thumbnail_type_id;
	xmpp_xep_jingle_content_thumbnails_thumbnail_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppXepJingleContentThumbnailsThumbnail", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return xmpp_xep_jingle_content_thumbnails_thumbnail_type_id;
}

GType
xmpp_xep_jingle_content_thumbnails_thumbnail_get_type (void)
{
	static volatile gsize xmpp_xep_jingle_content_thumbnails_thumbnail_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_jingle_content_thumbnails_thumbnail_type_id__once)) {
		GType xmpp_xep_jingle_content_thumbnails_thumbnail_type_id;
		xmpp_xep_jingle_content_thumbnails_thumbnail_type_id = xmpp_xep_jingle_content_thumbnails_thumbnail_get_type_once ();
		g_once_init_leave (&xmpp_xep_jingle_content_thumbnails_thumbnail_type_id__once, xmpp_xep_jingle_content_thumbnails_thumbnail_type_id);
	}
	return xmpp_xep_jingle_content_thumbnails_thumbnail_type_id__once;
}

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

void
xmpp_xep_jingle_content_thumbnails_thumbnail_unref (gpointer instance)
{
	XmppXepJingleContentThumbnailsThumbnail * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_XEP_JINGLE_CONTENT_THUMBNAILS_THUMBNAIL_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

