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

/*
 * SPDX-License-Identifier: GPL-3.0-or-later
 * SPDX-FileCopyrightText: 2020, 2025 elementary, Inc. (https://elementary.io)
 */

#include <glib-object.h>
#include <gio/gio.h>
#include <clutter/clutter.h>
#include <glib.h>
#include <math.h>
#include <float.h>
#include <string.h>

#define GALA_SESSION_LOCKER_LONG_ANIMATION_TIME ((guint) 3000)
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GALA_TYPE_SCREEN_SAVER_MANAGER (gala_screen_saver_manager_get_type ())
#define GALA_SCREEN_SAVER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_SCREEN_SAVER_MANAGER, GalaScreenSaverManager))
#define GALA_SCREEN_SAVER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_SCREEN_SAVER_MANAGER, GalaScreenSaverManagerClass))
#define GALA_IS_SCREEN_SAVER_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_SCREEN_SAVER_MANAGER))
#define GALA_IS_SCREEN_SAVER_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_SCREEN_SAVER_MANAGER))
#define GALA_SCREEN_SAVER_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_SCREEN_SAVER_MANAGER, GalaScreenSaverManagerClass))

typedef struct _GalaScreenSaverManager GalaScreenSaverManager;
typedef struct _GalaScreenSaverManagerClass GalaScreenSaverManagerClass;
typedef struct _GalaScreenSaverManagerPrivate GalaScreenSaverManagerPrivate;

#define GALA_TYPE_SESSION_LOCKER (gala_session_locker_get_type ())
#define GALA_SESSION_LOCKER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_SESSION_LOCKER, GalaSessionLocker))
#define GALA_SESSION_LOCKER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_SESSION_LOCKER, GalaSessionLockerClass))
#define GALA_IS_SESSION_LOCKER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_SESSION_LOCKER))
#define GALA_IS_SESSION_LOCKER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_SESSION_LOCKER))
#define GALA_SESSION_LOCKER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_SESSION_LOCKER, GalaSessionLockerClass))

typedef struct _GalaSessionLocker GalaSessionLocker;
typedef struct _GalaSessionLockerClass GalaSessionLockerClass;
enum  {
	GALA_SCREEN_SAVER_MANAGER_0_PROPERTY,
	GALA_SCREEN_SAVER_MANAGER_SESSION_LOCKER_PROPERTY,
	GALA_SCREEN_SAVER_MANAGER_NUM_PROPERTIES
};
static GParamSpec* gala_screen_saver_manager_properties[GALA_SCREEN_SAVER_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	GALA_SCREEN_SAVER_MANAGER_ACTIVE_CHANGED_SIGNAL,
	GALA_SCREEN_SAVER_MANAGER_NUM_SIGNALS
};
static guint gala_screen_saver_manager_signals[GALA_SCREEN_SAVER_MANAGER_NUM_SIGNALS] = {0};

struct _GalaScreenSaverManager {
	GObject parent_instance;
	GalaScreenSaverManagerPrivate * priv;
};

struct _GalaScreenSaverManagerClass {
	GObjectClass parent_class;
};

struct _GalaScreenSaverManagerPrivate {
	GalaSessionLocker* _session_locker;
};

static gint GalaScreenSaverManager_private_offset;
static gpointer gala_screen_saver_manager_parent_class = NULL;

VALA_EXTERN GType gala_screen_saver_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaScreenSaverManager, g_object_unref)
VALA_EXTERN guint gala_screen_saver_manager_register_object (void* object,
                                                 GDBusConnection* connection,
                                                 const gchar* path,
                                                 GError** error);
VALA_EXTERN GType gala_session_locker_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaSessionLocker, g_object_unref)
VALA_EXTERN GalaScreenSaverManager* gala_screen_saver_manager_new (GalaSessionLocker* session_locker);
VALA_EXTERN GalaScreenSaverManager* gala_screen_saver_manager_construct (GType object_type,
                                                             GalaSessionLocker* session_locker);
VALA_EXTERN void gala_screen_saver_manager_lock (GalaScreenSaverManager* self,
                                     GError** error);
