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

enum  {
	GEARY_IMAP_MESSAGE_FLAG_0_PROPERTY,
	GEARY_IMAP_MESSAGE_FLAG_NUM_PROPERTIES
};
static GParamSpec* geary_imap_message_flag_properties[GEARY_IMAP_MESSAGE_FLAG_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer geary_imap_message_flag_parent_class = NULL;
static GearyImapMessageFlag* geary_imap_message_flag__answered;
static GearyImapMessageFlag* geary_imap_message_flag__answered = NULL;
static GearyImapMessageFlag* geary_imap_message_flag__deleted;
static GearyImapMessageFlag* geary_imap_message_flag__deleted = NULL;
static GearyImapMessageFlag* geary_imap_message_flag__draft;
static GearyImapMessageFlag* geary_imap_message_flag__draft = NULL;
static GearyImapMessageFlag* geary_imap_message_flag__flagged;
static GearyImapMessageFlag* geary_imap_message_flag__flagged = NULL;
static GearyImapMessageFlag* geary_imap_message_flag__recent;
static GearyImapMessageFlag* geary_imap_message_flag__recent = NULL;
static GearyImapMessageFlag* geary_imap_message_flag__seen;
static GearyImapMessageFlag* geary_imap_message_flag__seen = NULL;
static GearyImapMessageFlag* geary_imap_message_flag__allows_new;
static GearyImapMessageFlag* geary_imap_message_flag__allows_new = NULL;
static GearyImapMessageFlag* geary_imap_message_flag__load_remote_images;
static GearyImapMessageFlag* geary_imap_message_flag__load_remote_images = NULL;

VALA_EXTERN void geary_imap_message_flag_init (void);
static void geary_imap_message_flag_finalize (GObject * obj);
static GType geary_imap_message_flag_get_type_once (void);
static void _vala_geary_imap_message_flag_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec);

GearyImapMessageFlag*
geary_imap_message_flag_get_ANSWERED (void)
{
	GearyImapMessageFlag* result;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp2_;
	_tmp0_ = geary_imap_message_flag__answered;
	if (_tmp0_ == NULL) {
		GearyImapMessageFlag* _tmp1_;
		_tmp1_ = geary_imap_message_flag_new ("\\answered");
		_g_object_unref0 (geary_imap_message_flag__answered);
		geary_imap_message_flag__answered = _tmp1_;
	}
	_tmp2_ = geary_imap_message_flag__answered;
	result = _tmp2_;
	return result;
}

GearyImapMessageFlag*
geary_imap_message_flag_get_DELETED (void)
{
	GearyImapMessageFlag* result;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp2_;
	_tmp0_ = geary_imap_message_flag__deleted;
	if (_tmp0_ == NULL) {
		GearyImapMessageFlag* _tmp1_;
		_tmp1_ = geary_imap_message_flag_new ("\\deleted");
		_g_object_unref0 (geary_imap_message_flag__deleted);
		geary_imap_message_flag__deleted = _tmp1_;
	}
	_tmp2_ = geary_imap_message_flag__deleted;
	result = _tmp2_;
	return result;
}

GearyImapMessageFlag*
geary_imap_message_flag_get_DRAFT (void)
{
	GearyImapMessageFlag* result;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp2_;
	_tmp0_ = geary_imap_message_flag__draft;
	if (_tmp0_ == NULL) {
		GearyImapMessageFlag* _tmp1_;
		_tmp1_ = geary_imap_message_flag_new ("\\draft");
		_g_object_unref0 (geary_imap_message_flag__draft);
		geary_imap_message_flag__draft = _tmp1_;
	}
	_tmp2_ = geary_imap_message_flag__draft;
	result = _tmp2_;
	return result;
}

