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

/* -*- Mode: vala; indent-tabs-mode: nil; tab-width: 4 -*-*/
/*-
 * Copyright (c) 2019 Adam Bieńkowski (https://github.com/elementary/switchboard-plug-parental-controls)
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Adam Bieńkowski <donadigos159@gmail.com>
 */

#include <glib-object.h>
#include <gio/gio.h>
#include <glib.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
#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 PC_DAEMON_TYPE_SESSION_HANDLER (pc_daemon_session_handler_get_type ())
#define PC_DAEMON_SESSION_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_SESSION_HANDLER, PCDaemonSessionHandler))
#define PC_DAEMON_SESSION_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PC_DAEMON_TYPE_SESSION_HANDLER, PCDaemonSessionHandlerClass))
#define PC_DAEMON_IS_SESSION_HANDLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_SESSION_HANDLER))
#define PC_DAEMON_IS_SESSION_HANDLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PC_DAEMON_TYPE_SESSION_HANDLER))
#define PC_DAEMON_SESSION_HANDLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PC_DAEMON_TYPE_SESSION_HANDLER, PCDaemonSessionHandlerClass))

typedef struct _PCDaemonSessionHandler PCDaemonSessionHandler;
typedef struct _PCDaemonSessionHandlerClass PCDaemonSessionHandlerClass;
typedef struct _PCDaemonSessionHandlerPrivate PCDaemonSessionHandlerPrivate;

#define PC_DAEMON_TYPE_ISESSION (pc_daemon_isession_get_type ())
#define PC_DAEMON_ISESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_ISESSION, PCDaemonISession))
#define PC_DAEMON_IS_ISESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_ISESSION))
#define PC_DAEMON_ISESSION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PC_DAEMON_TYPE_ISESSION, PCDaemonISessionIface))

typedef struct _PCDaemonISession PCDaemonISession;
typedef struct _PCDaemonISessionIface PCDaemonISessionIface;

#define PC_DAEMON_TYPE_ISESSION_PROXY (pc_daemon_isession_proxy_get_type ())

#define PC_DAEMON_TYPE_RESTRICTION_CONTROLLER (pc_daemon_restriction_controller_get_type ())
#define PC_DAEMON_RESTRICTION_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_RESTRICTION_CONTROLLER, PCDaemonRestrictionController))
#define PC_DAEMON_RESTRICTION_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PC_DAEMON_TYPE_RESTRICTION_CONTROLLER, PCDaemonRestrictionControllerClass))
#define PC_DAEMON_IS_RESTRICTION_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_RESTRICTION_CONTROLLER))
#define PC_DAEMON_IS_RESTRICTION_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PC_DAEMON_TYPE_RESTRICTION_CONTROLLER))
#define PC_DAEMON_RESTRICTION_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PC_DAEMON_TYPE_RESTRICTION_CONTROLLER, PCDaemonRestrictionControllerClass))

typedef struct _PCDaemonRestrictionController PCDaemonRestrictionController;
typedef struct _PCDaemonRestrictionControllerClass PCDaemonRestrictionControllerClass;

#define PC_DAEMON_TYPE_RESTRICTION (pc_daemon_restriction_get_type ())
#define PC_DAEMON_RESTRICTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_RESTRICTION, PCDaemonRestriction))
#define PC_DAEMON_RESTRICTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PC_DAEMON_TYPE_RESTRICTION, PCDaemonRestrictionClass))
#define PC_DAEMON_IS_RESTRICTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_RESTRICTION))
#define PC_DAEMON_IS_RESTRICTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PC_DAEMON_TYPE_RESTRICTION))
#define PC_DAEMON_RESTRICTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PC_DAEMON_TYPE_RESTRICTION, PCDaemonRestrictionClass))

typedef struct _PCDaemonRestriction PCDaemonRestriction;
typedef struct _PCDaemonRestrictionClass PCDaemonRestrictionClass;