VALA_EXTERN GalaSessionLocker* gala_screen_saver_manager_get_session_locker (GalaScreenSaverManager* self);
VALA_EXTERN void gala_session_locker_lock (GalaSessionLocker* self,
                               gboolean animate);
VALA_EXTERN gboolean gala_screen_saver_manager_get_active (GalaScreenSaverManager* self,
                                               GError** error);
VALA_EXTERN gboolean gala_session_locker_get_active (GalaSessionLocker* self);
VALA_EXTERN void gala_screen_saver_manager_set_active (GalaScreenSaverManager* self,
                                           gboolean active,
                                           GError** error);
VALA_EXTERN void gala_session_locker_activate (GalaSessionLocker* self,
                                   gboolean animate,
                                   guint animation_time);
VALA_EXTERN void gala_session_locker_deactivate (GalaSessionLocker* self,
                                     gboolean animate);
VALA_EXTERN guint gala_screen_saver_manager_get_active_time (GalaScreenSaverManager* self,
                                                 GError** error);
VALA_EXTERN gint64 gala_session_locker_get_activation_time (GalaSessionLocker* self);
static void gala_screen_saver_manager_set_session_locker (GalaScreenSaverManager* self,
                                                   GalaSessionLocker* value);
static GObject * gala_screen_saver_manager_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void _gala_screen_saver_manager___lambda81_ (GalaScreenSaverManager* self);
static void __gala_screen_saver_manager___lambda81__gala_session_locker_active_changed (GalaSessionLocker* _sender,
                                                                                 gpointer self);
static void gala_screen_saver_manager_finalize (GObject * obj);
static GType gala_screen_saver_manager_get_type_once (void);
static void _vala_gala_screen_saver_manager_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_gala_screen_saver_manager_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);
static void _dbus_gala_screen_saver_manager_lock (GalaScreenSaverManager* self,
                                           GVariant* _parameters_,
                                           GDBusMethodInvocation* invocation);
static void _dbus_gala_screen_saver_manager_get_active (GalaScreenSaverManager* self,
                                                 GVariant* _parameters_,
                                                 GDBusMethodInvocation* invocation);
static void _dbus_gala_screen_saver_manager_set_active (GalaScreenSaverManager* self,
                                                 GVariant* _parameters_,
                                                 GDBusMethodInvocation* invocation);
static void _dbus_gala_screen_saver_manager_get_active_time (GalaScreenSaverManager* self,
                                                      GVariant* _parameters_,
                                                      GDBusMethodInvocation* invocation);
static void gala_screen_saver_manager_dbus_interface_method_call (GDBusConnection* connection,
                                                           const gchar* sender,
                                                           const gchar* object_path,
                                                           const gchar* interface_name,
                                                           const gchar* method_name,
                                                           GVariant* parameters,
                                                           GDBusMethodInvocation* invocation,
                                                           gpointer user_data);
static GVariant* gala_screen_saver_manager_dbus_interface_get_property (GDBusConnection* connection,
                                                                 const gchar* sender,
                                                                 const gchar* object_path,
                                                                 const gchar* interface_name,
                                                                 const gchar* property_name,
                                                                 GError** error,
                                                                 gpointer user_data);
static gboolean gala_screen_saver_manager_dbus_interface_set_property (GDBusConnection* connection,
                                                                const gchar* sender,
                                                                const gchar* object_path,
                                                                const gchar* interface_name,
                                                                const gchar* property_name,
                                                                GVariant* value,
                                                                GError** error,
                                                                gpointer user_data);
static void _dbus_gala_screen_saver_manager_active_changed (GObject* _sender,
                                                     gboolean new_value,
                                                     gpointer* _data);
static void _gala_screen_saver_manager_unregister_object (gpointer user_data);