GearyImapMessageFlag*
geary_imap_message_flag_get_FLAGGED (void)
{
	GearyImapMessageFlag* result;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp2_;
	_tmp0_ = geary_imap_message_flag__flagged;
	if (_tmp0_ == NULL) {
		GearyImapMessageFlag* _tmp1_;
		_tmp1_ = geary_imap_message_flag_new ("\\flagged");
		_g_object_unref0 (geary_imap_message_flag__flagged);
		geary_imap_message_flag__flagged = _tmp1_;
	}
	_tmp2_ = geary_imap_message_flag__flagged;
	result = _tmp2_;
	return result;
}

GearyImapMessageFlag*
geary_imap_message_flag_get_RECENT (void)
{
	GearyImapMessageFlag* result;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp2_;
	_tmp0_ = geary_imap_message_flag__recent;
	if (_tmp0_ == NULL) {
		GearyImapMessageFlag* _tmp1_;
		_tmp1_ = geary_imap_message_flag_new ("\\recent");
		_g_object_unref0 (geary_imap_message_flag__recent);
		geary_imap_message_flag__recent = _tmp1_;
	}
	_tmp2_ = geary_imap_message_flag__recent;
	result = _tmp2_;
	return result;
}

GearyImapMessageFlag*
geary_imap_message_flag_get_SEEN (void)
{
	GearyImapMessageFlag* result;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp2_;
	_tmp0_ = geary_imap_message_flag__seen;
	if (_tmp0_ == NULL) {
		GearyImapMessageFlag* _tmp1_;
		_tmp1_ = geary_imap_message_flag_new ("\\seen");
		_g_object_unref0 (geary_imap_message_flag__seen);
		geary_imap_message_flag__seen = _tmp1_;
	}
	_tmp2_ = geary_imap_message_flag__seen;
	result = _tmp2_;
	return result;
}

GearyImapMessageFlag*
geary_imap_message_flag_get_ALLOWS_NEW (void)
{
	GearyImapMessageFlag* result;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp2_;
	_tmp0_ = geary_imap_message_flag__allows_new;
	if (_tmp0_ == NULL) {
		GearyImapMessageFlag* _tmp1_;
		_tmp1_ = geary_imap_message_flag_new ("\\*");
		_g_object_unref0 (geary_imap_message_flag__allows_new);
		geary_imap_message_flag__allows_new = _tmp1_;
	}
	_tmp2_ = geary_imap_message_flag__allows_new;
	result = _tmp2_;
	return result;
}

GearyImapMessageFlag*
geary_imap_message_flag_get_LOAD_REMOTE_IMAGES (void)
{
	GearyImapMessageFlag* result;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp2_;
	_tmp0_ = geary_imap_message_flag__load_remote_images;
	if (_tmp0_ == NULL) {
		GearyImapMessageFlag* _tmp1_;
		_tmp1_ = geary_imap_message_flag_new ("LoadRemoteImages");
		_g_object_unref0 (geary_imap_message_flag__load_remote_images);
		geary_imap_message_flag__load_remote_images = _tmp1_;
	}
	_tmp2_ = geary_imap_message_flag__load_remote_images;
	result = _tmp2_;
	return result;
}

/**
     * Creates an IMAP message (email) named flag.
     */
GearyImapMessageFlag*
geary_imap_message_flag_construct (GType object_type,
                                   const gchar* value)
{
	GearyImapMessageFlag * self = NULL;
	g_return_val_if_fail (value != NULL, NULL);
	self = (GearyImapMessageFlag*) geary_imap_flag_construct (object_type, value);
	return self;
}

GearyImapMessageFlag*
geary_imap_message_flag_new (const gchar* value)
{
	return geary_imap_message_flag_construct (GEARY_IMAP_TYPE_MESSAGE_FLAG, value);
}

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

