/* geary-aggregated-folder-properties.c generated by valac 0.56.19, the Vala compiler
 * generated from geary-aggregated-folder-properties.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

#include "geary-engine.h"
#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

#define GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES (geary_aggregated_folder_properties_get_type ())
#define GEARY_AGGREGATED_FOLDER_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES, GearyAggregatedFolderProperties))
#define GEARY_AGGREGATED_FOLDER_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES, GearyAggregatedFolderPropertiesClass))
#define GEARY_IS_AGGREGATED_FOLDER_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES))
#define GEARY_IS_AGGREGATED_FOLDER_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES))
#define GEARY_AGGREGATED_FOLDER_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES, GearyAggregatedFolderPropertiesClass))

typedef struct _GearyAggregatedFolderProperties GearyAggregatedFolderProperties;
typedef struct _GearyAggregatedFolderPropertiesClass GearyAggregatedFolderPropertiesClass;
typedef struct _GearyAggregatedFolderPropertiesPrivate GearyAggregatedFolderPropertiesPrivate;
enum  {
	GEARY_AGGREGATED_FOLDER_PROPERTIES_0_PROPERTY,
	GEARY_AGGREGATED_FOLDER_PROPERTIES_NUM_PROPERTIES
};
static GParamSpec* geary_aggregated_folder_properties_properties[GEARY_AGGREGATED_FOLDER_PROPERTIES_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _GearyAggregatedFolderProperties {
	GearyFolderProperties parent_instance;
	GearyAggregatedFolderPropertiesPrivate * priv;
};

struct _GearyAggregatedFolderPropertiesClass {
	GearyFolderPropertiesClass parent_class;
};

struct _GearyAggregatedFolderPropertiesPrivate {
	GeeMap* child_bindings;
};

static gint GearyAggregatedFolderProperties_private_offset;
static gpointer geary_aggregated_folder_properties_parent_class = NULL;

VALA_EXTERN GType geary_aggregated_folder_properties_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyAggregatedFolderProperties* geary_aggregated_folder_properties_new (gboolean is_local_only,
                                                                         gboolean is_virtual);
VALA_EXTERN GearyAggregatedFolderProperties* geary_aggregated_folder_properties_construct (GType object_type,
                                                                               gboolean is_local_only,
                                                                               gboolean is_virtual);
VALA_EXTERN void geary_aggregated_folder_properties_add (GearyAggregatedFolderProperties* self,
                                             GearyFolderProperties* child);
VALA_EXTERN gboolean geary_aggregated_folder_properties_remove (GearyAggregatedFolderProperties* self,
                                                    GearyFolderProperties* child);
static void geary_aggregated_folder_properties_finalize (GObject * obj);
static GType geary_aggregated_folder_properties_get_type_once (void);

static inline gpointer
geary_aggregated_folder_properties_get_instance_private (GearyAggregatedFolderProperties* self)
{
	return G_STRUCT_MEMBER_P (self, GearyAggregatedFolderProperties_private_offset);
}

/**
     * Creates an aggregate FolderProperties.
     */
GearyAggregatedFolderProperties*
geary_aggregated_folder_properties_construct (GType object_type,
                                              gboolean is_local_only,
                                              gboolean is_virtual)
{
	GearyAggregatedFolderProperties * self = NULL;
	self = (GearyAggregatedFolderProperties*) geary_folder_properties_construct (object_type, 0, 0, GEARY_TRILLIAN_UNKNOWN, GEARY_TRILLIAN_UNKNOWN, GEARY_TRILLIAN_UNKNOWN, is_local_only, is_virtual, FALSE);
	return self;
}

GearyAggregatedFolderProperties*
geary_aggregated_folder_properties_new (gboolean is_local_only,
                                        gboolean is_virtual)
{
	return geary_aggregated_folder_properties_construct (GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES, is_local_only, is_virtual);
}

/**
     * Adds a child FolderProperties.  The child's property values will overwrite
     * this class's property values.
     */
