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

#include "xmpp-vala.h"
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <string.h>
#include <stdlib.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

enum  {
	XMPP_TLS_XMPP_STREAM_0_PROPERTY,
	XMPP_TLS_XMPP_STREAM_NUM_PROPERTIES
};
static GParamSpec* xmpp_tls_xmpp_stream_properties[XMPP_TLS_XMPP_STREAM_NUM_PROPERTIES];
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
typedef struct _XmppTlsXmppStreamParamSpecOnInvalidCertWrapper XmppTlsXmppStreamParamSpecOnInvalidCertWrapper;

struct _XmppTlsXmppStreamParamSpecOnInvalidCertWrapper {
	GParamSpec parent_instance;
};

static gpointer xmpp_tls_xmpp_stream_parent_class = NULL;
static gpointer xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_parent_class = NULL;

static GTlsCertificateFlags* _g_tls_certificate_flags_dup (GTlsCertificateFlags* self);
static void xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_finalize (XmppTlsXmppStreamOnInvalidCertWrapper * obj);
static GType xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_get_type_once (void);
static void xmpp_tls_xmpp_stream_finalize (GObject * obj);
static GType xmpp_tls_xmpp_stream_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

XmppTlsXmppStream*
xmpp_tls_xmpp_stream_construct (GType object_type,
                                XmppJid* remote_name)
{
	XmppTlsXmppStream * self = NULL;
	g_return_val_if_fail (remote_name != NULL, NULL);
	self = (XmppTlsXmppStream*) xmpp_io_xmpp_stream_construct (object_type, remote_name, NULL);
	return self;
}

static GTlsCertificateFlags*
_g_tls_certificate_flags_dup (GTlsCertificateFlags* self)
{
	GTlsCertificateFlags* dup;
	dup = g_new0 (GTlsCertificateFlags, 1);
	memcpy (dup, self, sizeof (GTlsCertificateFlags));
	return dup;
}

static gpointer
__g_tls_certificate_flags_dup0 (gpointer self)
{
	return self ? _g_tls_certificate_flags_dup (self) : NULL;
}

