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

/**/
/*  Copyright 2020 elementary, Inc. (https://elementary.io)*/
/**/
/*  This program is free software: you can redistribute it and/or modify*/
/*  it under the terms of the GNU General Public License as published by*/
/*  the Free Software Foundation, either version 3 of the License, or*/
/*  (at your option) any later version.*/
/**/
/*  This program is distributed in the hope that it will be useful,*/
/*  but WITHOUT ANY WARRANTY; without even the implied warranty of*/
/*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the*/
/*  GNU General Public License for more details.*/
/**/
/*  You should have received a copy of the GNU General Public License*/
/*  along with this program.  If not, see <http://www.gnu.org/licenses/>.*/
/**/

#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_SCREEN_SHIELD_LONG_ANIMATION_TIME ((guint) 3000)
#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_SCREEN_SHIELD (gala_screen_shield_get_type ())
#define GALA_SCREEN_SHIELD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_SCREEN_SHIELD, GalaScreenShield))
#define GALA_SCREEN_SHIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_SCREEN_SHIELD, GalaScreenShieldClass))
#define GALA_IS_SCREEN_SHIELD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_SCREEN_SHIELD))
#define GALA_IS_SCREEN_SHIELD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_SCREEN_SHIELD))
#define GALA_SCREEN_SHIELD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_SCREEN_SHIELD, GalaScreenShieldClass))

typedef struct _GalaScreenShield GalaScreenShield;
typedef struct _GalaScreenShieldClass GalaScreenShieldClass;
enum  {
	GALA_SCREEN_SAVER_MANAGER_0_PROPERTY,
	GALA_SCREEN_SAVER_MANAGER_SCREEN_SHIELD_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 {
	GalaScreenShield* _screen_shield;
};

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_screen_shield_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaScreenShield, g_object_unref)
VALA_EXTERN GalaScreenSaverManager* gala_screen_saver_manager_new (GalaScreenShield* shield);
VALA_EXTERN GalaScreenSaverManager* gala_screen_saver_manager_construct (GType object_type,
                                                             GalaScreenShield* shield);
VALA_EXTERN void gala_screen_saver_manager_lock (GalaScreenSaverManager* self,
                                     GError** error);
VALA_EXTERN GalaScreenShield* gala_screen_saver_manager_get_screen_shield (GalaScreenSaverManager* self);
VALA_EXTERN void gala_screen_shield_lock (GalaScreenShield* self,
                              gboolean animate);
VALA_EXTERN gboolean gala_screen_saver_manager_get_active (GalaScreenSaverManager* self,
                                               GError** error);
VALA_EXTERN gboolean gala_screen_shield_get_active (GalaScreenShield* self);
VALA_EXTERN void gala_screen_saver_manager_set_active (GalaScreenSaverManager* self,
                                           gboolean active,
                                           GError** error);
VALA_EXTERN void gala_screen_shield_activate (GalaScreenShield* self,
                                  gboolean animate,
                                  guint animation_time);
VALA_EXTERN void gala_screen_shield_deactivate (GalaScreenShield* self,
                                    gboolean animate);
VALA_EXTERN guint gala_screen_saver_manager_get_active_time (GalaScreenSaverManager* self,
                                                 GError** error);
VALA_EXTERN gint64 gala_screen_shield_get_activation_time (GalaScreenShield* self);
static void gala_screen_saver_manager_set_screen_shield (GalaScreenSaverManager* self,
                                                  GalaScreenShield* value);
static GObject * gala_screen_saver_manager_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void _gala_screen_saver_manager___lambda23_ (GalaScreenSaverManager* self);
static void __gala_screen_saver_manager___lambda23__gala_screen_shield_active_changed (GalaScreenShield* _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 inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

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,
                                     GalaScreenShield* shield)
{
	GalaScreenSaverManager * self = NULL;
	g_return_val_if_fail (shield != NULL, NULL);
	self = (GalaScreenSaverManager*) g_object_new (object_type, "screen-shield", shield, NULL);
	return self;
}

