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

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

#include "ft_core.h"
#include <glib-object.h>
#include <glib.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_SLEEP_MONITOR_PROVIDER_PREPARE_FOR_SLEEP_SIGNAL,
	FT_SLEEP_MONITOR_PROVIDER_WOKE_UP_SIGNAL,
	FT_SLEEP_MONITOR_PROVIDER_NUM_SIGNALS
};
static guint ft_sleep_monitor_provider_signals[FT_SLEEP_MONITOR_PROVIDER_NUM_SIGNALS] = {0};
enum  {
	FT_SLEEP_MONITOR_0_PROPERTY,
	FT_SLEEP_MONITOR_NUM_PROPERTIES
};
static GParamSpec* ft_sleep_monitor_properties[FT_SLEEP_MONITOR_NUM_PROPERTIES];
enum  {
	FT_SLEEP_MONITOR_PREPARE_FOR_SLEEP_SIGNAL,
	FT_SLEEP_MONITOR_WOKE_UP_SIGNAL,
	FT_SLEEP_MONITOR_NUM_SIGNALS
};
static guint ft_sleep_monitor_signals[FT_SLEEP_MONITOR_NUM_SIGNALS] = {0};

static gpointer ft_sleep_monitor_parent_class = NULL;

static GType ft_sleep_monitor_provider_get_type_once (void);
static void ft_sleep_monitor_on_prepare_for_sleep (FtSleepMonitor* self);
static void ft_sleep_monitor_on_woke_up (FtSleepMonitor* self);
static void ft_sleep_monitor_real_initialize (FtProvidedObject* base);
static void ft_sleep_monitor_real_setup_providers (FtProvidedObject* base);
static void ft_sleep_monitor_real_provider_enabled (FtProvidedObject* base,
                                             FtSleepMonitorProvider* provider);
static void _ft_sleep_monitor_on_prepare_for_sleep_ft_sleep_monitor_provider_prepare_for_sleep (FtSleepMonitorProvider* _sender,
                                                                                         gpointer self);
static void _ft_sleep_monitor_on_woke_up_ft_sleep_monitor_provider_woke_up (FtSleepMonitorProvider* _sender,
                                                                     gpointer self);
static void ft_sleep_monitor_real_provider_disabled (FtProvidedObject* base,
                                              FtSleepMonitorProvider* provider);