gboolean
xmpp_tls_xmpp_stream_on_invalid_certificate (XmppTlsXmppStream* self,
                                             GTlsCertificate* peer_cert,
                                             GTlsCertificateFlags errors)
{
	GTlsCertificateFlags* _tmp0_;
	gchar* error_str = NULL;
	gchar* _tmp1_;
	GTlsCertificateFlags* _tmp2_;
	XmppJid* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	const gchar* _tmp11_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (peer_cert != NULL, FALSE);
	_tmp0_ = __g_tls_certificate_flags_dup0 (&errors);
	_g_free0 (self->errors);
	self->errors = _tmp0_;
	_tmp1_ = g_strdup ("");
	error_str = _tmp1_;
	_tmp2_ = g_new0 (GTlsCertificateFlags, 8);
	_tmp2_[0] = G_TLS_CERTIFICATE_UNKNOWN_CA;
	_tmp2_[1] = G_TLS_CERTIFICATE_BAD_IDENTITY;
	_tmp2_[2] = G_TLS_CERTIFICATE_NOT_ACTIVATED;
	_tmp2_[3] = G_TLS_CERTIFICATE_EXPIRED;
	_tmp2_[4] = G_TLS_CERTIFICATE_REVOKED;
	_tmp2_[5] = G_TLS_CERTIFICATE_INSECURE;
	_tmp2_[6] = G_TLS_CERTIFICATE_GENERIC_ERROR;
	_tmp2_[7] = G_TLS_CERTIFICATE_VALIDATE_ALL;
	{
		GTlsCertificateFlags* f_collection = NULL;
		gint f_collection_length1 = 0;
		gint _f_collection_size_ = 0;
		gint f_it = 0;
		f_collection = _tmp2_;
		f_collection_length1 = 8;
		for (f_it = 0; f_it < f_collection_length1; f_it = f_it + 1) {
			GTlsCertificateFlags f = 0U;
			f = f_collection[f_it];
			{
				if ((errors & f) == f) {
					const gchar* _tmp3_;
					GFlagsValue* _tmp4_;
					gchar* _tmp5_;
					gchar* _tmp6_;
					gchar* _tmp7_;
					_tmp3_ = error_str;
					_tmp4_ = g_flags_get_first_value (g_type_class_ref (g_tls_certificate_flags_get_type ()), f);
					_tmp5_ = g_strconcat ((_tmp4_ != NULL) ? _tmp4_->value_name : NULL, ", ", NULL);
					_tmp6_ = _tmp5_;
					_tmp7_ = g_strconcat (_tmp3_, _tmp6_, NULL);
					_g_free0 (error_str);
					error_str = _tmp7_;
					_g_free0 (_tmp6_);
				}
			}
		}
		f_collection = (g_free (f_collection), NULL);
	}
	_tmp8_ = ((XmppXmppStream*) self)->remote_name;
	_tmp9_ = xmpp_jid_to_string (_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = error_str;
	g_warning ("tls_xmpp_stream.vala:28: [%p, %s] Tls Certificate Errors: %s", self, _tmp10_, _tmp11_);
	_g_free0 (_tmp10_);
	result = FALSE;
	_g_free0 (error_str);
	return result;
}

XmppTlsXmppStreamOnInvalidCertWrapper*
xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_construct (GType object_type,
                                                        XmppTlsXmppStreamOnInvalidCert func,
                                                        gpointer func_target,
                                                        GDestroyNotify func_target_destroy_notify)
{
	XmppTlsXmppStreamOnInvalidCertWrapper* self = NULL;
	XmppTlsXmppStreamOnInvalidCert _tmp0_;
	gpointer _tmp0__target;
	GDestroyNotify _tmp0__target_destroy_notify;
	self = (XmppTlsXmppStreamOnInvalidCertWrapper*) g_type_create_instance (object_type);
	_tmp0_ = func;
	_tmp0__target = func_target;
	_tmp0__target_destroy_notify = func_target_destroy_notify;
	func = NULL;
	func_target = NULL;
	func_target_destroy_notify = NULL;
	(self->func_target_destroy_notify == NULL) ? NULL : (self->func_target_destroy_notify (self->func_target), NULL);
	self->func = NULL;
	self->func_target = NULL;
	self->func_target_destroy_notify = NULL;
	self->func = _tmp0_;
	self->func_target = _tmp0__target;
	self->func_target_destroy_notify = _tmp0__target_destroy_notify;
	(func_target_destroy_notify == NULL) ? NULL : (func_target_destroy_notify (func_target), NULL);
	func = NULL;
	func_target = NULL;
	func_target_destroy_notify = NULL;
	return self;
}

XmppTlsXmppStreamOnInvalidCertWrapper*
xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_new (XmppTlsXmppStreamOnInvalidCert func,
                                                  gpointer func_target,
                                                  GDestroyNotify func_target_destroy_notify)
{
	return xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_construct (XMPP_TLS_XMPP_STREAM_TYPE_ON_INVALID_CERT_WRAPPER, func, func_target, func_target_destroy_notify);
}

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

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

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

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

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

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

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

void
xmpp_tls_xmpp_stream_value_set_on_invalid_cert_wrapper (GValue* value,
                                                        gpointer v_object)
{
	XmppTlsXmppStreamOnInvalidCertWrapper * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, XMPP_TLS_XMPP_STREAM_TYPE_ON_INVALID_CERT_WRAPPER));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, XMPP_TLS_XMPP_STREAM_TYPE_ON_INVALID_CERT_WRAPPER));
		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_tls_xmpp_stream_on_invalid_cert_wrapper_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_unref (old);
	}
}

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

static void
xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_class_init (XmppTlsXmppStreamOnInvalidCertWrapperClass * klass,
                                                         gpointer klass_data)
{
	xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_parent_class = g_type_class_peek_parent (klass);
	((XmppTlsXmppStreamOnInvalidCertWrapperClass *) klass)->finalize = xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_finalize;
}

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

