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

#include "libdino.h"
#include <glib-object.h>
#include <glib.h>
#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.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  {
	DINO_BLOCKING_MANAGER_0_PROPERTY,
	DINO_BLOCKING_MANAGER_ID_PROPERTY,
	DINO_BLOCKING_MANAGER_NUM_PROPERTIES
};
static GParamSpec* dino_blocking_manager_properties[DINO_BLOCKING_MANAGER_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 _DinoBlockingManagerPrivate {
	DinoStreamInteractor* stream_interactor;
};

static gint DinoBlockingManager_private_offset;
static gpointer dino_blocking_manager_parent_class = NULL;
DinoModuleIdentity* dino_blocking_manager_IDENTITY = NULL;
static DinoStreamInteractionModuleIface * dino_blocking_manager_dino_stream_interaction_module_parent_iface = NULL;

static DinoBlockingManager* dino_blocking_manager_new (DinoStreamInteractor* stream_interactor);
static DinoBlockingManager* dino_blocking_manager_construct (GType object_type,
                                                      DinoStreamInteractor* stream_interactor);
static void dino_blocking_manager_finalize (GObject * obj);
static GType dino_blocking_manager_get_type_once (void);
static void _vala_dino_blocking_manager_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
dino_blocking_manager_get_instance_private (DinoBlockingManager* self)
{
	return G_STRUCT_MEMBER_P (self, DinoBlockingManager_private_offset);
}

void
dino_blocking_manager_start (DinoStreamInteractor* stream_interactor)
{
	DinoBlockingManager* m = NULL;
	DinoBlockingManager* _tmp0_;
	g_return_if_fail (stream_interactor != NULL);
	_tmp0_ = dino_blocking_manager_new (stream_interactor);
	m = _tmp0_;
	dino_stream_interactor_add_module (stream_interactor, (DinoStreamInteractionModule*) m);
	_g_object_unref0 (m);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static DinoBlockingManager*
dino_blocking_manager_construct (GType object_type,
                                 DinoStreamInteractor* stream_interactor)
{
	DinoBlockingManager * self = NULL;
	DinoStreamInteractor* _tmp0_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	self = (DinoBlockingManager*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	return self;
}

static DinoBlockingManager*
dino_blocking_manager_new (DinoStreamInteractor* stream_interactor)
{
	return dino_blocking_manager_construct (DINO_TYPE_BLOCKING_MANAGER, stream_interactor);
}

gboolean
dino_blocking_manager_is_blocked (DinoBlockingManager* self,
                                  DinoEntitiesAccount* account,
                                  XmppJid* jid)
{
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* _tmp1_;
	gboolean _tmp2_ = FALSE;
	XmppXmppStream* _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (account != NULL, FALSE);
	g_return_val_if_fail (jid != NULL, FALSE);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_stream_interactor_get_stream (_tmp0_, account);
	stream = _tmp1_;
	_tmp3_ = stream;
	if (_tmp3_ != NULL) {
		XmppXmppStream* _tmp4_;
		XmppModuleIdentity* _tmp5_;
		gpointer _tmp6_;
		XmppXepBlockingCommandModule* _tmp7_;
		XmppXmppStream* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp4_ = stream;
		_tmp5_ = xmpp_xep_blocking_command_module_IDENTITY;
		_tmp6_ = xmpp_xmpp_stream_get_module (_tmp4_, XMPP_XEP_BLOCKING_COMMAND_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp5_);
		_tmp7_ = (XmppXepBlockingCommandModule*) _tmp6_;
		_tmp8_ = stream;
		_tmp9_ = xmpp_jid_to_string (jid);
		_tmp10_ = _tmp9_;
		_tmp2_ = xmpp_xep_blocking_command_module_is_blocked (_tmp7_, _tmp8_, _tmp10_);
		_g_free0 (_tmp10_);
		_g_object_unref0 (_tmp7_);
	} else {
		_tmp2_ = FALSE;
	}
	result = _tmp2_;
	_g_object_unref0 (stream);
	return result;
}

void
dino_blocking_manager_block (DinoBlockingManager* self,
                             DinoEntitiesAccount* account,
                             XmppJid* jid)
{
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	XmppXepBlockingCommandModule* _tmp4_;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_stream_interactor_get_stream (_tmp0_, account);
	stream = _tmp1_;
	_tmp2_ = xmpp_xep_blocking_command_module_IDENTITY;
	_tmp3_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_BLOCKING_COMMAND_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (XmppXepBlockingCommandModule*) _tmp3_;
	_tmp5_ = xmpp_jid_to_string (jid);
	_tmp6_ = g_new0 (gchar*, 1 + 1);
	_tmp6_[0] = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp7__length1 = 1;
	xmpp_xep_blocking_command_module_block (_tmp4_, stream, _tmp7_, (gint) 1);
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (_tmp4_);
	_g_object_unref0 (stream);
}

void
dino_blocking_manager_unblock (DinoBlockingManager* self,
                               DinoEntitiesAccount* account,
                               XmppJid* jid)
{
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	XmppXepBlockingCommandModule* _tmp4_;
	gchar* _tmp5_;
	gchar** _tmp6_;
	gchar** _tmp7_;
	gint _tmp7__length1;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_stream_interactor_get_stream (_tmp0_, account);
	stream = _tmp1_;
	_tmp2_ = xmpp_xep_blocking_command_module_IDENTITY;
	_tmp3_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_BLOCKING_COMMAND_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (XmppXepBlockingCommandModule*) _tmp3_;
	_tmp5_ = xmpp_jid_to_string (jid);
	_tmp6_ = g_new0 (gchar*, 1 + 1);
	_tmp6_[0] = _tmp5_;
	_tmp7_ = _tmp6_;
	_tmp7__length1 = 1;
	xmpp_xep_blocking_command_module_unblock (_tmp4_, stream, _tmp7_, (gint) 1);
	_tmp7_ = (_vala_array_free (_tmp7_, _tmp7__length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (_tmp4_);
	_g_object_unref0 (stream);
}

gboolean
dino_blocking_manager_is_supported (DinoBlockingManager* self,
                                    DinoEntitiesAccount* account)
{
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* _tmp1_;
	gboolean _tmp2_ = FALSE;
	XmppXmppStream* _tmp3_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (account != NULL, FALSE);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_stream_interactor_get_stream (_tmp0_, account);
	stream = _tmp1_;
	_tmp3_ = stream;
	if (_tmp3_ != NULL) {
		XmppXmppStream* _tmp4_;
		XmppModuleIdentity* _tmp5_;
		gpointer _tmp6_;
		XmppXepBlockingCommandModule* _tmp7_;
		XmppXmppStream* _tmp8_;
		_tmp4_ = stream;
		_tmp5_ = xmpp_xep_blocking_command_module_IDENTITY;
		_tmp6_ = xmpp_xmpp_stream_get_module (_tmp4_, XMPP_XEP_BLOCKING_COMMAND_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp5_);
		_tmp7_ = (XmppXepBlockingCommandModule*) _tmp6_;
		_tmp8_ = stream;
		_tmp2_ = xmpp_xep_blocking_command_module_is_supported (_tmp7_, _tmp8_);
		_g_object_unref0 (_tmp7_);
	} else {
		_tmp2_ = FALSE;
	}
	result = _tmp2_;
	_g_object_unref0 (stream);
	return result;
}

static const gchar*
dino_blocking_manager_real_get_id (DinoStreamInteractionModule* base)
{
	const gchar* result;
	DinoBlockingManager* self;
	DinoModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (DinoBlockingManager*) base;
	_tmp0_ = dino_blocking_manager_IDENTITY;
	_tmp1_ = dino_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
dino_blocking_manager_class_init (DinoBlockingManagerClass * klass,
                                  gpointer klass_data)
{
	DinoModuleIdentity* _tmp0_;
	dino_blocking_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoBlockingManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_blocking_manager_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_blocking_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_BLOCKING_MANAGER_ID_PROPERTY, dino_blocking_manager_properties[DINO_BLOCKING_MANAGER_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = dino_module_identity_new (DINO_TYPE_BLOCKING_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, "blocking_manager");
	dino_blocking_manager_IDENTITY = _tmp0_;
}

static void
dino_blocking_manager_dino_stream_interaction_module_interface_init (DinoStreamInteractionModuleIface * iface,
                                                                     gpointer iface_data)
{
	dino_blocking_manager_dino_stream_interaction_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = dino_blocking_manager_real_get_id;
}

static void
dino_blocking_manager_instance_init (DinoBlockingManager * self,
                                     gpointer klass)
{
	self->priv = dino_blocking_manager_get_instance_private (self);
}

static void
dino_blocking_manager_finalize (GObject * obj)
{
	DinoBlockingManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_TYPE_BLOCKING_MANAGER, DinoBlockingManager);
	_g_object_unref0 (self->priv->stream_interactor);
	G_OBJECT_CLASS (dino_blocking_manager_parent_class)->finalize (obj);
}

static GType
dino_blocking_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoBlockingManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_blocking_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoBlockingManager), 0, (GInstanceInitFunc) dino_blocking_manager_instance_init, NULL };
	static const GInterfaceInfo dino_stream_interaction_module_info = { (GInterfaceInitFunc) dino_blocking_manager_dino_stream_interaction_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_blocking_manager_type_id;
	dino_blocking_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoBlockingManager", &g_define_type_info, 0);
	g_type_add_interface_static (dino_blocking_manager_type_id, DINO_TYPE_STREAM_INTERACTION_MODULE, &dino_stream_interaction_module_info);
	DinoBlockingManager_private_offset = g_type_add_instance_private (dino_blocking_manager_type_id, sizeof (DinoBlockingManagerPrivate));
	return dino_blocking_manager_type_id;
}

GType
dino_blocking_manager_get_type (void)
{
	static volatile gsize dino_blocking_manager_type_id__once = 0;
	if (g_once_init_enter (&dino_blocking_manager_type_id__once)) {
		GType dino_blocking_manager_type_id;
		dino_blocking_manager_type_id = dino_blocking_manager_get_type_once ();
		g_once_init_leave (&dino_blocking_manager_type_id__once, dino_blocking_manager_type_id);
	}
	return dino_blocking_manager_type_id__once;
}

static void
_vala_dino_blocking_manager_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec)
{
	DinoBlockingManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_TYPE_BLOCKING_MANAGER, DinoBlockingManager);
	switch (property_id) {
		case DINO_BLOCKING_MANAGER_ID_PROPERTY:
		g_value_set_string (value, dino_stream_interaction_module_get_id ((DinoStreamInteractionModule*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

