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

enum  {
	GEARY_IMAP_EMAIL_PROPERTIES_0_PROPERTY,
	GEARY_IMAP_EMAIL_PROPERTIES_INTERNALDATE_PROPERTY,
	GEARY_IMAP_EMAIL_PROPERTIES_RFC822_SIZE_PROPERTY,
	GEARY_IMAP_EMAIL_PROPERTIES_NUM_PROPERTIES
};
static GParamSpec* geary_imap_email_properties_properties[GEARY_IMAP_EMAIL_PROPERTIES_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GearyImapEmailPropertiesPrivate {
	GearyImapInternalDate* _internaldate;
	GearyImapRFC822Size* _rfc822_size;
};

static gint GearyImapEmailProperties_private_offset;
static gpointer geary_imap_email_properties_parent_class = NULL;
static GeeHashableIface * geary_imap_email_properties_gee_hashable_parent_iface = NULL;

static void geary_imap_email_properties_set_internaldate (GearyImapEmailProperties* self,
                                                   GearyImapInternalDate* value);
static void geary_imap_email_properties_set_rfc822_size (GearyImapEmailProperties* self,
                                                  GearyImapRFC822Size* value);
static gboolean geary_imap_email_properties_real_equal_to (GeeHashable* base,
                                                    GearyImapEmailProperties* other);
static guint geary_imap_email_properties_real_hash (GeeHashable* base);
static gchar* geary_imap_email_properties_real_to_string (GearyEmailProperties* base);
static void geary_imap_email_properties_finalize (GObject * obj);
static GType geary_imap_email_properties_get_type_once (void);
static void _vala_geary_imap_email_properties_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec);
static void _vala_geary_imap_email_properties_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec);

static inline gpointer
geary_imap_email_properties_get_instance_private (GearyImapEmailProperties* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEmailProperties_private_offset);
}

GearyImapInternalDate*
geary_imap_email_properties_get_internaldate (GearyImapEmailProperties* self)
{
	GearyImapInternalDate* result;
	GearyImapInternalDate* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_IS_EMAIL_PROPERTIES (self), NULL);
	_tmp0_ = self->priv->_internaldate;
	result = _tmp0_;
	return result;
}

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

static void
geary_imap_email_properties_set_internaldate (GearyImapEmailProperties* self,
                                              GearyImapInternalDate* value)
{
	GearyImapInternalDate* old_value;
	g_return_if_fail (GEARY_IMAP_IS_EMAIL_PROPERTIES (self));
	old_value = geary_imap_email_properties_get_internaldate (self);
	if (old_value != value) {
		GearyImapInternalDate* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_internaldate);
		self->priv->_internaldate = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_email_properties_properties[GEARY_IMAP_EMAIL_PROPERTIES_INTERNALDATE_PROPERTY]);
	}
}

GearyImapRFC822Size*
geary_imap_email_properties_get_rfc822_size (GearyImapEmailProperties* self)
{
	GearyImapRFC822Size* result;
	GearyImapRFC822Size* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_IS_EMAIL_PROPERTIES (self), NULL);
	_tmp0_ = self->priv->_rfc822_size;
	result = _tmp0_;
	return result;
}

static void
geary_imap_email_properties_set_rfc822_size (GearyImapEmailProperties* self,
                                             GearyImapRFC822Size* value)
{
	GearyImapRFC822Size* old_value;
	g_return_if_fail (GEARY_IMAP_IS_EMAIL_PROPERTIES (self));
	old_value = geary_imap_email_properties_get_rfc822_size (self);
	if (old_value != value) {
		GearyImapRFC822Size* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_rfc822_size);
		self->priv->_rfc822_size = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_email_properties_properties[GEARY_IMAP_EMAIL_PROPERTIES_RFC822_SIZE_PROPERTY]);
	}
}

GearyImapEmailProperties*
geary_imap_email_properties_construct (GType object_type,
                                       GearyImapInternalDate* internaldate,
                                       GearyImapRFC822Size* rfc822_size)
{
	GearyImapEmailProperties * self = NULL;
	GDateTime* _tmp0_;
	GDateTime* _tmp1_;
	gint64 _tmp2_;
	gint64 _tmp3_;
	g_return_val_if_fail (GEARY_IMAP_IS_INTERNAL_DATE (internaldate), NULL);
	g_return_val_if_fail (GEARY_IMAP_IS_RF_C822_SIZE (rfc822_size), NULL);
	_tmp0_ = geary_imap_internal_date_get_value (internaldate);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_message_data_int64_message_data_get_value (G_TYPE_CHECK_INSTANCE_CAST (rfc822_size, GEARY_MESSAGE_DATA_TYPE_INT64_MESSAGE_DATA, GearyMessageDataInt64MessageData));
	_tmp3_ = _tmp2_;
	self = (GearyImapEmailProperties*) geary_email_properties_construct (object_type, _tmp1_, _tmp3_);
	geary_imap_email_properties_set_internaldate (self, internaldate);
	geary_imap_email_properties_set_rfc822_size (self, rfc822_size);
	return self;
}

