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

/*
 * SPDX-License-Identifier: GPL-2.0-or-later
 * SPDX-FileCopyrightText: 2024 elementary, Inc. (https://elementary.io)
 */

#include "power.h"
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.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_PROFILE (power_services_dbus_interfaces_power_profile_get_type ())
#define POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_PROFILE, PowerServicesDBusInterfacesPowerProfile))
#define POWER_SERVICES_DBUS_INTERFACES_IS_POWER_PROFILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_PROFILE))
#define POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_PROFILE, PowerServicesDBusInterfacesPowerProfileIface))

typedef struct _PowerServicesDBusInterfacesPowerProfile PowerServicesDBusInterfacesPowerProfile;
typedef struct _PowerServicesDBusInterfacesPowerProfileIface PowerServicesDBusInterfacesPowerProfileIface;

#define POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_PROFILE_PROXY (power_services_dbus_interfaces_power_profile_proxy_get_type ())
enum  {
	POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE_CHANGED_SIGNAL,
	POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE_NUM_SIGNALS
};
static guint power_services_dbus_interfaces_power_profile_signals[POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE_NUM_SIGNALS] = {0};
typedef GDBusProxy PowerServicesDBusInterfacesPowerProfileProxy;
typedef GDBusProxyClass PowerServicesDBusInterfacesPowerProfileProxyClass;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _PowerServicesDBusInterfacesPowerProfileIface {
	GTypeInterface parent_iface;
	GHashTable** (*get_profiles) (PowerServicesDBusInterfacesPowerProfile* self, gint* result_length1);
	gchar* (*get_active_profile) (PowerServicesDBusInterfacesPowerProfile* self);
	void (*set_active_profile) (PowerServicesDBusInterfacesPowerProfile* self, const gchar* value);
};

VALA_EXTERN GType power_services_dbus_interfaces_power_profile_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType power_services_dbus_interfaces_power_profile_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint power_services_dbus_interfaces_power_profile_register_object (void* object,
                                                                    GDBusConnection* connection,
                                                                    const gchar* path,
                                                                    GError** error);
VALA_EXTERN GHashTable** power_services_dbus_interfaces_power_profile_get_profiles (PowerServicesDBusInterfacesPowerProfile* self,
                                                                        gint* result_length1);
VALA_EXTERN gchar* power_services_dbus_interfaces_power_profile_get_active_profile (PowerServicesDBusInterfacesPowerProfile* self);
VALA_EXTERN void power_services_dbus_interfaces_power_profile_set_active_profile (PowerServicesDBusInterfacesPowerProfile* self,
                                                                      const gchar* value);
static GType power_services_dbus_interfaces_power_profile_get_type_once (void);
static void power_services_dbus_interfaces_power_profile_proxy_g_signal (GDBusProxy* proxy,
                                                                  const gchar* sender_name,
                                                                  const gchar* signal_name,
                                                                  GVariant* parameters);
static void _dbus_handle_power_services_dbus_interfaces_power_profile_changed (PowerServicesDBusInterfacesPowerProfile* self,
                                                                        GVariant* parameters);
static GHashTable** power_services_dbus_interfaces_power_profile_dbus_proxy_get_profiles (PowerServicesDBusInterfacesPowerProfile* self,
                                                                                   gint* result_length1);
static gchar* power_services_dbus_interfaces_power_profile_dbus_proxy_get_active_profile (PowerServicesDBusInterfacesPowerProfile* self);
static void power_services_dbus_interfaces_power_profile_dbus_proxy_set_active_profile (PowerServicesDBusInterfacesPowerProfile* self,
                                                                                 const gchar* value);
static void power_services_dbus_interfaces_power_profile_proxy_power_services_dbus_interfaces_power_profile_interface_init (PowerServicesDBusInterfacesPowerProfileIface* iface);
static void power_services_dbus_interfaces_power_profile_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_profile_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_profile_get_profiles (PowerServicesDBusInterfacesPowerProfile* self);
static GVariant* _dbus_power_services_dbus_interfaces_power_profile_get_active_profile (PowerServicesDBusInterfacesPowerProfile* self);
static gboolean power_services_dbus_interfaces_power_profile_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_profile_set_active_profile (PowerServicesDBusInterfacesPowerProfile* self,
                                                                            GVariant* _value);
static void _dbus_power_services_dbus_interfaces_power_profile_changed (GObject* _sender,
                                                                 gpointer* _data);