#define PC_DAEMON_TYPE_APP_RESTRICTION (pc_daemon_app_restriction_get_type ())
#define PC_DAEMON_APP_RESTRICTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_APP_RESTRICTION, PCDaemonAppRestriction))
#define PC_DAEMON_APP_RESTRICTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PC_DAEMON_TYPE_APP_RESTRICTION, PCDaemonAppRestrictionClass))
#define PC_DAEMON_IS_APP_RESTRICTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_APP_RESTRICTION))
#define PC_DAEMON_IS_APP_RESTRICTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PC_DAEMON_TYPE_APP_RESTRICTION))
#define PC_DAEMON_APP_RESTRICTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PC_DAEMON_TYPE_APP_RESTRICTION, PCDaemonAppRestrictionClass))

typedef struct _PCDaemonAppRestriction PCDaemonAppRestriction;
typedef struct _PCDaemonAppRestrictionClass PCDaemonAppRestrictionClass;

#define PC_DAEMON_TYPE_WEB_RESTRICTION (pc_daemon_web_restriction_get_type ())
#define PC_DAEMON_WEB_RESTRICTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_WEB_RESTRICTION, PCDaemonWebRestriction))
#define PC_DAEMON_WEB_RESTRICTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PC_DAEMON_TYPE_WEB_RESTRICTION, PCDaemonWebRestrictionClass))
#define PC_DAEMON_IS_WEB_RESTRICTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_WEB_RESTRICTION))
#define PC_DAEMON_IS_WEB_RESTRICTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PC_DAEMON_TYPE_WEB_RESTRICTION))
#define PC_DAEMON_WEB_RESTRICTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PC_DAEMON_TYPE_WEB_RESTRICTION, PCDaemonWebRestrictionClass))

typedef struct _PCDaemonWebRestriction PCDaemonWebRestriction;
typedef struct _PCDaemonWebRestrictionClass PCDaemonWebRestrictionClass;

#define PC_DAEMON_TYPE_TIME_RESTRICTION (pc_daemon_time_restriction_get_type ())
#define PC_DAEMON_TIME_RESTRICTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_TIME_RESTRICTION, PCDaemonTimeRestriction))
#define PC_DAEMON_TIME_RESTRICTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PC_DAEMON_TYPE_TIME_RESTRICTION, PCDaemonTimeRestrictionClass))
#define PC_DAEMON_IS_TIME_RESTRICTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_TIME_RESTRICTION))
#define PC_DAEMON_IS_TIME_RESTRICTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PC_DAEMON_TYPE_TIME_RESTRICTION))
#define PC_DAEMON_TIME_RESTRICTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PC_DAEMON_TYPE_TIME_RESTRICTION, PCDaemonTimeRestrictionClass))

typedef struct _PCDaemonTimeRestriction PCDaemonTimeRestriction;
typedef struct _PCDaemonTimeRestrictionClass PCDaemonTimeRestrictionClass;

#define PC_DAEMON_TYPE_USER_CONFIG (pc_daemon_user_config_get_type ())
#define PC_DAEMON_USER_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_USER_CONFIG, PCDaemonUserConfig))
#define PC_DAEMON_USER_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PC_DAEMON_TYPE_USER_CONFIG, PCDaemonUserConfigClass))
#define PC_DAEMON_IS_USER_CONFIG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_USER_CONFIG))
#define PC_DAEMON_IS_USER_CONFIG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PC_DAEMON_TYPE_USER_CONFIG))
#define PC_DAEMON_USER_CONFIG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PC_DAEMON_TYPE_USER_CONFIG, PCDaemonUserConfigClass))

typedef struct _PCDaemonUserConfig PCDaemonUserConfig;
typedef struct _PCDaemonUserConfigClass PCDaemonUserConfigClass;

#define PC_DAEMON_TYPE_SERVER (pc_daemon_server_get_type ())
#define PC_DAEMON_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PC_DAEMON_TYPE_SERVER, PCDaemonServer))
#define PC_DAEMON_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PC_DAEMON_TYPE_SERVER, PCDaemonServerClass))
#define PC_DAEMON_IS_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PC_DAEMON_TYPE_SERVER))
#define PC_DAEMON_IS_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PC_DAEMON_TYPE_SERVER))
#define PC_DAEMON_SERVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PC_DAEMON_TYPE_SERVER, PCDaemonServerClass))

