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

enum  {
	GEARY_NAMED_FLAGS_0_PROPERTY,
	GEARY_NAMED_FLAGS_NUM_PROPERTIES
};
static GParamSpec* geary_named_flags_properties[GEARY_NAMED_FLAGS_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block10Data Block10Data;
typedef struct _Block11Data Block11Data;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
enum  {
	GEARY_NAMED_FLAGS_ADDED_SIGNAL,
	GEARY_NAMED_FLAGS_REMOVED_SIGNAL,
	GEARY_NAMED_FLAGS_NUM_SIGNALS
};
static guint geary_named_flags_signals[GEARY_NAMED_FLAGS_NUM_SIGNALS] = {0};

struct _Block10Data {
	int _ref_count_;
	GearyNamedFlags* self;
	GearyNamedFlags* flags;
};

struct _Block11Data {
	int _ref_count_;
	GearyNamedFlags* self;
	GearyNamedFlags* other;
};

static gpointer geary_named_flags_parent_class = NULL;
static GeeHashableIface * geary_named_flags_gee_hashable_parent_iface = NULL;

static void geary_named_flags_real_added (GearyNamedFlags* self,
                                   GeeCollection* flags);
static void geary_named_flags_real_removed (GearyNamedFlags* self,
                                     GeeCollection* flags);
static void geary_named_flags_real_notify_added (GearyNamedFlags* self,
                                          GeeCollection* flags);
static void geary_named_flags_real_notify_removed (GearyNamedFlags* self,
                                            GeeCollection* flags);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
static gboolean __lambda14_ (Block10Data* _data10_,
                      GearyNamedFlag* f);
static gboolean ___lambda14__gee_predicate (gconstpointer g,
                                     gpointer self);
static void geary_named_flags_real_add (GearyNamedFlags* self,
                                 GearyNamedFlag* flag);
static void geary_named_flags_real_add_all (GearyNamedFlags* self,
                                     GearyNamedFlags* flags);
static gboolean __lambda15_ (GearyNamedFlags* self,
                      GearyNamedFlag* f);
static gboolean ___lambda15__gee_predicate (gconstpointer g,
                                     gpointer self);
static gboolean geary_named_flags_real_remove (GearyNamedFlags* self,
                                        GearyNamedFlag* flag);
static gboolean geary_named_flags_real_remove_all (GearyNamedFlags* self,
                                            GearyNamedFlags* flags);
static gboolean __lambda16_ (GearyNamedFlags* self,
                      GearyNamedFlag* f);
static gboolean ___lambda16__gee_predicate (gconstpointer g,
                                     gpointer self);
static gboolean geary_named_flags_real_equal_to (GeeHashable* base,
                                          GearyNamedFlags* other);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static gboolean __lambda17_ (Block11Data* _data11_,
                      GearyNamedFlag* f);
static gboolean ___lambda17__gee_predicate (gconstpointer g,
                                     gpointer self);
static guint geary_named_flags_real_hash (GeeHashable* base);
static void geary_named_flags_finalize (GObject * obj);
static GType geary_named_flags_get_type_once (void);

static void
geary_named_flags_real_added (GearyNamedFlags* self,
                              GeeCollection* flags)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (flags, GEE_TYPE_COLLECTION));
}

static void
geary_named_flags_real_removed (GearyNamedFlags* self,
                                GeeCollection* flags)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (flags, GEE_TYPE_COLLECTION));
}

GearyNamedFlags*
geary_named_flags_construct (GType object_type)
{
	GearyNamedFlags * self = NULL;
	self = (GearyNamedFlags*) geary_base_object_construct (object_type);
	return self;
}

GearyNamedFlags*
geary_named_flags_new (void)
{
	return geary_named_flags_construct (GEARY_TYPE_NAMED_FLAGS);
}

static void
geary_named_flags_real_notify_added (GearyNamedFlags* self,
                                     GeeCollection* flags)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (flags, GEE_TYPE_COLLECTION));
	g_signal_emit (self, geary_named_flags_signals[GEARY_NAMED_FLAGS_ADDED_SIGNAL], 0, flags);
}