void
geary_imap_message_flag_init (void)
{
	GearyImapMessageFlag* to_init = NULL;
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp1_;
	GearyImapMessageFlag* _tmp2_;
	GearyImapMessageFlag* _tmp3_;
	GearyImapMessageFlag* _tmp4_;
	GearyImapMessageFlag* _tmp5_;
	GearyImapMessageFlag* _tmp6_;
	GearyImapMessageFlag* _tmp7_;
	GearyImapMessageFlag* _tmp8_;
	GearyImapMessageFlag* _tmp9_;
	GearyImapMessageFlag* _tmp10_;
	GearyImapMessageFlag* _tmp11_;
	GearyImapMessageFlag* _tmp12_;
	GearyImapMessageFlag* _tmp13_;
	GearyImapMessageFlag* _tmp14_;
	GearyImapMessageFlag* _tmp15_;
	GearyImapMessageFlag* _tmp16_;
	GearyImapMessageFlag* _tmp17_;
	GearyImapMessageFlag* _tmp18_;
	GearyImapMessageFlag* _tmp19_;
	GearyImapMessageFlag* _tmp20_;
	GearyImapMessageFlag* _tmp21_;
	GearyImapMessageFlag* _tmp22_;
	GearyImapMessageFlag* _tmp23_;
	_tmp0_ = geary_imap_message_flag_get_ANSWERED ();
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	to_init = _tmp2_;
	_tmp3_ = geary_imap_message_flag_get_DELETED ();
	_tmp4_ = _tmp3_;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	_g_object_unref0 (to_init);
	to_init = _tmp5_;
	_tmp6_ = geary_imap_message_flag_get_DRAFT ();
	_tmp7_ = _tmp6_;
	_tmp8_ = _g_object_ref0 (_tmp7_);
	_g_object_unref0 (to_init);
	to_init = _tmp8_;
	_tmp9_ = geary_imap_message_flag_get_FLAGGED ();
	_tmp10_ = _tmp9_;
	_tmp11_ = _g_object_ref0 (_tmp10_);
	_g_object_unref0 (to_init);
	to_init = _tmp11_;
	_tmp12_ = geary_imap_message_flag_get_RECENT ();
	_tmp13_ = _tmp12_;
	_tmp14_ = _g_object_ref0 (_tmp13_);
	_g_object_unref0 (to_init);
	to_init = _tmp14_;
	_tmp15_ = geary_imap_message_flag_get_SEEN ();
	_tmp16_ = _tmp15_;
	_tmp17_ = _g_object_ref0 (_tmp16_);
	_g_object_unref0 (to_init);
	to_init = _tmp17_;
	_tmp18_ = geary_imap_message_flag_get_ALLOWS_NEW ();
	_tmp19_ = _tmp18_;
	_tmp20_ = _g_object_ref0 (_tmp19_);
	_g_object_unref0 (to_init);
	to_init = _tmp20_;
	_tmp21_ = geary_imap_message_flag_get_LOAD_REMOTE_IMAGES ();
	_tmp22_ = _tmp21_;
	_tmp23_ = _g_object_ref0 (_tmp22_);
	_g_object_unref0 (to_init);
	to_init = _tmp23_;
	_g_object_unref0 (to_init);
}

