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

/*-
 * Copyright (c) 2016 elementary LLC (https://elementary.io)
 *
 * 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 <gee.h>
#include <glib.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_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;
typedef struct _PCDaemonRestrictionControllerPrivate PCDaemonRestrictionControllerPrivate;

#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;
enum  {
	PC_DAEMON_RESTRICTION_CONTROLLER_0_PROPERTY,
	PC_DAEMON_RESTRICTION_CONTROLLER_NUM_PROPERTIES
};
static GParamSpec* pc_daemon_restriction_controller_properties[PC_DAEMON_RESTRICTION_CONTROLLER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _PCDaemonRestrictionController {
	GObject parent_instance;
	PCDaemonRestrictionControllerPrivate * priv;
};

struct _PCDaemonRestrictionControllerClass {
	GObjectClass parent_class;
};

struct _PCDaemonRestrictionControllerPrivate {
	GeeArrayList* restrictions;
};

static gint PCDaemonRestrictionController_private_offset;
static gpointer pc_daemon_restriction_controller_parent_class = NULL;

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 void pc_daemon_restriction_controller_add_restriction (PCDaemonRestrictionController* self,
                                                       PCDaemonRestriction* restriction);
VALA_EXTERN void pc_daemon_restriction_start (PCDaemonRestriction* self);
VALA_EXTERN void pc_daemon_restriction_controller_remove_restriction (PCDaemonRestrictionController* self,
                                                          PCDaemonRestriction* restriction);
VALA_EXTERN void pc_daemon_restriction_stop (PCDaemonRestriction* self);
VALA_EXTERN gboolean pc_daemon_restriction_controller_has_restrictions (PCDaemonRestrictionController* self);
VALA_EXTERN PCDaemonRestrictionController* pc_daemon_restriction_controller_new (void);
VALA_EXTERN PCDaemonRestrictionController* pc_daemon_restriction_controller_construct (GType object_type);
static GObject * pc_daemon_restriction_controller_constructor (GType type,
                                                        guint n_construct_properties,
                                                        GObjectConstructParam * construct_properties);
static void pc_daemon_restriction_controller_finalize (GObject * obj);
static GType pc_daemon_restriction_controller_get_type_once (void);

static inline gpointer
pc_daemon_restriction_controller_get_instance_private (PCDaemonRestrictionController* self)
{
	return G_STRUCT_MEMBER_P (self, PCDaemonRestrictionController_private_offset);
}

void
pc_daemon_restriction_controller_add_restriction (PCDaemonRestrictionController* self,
                                                  PCDaemonRestriction* restriction)
{
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (restriction != NULL);
	_tmp0_ = self->priv->restrictions;
	if (gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp0_, restriction)) {
		return;
	}
	_tmp1_ = self->priv->restrictions;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, restriction);
	pc_daemon_restriction_start (restriction);
}

void
pc_daemon_restriction_controller_remove_restriction (PCDaemonRestrictionController* self,
                                                     PCDaemonRestriction* restriction)
{
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (restriction != NULL);
	_tmp0_ = self->priv->restrictions;
	if (!gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp0_, restriction)) {
		return;
	}
	_tmp1_ = self->priv->restrictions;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp1_, restriction);
	pc_daemon_restriction_stop (restriction);
}

gboolean
pc_daemon_restriction_controller_has_restrictions (PCDaemonRestrictionController* self)
{
	GeeArrayList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->restrictions;
	_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_ > 0;
	return result;
}

PCDaemonRestrictionController*
pc_daemon_restriction_controller_construct (GType object_type)
{
	PCDaemonRestrictionController * self = NULL;
	self = (PCDaemonRestrictionController*) g_object_new (object_type, NULL);
	return self;
}

PCDaemonRestrictionController*
pc_daemon_restriction_controller_new (void)
{
	return pc_daemon_restriction_controller_construct (PC_DAEMON_TYPE_RESTRICTION_CONTROLLER);
}

static GObject *
pc_daemon_restriction_controller_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	PCDaemonRestrictionController * self;
	GeeArrayList* _tmp0_;
	parent_class = G_OBJECT_CLASS (pc_daemon_restriction_controller_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PC_DAEMON_TYPE_RESTRICTION_CONTROLLER, PCDaemonRestrictionController);
	_tmp0_ = gee_array_list_new (PC_DAEMON_TYPE_RESTRICTION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->restrictions);
	self->priv->restrictions = _tmp0_;
	return obj;
}

static void
pc_daemon_restriction_controller_class_init (PCDaemonRestrictionControllerClass * klass,
                                             gpointer klass_data)
{
	pc_daemon_restriction_controller_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PCDaemonRestrictionController_private_offset);
	G_OBJECT_CLASS (klass)->constructor = pc_daemon_restriction_controller_constructor;
	G_OBJECT_CLASS (klass)->finalize = pc_daemon_restriction_controller_finalize;
}

static void
pc_daemon_restriction_controller_instance_init (PCDaemonRestrictionController * self,
                                                gpointer klass)
{
	self->priv = pc_daemon_restriction_controller_get_instance_private (self);
}

static void
pc_daemon_restriction_controller_finalize (GObject * obj)
{
	PCDaemonRestrictionController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PC_DAEMON_TYPE_RESTRICTION_CONTROLLER, PCDaemonRestrictionController);
	_g_object_unref0 (self->priv->restrictions);
	G_OBJECT_CLASS (pc_daemon_restriction_controller_parent_class)->finalize (obj);
}

static GType
pc_daemon_restriction_controller_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (PCDaemonRestrictionControllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) pc_daemon_restriction_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PCDaemonRestrictionController), 0, (GInstanceInitFunc) pc_daemon_restriction_controller_instance_init, NULL };
	GType pc_daemon_restriction_controller_type_id;
	pc_daemon_restriction_controller_type_id = g_type_register_static (G_TYPE_OBJECT, "PCDaemonRestrictionController", &g_define_type_info, 0);
	PCDaemonRestrictionController_private_offset = g_type_add_instance_private (pc_daemon_restriction_controller_type_id, sizeof (PCDaemonRestrictionControllerPrivate));
	return pc_daemon_restriction_controller_type_id;
}

GType
pc_daemon_restriction_controller_get_type (void)
{
	static volatile gsize pc_daemon_restriction_controller_type_id__once = 0;
	if (g_once_init_enter (&pc_daemon_restriction_controller_type_id__once)) {
		GType pc_daemon_restriction_controller_type_id;
		pc_daemon_restriction_controller_type_id = pc_daemon_restriction_controller_get_type_once ();
		g_once_init_leave (&pc_daemon_restriction_controller_type_id__once, pc_daemon_restriction_controller_type_id);
	}
	return pc_daemon_restriction_controller_type_id__once;
}

