/* lock-screen-provider.c generated by valac 0.56.19, the Vala compiler
 * generated from lock-screen-provider.vala, do not modify */

/*
 * Copyright (c) 2024-2025 focus-timer contributors
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include "ft_plugin_freedesktop.h"
#include <glib.h>
#include "ft_core.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  {
	FREEDESKTOP_LOCK_SCREEN_PROVIDER_0_PROPERTY,
	FREEDESKTOP_LOCK_SCREEN_PROVIDER_ACTIVE_PROPERTY,
	FREEDESKTOP_LOCK_SCREEN_PROVIDER_NUM_PROPERTIES
};
static GParamSpec* freedesktop_lock_screen_provider_properties[FREEDESKTOP_LOCK_SCREEN_PROVIDER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _FreedesktopLockScreenProviderInitializeData FreedesktopLockScreenProviderInitializeData;
typedef struct _FreedesktopLockScreenProviderUninitializeData FreedesktopLockScreenProviderUninitializeData;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _FreedesktopLockScreenProviderEnableData FreedesktopLockScreenProviderEnableData;
typedef struct _FreedesktopLockScreenProviderDisableData FreedesktopLockScreenProviderDisableData;

struct _FreedesktopLockScreenProviderPrivate {
	FreedesktopLoginSession* session_proxy;
	gboolean _active;
	guint watcher_id;
	gulong properties_changed_id;
};

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

struct _FreedesktopLockScreenProviderUninitializeData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FreedesktopLockScreenProvider* self;
};

struct _FreedesktopLockScreenProviderEnableData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FreedesktopLockScreenProvider* self;
	GCancellable* cancellable;
	FreedesktopLoginManager* manager_proxy;
	FreedesktopLoginManager* _tmp0_;
	FreedesktopLoginSession* session_auto_proxy;
	FreedesktopLoginSession* _tmp1_;
	FreedesktopSession* login_sessions;
	FreedesktopLoginManager* _tmp2_;
	gint _tmp3_;
	FreedesktopSession* _tmp4_;
	gint login_sessions_length1;
	gint _login_sessions_size_;
	FreedesktopSession* _tmp5_;
	gint _tmp5__length1;
	FreedesktopSession* login_session_collection;
	gint login_session_collection_length1;
	gint _login_session_collection_size_;
	gint login_session_it;
	FreedesktopSession _tmp6_;
	FreedesktopSession _tmp7_;
	FreedesktopSession login_session;
	FreedesktopSession _tmp8_;
	const gchar* _tmp9_;
	FreedesktopLoginSession* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gboolean _tmp14_;
	FreedesktopLoginSession* _tmp15_;
	FreedesktopSession _tmp16_;
	const gchar* _tmp17_;
	FreedesktopLoginSession* _tmp18_;
	FreedesktopLoginSession* _tmp19_;
	FreedesktopLoginSession* _tmp20_;
	FreedesktopLoginSession* _tmp21_;
	FreedesktopLoginSession* _tmp22_;
	GDBusProxy* session_dbus_proxy;
	FreedesktopLoginSession* _tmp23_;
	GDBusProxy* _tmp24_;
	GDBusProxy* _tmp25_;
	gulong _tmp26_;
	GError* _error_;
	GError* _tmp27_;
	const gchar* _tmp28_;
	GError* _inner_error0_;
};

struct _FreedesktopLockScreenProviderDisableData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FreedesktopLockScreenProvider* self;
	FreedesktopLoginSession* _tmp0_;
};

static gint FreedesktopLockScreenProvider_private_offset;
static gpointer freedesktop_lock_screen_provider_parent_class = NULL;
static FtLockScreenProviderIface * freedesktop_lock_screen_provider_ft_lock_screen_provider_parent_iface = NULL;
static GType freedesktop_lock_screen_provider_type_id = 0;

static void freedesktop_lock_screen_provider_update_active (FreedesktopLockScreenProvider* self);
static void freedesktop_lock_screen_provider_on_name_appeared (FreedesktopLockScreenProvider* self,
                                                        GDBusConnection* connection,
                                                        const gchar* name,
                                                        const gchar* name_owner);
static void freedesktop_lock_screen_provider_on_name_vanished (FreedesktopLockScreenProvider* self,
                                                        GDBusConnection* connection,
                                                        const gchar* name);
static void freedesktop_lock_screen_provider_on_properties_changed (FreedesktopLockScreenProvider* self,
                                                             GVariant* changed_properties,
                                                             gchar** invalidated_properties,
                                                             gint invalidated_properties_length1);
static void freedesktop_lock_screen_provider_real_initialize_data_free (gpointer _data);
static void freedesktop_lock_screen_provider_real_initialize (FtProvider* base,
                                                       GCancellable* cancellable,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static gboolean freedesktop_lock_screen_provider_real_initialize_co (FreedesktopLockScreenProviderInitializeData* _data_);
static void _freedesktop_lock_screen_provider_on_name_appeared_gbus_name_appeared_callback (GDBusConnection* connection,
                                                                                     const gchar* name,
                                                                                     const gchar* name_owner,
                                                                                     gpointer self);
static void _freedesktop_lock_screen_provider_on_name_vanished_gbus_name_vanished_callback (GDBusConnection* connection,
                                                                                     const gchar* name,
                                                                                     gpointer self);
static void freedesktop_lock_screen_provider_real_uninitialize_data_free (gpointer _data);
static void freedesktop_lock_screen_provider_real_uninitialize (FtProvider* base,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
static gboolean freedesktop_lock_screen_provider_real_uninitialize_co (FreedesktopLockScreenProviderUninitializeData* _data_);
static void freedesktop_lock_screen_provider_real_enable_data_free (gpointer _data);
static void freedesktop_lock_screen_provider_real_enable (FtProvider* base,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static gboolean freedesktop_lock_screen_provider_real_enable_co (FreedesktopLockScreenProviderEnableData* _data_);
static void freedesktop_lock_screen_provider_enable_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_);
static void _vala_FreedesktopSession_array_free (FreedesktopSession * array,
                                          gssize array_length);
static void _freedesktop_lock_screen_provider_on_properties_changed_g_dbus_proxy_g_properties_changed (GDBusProxy* _sender,
                                                                                                GVariant* changed_properties,
                                                                                                gchar** invalidated_properties,
                                                                                                gpointer self);
static void freedesktop_lock_screen_provider_real_disable_data_free (gpointer _data);
static void freedesktop_lock_screen_provider_real_disable (FtProvider* base,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
static gboolean freedesktop_lock_screen_provider_real_disable_co (FreedesktopLockScreenProviderDisableData* _data_);
static void freedesktop_lock_screen_provider_real_activate (FtLockScreenProvider* base);
static void ___lambda5_ (FreedesktopLockScreenProvider* self,
                  GObject* obj,
                  GAsyncResult* res);
static void ____lambda5__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static void freedesktop_lock_screen_provider_finalize (GObject * obj);
static void _vala_freedesktop_lock_screen_provider_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static gssize _vala_array_length (gpointer array);

static inline gpointer
freedesktop_lock_screen_provider_get_instance_private (FreedesktopLockScreenProvider* self)
{
	return G_STRUCT_MEMBER_P (self, FreedesktopLockScreenProvider_private_offset);
}

static void
freedesktop_lock_screen_provider_update_active (FreedesktopLockScreenProvider* self)
{
	gboolean _tmp0_ = FALSE;
	FreedesktopLoginSession* _tmp1_;
	gboolean active = FALSE;
	g_return_if_fail (self != NULL);
	_tmp1_ = self->priv->session_proxy;
	if (_tmp1_ != NULL) {
		gboolean _tmp2_ = FALSE;
		FreedesktopLoginSession* _tmp3_;
		gboolean _tmp4_;
		gboolean _tmp5_;
		_tmp3_ = self->priv->session_proxy;
		_tmp4_ = freedesktop_login_session_get_active (_tmp3_);
		_tmp5_ = _tmp4_;
		if (!_tmp5_) {
			_tmp2_ = TRUE;
		} else {
			FreedesktopLoginSession* _tmp6_;
			gboolean _tmp7_;
			gboolean _tmp8_;
			_tmp6_ = self->priv->session_proxy;
			_tmp7_ = freedesktop_login_session_get_locked_hint (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp2_ = _tmp8_;
		}
		_tmp0_ = _tmp2_;
	} else {
		_tmp0_ = FALSE;
	}
	active = _tmp0_;
	if (self->priv->_active != active) {
		self->priv->_active = active;
		g_object_notify ((GObject*) self, "active");
	}
}

static void
freedesktop_lock_screen_provider_on_name_appeared (FreedesktopLockScreenProvider* self,
                                                   GDBusConnection* connection,
                                                   const gchar* name,
                                                   const gchar* name_owner)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (connection != NULL);
	g_return_if_fail (name != NULL);
	g_return_if_fail (name_owner != NULL);
	ft_provider_set_available ((FtProvider*) self, TRUE);
}

static void
freedesktop_lock_screen_provider_on_name_vanished (FreedesktopLockScreenProvider* self,
                                                   GDBusConnection* connection,
                                                   const gchar* name)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	ft_provider_set_available ((FtProvider*) self, FALSE);
}

static void
freedesktop_lock_screen_provider_on_properties_changed (FreedesktopLockScreenProvider* self,
                                                        GVariant* changed_properties,
                                                        gchar** invalidated_properties,
                                                        gint invalidated_properties_length1)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (changed_properties != NULL);
	freedesktop_lock_screen_provider_update_active (self);
}

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

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

static void
freedesktop_lock_screen_provider_real_initialize (FtProvider* base,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	FreedesktopLockScreenProvider * self;
	FreedesktopLockScreenProviderInitializeData* _data_;
	FreedesktopLockScreenProvider* _tmp0_;
	GCancellable* _tmp1_;
	self = (FreedesktopLockScreenProvider*) base;
	_data_ = g_slice_new0 (FreedesktopLockScreenProviderInitializeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, freedesktop_lock_screen_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_;
	freedesktop_lock_screen_provider_real_initialize_co (_data_);
}

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

static void
_freedesktop_lock_screen_provider_on_name_appeared_gbus_name_appeared_callback (GDBusConnection* connection,
                                                                                const gchar* name,
                                                                                const gchar* name_owner,
                                                                                gpointer self)
{
	freedesktop_lock_screen_provider_on_name_appeared ((FreedesktopLockScreenProvider*) self, connection, name, name_owner);
}

static void
_freedesktop_lock_screen_provider_on_name_vanished_gbus_name_vanished_callback (GDBusConnection* connection,
                                                                                const gchar* name,
                                                                                gpointer self)
{
	freedesktop_lock_screen_provider_on_name_vanished ((FreedesktopLockScreenProvider*) self, connection, name);
}

static gboolean
freedesktop_lock_screen_provider_real_initialize_co (FreedesktopLockScreenProviderInitializeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->self->priv->watcher_id = g_bus_watch_name_with_closures (G_BUS_TYPE_SYSTEM, "org.freedesktop.login1", G_BUS_NAME_WATCHER_FLAGS_NONE, (GClosure*) ((_freedesktop_lock_screen_provider_on_name_appeared_gbus_name_appeared_callback == NULL) ? NULL : g_cclosure_new ((GCallback) _freedesktop_lock_screen_provider_on_name_appeared_gbus_name_appeared_callback, g_object_ref (_data_->self), (GClosureNotify) g_object_unref)), (GClosure*) ((_freedesktop_lock_screen_provider_on_name_vanished_gbus_name_vanished_callback == NULL) ? NULL : g_cclosure_new ((GCallback) _freedesktop_lock_screen_provider_on_name_vanished_gbus_name_vanished_callback, g_object_ref (_data_->self), (GClosureNotify) g_object_unref)));
	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
freedesktop_lock_screen_provider_real_uninitialize_data_free (gpointer _data)
{
	FreedesktopLockScreenProviderUninitializeData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FreedesktopLockScreenProviderUninitializeData, _data_);
}

static void
freedesktop_lock_screen_provider_real_uninitialize (FtProvider* base,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	FreedesktopLockScreenProvider * self;
	FreedesktopLockScreenProviderUninitializeData* _data_;
	FreedesktopLockScreenProvider* _tmp0_;
	self = (FreedesktopLockScreenProvider*) base;
	_data_ = g_slice_new0 (FreedesktopLockScreenProviderUninitializeData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, freedesktop_lock_screen_provider_real_uninitialize_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	freedesktop_lock_screen_provider_real_uninitialize_co (_data_);
}

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

static gboolean
freedesktop_lock_screen_provider_real_uninitialize_co (FreedesktopLockScreenProviderUninitializeData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->watcher_id != ((guint) 0)) {
		g_bus_unwatch_name (_data_->self->priv->watcher_id);
		_data_->self->priv->watcher_id = (guint) 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
freedesktop_lock_screen_provider_real_enable_data_free (gpointer _data)
{
	FreedesktopLockScreenProviderEnableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (FreedesktopLockScreenProviderEnableData, _data_);
}

static void
freedesktop_lock_screen_provider_real_enable (FtProvider* base,
                                              GCancellable* cancellable,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	FreedesktopLockScreenProvider * self;
	FreedesktopLockScreenProviderEnableData* _data_;
	FreedesktopLockScreenProvider* _tmp0_;
	GCancellable* _tmp1_;
	self = (FreedesktopLockScreenProvider*) base;
	_data_ = g_slice_new0 (FreedesktopLockScreenProviderEnableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, freedesktop_lock_screen_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_;
	freedesktop_lock_screen_provider_real_enable_co (_data_);
}

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

static void
freedesktop_lock_screen_provider_enable_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_)
{
	FreedesktopLockScreenProviderEnableData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	freedesktop_lock_screen_provider_real_enable_co (_data_);
}

static void
_vala_FreedesktopSession_array_free (FreedesktopSession * array,
                                     gssize array_length)
{
	if (array != NULL) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			freedesktop_session_destroy (&array[i]);
		}
	}
	g_free (array);
}

static void
_freedesktop_lock_screen_provider_on_properties_changed_g_dbus_proxy_g_properties_changed (GDBusProxy* _sender,
                                                                                           GVariant* changed_properties,
                                                                                           gchar** invalidated_properties,
                                                                                           gpointer self)
{
	freedesktop_lock_screen_provider_on_properties_changed ((FreedesktopLockScreenProvider*) self, changed_properties, invalidated_properties, _vala_array_length (invalidated_properties));
}

static gboolean
freedesktop_lock_screen_provider_real_enable_co (FreedesktopLockScreenProviderEnableData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_state_ = 1;
		g_async_initable_new_async (FREEDESKTOP_TYPE_LOGIN_MANAGER_PROXY, 0, _data_->cancellable, freedesktop_lock_screen_provider_enable_ready, _data_, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, "g-name", "org.freedesktop.login1", "g-bus-type", G_BUS_TYPE_SYSTEM, "g-object-path", "/org/freedesktop/login1", "g-interface-name", "org.freedesktop.login1.Manager", NULL);
		return FALSE;
		_state_1:
		_data_->_tmp0_ = (FreedesktopLoginManager*) g_async_initable_new_finish ((GAsyncInitable *) _data_->_source_object_, _data_->_res_, &_data_->_inner_error0_);
		_data_->manager_proxy = (FreedesktopLoginManager*) _data_->_tmp0_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_state_ = 2;
		g_async_initable_new_async (FREEDESKTOP_TYPE_LOGIN_SESSION_PROXY, 0, _data_->cancellable, freedesktop_lock_screen_provider_enable_ready, _data_, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, "g-name", "org.freedesktop.login1", "g-bus-type", G_BUS_TYPE_SYSTEM, "g-object-path", "/org/freedesktop/login1/session/auto", "g-interface-name", "org.freedesktop.login1.Session", NULL);
		return FALSE;
		_state_2:
		_data_->_tmp1_ = (FreedesktopLoginSession*) g_async_initable_new_finish ((GAsyncInitable *) _data_->_source_object_, _data_->_res_, &_data_->_inner_error0_);
		_data_->session_auto_proxy = (FreedesktopLoginSession*) _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->manager_proxy);
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->manager_proxy;
		_data_->_tmp3_ = 0;
		_data_->_state_ = 3;
		freedesktop_login_manager_list_sessions (_data_->_tmp2_, freedesktop_lock_screen_provider_enable_ready, _data_);
		return FALSE;
		_state_3:
		_data_->_tmp4_ = freedesktop_login_manager_list_sessions_finish (_data_->_tmp2_, _data_->_res_, &_data_->_tmp3_, &_data_->_inner_error0_);
		_data_->login_sessions = _data_->_tmp4_;
		_data_->login_sessions_length1 = _data_->_tmp3_;
		_data_->_login_sessions_size_ = _data_->login_sessions_length1;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->session_auto_proxy);
			_g_object_unref0 (_data_->manager_proxy);
			goto __catch0_g_error;
		}
		_data_->_tmp5_ = _data_->login_sessions;
		_data_->_tmp5__length1 = _data_->login_sessions_length1;
		{
			_data_->login_session_collection_length1 = 0;
			_data_->_login_session_collection_size_ = 0;
			_data_->login_session_collection = _data_->_tmp5_;
			_data_->login_session_collection_length1 = _data_->_tmp5__length1;
			for (_data_->login_session_it = 0; _data_->login_session_it < _data_->login_session_collection_length1; _data_->login_session_it = _data_->login_session_it + 1) {
				_data_->_tmp6_ = _data_->login_session_collection[_data_->login_session_it];
				memset (&_data_->_tmp7_, 0, sizeof (FreedesktopSession));
				freedesktop_session_copy (&_data_->_tmp6_, &_data_->_tmp7_);
				_data_->login_session = _data_->_tmp7_;
				{
					_data_->_tmp8_ = _data_->login_session;
					_data_->_tmp9_ = _data_->_tmp8_.session_id;
					_data_->_tmp10_ = _data_->session_auto_proxy;
					_data_->_tmp11_ = freedesktop_login_session_get_id (_data_->_tmp10_);
					_data_->_tmp12_ = _data_->_tmp11_;
					_data_->_tmp13_ = _data_->_tmp12_;
					_data_->_tmp14_ = g_strcmp0 (_data_->_tmp9_, _data_->_tmp13_) == 0;
					_g_free0 (_data_->_tmp13_);
					if (_data_->_tmp14_) {
						_data_->_tmp16_ = _data_->login_session;
						_data_->_tmp17_ = _data_->_tmp16_.object_path;
						_data_->_state_ = 4;
						g_async_initable_new_async (FREEDESKTOP_TYPE_LOGIN_SESSION_PROXY, 0, _data_->cancellable, freedesktop_lock_screen_provider_enable_ready, _data_, "g-flags", G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START | G_DBUS_PROXY_FLAGS_DO_NOT_CONNECT_SIGNALS, "g-name", "org.freedesktop.login1", "g-bus-type", G_BUS_TYPE_SYSTEM, "g-object-path", _data_->_tmp17_, "g-interface-name", "org.freedesktop.login1.Session", NULL);
						return FALSE;
						_state_4:
						_data_->_tmp18_ = (FreedesktopLoginSession*) g_async_initable_new_finish ((GAsyncInitable *) _data_->_source_object_, _data_->_res_, &_data_->_inner_error0_);
						_data_->_tmp15_ = (FreedesktopLoginSession*) _data_->_tmp18_;
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							freedesktop_session_destroy (&_data_->login_session);
							_data_->login_sessions = (_vala_FreedesktopSession_array_free (_data_->login_sessions, _data_->login_sessions_length1), NULL);
							_g_object_unref0 (_data_->session_auto_proxy);
							_g_object_unref0 (_data_->manager_proxy);
							goto __catch0_g_error;
						}
						_data_->_tmp19_ = _data_->_tmp15_;
						_data_->_tmp15_ = NULL;
						_g_object_unref0 (_data_->self->priv->session_proxy);
						_data_->self->priv->session_proxy = _data_->_tmp19_;
						_g_object_unref0 (_data_->_tmp15_);
						freedesktop_session_destroy (&_data_->login_session);
						break;
					}
					freedesktop_session_destroy (&_data_->login_session);
				}
			}
		}
		_data_->_tmp20_ = _data_->self->priv->session_proxy;
		if (_data_->_tmp20_ == NULL) {
			g_warning ("lock-screen-provider.vala:104: Can't connect to current login session." \
" Lock-screen detection will not work.");
			_data_->_tmp21_ = _data_->session_auto_proxy;
			_data_->_tmp22_ = _g_object_ref0 (_data_->_tmp21_);
			_g_object_unref0 (_data_->self->priv->session_proxy);
			_data_->self->priv->session_proxy = _data_->_tmp22_;
		}
		_data_->_tmp23_ = _data_->self->priv->session_proxy;
		_data_->_tmp24_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp23_, g_dbus_proxy_get_type (), GDBusProxy));
		_data_->session_dbus_proxy = _data_->_tmp24_;
		_data_->_tmp25_ = _data_->session_dbus_proxy;
		_data_->_tmp26_ = g_signal_connect_object (_data_->_tmp25_, "g-properties-changed", (GCallback) _freedesktop_lock_screen_provider_on_properties_changed_g_dbus_proxy_g_properties_changed, _data_->self, 0);
		_data_->self->priv->properties_changed_id = _data_->_tmp26_;
		freedesktop_lock_screen_provider_update_active (_data_->self);
		_g_object_unref0 (_data_->session_dbus_proxy);
		_data_->login_sessions = (_vala_FreedesktopSession_array_free (_data_->login_sessions, _data_->login_sessions_length1), NULL);
		_g_object_unref0 (_data_->session_auto_proxy);
		_g_object_unref0 (_data_->manager_proxy);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp27_ = _data_->_error_;
		_data_->_tmp28_ = _data_->_tmp27_->message;
		g_warning ("lock-screen-provider.vala:116: Error while initializing session proxy:" \
" %s", _data_->_tmp28_);
		_g_error_free0 (_data_->_error_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return 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
freedesktop_lock_screen_provider_real_disable_data_free (gpointer _data)
{
	FreedesktopLockScreenProviderDisableData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FreedesktopLockScreenProviderDisableData, _data_);
}

static void
freedesktop_lock_screen_provider_real_disable (FtProvider* base,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	FreedesktopLockScreenProvider * self;
	FreedesktopLockScreenProviderDisableData* _data_;
	FreedesktopLockScreenProvider* _tmp0_;
	self = (FreedesktopLockScreenProvider*) base;
	_data_ = g_slice_new0 (FreedesktopLockScreenProviderDisableData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, freedesktop_lock_screen_provider_real_disable_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	freedesktop_lock_screen_provider_real_disable_co (_data_);
}

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

static gboolean
freedesktop_lock_screen_provider_real_disable_co (FreedesktopLockScreenProviderDisableData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->properties_changed_id != ((gulong) 0)) {
		_data_->_tmp0_ = _data_->self->priv->session_proxy;
		g_signal_handler_disconnect ((GObject*) _data_->_tmp0_, _data_->self->priv->properties_changed_id);
		_data_->self->priv->properties_changed_id = (gulong) 0;
	}
	_g_object_unref0 (_data_->self->priv->session_proxy);
	_data_->self->priv->session_proxy = NULL;
	freedesktop_lock_screen_provider_update_active (_data_->self);
	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
___lambda5_ (FreedesktopLockScreenProvider* self,
             GObject* obj,
             GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (res != NULL);
	{
		FreedesktopLoginSession* _tmp0_;
		_tmp0_ = self->priv->session_proxy;
		freedesktop_login_session_lock_finish (_tmp0_, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = _error_;
		_tmp2_ = _tmp1_->message;
		g_warning ("lock-screen-provider.vala:141: Error while locking the screen: %s", _tmp2_);
		_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
____lambda5__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	___lambda5_ ((FreedesktopLockScreenProvider*) self, source_object, res);
	g_object_unref (self);
}

static void
freedesktop_lock_screen_provider_real_activate (FtLockScreenProvider* base)
{
	FreedesktopLockScreenProvider * self;
	FreedesktopLoginSession* _tmp0_;
	self = (FreedesktopLockScreenProvider*) base;
	_tmp0_ = self->priv->session_proxy;
	if (_tmp0_ != NULL) {
		FreedesktopLoginSession* _tmp1_;
		_tmp1_ = self->priv->session_proxy;
		freedesktop_login_session_lock (_tmp1_, ____lambda5__gasync_ready_callback, g_object_ref (self));
	} else {
		g_warning ("lock-screen-provider.vala:146: Unable to activate lock-screen.");
	}
}

FreedesktopLockScreenProvider*
freedesktop_lock_screen_provider_construct (GType object_type)
{
	FreedesktopLockScreenProvider * self = NULL;
	self = (FreedesktopLockScreenProvider*) ft_provider_construct (object_type);
	return self;
}

FreedesktopLockScreenProvider*
freedesktop_lock_screen_provider_new (void)
{
	return freedesktop_lock_screen_provider_construct (FREEDESKTOP_TYPE_LOCK_SCREEN_PROVIDER);
}

static gboolean
freedesktop_lock_screen_provider_real_get_active (FtLockScreenProvider* base)
{
	gboolean result;
	FreedesktopLockScreenProvider* self;
	self = (FreedesktopLockScreenProvider*) base;
	result = self->priv->_active;
	return result;
}

static void
freedesktop_lock_screen_provider_class_init (FreedesktopLockScreenProviderClass * klass,
                                             gpointer klass_data)
{
	freedesktop_lock_screen_provider_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &FreedesktopLockScreenProvider_private_offset);
	((FtProviderClass *) klass)->initialize = (void (*) (FtProvider*, GCancellable*, GAsyncReadyCallback, gpointer)) freedesktop_lock_screen_provider_real_initialize;
	((FtProviderClass *) klass)->initialize_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) freedesktop_lock_screen_provider_initialize_finish;
	((FtProviderClass *) klass)->uninitialize = (void (*) (FtProvider*, GAsyncReadyCallback, gpointer)) freedesktop_lock_screen_provider_real_uninitialize;
	((FtProviderClass *) klass)->uninitialize_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) freedesktop_lock_screen_provider_uninitialize_finish;
	((FtProviderClass *) klass)->enable = (void (*) (FtProvider*, GCancellable*, GAsyncReadyCallback, gpointer)) freedesktop_lock_screen_provider_real_enable;
	((FtProviderClass *) klass)->enable_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) freedesktop_lock_screen_provider_enable_finish;
	((FtProviderClass *) klass)->disable = (void (*) (FtProvider*, GAsyncReadyCallback, gpointer)) freedesktop_lock_screen_provider_real_disable;
	((FtProviderClass *) klass)->disable_finish = (void (*) (FtProvider*, GAsyncResult*, GError**)) freedesktop_lock_screen_provider_disable_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_freedesktop_lock_screen_provider_get_property;
	G_OBJECT_CLASS (klass)->finalize = freedesktop_lock_screen_provider_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), FREEDESKTOP_LOCK_SCREEN_PROVIDER_ACTIVE_PROPERTY, freedesktop_lock_screen_provider_properties[FREEDESKTOP_LOCK_SCREEN_PROVIDER_ACTIVE_PROPERTY] = g_param_spec_boolean ("active", "active", "active", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
freedesktop_lock_screen_provider_ft_lock_screen_provider_interface_init (FtLockScreenProviderIface * iface,
                                                                         gpointer iface_data)
{
	freedesktop_lock_screen_provider_ft_lock_screen_provider_parent_iface = g_type_interface_peek_parent (iface);
	iface->activate = (void (*) (FtLockScreenProvider*)) freedesktop_lock_screen_provider_real_activate;
	iface->get_active = freedesktop_lock_screen_provider_real_get_active;
}

static void
freedesktop_lock_screen_provider_instance_init (FreedesktopLockScreenProvider * self,
                                                gpointer klass)
{
	self->priv = freedesktop_lock_screen_provider_get_instance_private (self);
	self->priv->session_proxy = NULL;
	self->priv->_active = FALSE;
	self->priv->watcher_id = (guint) 0;
	self->priv->properties_changed_id = (gulong) 0;
}

static void
freedesktop_lock_screen_provider_finalize (GObject * obj)
{
	FreedesktopLockScreenProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FREEDESKTOP_TYPE_LOCK_SCREEN_PROVIDER, FreedesktopLockScreenProvider);
	_g_object_unref0 (self->priv->session_proxy);
	G_OBJECT_CLASS (freedesktop_lock_screen_provider_parent_class)->finalize (obj);
}

GType
freedesktop_lock_screen_provider_get_type (void)
{
	return freedesktop_lock_screen_provider_type_id;
}

GType
freedesktop_lock_screen_provider_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (FreedesktopLockScreenProviderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) freedesktop_lock_screen_provider_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FreedesktopLockScreenProvider), 0, (GInstanceInitFunc) freedesktop_lock_screen_provider_instance_init, NULL };
	static const GInterfaceInfo ft_lock_screen_provider_info = { (GInterfaceInitFunc) freedesktop_lock_screen_provider_ft_lock_screen_provider_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	freedesktop_lock_screen_provider_type_id = g_type_module_register_type (module, FT_TYPE_PROVIDER, "FreedesktopLockScreenProvider", &g_define_type_info, 0);
	g_type_module_add_interface (module, freedesktop_lock_screen_provider_type_id, FT_TYPE_LOCK_SCREEN_PROVIDER, &ft_lock_screen_provider_info);
	FreedesktopLockScreenProvider_private_offset = sizeof (FreedesktopLockScreenProviderPrivate);
	return freedesktop_lock_screen_provider_type_id;
}

static void
_vala_freedesktop_lock_screen_provider_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	FreedesktopLockScreenProvider * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, FREEDESKTOP_TYPE_LOCK_SCREEN_PROVIDER, FreedesktopLockScreenProvider);
	switch (property_id) {
		case FREEDESKTOP_LOCK_SCREEN_PROVIDER_ACTIVE_PROPERTY:
		g_value_set_boolean (value, ft_lock_screen_provider_get_active ((FtLockScreenProvider*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