static void _power_services_dbus_interfaces_power_profile_unregister_object (gpointer user_data);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static const GDBusMethodInfo * const _power_services_dbus_interfaces_power_profile_dbus_method_info[] = {NULL};
static const GDBusArgInfo * const _power_services_dbus_interfaces_power_profile_dbus_arg_info_changed[] = {NULL};
static const GDBusSignalInfo _power_services_dbus_interfaces_power_profile_dbus_signal_info_changed = {-1, "Changed", (GDBusArgInfo **) (&_power_services_dbus_interfaces_power_profile_dbus_arg_info_changed), NULL};
static const GDBusSignalInfo * const _power_services_dbus_interfaces_power_profile_dbus_signal_info[] = {&_power_services_dbus_interfaces_power_profile_dbus_signal_info_changed, NULL};
static const GDBusPropertyInfo _power_services_dbus_interfaces_power_profile_dbus_property_info_profiles = {-1, "Profiles", "aa{sv}", G_DBUS_PROPERTY_INFO_FLAGS_READABLE, NULL};
static const GDBusPropertyInfo _power_services_dbus_interfaces_power_profile_dbus_property_info_active_profile = {-1, "ActiveProfile", "s", G_DBUS_PROPERTY_INFO_FLAGS_READABLE | G_DBUS_PROPERTY_INFO_FLAGS_WRITABLE, NULL};
static const GDBusPropertyInfo * const _power_services_dbus_interfaces_power_profile_dbus_property_info[] = {&_power_services_dbus_interfaces_power_profile_dbus_property_info_profiles, &_power_services_dbus_interfaces_power_profile_dbus_property_info_active_profile, NULL};
static const GDBusInterfaceInfo _power_services_dbus_interfaces_power_profile_dbus_interface_info = {-1, "net.hadess.PowerProfiles", (GDBusMethodInfo **) (&_power_services_dbus_interfaces_power_profile_dbus_method_info), (GDBusSignalInfo **) (&_power_services_dbus_interfaces_power_profile_dbus_signal_info), (GDBusPropertyInfo **) (&_power_services_dbus_interfaces_power_profile_dbus_property_info), NULL};
static const GDBusInterfaceVTable _power_services_dbus_interfaces_power_profile_dbus_interface_vtable = {power_services_dbus_interfaces_power_profile_dbus_interface_method_call, power_services_dbus_interfaces_power_profile_dbus_interface_get_property, power_services_dbus_interfaces_power_profile_dbus_interface_set_property};

GHashTable**
power_services_dbus_interfaces_power_profile_get_profiles (PowerServicesDBusInterfacesPowerProfile* self,
                                                           gint* result_length1)
{
	PowerServicesDBusInterfacesPowerProfileIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE_GET_INTERFACE (self);
	if (_iface_->get_profiles) {
		return _iface_->get_profiles (self, result_length1);
	}
	return NULL;
}

gchar*
power_services_dbus_interfaces_power_profile_get_active_profile (PowerServicesDBusInterfacesPowerProfile* self)
{
	PowerServicesDBusInterfacesPowerProfileIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE_GET_INTERFACE (self);
	if (_iface_->get_active_profile) {
		return _iface_->get_active_profile (self);
	}
	return NULL;
}

void
power_services_dbus_interfaces_power_profile_set_active_profile (PowerServicesDBusInterfacesPowerProfile* self,
                                                                 const gchar* value)
{
	PowerServicesDBusInterfacesPowerProfileIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE_GET_INTERFACE (self);
	if (_iface_->set_active_profile) {
		_iface_->set_active_profile (self, value);
	}
}

static void
power_services_dbus_interfaces_power_profile_default_init (PowerServicesDBusInterfacesPowerProfileIface * iface,
                                                           gpointer iface_data)
{
	power_services_dbus_interfaces_power_profile_signals[POWER_SERVICES_DBUS_INTERFACES_POWER_PROFILE_CHANGED_SIGNAL] = g_signal_new ("changed", POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_PROFILE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static GType
power_services_dbus_interfaces_power_profile_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PowerServicesDBusInterfacesPowerProfileIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) power_services_dbus_interfaces_power_profile_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType power_services_dbus_interfaces_power_profile_type_id;
	power_services_dbus_interfaces_power_profile_type_id = g_type_register_static (G_TYPE_INTERFACE, "PowerServicesDBusInterfacesPowerProfile", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (power_services_dbus_interfaces_power_profile_type_id, G_TYPE_OBJECT);
	g_type_set_qdata (power_services_dbus_interfaces_power_profile_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) power_services_dbus_interfaces_power_profile_proxy_get_type);
	g_type_set_qdata (power_services_dbus_interfaces_power_profile_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "net.hadess.PowerProfiles");
	g_type_set_qdata (power_services_dbus_interfaces_power_profile_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_power_services_dbus_interfaces_power_profile_dbus_interface_info));
	g_type_set_qdata (power_services_dbus_interfaces_power_profile_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) power_services_dbus_interfaces_power_profile_register_object);
	return power_services_dbus_interfaces_power_profile_type_id;
}

