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

/* background-monitor.vala
 *
 * Copyright (C) 2024 Markus Göllnitz
 *
 * 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 * Authors: Markus Göllnitz <camelcasenick@bewares.it>
 */

#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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define ORG_FREEDESKTOP_BACKGROUND_TYPE_MONITOR (org_freedesktop_background_monitor_get_type ())
#define ORG_FREEDESKTOP_BACKGROUND_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), ORG_FREEDESKTOP_BACKGROUND_TYPE_MONITOR, orgfreedesktopbackgroundMonitor))
#define ORG_FREEDESKTOP_BACKGROUND_IS_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ORG_FREEDESKTOP_BACKGROUND_TYPE_MONITOR))
#define ORG_FREEDESKTOP_BACKGROUND_MONITOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), ORG_FREEDESKTOP_BACKGROUND_TYPE_MONITOR, orgfreedesktopbackgroundMonitorIface))

typedef struct _orgfreedesktopbackgroundMonitor orgfreedesktopbackgroundMonitor;
typedef struct _orgfreedesktopbackgroundMonitorIface orgfreedesktopbackgroundMonitorIface;

#define ORG_FREEDESKTOP_BACKGROUND_TYPE_MONITOR_PROXY (org_freedesktop_background_monitor_proxy_get_type ())
typedef GDBusProxy orgfreedesktopbackgroundMonitorProxy;
typedef GDBusProxyClass orgfreedesktopbackgroundMonitorProxyClass;

#define ORG_FREEDESKTOP_BACKGROUND_TYPE_BACKGROUND_APP (org_freedesktop_background_background_app_get_type ())
typedef struct _orgfreedesktopbackgroundBackgroundApp orgfreedesktopbackgroundBackgroundApp;
#define _g_free0(var) (var = (g_free (var), NULL))

#define USAGE_TYPE_BACKGROUND_MONITOR (usage_background_monitor_get_type ())
#define USAGE_BACKGROUND_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), USAGE_TYPE_BACKGROUND_MONITOR, UsageBackgroundMonitor))
#define USAGE_BACKGROUND_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), USAGE_TYPE_BACKGROUND_MONITOR, UsageBackgroundMonitorClass))
#define USAGE_IS_BACKGROUND_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), USAGE_TYPE_BACKGROUND_MONITOR))
#define USAGE_IS_BACKGROUND_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), USAGE_TYPE_BACKGROUND_MONITOR))
#define USAGE_BACKGROUND_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), USAGE_TYPE_BACKGROUND_MONITOR, UsageBackgroundMonitorClass))

typedef struct _UsageBackgroundMonitor UsageBackgroundMonitor;
typedef struct _UsageBackgroundMonitorClass UsageBackgroundMonitorClass;
typedef struct _UsageBackgroundMonitorPrivate UsageBackgroundMonitorPrivate;
enum  {
	USAGE_BACKGROUND_MONITOR_0_PROPERTY,
	USAGE_BACKGROUND_MONITOR_NUM_PROPERTIES
};
static GParamSpec* usage_background_monitor_properties[USAGE_BACKGROUND_MONITOR_NUM_PROPERTIES];
#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)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))

struct _orgfreedesktopbackgroundMonitorIface {
	GTypeInterface parent_iface;
	GHashTable** (*get_background_apps) (orgfreedesktopbackgroundMonitor* self, gint* result_length1);
	guint (*get_version) (orgfreedesktopbackgroundMonitor* self);
};

struct _orgfreedesktopbackgroundBackgroundApp {
	gchar* app_id;
	gchar* instance;
	gchar* message;
};

struct _UsageBackgroundMonitor {
	GObject parent_instance;
	UsageBackgroundMonitorPrivate * priv;
};

struct _UsageBackgroundMonitorClass {
	GObjectClass parent_class;
};

struct _UsageBackgroundMonitorPrivate {
	orgfreedesktopbackgroundMonitor* monitor;
};

static gint UsageBackgroundMonitor_private_offset;
static gpointer usage_background_monitor_parent_class = NULL;