static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_lock_in[] = {NULL};
static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_lock_out[] = {NULL};
static const GDBusMethodInfo _gala_screen_saver_manager_dbus_method_info_lock = {-1, "Lock", (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_lock_in), (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_lock_out), NULL};
static const GDBusArgInfo _gala_screen_saver_manager_dbus_arg_info_get_active_result = {-1, "result", "b", NULL};
static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_get_active_in[] = {NULL};
static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_get_active_out[] = {&_gala_screen_saver_manager_dbus_arg_info_get_active_result, NULL};
static const GDBusMethodInfo _gala_screen_saver_manager_dbus_method_info_get_active = {-1, "GetActive", (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_get_active_in), (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_get_active_out), NULL};
static const GDBusArgInfo _gala_screen_saver_manager_dbus_arg_info_set_active_active = {-1, "active", "b", NULL};
static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_set_active_in[] = {&_gala_screen_saver_manager_dbus_arg_info_set_active_active, NULL};
static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_set_active_out[] = {NULL};
static const GDBusMethodInfo _gala_screen_saver_manager_dbus_method_info_set_active = {-1, "SetActive", (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_set_active_in), (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_set_active_out), NULL};
static const GDBusArgInfo _gala_screen_saver_manager_dbus_arg_info_get_active_time_result = {-1, "result", "u", NULL};
static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_get_active_time_in[] = {NULL};
static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_get_active_time_out[] = {&_gala_screen_saver_manager_dbus_arg_info_get_active_time_result, NULL};
static const GDBusMethodInfo _gala_screen_saver_manager_dbus_method_info_get_active_time = {-1, "GetActiveTime", (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_get_active_time_in), (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_get_active_time_out), NULL};
static const GDBusMethodInfo * const _gala_screen_saver_manager_dbus_method_info[] = {&_gala_screen_saver_manager_dbus_method_info_lock, &_gala_screen_saver_manager_dbus_method_info_get_active, &_gala_screen_saver_manager_dbus_method_info_set_active, &_gala_screen_saver_manager_dbus_method_info_get_active_time, NULL};
static const GDBusArgInfo _gala_screen_saver_manager_dbus_arg_info_active_changed_new_value = {-1, "new_value", "b", NULL};
static const GDBusArgInfo * const _gala_screen_saver_manager_dbus_arg_info_active_changed[] = {&_gala_screen_saver_manager_dbus_arg_info_active_changed_new_value, NULL};
static const GDBusSignalInfo _gala_screen_saver_manager_dbus_signal_info_active_changed = {-1, "ActiveChanged", (GDBusArgInfo **) (&_gala_screen_saver_manager_dbus_arg_info_active_changed), NULL};
static const GDBusSignalInfo * const _gala_screen_saver_manager_dbus_signal_info[] = {&_gala_screen_saver_manager_dbus_signal_info_active_changed, NULL};
static const GDBusPropertyInfo * const _gala_screen_saver_manager_dbus_property_info[] = {NULL};
static const GDBusInterfaceInfo _gala_screen_saver_manager_dbus_interface_info = {-1, "org.gnome.ScreenSaver", (GDBusMethodInfo **) (&_gala_screen_saver_manager_dbus_method_info), (GDBusSignalInfo **) (&_gala_screen_saver_manager_dbus_signal_info), (GDBusPropertyInfo **) (&_gala_screen_saver_manager_dbus_property_info), NULL};
static const GDBusInterfaceVTable _gala_screen_saver_manager_dbus_interface_vtable = {gala_screen_saver_manager_dbus_interface_method_call, gala_screen_saver_manager_dbus_interface_get_property, gala_screen_saver_manager_dbus_interface_set_property};

static inline gpointer
gala_screen_saver_manager_get_instance_private (GalaScreenSaverManager* self)
{
	return G_STRUCT_MEMBER_P (self, GalaScreenSaverManager_private_offset);
}

GalaScreenSaverManager*
gala_screen_saver_manager_construct (GType object_type,
                                     GalaSessionLocker* session_locker)
{
	GalaScreenSaverManager * self = NULL;
	g_return_val_if_fail (session_locker != NULL, NULL);
	self = (GalaScreenSaverManager*) g_object_new (object_type, "session-locker", session_locker, NULL);
	return self;
}

GalaScreenSaverManager*
gala_screen_saver_manager_new (GalaSessionLocker* session_locker)
{
	return gala_screen_saver_manager_construct (GALA_TYPE_SCREEN_SAVER_MANAGER, session_locker);
}

