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

#include "libdino.h"
#include <gio/gio.h>
#include <string.h>
#include <glib.h>
#include <stdio.h>
#include <stdlib.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_UPOWER_SLEEPING_SIGNAL,
	DINO_UPOWER_RESUMING_SIGNAL,
	DINO_UPOWER_NUM_SIGNALS
};
static guint dino_upower_signals[DINO_UPOWER_NUM_SIGNALS] = {0};
typedef GDBusProxy DinoUPowerProxy;
typedef GDBusProxyClass DinoUPowerProxyClass;
#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)))

static GType dino_upower_get_type_once (void);
static void dino_upower_proxy_g_signal (GDBusProxy* proxy,
                                 const gchar* sender_name,
                                 const gchar* signal_name,
                                 GVariant* parameters);
static void _dbus_handle_dino_upower_sleeping (DinoUPower* self,
                                        GVariant* parameters);
static void _dbus_handle_dino_upower_resuming (DinoUPower* self,
                                        GVariant* parameters);
static void dino_upower_proxy_dino_upower_interface_init (DinoUPowerIface* iface);
static void dino_upower_dbus_interface_method_call (GDBusConnection* connection,
                                             const gchar* sender,
                                             const gchar* object_path,
                                             const gchar* interface_name,
                                             const gchar* method_name,
                                             GVariant* parameters,
                                             GDBusMethodInvocation* invocation,
                                             gpointer user_data);
static GVariant* dino_upower_dbus_interface_get_property (GDBusConnection* connection,
                                                   const gchar* sender,
                                                   const gchar* object_path,
                                                   const gchar* interface_name,
                                                   const gchar* property_name,
                                                   GError** error,
                                                   gpointer user_data);
static gboolean dino_upower_dbus_interface_set_property (GDBusConnection* connection,
                                                  const gchar* sender,
                                                  const gchar* object_path,
                                                  const gchar* interface_name,
                                                  const gchar* property_name,
                                                  GVariant* value,
                                                  GError** error,
                                                  gpointer user_data);
static void _dbus_dino_upower_sleeping (GObject* _sender,
                                 gpointer* _data);
static void _dbus_dino_upower_resuming (GObject* _sender,
                                 gpointer* _data);
static void _dino_upower_unregister_object (gpointer user_data);

static const GDBusMethodInfo * const _dino_upower_dbus_method_info[] = {NULL};
static const GDBusArgInfo * const _dino_upower_dbus_arg_info_sleeping[] = {NULL};
static const GDBusSignalInfo _dino_upower_dbus_signal_info_sleeping = {-1, "Sleeping", (GDBusArgInfo **) (&_dino_upower_dbus_arg_info_sleeping), NULL};
static const GDBusArgInfo * const _dino_upower_dbus_arg_info_resuming[] = {NULL};
static const GDBusSignalInfo _dino_upower_dbus_signal_info_resuming = {-1, "Resuming", (GDBusArgInfo **) (&_dino_upower_dbus_arg_info_resuming), NULL};
static const GDBusSignalInfo * const _dino_upower_dbus_signal_info[] = {&_dino_upower_dbus_signal_info_sleeping, &_dino_upower_dbus_signal_info_resuming, NULL};
static const GDBusPropertyInfo * const _dino_upower_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _dino_upower_dbus_interface_info = {-1, "org.freedesktop.UPower", (GDBusMethodInfo **) (&_dino_upower_dbus_method_info), (GDBusSignalInfo **) (&_dino_upower_dbus_signal_info), (GDBusPropertyInfo **) (&_dino_upower_dbus_property_info), NULL};
static const GDBusInterfaceVTable _dino_upower_dbus_interface_vtable = {dino_upower_dbus_interface_method_call, dino_upower_dbus_interface_get_property, dino_upower_dbus_interface_set_property};

static void
dino_upower_default_init (DinoUPowerIface * iface,
                          gpointer iface_data)
{
	dino_upower_signals[DINO_UPOWER_SLEEPING_SIGNAL] = g_signal_new ("sleeping", DINO_TYPE_UPOWER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	dino_upower_signals[DINO_UPOWER_RESUMING_SIGNAL] = g_signal_new ("resuming", DINO_TYPE_UPOWER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static GType
dino_upower_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUPowerIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_upower_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType dino_upower_type_id;
	dino_upower_type_id = g_type_register_static (G_TYPE_INTERFACE, "DinoUPower", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (dino_upower_type_id, G_TYPE_OBJECT);
	g_type_set_qdata (dino_upower_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) dino_upower_proxy_get_type);
	g_type_set_qdata (dino_upower_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.UPower");
	g_type_set_qdata (dino_upower_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_dino_upower_dbus_interface_info));
	g_type_set_qdata (dino_upower_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) dino_upower_register_object);
	return dino_upower_type_id;
}

GType
dino_upower_get_type (void)
{
	static volatile gsize dino_upower_type_id__once = 0;
	if (g_once_init_enter (&dino_upower_type_id__once)) {
		GType dino_upower_type_id;
		dino_upower_type_id = dino_upower_get_type_once ();
		g_once_init_leave (&dino_upower_type_id__once, dino_upower_type_id);
	}
	return dino_upower_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (DinoUPowerProxy, dino_upower_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (DINO_TYPE_UPOWER, dino_upower_proxy_dino_upower_interface_init) )
static void
dino_upower_proxy_class_init (DinoUPowerProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = dino_upower_proxy_g_signal;
}

static void
_dbus_handle_dino_upower_sleeping (DinoUPower* self,
                                   GVariant* parameters)
{
	GVariantIter _arguments_iter;
	g_variant_iter_init (&_arguments_iter, parameters);
	g_signal_emit_by_name (self, "sleeping");
}

static void
_dbus_handle_dino_upower_resuming (DinoUPower* self,
                                   GVariant* parameters)
{
	GVariantIter _arguments_iter;
	g_variant_iter_init (&_arguments_iter, parameters);
	g_signal_emit_by_name (self, "resuming");
}

static void
dino_upower_proxy_g_signal (GDBusProxy* proxy,
                            const gchar* sender_name,
                            const gchar* signal_name,
                            GVariant* parameters)
{
	if (strcmp (signal_name, "Sleeping") == 0) {
		_dbus_handle_dino_upower_sleeping ((DinoUPower*) proxy, parameters);
	} else if (strcmp (signal_name, "Resuming") == 0) {
		_dbus_handle_dino_upower_resuming ((DinoUPower*) proxy, parameters);
	}
}

static void
dino_upower_proxy_init (DinoUPowerProxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_dino_upower_dbus_interface_info));
}

