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

#include <glib-object.h>
#include "libdino.h"
#include <glib.h>
#include "xmpp-vala.h"
#include <gtk/gtk.h>
#include "dino_i18n.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER (dino_ui_contact_details_permissions_provider_get_type ())
#define DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER, DinoUiContactDetailsPermissionsProvider))
#define DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER, DinoUiContactDetailsPermissionsProviderClass))
#define DINO_UI_CONTACT_DETAILS_IS_PERMISSIONS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER))
#define DINO_UI_CONTACT_DETAILS_IS_PERMISSIONS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER))
#define DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER, DinoUiContactDetailsPermissionsProviderClass))

typedef struct _DinoUiContactDetailsPermissionsProvider DinoUiContactDetailsPermissionsProvider;
typedef struct _DinoUiContactDetailsPermissionsProviderClass DinoUiContactDetailsPermissionsProviderClass;
typedef struct _DinoUiContactDetailsPermissionsProviderPrivate DinoUiContactDetailsPermissionsProviderPrivate;
enum  {
	DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_0_PROPERTY,
	DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_ID_PROPERTY,
	DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_TAB_PROPERTY,
	DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_NUM_PROPERTIES
};
static GParamSpec* dino_ui_contact_details_permissions_provider_properties[DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block23Data Block23Data;
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))

struct _DinoUiContactDetailsPermissionsProvider {
	GObject parent_instance;
	DinoUiContactDetailsPermissionsProviderPrivate * priv;
};

struct _DinoUiContactDetailsPermissionsProviderClass {
	GObjectClass parent_class;
};

struct _DinoUiContactDetailsPermissionsProviderPrivate {
	DinoStreamInteractor* stream_interactor;
};

struct _Block23Data {
	int _ref_count_;
	DinoUiContactDetailsPermissionsProvider* self;
	DinoEntitiesConversation* conversation;
};

static gint DinoUiContactDetailsPermissionsProvider_private_offset;
static gpointer dino_ui_contact_details_permissions_provider_parent_class = NULL;
static DinoPluginsContactDetailsProviderIface * dino_ui_contact_details_permissions_provider_dino_plugins_contact_details_provider_parent_iface = NULL;

VALA_EXTERN GType dino_ui_contact_details_permissions_provider_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiContactDetailsPermissionsProvider, g_object_unref)
VALA_EXTERN DinoUiContactDetailsPermissionsProvider* dino_ui_contact_details_permissions_provider_new (DinoStreamInteractor* stream_interactor);
VALA_EXTERN DinoUiContactDetailsPermissionsProvider* dino_ui_contact_details_permissions_provider_construct (GType object_type,
                                                                                                 DinoStreamInteractor* stream_interactor);
static void dino_ui_contact_details_permissions_provider_real_populate (DinoPluginsContactDetailsProvider* base,
                                                                 DinoEntitiesConversation* conversation,
                                                                 DinoPluginsContactDetails* contact_details,
                                                                 DinoPluginsWidgetType type);
static Block23Data* block23_data_ref (Block23Data* _data23_);
static void block23_data_unref (void * _userdata_);
static gboolean _xmpp_xep_muc_role_equal (const XmppXepMucRole * s1,
                                   const XmppXepMucRole * s2);
static void ___lambda197_ (Block23Data* _data23_);
static void ____lambda197__gtk_button_clicked (GtkButton* _sender,
                                        gpointer self);
static GObject* dino_ui_contact_details_permissions_provider_real_get_widget (DinoPluginsContactDetailsProvider* base,
                                                                       DinoEntitiesConversation* conversation);
static void dino_ui_contact_details_permissions_provider_finalize (GObject * obj);
static GType dino_ui_contact_details_permissions_provider_get_type_once (void);
static void _vala_dino_ui_contact_details_permissions_provider_get_property (GObject * object,
                                                                      guint property_id,
                                                                      GValue * value,
                                                                      GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_contact_details_permissions_provider_get_instance_private (DinoUiContactDetailsPermissionsProvider* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiContactDetailsPermissionsProvider_private_offset);
}

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

DinoUiContactDetailsPermissionsProvider*
dino_ui_contact_details_permissions_provider_construct (GType object_type,
                                                        DinoStreamInteractor* stream_interactor)
{
	DinoUiContactDetailsPermissionsProvider * self = NULL;
	DinoStreamInteractor* _tmp0_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	self = (DinoUiContactDetailsPermissionsProvider*) 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;
}

