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

#include "xmpp-vala.h"
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.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_SERVICE_DISCOVERY_FLAG_0_PROPERTY,
	XMPP_XEP_SERVICE_DISCOVERY_FLAG_OWN_FEATURES_PROPERTY,
	XMPP_XEP_SERVICE_DISCOVERY_FLAG_OWN_IDENTITIES_PROPERTY,
	XMPP_XEP_SERVICE_DISCOVERY_FLAG_NUM_PROPERTIES
};
static GParamSpec* xmpp_xep_service_discovery_flag_properties[XMPP_XEP_SERVICE_DISCOVERY_FLAG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _XmppXepServiceDiscoveryFlagPrivate {
	GeeSet* own_features_;
	GeeSet* own_identities_;
};

static gint XmppXepServiceDiscoveryFlag_private_offset;
static gpointer xmpp_xep_service_discovery_flag_parent_class = NULL;
XmppFlagIdentity* xmpp_xep_service_discovery_flag_IDENTITY = NULL;

static guint _xmpp_xep_service_discovery_identity_hash_func_gee_hash_data_func (gconstpointer v,
                                                                         gpointer self);
static gboolean _xmpp_xep_service_discovery_identity_equals_func_gee_equal_data_func (gconstpointer a,
                                                                               gconstpointer b,
                                                                               gpointer self);
static gchar* xmpp_xep_service_discovery_flag_real_get_ns (XmppXmppStreamFlag* base);
static gchar* xmpp_xep_service_discovery_flag_real_get_id (XmppXmppStreamFlag* base);
static void xmpp_xep_service_discovery_flag_finalize (GObject * obj);
static GType xmpp_xep_service_discovery_flag_get_type_once (void);
static void _vala_xmpp_xep_service_discovery_flag_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
xmpp_xep_service_discovery_flag_get_instance_private (XmppXepServiceDiscoveryFlag* self)
{
	return G_STRUCT_MEMBER_P (self, XmppXepServiceDiscoveryFlag_private_offset);
}

static guint
_xmpp_xep_service_discovery_identity_hash_func_gee_hash_data_func (gconstpointer v,
                                                                   gpointer self)
{
	guint result;
	result = xmpp_xep_service_discovery_identity_hash_func ((XmppXepServiceDiscoveryIdentity*) v);
	return result;
}

static gboolean
_xmpp_xep_service_discovery_identity_equals_func_gee_equal_data_func (gconstpointer a,
                                                                      gconstpointer b,
                                                                      gpointer self)
{
	gboolean result;
	result = xmpp_xep_service_discovery_identity_equals_func ((XmppXepServiceDiscoveryIdentity*) a, (XmppXepServiceDiscoveryIdentity*) b);
	return result;
}

void
xmpp_xep_service_discovery_flag_add_own_feature (XmppXepServiceDiscoveryFlag* self,
                                                 const gchar* feature)
{
	GeeSet* _tmp0_;
	GeeSet* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (feature != NULL);
	_tmp0_ = self->priv->own_features_;
	if (gee_collection_contains ((GeeCollection*) _tmp0_, feature)) {
		gchar* _tmp1_;
		gchar* _tmp2_;
		_tmp1_ = g_strdup_printf ("Tried to add the feature %s a second time", feature);
		_tmp2_ = _tmp1_;
		g_warning ("flag.vala:24: %s", _tmp2_);
		_g_free0 (_tmp2_);
		return;
	}
	_tmp3_ = self->priv->own_features_;
	gee_collection_add ((GeeCollection*) _tmp3_, feature);
}

void
xmpp_xep_service_discovery_flag_remove_own_feature (XmppXepServiceDiscoveryFlag* self,
                                                    const gchar* feature)
{
	GeeSet* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (feature != NULL);
	_tmp0_ = self->priv->own_features_;
	gee_collection_remove ((GeeCollection*) _tmp0_, feature);
}

void
xmpp_xep_service_discovery_flag_add_own_identity (XmppXepServiceDiscoveryFlag* self,
                                                  XmppXepServiceDiscoveryIdentity* identity)
{
	GeeSet* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (identity != NULL);
	_tmp0_ = self->priv->own_identities_;
	gee_collection_add ((GeeCollection*) _tmp0_, identity);
}

void
xmpp_xep_service_discovery_flag_remove_own_identity (XmppXepServiceDiscoveryFlag* self,
                                                     XmppXepServiceDiscoveryIdentity* identity)
{
	GeeSet* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (identity != NULL);
	_tmp0_ = self->priv->own_identities_;
	gee_collection_remove ((GeeCollection*) _tmp0_, identity);
}

static gchar*
xmpp_xep_service_discovery_flag_real_get_ns (XmppXmppStreamFlag* base)
{
	XmppXepServiceDiscoveryFlag * self;
	gchar* _tmp0_;
	gchar* result;
	self = (XmppXepServiceDiscoveryFlag*) base;
	_tmp0_ = g_strdup (XMPP_XEP_SERVICE_DISCOVERY_NS_URI);
	result = _tmp0_;
	return result;
}

static gchar*
xmpp_xep_service_discovery_flag_real_get_id (XmppXmppStreamFlag* base)
{
	XmppXepServiceDiscoveryFlag * self;
	XmppFlagIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (XmppXepServiceDiscoveryFlag*) base;
	_tmp0_ = xmpp_xep_service_discovery_flag_IDENTITY;
	_tmp1_ = xmpp_flag_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

XmppXepServiceDiscoveryFlag*
xmpp_xep_service_discovery_flag_construct (GType object_type)
{
	XmppXepServiceDiscoveryFlag * self = NULL;
	self = (XmppXepServiceDiscoveryFlag*) xmpp_xmpp_stream_flag_construct (object_type);
	return self;
}

XmppXepServiceDiscoveryFlag*
xmpp_xep_service_discovery_flag_new (void)
{
	return xmpp_xep_service_discovery_flag_construct (XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG);
}

GeeList*
xmpp_xep_service_discovery_flag_get_own_features (XmppXepServiceDiscoveryFlag* self)
{
	GeeList* result;
	GeeArrayList* ret = NULL;
	GeeArrayList* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	ret = _tmp0_;
	{
		GeeIterator* _feature_it = NULL;
		GeeSet* _tmp1_;
		GeeIterator* _tmp2_;
		_tmp1_ = self->priv->own_features_;
		_tmp2_ = gee_iterable_iterator ((GeeIterable*) _tmp1_);
		_feature_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			gchar* feature = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			GeeArrayList* _tmp6_;
			const gchar* _tmp7_;
			_tmp3_ = _feature_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _feature_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			feature = (gchar*) _tmp5_;
			_tmp6_ = ret;
			_tmp7_ = feature;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp6_, _tmp7_);
			_g_free0 (feature);
		}
		_g_object_unref0 (_feature_it);
	}
	result = (GeeList*) ret;
	return result;
}

