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

/*
 * Copyright (c) 2024-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authors: Kamil Prusko <kamilprusko@gmail.com>
 */

#include "ft_core.h"
#include <glib.h>
#include <gio/gio.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	FT_IDLE_MONITOR_PROVIDER_BECAME_IDLE_SIGNAL,
	FT_IDLE_MONITOR_PROVIDER_BECAME_ACTIVE_SIGNAL,
	FT_IDLE_MONITOR_PROVIDER_NUM_SIGNALS
};
static guint ft_idle_monitor_provider_signals[FT_IDLE_MONITOR_PROVIDER_NUM_SIGNALS] = {0};
enum  {
	FT_DUMMY_IDLE_MONITOR_PROVIDER_0_PROPERTY,
	FT_DUMMY_IDLE_MONITOR_PROVIDER_CAN_IGNORE_INHIBITORS_PROPERTY,
	FT_DUMMY_IDLE_MONITOR_PROVIDER_NUM_PROPERTIES
};
static GParamSpec* ft_dummy_idle_monitor_provider_properties[FT_DUMMY_IDLE_MONITOR_PROVIDER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _FtDummyIdleMonitorProviderInitializeData FtDummyIdleMonitorProviderInitializeData;
typedef struct _FtDummyIdleMonitorProviderUninitializeData FtDummyIdleMonitorProviderUninitializeData;
typedef struct _FtDummyIdleMonitorProviderEnableData FtDummyIdleMonitorProviderEnableData;
typedef struct _FtDummyIdleMonitorProviderDisableData FtDummyIdleMonitorProviderDisableData;
typedef struct _FtIdleMonitorWatch FtIdleMonitorWatch;
enum  {
	FT_IDLE_MONITOR_0_PROPERTY,
	FT_IDLE_MONITOR_NUM_PROPERTIES
};
static GParamSpec* ft_idle_monitor_properties[FT_IDLE_MONITOR_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _Block15Data Block15Data;
typedef struct _Block16Data Block16Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _Block17Data Block17Data;
typedef struct _Block18Data Block18Data;
#define _ft_idle_monitor_watch_free0(var) ((var == NULL) ? NULL : (var = (ft_idle_monitor_watch_free (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _FtDummyIdleMonitorProviderInitializeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDummyIdleMonitorProvider* self;
	GCancellable* cancellable;
};

struct _FtDummyIdleMonitorProviderUninitializeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDummyIdleMonitorProvider* self;
};

struct _FtDummyIdleMonitorProviderEnableData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDummyIdleMonitorProvider* self;
	GCancellable* cancellable;
};

struct _FtDummyIdleMonitorProviderDisableData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FtDummyIdleMonitorProvider* self;
};

struct _FtIdleMonitorPrivate {
	GHashTable* watches;
	gint64 last_activity_time;
};

struct _Block15Data {
	int _ref_count_;
	FtIdleMonitor* self;
	guint32 id;
};

struct _FtIdleMonitorWatch {
	guint id;
	guint32 external_id;
	gint64 timeout;
	gint64 reference_time;
	gboolean ignore_inhibitors;
	FtCallback idle_callback;
	gpointer idle_callback_target;
	GDestroyNotify idle_callback_target_destroy_notify;
	FtCallback active_callback;
	gpointer active_callback_target;
	GDestroyNotify active_callback_target_destroy_notify;
	FtIdleMonitorProvider* provider;
	gboolean invalid;
};

struct _Block16Data {
	int _ref_count_;
	FtIdleMonitor* self;
	gint64 monotonic_time;
	FtIdleMonitorWatch** watches_to_trigger;
	gint watches_to_trigger_length1;
	gint _watches_to_trigger_size_;
};

struct _Block17Data {
	int _ref_count_;
	FtIdleMonitor* self;
	FtIdleMonitorProvider* provider;
};

struct _Block18Data {
	int _ref_count_;
	FtIdleMonitor* self;
	FtIdleMonitorProvider* provider;
};

static gpointer ft_dummy_idle_monitor_provider_parent_class = NULL;
static FtIdleMonitorProviderIface * ft_dummy_idle_monitor_provider_ft_idle_monitor_provider_parent_iface = NULL;
static gint FtIdleMonitor_private_offset;
static gpointer ft_idle_monitor_parent_class = NULL;
static guint ft_idle_monitor_next_watch_id;
static guint ft_idle_monitor_next_watch_id = 1U;