void
gala_screen_saver_manager_lock (GalaScreenSaverManager* self,
                                GError** error)
{
	GalaSessionLocker* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_session_locker;
	gala_session_locker_lock (_tmp0_, TRUE);
}

gboolean
gala_screen_saver_manager_get_active (GalaScreenSaverManager* self,
                                      GError** error)
{
	GalaSessionLocker* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_session_locker;
	_tmp1_ = gala_session_locker_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

void
gala_screen_saver_manager_set_active (GalaScreenSaverManager* self,
                                      gboolean active,
                                      GError** error)
{
	g_return_if_fail (self != NULL);
	if (active) {
		GalaSessionLocker* _tmp0_;
		_tmp0_ = self->priv->_session_locker;
		gala_session_locker_activate (_tmp0_, TRUE, GALA_SESSION_LOCKER_LONG_ANIMATION_TIME);
	} else {
		GalaSessionLocker* _tmp1_;
		_tmp1_ = self->priv->_session_locker;
		gala_session_locker_deactivate (_tmp1_, FALSE);
	}
}

guint
gala_screen_saver_manager_get_active_time (GalaScreenSaverManager* self,
                                           GError** error)
{
	gint64 started = 0LL;
	GalaSessionLocker* _tmp0_;
	gint64 _tmp1_;
	gint64 _tmp2_;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->_session_locker;
	_tmp1_ = gala_session_locker_get_activation_time (_tmp0_);
	_tmp2_ = _tmp1_;
	started = _tmp2_;
	if (started > ((gint64) 0)) {
		result = (guint) floor ((gdouble) ((g_get_monotonic_time () - started) / 1000000));
		return result;
	} else {
		result = (guint) 0;
		return result;
	}
}

GalaSessionLocker*
gala_screen_saver_manager_get_session_locker (GalaScreenSaverManager* self)
{
	GalaSessionLocker* result;
	GalaSessionLocker* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_session_locker;
	result = _tmp0_;
	return result;
}

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

static void
gala_screen_saver_manager_set_session_locker (GalaScreenSaverManager* self,
                                              GalaSessionLocker* value)
{
	GalaSessionLocker* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_screen_saver_manager_get_session_locker (self);
	if (old_value != value) {
		GalaSessionLocker* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_session_locker);
		self->priv->_session_locker = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_screen_saver_manager_properties[GALA_SCREEN_SAVER_MANAGER_SESSION_LOCKER_PROPERTY]);
	}
}

static void
_gala_screen_saver_manager___lambda81_ (GalaScreenSaverManager* self)
{
	GalaSessionLocker* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->_session_locker;
	_tmp1_ = gala_session_locker_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	g_signal_emit (self, gala_screen_saver_manager_signals[GALA_SCREEN_SAVER_MANAGER_ACTIVE_CHANGED_SIGNAL], 0, _tmp2_);
}

static void
__gala_screen_saver_manager___lambda81__gala_session_locker_active_changed (GalaSessionLocker* _sender,
                                                                            gpointer self)
{
	_gala_screen_saver_manager___lambda81_ ((GalaScreenSaverManager*) self);
}

static GObject *
gala_screen_saver_manager_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaScreenSaverManager * self;
	GalaSessionLocker* _tmp0_;
	parent_class = G_OBJECT_CLASS (gala_screen_saver_manager_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_SCREEN_SAVER_MANAGER, GalaScreenSaverManager);
	_tmp0_ = self->priv->_session_locker;
	g_signal_connect_object (_tmp0_, "active-changed", (GCallback) __gala_screen_saver_manager___lambda81__gala_session_locker_active_changed, self, 0);
	return obj;
}

