/* UPower.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from UPower.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 "power.h"
#include <stdlib.h>
#include <string.h>
#include <glib.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

enum  {
	POWER_SERVICES_DBUS_INTERFACES_UPOWER_DEVICE_ADDED_SIGNAL,
	POWER_SERVICES_DBUS_INTERFACES_UPOWER_DEVICE_REMOVED_SIGNAL,
	POWER_SERVICES_DBUS_INTERFACES_UPOWER_NUM_SIGNALS
};
static guint power_services_dbus_interfaces_upower_signals[POWER_SERVICES_DBUS_INTERFACES_UPOWER_NUM_SIGNALS] = {0};
typedef GDBusProxy PowerServicesDBusInterfacesUPowerProxy;
typedef GDBusProxyClass PowerServicesDBusInterfacesUPowerProxyClass;
#define _g_free0(var) (var = (g_free (var), NULL))

static GType power_services_dbus_interfaces_upower_get_type_once (void);
static void power_services_dbus_interfaces_upower_proxy_g_signal (GDBusProxy* proxy,
                                                           const gchar* sender_name,
                                                           const gchar* signal_name,
                                                           GVariant* parameters);
static void _dbus_handle_power_services_dbus_interfaces_upower_device_added (PowerServicesDBusInterfacesUPower* self,
                                                                      GVariant* parameters);
static void _dbus_handle_power_services_dbus_interfaces_upower_device_removed (PowerServicesDBusInterfacesUPower* self,
                                                                        GVariant* parameters);
static char** power_services_dbus_interfaces_upower_proxy_enumerate_devices (PowerServicesDBusInterfacesUPower* self,
                                                                      gint* result_length1,
                                                                      GError** error);
static char* power_services_dbus_interfaces_upower_proxy_get_display_device (PowerServicesDBusInterfacesUPower* self,
                                                                      GError** error);
static gboolean power_services_dbus_interfaces_upower_dbus_proxy_get_on_battery (PowerServicesDBusInterfacesUPower* self);
static void power_services_dbus_interfaces_upower_proxy_power_services_dbus_interfaces_upower_interface_init (PowerServicesDBusInterfacesUPowerIface* iface);
static void _dbus_power_services_dbus_interfaces_upower_enumerate_devices (PowerServicesDBusInterfacesUPower* self,
                                                                    GVariant* _parameters_,
                                                                    GDBusMethodInvocation* invocation);
static void _dbus_power_services_dbus_interfaces_upower_get_display_device (PowerServicesDBusInterfacesUPower* self,
                                                                     GVariant* _parameters_,
                                                                     GDBusMethodInvocation* invocation);
static void power_services_dbus_interfaces_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* power_services_dbus_interfaces_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 GVariant* _dbus_power_services_dbus_interfaces_upower_get_on_battery (PowerServicesDBusInterfacesUPower* self);
static gboolean power_services_dbus_interfaces_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_power_services_dbus_interfaces_upower_device_added (GObject* _sender,
                                                               const char* device_path,
                                                               gpointer* _data);
static void _dbus_power_services_dbus_interfaces_upower_device_removed (GObject* _sender,
                                                                 const char* device_path,
                                                                 gpointer* _data);
static void _power_services_dbus_interfaces_upower_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 GDBusArgInfo _power_services_dbus_interfaces_upower_dbus_arg_info_enumerate_devices_result = {-1, "result", "ao", NULL};
static const GDBusArgInfo * const _power_services_dbus_interfaces_upower_dbus_arg_info_enumerate_devices_in[] = {NULL};
static const GDBusArgInfo * const _power_services_dbus_interfaces_upower_dbus_arg_info_enumerate_devices_out[] = {&_power_services_dbus_interfaces_upower_dbus_arg_info_enumerate_devices_result, NULL};
static const GDBusMethodInfo _power_services_dbus_interfaces_upower_dbus_method_info_enumerate_devices = {-1, "EnumerateDevices", (GDBusArgInfo **) (&_power_services_dbus_interfaces_upower_dbus_arg_info_enumerate_devices_in), (GDBusArgInfo **) (&_power_services_dbus_interfaces_upower_dbus_arg_info_enumerate_devices_out), NULL};
static const GDBusArgInfo _power_services_dbus_interfaces_upower_dbus_arg_info_get_display_device_result = {-1, "result", "o", NULL};
static const GDBusArgInfo * const _power_services_dbus_interfaces_upower_dbus_arg_info_get_display_device_in[] = {NULL};
static const GDBusArgInfo * const _power_services_dbus_interfaces_upower_dbus_arg_info_get_display_device_out[] = {&_power_services_dbus_interfaces_upower_dbus_arg_info_get_display_device_result, NULL};
static const GDBusMethodInfo _power_services_dbus_interfaces_upower_dbus_method_info_get_display_device = {-1, "GetDisplayDevice", (GDBusArgInfo **) (&_power_services_dbus_interfaces_upower_dbus_arg_info_get_display_device_in), (GDBusArgInfo **) (&_power_services_dbus_interfaces_upower_dbus_arg_info_get_display_device_out), NULL};
static const GDBusMethodInfo * const _power_services_dbus_interfaces_upower_dbus_method_info[] = {&_power_services_dbus_interfaces_upower_dbus_method_info_enumerate_devices, &_power_services_dbus_interfaces_upower_dbus_method_info_get_display_device, NULL};
static const GDBusArgInfo _power_services_dbus_interfaces_upower_dbus_arg_info_device_added_device_path = {-1, "device_path", "o", NULL};
static const GDBusArgInfo * const _power_services_dbus_interfaces_upower_dbus_arg_info_device_added[] = {&_power_services_dbus_interfaces_upower_dbus_arg_info_device_added_device_path, NULL};
static const GDBusSignalInfo _power_services_dbus_interfaces_upower_dbus_signal_info_device_added = {-1, "DeviceAdded", (GDBusArgInfo **) (&_power_services_dbus_interfaces_upower_dbus_arg_info_device_added), NULL};
static const GDBusArgInfo _power_services_dbus_interfaces_upower_dbus_arg_info_device_removed_device_path = {-1, "device_path", "o", NULL};
static const GDBusArgInfo * const _power_services_dbus_interfaces_upower_dbus_arg_info_device_removed[] = {&_power_services_dbus_interfaces_upower_dbus_arg_info_device_removed_device_path, NULL};
static const GDBusSignalInfo _power_services_dbus_interfaces_upower_dbus_signal_info_device_removed = {-1, "DeviceRemoved", (GDBusArgInfo **) (&_power_services_dbus_interfaces_upower_dbus_arg_info_device_removed), NULL};
static const GDBusSignalInfo * const _power_services_dbus_interfaces_upower_dbus_signal_info[] = {&_power_services_dbus_interfaces_upower_dbus_signal_info_device_added, &_power_services_dbus_interfaces_upower_dbus_signal_info_device_removed, NULL};
static const GDBusPropertyInfo _power_services_dbus_interfaces_upower_dbus_property_info_on_battery = {-1, "OnBattery", "b", G_DBUS_PROPERTY_INFO_FLAGS_READABLE, NULL};
static const GDBusPropertyInfo * const _power_services_dbus_interfaces_upower_dbus_property_info[] = {&_power_services_dbus_interfaces_upower_dbus_property_info_on_battery, NULL};
static const GDBusInterfaceInfo _power_services_dbus_interfaces_upower_dbus_interface_info = {-1, "org.freedesktop.UPower", (GDBusMethodInfo **) (&_power_services_dbus_interfaces_upower_dbus_method_info), (GDBusSignalInfo **) (&_power_services_dbus_interfaces_upower_dbus_signal_info), (GDBusPropertyInfo **) (&_power_services_dbus_interfaces_upower_dbus_property_info), NULL};
static const GDBusInterfaceVTable _power_services_dbus_interfaces_upower_dbus_interface_vtable = {power_services_dbus_interfaces_upower_dbus_interface_method_call, power_services_dbus_interfaces_upower_dbus_interface_get_property, power_services_dbus_interfaces_upower_dbus_interface_set_property};

char**
power_services_dbus_interfaces_upower_enumerate_devices (PowerServicesDBusInterfacesUPower* self,
                                                         gint* result_length1,
                                                         GError** error)
{
	PowerServicesDBusInterfacesUPowerIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = POWER_SERVICES_DBUS_INTERFACES_UPOWER_GET_INTERFACE (self);
	if (_iface_->enumerate_devices) {
		return _iface_->enumerate_devices (self, result_length1, error);
	}
	return NULL;
}

char*
power_services_dbus_interfaces_upower_get_display_device (PowerServicesDBusInterfacesUPower* self,
                                                          GError** error)
{
	PowerServicesDBusInterfacesUPowerIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = POWER_SERVICES_DBUS_INTERFACES_UPOWER_GET_INTERFACE (self);
	if (_iface_->get_display_device) {
		return _iface_->get_display_device (self, error);
	}
	return NULL;
}

gboolean
power_services_dbus_interfaces_upower_get_on_battery (PowerServicesDBusInterfacesUPower* self)
{
	PowerServicesDBusInterfacesUPowerIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = POWER_SERVICES_DBUS_INTERFACES_UPOWER_GET_INTERFACE (self);
	if (_iface_->get_on_battery) {
		return _iface_->get_on_battery (self);
	}
	return FALSE;
}

static void
power_services_dbus_interfaces_upower_default_init (PowerServicesDBusInterfacesUPowerIface * iface,
                                                    gpointer iface_data)
{
	power_services_dbus_interfaces_upower_signals[POWER_SERVICES_DBUS_INTERFACES_UPOWER_DEVICE_ADDED_SIGNAL] = g_signal_new ("device-added", POWER_SERVICES_DBUS_INTERFACES_TYPE_UPOWER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
	power_services_dbus_interfaces_upower_signals[POWER_SERVICES_DBUS_INTERFACES_UPOWER_DEVICE_REMOVED_SIGNAL] = g_signal_new ("device-removed", POWER_SERVICES_DBUS_INTERFACES_TYPE_UPOWER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING);
}

static GType
power_services_dbus_interfaces_upower_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PowerServicesDBusInterfacesUPowerIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) power_services_dbus_interfaces_upower_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType power_services_dbus_interfaces_upower_type_id;
	power_services_dbus_interfaces_upower_type_id = g_type_register_static (G_TYPE_INTERFACE, "PowerServicesDBusInterfacesUPower", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (power_services_dbus_interfaces_upower_type_id, g_dbus_proxy_get_type ());
	g_type_set_qdata (power_services_dbus_interfaces_upower_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) power_services_dbus_interfaces_upower_proxy_get_type);
	g_type_set_qdata (power_services_dbus_interfaces_upower_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.UPower");
	g_type_set_qdata (power_services_dbus_interfaces_upower_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_power_services_dbus_interfaces_upower_dbus_interface_info));
	g_type_set_qdata (power_services_dbus_interfaces_upower_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) power_services_dbus_interfaces_upower_register_object);
	return power_services_dbus_interfaces_upower_type_id;
}

GType
power_services_dbus_interfaces_upower_get_type (void)
{
	static volatile gsize power_services_dbus_interfaces_upower_type_id__once = 0;
	if (g_once_init_enter (&power_services_dbus_interfaces_upower_type_id__once)) {
		GType power_services_dbus_interfaces_upower_type_id;
		power_services_dbus_interfaces_upower_type_id = power_services_dbus_interfaces_upower_get_type_once ();
		g_once_init_leave (&power_services_dbus_interfaces_upower_type_id__once, power_services_dbus_interfaces_upower_type_id);
	}
	return power_services_dbus_interfaces_upower_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (PowerServicesDBusInterfacesUPowerProxy, power_services_dbus_interfaces_upower_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (POWER_SERVICES_DBUS_INTERFACES_TYPE_UPOWER, power_services_dbus_interfaces_upower_proxy_power_services_dbus_interfaces_upower_interface_init) )
static void
power_services_dbus_interfaces_upower_proxy_class_init (PowerServicesDBusInterfacesUPowerProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = power_services_dbus_interfaces_upower_proxy_g_signal;
}

static void
_dbus_handle_power_services_dbus_interfaces_upower_device_added (PowerServicesDBusInterfacesUPower* self,
                                                                 GVariant* parameters)
{
	GVariantIter _arguments_iter;
	char* device_path = NULL;
	GVariant* _tmp76_;
	g_variant_iter_init (&_arguments_iter, parameters);
	_tmp76_ = g_variant_iter_next_value (&_arguments_iter);
	device_path = g_variant_dup_string (_tmp76_, NULL);
	g_variant_unref (_tmp76_);
	g_signal_emit_by_name (self, "device-added", device_path);
	_g_free0 (device_path);
}

static void
_dbus_handle_power_services_dbus_interfaces_upower_device_removed (PowerServicesDBusInterfacesUPower* self,
                                                                   GVariant* parameters)
{
	GVariantIter _arguments_iter;
	char* device_path = NULL;
	GVariant* _tmp77_;
	g_variant_iter_init (&_arguments_iter, parameters);
	_tmp77_ = g_variant_iter_next_value (&_arguments_iter);
	device_path = g_variant_dup_string (_tmp77_, NULL);
	g_variant_unref (_tmp77_);
	g_signal_emit_by_name (self, "device-removed", device_path);
	_g_free0 (device_path);
}

static void
power_services_dbus_interfaces_upower_proxy_g_signal (GDBusProxy* proxy,
                                                      const gchar* sender_name,
                                                      const gchar* signal_name,
                                                      GVariant* parameters)
{
	if (strcmp (signal_name, "DeviceAdded") == 0) {
		_dbus_handle_power_services_dbus_interfaces_upower_device_added ((PowerServicesDBusInterfacesUPower*) proxy, parameters);
	} else if (strcmp (signal_name, "DeviceRemoved") == 0) {
		_dbus_handle_power_services_dbus_interfaces_upower_device_removed ((PowerServicesDBusInterfacesUPower*) proxy, parameters);
	}
}

static void
power_services_dbus_interfaces_upower_proxy_init (PowerServicesDBusInterfacesUPowerProxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_power_services_dbus_interfaces_upower_dbus_interface_info));
}

static char**
power_services_dbus_interfaces_upower_proxy_enumerate_devices (PowerServicesDBusInterfacesUPower* self,
                                                               gint* result_length1,
                                                               GError** error)
{
	GDBusMessage *_message;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	GDBusMessage *_reply_message;
	GVariant *_reply;
	GVariantIter _reply_iter;
	char** _result = NULL;
	gint _result_length1;
	GVariant* _tmp78_;
	char** _tmp79_;
	gint _tmp79__length;
	gint _tmp79__size;
	gint _tmp79__length1;
	GVariantIter _tmp80_;
	GVariant* _tmp81_;
	_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.freedesktop.UPower", "EnumerateDevices");
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	_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 NULL;
	}
	if (g_dbus_message_to_gerror (_reply_message, error)) {
		g_object_unref (_reply_message);
		return NULL;
	}
	_reply = g_dbus_message_get_body (_reply_message);
	g_variant_iter_init (&_reply_iter, _reply);
	_result_length1 = 0;
	_tmp78_ = g_variant_iter_next_value (&_reply_iter);
	_tmp79_ = g_new (char*, 5);
	_tmp79__length = 0;
	_tmp79__size = 4;
	_tmp79__length1 = 0;
	g_variant_iter_init (&_tmp80_, _tmp78_);
	for (; (_tmp81_ = g_variant_iter_next_value (&_tmp80_)) != NULL; _tmp79__length1++) {
		if (_tmp79__size == _tmp79__length) {
			_tmp79__size = 2 * _tmp79__size;
			_tmp79_ = g_renew (char*, _tmp79_, _tmp79__size + 1);
		}
		_tmp79_[_tmp79__length++] = g_variant_dup_string (_tmp81_, NULL);
		g_variant_unref (_tmp81_);
	}
	_result_length1 = _tmp79__length1;
	_tmp79_[_tmp79__length] = NULL;
	_result = _tmp79_;
	g_variant_unref (_tmp78_);
	*result_length1 = _result_length1;
	g_object_unref (_reply_message);
	return _result;
}

static char*
power_services_dbus_interfaces_upower_proxy_get_display_device (PowerServicesDBusInterfacesUPower* self,
                                                                GError** error)
{
	GDBusMessage *_message;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	GDBusMessage *_reply_message;
	GVariant *_reply;
	GVariantIter _reply_iter;
	char* _result = NULL;
	GVariant* _tmp82_;
	_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.freedesktop.UPower", "GetDisplayDevice");
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	_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 NULL;
	}
	if (g_dbus_message_to_gerror (_reply_message, error)) {
		g_object_unref (_reply_message);
		return NULL;
	}
	_reply = g_dbus_message_get_body (_reply_message);
	g_variant_iter_init (&_reply_iter, _reply);
	_tmp82_ = g_variant_iter_next_value (&_reply_iter);
	_result = g_variant_dup_string (_tmp82_, NULL);
	g_variant_unref (_tmp82_);
	g_object_unref (_reply_message);
	return _result;
}

static gboolean
power_services_dbus_interfaces_upower_dbus_proxy_get_on_battery (PowerServicesDBusInterfacesUPower* self)
{
	GVariant *_inner_reply;
	gboolean _result;
	_inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "OnBattery");
	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.freedesktop.UPower"));
		g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("OnBattery"));
		_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) {
			gboolean _tmp83_ = FALSE;
			return _tmp83_;
		}
		g_variant_get (_reply, "(v)", &_inner_reply);
		g_variant_unref (_reply);
	}
	_result = g_variant_get_boolean (_inner_reply);
	g_variant_unref (_inner_reply);
	return _result;
}

static void
power_services_dbus_interfaces_upower_proxy_power_services_dbus_interfaces_upower_interface_init (PowerServicesDBusInterfacesUPowerIface* iface)
{
	iface->enumerate_devices = power_services_dbus_interfaces_upower_proxy_enumerate_devices;
	iface->get_display_device = power_services_dbus_interfaces_upower_proxy_get_display_device;
	iface->get_on_battery = power_services_dbus_interfaces_upower_dbus_proxy_get_on_battery;
}

static void
_dbus_power_services_dbus_interfaces_upower_enumerate_devices (PowerServicesDBusInterfacesUPower* self,
                                                               GVariant* _parameters_,
                                                               GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	char** result;
	gint result_length1 = 0;
	char** _tmp84_;
	GVariantBuilder _tmp85_;
	gint _tmp86_;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	result = power_services_dbus_interfaces_upower_enumerate_devices (self, &result_length1, &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);
	_tmp84_ = result;
	g_variant_builder_init (&_tmp85_, G_VARIANT_TYPE ("ao"));
	for (_tmp86_ = 0; _tmp86_ < result_length1; _tmp86_++) {
		g_variant_builder_add_value (&_tmp85_, g_variant_new_object_path (*_tmp84_));
		_tmp84_++;
	}
	g_variant_builder_add_value (&_reply_builder, g_variant_builder_end (&_tmp85_));
	result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_free), NULL);
	_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
_dbus_power_services_dbus_interfaces_upower_get_display_device (PowerServicesDBusInterfacesUPower* self,
                                                                GVariant* _parameters_,
                                                                GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	char* result;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	result = power_services_dbus_interfaces_upower_get_display_device (self, &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);
	g_variant_builder_add_value (&_reply_builder, g_variant_new_object_path (result));
	_g_free0 (result);
	_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
power_services_dbus_interfaces_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)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (method_name, "EnumerateDevices") == 0) {
		_dbus_power_services_dbus_interfaces_upower_enumerate_devices (object, parameters, invocation);
	} else if (strcmp (method_name, "GetDisplayDevice") == 0) {
		_dbus_power_services_dbus_interfaces_upower_get_display_device (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
_dbus_power_services_dbus_interfaces_upower_get_on_battery (PowerServicesDBusInterfacesUPower* self)
{
	gboolean result;
	GVariant* _reply;
	result = power_services_dbus_interfaces_upower_get_on_battery (self);
	_reply = g_variant_new_boolean (result);
	return _reply;
}

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

static gboolean
power_services_dbus_interfaces_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)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return FALSE;
}

static void
_dbus_power_services_dbus_interfaces_upower_device_added (GObject* _sender,
                                                          const char* device_path,
                                                          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);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_object_path (device_path));
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_connection_emit_signal (_connection, NULL, _path, "org.freedesktop.UPower", "DeviceAdded", _arguments, NULL);
}

static void
_dbus_power_services_dbus_interfaces_upower_device_removed (GObject* _sender,
                                                            const char* device_path,
                                                            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);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_object_path (device_path));
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_connection_emit_signal (_connection, NULL, _path, "org.freedesktop.UPower", "DeviceRemoved", _arguments, NULL);
}

guint
power_services_dbus_interfaces_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 *) (&_power_services_dbus_interfaces_upower_dbus_interface_info), &_power_services_dbus_interfaces_upower_dbus_interface_vtable, data, _power_services_dbus_interfaces_upower_unregister_object, error);
	if (!result) {
		return 0;
	}
	g_signal_connect (object, "device-added", (GCallback) _dbus_power_services_dbus_interfaces_upower_device_added, data);
	g_signal_connect (object, "device-removed", (GCallback) _dbus_power_services_dbus_interfaces_upower_device_removed, data);
	return result;
}

static void
_power_services_dbus_interfaces_upower_unregister_object (gpointer user_data)
{
	gpointer* data;
	data = user_data;
	g_signal_handlers_disconnect_by_func (data[0], _dbus_power_services_dbus_interfaces_upower_device_added, data);
	g_signal_handlers_disconnect_by_func (data[0], _dbus_power_services_dbus_interfaces_upower_device_removed, 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);
}