void
geary_imap_message_flag_from_email_flags (GearyEmailFlags* email_flags_add,
                                          GearyEmailFlags* email_flags_remove,
                                          GeeList** msg_flags_add,
                                          GeeList** msg_flags_remove)
{
	GeeList* _vala_msg_flags_add = NULL;
	GeeList* _vala_msg_flags_remove = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	g_return_if_fail ((email_flags_add == NULL) || GEARY_IS_EMAIL_FLAGS (email_flags_add));
	g_return_if_fail ((email_flags_remove == NULL) || GEARY_IS_EMAIL_FLAGS (email_flags_remove));
	_tmp0_ = gee_array_list_new (GEARY_IMAP_TYPE_MESSAGE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (_vala_msg_flags_add);
	_vala_msg_flags_add = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_LIST, GeeList);
	_tmp1_ = gee_array_list_new (GEARY_IMAP_TYPE_MESSAGE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_g_object_unref0 (_vala_msg_flags_remove);
	_vala_msg_flags_remove = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_LIST, GeeList);
	if (email_flags_add != NULL) {
		GearyNamedFlag* _tmp2_;
		GearyNamedFlag* _tmp3_;
		GearyNamedFlag* _tmp4_;
		gboolean _tmp5_;
		GearyNamedFlag* _tmp9_;
		GearyNamedFlag* _tmp10_;
		GearyNamedFlag* _tmp11_;
		gboolean _tmp12_;
		GearyNamedFlag* _tmp16_;
		GearyNamedFlag* _tmp17_;
		GearyNamedFlag* _tmp18_;
		gboolean _tmp19_;
		GearyNamedFlag* _tmp23_;
		GearyNamedFlag* _tmp24_;
		GearyNamedFlag* _tmp25_;
		gboolean _tmp26_;
		GearyNamedFlag* _tmp30_;
		GearyNamedFlag* _tmp31_;
		GearyNamedFlag* _tmp32_;
		gboolean _tmp33_;
		_tmp2_ = geary_email_flags_get_UNREAD ();
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp5_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_add, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp4_);
		_g_object_unref0 (_tmp4_);
		if (_tmp5_) {
			GeeList* _tmp6_;
			GearyImapMessageFlag* _tmp7_;
			GearyImapMessageFlag* _tmp8_;
			_tmp6_ = _vala_msg_flags_remove;
			_tmp7_ = geary_imap_message_flag_get_SEEN ();
			_tmp8_ = _tmp7_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_COLLECTION, GeeCollection), _tmp8_);
		}
		_tmp9_ = geary_email_flags_get_FLAGGED ();
		_tmp10_ = _tmp9_;
		_tmp11_ = _tmp10_;
		_tmp12_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_add, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp11_);
		_g_object_unref0 (_tmp11_);
		if (_tmp12_) {
			GeeList* _tmp13_;
			GearyImapMessageFlag* _tmp14_;
			GearyImapMessageFlag* _tmp15_;
			_tmp13_ = _vala_msg_flags_add;
			_tmp14_ = geary_imap_message_flag_get_FLAGGED ();
			_tmp15_ = _tmp14_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEE_TYPE_COLLECTION, GeeCollection), _tmp15_);
		}
		_tmp16_ = geary_email_flags_get_LOAD_REMOTE_IMAGES ();
		_tmp17_ = _tmp16_;
		_tmp18_ = _tmp17_;
		_tmp19_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_add, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp18_);
		_g_object_unref0 (_tmp18_);
		if (_tmp19_) {
			GeeList* _tmp20_;
			GearyImapMessageFlag* _tmp21_;
			GearyImapMessageFlag* _tmp22_;
			_tmp20_ = _vala_msg_flags_add;
			_tmp21_ = geary_imap_message_flag_get_LOAD_REMOTE_IMAGES ();
			_tmp22_ = _tmp21_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, GEE_TYPE_COLLECTION, GeeCollection), _tmp22_);
		}
		_tmp23_ = geary_email_flags_get_DRAFT ();
		_tmp24_ = _tmp23_;
		_tmp25_ = _tmp24_;
		_tmp26_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_add, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp25_);
		_g_object_unref0 (_tmp25_);
		if (_tmp26_) {
			GeeList* _tmp27_;
			GearyImapMessageFlag* _tmp28_;
			GearyImapMessageFlag* _tmp29_;
			_tmp27_ = _vala_msg_flags_add;
			_tmp28_ = geary_imap_message_flag_get_DRAFT ();
			_tmp29_ = _tmp28_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, GEE_TYPE_COLLECTION, GeeCollection), _tmp29_);
		}
		_tmp30_ = geary_email_flags_get_DELETED ();
		_tmp31_ = _tmp30_;
		_tmp32_ = _tmp31_;
		_tmp33_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_add, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp32_);
		_g_object_unref0 (_tmp32_);
		if (_tmp33_) {
			GeeList* _tmp34_;
			GearyImapMessageFlag* _tmp35_;
			GearyImapMessageFlag* _tmp36_;
			_tmp34_ = _vala_msg_flags_add;
			_tmp35_ = geary_imap_message_flag_get_DELETED ();
			_tmp36_ = _tmp35_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, GEE_TYPE_COLLECTION, GeeCollection), _tmp36_);
		}
	}
	if (email_flags_remove != NULL) {
		GearyNamedFlag* _tmp37_;
		GearyNamedFlag* _tmp38_;
		GearyNamedFlag* _tmp39_;
		gboolean _tmp40_;
		GearyNamedFlag* _tmp44_;
		GearyNamedFlag* _tmp45_;
		GearyNamedFlag* _tmp46_;
		gboolean _tmp47_;
		GearyNamedFlag* _tmp51_;
		GearyNamedFlag* _tmp52_;
		GearyNamedFlag* _tmp53_;
		gboolean _tmp54_;
		GearyNamedFlag* _tmp58_;
		GearyNamedFlag* _tmp59_;
		GearyNamedFlag* _tmp60_;
		gboolean _tmp61_;
		GearyNamedFlag* _tmp65_;
		GearyNamedFlag* _tmp66_;
		GearyNamedFlag* _tmp67_;
		gboolean _tmp68_;
		_tmp37_ = geary_email_flags_get_UNREAD ();
		_tmp38_ = _tmp37_;
		_tmp39_ = _tmp38_;
		_tmp40_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_remove, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp39_);
		_g_object_unref0 (_tmp39_);
		if (_tmp40_) {
			GeeList* _tmp41_;
			GearyImapMessageFlag* _tmp42_;
			GearyImapMessageFlag* _tmp43_;
			_tmp41_ = _vala_msg_flags_add;
			_tmp42_ = geary_imap_message_flag_get_SEEN ();
			_tmp43_ = _tmp42_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp41_, GEE_TYPE_COLLECTION, GeeCollection), _tmp43_);
		}
		_tmp44_ = geary_email_flags_get_FLAGGED ();
		_tmp45_ = _tmp44_;
		_tmp46_ = _tmp45_;
		_tmp47_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_remove, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp46_);
		_g_object_unref0 (_tmp46_);
		if (_tmp47_) {
			GeeList* _tmp48_;
			GearyImapMessageFlag* _tmp49_;
			GearyImapMessageFlag* _tmp50_;
			_tmp48_ = _vala_msg_flags_remove;
			_tmp49_ = geary_imap_message_flag_get_FLAGGED ();
			_tmp50_ = _tmp49_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp48_, GEE_TYPE_COLLECTION, GeeCollection), _tmp50_);
		}
		_tmp51_ = geary_email_flags_get_LOAD_REMOTE_IMAGES ();
		_tmp52_ = _tmp51_;
		_tmp53_ = _tmp52_;
		_tmp54_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_remove, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp53_);
		_g_object_unref0 (_tmp53_);
		if (_tmp54_) {
			GeeList* _tmp55_;
			GearyImapMessageFlag* _tmp56_;
			GearyImapMessageFlag* _tmp57_;
			_tmp55_ = _vala_msg_flags_remove;
			_tmp56_ = geary_imap_message_flag_get_LOAD_REMOTE_IMAGES ();
			_tmp57_ = _tmp56_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp55_, GEE_TYPE_COLLECTION, GeeCollection), _tmp57_);
		}
		_tmp58_ = geary_email_flags_get_DRAFT ();
		_tmp59_ = _tmp58_;
		_tmp60_ = _tmp59_;
		_tmp61_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_remove, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp60_);
		_g_object_unref0 (_tmp60_);
		if (_tmp61_) {
			GeeList* _tmp62_;
			GearyImapMessageFlag* _tmp63_;
			GearyImapMessageFlag* _tmp64_;
			_tmp62_ = _vala_msg_flags_remove;
			_tmp63_ = geary_imap_message_flag_get_DRAFT ();
			_tmp64_ = _tmp63_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp62_, GEE_TYPE_COLLECTION, GeeCollection), _tmp64_);
		}
		_tmp65_ = geary_email_flags_get_DELETED ();
		_tmp66_ = _tmp65_;
		_tmp67_ = _tmp66_;
		_tmp68_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (email_flags_remove, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _tmp67_);
		_g_object_unref0 (_tmp67_);
		if (_tmp68_) {
			GeeList* _tmp69_;
			GearyImapMessageFlag* _tmp70_;
			GearyImapMessageFlag* _tmp71_;
			_tmp69_ = _vala_msg_flags_remove;
			_tmp70_ = geary_imap_message_flag_get_DELETED ();
			_tmp71_ = _tmp70_;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp69_, GEE_TYPE_COLLECTION, GeeCollection), _tmp71_);
		}
	}
	if (msg_flags_add) {
		*msg_flags_add = _vala_msg_flags_add;
	} else {
		_g_object_unref0 (_vala_msg_flags_add);
	}
	if (msg_flags_remove) {
		*msg_flags_remove = _vala_msg_flags_remove;
	} else {
		_g_object_unref0 (_vala_msg_flags_remove);
	}
}