GeeSet*
xmpp_xep_service_discovery_flag_get_own_identities (XmppXepServiceDiscoveryFlag* self)
{
	GeeSet* result;
	GeeSet* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->own_identities_;
	_tmp1_ = gee_set_get_read_only_view (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
xmpp_xep_service_discovery_flag_class_init (XmppXepServiceDiscoveryFlagClass * klass,
                                            gpointer klass_data)
{
	XmppFlagIdentity* _tmp0_;
	xmpp_xep_service_discovery_flag_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &XmppXepServiceDiscoveryFlag_private_offset);
	((XmppXmppStreamFlagClass *) klass)->get_ns = (gchar* (*) (XmppXmppStreamFlag*)) xmpp_xep_service_discovery_flag_real_get_ns;
	((XmppXmppStreamFlagClass *) klass)->get_id = (gchar* (*) (XmppXmppStreamFlag*)) xmpp_xep_service_discovery_flag_real_get_id;
	G_OBJECT_CLASS (klass)->get_property = _vala_xmpp_xep_service_discovery_flag_get_property;
	G_OBJECT_CLASS (klass)->finalize = xmpp_xep_service_discovery_flag_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_SERVICE_DISCOVERY_FLAG_OWN_FEATURES_PROPERTY, xmpp_xep_service_discovery_flag_properties[XMPP_XEP_SERVICE_DISCOVERY_FLAG_OWN_FEATURES_PROPERTY] = g_param_spec_object ("own-features", "own-features", "own-features", GEE_TYPE_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), XMPP_XEP_SERVICE_DISCOVERY_FLAG_OWN_IDENTITIES_PROPERTY, xmpp_xep_service_discovery_flag_properties[XMPP_XEP_SERVICE_DISCOVERY_FLAG_OWN_IDENTITIES_PROPERTY] = g_param_spec_object ("own-identities", "own-identities", "own-identities", GEE_TYPE_SET, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = xmpp_flag_identity_new (XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, XMPP_XEP_SERVICE_DISCOVERY_NS_URI, "service_discovery");
	xmpp_xep_service_discovery_flag_IDENTITY = _tmp0_;
}

static void
xmpp_xep_service_discovery_flag_instance_init (XmppXepServiceDiscoveryFlag * self,
                                               gpointer klass)
{
	GeeHashSet* _tmp0_;
	GeeHashSet* _tmp1_;
	self->priv = xmpp_xep_service_discovery_flag_get_instance_private (self);
	_tmp0_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->own_features_ = (GeeSet*) _tmp0_;
	_tmp1_ = gee_hash_set_new (XMPP_XEP_SERVICE_DISCOVERY_TYPE_IDENTITY, (GBoxedCopyFunc) xmpp_xep_service_discovery_identity_ref, (GDestroyNotify) xmpp_xep_service_discovery_identity_unref, _xmpp_xep_service_discovery_identity_hash_func_gee_hash_data_func, NULL, NULL, _xmpp_xep_service_discovery_identity_equals_func_gee_equal_data_func, NULL, NULL);
	self->priv->own_identities_ = (GeeSet*) _tmp1_;
}

static void
xmpp_xep_service_discovery_flag_finalize (GObject * obj)
{
	XmppXepServiceDiscoveryFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG, XmppXepServiceDiscoveryFlag);
	_g_object_unref0 (self->priv->own_features_);
	_g_object_unref0 (self->priv->own_identities_);
	G_OBJECT_CLASS (xmpp_xep_service_discovery_flag_parent_class)->finalize (obj);
}

static GType
xmpp_xep_service_discovery_flag_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (XmppXepServiceDiscoveryFlagClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) xmpp_xep_service_discovery_flag_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (XmppXepServiceDiscoveryFlag), 0, (GInstanceInitFunc) xmpp_xep_service_discovery_flag_instance_init, NULL };
	GType xmpp_xep_service_discovery_flag_type_id;
	xmpp_xep_service_discovery_flag_type_id = g_type_register_static (XMPP_TYPE_XMPP_STREAM_FLAG, "XmppXepServiceDiscoveryFlag", &g_define_type_info, 0);
	XmppXepServiceDiscoveryFlag_private_offset = g_type_add_instance_private (xmpp_xep_service_discovery_flag_type_id, sizeof (XmppXepServiceDiscoveryFlagPrivate));
	return xmpp_xep_service_discovery_flag_type_id;
}