typedef struct _PCDaemonServer PCDaemonServer;
typedef struct _PCDaemonServerClass PCDaemonServerClass;
enum  {
	PC_DAEMON_SESSION_HANDLER_0_PROPERTY,
	PC_DAEMON_SESSION_HANDLER_NUM_PROPERTIES
};
static GParamSpec* pc_daemon_session_handler_properties[PC_DAEMON_SESSION_HANDLER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block1Data Block1Data;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _PCDaemonISessionIface {
	GTypeInterface parent_iface;
	void (*terminate) (PCDaemonISession* self, GError** error);
	gboolean (*get_active) (PCDaemonISession* self);
	gchar* (*get_name) (PCDaemonISession* self);
	gchar* (*get_id) (PCDaemonISession* self);
};

struct _PCDaemonSessionHandler {
	GObject parent_instance;
	PCDaemonSessionHandlerPrivate * priv;
	PCDaemonISession* session;
};

struct _PCDaemonSessionHandlerClass {
	GObjectClass parent_class;
};

struct _PCDaemonSessionHandlerPrivate {
	PCDaemonRestrictionController* controller;
	PCDaemonAppRestriction* app_restriction;
	PCDaemonWebRestriction* web_restriction;
	PCDaemonTimeRestriction* time_restriction;
	PCDaemonUserConfig* config;
	PCDaemonServer* server;
};

struct _Block1Data {
	int _ref_count_;
	PCDaemonSessionHandler* self;
	PCDaemonISession* session;
};

static gint PCDaemonSessionHandler_private_offset;
static gpointer pc_daemon_session_handler_parent_class = NULL;

VALA_EXTERN GType pc_daemon_session_handler_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonSessionHandler, g_object_unref)
VALA_EXTERN GType pc_daemon_isession_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint pc_daemon_isession_register_object (void* object,
                                          GDBusConnection* connection,
                                          const gchar* path,
                                          GError** error);
VALA_EXTERN GType pc_daemon_isession_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonISession, g_object_unref)
VALA_EXTERN GType pc_daemon_restriction_controller_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonRestrictionController, g_object_unref)
VALA_EXTERN GType pc_daemon_restriction_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonRestriction, g_object_unref)
VALA_EXTERN GType pc_daemon_app_restriction_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonAppRestriction, g_object_unref)
VALA_EXTERN GType pc_daemon_web_restriction_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonWebRestriction, g_object_unref)
VALA_EXTERN GType pc_daemon_time_restriction_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonTimeRestriction, g_object_unref)
VALA_EXTERN GType pc_daemon_user_config_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonUserConfig, g_object_unref)
VALA_EXTERN GType pc_daemon_server_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PCDaemonServer, g_object_unref)
VALA_EXTERN guint pc_daemon_server_register_object (void* object,
                                        GDBusConnection* connection,
                                        const gchar* path,
                                        GError** error);
VALA_EXTERN PCDaemonSessionHandler* pc_daemon_session_handler_new (PCDaemonISession* session);
VALA_EXTERN PCDaemonSessionHandler* pc_daemon_session_handler_construct (GType object_type,
                                                             PCDaemonISession* session);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
VALA_EXTERN PCDaemonServer* pc_daemon_server_get_default (void);
VALA_EXTERN PCDaemonUserConfig* pc_daemon_user_config_get_for_username (const gchar* username,
                                                            gboolean create);
VALA_EXTERN gchar* pc_daemon_isession_get_name (PCDaemonISession* self);
VALA_EXTERN void pc_daemon_session_handler_update (PCDaemonSessionHandler* self);
static void _pc_daemon_session_handler_update_g_object_notify (GObject* _sender,
                                                        GParamSpec* pspec,
                                                        gpointer self);
VALA_EXTERN PCDaemonRestrictionController* pc_daemon_restriction_controller_new (void);
VALA_EXTERN PCDaemonRestrictionController* pc_daemon_restriction_controller_construct (GType object_type);
VALA_EXTERN PCDaemonAppRestriction* pc_daemon_app_restriction_new (PCDaemonUserConfig* config);
VALA_EXTERN PCDaemonAppRestriction* pc_daemon_app_restriction_construct (GType object_type,
                                                             PCDaemonUserConfig* config);