GalaScreenSaverManager*
gala_screen_saver_manager_new (GalaScreenShield* shield)
{
	return gala_screen_saver_manager_construct (GALA_TYPE_SCREEN_SAVER_MANAGER, shield);
}

void
gala_screen_saver_manager_lock (GalaScreenSaverManager* self,
                                GError** error)
{
	GalaScreenShield* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->_screen_shield;
	gala_screen_shield_lock (_tmp0_, TRUE);
}

gboolean
gala_screen_saver_manager_get_active (GalaScreenSaverManager* self,
                                      GError** error)
{
	GalaScreenShield* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_screen_shield;
	_tmp1_ = gala_screen_shield_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) {
		GalaScreenShield* _tmp0_;
		_tmp0_ = self->priv->_screen_shield;
		gala_screen_shield_activate (_tmp0_, TRUE, GALA_SCREEN_SHIELD_LONG_ANIMATION_TIME);
	} else {
		GalaScreenShield* _tmp1_;
		_tmp1_ = self->priv->_screen_shield;
		gala_screen_shield_deactivate (_tmp1_, FALSE);
	}
}

guint
gala_screen_saver_manager_get_active_time (GalaScreenSaverManager* self,
                                           GError** error)
{
	gint64 started = 0LL;
	GalaScreenShield* _tmp0_;
	gint64 _tmp1_;
	gint64 _tmp2_;
	guint result;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->_screen_shield;
	_tmp1_ = gala_screen_shield_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;
	}
}

GalaScreenShield*
gala_screen_saver_manager_get_screen_shield (GalaScreenSaverManager* self)
{
	GalaScreenShield* result;
	GalaScreenShield* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_screen_shield;
	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_screen_shield (GalaScreenSaverManager* self,
                                             GalaScreenShield* value)
{
	GalaScreenShield* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_screen_saver_manager_get_screen_shield (self);
	if (old_value != value) {
		GalaScreenShield* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_screen_shield);
		self->priv->_screen_shield = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_screen_saver_manager_properties[GALA_SCREEN_SAVER_MANAGER_SCREEN_SHIELD_PROPERTY]);
	}
}

static void
_gala_screen_saver_manager___lambda23_ (GalaScreenSaverManager* self)
{
	GalaScreenShield* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	_tmp0_ = self->priv->_screen_shield;
	_tmp1_ = gala_screen_shield_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___lambda23__gala_screen_shield_active_changed (GalaScreenShield* _sender,
                                                                           gpointer self)
{
	_gala_screen_saver_manager___lambda23_ ((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;
	GalaScreenShield* _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->_screen_shield;
	g_signal_connect_object (_tmp0_, "active-changed", (GCallback) __gala_screen_saver_manager___lambda23__gala_screen_shield_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_SCREEN_SHIELD_PROPERTY, gala_screen_saver_manager_properties[GALA_SCREEN_SAVER_MANAGER_SCREEN_SHIELD_PROPERTY] = g_param_spec_object ("screen-shield", "screen-shield", "screen-shield", GALA_TYPE_SCREEN_SHIELD, 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->_screen_shield);
	G_OBJECT_CLASS (gala_screen_saver_manager_parent_class)->finalize (obj);
}

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 volatile 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_SCREEN_SHIELD_PROPERTY:
		g_value_set_object (value, gala_screen_saver_manager_get_screen_shield (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_SCREEN_SHIELD_PROPERTY:
		gala_screen_saver_manager_set_screen_shield (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* _tmp96_;
	GDBusMessage* _reply_message = NULL;
	GVariant* _reply;
	GVariantBuilder _reply_builder;
	g_variant_iter_init (&_arguments_iter, _parameters_);
	_tmp96_ = g_variant_iter_next_value (&_arguments_iter);
	active = g_variant_get_boolean (_tmp96_);
	g_variant_unref (_tmp96_);
	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);
}

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