VALA_EXTERN GType org_freedesktop_background_monitor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (orgfreedesktopbackgroundMonitor, g_object_unref)
VALA_EXTERN GType org_freedesktop_background_monitor_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint org_freedesktop_background_monitor_register_object (void* object,
                                                          GDBusConnection* connection,
                                                          const gchar* path,
                                                          GError** error);
VALA_EXTERN GHashTable** org_freedesktop_background_monitor_get_background_apps (orgfreedesktopbackgroundMonitor* self,
                                                                     gint* result_length1);
VALA_EXTERN guint org_freedesktop_background_monitor_get_version (orgfreedesktopbackgroundMonitor* self);
static GType org_freedesktop_background_monitor_get_type_once (void);
static void org_freedesktop_background_monitor_proxy_g_signal (GDBusProxy* proxy,
                                                        const gchar* sender_name,
                                                        const gchar* signal_name,
                                                        GVariant* parameters);
static GHashTable** org_freedesktop_background_monitor_dbus_proxy_get_background_apps (orgfreedesktopbackgroundMonitor* self,
                                                                                gint* result_length1);
static guint org_freedesktop_background_monitor_dbus_proxy_get_version (orgfreedesktopbackgroundMonitor* self);
static void org_freedesktop_background_monitor_proxy_org_freedesktop_background_monitor_interface_init (orgfreedesktopbackgroundMonitorIface* iface);
static void org_freedesktop_background_monitor_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* org_freedesktop_background_monitor_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_org_freedesktop_background_monitor_get_background_apps (orgfreedesktopbackgroundMonitor* self);
static GVariant* _dbus_org_freedesktop_background_monitor_get_version (orgfreedesktopbackgroundMonitor* self);
static gboolean org_freedesktop_background_monitor_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 _org_freedesktop_background_monitor_unregister_object (gpointer user_data);
VALA_EXTERN GType org_freedesktop_background_background_app_get_type (void) G_GNUC_CONST ;
VALA_EXTERN orgfreedesktopbackgroundBackgroundApp* org_freedesktop_background_background_app_dup (const orgfreedesktopbackgroundBackgroundApp* self);
VALA_EXTERN void org_freedesktop_background_background_app_free (orgfreedesktopbackgroundBackgroundApp* self);
VALA_EXTERN void org_freedesktop_background_background_app_copy (const orgfreedesktopbackgroundBackgroundApp* self,
                                                     orgfreedesktopbackgroundBackgroundApp* dest);
VALA_EXTERN void org_freedesktop_background_background_app_destroy (orgfreedesktopbackgroundBackgroundApp* self);
G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (orgfreedesktopbackgroundBackgroundApp, org_freedesktop_background_background_app_destroy)
VALA_EXTERN GType usage_background_monitor_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (UsageBackgroundMonitor, g_object_unref)
VALA_EXTERN UsageBackgroundMonitor* usage_background_monitor_new (void);
VALA_EXTERN UsageBackgroundMonitor* usage_background_monitor_construct (GType object_type);
static guint* _uint_dup (guint* self);
VALA_EXTERN orgfreedesktopbackgroundBackgroundApp* usage_background_monitor_get_background_apps (UsageBackgroundMonitor* self,
                                                                                     gint* result_length1);
static void _vala_array_add1 (orgfreedesktopbackgroundBackgroundApp* * array,
                       gint* length,
                       gint* size,
                       const orgfreedesktopbackgroundBackgroundApp* value);