VALA_EXTERN PCDaemonWebRestriction* pc_daemon_web_restriction_new (PCDaemonUserConfig* config);
VALA_EXTERN PCDaemonWebRestriction* pc_daemon_web_restriction_construct (GType object_type,
                                                             PCDaemonUserConfig* config);
VALA_EXTERN PCDaemonTimeRestriction* pc_daemon_time_restriction_new (PCDaemonUserConfig* config);
VALA_EXTERN PCDaemonTimeRestriction* pc_daemon_time_restriction_construct (GType object_type,
                                                               PCDaemonUserConfig* config);
static void __lambda8_ (Block1Data* _data1_);
VALA_EXTERN void pc_daemon_isession_terminate (PCDaemonISession* self,
                                   GError** error);
static void ___lambda8__pc_daemon_time_restriction_terminate (PCDaemonTimeRestriction* _sender,
                                                       gpointer self);
VALA_EXTERN gchar* pc_daemon_session_handler_get_id (PCDaemonSessionHandler* self);
VALA_EXTERN gchar* pc_daemon_isession_get_id (PCDaemonISession* self);
VALA_EXTERN PCDaemonUserConfig* pc_daemon_session_handler_get_config (PCDaemonSessionHandler* self);
static void pc_daemon_session_handler_start (PCDaemonSessionHandler* self);
VALA_EXTERN void pc_daemon_restriction_controller_add_restriction (PCDaemonRestrictionController* self,
                                                       PCDaemonRestriction* restriction);
VALA_EXTERN gboolean pc_daemon_user_config_get_active (PCDaemonUserConfig* self);
VALA_EXTERN gboolean pc_daemon_restriction_controller_has_restrictions (PCDaemonRestrictionController* self);
VALA_EXTERN void pc_daemon_session_handler_stop (PCDaemonSessionHandler* self);
VALA_EXTERN void pc_daemon_restriction_controller_remove_restriction (PCDaemonRestrictionController* self,
                                                          PCDaemonRestriction* restriction);
static void pc_daemon_session_handler_finalize (GObject * obj);
static GType pc_daemon_session_handler_get_type_once (void);

static inline gpointer
pc_daemon_session_handler_get_instance_private (PCDaemonSessionHandler* self)
{
	return G_STRUCT_MEMBER_P (self, PCDaemonSessionHandler_private_offset);
}

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

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		PCDaemonSessionHandler* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->session);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
_pc_daemon_session_handler_update_g_object_notify (GObject* _sender,
                                                   GParamSpec* pspec,
                                                   gpointer self)
{
	pc_daemon_session_handler_update ((PCDaemonSessionHandler*) self);
}