static void
gala_screen_saver_manager_class_init (GalaScreenSaverManagerClass * klass,
                                      gpointer klass_data)
{
	gala_screen_saver_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaScreenSaverManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_screen_saver_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_screen_saver_manager_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_screen_saver_manager_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_screen_saver_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_SCREEN_SAVER_MANAGER_SESSION_LOCKER_PROPERTY, gala_screen_saver_manager_properties[GALA_SCREEN_SAVER_MANAGER_SESSION_LOCKER_PROPERTY] = g_param_spec_object ("session-locker", "session-locker", "session-locker", GALA_TYPE_SESSION_LOCKER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	gala_screen_saver_manager_signals[GALA_SCREEN_SAVER_MANAGER_ACTIVE_CHANGED_SIGNAL] = g_signal_new ("active-changed", GALA_TYPE_SCREEN_SAVER_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
}

static void
gala_screen_saver_manager_instance_init (GalaScreenSaverManager * self,
                                         gpointer klass)
{
	self->priv = gala_screen_saver_manager_get_instance_private (self);
}

static void
gala_screen_saver_manager_finalize (GObject * obj)
{
	GalaScreenSaverManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_SCREEN_SAVER_MANAGER, GalaScreenSaverManager);
	_g_object_unref0 (self->priv->_session_locker);
	G_OBJECT_CLASS (gala_screen_saver_manager_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_screen_saver_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaScreenSaverManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_screen_saver_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaScreenSaverManager), 0, (GInstanceInitFunc) gala_screen_saver_manager_instance_init, NULL };
	GType gala_screen_saver_manager_type_id;
	gala_screen_saver_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaScreenSaverManager", &g_define_type_info, 0);
	g_type_set_qdata (gala_screen_saver_manager_type_id, g_quark_from_static_string ("vala-dbus-register-object"), (void*) gala_screen_saver_manager_register_object);
	GalaScreenSaverManager_private_offset = g_type_add_instance_private (gala_screen_saver_manager_type_id, sizeof (GalaScreenSaverManagerPrivate));
	return gala_screen_saver_manager_type_id;
}

GType
gala_screen_saver_manager_get_type (void)
{
	static gsize gala_screen_saver_manager_type_id__once = 0;
	if (g_once_init_enter (&gala_screen_saver_manager_type_id__once)) {
		GType gala_screen_saver_manager_type_id;
		gala_screen_saver_manager_type_id = gala_screen_saver_manager_get_type_once ();
		g_once_init_leave (&gala_screen_saver_manager_type_id__once, gala_screen_saver_manager_type_id);
	}
	return gala_screen_saver_manager_type_id__once;
}