void
geary_named_flags_notify_added (GearyNamedFlags* self,
                                GeeCollection* flags)
{
	GearyNamedFlagsClass* _klass_;
	g_return_if_fail (GEARY_IS_NAMED_FLAGS (self));
	_klass_ = GEARY_NAMED_FLAGS_GET_CLASS (self);
	if (_klass_->notify_added) {
		_klass_->notify_added (self, flags);
	}
}

static void
geary_named_flags_real_notify_removed (GearyNamedFlags* self,
                                       GeeCollection* flags)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (flags, GEE_TYPE_COLLECTION));
	g_signal_emit (self, geary_named_flags_signals[GEARY_NAMED_FLAGS_REMOVED_SIGNAL], 0, flags);
}

void
geary_named_flags_notify_removed (GearyNamedFlags* self,
                                  GeeCollection* flags)
{
	GearyNamedFlagsClass* _klass_;
	g_return_if_fail (GEARY_IS_NAMED_FLAGS (self));
	_klass_ = GEARY_NAMED_FLAGS_GET_CLASS (self);
	if (_klass_->notify_removed) {
		_klass_->notify_removed (self, flags);
	}
}

gboolean
geary_named_flags_contains (GearyNamedFlags* self,
                            GearyNamedFlag* flag)
{
	GeeSet* _tmp0_;
	gboolean result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (self), FALSE);
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (flag), FALSE);
	_tmp0_ = self->list;
	result = gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection), flag);
	return result;
}

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

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		GearyNamedFlags* self;
		self = _data10_->self;
		_g_object_unref0 (_data10_->flags);
		_g_object_unref0 (self);
		g_slice_free (Block10Data, _data10_);
	}
}

static gboolean
__lambda14_ (Block10Data* _data10_,
             GearyNamedFlag* f)
{
	GearyNamedFlags* self;
	gboolean result;
	self = _data10_->self;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (f), FALSE);
	result = geary_named_flags_contains (_data10_->flags, f);
	return result;
}

static gboolean
___lambda14__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = __lambda14_ (self, (GearyNamedFlag*) g);
	return result;
}

gboolean
geary_named_flags_contains_any (GearyNamedFlags* self,
                                GearyNamedFlags* flags)
{
	Block10Data* _data10_;
	GearyNamedFlags* _tmp0_;
	GeeSet* _tmp1_;
	GearyIterable* _tmp2_;
	GearyIterable* _tmp3_;
	gboolean _tmp4_;
	gboolean result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (self), FALSE);
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (flags), FALSE);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_data10_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (flags);
	_g_object_unref0 (_data10_->flags);
	_data10_->flags = _tmp0_;
	_tmp1_ = self->list;
	_tmp2_ = geary_traverse (GEARY_TYPE_NAMED_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_iterable_any (_tmp3_, ___lambda14__gee_predicate, block10_data_ref (_data10_), block10_data_unref);
	_g_object_unref0 (_tmp3_);
	result = _tmp4_;
	block10_data_unref (_data10_);
	_data10_ = NULL;
	return result;
}

GeeSet*
geary_named_flags_get_all (GearyNamedFlags* self)
{
	GeeSet* _tmp0_;
	GeeSet* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (self), NULL);
	_tmp0_ = self->list;
	_tmp1_ = gee_set_get_read_only_view (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static void
geary_named_flags_real_add (GearyNamedFlags* self,
                            GearyNamedFlag* flag)
{
	GeeSet* _tmp0_;
	g_return_if_fail (GEARY_IS_NAMED_FLAG (flag));
	_tmp0_ = self->list;
	if (!gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection), flag)) {
		GeeSet* _tmp1_;
		GearyIterable* _tmp2_;
		GearyIterable* _tmp3_;
		GeeArrayList* _tmp4_;
		GeeArrayList* _tmp5_;
		_tmp1_ = self->list;
		gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection), flag);
		_tmp2_ = geary_iterate (GEARY_TYPE_NAMED_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, flag, NULL);
		_tmp3_ = _tmp2_;
		_tmp4_ = geary_iterable_to_array_list (_tmp3_, NULL, NULL, NULL);
		_tmp5_ = _tmp4_;
		geary_named_flags_notify_added (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEE_TYPE_COLLECTION, GeeCollection));
		_g_object_unref0 (_tmp5_);
		_g_object_unref0 (_tmp3_);
	}
}