static void usage_background_monitor_finalize (GObject * obj);
static GType usage_background_monitor_get_type_once (void);
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 _org_freedesktop_background_monitor_dbus_method_info[] = {NULL};
static const GDBusSignalInfo * const _org_freedesktop_background_monitor_dbus_signal_info[] = {NULL};
static const GDBusPropertyInfo _org_freedesktop_background_monitor_dbus_property_info_background_apps = {-1, "BackgroundApps", "aa{sv}", G_DBUS_PROPERTY_INFO_FLAGS_READABLE, NULL};
static const GDBusPropertyInfo _org_freedesktop_background_monitor_dbus_property_info_version = {-1, "version", "u", G_DBUS_PROPERTY_INFO_FLAGS_READABLE, NULL};
static const GDBusPropertyInfo * const _org_freedesktop_background_monitor_dbus_property_info[] = {&_org_freedesktop_background_monitor_dbus_property_info_background_apps, &_org_freedesktop_background_monitor_dbus_property_info_version, NULL};
static const GDBusInterfaceInfo _org_freedesktop_background_monitor_dbus_interface_info = {-1, "org.freedesktop.background.Monitor", (GDBusMethodInfo **) (&_org_freedesktop_background_monitor_dbus_method_info), (GDBusSignalInfo **) (&_org_freedesktop_background_monitor_dbus_signal_info), (GDBusPropertyInfo **) (&_org_freedesktop_background_monitor_dbus_property_info), NULL};
static const GDBusInterfaceVTable _org_freedesktop_background_monitor_dbus_interface_vtable = {org_freedesktop_background_monitor_dbus_interface_method_call, org_freedesktop_background_monitor_dbus_interface_get_property, org_freedesktop_background_monitor_dbus_interface_set_property};

GHashTable**
org_freedesktop_background_monitor_get_background_apps (orgfreedesktopbackgroundMonitor* self,
                                                        gint* result_length1)
{
	orgfreedesktopbackgroundMonitorIface* _iface_;
	g_return_val_if_fail (self != NULL, NULL);
	_iface_ = ORG_FREEDESKTOP_BACKGROUND_MONITOR_GET_INTERFACE (self);
	if (_iface_->get_background_apps) {
		return _iface_->get_background_apps (self, result_length1);
	}
	return NULL;
}

guint
org_freedesktop_background_monitor_get_version (orgfreedesktopbackgroundMonitor* self)
{
	orgfreedesktopbackgroundMonitorIface* _iface_;
	g_return_val_if_fail (self != NULL, 0U);
	_iface_ = ORG_FREEDESKTOP_BACKGROUND_MONITOR_GET_INTERFACE (self);
	if (_iface_->get_version) {
		return _iface_->get_version (self);
	}
	return 0U;
}

static void
org_freedesktop_background_monitor_default_init (orgfreedesktopbackgroundMonitorIface * iface,
                                                 gpointer iface_data)
{
}

static GType
org_freedesktop_background_monitor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (orgfreedesktopbackgroundMonitorIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) org_freedesktop_background_monitor_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType org_freedesktop_background_monitor_type_id;
	org_freedesktop_background_monitor_type_id = g_type_register_static (G_TYPE_INTERFACE, "orgfreedesktopbackgroundMonitor", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (org_freedesktop_background_monitor_type_id, G_TYPE_OBJECT);
	g_type_set_qdata (org_freedesktop_background_monitor_type_id, g_quark_from_static_string ("vala-dbus-proxy-type"), (void*) org_freedesktop_background_monitor_proxy_get_type);
	g_type_set_qdata (org_freedesktop_background_monitor_type_id, g_quark_from_static_string ("vala-dbus-interface-name"), "org.freedesktop.background.Monitor");
	g_type_set_qdata (org_freedesktop_background_monitor_type_id, g_quark_from_static_string ("vala-dbus-interface-info"), (void*) (&_org_freedesktop_background_monitor_dbus_interface_info));
	g_type_set_qdata (org_freedesktop_background_monitor_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) org_freedesktop_background_monitor_register_object);
	return org_freedesktop_background_monitor_type_id;
}

GType
org_freedesktop_background_monitor_get_type (void)
{
	static volatile gsize org_freedesktop_background_monitor_type_id__once = 0;
	if (g_once_init_enter (&org_freedesktop_background_monitor_type_id__once)) {
		GType org_freedesktop_background_monitor_type_id;
		org_freedesktop_background_monitor_type_id = org_freedesktop_background_monitor_get_type_once ();
		g_once_init_leave (&org_freedesktop_background_monitor_type_id__once, org_freedesktop_background_monitor_type_id);
	}
	return org_freedesktop_background_monitor_type_id__once;
}