GType
power_services_dbus_interfaces_power_profile_get_type (void)
{
	static volatile gsize power_services_dbus_interfaces_power_profile_type_id__once = 0;
	if (g_once_init_enter (&power_services_dbus_interfaces_power_profile_type_id__once)) {
		GType power_services_dbus_interfaces_power_profile_type_id;
		power_services_dbus_interfaces_power_profile_type_id = power_services_dbus_interfaces_power_profile_get_type_once ();
		g_once_init_leave (&power_services_dbus_interfaces_power_profile_type_id__once, power_services_dbus_interfaces_power_profile_type_id);
	}
	return power_services_dbus_interfaces_power_profile_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (PowerServicesDBusInterfacesPowerProfileProxy, power_services_dbus_interfaces_power_profile_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (POWER_SERVICES_DBUS_INTERFACES_TYPE_POWER_PROFILE, power_services_dbus_interfaces_power_profile_proxy_power_services_dbus_interfaces_power_profile_interface_init) )
static void
power_services_dbus_interfaces_power_profile_proxy_class_init (PowerServicesDBusInterfacesPowerProfileProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = power_services_dbus_interfaces_power_profile_proxy_g_signal;
}

static void
_dbus_handle_power_services_dbus_interfaces_power_profile_changed (PowerServicesDBusInterfacesPowerProfile* self,
                                                                   GVariant* parameters)
{
	GVariantIter _arguments_iter;
	g_variant_iter_init (&_arguments_iter, parameters);
	g_signal_emit_by_name (self, "changed");
}

static void
power_services_dbus_interfaces_power_profile_proxy_g_signal (GDBusProxy* proxy,
                                                             const gchar* sender_name,
                                                             const gchar* signal_name,
                                                             GVariant* parameters)
{
	if (strcmp (signal_name, "Changed") == 0) {
		_dbus_handle_power_services_dbus_interfaces_power_profile_changed ((PowerServicesDBusInterfacesPowerProfile*) proxy, parameters);
	}
}

static void
power_services_dbus_interfaces_power_profile_proxy_init (PowerServicesDBusInterfacesPowerProfileProxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_power_services_dbus_interfaces_power_profile_dbus_interface_info));
}

static GHashTable**
power_services_dbus_interfaces_power_profile_dbus_proxy_get_profiles (PowerServicesDBusInterfacesPowerProfile* self,
                                                                      gint* result_length1)
{
	GVariant *_inner_reply;
	GHashTable** _result;
	gint _result_length1;
	GHashTable** _tmp87_;
	gint _tmp87__length;
	gint _tmp87__size;
	gint _tmp87__length1;
	GVariantIter _tmp88_;
	GVariant* _tmp89_;
	_inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "Profiles");
	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 ("net.hadess.PowerProfiles"));
		g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("Profiles"));
		_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) {
			return NULL;
		}
		g_variant_get (_reply, "(v)", &_inner_reply);
		g_variant_unref (_reply);
	}
	_result_length1 = 0;
	_tmp87_ = g_new (GHashTable*, 5);
	_tmp87__length = 0;
	_tmp87__size = 4;
	_tmp87__length1 = 0;
	g_variant_iter_init (&_tmp88_, _inner_reply);
	for (; (_tmp89_ = g_variant_iter_next_value (&_tmp88_)) != NULL; _tmp87__length1++) {
		GHashTable* _tmp90_;
		GVariantIter _tmp91_;
		GVariant* _tmp92_;
		GVariant* _tmp93_;
		if (_tmp87__size == _tmp87__length) {
			_tmp87__size = 2 * _tmp87__size;
			_tmp87_ = g_renew (GHashTable*, _tmp87_, _tmp87__size + 1);
		}
		_tmp90_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
		g_variant_iter_init (&_tmp91_, _tmp89_);
		while (g_variant_iter_loop (&_tmp91_, "{?*}", &_tmp92_, &_tmp93_)) {
			g_hash_table_insert (_tmp90_, g_variant_dup_string (_tmp92_, NULL), g_variant_get_variant (_tmp93_));
		}
		_tmp87_[_tmp87__length++] = _tmp90_;
		g_variant_unref (_tmp89_);
	}
	_result_length1 = _tmp87__length1;
	_tmp87_[_tmp87__length] = NULL;
	_result = _tmp87_;
	*result_length1 = _result_length1;
	g_variant_unref (_inner_reply);
	return _result;
}