static GType ft_idle_monitor_provider_get_type_once (void);
static void ft_dummy_idle_monitor_provider_real_initialize_data_free (gpointer _data);
static void ft_dummy_idle_monitor_provider_real_initialize (FtProvider* base,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean ft_dummy_idle_monitor_provider_real_initialize_co (FtDummyIdleMonitorProviderInitializeData* _data_);
VALA_EXTERN void ft_provider_set_enabled (FtProvider* self,
                              gboolean value);
static void ft_dummy_idle_monitor_provider_real_uninitialize_data_free (gpointer _data);
static void ft_dummy_idle_monitor_provider_real_uninitialize (FtProvider* base,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static gboolean ft_dummy_idle_monitor_provider_real_uninitialize_co (FtDummyIdleMonitorProviderUninitializeData* _data_);
static void ft_dummy_idle_monitor_provider_real_enable_data_free (gpointer _data);
static void ft_dummy_idle_monitor_provider_real_enable (FtProvider* base,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static gboolean ft_dummy_idle_monitor_provider_real_enable_co (FtDummyIdleMonitorProviderEnableData* _data_);
static void ft_dummy_idle_monitor_provider_real_disable_data_free (gpointer _data);
static void ft_dummy_idle_monitor_provider_real_disable (FtProvider* base,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static gboolean ft_dummy_idle_monitor_provider_real_disable_co (FtDummyIdleMonitorProviderDisableData* _data_);
static guint32 ft_dummy_idle_monitor_provider_real_add_idle_watch (FtIdleMonitorProvider* base,
                                                            gint64 timeout,
                                                            gboolean ignore_inhibitors,
                                                            gint64 monotonic_time,
                                                            GError** error);
static guint32 ft_dummy_idle_monitor_provider_real_reset_idle_watch (FtIdleMonitorProvider* base,
                                                              guint32 id,
                                                              gint64 monotonic_time,
                                                              GError** error);
static void ft_dummy_idle_monitor_provider_real_add_active_watch (FtIdleMonitorProvider* base,
                                                           GError** error);
static void ft_dummy_idle_monitor_provider_real_remove_idle_watch (FtIdleMonitorProvider* base,
                                                            guint32 id,
                                                            GError** error);
static void ft_dummy_idle_monitor_provider_real_remove_active_watch (FtIdleMonitorProvider* base,
                                                              GError** error);
static GType ft_dummy_idle_monitor_provider_get_type_once (void);
static void _vala_ft_dummy_idle_monitor_provider_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
static void ft_idle_monitor_watch_free (FtIdleMonitorWatch * self);
static void ft_idle_monitor_on_became_idle (FtIdleMonitor* self,
                                     guint32 id);
static Block15Data* block15_data_ref (Block15Data* _data15_);
static void block15_data_unref (void * _userdata_);
static gboolean __lambda33_ (Block15Data* _data15_,
                      gint64* _id,
                      FtIdleMonitorWatch* watch);
static gboolean ___lambda33__ghr_func (gconstpointer key,
                                gconstpointer value,
                                gpointer self);
static void ft_idle_monitor_on_became_active (FtIdleMonitor* self);
static Block16Data* block16_data_ref (Block16Data* _data16_);
static void block16_data_unref (void * _userdata_);
static void __lambda34_ (Block16Data* _data16_,
                  gint64* id,
                  FtIdleMonitorWatch* watch);
static void _vala_array_add19 (FtIdleMonitorWatch** * array,
                        gint* length,
                        gint* size,
                        FtIdleMonitorWatch* value);
static void ___lambda34__gh_func (gconstpointer key,
                           gconstpointer value,
                           gpointer self);
static gboolean __lambda35_ (FtIdleMonitor* self,
                      gint64* id,
                      FtIdleMonitorWatch* watch);
static gboolean ___lambda35__ghr_func (gconstpointer key,
                                gconstpointer value,
                                gpointer self);
static void ft_idle_monitor_real_initialize (FtProvidedObject* base);
static void _g_free0_ (gpointer var);
static void _ft_idle_monitor_watch_free0_ (gpointer var);
static void ft_idle_monitor_real_setup_providers (FtProvidedObject* base);
VALA_EXTERN gboolean ft_is_test (void);
static void ft_idle_monitor_real_provider_enabled (FtProvidedObject* base,
                                            FtIdleMonitorProvider* provider);
static Block17Data* block17_data_ref (Block17Data* _data17_);
static void block17_data_unref (void * _userdata_);
static void _ft_idle_monitor_on_became_idle_ft_idle_monitor_provider_became_idle (FtIdleMonitorProvider* _sender,
                                                                           guint32 id,
                                                                           gpointer self);
static void _ft_idle_monitor_on_became_active_ft_idle_monitor_provider_became_active (FtIdleMonitorProvider* _sender,
                                                                               gpointer self);
static void __lambda36_ (Block17Data* _data17_,
                  gint64* id,
                  FtIdleMonitorWatch* watch);
static void ___lambda36__gh_func (gconstpointer key,
                           gconstpointer value,
                           gpointer self);
static void ft_idle_monitor_real_provider_disabled (FtProvidedObject* base,
                                             FtIdleMonitorProvider* provider);
static Block18Data* block18_data_ref (Block18Data* _data18_);
static void block18_data_unref (void * _userdata_);
static void __lambda37_ (Block18Data* _data18_,
                  gint64* id,
                  FtIdleMonitorWatch* watch);
static void ___lambda37__gh_func (gconstpointer key,
                           gconstpointer value,
                           gpointer self);
static FtIdleMonitorWatch* ft_idle_monitor_watch_new (void);
static gint64* _int64_dup (gint64* self);
static void ft_idle_monitor_real_dispose (GObject* base);
static void ft_idle_monitor_watch_instance_init (FtIdleMonitorWatch * self);
static GObject * ft_idle_monitor_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties);
static void ft_idle_monitor_finalize (GObject * obj);
static GType ft_idle_monitor_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

/**
         * Register an idle watch with the session idle monitor.
         *
         * Fires `became_idle` after `timeout` microseconds without user activity.
         *
         * When `monotonic_time` is defined, idle time is counted from from the given timestamp.
         *
         * When `ignore_inhibitors` is `true`, the watch reacts to real user input (not supported
         * by all providers).
         */
guint32
ft_idle_monitor_provider_add_idle_watch (FtIdleMonitorProvider* self,
                                         gint64 timeout,
                                         gboolean ignore_inhibitors,
                                         gint64 monotonic_time,
                                         GError** error)
{
	FtIdleMonitorProviderIface* _iface_;
	g_return_val_if_fail (self != NULL, 0U);
	_iface_ = FT_IDLE_MONITOR_PROVIDER_GET_INTERFACE (self);
	if (_iface_->add_idle_watch) {
		return _iface_->add_idle_watch (self, timeout, ignore_inhibitors, monotonic_time, error);
	}
	return 0U;
}

/**
         * Reschedule an idle watch. It ensures that it'll not fire before `timeout` passes
         * counting from the current time.
         */
guint32
ft_idle_monitor_provider_reset_idle_watch (FtIdleMonitorProvider* self,
                                           guint32 id,
                                           gint64 monotonic_time,
                                           GError** error)
{
	FtIdleMonitorProviderIface* _iface_;
	g_return_val_if_fail (self != NULL, 0U);
	_iface_ = FT_IDLE_MONITOR_PROVIDER_GET_INTERFACE (self);
	if (_iface_->reset_idle_watch) {
		return _iface_->reset_idle_watch (self, id, monotonic_time, error);
	}
	return 0U;
}

void
ft_idle_monitor_provider_remove_idle_watch (FtIdleMonitorProvider* self,
                                            guint32 id,
                                            GError** error)
{
	FtIdleMonitorProviderIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = FT_IDLE_MONITOR_PROVIDER_GET_INTERFACE (self);
	if (_iface_->remove_idle_watch) {
		_iface_->remove_idle_watch (self, id, error);
	}
}

void
ft_idle_monitor_provider_add_active_watch (FtIdleMonitorProvider* self,
                                           GError** error)
{
	FtIdleMonitorProviderIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = FT_IDLE_MONITOR_PROVIDER_GET_INTERFACE (self);
	if (_iface_->add_active_watch) {
		_iface_->add_active_watch (self, error);
	}
}

void
ft_idle_monitor_provider_remove_active_watch (FtIdleMonitorProvider* self,
                                              GError** error)
{
	FtIdleMonitorProviderIface* _iface_;
	g_return_if_fail (self != NULL);
	_iface_ = FT_IDLE_MONITOR_PROVIDER_GET_INTERFACE (self);
	if (_iface_->remove_active_watch) {
		_iface_->remove_active_watch (self, error);
	}
}

/**
         * Convert an idle interval anchored at `reference_time` into one relative to the
         * user's last activity.
         */
gint64
ft_idle_monitor_provider_calculate_absolute_timeout (gint64 relative_timeout,
                                                     gint64 idle_time,
                                                     gint64 reference_time)
{
	gint64 last_active_time = 0LL;
	gint64 absolute_timeout = 0LL;
	gint64 _tmp0_ = 0LL;
	gint64 result;
	_vala_return_val_if_fail (ft_timestamp_is_defined (reference_time), "Ft.Timestamp.is_defined (reference_time)", -1LL);
	if (idle_time == ((gint64) 0)) {
		result = relative_timeout;
		return result;
	}
	last_active_time = g_get_monotonic_time () - idle_time;
	absolute_timeout = (relative_timeout + reference_time) - last_active_time;
	if (absolute_timeout > ((gint64) 0)) {
		_tmp0_ = absolute_timeout;
	} else {
		_tmp0_ = relative_timeout;
	}
	result = _tmp0_;
	return result;
}

gboolean
ft_idle_monitor_provider_get_can_ignore_inhibitors (FtIdleMonitorProvider* self)
{
	FtIdleMonitorProviderIface* _iface_;
	g_return_val_if_fail (self != NULL, FALSE);
	_iface_ = FT_IDLE_MONITOR_PROVIDER_GET_INTERFACE (self);
	if (_iface_->get_can_ignore_inhibitors) {
		return _iface_->get_can_ignore_inhibitors (self);
	}
	return FALSE;
}

static void
ft_idle_monitor_provider_default_init (FtIdleMonitorProviderIface * iface,
                                       gpointer iface_data)
{
	g_object_interface_install_property (iface, g_param_spec_boolean ("can-ignore-inhibitors", "can-ignore-inhibitors", "can-ignore-inhibitors", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	ft_idle_monitor_provider_signals[FT_IDLE_MONITOR_PROVIDER_BECAME_IDLE_SIGNAL] = g_signal_new ("became-idle", FT_TYPE_IDLE_MONITOR_PROVIDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT);
	ft_idle_monitor_provider_signals[FT_IDLE_MONITOR_PROVIDER_BECAME_ACTIVE_SIGNAL] = g_signal_new ("became-active", FT_TYPE_IDLE_MONITOR_PROVIDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static GType
ft_idle_monitor_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtIdleMonitorProviderIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_idle_monitor_provider_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType ft_idle_monitor_provider_type_id;
	ft_idle_monitor_provider_type_id = g_type_register_static (G_TYPE_INTERFACE, "FtIdleMonitorProvider", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (ft_idle_monitor_provider_type_id, FT_TYPE_PROVIDER);
	return ft_idle_monitor_provider_type_id;
}

GType
ft_idle_monitor_provider_get_type (void)
{
	static volatile gsize ft_idle_monitor_provider_type_id__once = 0;
	if (g_once_init_enter (&ft_idle_monitor_provider_type_id__once)) {
		GType ft_idle_monitor_provider_type_id;
		ft_idle_monitor_provider_type_id = ft_idle_monitor_provider_get_type_once ();
		g_once_init_leave (&ft_idle_monitor_provider_type_id__once, ft_idle_monitor_provider_type_id);
	}
	return ft_idle_monitor_provider_type_id__once;
}

static void
ft_dummy_idle_monitor_provider_real_initialize_data_free (gpointer _data)
{
	FtDummyIdleMonitorProviderInitializeData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDummyIdleMonitorProviderInitializeData, _data_);
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
ft_dummy_idle_monitor_provider_real_initialize (FtProvider* base,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	FtDummyIdleMonitorProvider * self;
	FtDummyIdleMonitorProviderInitializeData* _data_;
	FtDummyIdleMonitorProvider* _tmp0_;
	GCancellable* _tmp1_;
	self = (FtDummyIdleMonitorProvider*) base;
	_data_ = g_slice_new0 (FtDummyIdleMonitorProviderInitializeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_dummy_idle_monitor_provider_real_initialize_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	ft_dummy_idle_monitor_provider_real_initialize_co (_data_);
}

static void
ft_dummy_idle_monitor_provider_initialize_finish (FtProvider* base,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	FtDummyIdleMonitorProviderInitializeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
ft_dummy_idle_monitor_provider_real_initialize_co (FtDummyIdleMonitorProviderInitializeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	ft_provider_set_available ((FtProvider*) _data_->self, TRUE);
	ft_provider_set_enabled ((FtProvider*) _data_->self, TRUE);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
ft_dummy_idle_monitor_provider_real_uninitialize_data_free (gpointer _data)
{
	FtDummyIdleMonitorProviderUninitializeData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDummyIdleMonitorProviderUninitializeData, _data_);
}

static void
ft_dummy_idle_monitor_provider_real_uninitialize (FtProvider* base,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	FtDummyIdleMonitorProvider * self;
	FtDummyIdleMonitorProviderUninitializeData* _data_;
	FtDummyIdleMonitorProvider* _tmp0_;
	self = (FtDummyIdleMonitorProvider*) base;
	_data_ = g_slice_new0 (FtDummyIdleMonitorProviderUninitializeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_dummy_idle_monitor_provider_real_uninitialize_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	ft_dummy_idle_monitor_provider_real_uninitialize_co (_data_);
}

static void
ft_dummy_idle_monitor_provider_uninitialize_finish (FtProvider* base,
                                                    GAsyncResult* _res_,
                                                    GError** error)
{
	FtDummyIdleMonitorProviderUninitializeData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
ft_dummy_idle_monitor_provider_real_uninitialize_co (FtDummyIdleMonitorProviderUninitializeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	ft_provider_set_available ((FtProvider*) _data_->self, FALSE);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
ft_dummy_idle_monitor_provider_real_enable_data_free (gpointer _data)
{
	FtDummyIdleMonitorProviderEnableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDummyIdleMonitorProviderEnableData, _data_);
}

static void
ft_dummy_idle_monitor_provider_real_enable (FtProvider* base,
                                            GCancellable* cancellable,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	FtDummyIdleMonitorProvider * self;
	FtDummyIdleMonitorProviderEnableData* _data_;
	FtDummyIdleMonitorProvider* _tmp0_;
	GCancellable* _tmp1_;
	self = (FtDummyIdleMonitorProvider*) base;
	_data_ = g_slice_new0 (FtDummyIdleMonitorProviderEnableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_dummy_idle_monitor_provider_real_enable_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	ft_dummy_idle_monitor_provider_real_enable_co (_data_);
}

static void
ft_dummy_idle_monitor_provider_enable_finish (FtProvider* base,
                                              GAsyncResult* _res_,
                                              GError** error)
{
	FtDummyIdleMonitorProviderEnableData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
ft_dummy_idle_monitor_provider_real_enable_co (FtDummyIdleMonitorProviderEnableData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
ft_dummy_idle_monitor_provider_real_disable_data_free (gpointer _data)
{
	FtDummyIdleMonitorProviderDisableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FtDummyIdleMonitorProviderDisableData, _data_);
}

static void
ft_dummy_idle_monitor_provider_real_disable (FtProvider* base,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	FtDummyIdleMonitorProvider * self;
	FtDummyIdleMonitorProviderDisableData* _data_;
	FtDummyIdleMonitorProvider* _tmp0_;
	self = (FtDummyIdleMonitorProvider*) base;
	_data_ = g_slice_new0 (FtDummyIdleMonitorProviderDisableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, ft_dummy_idle_monitor_provider_real_disable_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	ft_dummy_idle_monitor_provider_real_disable_co (_data_);
}

static void
ft_dummy_idle_monitor_provider_disable_finish (FtProvider* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	FtDummyIdleMonitorProviderDisableData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
ft_dummy_idle_monitor_provider_real_disable_co (FtDummyIdleMonitorProviderDisableData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

gint64
ft_dummy_idle_monitor_provider_get_idle_time (FtDummyIdleMonitorProvider* self,
                                              GError** error)
{
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	result = (gint64) 0;
	return result;
}

static guint32
ft_dummy_idle_monitor_provider_real_add_idle_watch (FtIdleMonitorProvider* base,
                                                    gint64 timeout,
                                                    gboolean ignore_inhibitors,
                                                    gint64 monotonic_time,
                                                    GError** error)
{
	FtDummyIdleMonitorProvider * self;
	guint32 result;
	self = (FtDummyIdleMonitorProvider*) base;
	result = (guint32) 1;
	return result;
}

static guint32
ft_dummy_idle_monitor_provider_real_reset_idle_watch (FtIdleMonitorProvider* base,
                                                      guint32 id,
                                                      gint64 monotonic_time,
                                                      GError** error)
{
	FtDummyIdleMonitorProvider * self;
	guint32 result;
	self = (FtDummyIdleMonitorProvider*) base;
	result = (guint32) 1;
	return result;
}

static void
ft_dummy_idle_monitor_provider_real_add_active_watch (FtIdleMonitorProvider* base,
                                                      GError** error)
{
	FtDummyIdleMonitorProvider * self;
	self = (FtDummyIdleMonitorProvider*) base;
}

static void
ft_dummy_idle_monitor_provider_real_remove_idle_watch (FtIdleMonitorProvider* base,
                                                       guint32 id,
                                                       GError** error)
{
	FtDummyIdleMonitorProvider * self;
	self = (FtDummyIdleMonitorProvider*) base;
}

static void
ft_dummy_idle_monitor_provider_real_remove_active_watch (FtIdleMonitorProvider* base,
                                                         GError** error)
{
	FtDummyIdleMonitorProvider * self;
	self = (FtDummyIdleMonitorProvider*) base;
}

FtDummyIdleMonitorProvider*
ft_dummy_idle_monitor_provider_construct (GType object_type)
{
	FtDummyIdleMonitorProvider * self = NULL;
	self = (FtDummyIdleMonitorProvider*) ft_provider_construct (object_type);
	return self;
}

FtDummyIdleMonitorProvider*
ft_dummy_idle_monitor_provider_new (void)
{
	return ft_dummy_idle_monitor_provider_construct (FT_TYPE_DUMMY_IDLE_MONITOR_PROVIDER);
}

static gboolean
ft_dummy_idle_monitor_provider_real_get_can_ignore_inhibitors (FtIdleMonitorProvider* base)
{
	gboolean result;
	FtDummyIdleMonitorProvider* self;
	self = (FtDummyIdleMonitorProvider*) base;
	result = FALSE;
	return result;
}

static void
ft_dummy_idle_monitor_provider_class_init (FtDummyIdleMonitorProviderClass * klass,
                                           gpointer klass_data)
{
	ft_dummy_idle_monitor_provider_parent_class = g_type_class_peek_parent (klass);
	((FtProviderClass *) klass)->initialize = (void (*) (FtProvider*, GCancellable*, GAsyncReadyCallback, gpointer)) ft_dummy_idle_monitor_provider_real_initialize;
	((FtProviderClass *) klass)->initialize_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) ft_dummy_idle_monitor_provider_initialize_finish;
	((FtProviderClass *) klass)->uninitialize = (void (*) (FtProvider*, GAsyncReadyCallback, gpointer)) ft_dummy_idle_monitor_provider_real_uninitialize;
	((FtProviderClass *) klass)->uninitialize_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) ft_dummy_idle_monitor_provider_uninitialize_finish;
	((FtProviderClass *) klass)->enable = (void (*) (FtProvider*, GCancellable*, GAsyncReadyCallback, gpointer)) ft_dummy_idle_monitor_provider_real_enable;
	((FtProviderClass *) klass)->enable_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) ft_dummy_idle_monitor_provider_enable_finish;
	((FtProviderClass *) klass)->disable = (void (*) (FtProvider*, GAsyncReadyCallback, gpointer)) ft_dummy_idle_monitor_provider_real_disable;
	((FtProviderClass *) klass)->disable_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) ft_dummy_idle_monitor_provider_disable_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_ft_dummy_idle_monitor_provider_get_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FT_DUMMY_IDLE_MONITOR_PROVIDER_CAN_IGNORE_INHIBITORS_PROPERTY, ft_dummy_idle_monitor_provider_properties[FT_DUMMY_IDLE_MONITOR_PROVIDER_CAN_IGNORE_INHIBITORS_PROPERTY] = g_param_spec_boolean ("can-ignore-inhibitors", "can-ignore-inhibitors", "can-ignore-inhibitors", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
ft_dummy_idle_monitor_provider_ft_idle_monitor_provider_interface_init (FtIdleMonitorProviderIface * iface,
                                                                        gpointer iface_data)
{
	ft_dummy_idle_monitor_provider_ft_idle_monitor_provider_parent_iface = g_type_interface_peek_parent (iface);
	iface->add_idle_watch = (guint32 (*) (FtIdleMonitorProvider*, gint64, gboolean, gint64, GError**)) ft_dummy_idle_monitor_provider_real_add_idle_watch;
	iface->reset_idle_watch = (guint32 (*) (FtIdleMonitorProvider*, guint32, gint64, GError**)) ft_dummy_idle_monitor_provider_real_reset_idle_watch;
	iface->add_active_watch = (void (*) (FtIdleMonitorProvider*, GError**)) ft_dummy_idle_monitor_provider_real_add_active_watch;
	iface->remove_idle_watch = (void (*) (FtIdleMonitorProvider*, guint32, GError**)) ft_dummy_idle_monitor_provider_real_remove_idle_watch;
	iface->remove_active_watch = (void (*) (FtIdleMonitorProvider*, GError**)) ft_dummy_idle_monitor_provider_real_remove_active_watch;
	iface->get_can_ignore_inhibitors = ft_dummy_idle_monitor_provider_real_get_can_ignore_inhibitors;
}

static void
ft_dummy_idle_monitor_provider_instance_init (FtDummyIdleMonitorProvider * self,
                                              gpointer klass)
{
}

static GType
ft_dummy_idle_monitor_provider_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtDummyIdleMonitorProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_dummy_idle_monitor_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtDummyIdleMonitorProvider), 0, (GInstanceInitFunc) ft_dummy_idle_monitor_provider_instance_init, NULL };
	static const GInterfaceInfo ft_idle_monitor_provider_info = { (GInterfaceInitFunc) ft_dummy_idle_monitor_provider_ft_idle_monitor_provider_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType ft_dummy_idle_monitor_provider_type_id;
	ft_dummy_idle_monitor_provider_type_id = g_type_register_static (FT_TYPE_PROVIDER, "FtDummyIdleMonitorProvider", &g_define_type_info, 0);
	g_type_add_interface_static (ft_dummy_idle_monitor_provider_type_id, FT_TYPE_IDLE_MONITOR_PROVIDER, &ft_idle_monitor_provider_info);
	return ft_dummy_idle_monitor_provider_type_id;
}

GType
ft_dummy_idle_monitor_provider_get_type (void)
{
	static volatile gsize ft_dummy_idle_monitor_provider_type_id__once = 0;
	if (g_once_init_enter (&ft_dummy_idle_monitor_provider_type_id__once)) {
		GType ft_dummy_idle_monitor_provider_type_id;
		ft_dummy_idle_monitor_provider_type_id = ft_dummy_idle_monitor_provider_get_type_once ();
		g_once_init_leave (&ft_dummy_idle_monitor_provider_type_id__once, ft_dummy_idle_monitor_provider_type_id);
	}
	return ft_dummy_idle_monitor_provider_type_id__once;
}

static void
_vala_ft_dummy_idle_monitor_provider_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	FtDummyIdleMonitorProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FT_TYPE_DUMMY_IDLE_MONITOR_PROVIDER, FtDummyIdleMonitorProvider);
	switch (property_id) {
		case FT_DUMMY_IDLE_MONITOR_PROVIDER_CAN_IGNORE_INHIBITORS_PROPERTY:
		g_value_set_boolean (value, ft_idle_monitor_provider_get_can_ignore_inhibitors ((FtIdleMonitorProvider*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
ft_idle_monitor_get_instance_private (FtIdleMonitor* self)
{
	return G_STRUCT_MEMBER_P (self, FtIdleMonitor_private_offset);
}

static Block15Data*
block15_data_ref (Block15Data* _data15_)
{
	g_atomic_int_inc (&_data15_->_ref_count_);
	return _data15_;
}

static void
block15_data_unref (void * _userdata_)
{
	Block15Data* _data15_;
	_data15_ = (Block15Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data15_->_ref_count_)) {
		FtIdleMonitor* self;
		self = _data15_->self;
		_g_object_unref0 (self);
		g_slice_free (Block15Data, _data15_);
	}
}

static gboolean
__lambda33_ (Block15Data* _data15_,
             gint64* _id,
             FtIdleMonitorWatch* watch)
{
	FtIdleMonitor* self;
	gboolean result;
	self = _data15_->self;
	g_return_val_if_fail (watch != NULL, FALSE);
	result = watch->external_id == _data15_->id;
	return result;
}

static gboolean
___lambda33__ghr_func (gconstpointer key,
                       gconstpointer value,
                       gpointer self)
{
	gboolean result;
	result = __lambda33_ (self, (gint64*) key, (FtIdleMonitorWatch*) value);
	return result;
}

static void
ft_idle_monitor_on_became_idle (FtIdleMonitor* self,
                                guint32 id)
{
	Block15Data* _data15_;
	FtIdleMonitorWatch* watch = NULL;
	GHashTable* _tmp0_;
	gconstpointer _tmp1_;
	gboolean _tmp2_ = FALSE;
	FtIdleMonitorWatch* _tmp3_;
	g_return_if_fail (self != NULL);
	_data15_ = g_slice_new0 (Block15Data);
	_data15_->_ref_count_ = 1;
	_data15_->self = g_object_ref (self);
	_data15_->id = id;
	_tmp0_ = self->priv->watches;
	_tmp1_ = g_hash_table_find (_tmp0_, ___lambda33__ghr_func, _data15_);
	watch = (FtIdleMonitorWatch*) _tmp1_;
	_tmp3_ = watch;
	if (_tmp3_ != NULL) {
		FtIdleMonitorWatch* _tmp4_;
		_tmp4_ = watch;
		_tmp2_ = !_tmp4_->invalid;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		FtIdleMonitorWatch* _tmp5_;
		FtCallback _tmp6_;
		gpointer _tmp6__target;
		_tmp5_ = watch;
		_tmp6_ = _tmp5_->idle_callback;
		_tmp6__target = _tmp5_->idle_callback_target;
		_tmp6_ (_tmp6__target);
	}
	block15_data_unref (_data15_);
	_data15_ = NULL;
}

static Block16Data*
block16_data_ref (Block16Data* _data16_)
{
	g_atomic_int_inc (&_data16_->_ref_count_);
	return _data16_;
}

static void
block16_data_unref (void * _userdata_)
{
	Block16Data* _data16_;
	_data16_ = (Block16Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data16_->_ref_count_)) {
		FtIdleMonitor* self;
		self = _data16_->self;
		_data16_->watches_to_trigger = (g_free (_data16_->watches_to_trigger), NULL);
		_g_object_unref0 (self);
		g_slice_free (Block16Data, _data16_);
	}
}

static void
_vala_array_add19 (FtIdleMonitorWatch** * array,
                   gint* length,
                   gint* size,
                   FtIdleMonitorWatch* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (FtIdleMonitorWatch*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
__lambda34_ (Block16Data* _data16_,
             gint64* id,
             FtIdleMonitorWatch* watch)
{
	FtIdleMonitor* self;
	FtCallback _tmp0_;
	gpointer _tmp0__target;
	FtCallback _tmp1_;
	gpointer _tmp1__target;
	GError* _inner_error0_ = NULL;
	self = _data16_->self;
	g_return_if_fail (watch != NULL);
	if (watch->invalid) {
		return;
	}
	_tmp0_ = watch->active_callback;
	_tmp0__target = watch->active_callback_target;
	if (_tmp0_ != NULL) {
		_vala_array_add19 (&_data16_->watches_to_trigger, &_data16_->watches_to_trigger_length1, &_data16_->_watches_to_trigger_size_, watch);
	}
	_tmp1_ = watch->idle_callback;
	_tmp1__target = watch->idle_callback_target;
	if (_tmp1_ != NULL) {
		{
			guint32 _tmp2_ = 0U;
			gconstpointer _tmp3_;
			gconstpointer _tmp4_;
			_tmp3_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
			_tmp4_ = _tmp3_;
			_tmp2_ = ft_idle_monitor_provider_reset_idle_watch ((FtIdleMonitorProvider*) _tmp4_, watch->external_id, _data16_->monotonic_time, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			watch->external_id = _tmp2_;
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* _error_ = NULL;
			GError* _tmp5_;
			const gchar* _tmp6_;
			_error_ = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp5_ = _error_;
			_tmp6_ = _tmp5_->message;
			g_warning ("idle-monitor.vala:193: Unable to reset an idle watch: %s", _tmp6_);
			_g_error_free0 (_error_);
			return;
		}
		__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;
		}
	}
}

static void
___lambda34__gh_func (gconstpointer key,
                      gconstpointer value,
                      gpointer self)
{
	__lambda34_ (self, (gint64*) key, (FtIdleMonitorWatch*) value);
}

static gboolean
__lambda35_ (FtIdleMonitor* self,
             gint64* id,
             FtIdleMonitorWatch* watch)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	g_return_val_if_fail (watch != NULL, FALSE);
	if (watch->invalid) {
		FtCallback _tmp1_;
		gpointer _tmp1__target;
		_tmp1_ = watch->active_callback;
		_tmp1__target = watch->active_callback_target;
		_tmp0_ = _tmp1_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static gboolean
___lambda35__ghr_func (gconstpointer key,
                       gconstpointer value,
                       gpointer self)
{
	gboolean result;
	result = __lambda35_ ((FtIdleMonitor*) self, (gint64*) key, (FtIdleMonitorWatch*) value);
	return result;
}

static void
ft_idle_monitor_on_became_active (FtIdleMonitor* self)
{
	Block16Data* _data16_;
	FtIdleMonitorWatch** _tmp0_;
	GHashTable* _tmp1_;
	GHashTable* _tmp10_;
	g_return_if_fail (self != NULL);
	_data16_ = g_slice_new0 (Block16Data);
	_data16_->_ref_count_ = 1;
	_data16_->self = g_object_ref (self);
	_data16_->monotonic_time = g_get_monotonic_time ();
	self->priv->last_activity_time = _data16_->monotonic_time;
	_tmp0_ = g_new0 (FtIdleMonitorWatch*, 0 + 1);
	_data16_->watches_to_trigger = _tmp0_;
	_data16_->watches_to_trigger_length1 = 0;
	_data16_->_watches_to_trigger_size_ = _data16_->watches_to_trigger_length1;
	_tmp1_ = self->priv->watches;
	g_hash_table_foreach (_tmp1_, ___lambda34__gh_func, _data16_);
	{
		gint index = 0;
		index = 0;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				FtIdleMonitorWatch** _tmp4_;
				gint _tmp4__length1;
				FtIdleMonitorWatch* watch = NULL;
				FtIdleMonitorWatch** _tmp5_;
				gint _tmp5__length1;
				FtIdleMonitorWatch* _tmp6_;
				FtIdleMonitorWatch* _tmp7_;
				FtCallback _tmp8_;
				gpointer _tmp8__target;
				FtIdleMonitorWatch* _tmp9_;
				if (!_tmp2_) {
					gint _tmp3_;
					_tmp3_ = index;
					index = _tmp3_ + 1;
				}
				_tmp2_ = FALSE;
				_tmp4_ = _data16_->watches_to_trigger;
				_tmp4__length1 = _data16_->watches_to_trigger_length1;
				if (!(index < _tmp4__length1)) {
					break;
				}
				_tmp5_ = _data16_->watches_to_trigger;
				_tmp5__length1 = _data16_->watches_to_trigger_length1;
				_tmp6_ = _tmp5_[index];
				watch = _tmp6_;
				_tmp7_ = watch;
				_tmp8_ = _tmp7_->active_callback;
				_tmp8__target = _tmp7_->active_callback_target;
				_tmp8_ (_tmp8__target);
				_tmp9_ = watch;
				_tmp9_->invalid = TRUE;
			}
		}
	}
	_tmp10_ = self->priv->watches;
	g_hash_table_foreach_remove (_tmp10_, ___lambda35__ghr_func, self);
	block16_data_unref (_data16_);
	_data16_ = NULL;
}

static void
_g_free0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_free (var), NULL));
}

static void
_ft_idle_monitor_watch_free0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (ft_idle_monitor_watch_free (var), NULL));
}

static void
ft_idle_monitor_real_initialize (FtProvidedObject* base)
{
	FtIdleMonitor * self;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	self = (FtIdleMonitor*) base;
	_tmp0_ = g_int64_hash;
	_tmp1_ = g_int64_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _ft_idle_monitor_watch_free0_);
	_g_hash_table_unref0 (self->priv->watches);
	self->priv->watches = _tmp2_;
}

static void
ft_idle_monitor_real_setup_providers (FtProvidedObject* base)
{
	FtIdleMonitor * self;
	self = (FtIdleMonitor*) base;
	if (ft_is_test ()) {
		FtProviderSet* _tmp0_;
		FtDummyIdleMonitorProvider* _tmp1_;
		FtDummyIdleMonitorProvider* _tmp2_;
		_tmp0_ = ((FtProvidedObject*) self)->providers;
		_tmp1_ = ft_dummy_idle_monitor_provider_new ();
		_tmp2_ = _tmp1_;
		ft_provider_set_add (_tmp0_, (FtIdleMonitorProvider*) _tmp2_, FT_PRIORITY_HIGH);
		_g_object_unref0 (_tmp2_);
	}
}

static Block17Data*
block17_data_ref (Block17Data* _data17_)
{
	g_atomic_int_inc (&_data17_->_ref_count_);
	return _data17_;
}

static void
block17_data_unref (void * _userdata_)
{
	Block17Data* _data17_;
	_data17_ = (Block17Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data17_->_ref_count_)) {
		FtIdleMonitor* self;
		self = _data17_->self;
		_g_object_unref0 (_data17_->provider);
		_g_object_unref0 (self);
		g_slice_free (Block17Data, _data17_);
	}
}

static void
_ft_idle_monitor_on_became_idle_ft_idle_monitor_provider_became_idle (FtIdleMonitorProvider* _sender,
                                                                      guint32 id,
                                                                      gpointer self)
{
	ft_idle_monitor_on_became_idle ((FtIdleMonitor*) self, id);
}

static void
_ft_idle_monitor_on_became_active_ft_idle_monitor_provider_became_active (FtIdleMonitorProvider* _sender,
                                                                          gpointer self)
{
	ft_idle_monitor_on_became_active ((FtIdleMonitor*) self);
}

static void
__lambda36_ (Block17Data* _data17_,
             gint64* id,
             FtIdleMonitorWatch* watch)
{
	FtIdleMonitor* self;
	gboolean _tmp0_ = FALSE;
	FtCallback _tmp1_;
	gpointer _tmp1__target;
	FtCallback _tmp8_;
	gpointer _tmp8__target;
	GError* _inner_error0_ = NULL;
	self = _data17_->self;
	g_return_if_fail (watch != NULL);
	_tmp1_ = watch->idle_callback;
	_tmp1__target = watch->idle_callback_target;
	if (_tmp1_ != NULL) {
		_tmp0_ = watch->external_id == ((guint32) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		{
			gboolean _tmp2_ = FALSE;
			guint32 _tmp5_ = 0U;
			if (watch->ignore_inhibitors) {
				gboolean _tmp3_;
				gboolean _tmp4_;
				_tmp3_ = ft_idle_monitor_provider_get_can_ignore_inhibitors (_data17_->provider);
				_tmp4_ = _tmp3_;
				_tmp2_ = _tmp4_;
			} else {
				_tmp2_ = FALSE;
			}
			_tmp5_ = ft_idle_monitor_provider_add_idle_watch (_data17_->provider, watch->timeout, _tmp2_, watch->reference_time, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			watch->external_id = _tmp5_;
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* _error_ = NULL;
			GError* _tmp6_;
			const gchar* _tmp7_;
			_error_ = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp6_ = _error_;
			_tmp7_ = _tmp6_->message;
			g_warning ("idle-monitor.vala:243: Error while adding idle watch: %s", _tmp7_);
			_g_error_free0 (_error_);
		}
		__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;
		}
	}
	_tmp8_ = watch->active_callback;
	_tmp8__target = watch->active_callback_target;
	if (_tmp8_ != NULL) {
		{
			ft_idle_monitor_provider_add_active_watch (_data17_->provider, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
		}
		goto __finally1;
		__catch1_g_error:
		{
			GError* _error_ = NULL;
			GError* _tmp9_;
			const gchar* _tmp10_;
			_error_ = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp9_ = _error_;
			_tmp10_ = _tmp9_->message;
			g_warning ("idle-monitor.vala:253: Error while adding active watch: %s", _tmp10_);
			_g_error_free0 (_error_);
		}
		__finally1:
		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;
		}
	}
}

static void
___lambda36__gh_func (gconstpointer key,
                      gconstpointer value,
                      gpointer self)
{
	__lambda36_ (self, (gint64*) key, (FtIdleMonitorWatch*) value);
}

static void
ft_idle_monitor_real_provider_enabled (FtProvidedObject* base,
                                       FtIdleMonitorProvider* provider)
{
	FtIdleMonitor * self;
	Block17Data* _data17_;
	FtIdleMonitorProvider* _tmp0_;
	GHashTable* _tmp1_;
	self = (FtIdleMonitor*) base;
	g_return_if_fail (provider != NULL);
	_data17_ = g_slice_new0 (Block17Data);
	_data17_->_ref_count_ = 1;
	_data17_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (provider);
	_g_object_unref0 (_data17_->provider);
	_data17_->provider = _tmp0_;
	g_signal_connect_object (_data17_->provider, "became-idle", (GCallback) _ft_idle_monitor_on_became_idle_ft_idle_monitor_provider_became_idle, self, 0);
	g_signal_connect_object (_data17_->provider, "became-active", (GCallback) _ft_idle_monitor_on_became_active_ft_idle_monitor_provider_became_active, self, 0);
	_tmp1_ = self->priv->watches;
	g_hash_table_foreach (_tmp1_, ___lambda36__gh_func, _data17_);
	block17_data_unref (_data17_);
	_data17_ = NULL;
}

static Block18Data*
block18_data_ref (Block18Data* _data18_)
{
	g_atomic_int_inc (&_data18_->_ref_count_);
	return _data18_;
}

static void
block18_data_unref (void * _userdata_)
{
	Block18Data* _data18_;
	_data18_ = (Block18Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data18_->_ref_count_)) {
		FtIdleMonitor* self;
		self = _data18_->self;
		_g_object_unref0 (_data18_->provider);
		_g_object_unref0 (self);
		g_slice_free (Block18Data, _data18_);
	}
}

static void
__lambda37_ (Block18Data* _data18_,
             gint64* id,
             FtIdleMonitorWatch* watch)
{
	FtIdleMonitor* self;
	GError* _inner_error0_ = NULL;
	self = _data18_->self;
	g_return_if_fail (watch != NULL);
	{
		ft_idle_monitor_provider_remove_idle_watch (_data18_->provider, watch->external_id, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = _error_;
		_tmp1_ = _tmp0_->message;
		g_warning ("idle-monitor.vala:270: Error while removing idle watch: %s", _tmp1_);
		_g_error_free0 (_error_);
	}
	__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;
	}
	watch->external_id = (guint32) 0;
}

static void
___lambda37__gh_func (gconstpointer key,
                      gconstpointer value,
                      gpointer self)
{
	__lambda37_ (self, (gint64*) key, (FtIdleMonitorWatch*) value);
}

static void
ft_idle_monitor_real_provider_disabled (FtProvidedObject* base,
                                        FtIdleMonitorProvider* provider)
{
	FtIdleMonitor * self;
	Block18Data* _data18_;
	FtIdleMonitorProvider* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	GHashTable* _tmp3_;
	self = (FtIdleMonitor*) base;
	g_return_if_fail (provider != NULL);
	_data18_ = g_slice_new0 (Block18Data);
	_data18_->_ref_count_ = 1;
	_data18_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (provider);
	_g_object_unref0 (_data18_->provider);
	_data18_->provider = _tmp0_;
	g_signal_parse_name ("became-idle", FT_TYPE_IDLE_MONITOR_PROVIDER, &_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data18_->provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp1_, 0, NULL, (GCallback) _ft_idle_monitor_on_became_idle_ft_idle_monitor_provider_became_idle, self);
	g_signal_parse_name ("became-active", FT_TYPE_IDLE_MONITOR_PROVIDER, &_tmp2_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data18_->provider, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _ft_idle_monitor_on_became_active_ft_idle_monitor_provider_became_active, self);
	_tmp3_ = self->priv->watches;
	g_hash_table_foreach (_tmp3_, ___lambda37__gh_func, _data18_);
	block18_data_unref (_data18_);
	_data18_ = NULL;
}

/**
         * Register an idle watch.
         *
         * `reference_time` specifies whether idle-time should be detected from this point of time,
         * otherwise the callback will be called counting from the time of users last activity.
         */
static gint64*
_int64_dup (gint64* self)
{
	gint64* dup;
	dup = g_new0 (gint64, 1);
	memcpy (dup, self, sizeof (gint64));
	return dup;
}

static gpointer
__int64_dup0 (gpointer self)
{
	return self ? _int64_dup (self) : NULL;
}

guint
ft_idle_monitor_add_idle_watch (FtIdleMonitor* self,
                                gint64 timeout,
                                gboolean ignore_inhibitors,
                                FtCallback callback,
                                gpointer callback_target,
                                GDestroyNotify callback_target_destroy_notify,
                                gint64 monotonic_time)
{
	guint watch_id = 0U;
	guint _tmp0_;
	FtIdleMonitorWatch* watch = NULL;
	FtIdleMonitorWatch* _tmp1_;
	FtIdleMonitorWatch* _tmp2_;
	FtIdleMonitorWatch* _tmp3_;
	FtIdleMonitorWatch* _tmp4_;
	FtIdleMonitorWatch* _tmp5_;
	FtCallback _tmp6_;
	gpointer _tmp6__target;
	GDestroyNotify _tmp6__target_destroy_notify;
	FtIdleMonitorWatch* _tmp7_;
	FtIdleMonitorWatch* _tmp8_;
	gconstpointer _tmp9_;
	gconstpointer _tmp10_;
	gboolean _tmp11_ = FALSE;
	gconstpointer _tmp12_;
	gconstpointer _tmp13_;
	GHashTable* _tmp30_;
	gint64 _tmp31_;
	gint64* _tmp32_;
	FtIdleMonitorWatch* _tmp33_;
	GError* _inner_error0_ = NULL;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	if (timeout == ((gint64) 0)) {
		result = (guint) 0;
		(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
		callback = NULL;
		callback_target = NULL;
		callback_target_destroy_notify = NULL;
		return result;
	}
	watch_id = ft_idle_monitor_next_watch_id;
	_tmp0_ = ft_idle_monitor_next_watch_id;
	ft_idle_monitor_next_watch_id = _tmp0_ + 1;
	_tmp1_ = ft_idle_monitor_watch_new ();
	watch = _tmp1_;
	_tmp2_ = watch;
	_tmp2_->id = watch_id;
	_tmp3_ = watch;
	_tmp3_->timeout = timeout;
	_tmp4_ = watch;
	_tmp4_->ignore_inhibitors = ignore_inhibitors;
	_tmp5_ = watch;
	_tmp6_ = callback;
	_tmp6__target = callback_target;
	_tmp6__target_destroy_notify = callback_target_destroy_notify;
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	(_tmp5_->idle_callback_target_destroy_notify == NULL) ? NULL : (_tmp5_->idle_callback_target_destroy_notify (_tmp5_->idle_callback_target), NULL);
	_tmp5_->idle_callback = NULL;
	_tmp5_->idle_callback_target = NULL;
	_tmp5_->idle_callback_target_destroy_notify = NULL;
	_tmp5_->idle_callback = _tmp6_;
	_tmp5_->idle_callback_target = _tmp6__target;
	_tmp5_->idle_callback_target_destroy_notify = _tmp6__target_destroy_notify;
	_tmp7_ = watch;
	_tmp7_->reference_time = monotonic_time;
	_tmp8_ = watch;
	_tmp9_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp10_ = _tmp9_;
	_tmp8_->provider = (FtIdleMonitorProvider*) _tmp10_;
	_tmp12_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp13_ = _tmp12_;
	if (((FtIdleMonitorProvider*) _tmp13_) != NULL) {
		gconstpointer _tmp14_;
		gconstpointer _tmp15_;
		gboolean _tmp16_;
		gboolean _tmp17_;
		_tmp14_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
		_tmp15_ = _tmp14_;
		_tmp16_ = ft_provider_get_enabled ((FtProvider*) ((FtIdleMonitorProvider*) _tmp15_));
		_tmp17_ = _tmp16_;
		_tmp11_ = _tmp17_;
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		{
			gboolean _tmp18_ = FALSE;
			guint32 _tmp23_ = 0U;
			gconstpointer _tmp24_;
			gconstpointer _tmp25_;
			FtIdleMonitorWatch* _tmp26_;
			if (ignore_inhibitors) {
				gconstpointer _tmp19_;
				gconstpointer _tmp20_;
				gboolean _tmp21_;
				gboolean _tmp22_;
				_tmp19_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
				_tmp20_ = _tmp19_;
				_tmp21_ = ft_idle_monitor_provider_get_can_ignore_inhibitors ((FtIdleMonitorProvider*) _tmp20_);
				_tmp22_ = _tmp21_;
				_tmp18_ = _tmp22_;
			} else {
				_tmp18_ = FALSE;
			}
			_tmp24_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
			_tmp25_ = _tmp24_;
			_tmp23_ = ft_idle_monitor_provider_add_idle_watch ((FtIdleMonitorProvider*) _tmp25_, timeout, _tmp18_, monotonic_time, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp26_ = watch;
			_tmp26_->external_id = _tmp23_;
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* _error_ = NULL;
			GError* _tmp27_;
			const gchar* _tmp28_;
			_error_ = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp27_ = _error_;
			_tmp28_ = _tmp27_->message;
			g_warning ("idle-monitor.vala:312: Unable to add an idle watch: %s", _tmp28_);
			_g_error_free0 (_error_);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			guint _tmp29_ = 0U;
			_ft_idle_monitor_watch_free0 (watch);
			(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
			callback = NULL;
			callback_target = NULL;
			callback_target_destroy_notify = 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 _tmp29_;
		}
	} else {
		g_debug ("idle-monitor.vala:316: Unable to add an idle watch: no provider.");
	}
	_tmp30_ = self->priv->watches;
	_tmp31_ = (gint64) watch_id;
	_tmp32_ = __int64_dup0 (&_tmp31_);
	_tmp33_ = watch;
	watch = NULL;
	g_hash_table_insert (_tmp30_, _tmp32_, _tmp33_);
	result = watch_id;
	_ft_idle_monitor_watch_free0 (watch);
	(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	return result;
}

/**
         * Trigger callback on first user activity counting from now.
         */
guint
ft_idle_monitor_add_active_watch (FtIdleMonitor* self,
                                  FtCallback callback,
                                  gpointer callback_target,
                                  GDestroyNotify callback_target_destroy_notify,
                                  gint64 monotonic_time)
{
	guint watch_id = 0U;
	guint _tmp0_;
	FtIdleMonitorWatch* watch = NULL;
	FtIdleMonitorWatch* _tmp1_;
	FtIdleMonitorWatch* _tmp2_;
	FtIdleMonitorWatch* _tmp3_;
	FtCallback _tmp4_;
	gpointer _tmp4__target;
	GDestroyNotify _tmp4__target_destroy_notify;
	FtIdleMonitorWatch* _tmp5_;
	FtIdleMonitorWatch* _tmp6_;
	gconstpointer _tmp7_;
	gconstpointer _tmp8_;
	gboolean _tmp9_ = FALSE;
	gconstpointer _tmp10_;
	gconstpointer _tmp11_;
	GHashTable* _tmp21_;
	gint64 _tmp22_;
	gint64* _tmp23_;
	FtIdleMonitorWatch* _tmp24_;
	GError* _inner_error0_ = NULL;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	watch_id = ft_idle_monitor_next_watch_id;
	_tmp0_ = ft_idle_monitor_next_watch_id;
	ft_idle_monitor_next_watch_id = _tmp0_ + 1;
	_tmp1_ = ft_idle_monitor_watch_new ();
	watch = _tmp1_;
	_tmp2_ = watch;
	_tmp2_->id = watch_id;
	_tmp3_ = watch;
	_tmp4_ = callback;
	_tmp4__target = callback_target;
	_tmp4__target_destroy_notify = callback_target_destroy_notify;
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	(_tmp3_->active_callback_target_destroy_notify == NULL) ? NULL : (_tmp3_->active_callback_target_destroy_notify (_tmp3_->active_callback_target), NULL);
	_tmp3_->active_callback = NULL;
	_tmp3_->active_callback_target = NULL;
	_tmp3_->active_callback_target_destroy_notify = NULL;
	_tmp3_->active_callback = _tmp4_;
	_tmp3_->active_callback_target = _tmp4__target;
	_tmp3_->active_callback_target_destroy_notify = _tmp4__target_destroy_notify;
	_tmp5_ = watch;
	_tmp5_->reference_time = monotonic_time;
	_tmp6_ = watch;
	_tmp7_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp8_ = _tmp7_;
	_tmp6_->provider = (FtIdleMonitorProvider*) _tmp8_;
	_tmp10_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp11_ = _tmp10_;
	if (((FtIdleMonitorProvider*) _tmp11_) != NULL) {
		gconstpointer _tmp12_;
		gconstpointer _tmp13_;
		gboolean _tmp14_;
		gboolean _tmp15_;
		_tmp12_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
		_tmp13_ = _tmp12_;
		_tmp14_ = ft_provider_get_enabled ((FtProvider*) ((FtIdleMonitorProvider*) _tmp13_));
		_tmp15_ = _tmp14_;
		_tmp9_ = _tmp15_;
	} else {
		_tmp9_ = FALSE;
	}
	if (_tmp9_) {
		{
			gconstpointer _tmp16_;
			gconstpointer _tmp17_;
			_tmp16_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
			_tmp17_ = _tmp16_;
			ft_idle_monitor_provider_add_active_watch ((FtIdleMonitorProvider*) _tmp17_, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* _error_ = NULL;
			GError* _tmp18_;
			const gchar* _tmp19_;
			_error_ = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp18_ = _error_;
			_tmp19_ = _tmp18_->message;
			g_warning ("idle-monitor.vala:345: Unable to add an active watch: %s", _tmp19_);
			_g_error_free0 (_error_);
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			guint _tmp20_ = 0U;
			_ft_idle_monitor_watch_free0 (watch);
			(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
			callback = NULL;
			callback_target = NULL;
			callback_target_destroy_notify = 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 _tmp20_;
		}
	} else {
		g_debug ("idle-monitor.vala:349: Unable to add an active watch: no provider.");
	}
	_tmp21_ = self->priv->watches;
	_tmp22_ = (gint64) watch_id;
	_tmp23_ = __int64_dup0 (&_tmp22_);
	_tmp24_ = watch;
	watch = NULL;
	g_hash_table_insert (_tmp21_, _tmp23_, _tmp24_);
	result = watch_id;
	_ft_idle_monitor_watch_free0 (watch);
	(callback_target_destroy_notify == NULL) ? NULL : (callback_target_destroy_notify (callback_target), NULL);
	callback = NULL;
	callback_target = NULL;
	callback_target_destroy_notify = NULL;
	return result;
}

void
ft_idle_monitor_remove_watch (FtIdleMonitor* self,
                              guint id)
{
	FtIdleMonitorWatch* watch = NULL;
	GHashTable* _tmp0_;
	gint64 _tmp1_;
	gconstpointer _tmp2_;
	FtIdleMonitorWatch* _tmp3_;
	gconstpointer _tmp4_;
	gconstpointer _tmp5_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->watches;
	_tmp1_ = (gint64) id;
	_tmp2_ = g_hash_table_lookup (_tmp0_, &_tmp1_);
	watch = (FtIdleMonitorWatch*) _tmp2_;
	_tmp3_ = watch;
	if (_tmp3_ == NULL) {
		return;
	}
	_tmp4_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
	_tmp5_ = _tmp4_;
	if (((FtIdleMonitorProvider*) _tmp5_) == NULL) {
		FtIdleMonitorWatch* _tmp6_;
		_tmp6_ = watch;
		_tmp6_->invalid = TRUE;
		return;
	}
	{
		gboolean _tmp7_ = FALSE;
		FtIdleMonitorWatch* _tmp8_;
		FtCallback _tmp9_;
		gpointer _tmp9__target;
		FtIdleMonitorWatch* _tmp14_;
		FtCallback _tmp15_;
		gpointer _tmp15__target;
		GHashTable* _tmp18_;
		gint64 _tmp19_;
		_tmp8_ = watch;
		_tmp9_ = _tmp8_->idle_callback;
		_tmp9__target = _tmp8_->idle_callback_target;
		if (_tmp9_ != NULL) {
			FtIdleMonitorWatch* _tmp10_;
			_tmp10_ = watch;
			_tmp7_ = _tmp10_->external_id != ((guint32) 0);
		} else {
			_tmp7_ = FALSE;
		}
		if (_tmp7_) {
			gconstpointer _tmp11_;
			gconstpointer _tmp12_;
			FtIdleMonitorWatch* _tmp13_;
			_tmp11_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
			_tmp12_ = _tmp11_;
			_tmp13_ = watch;
			ft_idle_monitor_provider_remove_idle_watch ((FtIdleMonitorProvider*) _tmp12_, _tmp13_->external_id, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		_tmp14_ = watch;
		_tmp15_ = _tmp14_->active_callback;
		_tmp15__target = _tmp14_->active_callback_target;
		if (_tmp15_ != NULL) {
			gconstpointer _tmp16_;
			gconstpointer _tmp17_;
			_tmp16_ = ft_provided_object_get_provider ((FtProvidedObject*) self);
			_tmp17_ = _tmp16_;
			ft_idle_monitor_provider_remove_active_watch ((FtIdleMonitorProvider*) _tmp17_, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		_tmp18_ = self->priv->watches;
		_tmp19_ = (gint64) id;
		g_hash_table_remove (_tmp18_, &_tmp19_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp20_;
		const gchar* _tmp21_;
		FtIdleMonitorWatch* _tmp22_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp20_ = _error_;
		_tmp21_ = _tmp20_->message;
		g_debug ("idle-monitor.vala:383: Error while removing watch: %s", _tmp21_);
		_tmp22_ = watch;
		_tmp22_->invalid = TRUE;
		_g_error_free0 (_error_);
	}
	__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;
	}
}

static void
ft_idle_monitor_real_dispose (GObject* base)
{
	FtIdleMonitor * self;
	self = (FtIdleMonitor*) base;
	G_OBJECT_CLASS (ft_idle_monitor_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, FT_TYPE_PROVIDED_OBJECT, FtProvidedObject));
	_g_hash_table_unref0 (self->priv->watches);
	self->priv->watches = NULL;
}

FtIdleMonitor*
ft_idle_monitor_construct (GType object_type)
{
	FtIdleMonitor * self = NULL;
	self = (FtIdleMonitor*) ft_provided_object_construct (object_type, FT_TYPE_IDLE_MONITOR_PROVIDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref);
	return self;
}

FtIdleMonitor*
ft_idle_monitor_new (void)
{
	return ft_idle_monitor_construct (FT_TYPE_IDLE_MONITOR);
}

static FtIdleMonitorWatch*
ft_idle_monitor_watch_new (void)
{
	FtIdleMonitorWatch* self;
	self = g_slice_new0 (FtIdleMonitorWatch);
	ft_idle_monitor_watch_instance_init (self);
	return self;
}

static void
ft_idle_monitor_watch_instance_init (FtIdleMonitorWatch * self)
{
	self->id = 0U;
	self->external_id = (guint32) 0U;
	self->timeout = (gint64) 0;
	self->reference_time = FT_TIMESTAMP_UNDEFINED;
	self->ignore_inhibitors = FALSE;
	self->idle_callback = NULL;
	self->idle_callback_target = NULL;
	self->idle_callback_target_destroy_notify = NULL;
	self->active_callback = NULL;
	self->active_callback_target = NULL;
	self->active_callback_target_destroy_notify = NULL;
	self->provider = NULL;
	self->invalid = FALSE;
}

static void
ft_idle_monitor_watch_free (FtIdleMonitorWatch * self)
{
	(self->idle_callback_target_destroy_notify == NULL) ? NULL : (self->idle_callback_target_destroy_notify (self->idle_callback_target), NULL);
	self->idle_callback = NULL;
	self->idle_callback_target = NULL;
	self->idle_callback_target_destroy_notify = NULL;
	self->idle_callback = NULL;
	self->idle_callback_target = NULL;
	self->idle_callback_target_destroy_notify = NULL;
	(self->active_callback_target_destroy_notify == NULL) ? NULL : (self->active_callback_target_destroy_notify (self->active_callback_target), NULL);
	self->active_callback = NULL;
	self->active_callback_target = NULL;
	self->active_callback_target_destroy_notify = NULL;
	self->active_callback = NULL;
	self->active_callback_target = NULL;
	self->active_callback_target_destroy_notify = NULL;
	self->provider = NULL;
	(self->idle_callback_target_destroy_notify == NULL) ? NULL : (self->idle_callback_target_destroy_notify (self->idle_callback_target), NULL);
	self->idle_callback = NULL;
	self->idle_callback_target = NULL;
	self->idle_callback_target_destroy_notify = NULL;
	(self->active_callback_target_destroy_notify == NULL) ? NULL : (self->active_callback_target_destroy_notify (self->active_callback_target), NULL);
	self->active_callback = NULL;
	self->active_callback_target = NULL;
	self->active_callback_target_destroy_notify = NULL;
	g_slice_free (FtIdleMonitorWatch, self);
}

static GObject *
ft_idle_monitor_constructor (GType type,
                             guint n_construct_properties,
                             GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	static GWeakRef FtIdleMonitor_singleton__ref;
	static GMutex FtIdleMonitor_singleton__lock;
	FtIdleMonitor * self;
	g_mutex_lock (&FtIdleMonitor_singleton__lock);
	obj = g_weak_ref_get (&FtIdleMonitor_singleton__ref);
	if (obj != NULL) {
		g_mutex_unlock (&FtIdleMonitor_singleton__lock);
		return obj;
	}
	parent_class = G_OBJECT_CLASS (ft_idle_monitor_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_IDLE_MONITOR, FtIdleMonitor);
	g_weak_ref_set (&FtIdleMonitor_singleton__ref, obj);
	g_mutex_unlock (&FtIdleMonitor_singleton__lock);
	return obj;
}

static void
ft_idle_monitor_class_init (FtIdleMonitorClass * klass,
                            gpointer klass_data)
{
	ft_idle_monitor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FtIdleMonitor_private_offset);
	((FtProvidedObjectClass *) klass)->initialize = (void (*) (FtProvidedObject*)) ft_idle_monitor_real_initialize;
	((FtProvidedObjectClass *) klass)->setup_providers = (void (*) (FtProvidedObject*)) ft_idle_monitor_real_setup_providers;
	((FtProvidedObjectClass *) klass)->provider_enabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_idle_monitor_real_provider_enabled;
	((FtProvidedObjectClass *) klass)->provider_disabled = (void (*) (FtProvidedObject*, gconstpointer)) ft_idle_monitor_real_provider_disabled;
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) ft_idle_monitor_real_dispose;
	G_OBJECT_CLASS (klass)->constructor = ft_idle_monitor_constructor;
	G_OBJECT_CLASS (klass)->finalize = ft_idle_monitor_finalize;
}

static void
ft_idle_monitor_instance_init (FtIdleMonitor * self,
                               gpointer klass)
{
	self->priv = ft_idle_monitor_get_instance_private (self);
	self->priv->watches = NULL;
	self->priv->last_activity_time = FT_TIMESTAMP_UNDEFINED;
}

static void
ft_idle_monitor_finalize (GObject * obj)
{
	FtIdleMonitor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FT_TYPE_IDLE_MONITOR, FtIdleMonitor);
	_g_hash_table_unref0 (self->priv->watches);
	G_OBJECT_CLASS (ft_idle_monitor_parent_class)->finalize (obj);
}

static GType
ft_idle_monitor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FtIdleMonitorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ft_idle_monitor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FtIdleMonitor), 0, (GInstanceInitFunc) ft_idle_monitor_instance_init, NULL };
	GType ft_idle_monitor_type_id;
	ft_idle_monitor_type_id = g_type_register_static (FT_TYPE_PROVIDED_OBJECT, "FtIdleMonitor", &g_define_type_info, 0);
	FtIdleMonitor_private_offset = g_type_add_instance_private (ft_idle_monitor_type_id, sizeof (FtIdleMonitorPrivate));
	return ft_idle_monitor_type_id;
}

GType
ft_idle_monitor_get_type (void)
{
	static volatile gsize ft_idle_monitor_type_id__once = 0;
	if (g_once_init_enter (&ft_idle_monitor_type_id__once)) {
		GType ft_idle_monitor_type_id;
		ft_idle_monitor_type_id = ft_idle_monitor_get_type_once ();
		g_once_init_leave (&ft_idle_monitor_type_id__once, ft_idle_monitor_type_id);
	}
	return ft_idle_monitor_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