G_DEFINE_TYPE_EXTENDED (orgfreedesktopbackgroundMonitorProxy, org_freedesktop_background_monitor_proxy, G_TYPE_DBUS_PROXY, 0, G_IMPLEMENT_INTERFACE (ORG_FREEDESKTOP_BACKGROUND_TYPE_MONITOR, org_freedesktop_background_monitor_proxy_org_freedesktop_background_monitor_interface_init) )
static void
org_freedesktop_background_monitor_proxy_class_init (orgfreedesktopbackgroundMonitorProxyClass* klass)
{
	G_DBUS_PROXY_CLASS (klass)->g_signal = org_freedesktop_background_monitor_proxy_g_signal;
}

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

static void
org_freedesktop_background_monitor_proxy_init (orgfreedesktopbackgroundMonitorProxy* self)
{
	g_dbus_proxy_set_interface_info (G_DBUS_PROXY (self), (GDBusInterfaceInfo *) (&_org_freedesktop_background_monitor_dbus_interface_info));
}

static GHashTable**
org_freedesktop_background_monitor_dbus_proxy_get_background_apps (orgfreedesktopbackgroundMonitor* self,
                                                                   gint* result_length1)
{
	GVariant *_inner_reply;
	GHashTable** _result;
	gint _result_length1;
	GHashTable** _tmp0_;
	gint _tmp0__length;
	gint _tmp0__size;
	gint _tmp0__length1;
	GVariantIter _tmp1_;
	GVariant* _tmp2_;
	_inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "BackgroundApps");
	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.background.Monitor"));
		g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("BackgroundApps"));
		_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, 120000, NULL, NULL);
		if (!_reply) {
			return NULL;
		}
		g_variant_get (_reply, "(v)", &_inner_reply);
		g_variant_unref (_reply);
	}
	_result_length1 = 0;
	_tmp0_ = g_new (GHashTable*, 5);
	_tmp0__length = 0;
	_tmp0__size = 4;
	_tmp0__length1 = 0;
	g_variant_iter_init (&_tmp1_, _inner_reply);
	for (; (_tmp2_ = g_variant_iter_next_value (&_tmp1_)) != NULL; _tmp0__length1++) {
		GHashTable* _tmp3_;
		GVariantIter _tmp4_;
		GVariant* _tmp5_;
		GVariant* _tmp6_;
		if (_tmp0__size == _tmp0__length) {
			_tmp0__size = 2 * _tmp0__size;
			_tmp0_ = g_renew (GHashTable*, _tmp0_, _tmp0__size + 1);
		}
		_tmp3_ = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_variant_unref);
		g_variant_iter_init (&_tmp4_, _tmp2_);
		while (g_variant_iter_loop (&_tmp4_, "{?*}", &_tmp5_, &_tmp6_)) {
			g_hash_table_insert (_tmp3_, g_variant_dup_string (_tmp5_, NULL), g_variant_get_variant (_tmp6_));
		}
		_tmp0_[_tmp0__length++] = _tmp3_;
		g_variant_unref (_tmp2_);
	}
	_result_length1 = _tmp0__length1;
	_tmp0_[_tmp0__length] = NULL;
	_result = _tmp0_;
	*result_length1 = _result_length1;
	g_variant_unref (_inner_reply);
	return _result;
}

static guint
org_freedesktop_background_monitor_dbus_proxy_get_version (orgfreedesktopbackgroundMonitor* self)
{
	GVariant *_inner_reply;
	guint _result;
	_inner_reply = g_dbus_proxy_get_cached_property ((GDBusProxy *) self, "version");
	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.background.Monitor"));
		g_variant_builder_add_value (&_arguments_builder, g_variant_new_string ("version"));
		_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, 120000, NULL, NULL);
		if (!_reply) {
			guint _tmp7_ = 0U;
			return _tmp7_;
		}
		g_variant_get (_reply, "(v)", &_inner_reply);
		g_variant_unref (_reply);
	}
	_result = g_variant_get_uint32 (_inner_reply);
	g_variant_unref (_inner_reply);
	return _result;
}