DinoUiContactDetailsPermissionsProvider*
dino_ui_contact_details_permissions_provider_new (DinoStreamInteractor* stream_interactor)
{
	return dino_ui_contact_details_permissions_provider_construct (DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER, stream_interactor);
}

static Block23Data*
block23_data_ref (Block23Data* _data23_)
{
	g_atomic_int_inc (&_data23_->_ref_count_);
	return _data23_;
}

static void
block23_data_unref (void * _userdata_)
{
	Block23Data* _data23_;
	_data23_ = (Block23Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data23_->_ref_count_)) {
		DinoUiContactDetailsPermissionsProvider* self;
		self = _data23_->self;
		_g_object_unref0 (_data23_->conversation);
		_g_object_unref0 (self);
		g_slice_free (Block23Data, _data23_);
	}
}

static gboolean
_xmpp_xep_muc_role_equal (const XmppXepMucRole * s1,
                          const XmppXepMucRole * s2)
{
	if (s1 == s2) {
		return TRUE;
	}
	if (s1 == NULL) {
		return FALSE;
	}
	if (s2 == NULL) {
		return FALSE;
	}
	return (*s1) == (*s2);
}

static void
___lambda197_ (Block23Data* _data23_)
{
	DinoUiContactDetailsPermissionsProvider* self;
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoMucManager* _tmp3_;
	DinoEntitiesAccount* _tmp4_;
	DinoEntitiesAccount* _tmp5_;
	XmppJid* _tmp6_;
	XmppJid* _tmp7_;
	self = _data23_->self;
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_muc_manager_IDENTITY;
	_tmp2_ = dino_stream_interactor_get_module (_tmp0_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp1_);
	_tmp3_ = (DinoMucManager*) _tmp2_;
	_tmp4_ = dino_entities_conversation_get_account (_data23_->conversation);
	_tmp5_ = _tmp4_;
	_tmp6_ = dino_entities_conversation_get_counterpart (_data23_->conversation);
	_tmp7_ = _tmp6_;
	dino_muc_manager_request_voice (_tmp3_, _tmp5_, _tmp7_);
	_g_object_unref0 (_tmp3_);
}

static void
____lambda197__gtk_button_clicked (GtkButton* _sender,
                                   gpointer self)
{
	___lambda197_ (self);
}