GType
xmpp_xep_service_discovery_flag_get_type (void)
{
	static volatile gsize xmpp_xep_service_discovery_flag_type_id__once = 0;
	if (g_once_init_enter (&xmpp_xep_service_discovery_flag_type_id__once)) {
		GType xmpp_xep_service_discovery_flag_type_id;
		xmpp_xep_service_discovery_flag_type_id = xmpp_xep_service_discovery_flag_get_type_once ();
		g_once_init_leave (&xmpp_xep_service_discovery_flag_type_id__once, xmpp_xep_service_discovery_flag_type_id);
	}
	return xmpp_xep_service_discovery_flag_type_id__once;
}

static void
_vala_xmpp_xep_service_discovery_flag_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	XmppXepServiceDiscoveryFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, XMPP_XEP_SERVICE_DISCOVERY_TYPE_FLAG, XmppXepServiceDiscoveryFlag);
	switch (property_id) {
		case XMPP_XEP_SERVICE_DISCOVERY_FLAG_OWN_FEATURES_PROPERTY:
		g_value_take_object (value, xmpp_xep_service_discovery_flag_get_own_features (self));
		break;
		case XMPP_XEP_SERVICE_DISCOVERY_FLAG_OWN_IDENTITIES_PROPERTY:
		g_value_take_object (value, xmpp_xep_service_discovery_flag_get_own_identities (self));
		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;
}