static void
org_freedesktop_background_monitor_proxy_org_freedesktop_background_monitor_interface_init (orgfreedesktopbackgroundMonitorIface* iface)
{
	iface->get_background_apps = org_freedesktop_background_monitor_dbus_proxy_get_background_apps;
	iface->get_version = org_freedesktop_background_monitor_dbus_proxy_get_version;
}

static void
org_freedesktop_background_monitor_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_org_freedesktop_background_monitor_get_background_apps (orgfreedesktopbackgroundMonitor* self)
{
	GHashTable** result;
	gint result_length1 = 0;
	GVariant* _reply;
	GHashTable** _tmp8_;
	GVariantBuilder _tmp9_;
	gint _tmp10_;
	result = org_freedesktop_background_monitor_get_background_apps (self, &result_length1);
	_tmp8_ = result;
	g_variant_builder_init (&_tmp9_, G_VARIANT_TYPE ("aa{sv}"));
	for (_tmp10_ = 0; _tmp10_ < result_length1; _tmp10_++) {
		GVariantBuilder _tmp11_;
		GHashTableIter _tmp12_;
		gpointer _tmp13_;
		gpointer _tmp14_;
		g_hash_table_iter_init (&_tmp12_, *_tmp8_);
		g_variant_builder_init (&_tmp11_, G_VARIANT_TYPE ("a{sv}"));
		while (g_hash_table_iter_next (&_tmp12_, &_tmp13_, &_tmp14_)) {
			gchar* _key;
			GVariant* _value;
			_key = (gchar*) _tmp13_;
			_value = (GVariant*) _tmp14_;
			g_variant_builder_add (&_tmp11_, "{?*}", g_variant_new_string (_key), g_variant_new_variant (_value));
		}
		g_variant_builder_add_value (&_tmp9_, g_variant_builder_end (&_tmp11_));
		_tmp8_++;
	}
	_reply = g_variant_builder_end (&_tmp9_);
	result = (_vala_array_free (result, result_length1, (GDestroyNotify) g_hash_table_unref), NULL);
	return _reply;
}

static GVariant*
_dbus_org_freedesktop_background_monitor_get_version (orgfreedesktopbackgroundMonitor* self)
{
	guint result;
	GVariant* _reply;
	result = org_freedesktop_background_monitor_get_version (self);
	_reply = g_variant_new_uint32 (result);
	return _reply;
}

static GVariant*
org_freedesktop_background_monitor_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, "BackgroundApps") == 0) {
		return _dbus_org_freedesktop_background_monitor_get_background_apps (object);
	} else if (strcmp (property_name, "version") == 0) {
		return _dbus_org_freedesktop_background_monitor_get_version (object);
	}
	return NULL;
}

static gboolean
org_freedesktop_background_monitor_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;
}

guint
org_freedesktop_background_monitor_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 *) (&_org_freedesktop_background_monitor_dbus_interface_info), &_org_freedesktop_background_monitor_dbus_interface_vtable, data, _org_freedesktop_background_monitor_unregister_object, error);
	if (!result) {
		return 0;
	}
	return result;
}

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

void
org_freedesktop_background_background_app_copy (const orgfreedesktopbackgroundBackgroundApp* self,
                                                orgfreedesktopbackgroundBackgroundApp* dest)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	_tmp0_ = (*self).app_id;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 ((*dest).app_id);
	(*dest).app_id = _tmp1_;
	_tmp2_ = (*self).instance;
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 ((*dest).instance);
	(*dest).instance = _tmp3_;
	_tmp4_ = (*self).message;
	_tmp5_ = g_strdup (_tmp4_);
	_g_free0 ((*dest).message);
	(*dest).message = _tmp5_;
}

void
org_freedesktop_background_background_app_destroy (orgfreedesktopbackgroundBackgroundApp* self)
{
	_g_free0 ((*self).app_id);
	_g_free0 ((*self).instance);
	_g_free0 ((*self).message);
}