static void
dino_ui_contact_details_permissions_provider_real_populate (DinoPluginsContactDetailsProvider* base,
                                                            DinoEntitiesConversation* conversation,
                                                            DinoPluginsContactDetails* contact_details,
                                                            DinoPluginsWidgetType type)
{
	DinoUiContactDetailsPermissionsProvider * self;
	Block23Data* _data23_;
	DinoEntitiesConversation* _tmp0_;
	XmppJid* own_jid = NULL;
	DinoStreamInteractor* _tmp1_;
	DinoModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	DinoMucManager* _tmp4_;
	XmppJid* _tmp5_;
	XmppJid* _tmp6_;
	DinoEntitiesAccount* _tmp7_;
	DinoEntitiesAccount* _tmp8_;
	XmppJid* _tmp9_;
	XmppJid* _tmp10_;
	XmppJid* _tmp11_;
	DinoStreamInteractor* _tmp12_;
	DinoModuleIdentity* _tmp13_;
	gpointer _tmp14_;
	DinoMucManager* _tmp15_;
	XmppJid* _tmp16_;
	DinoEntitiesAccount* _tmp17_;
	DinoEntitiesAccount* _tmp18_;
	XmppXepMucRole* _tmp19_;
	XmppXepMucRole* _tmp20_;
	XmppXepMucRole _tmp21_;
	gboolean _tmp22_;
	self = (DinoUiContactDetailsPermissionsProvider*) base;
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (contact_details != NULL);
	_data23_ = g_slice_new0 (Block23Data);
	_data23_->_ref_count_ = 1;
	_data23_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data23_->conversation);
	_data23_->conversation = _tmp0_;
	if (type != DINO_PLUGINS_WIDGET_TYPE_GTK4) {
		block23_data_unref (_data23_);
		_data23_ = NULL;
		return;
	}
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = dino_muc_manager_IDENTITY;
	_tmp3_ = dino_stream_interactor_get_module (_tmp1_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (DinoMucManager*) _tmp3_;
	_tmp5_ = dino_entities_conversation_get_counterpart (_data23_->conversation);
	_tmp6_ = _tmp5_;
	_tmp7_ = dino_entities_conversation_get_account (_data23_->conversation);
	_tmp8_ = _tmp7_;
	_tmp9_ = dino_muc_manager_get_own_jid (_tmp4_, _tmp6_, _tmp8_);
	_tmp10_ = _tmp9_;
	_g_object_unref0 (_tmp4_);
	own_jid = _tmp10_;
	_tmp11_ = own_jid;
	if (_tmp11_ == NULL) {
		_xmpp_jid_unref0 (own_jid);
		block23_data_unref (_data23_);
		_data23_ = NULL;
		return;
	}
	_tmp12_ = self->priv->stream_interactor;
	_tmp13_ = dino_muc_manager_IDENTITY;
	_tmp14_ = dino_stream_interactor_get_module (_tmp12_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp13_);
	_tmp15_ = (DinoMucManager*) _tmp14_;
	_tmp16_ = own_jid;
	_tmp17_ = dino_entities_conversation_get_account (_data23_->conversation);
	_tmp18_ = _tmp17_;
	_tmp19_ = dino_muc_manager_get_role (_tmp15_, _tmp16_, _tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = XMPP_XEP_MUC_ROLE_VISITOR;
	_tmp22_ = _xmpp_xep_muc_role_equal (_tmp20_, &_tmp21_) == TRUE;
	_g_free0 (_tmp20_);
	_g_object_unref0 (_tmp15_);
	if (_tmp22_) {
		GtkButton* voice_request = NULL;
		const gchar* _tmp23_;
		GtkButton* _tmp24_;
		GtkButton* _tmp25_;
		const gchar* _tmp26_;
		GtkButton* _tmp27_;
		_tmp23_ = dino_gettext ("Request");
		_tmp24_ = (GtkButton*) gtk_button_new_with_label (_tmp23_);
		g_object_ref_sink (_tmp24_);
		voice_request = _tmp24_;
		_tmp25_ = voice_request;
		g_signal_connect_data (_tmp25_, "clicked", (GCallback) ____lambda197__gtk_button_clicked, block23_data_ref (_data23_), (GClosureNotify) block23_data_unref, 0);
		_tmp26_ = dino_gettext ("Request permission to send messages");
		_tmp27_ = voice_request;
		g_signal_emit_by_name (contact_details, "add", "Permissions", _tmp26_, "", (GObject*) _tmp27_);
		_g_object_unref0 (voice_request);
	}
	_xmpp_jid_unref0 (own_jid);
	block23_data_unref (_data23_);
	_data23_ = NULL;
}

static GObject*
dino_ui_contact_details_permissions_provider_real_get_widget (DinoPluginsContactDetailsProvider* base,
                                                              DinoEntitiesConversation* conversation)
{
	DinoUiContactDetailsPermissionsProvider * self;
	GObject* result;
	self = (DinoUiContactDetailsPermissionsProvider*) base;
	g_return_val_if_fail (conversation != NULL, NULL);
	result = NULL;
	return result;
}

static const gchar*
dino_ui_contact_details_permissions_provider_real_get_id (DinoPluginsContactDetailsProvider* base)
{
	const gchar* result;
	DinoUiContactDetailsPermissionsProvider* self;
	self = (DinoUiContactDetailsPermissionsProvider*) base;
	result = "permissions";
	return result;
}

static const gchar*
dino_ui_contact_details_permissions_provider_real_get_tab (DinoPluginsContactDetailsProvider* base)
{
	const gchar* result;
	DinoUiContactDetailsPermissionsProvider* self;
	self = (DinoUiContactDetailsPermissionsProvider*) base;
	result = "about";
	return result;
}

static void
dino_ui_contact_details_permissions_provider_class_init (DinoUiContactDetailsPermissionsProviderClass * klass,
                                                         gpointer klass_data)
{
	dino_ui_contact_details_permissions_provider_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiContactDetailsPermissionsProvider_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_ui_contact_details_permissions_provider_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_ui_contact_details_permissions_provider_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_ID_PROPERTY, dino_ui_contact_details_permissions_provider_properties[DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_TAB_PROPERTY, dino_ui_contact_details_permissions_provider_properties[DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_TAB_PROPERTY] = g_param_spec_string ("tab", "tab", "tab", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dino_ui_contact_details_permissions_provider_dino_plugins_contact_details_provider_interface_init (DinoPluginsContactDetailsProviderIface * iface,
                                                                                                   gpointer iface_data)
{
	dino_ui_contact_details_permissions_provider_dino_plugins_contact_details_provider_parent_iface = g_type_interface_peek_parent (iface);
	iface->populate = (void (*) (DinoPluginsContactDetailsProvider*, DinoEntitiesConversation*, DinoPluginsContactDetails*, DinoPluginsWidgetType)) dino_ui_contact_details_permissions_provider_real_populate;
	iface->get_widget = (GObject* (*) (DinoPluginsContactDetailsProvider*, DinoEntitiesConversation*)) dino_ui_contact_details_permissions_provider_real_get_widget;
	iface->get_id = dino_ui_contact_details_permissions_provider_real_get_id;
	iface->get_tab = dino_ui_contact_details_permissions_provider_real_get_tab;
}

static void
dino_ui_contact_details_permissions_provider_instance_init (DinoUiContactDetailsPermissionsProvider * self,
                                                            gpointer klass)
{
	self->priv = dino_ui_contact_details_permissions_provider_get_instance_private (self);
}

static void
dino_ui_contact_details_permissions_provider_finalize (GObject * obj)
{
	DinoUiContactDetailsPermissionsProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER, DinoUiContactDetailsPermissionsProvider);
	_g_object_unref0 (self->priv->stream_interactor);
	G_OBJECT_CLASS (dino_ui_contact_details_permissions_provider_parent_class)->finalize (obj);
}

static GType
dino_ui_contact_details_permissions_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiContactDetailsPermissionsProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_contact_details_permissions_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiContactDetailsPermissionsProvider), 0, (GInstanceInitFunc) dino_ui_contact_details_permissions_provider_instance_init, NULL };
	static const GInterfaceInfo dino_plugins_contact_details_provider_info = { (GInterfaceInitFunc) dino_ui_contact_details_permissions_provider_dino_plugins_contact_details_provider_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_ui_contact_details_permissions_provider_type_id;
	dino_ui_contact_details_permissions_provider_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoUiContactDetailsPermissionsProvider", &g_define_type_info, 0);
	g_type_add_interface_static (dino_ui_contact_details_permissions_provider_type_id, DINO_PLUGINS_TYPE_CONTACT_DETAILS_PROVIDER, &dino_plugins_contact_details_provider_info);
	DinoUiContactDetailsPermissionsProvider_private_offset = g_type_add_instance_private (dino_ui_contact_details_permissions_provider_type_id, sizeof (DinoUiContactDetailsPermissionsProviderPrivate));
	return dino_ui_contact_details_permissions_provider_type_id;
}

GType
dino_ui_contact_details_permissions_provider_get_type (void)
{
	static volatile gsize dino_ui_contact_details_permissions_provider_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_contact_details_permissions_provider_type_id__once)) {
		GType dino_ui_contact_details_permissions_provider_type_id;
		dino_ui_contact_details_permissions_provider_type_id = dino_ui_contact_details_permissions_provider_get_type_once ();
		g_once_init_leave (&dino_ui_contact_details_permissions_provider_type_id__once, dino_ui_contact_details_permissions_provider_type_id);
	}
	return dino_ui_contact_details_permissions_provider_type_id__once;
}

static void
_vala_dino_ui_contact_details_permissions_provider_get_property (GObject * object,
                                                                 guint property_id,
                                                                 GValue * value,
                                                                 GParamSpec * pspec)
{
	DinoUiContactDetailsPermissionsProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_UI_CONTACT_DETAILS_TYPE_PERMISSIONS_PROVIDER, DinoUiContactDetailsPermissionsProvider);
	switch (property_id) {
		case DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_ID_PROPERTY:
		g_value_set_string (value, dino_plugins_contact_details_provider_get_id ((DinoPluginsContactDetailsProvider*) self));
		break;
		case DINO_UI_CONTACT_DETAILS_PERMISSIONS_PROVIDER_TAB_PROPERTY:
		g_value_set_string (value, dino_plugins_contact_details_provider_get_tab ((DinoPluginsContactDetailsProvider*) 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;
}

