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

#include "display.h"
#include <glib.h>
#include <gio/gio.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

typedef GDBusProxy SettingsDaemonProxy;
typedef GDBusProxyClass SettingsDaemonProxyClass;
#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 settings_daemon_get_type_once (void);
static void settings_daemon_proxy_g_signal (GDBusProxy* proxy,
                                     const gchar* sender_name,
                                     const gchar* signal_name,
                                     GVariant* parameters);
static void settings_daemon_proxy_apply_configuration (SettingsDaemon* self,
                                                gint64 parent_window_xid,
                                                gint64 timestamp,
                                                GError** error);
static void settings_daemon_proxy_settings_daemon_interface_init (SettingsDaemonIface* iface);
static void _dbus_settings_daemon_apply_configuration (SettingsDaemon* self,
                                                GVariant* _parameters_,
                                                GDBusMethodInvocation* invocation);
static void settings_daemon_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* settings_daemon_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 settings_daemon_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 _settings_daemon_unregister_object (gpointer user_data);

static const GDBusArgInfo _settings_daemon_dbus_arg_info_apply_configuration_parent_window_xid = {-1, "parent_window_xid", "x", NULL};
static const GDBusArgInfo _settings_daemon_dbus_arg_info_apply_configuration_timestamp = {-1, "timestamp", "x", NULL};
static const GDBusArgInfo * const _settings_daemon_dbus_arg_info_apply_configuration_in[] = {&_settings_daemon_dbus_arg_info_apply_configuration_parent_window_xid, &_settings_daemon_dbus_arg_info_apply_configuration_timestamp, NULL};
static const GDBusArgInfo * const _settings_daemon_dbus_arg_info_apply_configuration_out[] = {NULL};
static const GDBusMethodInfo _settings_daemon_dbus_method_info_apply_configuration = {-1, "ApplyConfiguration", (GDBusArgInfo **) (&_settings_daemon_dbus_arg_info_apply_configuration_in), (GDBusArgInfo **) (&_settings_daemon_dbus_arg_info_apply_configuration_out), NULL};
static const GDBusMethodInfo * const _settings_daemon_dbus_method_info[] = {&_settings_daemon_dbus_method_info_apply_configuration, NULL};
static const GDBusSignalInfo * const _settings_daemon_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo * const _settings_daemon_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _settings_daemon_dbus_interface_info = {-1, "org.gnome.SettingsDaemon.XRANDR_2", (GDBusMethodInfo **) (&_settings_daemon_dbus_method_info), (GDBusSignalInfo **) (&_settings_daemon_dbus_signal_info), (GDBusPropertyInfo **) (&_settings_daemon_dbus_property_info), NULL};
static const GDBusInterfaceVTable _settings_daemon_dbus_interface_vtable = {settings_daemon_dbus_interface_method_call, settings_daemon_dbus_interface_get_property, settings_daemon_dbus_interface_set_property};

void
settings_daemon_apply_configuration (SettingsDaemon* self,
                                     gint64 parent_window_xid,
                                     gint64 timestamp,
                                     GError** error)
{
	SettingsDaemonIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = SETTINGS_DAEMON_GET_INTERFACE (self);
	if (_iface_->apply_configuration) {
		_iface_->apply_configuration (self, parent_window_xid, timestamp, error);
	}
}

static void
settings_daemon_default_init (SettingsDaemonIface * iface,
                              gpointer iface_data)
{
}

static GType
settings_daemon_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SettingsDaemonIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) settings_daemon_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType settings_daemon_type_id;
	settings_daemon_type_id = g_type_register_static (G_TYPE_INTERFACE, "SettingsDaemon", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (settings_daemon_type_id, G_TYPE_OBJECT);
	g_type_set_qdata (settings_daemon_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) settings_daemon_proxy_get_type);
	g_type_set_qdata (settings_daemon_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.gnome.SettingsDaemon.XRANDR_2");
	g_type_set_qdata (settings_daemon_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_settings_daemon_dbus_interface_info));
	g_type_set_qdata (settings_daemon_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) settings_daemon_register_object);
	return settings_daemon_type_id;
}