/**
     * Returns a keyword suitable for the IMAP SEARCH command.
     *
     * See [[http://tools.ietf.org/html/rfc3501#section-6.4.4]].  This only returns a value for
     * SEARCH's known flag keywords, all of which are system keywords.
     *
     * If present is false, the ''negative'' value is returned.  So, ANSWERED !present is
     * UNANSWERED.  One exception: there is no UNRECENT, and so that will return null.
     */
gchar*
geary_imap_message_flag_get_search_keyword (GearyImapMessageFlag* self,
                                            gboolean present)
{
	GearyImapMessageFlag* _tmp0_;
	GearyImapMessageFlag* _tmp1_;
	GearyImapMessageFlag* _tmp4_;
	GearyImapMessageFlag* _tmp5_;
	GearyImapMessageFlag* _tmp8_;
	GearyImapMessageFlag* _tmp9_;
	GearyImapMessageFlag* _tmp12_;
	GearyImapMessageFlag* _tmp13_;
	GearyImapMessageFlag* _tmp16_;
	GearyImapMessageFlag* _tmp17_;
	GearyImapMessageFlag* _tmp20_;
	GearyImapMessageFlag* _tmp21_;
	gchar* result;
	g_return_val_if_fail (GEARY_IMAP_IS_MESSAGE_FLAG (self), NULL);
	_tmp0_ = geary_imap_message_flag_get_ANSWERED ();
	_tmp1_ = _tmp0_;
	if (gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEARY_IMAP_TYPE_FLAG, GearyImapFlag))) {
		const gchar* _tmp2_ = NULL;
		gchar* _tmp3_;
		if (present) {
			_tmp2_ = "answered";
		} else {
			_tmp2_ = "unanswered";
		}
		_tmp3_ = g_strdup (_tmp2_);
		result = _tmp3_;
		return result;
	}
	_tmp4_ = geary_imap_message_flag_get_DELETED ();
	_tmp5_ = _tmp4_;
	if (gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEARY_IMAP_TYPE_FLAG, GearyImapFlag))) {
		const gchar* _tmp6_ = NULL;
		gchar* _tmp7_;
		if (present) {
			_tmp6_ = "deleted";
		} else {
			_tmp6_ = "undeleted";
		}
		_tmp7_ = g_strdup (_tmp6_);
		result = _tmp7_;
		return result;
	}
	_tmp8_ = geary_imap_message_flag_get_DRAFT ();
	_tmp9_ = _tmp8_;
	if (gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEARY_IMAP_TYPE_FLAG, GearyImapFlag))) {
		const gchar* _tmp10_ = NULL;
		gchar* _tmp11_;
		if (present) {
			_tmp10_ = "draft";
		} else {
			_tmp10_ = "undraft";
		}
		_tmp11_ = g_strdup (_tmp10_);
		result = _tmp11_;
		return result;
	}
	_tmp12_ = geary_imap_message_flag_get_FLAGGED ();
	_tmp13_ = _tmp12_;
	if (gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEARY_IMAP_TYPE_FLAG, GearyImapFlag))) {
		const gchar* _tmp14_ = NULL;
		gchar* _tmp15_;
		if (present) {
			_tmp14_ = "flagged";
		} else {
			_tmp14_ = "unflagged";
		}
		_tmp15_ = g_strdup (_tmp14_);
		result = _tmp15_;
		return result;
	}
	_tmp16_ = geary_imap_message_flag_get_RECENT ();
	_tmp17_ = _tmp16_;
	if (gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, GEARY_IMAP_TYPE_FLAG, GearyImapFlag))) {
		const gchar* _tmp18_ = NULL;
		gchar* _tmp19_;
		if (present) {
			_tmp18_ = "recent";
		} else {
			_tmp18_ = NULL;
		}
		_tmp19_ = g_strdup (_tmp18_);
		result = _tmp19_;
		return result;
	}
	_tmp20_ = geary_imap_message_flag_get_SEEN ();
	_tmp21_ = _tmp20_;
	if (gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (self, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, GEARY_IMAP_TYPE_FLAG, GearyImapFlag))) {
		const gchar* _tmp22_ = NULL;
		gchar* _tmp23_;
		if (present) {
			_tmp22_ = "seen";
		} else {
			_tmp22_ = "unseen";
		}
		_tmp23_ = g_strdup (_tmp22_);
		result = _tmp23_;
		return result;
	}
	result = NULL;
	return result;
}