void
geary_named_flags_add (GearyNamedFlags* self,
                       GearyNamedFlag* flag)
{
	GearyNamedFlagsClass* _klass_;
	g_return_if_fail (GEARY_IS_NAMED_FLAGS (self));
	_klass_ = GEARY_NAMED_FLAGS_GET_CLASS (self);
	if (_klass_->add) {
		_klass_->add (self, flag);
	}
}

static gboolean
__lambda15_ (GearyNamedFlags* self,
             GearyNamedFlag* f)
{
	GeeSet* _tmp0_;
	gboolean result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (f), FALSE);
	_tmp0_ = self->list;
	result = !gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection), f);
	return result;
}

static gboolean
___lambda15__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = __lambda15_ ((GearyNamedFlags*) self, (GearyNamedFlag*) g);
	return result;
}

static void
geary_named_flags_real_add_all (GearyNamedFlags* self,
                                GearyNamedFlags* flags)
{
	GeeArrayList* added = NULL;
	GeeSet* _tmp0_;
	GeeSet* _tmp1_;
	GearyIterable* _tmp2_;
	GearyIterable* _tmp3_;
	GearyIterable* _tmp4_;
	GearyIterable* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeSet* _tmp8_;
	g_return_if_fail (GEARY_IS_NAMED_FLAGS (flags));
	_tmp0_ = geary_named_flags_get_all (flags);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_traverse (GEARY_TYPE_NAMED_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_iterable_filter (_tmp3_, ___lambda15__gee_predicate, g_object_ref (self), g_object_unref);
	_tmp5_ = _tmp4_;
	_tmp6_ = geary_iterable_to_array_list (_tmp5_, NULL, NULL, NULL);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	added = _tmp7_;
	_tmp8_ = self->list;
	gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (added, GEE_TYPE_COLLECTION, GeeCollection));
	geary_named_flags_notify_added (self, G_TYPE_CHECK_INSTANCE_CAST (added, GEE_TYPE_COLLECTION, GeeCollection));
	_g_object_unref0 (added);
}

void
geary_named_flags_add_all (GearyNamedFlags* self,
                           GearyNamedFlags* flags)
{
	GearyNamedFlagsClass* _klass_;
	g_return_if_fail (GEARY_IS_NAMED_FLAGS (self));
	_klass_ = GEARY_NAMED_FLAGS_GET_CLASS (self);
	if (_klass_->add_all) {
		_klass_->add_all (self, flags);
	}
}

static gboolean
geary_named_flags_real_remove (GearyNamedFlags* self,
                               GearyNamedFlag* flag)
{
	gboolean removed = FALSE;
	GeeSet* _tmp0_;
	gboolean result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (flag), FALSE);
	_tmp0_ = self->list;
	removed = gee_collection_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection), flag);
	if (removed) {
		GearyIterable* _tmp1_;
		GearyIterable* _tmp2_;
		GeeArrayList* _tmp3_;
		GeeArrayList* _tmp4_;
		_tmp1_ = geary_iterate (GEARY_TYPE_NAMED_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, flag, NULL);
		_tmp2_ = _tmp1_;
		_tmp3_ = geary_iterable_to_array_list (_tmp2_, NULL, NULL, NULL);
		_tmp4_ = _tmp3_;
		geary_named_flags_notify_removed (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_COLLECTION, GeeCollection));
		_g_object_unref0 (_tmp4_);
		_g_object_unref0 (_tmp2_);
	}
	result = removed;
	return result;
}

gboolean
geary_named_flags_remove (GearyNamedFlags* self,
                          GearyNamedFlag* flag)
{
	GearyNamedFlagsClass* _klass_;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (self), FALSE);
	_klass_ = GEARY_NAMED_FLAGS_GET_CLASS (self);
	if (_klass_->remove) {
		return _klass_->remove (self, flag);
	}
	return FALSE;
}