GType
settings_daemon_get_type (void)
{
	static volatile gsize settings_daemon_type_id__once = 0;
	if (g_once_init_enter (&settings_daemon_type_id__once)) {
		GType settings_daemon_type_id;
		settings_daemon_type_id = settings_daemon_get_type_once ();
		g_once_init_leave (&settings_daemon_type_id__once, settings_daemon_type_id);
	}
	return settings_daemon_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (SettingsDaemonProxy, settings_daemon_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (TYPE_SETTINGS_DAEMON, settings_daemon_proxy_settings_daemon_interface_init) )
static void
settings_daemon_proxy_class_init (SettingsDaemonProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = settings_daemon_proxy_g_signal;
}

static void
settings_daemon_proxy_g_signal (GDBusProxy* proxy,
                                const gchar* sender_name,
                                const gchar* signal_name,
                                GVariant* parameters)
{
}

static void
settings_daemon_proxy_init (SettingsDaemonProxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_settings_daemon_dbus_interface_info));
}

static void
settings_daemon_proxy_apply_configuration (SettingsDaemon* self,
                                           gint64 parent_window_xid,
                                           gint64 timestamp,
                                           GError** error)
{
	GDBusMessage *_message;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	GDBusMessage *_reply_message;
	_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.gnome.SettingsDaemon.XRANDR_2", "ApplyConfiguration");
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_int64 (parent_window_xid));
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_int64 (timestamp));
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_message_set_body (_message, _arguments);
	_reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error);
	g_object_unref (_message);
	if (!_reply_message) {
		return;
	}
	if (g_dbus_message_to_gerror (_reply_message, error)) {
		g_object_unref (_reply_message);
		return;
	}
	g_object_unref (_reply_message);
}

static void
settings_daemon_proxy_settings_daemon_interface_init (SettingsDaemonIface* iface)
{
	iface->apply_configuration = settings_daemon_proxy_apply_configuration;
}

static void
_dbus_settings_daemon_apply_configuration (SettingsDaemon* self,
                                           GVariant* _parameters_,
                                           GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gint64 parent_window_xid = 0LL;
	GVariant* _tmp0_;
	gint64 timestamp = 0LL;
	GVariant* _tmp1_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp0_ = g_variant_iter_next_value (&_arguments_iter);
	parent_window_xid = g_variant_get_int64 (_tmp0_);
	g_variant_unref (_tmp0_);
	_tmp1_ = g_variant_iter_next_value (&_arguments_iter);
	timestamp = g_variant_get_int64 (_tmp1_);
	g_variant_unref (_tmp1_);
	settings_daemon_apply_configuration (self, parent_window_xid, timestamp, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		return;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
}

static void
settings_daemon_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)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (method_name, "ApplyConfiguration") == 0) {
		_dbus_settings_daemon_apply_configuration (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
settings_daemon_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
settings_daemon_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;
}

guint
settings_daemon_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 *) (&_settings_daemon_dbus_interface_info), &_settings_daemon_dbus_interface_vtable, data, _settings_daemon_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

static void
_settings_daemon_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_object_unref (data[0]);
	g_object_unref (data[1]);
	g_free (data[2]);
	g_free (data);
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

SettingsDaemon*
get_settings_daemon (GError** error)
{
	SettingsDaemon* daemon = NULL;
	GError* _inner_error0_ = NULL;
	SettingsDaemon* result;
	{
		SettingsDaemon* _tmp0_ = NULL;
		SettingsDaemon* _tmp1_;
		SettingsDaemon* _tmp2_;
		_tmp1_ = (SettingsDaemon*) g_initable_new (TYPE_SETTINGS_DAEMON_PROXY, NULL, &_inner_error0_, "g-flags", 0, "g-name", "org.gnome.SettingsDaemon.XRANDR", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/gnome/SettingsDaemon/XRANDR", "g-interface-name", "org.gnome.SettingsDaemon.XRANDR_2", NULL);
		_tmp0_ = (SettingsDaemon*) _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (daemon);
		daemon = _tmp2_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		GError* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _g_error_copy0 (_tmp3_);
		_inner_error0_ = _tmp4_;
		_g_error_free0 (e);
		goto __finally0;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (daemon);
		return NULL;
	}
	result = daemon;
	return result;
}