static void
_vala_gala_screen_saver_manager_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	GalaScreenSaverManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_SCREEN_SAVER_MANAGER, GalaScreenSaverManager);
	switch (property_id) {
		case GALA_SCREEN_SAVER_MANAGER_SESSION_LOCKER_PROPERTY:
		g_value_set_object (value, gala_screen_saver_manager_get_session_locker (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_screen_saver_manager_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	GalaScreenSaverManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_SCREEN_SAVER_MANAGER, GalaScreenSaverManager);
	switch (property_id) {
		case GALA_SCREEN_SAVER_MANAGER_SESSION_LOCKER_PROPERTY:
		gala_screen_saver_manager_set_session_locker (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_dbus_gala_screen_saver_manager_lock (GalaScreenSaverManager* self,
                                      GVariant* _parameters_,
                                      GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	gala_screen_saver_manager_lock (self, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		return;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
}

static void
_dbus_gala_screen_saver_manager_get_active (GalaScreenSaverManager* self,
                                            GVariant* _parameters_,
                                            GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	gboolean result;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	result = gala_screen_saver_manager_get_active (self, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		return;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_reply_builder, g_variant_new_boolean (result));
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
}

static void
_dbus_gala_screen_saver_manager_set_active (GalaScreenSaverManager* self,
                                            GVariant* _parameters_,
                                            GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	gboolean active = FALSE;
	GVariant* _tmp53_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp53_ = g_variant_iter_next_value (&_arguments_iter);
	active = g_variant_get_boolean (_tmp53_);
	g_variant_unref (_tmp53_);
	gala_screen_saver_manager_set_active (self, active, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		return;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
}

static void
_dbus_gala_screen_saver_manager_get_active_time (GalaScreenSaverManager* self,
                                                 GVariant* _parameters_,
                                                 GDBusMethodInvocation* invocation)
{
	GError* error = NULL;
	GVariantIter _arguments_iter;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	guint result;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	result = gala_screen_saver_manager_get_active_time (self, &error);
	if (error) {
		g_dbus_method_invocation_take_error (invocation, error);
		return;
	}
	_reply_message = g_dbus_message_new_method_reply (g_dbus_method_invocation_get_message (invocation));
	g_variant_builder_init (&_reply_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_reply_builder, g_variant_new_uint32 (result));
	_reply = g_variant_builder_end (&_reply_builder);
	g_dbus_message_set_body (_reply_message, _reply);
	g_dbus_connection_send_message (g_dbus_method_invocation_get_connection (invocation), _reply_message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, NULL, NULL);
	g_object_unref (invocation);
	g_object_unref (_reply_message);
}

static void
gala_screen_saver_manager_dbus_interface_method_call (GDBusConnection* connection,
                                                      const gchar* sender,
                                                      const gchar* object_path,
                                                      const gchar* interface_name,
                                                      const gchar* method_name,
                                                      GVariant* parameters,
                                                      GDBusMethodInvocation* invocation,
                                                      gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	if (strcmp (method_name, "Lock") == 0) {
		_dbus_gala_screen_saver_manager_lock (object, parameters, invocation);
	} else if (strcmp (method_name, "GetActive") == 0) {
		_dbus_gala_screen_saver_manager_get_active (object, parameters, invocation);
	} else if (strcmp (method_name, "SetActive") == 0) {
		_dbus_gala_screen_saver_manager_set_active (object, parameters, invocation);
	} else if (strcmp (method_name, "GetActiveTime") == 0) {
		_dbus_gala_screen_saver_manager_get_active_time (object, parameters, invocation);
	} else {
		g_object_unref (invocation);
	}
}

static GVariant*
gala_screen_saver_manager_dbus_interface_get_property (GDBusConnection* connection,
                                                       const gchar* sender,
                                                       const gchar* object_path,
                                                       const gchar* interface_name,
                                                       const gchar* property_name,
                                                       GError** error,
                                                       gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return NULL;
}

static gboolean
gala_screen_saver_manager_dbus_interface_set_property (GDBusConnection* connection,
                                                       const gchar* sender,
                                                       const gchar* object_path,
                                                       const gchar* interface_name,
                                                       const gchar* property_name,
                                                       GVariant* value,
                                                       GError** error,
                                                       gpointer user_data)
{
	gpointer* data;
	gpointer object;
	data = user_data;
	object = data[0];
	return FALSE;
}

static void
_dbus_gala_screen_saver_manager_active_changed (GObject* _sender,
                                                gboolean new_value,
                                                gpointer* _data)
{
	GDBusConnection * _connection;
	const gchar * _path;
	GVariant *_arguments;
	GVariantBuilder _arguments_builder;
	_connection = _data[1];
	_path = _data[2];
	g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
	g_variant_builder_add_value (&_arguments_builder, g_variant_new_boolean (new_value));
	_arguments = g_variant_builder_end (&_arguments_builder);
	g_dbus_connection_emit_signal (_connection, NULL, _path, "org.gnome.ScreenSaver", "ActiveChanged", _arguments, NULL);
}

guint
gala_screen_saver_manager_register_object (gpointer object,
                                           GDBusConnection* connection,
                                           const gchar* path,
                                           GError** error)
{
	guint result;
	gpointer *data;
	data = g_new (gpointer, 3);
	data[0] = g_object_ref (object);
	data[1] = g_object_ref (connection);
	data[2] = g_strdup (path);
	result = g_dbus_connection_register_object (connection, path, (GDBusInterfaceInfo *) (&_gala_screen_saver_manager_dbus_interface_info), &_gala_screen_saver_manager_dbus_interface_vtable, data, _gala_screen_saver_manager_unregister_object, error);
	if (!result) {
		return 0;
	}
	g_signal_connect (object, "active-changed", (GCallback) _dbus_gala_screen_saver_manager_active_changed, data);
	return result;
}

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