static gboolean
__lambda16_ (GearyNamedFlags* self,
             GearyNamedFlag* f)
{
	GeeSet* _tmp0_;
	gboolean result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (f), FALSE);
	_tmp0_ = self->list;
	result = gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection), f);
	return result;
}

static gboolean
___lambda16__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = __lambda16_ ((GearyNamedFlags*) self, (GearyNamedFlag*) g);
	return result;
}

static gboolean
geary_named_flags_real_remove_all (GearyNamedFlags* self,
                                   GearyNamedFlags* flags)
{
	GeeArrayList* removed = NULL;
	GeeSet* _tmp0_;
	GeeSet* _tmp1_;
	GearyIterable* _tmp2_;
	GearyIterable* _tmp3_;
	GearyIterable* _tmp4_;
	GearyIterable* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeSet* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gboolean result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (flags), FALSE);
	_tmp0_ = geary_named_flags_get_all (flags);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_traverse (GEARY_TYPE_NAMED_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_iterable_filter (_tmp3_, ___lambda16__gee_predicate, g_object_ref (self), g_object_unref);
	_tmp5_ = _tmp4_;
	_tmp6_ = geary_iterable_to_array_list (_tmp5_, NULL, NULL, NULL);
	_tmp7_ = _tmp6_;
	_g_object_unref0 (_tmp5_);
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	removed = _tmp7_;
	_tmp8_ = self->list;
	gee_collection_remove_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (removed, GEE_TYPE_COLLECTION, GeeCollection));
	geary_named_flags_notify_removed (self, G_TYPE_CHECK_INSTANCE_CAST (removed, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp9_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (removed, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
	_tmp10_ = _tmp9_;
	result = _tmp10_ > 0;
	_g_object_unref0 (removed);
	return result;
}

gboolean
geary_named_flags_remove_all (GearyNamedFlags* self,
                              GearyNamedFlags* flags)
{
	GearyNamedFlagsClass* _klass_;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (self), FALSE);
	_klass_ = GEARY_NAMED_FLAGS_GET_CLASS (self);
	if (_klass_->remove_all) {
		return _klass_->remove_all (self, flags);
	}
	return FALSE;
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		GearyNamedFlags* self;
		self = _data11_->self;
		_g_object_unref0 (_data11_->other);
		_g_object_unref0 (self);
		g_slice_free (Block11Data, _data11_);
	}
}

static gboolean
__lambda17_ (Block11Data* _data11_,
             GearyNamedFlag* f)
{
	GearyNamedFlags* self;
	gboolean result;
	self = _data11_->self;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAG (f), FALSE);
	result = geary_named_flags_contains (_data11_->other, f);
	return result;
}

static gboolean
___lambda17__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = __lambda17_ (self, (GearyNamedFlag*) g);
	return result;
}

static gboolean
geary_named_flags_real_equal_to (GeeHashable* base,
                                 GearyNamedFlags* other)
{
	GearyNamedFlags * self;
	Block11Data* _data11_;
	GearyNamedFlags* _tmp0_;
	GeeSet* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	GeeSet* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	GeeSet* _tmp7_;
	GearyIterable* _tmp8_;
	GearyIterable* _tmp9_;
	gboolean _tmp10_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags);
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (other), FALSE);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_data11_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (other);
	_g_object_unref0 (_data11_->other);
	_data11_->other = _tmp0_;
	if (self == _data11_->other) {
		result = TRUE;
		block11_data_unref (_data11_);
		_data11_ = NULL;
		return result;
	}
	_tmp1_ = self->list;
	_tmp2_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp3_ = _tmp2_;
	_tmp4_ = _data11_->other->list;
	_tmp5_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp6_ = _tmp5_;
	if (_tmp3_ != _tmp6_) {
		result = FALSE;
		block11_data_unref (_data11_);
		_data11_ = NULL;
		return result;
	}
	_tmp7_ = self->list;
	_tmp8_ = geary_traverse (GEARY_TYPE_NAMED_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_ITERABLE, GeeIterable));
	_tmp9_ = _tmp8_;
	_tmp10_ = geary_iterable_all (_tmp9_, ___lambda17__gee_predicate, block11_data_ref (_data11_), block11_data_unref);
	_g_object_unref0 (_tmp9_);
	result = _tmp10_;
	block11_data_unref (_data11_);
	_data11_ = NULL;
	return result;
}