void
geary_aggregated_folder_properties_add (GearyAggregatedFolderProperties* self,
                                        GearyFolderProperties* child)
{
	GeeList* bindings = NULL;
	GeeList* _tmp0_;
	GeeMap* _tmp1_;
	g_return_if_fail (GEARY_IS_AGGREGATED_FOLDER_PROPERTIES (self));
	g_return_if_fail (GEARY_IS_FOLDER_PROPERTIES (child));
	_tmp0_ = geary_object_utils_mirror_properties (G_TYPE_CHECK_INSTANCE_CAST (child, G_TYPE_OBJECT, GObject), G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject), G_BINDING_DEFAULT | G_BINDING_SYNC_CREATE);
	bindings = _tmp0_;
	_vala_assert (bindings != NULL, "bindings != null");
	_tmp1_ = self->priv->child_bindings;
	gee_map_set (_tmp1_, child, bindings);
	_g_object_unref0 (bindings);
}

/**
     * Removes a child FolderProperties.
     */
gboolean
geary_aggregated_folder_properties_remove (GearyAggregatedFolderProperties* self,
                                           GearyFolderProperties* child)
{
	GeeList* bindings = NULL;
	GeeMap* _tmp0_;
	gpointer _tmp1_ = NULL;
	gboolean _tmp2_;
	gboolean result;
	g_return_val_if_fail (GEARY_IS_AGGREGATED_FOLDER_PROPERTIES (self), FALSE);
	g_return_val_if_fail (GEARY_IS_FOLDER_PROPERTIES (child), FALSE);
	_tmp0_ = self->priv->child_bindings;
	_tmp2_ = gee_map_unset (_tmp0_, child, &_tmp1_);
	_g_object_unref0 (bindings);
	bindings = (GeeList*) _tmp1_;
	if (_tmp2_) {
		GeeList* _tmp3_;
		_tmp3_ = bindings;
		geary_object_utils_unmirror_properties (_tmp3_);
		result = TRUE;
		_g_object_unref0 (bindings);
		return result;
	}
	result = FALSE;
	_g_object_unref0 (bindings);
	return result;
}

static void
geary_aggregated_folder_properties_class_init (GearyAggregatedFolderPropertiesClass * klass,
                                               gpointer klass_data)
{
	geary_aggregated_folder_properties_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyAggregatedFolderProperties_private_offset);
	G_OBJECT_CLASS (klass)->finalize = geary_aggregated_folder_properties_finalize;
}

static void
geary_aggregated_folder_properties_instance_init (GearyAggregatedFolderProperties * self,
                                                  gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = geary_aggregated_folder_properties_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (GEARY_TYPE_FOLDER_PROPERTIES, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEE_TYPE_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->child_bindings = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_MAP, GeeMap);
}

static void
geary_aggregated_folder_properties_finalize (GObject * obj)
{
	GearyAggregatedFolderProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES, GearyAggregatedFolderProperties);
	_g_object_unref0 (self->priv->child_bindings);
	G_OBJECT_CLASS (geary_aggregated_folder_properties_parent_class)->finalize (obj);
}

/**
 * Aggregates multiple FolderProperties into one.  This way a Geary.Folder can
 * present one stable FolderProperties object that the client can register
 * change listeners on, etc. despite most Geary.Folders having both a local
 * and remote version of FolderProperties.
 *
 * The class relies on GObject bindings and the fact that FolderProperties
 * contains only propertiess.
 */
 G_GNUC_NO_INLINE static GType
geary_aggregated_folder_properties_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyAggregatedFolderPropertiesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_aggregated_folder_properties_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyAggregatedFolderProperties), 0, (GInstanceInitFunc) geary_aggregated_folder_properties_instance_init, NULL };
	GType geary_aggregated_folder_properties_type_id;
	geary_aggregated_folder_properties_type_id = g_type_register_static (GEARY_TYPE_FOLDER_PROPERTIES, "GearyAggregatedFolderProperties", &g_define_type_info, 0);
	GearyAggregatedFolderProperties_private_offset = g_type_add_instance_private (geary_aggregated_folder_properties_type_id, sizeof (GearyAggregatedFolderPropertiesPrivate));
	return geary_aggregated_folder_properties_type_id;
}

GType
geary_aggregated_folder_properties_get_type (void)
{
	static gsize geary_aggregated_folder_properties_type_id__once = 0;
	if (g_once_init_enter (&geary_aggregated_folder_properties_type_id__once)) {
		GType geary_aggregated_folder_properties_type_id;
		geary_aggregated_folder_properties_type_id = geary_aggregated_folder_properties_get_type_once ();
		g_once_init_leave (&geary_aggregated_folder_properties_type_id__once, geary_aggregated_folder_properties_type_id);
	}
	return geary_aggregated_folder_properties_type_id__once;
}