static void
dino_upower_proxy_dino_upower_interface_init (DinoUPowerIface* iface)
{
}

static void
dino_upower_dbus_interface_method_call (GDBusConnection* connection,
                                        const gchar* sender,
                                        const gchar* object_path,
                                        const gchar* interface_name,
                                        const gchar* method_name,
                                        GVariant* parameters,
                                        GDBusMethodInvocation* invocation,
                                        gpointer user_data)
{
	g_object_unref (invocation);
}

static GVariant*
dino_upower_dbus_interface_get_property (GDBusConnection* connection,
                                         const gchar* sender,
                                         const gchar* object_path,
                                         const gchar* interface_name,
                                         const gchar* property_name,
                                         GError** error,
                                         gpointer user_data)
{
	return NULL;
}

static gboolean
dino_upower_dbus_interface_set_property (GDBusConnection* connection,
                                         const gchar* sender,
                                         const gchar* object_path,
                                         const gchar* interface_name,
                                         const gchar* property_name,
                                         GVariant* value,
                                         GError** error,
                                         gpointer user_data)
{
	return FALSE;
}

static void
_dbus_dino_upower_sleeping (GObject* _sender,
                            gpointer* _data)
{
	GDBusConnection * _connection;
	const gchar * _path;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	_connection = _data[1];
	_path = _data[2];
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_connection_emit_signal (_connection, NULL, _path, "org.freedesktop.UPower", "Sleeping", _arguments, NULL);
}

static void
_dbus_dino_upower_resuming (GObject* _sender,
                            gpointer* _data)
{
	GDBusConnection * _connection;
	const gchar * _path;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	_connection = _data[1];
	_path = _data[2];
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_connection_emit_signal (_connection, NULL, _path, "org.freedesktop.UPower", "Resuming", _arguments, NULL);
}

guint
dino_upower_register_object (gpointer object,
                             GDBusConnection* connection,
                             const gchar* path,
                             GError** error)
{
	guint result;
	gpointer *data;
	data = g_new (gpointer, 3);
	data[0] = g_object_ref (object);
	data[1] = g_object_ref (connection);
	data[2] = g_strdup (path);
	result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_dino_upower_dbus_interface_info), &_dino_upower_dbus_interface_vtable, data, _dino_upower_unregister_object, error);
	if (!result) {
		return 0;
	}
	g_signal_connect (object, "sleeping", (GCallback) _dbus_dino_upower_sleeping, data);
	g_signal_connect (object, "resuming", (GCallback) _dbus_dino_upower_resuming, data);
	return result;
}

static void
_dino_upower_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_signal_handlers_disconnect_by_func (data[0], _dbus_dino_upower_sleeping, data);
	g_signal_handlers_disconnect_by_func (data[0], _dbus_dino_upower_resuming, data);
	g_object_unref (data[0]);
	g_object_unref (data[1]);
	g_free (data[2]);
	g_free (data);
}

DinoUPower*
dino_get_upower (void)
{
	DinoUPower* upower = NULL;
	GError* _inner_error0_ = NULL;
	DinoUPower* result;
	upower = NULL;
	{
		DinoUPower* _tmp0_ = NULL;
		DinoUPower* _tmp1_;
		DinoUPower* _tmp2_;
		_tmp1_ = (DinoUPower*) g_initable_new (DINO_TYPE_UPOWER_PROXY, NULL, &_inner_error0_, "g-flags", 0, "g-name", "org.freedesktop.UPower", "g-bus-type", G_BUS_TYPE_SYSTEM, "g-object-path", "/org/freedesktop/UPower", "g-interface-name", "org.freedesktop.UPower", NULL);
		_tmp0_ = (DinoUPower*) _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			_g_object_unref0 (upower);
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (upower);
		upower = _tmp2_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		GError* e = NULL;
		FILE* _tmp3_;
		GError* _tmp4_;
		const gchar* _tmp5_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = stderr;
		_tmp4_ = e;
		_tmp5_ = _tmp4_->message;
		fprintf (_tmp3_, "%s\n", _tmp5_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (upower);
		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 NULL;
	}
	result = upower;
	return result;
}