static guint
geary_named_flags_real_hash (GeeHashable* base)
{
	GearyNamedFlags * self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	guint _tmp2_;
	guint result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags);
	_tmp0_ = geary_named_flags_to_string (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_string_stri_hash (_tmp1_);
	_g_free0 (_tmp1_);
	result = _tmp2_;
	return result;
}

/** Formats the flags for serialising in the database. */
gchar*
geary_named_flags_serialise (GearyNamedFlags* self)
{
	GString* builder = NULL;
	GString* _tmp0_;
	GString* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (self), NULL);
	_tmp0_ = g_string_new ("");
	builder = _tmp0_;
	{
		GeeIterator* _flag_it = NULL;
		GeeSet* _tmp1_;
		GeeIterator* _tmp2_;
		_tmp1_ = self->list;
		_tmp2_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
		_flag_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			GearyNamedFlag* flag = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			GString* _tmp6_;
			GearyNamedFlag* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			GString* _tmp10_;
			_tmp3_ = _flag_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _flag_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			flag = (GearyNamedFlag*) _tmp5_;
			_tmp6_ = builder;
			_tmp7_ = flag;
			_tmp8_ = geary_named_flag_serialise (_tmp7_);
			_tmp9_ = _tmp8_;
			g_string_append (_tmp6_, _tmp9_);
			_g_free0 (_tmp9_);
			_tmp10_ = builder;
			g_string_append_c (_tmp10_, ' ');
			_g_object_unref0 (flag);
		}
		_g_object_unref0 (_flag_it);
	}
	_tmp11_ = builder;
	_tmp12_ = _tmp11_->str;
	_tmp13_ = g_strdup (_tmp12_);
	result = _tmp13_;
	_g_string_free0 (builder);
	return result;
}

/** Formats the flags for debugging. */
gchar*
geary_named_flags_to_string (GearyNamedFlags* self)
{
	gchar* ret = NULL;
	gchar* _tmp0_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	g_return_val_if_fail (GEARY_IS_NAMED_FLAGS (self), NULL);
	_tmp0_ = g_strdup ("[");
	ret = _tmp0_;
	{
		GeeIterator* _flag_it = NULL;
		GeeSet* _tmp1_;
		GeeIterator* _tmp2_;
		_tmp1_ = self->list;
		_tmp2_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
		_flag_it = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			GearyNamedFlag* flag = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			const gchar* _tmp6_;
			GearyNamedFlag* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			gchar* _tmp11_;
			gchar* _tmp12_;
			_tmp3_ = _flag_it;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = _flag_it;
			_tmp5_ = gee_iterator_get (_tmp4_);
			flag = (GearyNamedFlag*) _tmp5_;
			_tmp6_ = ret;
			_tmp7_ = flag;
			_tmp8_ = geary_named_flag_to_string (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp10_ = g_strconcat (_tmp9_, " ", NULL);
			_tmp11_ = _tmp10_;
			_tmp12_ = g_strconcat (_tmp6_, _tmp11_, NULL);
			_g_free0 (ret);
			ret = _tmp12_;
			_g_free0 (_tmp11_);
			_g_free0 (_tmp9_);
			_g_object_unref0 (flag);
		}
		_g_object_unref0 (_flag_it);
	}
	_tmp13_ = ret;
	_tmp14_ = g_strconcat (_tmp13_, "]", NULL);
	result = _tmp14_;
	_g_free0 (ret);
	return result;
}