static gchar*
power_services_dbus_interfaces_power_profile_dbus_proxy_get_active_profile (PowerServicesDBusInterfacesPowerProfile* self)
{
	GVariant *_inner_reply;
	gchar* _result;
	_inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "ActiveProfile");
	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 ("net.hadess.PowerProfiles"));
		g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("ActiveProfile"));
		_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) {
			return NULL;
		}
		g_variant_get (_reply, "(v)", &_inner_reply);
		g_variant_unref (_reply);
	}
	_result = g_variant_dup_string (_inner_reply, NULL);
	g_variant_unref (_inner_reply);
	return _result;
}

static void
power_services_dbus_interfaces_power_profile_dbus_proxy_set_active_profile (PowerServicesDBusInterfacesPowerProfile* self,
                                                                            const gchar* 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 ("net.hadess.PowerProfiles"));
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("ActiveProfile"));
	g_variant_builder_open (&_arguments_builder, G_VARIANT_TYPE_VARIANT);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (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_profile_proxy_power_services_dbus_interfaces_power_profile_interface_init (PowerServicesDBusInterfacesPowerProfileIface* iface)
{
	iface->get_profiles = power_services_dbus_interfaces_power_profile_dbus_proxy_get_profiles;
	iface->get_active_profile = power_services_dbus_interfaces_power_profile_dbus_proxy_get_active_profile;
	iface->set_active_profile = power_services_dbus_interfaces_power_profile_dbus_proxy_set_active_profile;
}

static void
power_services_dbus_interfaces_power_profile_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_profile_get_profiles (PowerServicesDBusInterfacesPowerProfile* self)
{
	GHashTable** result;
	gint result_length1 = 0;
	GVariant* _reply;
	GHashTable** _tmp94_;
	GVariantBuilder _tmp95_;
	gint _tmp96_;
	result = power_services_dbus_interfaces_power_profile_get_profiles (self, &result_length1);
	_tmp94_ = result;
	g_variant_builder_init (&_tmp95_, G_VARIANT_TYPE ("aa{sv}"));
	for (_tmp96_ = 0; _tmp96_ < result_length1; _tmp96_++) {
		GVariantBuilder _tmp97_;
		GHashTableIter _tmp98_;
		gpointer _tmp99_;
		gpointer _tmp100_;
		g_hash_table_iter_init (&_tmp98_, *_tmp94_);
		g_variant_builder_init (&_tmp97_, G_VARIANT_TYPE ("a{sv}"));
		while (g_hash_table_iter_next (&_tmp98_, &_tmp99_, &_tmp100_)) {
			gchar* _key;
			GVariant* _value;
			_key = (gchar*) _tmp99_;
			_value = (GVariant*) _tmp100_;
			g_variant_builder_add (&_tmp97_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value));
		}
		g_variant_builder_add_value (&_tmp95_, g_variant_builder_end (&_tmp97_));
		_tmp94_++;
	}
	_reply = g_variant_builder_end (&_tmp95_);
	result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_hash_table_unref), NULL);
	return _reply;
}

static GVariant*
_dbus_power_services_dbus_interfaces_power_profile_get_active_profile (PowerServicesDBusInterfacesPowerProfile* self)
{
	gchar* result;
	GVariant* _reply;
	result = power_services_dbus_interfaces_power_profile_get_active_profile (self);
	_reply = g_variant_new_string (result);
	_g_free0 (result);
	return _reply;
}

static GVariant*
power_services_dbus_interfaces_power_profile_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, "Profiles") == 0) {
		return _dbus_power_services_dbus_interfaces_power_profile_get_profiles (object);
	} else if (strcmp (property_name, "ActiveProfile") == 0) {
		return _dbus_power_services_dbus_interfaces_power_profile_get_active_profile (object);
	}
	return NULL;
}

static void
_dbus_power_services_dbus_interfaces_power_profile_set_active_profile (PowerServicesDBusInterfacesPowerProfile* self,
                                                                       GVariant* _value)
{
	gchar* value = NULL;
	value = g_variant_dup_string (_value, NULL);
	power_services_dbus_interfaces_power_profile_set_active_profile (self, value);
	_g_free0 (value);
}

static gboolean
power_services_dbus_interfaces_power_profile_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, "ActiveProfile") == 0) {
		_dbus_power_services_dbus_interfaces_power_profile_set_active_profile (object, value);
		return TRUE;
	}
	return FALSE;
}

static void
_dbus_power_services_dbus_interfaces_power_profile_changed (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, "net.hadess.PowerProfiles", "Changed", _arguments, NULL);
}

guint
power_services_dbus_interfaces_power_profile_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_profile_dbus_interface_info), &_power_services_dbus_interfaces_power_profile_dbus_interface_vtable, data, _power_services_dbus_interfaces_power_profile_unregister_object, error);
	if (!result) {
		return 0;
	}
	g_signal_connect (object, "changed", (GCallback) _dbus_power_services_dbus_interfaces_power_profile_changed, data);
	return result;
}

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

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