static GObject * ft_sleep_monitor_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static GType ft_sleep_monitor_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
ft_sleep_monitor_provider_default_init (FtSleepMonitorProviderIface * iface,
                                        gpointer iface_data)
{
	ft_sleep_monitor_provider_signals[FT_SLEEP_MONITOR_PROVIDER_PREPARE_FOR_SLEEP_SIGNAL] = g_signal_new ("prepare-for-sleep", FT_TYPE_SLEEP_MONITOR_PROVIDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	ft_sleep_monitor_provider_signals[FT_SLEEP_MONITOR_PROVIDER_WOKE_UP_SIGNAL] = g_signal_new ("woke-up", FT_TYPE_SLEEP_MONITOR_PROVIDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static GType
ft_sleep_monitor_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtSleepMonitorProviderIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_sleep_monitor_provider_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType ft_sleep_monitor_provider_type_id;
	ft_sleep_monitor_provider_type_id = g_type_register_static (G_TYPE_INTERFACE, "FtSleepMonitorProvider", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (ft_sleep_monitor_provider_type_id, FT_TYPE_PROVIDER);
	return ft_sleep_monitor_provider_type_id;
}

GType
ft_sleep_monitor_provider_get_type (void)
{
	static volatile gsize ft_sleep_monitor_provider_type_id__once = 0;
	if (g_once_init_enter (&ft_sleep_monitor_provider_type_id__once)) {
		GType ft_sleep_monitor_provider_type_id;
		ft_sleep_monitor_provider_type_id = ft_sleep_monitor_provider_get_type_once ();
		g_once_init_leave (&ft_sleep_monitor_provider_type_id__once, ft_sleep_monitor_provider_type_id);
	}
	return ft_sleep_monitor_provider_type_id__once;
}

static void
ft_sleep_monitor_on_prepare_for_sleep (FtSleepMonitor* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, ft_sleep_monitor_signals[FT_SLEEP_MONITOR_PREPARE_FOR_SLEEP_SIGNAL], 0);
}

static void
ft_sleep_monitor_on_woke_up (FtSleepMonitor* self)
{
	g_return_if_fail (self != NULL);
	g_signal_emit (self, ft_sleep_monitor_signals[FT_SLEEP_MONITOR_WOKE_UP_SIGNAL], 0);
}

static void
ft_sleep_monitor_real_initialize (FtProvidedObject* base)
{
	FtSleepMonitor * self;
	self = (FtSleepMonitor*) base;
}

static void
ft_sleep_monitor_real_setup_providers (FtProvidedObject* base)
{
	FtSleepMonitor * self;
	self = (FtSleepMonitor*) base;
}

static void
_ft_sleep_monitor_on_prepare_for_sleep_ft_sleep_monitor_provider_prepare_for_sleep (FtSleepMonitorProvider* _sender,
                                                                                    gpointer self)
{
	ft_sleep_monitor_on_prepare_for_sleep ((FtSleepMonitor*) self);
}

static void
_ft_sleep_monitor_on_woke_up_ft_sleep_monitor_provider_woke_up (FtSleepMonitorProvider* _sender,
                                                                gpointer self)
{
	ft_sleep_monitor_on_woke_up ((FtSleepMonitor*) self);
}

static void
ft_sleep_monitor_real_provider_enabled (FtProvidedObject* base,
                                        FtSleepMonitorProvider* provider)
{
	FtSleepMonitor * self;
	self = (FtSleepMonitor*) base;
	g_return_if_fail (provider != NULL);
	g_signal_connect_object (provider, "prepare-for-sleep", (GCallback) _ft_sleep_monitor_on_prepare_for_sleep_ft_sleep_monitor_provider_prepare_for_sleep, self, 0);
	g_signal_connect_object (provider, "woke-up", (GCallback) _ft_sleep_monitor_on_woke_up_ft_sleep_monitor_provider_woke_up, self, 0);
}

static void
ft_sleep_monitor_real_provider_disabled (FtProvidedObject* base,
                                         FtSleepMonitorProvider* provider)
{
	FtSleepMonitor * self;
	guint _tmp0_;
	guint _tmp1_;
	self = (FtSleepMonitor*) base;
	g_return_if_fail (provider != NULL);
	g_signal_parse_name ("prepare-for-sleep", FT_TYPE_SLEEP_MONITOR_PROVIDER, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _ft_sleep_monitor_on_prepare_for_sleep_ft_sleep_monitor_provider_prepare_for_sleep, self);
	g_signal_parse_name ("woke-up", FT_TYPE_SLEEP_MONITOR_PROVIDER, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _ft_sleep_monitor_on_woke_up_ft_sleep_monitor_provider_woke_up, self);
}

FtSleepMonitor*
ft_sleep_monitor_construct (GType object_type)
{
	FtSleepMonitor * self = NULL;
	self = (FtSleepMonitor*) ft_provided_object_construct (object_type, FT_TYPE_SLEEP_MONITOR_PROVIDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref);
	return self;
}

FtSleepMonitor*
ft_sleep_monitor_new (void)
{
	return ft_sleep_monitor_construct (FT_TYPE_SLEEP_MONITOR);
}

static GObject *
ft_sleep_monitor_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	static GWeakRef FtSleepMonitor_singleton__ref;
	static GMutex FtSleepMonitor_singleton__lock;
	FtSleepMonitor * self;
	g_mutex_lock (&FtSleepMonitor_singleton__lock);
	obj = g_weak_ref_get (&FtSleepMonitor_singleton__ref);
	if (obj != NULL) {
		g_mutex_unlock (&FtSleepMonitor_singleton__lock);
		return obj;
	}
	parent_class = G_OBJECT_CLASS (ft_sleep_monitor_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_SLEEP_MONITOR, FtSleepMonitor);
	g_weak_ref_set (&FtSleepMonitor_singleton__ref, obj);
	g_mutex_unlock (&FtSleepMonitor_singleton__lock);
	return obj;
}

static void
ft_sleep_monitor_class_init (FtSleepMonitorClass * klass,
                             gpointer klass_data)
{
	ft_sleep_monitor_parent_class = g_type_class_peek_parent (klass);
	((FtProvidedObjectClass *) klass)->initialize = (void (*) (FtProvidedObject*)) ft_sleep_monitor_real_initialize;
	((FtProvidedObjectClass *) klass)->setup_providers = (void (*) (FtProvidedObject*)) ft_sleep_monitor_real_setup_providers;
	((FtProvidedObjectClass *) klass)->provider_enabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_sleep_monitor_real_provider_enabled;
	((FtProvidedObjectClass *) klass)->provider_disabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_sleep_monitor_real_provider_disabled;
	G_OBJECT_CLASS (klass)->constructor = ft_sleep_monitor_constructor;
	ft_sleep_monitor_signals[FT_SLEEP_MONITOR_PREPARE_FOR_SLEEP_SIGNAL] = g_signal_new ("prepare-for-sleep", FT_TYPE_SLEEP_MONITOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	ft_sleep_monitor_signals[FT_SLEEP_MONITOR_WOKE_UP_SIGNAL] = g_signal_new ("woke-up", FT_TYPE_SLEEP_MONITOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
ft_sleep_monitor_instance_init (FtSleepMonitor * self,
                                gpointer klass)
{
}

static GType
ft_sleep_monitor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtSleepMonitorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_sleep_monitor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtSleepMonitor), 0, (GInstanceInitFunc) ft_sleep_monitor_instance_init, NULL };
	GType ft_sleep_monitor_type_id;
	ft_sleep_monitor_type_id = g_type_register_static (FT_TYPE_PROVIDED_OBJECT, "FtSleepMonitor", &g_define_type_info, 0);
	return ft_sleep_monitor_type_id;
}

GType
ft_sleep_monitor_get_type (void)
{
	static volatile gsize ft_sleep_monitor_type_id__once = 0;
	if (g_once_init_enter (&ft_sleep_monitor_type_id__once)) {
		GType ft_sleep_monitor_type_id;
		ft_sleep_monitor_type_id = ft_sleep_monitor_get_type_once ();
		g_once_init_leave (&ft_sleep_monitor_type_id__once, ft_sleep_monitor_type_id);
	}
	return ft_sleep_monitor_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;
}