static void
geary_named_flags_class_init (GearyNamedFlagsClass * klass,
                              gpointer klass_data)
{
	geary_named_flags_parent_class = g_type_class_peek_parent (klass);
	((GearyNamedFlagsClass *) klass)->notify_added = (void (*) (GearyNamedFlags*, GeeCollection*)) geary_named_flags_real_notify_added;
	((GearyNamedFlagsClass *) klass)->notify_removed = (void (*) (GearyNamedFlags*, GeeCollection*)) geary_named_flags_real_notify_removed;
	((GearyNamedFlagsClass *) klass)->add = (void (*) (GearyNamedFlags*, GearyNamedFlag*)) geary_named_flags_real_add;
	((GearyNamedFlagsClass *) klass)->add_all = (void (*) (GearyNamedFlags*, GearyNamedFlags*)) geary_named_flags_real_add_all;
	((GearyNamedFlagsClass *) klass)->remove = (gboolean (*) (GearyNamedFlags*, GearyNamedFlag*)) geary_named_flags_real_remove;
	((GearyNamedFlagsClass *) klass)->remove_all = (gboolean (*) (GearyNamedFlags*, GearyNamedFlags*)) geary_named_flags_real_remove_all;
	((GearyNamedFlagsClass *) klass)->added = geary_named_flags_real_added;
	((GearyNamedFlagsClass *) klass)->removed = geary_named_flags_real_removed;
	G_OBJECT_CLASS (klass)->finalize = geary_named_flags_finalize;
	geary_named_flags_signals[GEARY_NAMED_FLAGS_ADDED_SIGNAL] = g_signal_new ("added", GEARY_TYPE_NAMED_FLAGS, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyNamedFlagsClass, added), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_COLLECTION);
	geary_named_flags_signals[GEARY_NAMED_FLAGS_REMOVED_SIGNAL] = g_signal_new ("removed", GEARY_TYPE_NAMED_FLAGS, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GearyNamedFlagsClass, removed), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_COLLECTION);
}

static void
geary_named_flags_gee_hashable_interface_init (GeeHashableIface * iface,
                                               gpointer iface_data)
{
	geary_named_flags_gee_hashable_parent_iface = g_type_interface_peek_parent (iface);
	iface->equal_to = (gboolean (*) (GeeHashable*, gconstpointer)) geary_named_flags_real_equal_to;
	iface->hash = (guint (*) (GeeHashable*)) geary_named_flags_real_hash;
}

static void
geary_named_flags_instance_init (GearyNamedFlags * self,
                                 gpointer klass)
{
	GeeHashSet* _tmp0_;
	_tmp0_ = gee_hash_set_new (GEARY_TYPE_NAMED_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	self->list = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_SET, GeeSet);
}

static void
geary_named_flags_finalize (GObject * obj)
{
	GearyNamedFlags * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags);
	_g_object_unref0 (self->list);
	G_OBJECT_CLASS (geary_named_flags_parent_class)->finalize (obj);
}

/**
 * A signalled collection of NamedFlags.  Currently Geary uses these flags for enabling/disabling
 * options with email or contacts.
 */
 G_GNUC_NO_INLINE static GType
geary_named_flags_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyNamedFlagsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_named_flags_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyNamedFlags), 0, (GInstanceInitFunc) geary_named_flags_instance_init, NULL };
	static const GInterfaceInfo gee_hashable_info = { (GInterfaceInitFunc) geary_named_flags_gee_hashable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType geary_named_flags_type_id;
	geary_named_flags_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "GearyNamedFlags", &g_define_type_info, 0);
	g_type_add_interface_static (geary_named_flags_type_id, GEE_TYPE_HASHABLE, &gee_hashable_info);
	return geary_named_flags_type_id;
}

GType
geary_named_flags_get_type (void)
{
	static gsize geary_named_flags_type_id__once = 0;
	if (g_once_init_enter (&geary_named_flags_type_id__once)) {
		GType geary_named_flags_type_id;
		geary_named_flags_type_id = geary_named_flags_get_type_once ();
		g_once_init_leave (&geary_named_flags_type_id__once, geary_named_flags_type_id);
	}
	return geary_named_flags_type_id__once;
}

