/* geary-named-flag.c generated by valac 0.56.3, the Vala compiler
 * generated from geary-named-flag.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 <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>

enum  {
	GEARY_NAMED_FLAG_0_PROPERTY,
	GEARY_NAMED_FLAG_NAME_PROPERTY,
	GEARY_NAMED_FLAG_NUM_PROPERTIES
};
static GParamSpec* geary_named_flag_properties[GEARY_NAMED_FLAG_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GearyNamedFlagPrivate {
	gchar* _name;
};

static gint GearyNamedFlag_private_offset;
static gpointer geary_named_flag_parent_class = NULL;
static GeeHashableIface * geary_named_flag_gee_hashable_parent_iface = NULL;

static void geary_named_flag_set_name (GearyNamedFlag* self,
                                const gchar* value);
static gboolean geary_named_flag_real_equal_to (GeeHashable* base,
                                         GearyNamedFlag* other);
static guint geary_named_flag_real_hash (GeeHashable* base);
static void geary_named_flag_finalize (GObject * obj);
static GType geary_named_flag_get_type_once (void);
static void _vala_geary_named_flag_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_geary_named_flag_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);

static inline gpointer
geary_named_flag_get_instance_private (GearyNamedFlag* self)
{
	return G_STRUCT_MEMBER_P (self, GearyNamedFlag_private_offset);
}

const gchar*
geary_named_flag_get_name (GearyNamedFlag* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (self), NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

static void
geary_named_flag_set_name (GearyNamedFlag* self,
                           const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (GEARY_IS_NAMED_FLAG (self));
	old_value = geary_named_flag_get_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_name);
		self->priv->_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_named_flag_properties[GEARY_NAMED_FLAG_NAME_PROPERTY]);
	}
}

GearyNamedFlag*
geary_named_flag_construct (GType object_type,
                            const gchar* name)
{
	GearyNamedFlag * self = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	self = (GearyNamedFlag*) geary_base_object_construct (object_type);
	geary_named_flag_set_name (self, name);
	return self;
}

GearyNamedFlag*
geary_named_flag_new (const gchar* name)
{
	return geary_named_flag_construct (GEARY_TYPE_NAMED_FLAG, name);
}

static gboolean
geary_named_flag_real_equal_to (GeeHashable* base,
                                GearyNamedFlag* other)
{
	GearyNamedFlag * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gboolean _tmp6_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_TYPE_NAMED_FLAG, GearyNamedFlag);
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (other), FALSE);
	if (self == other) {
		result = TRUE;
		return result;
	}
	_tmp0_ = self->priv->_name;
	_tmp1_ = g_utf8_strdown (_tmp0_, (gssize) -1);
	_tmp2_ = _tmp1_;
	_tmp3_ = other->priv->_name;
	_tmp4_ = g_utf8_strdown (_tmp3_, (gssize) -1);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strcmp0 (_tmp2_, _tmp5_) == 0;
	_g_free0 (_tmp5_);
	_g_free0 (_tmp2_);
	result = _tmp6_;
	return result;
}

static guint
geary_named_flag_real_hash (GeeHashable* base)
{
	GearyNamedFlag * self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	guint _tmp3_;
	guint result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_TYPE_NAMED_FLAG, GearyNamedFlag);
	_tmp0_ = self->priv->_name;
	_tmp1_ = g_utf8_strdown (_tmp0_, (gssize) -1);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_str_hash (_tmp2_);
	_g_free0 (_tmp2_);
	result = _tmp3_;
	return result;
}

gchar*
geary_named_flag_serialise (GearyNamedFlag* self)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (self), NULL);
	_tmp0_ = self->priv->_name;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

gchar*
geary_named_flag_to_string (GearyNamedFlag* self)
{
	const gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (self), NULL);
	_tmp0_ = self->priv->_name;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}

static void
geary_named_flag_class_init (GearyNamedFlagClass * klass,
                             gpointer klass_data)
{
	geary_named_flag_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyNamedFlag_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_named_flag_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_geary_named_flag_set_property;
	G_OBJECT_CLASS (klass)->finalize = geary_named_flag_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_NAMED_FLAG_NAME_PROPERTY, geary_named_flag_properties[GEARY_NAMED_FLAG_NAME_PROPERTY] = g_param_spec_string ("name", "name", "name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
geary_named_flag_gee_hashable_interface_init (GeeHashableIface * iface,
                                              gpointer iface_data)
{
	geary_named_flag_gee_hashable_parent_iface = g_type_interface_peek_parent (iface);
	iface->equal_to = (gboolean (*) (GeeHashable*, gconstpointer)) geary_named_flag_real_equal_to;
	iface->hash = (guint (*) (GeeHashable*)) geary_named_flag_real_hash;
}

static void
geary_named_flag_instance_init (GearyNamedFlag * self,
                                gpointer klass)
{
	self->priv = geary_named_flag_get_instance_private (self);
}

static void
geary_named_flag_finalize (GObject * obj)
{
	GearyNamedFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_TYPE_NAMED_FLAG, GearyNamedFlag);
	_g_free0 (self->priv->_name);
	G_OBJECT_CLASS (geary_named_flag_parent_class)->finalize (obj);
}

/**
 * Geary offers a couple of places where the user may mark an object (email, contact)
 * with a named flag.  The presence of the flag indicates if the state is enabled/on
 * or disabled/off.
 */
 G_GNUC_NO_INLINE static GType
geary_named_flag_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyNamedFlagClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_named_flag_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyNamedFlag), 0, (GInstanceInitFunc) geary_named_flag_instance_init, NULL };
	static const GInterfaceInfo gee_hashable_info = { (GInterfaceInitFunc) geary_named_flag_gee_hashable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType geary_named_flag_type_id;
	geary_named_flag_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "GearyNamedFlag", &g_define_type_info, 0);
	g_type_add_interface_static (geary_named_flag_type_id, GEE_TYPE_HASHABLE, &gee_hashable_info);
	GearyNamedFlag_private_offset = g_type_add_instance_private (geary_named_flag_type_id, sizeof (GearyNamedFlagPrivate));
	return geary_named_flag_type_id;
}

GType
geary_named_flag_get_type (void)
{
	static gsize geary_named_flag_type_id__once = 0;
	if (g_once_init_enter (&geary_named_flag_type_id__once)) {
		GType geary_named_flag_type_id;
		geary_named_flag_type_id = geary_named_flag_get_type_once ();
		g_once_init_leave (&geary_named_flag_type_id__once, geary_named_flag_type_id);
	}
	return geary_named_flag_type_id__once;
}

static void
_vala_geary_named_flag_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	GearyNamedFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_TYPE_NAMED_FLAG, GearyNamedFlag);
	switch (property_id) {
		case GEARY_NAMED_FLAG_NAME_PROPERTY:
		g_value_set_string (value, geary_named_flag_get_name (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_geary_named_flag_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	GearyNamedFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_TYPE_NAMED_FLAG, GearyNamedFlag);
	switch (property_id) {
		case GEARY_NAMED_FLAG_NAME_PROPERTY:
		geary_named_flag_set_name (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