orgfreedesktopbackgroundBackgroundApp*
org_freedesktop_background_background_app_dup (const orgfreedesktopbackgroundBackgroundApp* self)
{
	orgfreedesktopbackgroundBackgroundApp* dup;
	dup = g_new0 (orgfreedesktopbackgroundBackgroundApp, 1);
	org_freedesktop_background_background_app_copy (self, dup);
	return dup;
}

void
org_freedesktop_background_background_app_free (orgfreedesktopbackgroundBackgroundApp* self)
{
	org_freedesktop_background_background_app_destroy (self);
	g_free (self);
}

static GType
org_freedesktop_background_background_app_get_type_once (void)
{
	GType org_freedesktop_background_background_app_type_id;
	org_freedesktop_background_background_app_type_id = g_boxed_type_register_static ("orgfreedesktopbackgroundBackgroundApp", (GBoxedCopyFunc) org_freedesktop_background_background_app_dup, (GBoxedFreeFunc) org_freedesktop_background_background_app_free);
	return org_freedesktop_background_background_app_type_id;
}

GType
org_freedesktop_background_background_app_get_type (void)
{
	static volatile gsize org_freedesktop_background_background_app_type_id__once = 0;
	if (g_once_init_enter (&org_freedesktop_background_background_app_type_id__once)) {
		GType org_freedesktop_background_background_app_type_id;
		org_freedesktop_background_background_app_type_id = org_freedesktop_background_background_app_get_type_once ();
		g_once_init_leave (&org_freedesktop_background_background_app_type_id__once, org_freedesktop_background_background_app_type_id);
	}
	return org_freedesktop_background_background_app_type_id__once;
}

static inline gpointer
usage_background_monitor_get_instance_private (UsageBackgroundMonitor* self)
{
	return G_STRUCT_MEMBER_P (self, UsageBackgroundMonitor_private_offset);
}

static guint*
_uint_dup (guint* self)
{
	guint* dup;
	dup = g_new0 (guint, 1);
	memcpy (dup, self, sizeof (guint));
	return dup;
}

static gpointer
__uint_dup0 (gpointer self)
{
	return self ? _uint_dup (self) : NULL;
}

