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

/*
 * Copyright (c) 2024-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_core.h"
#include <glib.h>
#include <glib-object.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  {
	FT_LOCK_SCREEN_0_PROPERTY,
	FT_LOCK_SCREEN_ACTIVE_PROPERTY,
	FT_LOCK_SCREEN_NUM_PROPERTIES
};
static GParamSpec* ft_lock_screen_properties[FT_LOCK_SCREEN_NUM_PROPERTIES];

struct _FtLockScreenPrivate {
	gboolean _active;
};

static gint FtLockScreen_private_offset;
static gpointer ft_lock_screen_parent_class = NULL;

static GType ft_lock_screen_provider_get_type_once (void);
static void ft_lock_screen_update_active (FtLockScreen* self);
static void ft_lock_screen_on_notify_active (FtLockScreen* self,
                                      GObject* object,
                                      GParamSpec* pspec);
static void ft_lock_screen_real_initialize (FtProvidedObject* base);
static void ft_lock_screen_real_setup_providers (FtProvidedObject* base);
static void ft_lock_screen_real_provider_enabled (FtProvidedObject* base,
                                           FtLockScreenProvider* provider);
static void _ft_lock_screen_on_notify_active_g_object_notify (GObject* _sender,
                                                       GParamSpec* pspec,
                                                       gpointer self);
static void ft_lock_screen_real_provider_disabled (FtProvidedObject* base,
                                            FtLockScreenProvider* provider);
static GObject * ft_lock_screen_constructor (GType type,
                                      guint n_construct_properties,
                                      GObjectConstructParam * construct_properties);
static void ft_lock_screen_finalize (GObject * obj);
static GType ft_lock_screen_get_type_once (void);
static void _vala_ft_lock_screen_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

void
ft_lock_screen_provider_activate (FtLockScreenProvider* self)
{
	FtLockScreenProviderIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = FT_LOCK_SCREEN_PROVIDER_GET_INTERFACE (self);
	if (_iface_->activate) {
		_iface_->activate (self);
	}
}

gboolean
ft_lock_screen_provider_get_active (FtLockScreenProvider* self)
{
	FtLockScreenProviderIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = FT_LOCK_SCREEN_PROVIDER_GET_INTERFACE (self);
	if (_iface_->get_active) {
		return _iface_->get_active (self);
	}
	return FALSE;
}

static void
ft_lock_screen_provider_default_init (FtLockScreenProviderIface * iface,
                                      gpointer iface_data)
{
	g_object_interface_install_property (iface, g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static GType
ft_lock_screen_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtLockScreenProviderIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_lock_screen_provider_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType ft_lock_screen_provider_type_id;
	ft_lock_screen_provider_type_id = g_type_register_static (G_TYPE_INTERFACE, "FtLockScreenProvider", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (ft_lock_screen_provider_type_id, FT_TYPE_PROVIDER);
	return ft_lock_screen_provider_type_id;
}

GType
ft_lock_screen_provider_get_type (void)
{
	static volatile gsize ft_lock_screen_provider_type_id__once = 0;
	if (g_once_init_enter (&ft_lock_screen_provider_type_id__once)) {
		GType ft_lock_screen_provider_type_id;
		ft_lock_screen_provider_type_id = ft_lock_screen_provider_get_type_once ();
		g_once_init_leave (&ft_lock_screen_provider_type_id__once, ft_lock_screen_provider_type_id);
	}
	return ft_lock_screen_provider_type_id__once;
}

static inline gpointer
ft_lock_screen_get_instance_private (FtLockScreen* self)
{
	return G_STRUCT_MEMBER_P (self, FtLockScreen_private_offset);
}

static void
ft_lock_screen_update_active (FtLockScreen* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gconstpointer _tmp2_;
	gconstpointer _tmp3_;
	gboolean active = FALSE;
	g_return_if_fail (self != NULL);
	_tmp2_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp3_ = _tmp2_;
	if (((FtLockScreenProvider*) _tmp3_) != NULL) {
		gconstpointer _tmp4_;
		gconstpointer _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp4_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
		_tmp5_ = _tmp4_;
		_tmp6_ = ft_provider_get_enabled ((FtProvider*) ((FtLockScreenProvider*) _tmp5_));
		_tmp7_ = _tmp6_;
		_tmp1_ = _tmp7_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gconstpointer _tmp8_;
		gconstpointer _tmp9_;
		gboolean _tmp10_;
		gboolean _tmp11_;
		_tmp8_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
		_tmp9_ = _tmp8_;
		_tmp10_ = ft_lock_screen_provider_get_active ((FtLockScreenProvider*) _tmp9_);
		_tmp11_ = _tmp10_;
		_tmp0_ = _tmp11_;
	} else {
		_tmp0_ = FALSE;
	}
	active = _tmp0_;
	if (self->priv->_active != active) {
		self->priv->_active = active;
		g_object_notify ((GObject*) self, "active");
	}
}

static void
ft_lock_screen_on_notify_active (FtLockScreen* self,
                                 GObject* object,
                                 GParamSpec* pspec)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	g_return_if_fail (pspec != NULL);
	ft_lock_screen_update_active (self);
}

static void
ft_lock_screen_real_initialize (FtProvidedObject* base)
{
	FtLockScreen * self;
	self = (FtLockScreen*) base;
}

static void
ft_lock_screen_real_setup_providers (FtProvidedObject* base)
{
	FtLockScreen * self;
	self = (FtLockScreen*) base;
}

static void
_ft_lock_screen_on_notify_active_g_object_notify (GObject* _sender,
                                                  GParamSpec* pspec,
                                                  gpointer self)
{
	ft_lock_screen_on_notify_active ((FtLockScreen*) self, _sender, pspec);
}

static void
ft_lock_screen_real_provider_enabled (FtProvidedObject* base,
                                      FtLockScreenProvider* provider)
{
	FtLockScreen * self;
	self = (FtLockScreen*) base;
	g_return_if_fail (provider != NULL);
	g_signal_connect_object ((GObject*) provider, "notify::active", (GCallback) _ft_lock_screen_on_notify_active_g_object_notify, self, 0);
	ft_lock_screen_update_active (self);
}

static void
ft_lock_screen_real_provider_disabled (FtProvidedObject* base,
                                       FtLockScreenProvider* provider)
{
	FtLockScreen * self;
	guint _tmp0_;
	GQuark _tmp1_;
	self = (FtLockScreen*) base;
	g_return_if_fail (provider != NULL);
	g_signal_parse_name ("notify::active", G_TYPE_OBJECT, &_tmp0_, &_tmp1_, TRUE);
	g_signal_handlers_disconnect_matched ((GObject*) provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, _tmp1_, NULL, (GCallback) _ft_lock_screen_on_notify_active_g_object_notify, self);
	ft_lock_screen_update_active (self);
}

void
ft_lock_screen_activate (FtLockScreen* self)
{
	gboolean _tmp0_ = FALSE;
	gconstpointer _tmp1_;
	gconstpointer _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp1_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp2_ = _tmp1_;
	if (((FtLockScreenProvider*) _tmp2_) != NULL) {
		gconstpointer _tmp3_;
		gconstpointer _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp3_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
		_tmp4_ = _tmp3_;
		_tmp5_ = ft_provider_get_enabled ((FtProvider*) ((FtLockScreenProvider*) _tmp4_));
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gconstpointer _tmp7_;
		gconstpointer _tmp8_;
		_tmp7_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
		_tmp8_ = _tmp7_;
		ft_lock_screen_provider_activate ((FtLockScreenProvider*) _tmp8_);
	} else {
		g_debug ("lock-screen.vala:74: Unable to activate lock-screen: no provider");
	}
}

FtLockScreen*
ft_lock_screen_construct (GType object_type)
{
	FtLockScreen * self = NULL;
	self = (FtLockScreen*) ft_provided_object_construct (object_type, FT_TYPE_LOCK_SCREEN_PROVIDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref);
	return self;
}

FtLockScreen*
ft_lock_screen_new (void)
{
	return ft_lock_screen_construct (FT_TYPE_LOCK_SCREEN);
}

gboolean
ft_lock_screen_get_active (FtLockScreen* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_active;
	return result;
}

static GObject *
ft_lock_screen_constructor (GType type,
                            guint n_construct_properties,
                            GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	static GWeakRef FtLockScreen_singleton__ref;
	static GMutex FtLockScreen_singleton__lock;
	FtLockScreen * self;
	g_mutex_lock (&FtLockScreen_singleton__lock);
	obj = g_weak_ref_get (&FtLockScreen_singleton__ref);
	if (obj != NULL) {
		g_mutex_unlock (&FtLockScreen_singleton__lock);
		return obj;
	}
	parent_class = G_OBJECT_CLASS (ft_lock_screen_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_LOCK_SCREEN, FtLockScreen);
	g_weak_ref_set (&FtLockScreen_singleton__ref, obj);
	g_mutex_unlock (&FtLockScreen_singleton__lock);
	return obj;
}

static void
ft_lock_screen_class_init (FtLockScreenClass * klass,
                           gpointer klass_data)
{
	ft_lock_screen_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtLockScreen_private_offset);
	((FtProvidedObjectClass *) klass)->initialize = (void (*) (FtProvidedObject*)) ft_lock_screen_real_initialize;
	((FtProvidedObjectClass *) klass)->setup_providers = (void (*) (FtProvidedObject*)) ft_lock_screen_real_setup_providers;
	((FtProvidedObjectClass *) klass)->provider_enabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_lock_screen_real_provider_enabled;
	((FtProvidedObjectClass *) klass)->provider_disabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_lock_screen_real_provider_disabled;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_lock_screen_get_property;
	G_OBJECT_CLASS (klass)->constructor = ft_lock_screen_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_lock_screen_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_LOCK_SCREEN_ACTIVE_PROPERTY, ft_lock_screen_properties[FT_LOCK_SCREEN_ACTIVE_PROPERTY] = g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
ft_lock_screen_instance_init (FtLockScreen * self,
                              gpointer klass)
{
	self->priv = ft_lock_screen_get_instance_private (self);
	self->priv->_active = FALSE;
}

static void
ft_lock_screen_finalize (GObject * obj)
{
	FtLockScreen * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_LOCK_SCREEN, FtLockScreen);
	G_OBJECT_CLASS (ft_lock_screen_parent_class)->finalize (obj);
}

static GType
ft_lock_screen_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtLockScreenClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_lock_screen_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtLockScreen), 0, (GInstanceInitFunc) ft_lock_screen_instance_init, NULL };
	GType ft_lock_screen_type_id;
	ft_lock_screen_type_id = g_type_register_static (FT_TYPE_PROVIDED_OBJECT, "FtLockScreen", &g_define_type_info, 0);
	FtLockScreen_private_offset = g_type_add_instance_private (ft_lock_screen_type_id, sizeof (FtLockScreenPrivate));
	return ft_lock_screen_type_id;
}

GType
ft_lock_screen_get_type (void)
{
	static volatile gsize ft_lock_screen_type_id__once = 0;
	if (g_once_init_enter (&ft_lock_screen_type_id__once)) {
		GType ft_lock_screen_type_id;
		ft_lock_screen_type_id = ft_lock_screen_get_type_once ();
		g_once_init_leave (&ft_lock_screen_type_id__once, ft_lock_screen_type_id);
	}
	return ft_lock_screen_type_id__once;
}

static void
_vala_ft_lock_screen_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	FtLockScreen * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_LOCK_SCREEN, FtLockScreen);
	switch (property_id) {
		case FT_LOCK_SCREEN_ACTIVE_PROPERTY:
		g_value_set_boolean (value, ft_lock_screen_get_active (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;
}