static void
__lambda8_ (Block1Data* _data1_)
{
	PCDaemonSessionHandler* self;
	GError* _inner_error0_ = NULL;
	self = _data1_->self;
	{
		pc_daemon_isession_terminate (_data1_->session, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = e;
		_tmp1_ = _tmp0_->message;
		g_critical ("SessionHandler.vala:52: %s", _tmp1_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda8__pc_daemon_time_restriction_terminate (PCDaemonTimeRestriction* _sender,
                                                  gpointer self)
{
	__lambda8_ (self);
}

PCDaemonSessionHandler*
pc_daemon_session_handler_construct (GType object_type,
                                     PCDaemonISession* session)
{
	PCDaemonSessionHandler * self = NULL;
	Block1Data* _data1_;
	PCDaemonISession* _tmp0_;
	PCDaemonISession* _tmp1_;
	PCDaemonServer* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	PCDaemonUserConfig* _tmp6_;
	PCDaemonUserConfig* _tmp7_;
	PCDaemonRestrictionController* _tmp8_;
	PCDaemonUserConfig* _tmp9_;
	PCDaemonAppRestriction* _tmp10_;
	PCDaemonUserConfig* _tmp11_;
	PCDaemonWebRestriction* _tmp12_;
	PCDaemonUserConfig* _tmp13_;
	PCDaemonTimeRestriction* _tmp14_;
	PCDaemonTimeRestriction* _tmp15_;
	g_return_val_if_fail (session != NULL, NULL);
	_data1_ = g_slice_new0 (Block1Data);
	_data1_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (session);
	_g_object_unref0 (_data1_->session);
	_data1_->session = _tmp0_;
	self = (PCDaemonSessionHandler*) g_object_new (object_type, NULL);
	_data1_->self = g_object_ref (self);
	_tmp1_ = _g_object_ref0 (_data1_->session);
	_g_object_unref0 (self->session);
	self->session = _tmp1_;
	_tmp2_ = pc_daemon_server_get_default ();
	_g_object_unref0 (self->priv->server);
	self->priv->server = _tmp2_;
	_tmp3_ = pc_daemon_isession_get_name (_data1_->session);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp6_ = pc_daemon_user_config_get_for_username (_tmp5_, TRUE);
	_g_object_unref0 (self->priv->config);
	self->priv->config = _tmp6_;
	_g_free0 (_tmp5_);
	_tmp7_ = self->priv->config;
	g_signal_connect_object ((GObject*) _tmp7_, "notify::active", (GCallback) _pc_daemon_session_handler_update_g_object_notify, self, 0);
	_tmp8_ = pc_daemon_restriction_controller_new ();
	_g_object_unref0 (self->priv->controller);
	self->priv->controller = _tmp8_;
	_tmp9_ = self->priv->config;
	_tmp10_ = pc_daemon_app_restriction_new (_tmp9_);
	_g_object_unref0 (self->priv->app_restriction);
	self->priv->app_restriction = _tmp10_;
	_tmp11_ = self->priv->config;
	_tmp12_ = pc_daemon_web_restriction_new (_tmp11_);
	_g_object_unref0 (self->priv->web_restriction);
	self->priv->web_restriction = _tmp12_;
	_tmp13_ = self->priv->config;
	_tmp14_ = pc_daemon_time_restriction_new (_tmp13_);
	_g_object_unref0 (self->priv->time_restriction);
	self->priv->time_restriction = _tmp14_;
	_tmp15_ = self->priv->time_restriction;
	g_signal_connect_data (_tmp15_, "terminate", (GCallback) ___lambda8__pc_daemon_time_restriction_terminate, block1_data_ref (_data1_), (GClosureNotify) block1_data_unref, 0);
	block1_data_unref (_data1_);
	_data1_ = NULL;
	return self;
}

PCDaemonSessionHandler*
pc_daemon_session_handler_new (PCDaemonISession* session)
{
	return pc_daemon_session_handler_construct (PC_DAEMON_TYPE_SESSION_HANDLER, session);
}

gchar*
pc_daemon_session_handler_get_id (PCDaemonSessionHandler* self)
{
	PCDaemonISession* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->session;
	_tmp1_ = pc_daemon_isession_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

PCDaemonUserConfig*
pc_daemon_session_handler_get_config (PCDaemonSessionHandler* self)
{
	PCDaemonUserConfig* _tmp0_;
	PCDaemonUserConfig* _tmp1_;
	PCDaemonUserConfig* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->config;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
pc_daemon_session_handler_start (PCDaemonSessionHandler* self)
{
	PCDaemonRestrictionController* _tmp0_;
	PCDaemonAppRestriction* _tmp1_;
	PCDaemonRestrictionController* _tmp2_;
	PCDaemonWebRestriction* _tmp3_;
	PCDaemonRestrictionController* _tmp4_;
	PCDaemonTimeRestriction* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->controller;
	_tmp1_ = self->priv->app_restriction;
	pc_daemon_restriction_controller_add_restriction (_tmp0_, (PCDaemonRestriction*) _tmp1_);
	_tmp2_ = self->priv->controller;
	_tmp3_ = self->priv->web_restriction;
	pc_daemon_restriction_controller_add_restriction (_tmp2_, (PCDaemonRestriction*) _tmp3_);
	_tmp4_ = self->priv->controller;
	_tmp5_ = self->priv->time_restriction;
	pc_daemon_restriction_controller_add_restriction (_tmp4_, (PCDaemonRestriction*) _tmp5_);
}

void
pc_daemon_session_handler_update (PCDaemonSessionHandler* self)
{
	gboolean active = FALSE;
	PCDaemonUserConfig* _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_ = FALSE;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->config;
	_tmp1_ = pc_daemon_user_config_get_active (_tmp0_);
	_tmp2_ = _tmp1_;
	active = _tmp2_;
	if (!active) {
		PCDaemonRestrictionController* _tmp4_;
		_tmp4_ = self->priv->controller;
		_tmp3_ = pc_daemon_restriction_controller_has_restrictions (_tmp4_);
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		pc_daemon_session_handler_stop (self);
	} else {
		gboolean _tmp5_ = FALSE;
		if (active) {
			PCDaemonRestrictionController* _tmp6_;
			_tmp6_ = self->priv->controller;
			_tmp5_ = !pc_daemon_restriction_controller_has_restrictions (_tmp6_);
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			pc_daemon_session_handler_start (self);
		}
	}
}

void
pc_daemon_session_handler_stop (PCDaemonSessionHandler* self)
{
	PCDaemonRestrictionController* _tmp0_;
	PCDaemonAppRestriction* _tmp1_;
	PCDaemonRestrictionController* _tmp2_;
	PCDaemonWebRestriction* _tmp3_;
	PCDaemonRestrictionController* _tmp4_;
	PCDaemonTimeRestriction* _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->controller;
	_tmp1_ = self->priv->app_restriction;
	pc_daemon_restriction_controller_remove_restriction (_tmp0_, (PCDaemonRestriction*) _tmp1_);
	_tmp2_ = self->priv->controller;
	_tmp3_ = self->priv->web_restriction;
	pc_daemon_restriction_controller_remove_restriction (_tmp2_, (PCDaemonRestriction*) _tmp3_);
	_tmp4_ = self->priv->controller;
	_tmp5_ = self->priv->time_restriction;
	pc_daemon_restriction_controller_remove_restriction (_tmp4_, (PCDaemonRestriction*) _tmp5_);
}

static void
pc_daemon_session_handler_class_init (PCDaemonSessionHandlerClass * klass,
                                      gpointer klass_data)
{
	pc_daemon_session_handler_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PCDaemonSessionHandler_private_offset);
	G_OBJECT_CLASS (klass)->finalize = pc_daemon_session_handler_finalize;
}

static void
pc_daemon_session_handler_instance_init (PCDaemonSessionHandler * self,
                                         gpointer klass)
{
	self->priv = pc_daemon_session_handler_get_instance_private (self);
}

static void
pc_daemon_session_handler_finalize (GObject * obj)
{
	PCDaemonSessionHandler * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PC_DAEMON_TYPE_SESSION_HANDLER, PCDaemonSessionHandler);
	_g_object_unref0 (self->priv->controller);
	_g_object_unref0 (self->priv->app_restriction);
	_g_object_unref0 (self->priv->web_restriction);
	_g_object_unref0 (self->priv->time_restriction);
	_g_object_unref0 (self->priv->config);
	_g_object_unref0 (self->session);
	_g_object_unref0 (self->priv->server);
	G_OBJECT_CLASS (pc_daemon_session_handler_parent_class)->finalize (obj);
}

static GType
pc_daemon_session_handler_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PCDaemonSessionHandlerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pc_daemon_session_handler_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PCDaemonSessionHandler), 0, (GInstanceInitFunc) pc_daemon_session_handler_instance_init, NULL };
	GType pc_daemon_session_handler_type_id;
	pc_daemon_session_handler_type_id = g_type_register_static (G_TYPE_OBJECT, "PCDaemonSessionHandler", &g_define_type_info, 0);
	PCDaemonSessionHandler_private_offset = g_type_add_instance_private (pc_daemon_session_handler_type_id, sizeof (PCDaemonSessionHandlerPrivate));
	return pc_daemon_session_handler_type_id;
}

GType
pc_daemon_session_handler_get_type (void)
{
	static volatile gsize pc_daemon_session_handler_type_id__once = 0;
	if (g_once_init_enter (&pc_daemon_session_handler_type_id__once)) {
		GType pc_daemon_session_handler_type_id;
		pc_daemon_session_handler_type_id = pc_daemon_session_handler_get_type_once ();
		g_once_init_leave (&pc_daemon_session_handler_type_id__once, pc_daemon_session_handler_type_id);
	}
	return pc_daemon_session_handler_type_id__once;
}