GearyImapEmailProperties*
geary_imap_email_properties_new (GearyImapInternalDate* internaldate,
                                 GearyImapRFC822Size* rfc822_size)
{
	return geary_imap_email_properties_construct (GEARY_IMAP_TYPE_EMAIL_PROPERTIES, internaldate, rfc822_size);
}

static gboolean
geary_imap_email_properties_real_equal_to (GeeHashable* base,
                                           GearyImapEmailProperties* other)
{
	GearyImapEmailProperties * self;
	gboolean _tmp0_ = FALSE;
	GearyImapInternalDate* _tmp1_;
	gboolean _tmp3_ = FALSE;
	GearyImapRFC822Size* _tmp4_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_TYPE_EMAIL_PROPERTIES, GearyImapEmailProperties);
	g_return_val_if_fail (GEARY_IMAP_IS_EMAIL_PROPERTIES (other), FALSE);
	if (self == other) {
		result = TRUE;
		return result;
	}
	_tmp1_ = self->priv->_internaldate;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GearyImapInternalDate* _tmp2_;
		_tmp2_ = other->priv->_internaldate;
		_tmp0_ = _tmp2_ == NULL;
	}
	if (_tmp0_) {
		result = FALSE;
		return result;
	}
	_tmp4_ = self->priv->_rfc822_size;
	if (_tmp4_ == NULL) {
		_tmp3_ = TRUE;
	} else {
		GearyImapRFC822Size* _tmp5_;
		_tmp5_ = other->priv->_rfc822_size;
		_tmp3_ = _tmp5_ == NULL;
	}
	if (_tmp3_) {
		result = FALSE;
		return result;
	}
	result = TRUE;
	return result;
}

static guint
geary_imap_email_properties_real_hash (GeeHashable* base)
{
	GearyImapEmailProperties * self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	guint _tmp2_;
	guint result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_TYPE_EMAIL_PROPERTIES, GearyImapEmailProperties);
	_tmp0_ = geary_email_properties_to_string (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_EMAIL_PROPERTIES, GearyEmailProperties));
	_tmp1_ = _tmp0_;
	_tmp2_ = g_str_hash (_tmp1_);
	_g_free0 (_tmp1_);
	result = _tmp2_;
	return result;
}

static gchar*
geary_imap_email_properties_real_to_string (GearyEmailProperties* base)
{
	GearyImapEmailProperties * self;
	gchar* _tmp0_ = NULL;
	GearyImapInternalDate* _tmp1_;
	gchar* _tmp5_ = NULL;
	GearyImapRFC822Size* _tmp6_;
	gchar* _tmp10_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_TYPE_EMAIL_PROPERTIES, GearyImapEmailProperties);
	_tmp1_ = self->priv->_internaldate;
	if (_tmp1_ != NULL) {
		GearyImapInternalDate* _tmp2_;
		gchar* _tmp3_;
		_tmp2_ = self->priv->_internaldate;
		_tmp3_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp3_;
	} else {
		gchar* _tmp4_;
		_tmp4_ = g_strdup ("(none)");
		_g_free0 (_tmp0_);
		_tmp0_ = _tmp4_;
	}
	_tmp6_ = self->priv->_rfc822_size;
	if (_tmp6_ != NULL) {
		GearyImapRFC822Size* _tmp7_;
		gchar* _tmp8_;
		_tmp7_ = self->priv->_rfc822_size;
		_tmp8_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_g_free0 (_tmp5_);
		_tmp5_ = _tmp8_;
	} else {
		gchar* _tmp9_;
		_tmp9_ = g_strdup ("(none)");
		_g_free0 (_tmp5_);
		_tmp5_ = _tmp9_;
	}
	_tmp10_ = g_strdup_printf ("internaldate:%s/size:%s", _tmp0_, _tmp5_);
	result = _tmp10_;
	_g_free0 (_tmp5_);
	_g_free0 (_tmp0_);
	return result;
}