static void
xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_finalize (XmppTlsXmppStreamOnInvalidCertWrapper * obj)
{
	XmppTlsXmppStreamOnInvalidCertWrapper * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_TLS_XMPP_STREAM_TYPE_ON_INVALID_CERT_WRAPPER, XmppTlsXmppStreamOnInvalidCertWrapper);
	g_signal_handlers_destroy (self);
	(self->func_target_destroy_notify == NULL) ? NULL : (self->func_target_destroy_notify (self->func_target), NULL);
	self->func = NULL;
	self->func_target = NULL;
	self->func_target_destroy_notify = NULL;
}

static GType
xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { xmpp_tls_xmpp_stream_value_on_invalid_cert_wrapper_init, xmpp_tls_xmpp_stream_value_on_invalid_cert_wrapper_free_value, xmpp_tls_xmpp_stream_value_on_invalid_cert_wrapper_copy_value, xmpp_tls_xmpp_stream_value_on_invalid_cert_wrapper_peek_pointer, "p", xmpp_tls_xmpp_stream_value_on_invalid_cert_wrapper_collect_value, "p", xmpp_tls_xmpp_stream_value_on_invalid_cert_wrapper_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (XmppTlsXmppStreamOnInvalidCertWrapperClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppTlsXmppStreamOnInvalidCertWrapper), 0, (GInstanceInitFunc) xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_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_tls_xmpp_stream_on_invalid_cert_wrapper_type_id;
	xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id = g_type_register_fundamental (g_type_fundamental_next (), "XmppTlsXmppStreamOnInvalidCertWrapper", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id;
}

GType
xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_get_type (void)
{
	static volatile gsize xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id__once = 0;
	if (g_once_init_enter (&xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id__once)) {
		GType xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id;
		xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id = xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_get_type_once ();
		g_once_init_leave (&xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id__once, xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id);
	}
	return xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_type_id__once;
}

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

void
xmpp_tls_xmpp_stream_on_invalid_cert_wrapper_unref (gpointer instance)
{
	XmppTlsXmppStreamOnInvalidCertWrapper * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		XMPP_TLS_XMPP_STREAM_ON_INVALID_CERT_WRAPPER_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
xmpp_tls_xmpp_stream_class_init (XmppTlsXmppStreamClass * klass,
                                 gpointer klass_data)
{
	xmpp_tls_xmpp_stream_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->finalize = xmpp_tls_xmpp_stream_finalize;
}

static void
xmpp_tls_xmpp_stream_instance_init (XmppTlsXmppStream * self,
                                    gpointer klass)
{
}

static void
xmpp_tls_xmpp_stream_finalize (GObject * obj)
{
	XmppTlsXmppStream * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_TYPE_TLS_XMPP_STREAM, XmppTlsXmppStream);
	_g_free0 (self->errors);
	G_OBJECT_CLASS (xmpp_tls_xmpp_stream_parent_class)->finalize (obj);
}

static GType
xmpp_tls_xmpp_stream_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppTlsXmppStreamClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_tls_xmpp_stream_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppTlsXmppStream), 0, (GInstanceInitFunc) xmpp_tls_xmpp_stream_instance_init, NULL };
	GType xmpp_tls_xmpp_stream_type_id;
	xmpp_tls_xmpp_stream_type_id = g_type_register_static (XMPP_TYPE_IO_XMPP_STREAM, "XmppTlsXmppStream", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return xmpp_tls_xmpp_stream_type_id;
}

GType
xmpp_tls_xmpp_stream_get_type (void)
{
	static volatile gsize xmpp_tls_xmpp_stream_type_id__once = 0;
	if (g_once_init_enter (&xmpp_tls_xmpp_stream_type_id__once)) {
		GType xmpp_tls_xmpp_stream_type_id;
		xmpp_tls_xmpp_stream_type_id = xmpp_tls_xmpp_stream_get_type_once ();
		g_once_init_leave (&xmpp_tls_xmpp_stream_type_id__once, xmpp_tls_xmpp_stream_type_id);
	}
	return xmpp_tls_xmpp_stream_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;
}

