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

/*
 * Copyright 2026 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include <glib-object.h>
#include <gio/gio.h>
#include <glib.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 GALA_DAEMON_TYPE_OSK_MANAGER (gala_daemon_osk_manager_get_type ())
#define GALA_DAEMON_OSK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_DAEMON_TYPE_OSK_MANAGER, GalaDaemonOSKManager))
#define GALA_DAEMON_OSK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_DAEMON_TYPE_OSK_MANAGER, GalaDaemonOSKManagerClass))
#define GALA_DAEMON_IS_OSK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_DAEMON_TYPE_OSK_MANAGER))
#define GALA_DAEMON_IS_OSK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_DAEMON_TYPE_OSK_MANAGER))
#define GALA_DAEMON_OSK_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_DAEMON_TYPE_OSK_MANAGER, GalaDaemonOSKManagerClass))

typedef struct _GalaDaemonOSKManager GalaDaemonOSKManager;
typedef struct _GalaDaemonOSKManagerClass GalaDaemonOSKManagerClass;
typedef struct _GalaDaemonOSKManagerPrivate GalaDaemonOSKManagerPrivate;

#define GALA_DAEMON_TYPE_IBUS_SERVICE (gala_daemon_ibus_service_get_type ())
#define GALA_DAEMON_IBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_DAEMON_TYPE_IBUS_SERVICE, GalaDaemonIBusService))
#define GALA_DAEMON_IBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_DAEMON_TYPE_IBUS_SERVICE, GalaDaemonIBusServiceClass))
#define GALA_DAEMON_IS_IBUS_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_DAEMON_TYPE_IBUS_SERVICE))
#define GALA_DAEMON_IS_IBUS_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_DAEMON_TYPE_IBUS_SERVICE))
#define GALA_DAEMON_IBUS_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_DAEMON_TYPE_IBUS_SERVICE, GalaDaemonIBusServiceClass))

typedef struct _GalaDaemonIBusService GalaDaemonIBusService;
typedef struct _GalaDaemonIBusServiceClass GalaDaemonIBusServiceClass;

#define GALA_DAEMON_TYPE_OSK_SERVICE (gala_daemon_osk_service_get_type ())
#define GALA_DAEMON_OSK_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_DAEMON_TYPE_OSK_SERVICE, GalaDaemonOSKService))
#define GALA_DAEMON_OSK_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_DAEMON_TYPE_OSK_SERVICE, GalaDaemonOSKServiceClass))
#define GALA_DAEMON_IS_OSK_SERVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_DAEMON_TYPE_OSK_SERVICE))
#define GALA_DAEMON_IS_OSK_SERVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_DAEMON_TYPE_OSK_SERVICE))
#define GALA_DAEMON_OSK_SERVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_DAEMON_TYPE_OSK_SERVICE, GalaDaemonOSKServiceClass))

typedef struct _GalaDaemonOSKService GalaDaemonOSKService;
typedef struct _GalaDaemonOSKServiceClass GalaDaemonOSKServiceClass;
enum  {
	GALA_DAEMON_OSK_MANAGER_0_PROPERTY,
	GALA_DAEMON_OSK_MANAGER_IBUS_SERVICE_PROPERTY,
	GALA_DAEMON_OSK_MANAGER_NUM_PROPERTIES
};
static GParamSpec* gala_daemon_osk_manager_properties[GALA_DAEMON_OSK_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _GalaDaemonOSKManager {
	GObject parent_instance;
	GalaDaemonOSKManagerPrivate * priv;
};

struct _GalaDaemonOSKManagerClass {
	GObjectClass parent_class;
};

struct _GalaDaemonOSKManagerPrivate {
	GalaDaemonIBusService* _ibus_service;
	GalaDaemonOSKService* osk_service;
};

static gint GalaDaemonOSKManager_private_offset;
static gpointer gala_daemon_osk_manager_parent_class = NULL;

VALA_EXTERN GType gala_daemon_osk_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaDaemonOSKManager, g_object_unref)
VALA_EXTERN GType gala_daemon_ibus_service_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaDaemonIBusService, g_object_unref)
VALA_EXTERN GType gala_daemon_osk_service_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaDaemonOSKService, g_object_unref)
VALA_EXTERN guint gala_daemon_osk_service_register_object (void* object,
                                               GDBusConnection* connection,
                                               const gchar* path,
                                               GError** error);
VALA_EXTERN GalaDaemonOSKManager* gala_daemon_osk_manager_new (GalaDaemonIBusService* ibus_service);
VALA_EXTERN GalaDaemonOSKManager* gala_daemon_osk_manager_construct (GType object_type,
                                                         GalaDaemonIBusService* ibus_service);
static void gala_daemon_osk_manager_on_name_acquired (GalaDaemonOSKManager* self,
                                               GDBusConnection* connection,
                                               const gchar* name);
static GalaDaemonIBusService* gala_daemon_osk_manager_get_ibus_service (GalaDaemonOSKManager* self);
static void gala_daemon_osk_manager_set_ibus_service (GalaDaemonOSKManager* self,
                                               GalaDaemonIBusService* value);
static GObject * gala_daemon_osk_manager_constructor (GType type,
                                               guint n_construct_properties,
                                               GObjectConstructParam * construct_properties);
 G_GNUC_INTERNAL GalaDaemonOSKService* gala_daemon_osk_service_new (GalaDaemonIBusService* ibus_service);
 G_GNUC_INTERNAL GalaDaemonOSKService* gala_daemon_osk_service_construct (GType object_type,
                                                         GalaDaemonIBusService* ibus_service);
static void _gala_daemon_osk_manager_on_name_acquired_gbus_name_acquired_callback (GDBusConnection* connection,
                                                                            const gchar* name,
                                                                            gpointer self);
static void gala_daemon_osk_manager_finalize (GObject * obj);
static GType gala_daemon_osk_manager_get_type_once (void);
static void _vala_gala_daemon_osk_manager_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);
static void _vala_gala_daemon_osk_manager_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec);

static inline gpointer
gala_daemon_osk_manager_get_instance_private (GalaDaemonOSKManager* self)
{
	return G_STRUCT_MEMBER_P (self, GalaDaemonOSKManager_private_offset);
}

GalaDaemonOSKManager*
gala_daemon_osk_manager_construct (GType object_type,
                                   GalaDaemonIBusService* ibus_service)
{
	GalaDaemonOSKManager * self = NULL;
	g_return_val_if_fail (ibus_service != NULL, NULL);
	self = (GalaDaemonOSKManager*) g_object_new (object_type, "ibus-service", ibus_service, NULL);
	return self;
}

GalaDaemonOSKManager*
gala_daemon_osk_manager_new (GalaDaemonIBusService* ibus_service)
{
	return gala_daemon_osk_manager_construct (GALA_DAEMON_TYPE_OSK_MANAGER, ibus_service);
}

static void
gala_daemon_osk_manager_on_name_acquired (GalaDaemonOSKManager* self,
                                          GDBusConnection* connection,
                                          const gchar* name)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (connection != NULL);
	g_return_if_fail (name != NULL);
	{
		GalaDaemonOSKService* _tmp0_;
		_tmp0_ = self->priv->osk_service;
		gala_daemon_osk_service_register_object (_tmp0_, connection, "/io/elementary/OSK", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_warning ("OSKManager.vala:27: Failed to get D-Bus session bus: %s", _tmp2_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static GalaDaemonIBusService*
gala_daemon_osk_manager_get_ibus_service (GalaDaemonOSKManager* self)
{
	GalaDaemonIBusService* result;
	GalaDaemonIBusService* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_ibus_service;
	result = _tmp0_;
	return result;
}

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

static void
gala_daemon_osk_manager_set_ibus_service (GalaDaemonOSKManager* self,
                                          GalaDaemonIBusService* value)
{
	GalaDaemonIBusService* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_daemon_osk_manager_get_ibus_service (self);
	if (old_value != value) {
		GalaDaemonIBusService* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_ibus_service);
		self->priv->_ibus_service = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_daemon_osk_manager_properties[GALA_DAEMON_OSK_MANAGER_IBUS_SERVICE_PROPERTY]);
	}
}

static void
_gala_daemon_osk_manager_on_name_acquired_gbus_name_acquired_callback (GDBusConnection* connection,
                                                                       const gchar* name,
                                                                       gpointer self)
{
	gala_daemon_osk_manager_on_name_acquired ((GalaDaemonOSKManager*) self, connection, name);
}

static GObject *
gala_daemon_osk_manager_constructor (GType type,
                                     guint n_construct_properties,
                                     GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaDaemonOSKManager * self;
	GalaDaemonIBusService* _tmp0_;
	GalaDaemonOSKService* _tmp1_;
	parent_class = G_OBJECT_CLASS (gala_daemon_osk_manager_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_DAEMON_TYPE_OSK_MANAGER, GalaDaemonOSKManager);
	_tmp0_ = self->priv->_ibus_service;
	_tmp1_ = gala_daemon_osk_service_new (_tmp0_);
	_g_object_unref0 (self->priv->osk_service);
	self->priv->osk_service = _tmp1_;
	g_bus_own_name_with_closures (G_BUS_TYPE_SESSION, "io.elementary.OSK", G_BUS_NAME_OWNER_FLAGS_NONE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((_gala_daemon_osk_manager_on_name_acquired_gbus_name_acquired_callback == NULL) ? NULL : g_cclosure_new ((GCallback) _gala_daemon_osk_manager_on_name_acquired_gbus_name_acquired_callback, g_object_ref (self), (GClosureNotify) g_object_unref)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	return obj;
}

static void
gala_daemon_osk_manager_class_init (GalaDaemonOSKManagerClass * klass,
                                    gpointer klass_data)
{
	gala_daemon_osk_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaDaemonOSKManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_daemon_osk_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_daemon_osk_manager_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_daemon_osk_manager_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_daemon_osk_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_DAEMON_OSK_MANAGER_IBUS_SERVICE_PROPERTY, gala_daemon_osk_manager_properties[GALA_DAEMON_OSK_MANAGER_IBUS_SERVICE_PROPERTY] = g_param_spec_object ("ibus-service", "ibus-service", "ibus-service", GALA_DAEMON_TYPE_IBUS_SERVICE, G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_daemon_osk_manager_instance_init (GalaDaemonOSKManager * self,
                                       gpointer klass)
{
	self->priv = gala_daemon_osk_manager_get_instance_private (self);
}

static void
gala_daemon_osk_manager_finalize (GObject * obj)
{
	GalaDaemonOSKManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_DAEMON_TYPE_OSK_MANAGER, GalaDaemonOSKManager);
	_g_object_unref0 (self->priv->_ibus_service);
	_g_object_unref0 (self->priv->osk_service);
	G_OBJECT_CLASS (gala_daemon_osk_manager_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_daemon_osk_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaDaemonOSKManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_daemon_osk_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaDaemonOSKManager), 0, (GInstanceInitFunc) gala_daemon_osk_manager_instance_init, NULL };
	GType gala_daemon_osk_manager_type_id;
	gala_daemon_osk_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaDaemonOSKManager", &g_define_type_info, G_TYPE_FLAG_NONE);
	GalaDaemonOSKManager_private_offset = g_type_add_instance_private (gala_daemon_osk_manager_type_id, sizeof (GalaDaemonOSKManagerPrivate));
	return gala_daemon_osk_manager_type_id;
}

GType
gala_daemon_osk_manager_get_type (void)
{
	static gsize gala_daemon_osk_manager_type_id__once = 0;
	if (g_once_init_enter (&gala_daemon_osk_manager_type_id__once)) {
		GType gala_daemon_osk_manager_type_id;
		gala_daemon_osk_manager_type_id = gala_daemon_osk_manager_get_type_once ();
		g_once_init_leave (&gala_daemon_osk_manager_type_id__once, gala_daemon_osk_manager_type_id);
	}
	return gala_daemon_osk_manager_type_id__once;
}

static void
_vala_gala_daemon_osk_manager_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	GalaDaemonOSKManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_DAEMON_TYPE_OSK_MANAGER, GalaDaemonOSKManager);
	switch (property_id) {
		case GALA_DAEMON_OSK_MANAGER_IBUS_SERVICE_PROPERTY:
		g_value_set_object (value, gala_daemon_osk_manager_get_ibus_service (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_daemon_osk_manager_set_property (GObject * object,
                                            guint property_id,
                                            const GValue * value,
                                            GParamSpec * pspec)
{
	GalaDaemonOSKManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_DAEMON_TYPE_OSK_MANAGER, GalaDaemonOSKManager);
	switch (property_id) {
		case GALA_DAEMON_OSK_MANAGER_IBUS_SERVICE_PROPERTY:
		gala_daemon_osk_manager_set_ibus_service (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