static void
geary_imap_message_flag_class_init (GearyImapMessageFlagClass * klass,
                                    gpointer klass_data)
{
	geary_imap_message_flag_parent_class = g_type_class_peek_parent (klass);
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_imap_message_flag_get_property;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_message_flag_finalize;
}

static void
geary_imap_message_flag_instance_init (GearyImapMessageFlag * self,
                                       gpointer klass)
{
}

static void
geary_imap_message_flag_finalize (GObject * obj)
{
	GearyImapMessageFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_TYPE_MESSAGE_FLAG, GearyImapMessageFlag);
	G_OBJECT_CLASS (geary_imap_message_flag_parent_class)->finalize (obj);
}

/**
 * An IMAP message (email) flag.
 *
 * See [[http://tools.ietf.org/html/rfc3501#section-2.3.2]]
 *
 * @see StoreCommand
 * @see FetchCommand
 * @see FetchedData
 */
 G_GNUC_NO_INLINE static GType
geary_imap_message_flag_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapMessageFlagClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_message_flag_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapMessageFlag), 0, (GInstanceInitFunc) geary_imap_message_flag_instance_init, NULL };
	GType geary_imap_message_flag_type_id;
	geary_imap_message_flag_type_id = g_type_register_static (GEARY_IMAP_TYPE_FLAG, "GearyImapMessageFlag", &g_define_type_info, 0);
	return geary_imap_message_flag_type_id;
}

GType
geary_imap_message_flag_get_type (void)
{
	static gsize geary_imap_message_flag_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_message_flag_type_id__once)) {
		GType geary_imap_message_flag_type_id;
		geary_imap_message_flag_type_id = geary_imap_message_flag_get_type_once ();
		g_once_init_leave (&geary_imap_message_flag_type_id__once, geary_imap_message_flag_type_id);
	}
	return geary_imap_message_flag_type_id__once;
}

static void
_vala_geary_imap_message_flag_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec)
{
	GearyImapMessageFlag * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_TYPE_MESSAGE_FLAG, GearyImapMessageFlag);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