UsageBackgroundMonitor*
usage_background_monitor_construct (GType object_type)
{
	UsageBackgroundMonitor * self = NULL;
	GError* _inner_error0_ = NULL;
	self = (UsageBackgroundMonitor*) g_object_new (object_type, NULL);
	{
		orgfreedesktopbackgroundMonitor* _tmp0_ = NULL;
		orgfreedesktopbackgroundMonitor* _tmp1_;
		orgfreedesktopbackgroundMonitor* _tmp2_;
		orgfreedesktopbackgroundMonitor* _tmp3_ = NULL;
		orgfreedesktopbackgroundMonitor* _tmp4_;
		guint* _tmp5_ = NULL;
		_tmp1_ = (orgfreedesktopbackgroundMonitor*) g_initable_new (ORG_FREEDESKTOP_BACKGROUND_TYPE_MONITOR_PROXY, NULL, &_inner_error0_, "g-flags", 0, "g-name", "org.freedesktop.background.Monitor", "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", "/org/freedesktop/background/monitor", "g-interface-name", "org.freedesktop.background.Monitor", NULL);
		_tmp0_ = (orgfreedesktopbackgroundMonitor*) _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_IO_ERROR) {
				goto __catch0_g_io_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (self->priv->monitor);
		self->priv->monitor = _tmp2_;
		_tmp4_ = self->priv->monitor;
		_tmp3_ = _tmp4_;
		_tmp5_ = NULL;
		if (_tmp3_ != NULL) {
			guint _tmp6_;
			guint _tmp7_;
			guint* _tmp8_;
			_tmp6_ = org_freedesktop_background_monitor_get_version (_tmp3_);
			_tmp7_ = _tmp6_;
			_tmp8_ = __uint_dup0 (&_tmp7_);
			_g_free0 (_tmp5_);
			_tmp5_ = _tmp8_;
		}
		if ((*_tmp5_) > ((guint) 1)) {
			g_warning ("background-monitor.vala:46: Usage.BackgroundMonitor only makes use of " \
"org.freedesktop.background.Monitor version 1");
		}
		_g_free0 (_tmp5_);
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_io_error:
	{
		GError* e = NULL;
		GError* _tmp9_;
		const gchar* _tmp10_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp9_ = e;
		_tmp10_ = _tmp9_->message;
		g_warning ("background-monitor.vala:49: BackgroundMonitor proxy creation failed: %" \
"s", _tmp10_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return NULL;
	}
	return self;
}

UsageBackgroundMonitor*
usage_background_monitor_new (void)
{
	return usage_background_monitor_construct (USAGE_TYPE_BACKGROUND_MONITOR);
}

static gpointer
_g_hash_table_ref0 (gpointer self)
{
	return self ? g_hash_table_ref (self) : NULL;
}

static void
_vala_array_add1 (orgfreedesktopbackgroundBackgroundApp* * array,
                  gint* length,
                  gint* size,
                  const orgfreedesktopbackgroundBackgroundApp* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (orgfreedesktopbackgroundBackgroundApp, *array, *size);
	}
	(*array)[(*length)++] = *value;
}

orgfreedesktopbackgroundBackgroundApp*
usage_background_monitor_get_background_apps (UsageBackgroundMonitor* self,
                                              gint* result_length1)
{
	orgfreedesktopbackgroundBackgroundApp* background_apps = NULL;
	orgfreedesktopbackgroundBackgroundApp* _tmp0_;
	gint background_apps_length1;
	gint _background_apps_size_;
	orgfreedesktopbackgroundMonitor* _tmp1_ = NULL;
	orgfreedesktopbackgroundMonitor* _tmp2_;
	GHashTable** _tmp3_ = NULL;
	gint _tmp3__length1;
	gint __tmp3__size_;
	orgfreedesktopbackgroundBackgroundApp* _tmp23_;
	gint _tmp23__length1;
	orgfreedesktopbackgroundBackgroundApp* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_new0 (orgfreedesktopbackgroundBackgroundApp, 0);
	background_apps = _tmp0_;
	background_apps_length1 = 0;
	_background_apps_size_ = background_apps_length1;
	_tmp2_ = self->priv->monitor;
	_tmp1_ = _tmp2_;
	_tmp3_ = NULL;
	_tmp3__length1 = 0;
	__tmp3__size_ = _tmp3__length1;
	if (_tmp1_ != NULL) {
		GHashTable** _tmp4_;
		gint _tmp4__length1;
		gint _tmp5_ = 0;
		GHashTable** _tmp6_;
		gint _tmp6__length1;
		_tmp4_ = org_freedesktop_background_monitor_get_background_apps (_tmp1_, &_tmp5_);
		_tmp4__length1 = _tmp5_;
		_tmp6_ = _tmp4_;
		_tmp6__length1 = _tmp4__length1;
		_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_hash_table_unref), NULL);
		_tmp3_ = _tmp6_;
		_tmp3__length1 = _tmp6__length1;
		__tmp3__size_ = _tmp3__length1;
	}
	{
		GHashTable** app_as_table_collection = NULL;
		gint app_as_table_collection_length1 = 0;
		gint _app_as_table_collection_size_ = 0;
		gint app_as_table_it = 0;
		app_as_table_collection = _tmp3_;
		app_as_table_collection_length1 = _tmp3__length1;
		for (app_as_table_it = 0; app_as_table_it < app_as_table_collection_length1; app_as_table_it = app_as_table_it + 1) {
			GHashTable* _tmp7_;
			GHashTable* app_as_table = NULL;
			_tmp7_ = _g_hash_table_ref0 (app_as_table_collection[app_as_table_it]);
			app_as_table = _tmp7_;
			{
				GVariant* _tmp8_ = NULL;
				GHashTable* _tmp9_;
				gconstpointer _tmp10_;
				const gchar* _tmp11_ = NULL;
				GHashTable* _tmp13_;
				gconstpointer _tmp14_;
				const gchar* _tmp15_;
				gchar* _tmp16_;
				GHashTable* _tmp17_;
				gconstpointer _tmp18_;
				const gchar* _tmp19_;
				gchar* _tmp20_;
				gchar* _tmp21_;
				orgfreedesktopbackgroundBackgroundApp _tmp22_ = {0};
				_tmp9_ = app_as_table;
				_tmp10_ = g_hash_table_lookup (_tmp9_, "message");
				_tmp8_ = (GVariant*) _tmp10_;
				_tmp11_ = NULL;
				if (_tmp8_ != NULL) {
					const gchar* _tmp12_;
					_tmp12_ = g_variant_get_string (_tmp8_, NULL);
					_tmp11_ = _tmp12_;
				}
				_tmp13_ = app_as_table;
				_tmp14_ = g_hash_table_lookup (_tmp13_, "app_id");
				_tmp15_ = g_variant_get_string ((GVariant*) ((GVariant*) _tmp14_), NULL);
				_tmp16_ = g_strdup (_tmp15_);
				_tmp17_ = app_as_table;
				_tmp18_ = g_hash_table_lookup (_tmp17_, "instance");
				_tmp19_ = g_variant_get_string ((GVariant*) ((GVariant*) _tmp18_), NULL);
				_tmp20_ = g_strdup (_tmp19_);
				_tmp21_ = g_strdup (_tmp11_);
				memset (&_tmp22_, 0, sizeof (orgfreedesktopbackgroundBackgroundApp));
				_g_free0 (_tmp22_.app_id);
				_tmp22_.app_id = _tmp16_;
				_g_free0 (_tmp22_.instance);
				_tmp22_.instance = _tmp20_;
				_g_free0 (_tmp22_.message);
				_tmp22_.message = _tmp21_;
				_vala_array_add1 (&background_apps, &background_apps_length1, &_background_apps_size_, &_tmp22_);
				_g_hash_table_unref0 (app_as_table);
			}
		}
	}
	_tmp23_ = background_apps;
	_tmp23__length1 = background_apps_length1;
	if (result_length1) {
		*result_length1 = _tmp23__length1;
	}
	result = _tmp23_;
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_hash_table_unref), NULL);
	return result;
}