static void
geary_imap_email_properties_class_init (GearyImapEmailPropertiesClass * klass,
                                        gpointer klass_data)
{
	geary_imap_email_properties_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEmailProperties_private_offset);
	((GearyEmailPropertiesClass *) klass)->to_string = (gchar* (*) (GearyEmailProperties*)) geary_imap_email_properties_real_to_string;
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_imap_email_properties_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_geary_imap_email_properties_set_property;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_email_properties_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_EMAIL_PROPERTIES_INTERNALDATE_PROPERTY, geary_imap_email_properties_properties[GEARY_IMAP_EMAIL_PROPERTIES_INTERNALDATE_PROPERTY] = g_param_spec_object ("internaldate", "internaldate", "internaldate", GEARY_IMAP_TYPE_INTERNAL_DATE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_EMAIL_PROPERTIES_RFC822_SIZE_PROPERTY, geary_imap_email_properties_properties[GEARY_IMAP_EMAIL_PROPERTIES_RFC822_SIZE_PROPERTY] = g_param_spec_object ("rfc822-size", "rfc822-size", "rfc822-size", GEARY_IMAP_TYPE_RF_C822_SIZE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
geary_imap_email_properties_gee_hashable_interface_init (GeeHashableIface * iface,
                                                         gpointer iface_data)
{
	geary_imap_email_properties_gee_hashable_parent_iface = g_type_interface_peek_parent (iface);
	iface->equal_to = (gboolean (*) (GeeHashable*, gconstpointer)) geary_imap_email_properties_real_equal_to;
	iface->hash = (guint (*) (GeeHashable*)) geary_imap_email_properties_real_hash;
}

static void
geary_imap_email_properties_instance_init (GearyImapEmailProperties * self,
                                           gpointer klass)
{
	self->priv = geary_imap_email_properties_get_instance_private (self);
}

static void
geary_imap_email_properties_finalize (GObject * obj)
{
	GearyImapEmailProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_TYPE_EMAIL_PROPERTIES, GearyImapEmailProperties);
	_g_object_unref0 (self->priv->_internaldate);
	_g_object_unref0 (self->priv->_rfc822_size);
	G_OBJECT_CLASS (geary_imap_email_properties_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
geary_imap_email_properties_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEmailPropertiesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_email_properties_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEmailProperties), 0, (GInstanceInitFunc) geary_imap_email_properties_instance_init, NULL };
	static const GInterfaceInfo gee_hashable_info = { (GInterfaceInitFunc) geary_imap_email_properties_gee_hashable_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType geary_imap_email_properties_type_id;
	geary_imap_email_properties_type_id = g_type_register_static (GEARY_TYPE_EMAIL_PROPERTIES, "GearyImapEmailProperties", &g_define_type_info, 0);
	g_type_add_interface_static (geary_imap_email_properties_type_id, GEE_TYPE_HASHABLE, &gee_hashable_info);
	GearyImapEmailProperties_private_offset = g_type_add_instance_private (geary_imap_email_properties_type_id, sizeof (GearyImapEmailPropertiesPrivate));
	return geary_imap_email_properties_type_id;
}

GType
geary_imap_email_properties_get_type (void)
{
	static gsize geary_imap_email_properties_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_email_properties_type_id__once)) {
		GType geary_imap_email_properties_type_id;
		geary_imap_email_properties_type_id = geary_imap_email_properties_get_type_once ();
		g_once_init_leave (&geary_imap_email_properties_type_id__once, geary_imap_email_properties_type_id);
	}
	return geary_imap_email_properties_type_id__once;
}

static void
_vala_geary_imap_email_properties_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec)
{
	GearyImapEmailProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_TYPE_EMAIL_PROPERTIES, GearyImapEmailProperties);
	switch (property_id) {
		case GEARY_IMAP_EMAIL_PROPERTIES_INTERNALDATE_PROPERTY:
		g_value_set_object (value, geary_imap_email_properties_get_internaldate (self));
		break;
		case GEARY_IMAP_EMAIL_PROPERTIES_RFC822_SIZE_PROPERTY:
		g_value_set_object (value, geary_imap_email_properties_get_rfc822_size (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_geary_imap_email_properties_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec)
{
	GearyImapEmailProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_TYPE_EMAIL_PROPERTIES, GearyImapEmailProperties);
	switch (property_id) {
		case GEARY_IMAP_EMAIL_PROPERTIES_INTERNALDATE_PROPERTY:
		geary_imap_email_properties_set_internaldate (self, g_value_get_object (value));
		break;
		case GEARY_IMAP_EMAIL_PROPERTIES_RFC822_SIZE_PROPERTY:
		geary_imap_email_properties_set_rfc822_size (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

