/* Screen.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from Screen.vala, do not modify */

/*
 * Copyright (c) 2011-2018 elementary LLC. (https://elementary.io)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

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

#define POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_SETTINGS (power_services_dbus_interfaces_power_settings_get_type ())
#define POWER_SERVICES_DBUS_INTERFACES_POWER_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_SETTINGS, PowerServicesDBusInterfacesPowerSettings))
#define POWER_SERVICES_DBUS_INTERFACES_IS_POWER_SETTINGS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_SETTINGS))
#define POWER_SERVICES_DBUS_INTERFACES_POWER_SETTINGS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_SETTINGS, PowerServicesDBusInterfacesPowerSettingsIface))

typedef struct _PowerServicesDBusInterfacesPowerSettings PowerServicesDBusInterfacesPowerSettings;
typedef struct _PowerServicesDBusInterfacesPowerSettingsIface PowerServicesDBusInterfacesPowerSettingsIface;

#define POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_SETTINGS_PROXY (power_services_dbus_interfaces_power_settings_proxy_get_type ())
typedef GDBusProxy PowerServicesDBusInterfacesPowerSettingsProxy;
typedef GDBusProxyClass PowerServicesDBusInterfacesPowerSettingsProxyClass;

struct _PowerServicesDBusInterfacesPowerSettingsIface {
	GTypeInterface parent_iface;
	gint (*get_brightness) (PowerServicesDBusInterfacesPowerSettings* self);
	void (*set_brightness) (PowerServicesDBusInterfacesPowerSettings* self, gint value);
};

VALA_EXTERN GType power_services_dbus_interfaces_power_settings_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType power_services_dbus_interfaces_power_settings_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint power_services_dbus_interfaces_power_settings_register_object (void* object,
                                                                     GDBusConnection* connection,
                                                                     const gchar* path,
                                                                     GError** error);
VALA_EXTERN gint power_services_dbus_interfaces_power_settings_get_brightness (PowerServicesDBusInterfacesPowerSettings* self);
VALA_EXTERN void power_services_dbus_interfaces_power_settings_set_brightness (PowerServicesDBusInterfacesPowerSettings* self,
                                                                   gint value);
static GType power_services_dbus_interfaces_power_settings_get_type_once (void);
static void power_services_dbus_interfaces_power_settings_proxy_g_signal (GDBusProxy* proxy,
                                                                   const gchar* sender_name,
                                                                   const gchar* signal_name,
                                                                   GVariant* parameters);
static gint power_services_dbus_interfaces_power_settings_dbus_proxy_get_brightness (PowerServicesDBusInterfacesPowerSettings* self);
static void power_services_dbus_interfaces_power_settings_dbus_proxy_set_brightness (PowerServicesDBusInterfacesPowerSettings* self,
                                                                              gint value);
static void power_services_dbus_interfaces_power_settings_proxy_power_services_dbus_interfaces_power_settings_interface_init (PowerServicesDBusInterfacesPowerSettingsIface* iface);
static void power_services_dbus_interfaces_power_settings_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* power_services_dbus_interfaces_power_settings_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 GVariant* _dbus_power_services_dbus_interfaces_power_settings_get_brightness (PowerServicesDBusInterfacesPowerSettings* self);
static gboolean power_services_dbus_interfaces_power_settings_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_power_services_dbus_interfaces_power_settings_set_brightness (PowerServicesDBusInterfacesPowerSettings* self,
                                                                         GVariant* _value);
static void _power_services_dbus_interfaces_power_settings_unregister_object (gpointer user_data);

static const GDBusMethodInfo * const _power_services_dbus_interfaces_power_settings_dbus_method_info[] = {NULL};
static const GDBusSignalInfo * const _power_services_dbus_interfaces_power_settings_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo _power_services_dbus_interfaces_power_settings_dbus_property_info_brightness = {-1, "Brightness", "i", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE, NULL};
static const GDBusPropertyInfo * const _power_services_dbus_interfaces_power_settings_dbus_property_info[] = {&_power_services_dbus_interfaces_power_settings_dbus_property_info_brightness, NULL};
static const GDBusInterfaceInfo _power_services_dbus_interfaces_power_settings_dbus_interface_info = {-1, "org.gnome.SettingsDaemon.Power.Screen", (GDBusMethodInfo **) (&_power_services_dbus_interfaces_power_settings_dbus_method_info), (GDBusSignalInfo **) (&_power_services_dbus_interfaces_power_settings_dbus_signal_info), (GDBusPropertyInfo **) (&_power_services_dbus_interfaces_power_settings_dbus_property_info), NULL};
static const GDBusInterfaceVTable _power_services_dbus_interfaces_power_settings_dbus_interface_vtable = {power_services_dbus_interfaces_power_settings_dbus_interface_method_call, power_services_dbus_interfaces_power_settings_dbus_interface_get_property, power_services_dbus_interfaces_power_settings_dbus_interface_set_property};

gint
power_services_dbus_interfaces_power_settings_get_brightness (PowerServicesDBusInterfacesPowerSettings* self)
{
	PowerServicesDBusInterfacesPowerSettingsIface* _iface_;
	g_return_val_if_fail (self != NULL, 0);
	_iface_ = POWER_SERVICES_DBUS_INTERFACES_POWER_SETTINGS_GET_INTERFACE (self);
	if (_iface_->get_brightness) {
		return _iface_->get_brightness (self);
	}
	return -1;
}

void
power_services_dbus_interfaces_power_settings_set_brightness (PowerServicesDBusInterfacesPowerSettings* self,
                                                              gint value)
{
	PowerServicesDBusInterfacesPowerSettingsIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = POWER_SERVICES_DBUS_INTERFACES_POWER_SETTINGS_GET_INTERFACE (self);
	if (_iface_->set_brightness) {
		_iface_->set_brightness (self, value);
	}
}

static void
power_services_dbus_interfaces_power_settings_default_init (PowerServicesDBusInterfacesPowerSettingsIface * iface,
                                                            gpointer iface_data)
{
}

static GType
power_services_dbus_interfaces_power_settings_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PowerServicesDBusInterfacesPowerSettingsIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) power_services_dbus_interfaces_power_settings_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType power_services_dbus_interfaces_power_settings_type_id;
	power_services_dbus_interfaces_power_settings_type_id = g_type_register_static (G_TYPE_INTERFACE, "PowerServicesDBusInterfacesPowerSettings", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (power_services_dbus_interfaces_power_settings_type_id, G_TYPE_OBJECT);
	g_type_set_qdata (power_services_dbus_interfaces_power_settings_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) power_services_dbus_interfaces_power_settings_proxy_get_type);
	g_type_set_qdata (power_services_dbus_interfaces_power_settings_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.gnome.SettingsDaemon.Power.Screen");
	g_type_set_qdata (power_services_dbus_interfaces_power_settings_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_power_services_dbus_interfaces_power_settings_dbus_interface_info));
	g_type_set_qdata (power_services_dbus_interfaces_power_settings_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) power_services_dbus_interfaces_power_settings_register_object);
	return power_services_dbus_interfaces_power_settings_type_id;
}

GType
power_services_dbus_interfaces_power_settings_get_type (void)
{
	static volatile gsize power_services_dbus_interfaces_power_settings_type_id__once = 0;
	if (g_once_init_enter (&power_services_dbus_interfaces_power_settings_type_id__once)) {
		GType power_services_dbus_interfaces_power_settings_type_id;
		power_services_dbus_interfaces_power_settings_type_id = power_services_dbus_interfaces_power_settings_get_type_once ();
		g_once_init_leave (&power_services_dbus_interfaces_power_settings_type_id__once, power_services_dbus_interfaces_power_settings_type_id);
	}
	return power_services_dbus_interfaces_power_settings_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (PowerServicesDBusInterfacesPowerSettingsProxy, power_services_dbus_interfaces_power_settings_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_SETTINGS, power_services_dbus_interfaces_power_settings_proxy_power_services_dbus_interfaces_power_settings_interface_init) )
static void
power_services_dbus_interfaces_power_settings_proxy_class_init (PowerServicesDBusInterfacesPowerSettingsProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = power_services_dbus_interfaces_power_settings_proxy_g_signal;
}

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

static void
power_services_dbus_interfaces_power_settings_proxy_init (PowerServicesDBusInterfacesPowerSettingsProxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_power_services_dbus_interfaces_power_settings_dbus_interface_info));
}

static gint
power_services_dbus_interfaces_power_settings_dbus_proxy_get_brightness (PowerServicesDBusInterfacesPowerSettings* self)
{
	GVariant *_inner_reply;
	gint _result;
	_inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "Brightness");
	if (!_inner_reply) {
		GVariant *_arguments;
		GVariant *_reply;
		GVariantBuilder _arguments_builder;
		g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
		g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.gnome.SettingsDaemon.Power.Screen"));
		g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("Brightness"));
		_arguments = g_variant_builder_end (&_arguments_builder);
		_reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Get", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
		if (!_reply) {
			gint _tmp75_ = 0;
			return _tmp75_;
		}
		g_variant_get (_reply, "(v)", &_inner_reply);
		g_variant_unref (_reply);
	}
	_result = g_variant_get_int32 (_inner_reply);
	g_variant_unref (_inner_reply);
	return _result;
}

static void
power_services_dbus_interfaces_power_settings_dbus_proxy_set_brightness (PowerServicesDBusInterfacesPowerSettings* self,
                                                                         gint value)
{
	GVariant *_arguments;
	GVariant *_reply;
	GVariantBuilder _arguments_builder;
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("org.gnome.SettingsDaemon.Power.Screen"));
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("Brightness"));
	g_variant_builder_open (&_arguments_builder, G_VARIANT_TYPE_VARIANT);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_int32 (value));
	g_variant_builder_close (&_arguments_builder);
	_arguments = g_variant_builder_end (&_arguments_builder);
	_reply = g_dbus_proxy_call_sync ((GDBusProxy *) self, "org.freedesktop.DBus.Properties.Set", _arguments, G_DBUS_CALL_FLAGS_NONE, -1, NULL, NULL);
	if (!_reply) {
		return;
	}
	g_variant_unref (_reply);
}

static void
power_services_dbus_interfaces_power_settings_proxy_power_services_dbus_interfaces_power_settings_interface_init (PowerServicesDBusInterfacesPowerSettingsIface* iface)
{
	iface->get_brightness = power_services_dbus_interfaces_power_settings_dbus_proxy_get_brightness;
	iface->set_brightness = power_services_dbus_interfaces_power_settings_dbus_proxy_set_brightness;
}

static void
power_services_dbus_interfaces_power_settings_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];
	g_object_unref (invocation);
}

static GVariant*
_dbus_power_services_dbus_interfaces_power_settings_get_brightness (PowerServicesDBusInterfacesPowerSettings* self)
{
	gint result;
	GVariant* _reply;
	result = power_services_dbus_interfaces_power_settings_get_brightness (self);
	_reply = g_variant_new_int32 (result);
	return _reply;
}

static GVariant*
power_services_dbus_interfaces_power_settings_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)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (property_name, "Brightness") == 0) {
		return _dbus_power_services_dbus_interfaces_power_settings_get_brightness (object);
	}
	return NULL;
}

static void
_dbus_power_services_dbus_interfaces_power_settings_set_brightness (PowerServicesDBusInterfacesPowerSettings* self,
                                                                    GVariant* _value)
{
	gint value = 0;
	value = g_variant_get_int32 (_value);
	power_services_dbus_interfaces_power_settings_set_brightness (self, value);
}

static gboolean
power_services_dbus_interfaces_power_settings_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)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (property_name, "Brightness") == 0) {
		_dbus_power_services_dbus_interfaces_power_settings_set_brightness (object, value);
		return TRUE;
	}
	return FALSE;
}

guint
power_services_dbus_interfaces_power_settings_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 *) (&_power_services_dbus_interfaces_power_settings_dbus_interface_info), &_power_services_dbus_interfaces_power_settings_dbus_interface_vtable, data, _power_services_dbus_interfaces_power_settings_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

static void
_power_services_dbus_interfaces_power_settings_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);
}