static void
usage_background_monitor_class_init (UsageBackgroundMonitorClass * klass,
                                     gpointer klass_data)
{
	usage_background_monitor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &UsageBackgroundMonitor_private_offset);
	G_OBJECT_CLASS (klass)->finalize = usage_background_monitor_finalize;
}

static void
usage_background_monitor_instance_init (UsageBackgroundMonitor * self,
                                        gpointer klass)
{
	self->priv = usage_background_monitor_get_instance_private (self);
}

static void
usage_background_monitor_finalize (GObject * obj)
{
	UsageBackgroundMonitor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, USAGE_TYPE_BACKGROUND_MONITOR, UsageBackgroundMonitor);
	_g_object_unref0 (self->priv->monitor);
	G_OBJECT_CLASS (usage_background_monitor_parent_class)->finalize (obj);
}

static GType
usage_background_monitor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (UsageBackgroundMonitorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) usage_background_monitor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UsageBackgroundMonitor), 0, (GInstanceInitFunc) usage_background_monitor_instance_init, NULL };
	GType usage_background_monitor_type_id;
	usage_background_monitor_type_id = g_type_register_static (G_TYPE_OBJECT, "UsageBackgroundMonitor", &g_define_type_info, 0);
	UsageBackgroundMonitor_private_offset = g_type_add_instance_private (usage_background_monitor_type_id, sizeof (UsageBackgroundMonitorPrivate));
	return usage_background_monitor_type_id;
}

GType
usage_background_monitor_get_type (void)
{
	static volatile gsize usage_background_monitor_type_id__once = 0;
	if (g_once_init_enter (&usage_background_monitor_type_id__once)) {
		GType usage_background_monitor_type_id;
		usage_background_monitor_type_id = usage_background_monitor_get_type_once ();
		g_once_init_leave (&usage_background_monitor_type_id__once, usage_background_monitor_type_id);
	}
	return usage_background_monitor_type_id__once;
}

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);
}

