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

enum  {
	GEARY_EMAIL_PROPERTIES_0_PROPERTY,
	GEARY_EMAIL_PROPERTIES_DATE_RECEIVED_PROPERTY,
	GEARY_EMAIL_PROPERTIES_TOTAL_BYTES_PROPERTY,
	GEARY_EMAIL_PROPERTIES_NUM_PROPERTIES
};
static GParamSpec* geary_email_properties_properties[GEARY_EMAIL_PROPERTIES_NUM_PROPERTIES];
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

struct _GearyEmailPropertiesPrivate {
	GDateTime* _date_received;
	gint64 _total_bytes;
};

static gint GearyEmailProperties_private_offset;
static gpointer geary_email_properties_parent_class = NULL;

static gchar* geary_email_properties_real_to_string (GearyEmailProperties* self);
static void geary_email_properties_finalize (GObject * obj);
static GType geary_email_properties_get_type_once (void);
static void _vala_geary_email_properties_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_geary_email_properties_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);

static inline gpointer
geary_email_properties_get_instance_private (GearyEmailProperties* self)
{
	return G_STRUCT_MEMBER_P (self, GearyEmailProperties_private_offset);
}

GDateTime*
geary_email_properties_get_date_received (GearyEmailProperties* self)
{
	GDateTime* result;
	GDateTime* _tmp0_;
	g_return_val_if_fail (GEARY_IS_EMAIL_PROPERTIES (self), NULL);
	_tmp0_ = self->priv->_date_received;
	result = _tmp0_;
	return result;
}

static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

void
geary_email_properties_set_date_received (GearyEmailProperties* self,
                                          GDateTime* value)
{
	GDateTime* old_value;
	g_return_if_fail (GEARY_IS_EMAIL_PROPERTIES (self));
	old_value = geary_email_properties_get_date_received (self);
	if (old_value != value) {
		GDateTime* _tmp0_;
		_tmp0_ = _g_date_time_ref0 (value);
		_g_date_time_unref0 (self->priv->_date_received);
		self->priv->_date_received = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_email_properties_properties[GEARY_EMAIL_PROPERTIES_DATE_RECEIVED_PROPERTY]);
	}
}

gint64
geary_email_properties_get_total_bytes (GearyEmailProperties* self)
{
	gint64 result;
	g_return_val_if_fail (GEARY_IS_EMAIL_PROPERTIES (self), -1LL);
	result = self->priv->_total_bytes;
	return result;
}

void
geary_email_properties_set_total_bytes (GearyEmailProperties* self,
                                        gint64 value)
{
	gint64 old_value;
	g_return_if_fail (GEARY_IS_EMAIL_PROPERTIES (self));
	old_value = geary_email_properties_get_total_bytes (self);
	if (old_value != value) {
		self->priv->_total_bytes = value;
		g_object_notify_by_pspec ((GObject *) self, geary_email_properties_properties[GEARY_EMAIL_PROPERTIES_TOTAL_BYTES_PROPERTY]);
	}
}

GearyEmailProperties*
geary_email_properties_construct (GType object_type,
                                  GDateTime* date_received,
                                  gint64 total_bytes)
{
	GearyEmailProperties * self = NULL;
	g_return_val_if_fail (date_received != NULL, NULL);
	self = (GearyEmailProperties*) geary_base_object_construct (object_type);
	geary_email_properties_set_date_received (self, date_received);
	geary_email_properties_set_total_bytes (self, total_bytes);
	return self;
}

static gchar*
geary_email_properties_real_to_string (GearyEmailProperties* self)
{
	g_critical ("Type `%s' does not implement abstract method `geary_email_properties_to_string'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

gchar*
geary_email_properties_to_string (GearyEmailProperties* self)
{
	GearyEmailPropertiesClass* _klass_;
	g_return_val_if_fail (GEARY_IS_EMAIL_PROPERTIES (self), NULL);
	_klass_ = GEARY_EMAIL_PROPERTIES_GET_CLASS (self);
	if (_klass_->to_string) {
		return _klass_->to_string (self);
	}
	return NULL;
}

static void
geary_email_properties_class_init (GearyEmailPropertiesClass * klass,
                                   gpointer klass_data)
{
	geary_email_properties_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyEmailProperties_private_offset);
	((GearyEmailPropertiesClass *) klass)->to_string = (gchar* (*) (GearyEmailProperties*)) geary_email_properties_real_to_string;
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_email_properties_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_geary_email_properties_set_property;
	G_OBJECT_CLASS (klass)->finalize = geary_email_properties_finalize;
	/**
	     * date_received may be the date/time received on the server or in the local store, depending
	     * on whether the information is available on the server.  For example, with IMAP, this is
	     * the INTERNALDATE supplied by the server.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_EMAIL_PROPERTIES_DATE_RECEIVED_PROPERTY, geary_email_properties_properties[GEARY_EMAIL_PROPERTIES_DATE_RECEIVED_PROPERTY] = g_param_spec_boxed ("date-received", "date-received", "date-received", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Total size of the email (header and body) in bytes.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_EMAIL_PROPERTIES_TOTAL_BYTES_PROPERTY, geary_email_properties_properties[GEARY_EMAIL_PROPERTIES_TOTAL_BYTES_PROPERTY] = g_param_spec_int64 ("total-bytes", "total-bytes", "total-bytes", G_MININT64, G_MAXINT64, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
geary_email_properties_instance_init (GearyEmailProperties * self,
                                      gpointer klass)
{
	self->priv = geary_email_properties_get_instance_private (self);
}

static void
geary_email_properties_finalize (GObject * obj)
{
	GearyEmailProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_TYPE_EMAIL_PROPERTIES, GearyEmailProperties);
	_g_date_time_unref0 (self->priv->_date_received);
	G_OBJECT_CLASS (geary_email_properties_parent_class)->finalize (obj);
}

/**
 * EmailProperties holds (in general) immutable metadata about an Email.  EmailFlags used to be
 * held here and retrieved via Email.Field.PROPERTIES, but as they're mutable, they were broken out
 * for efficiency reasons.
 *
 * EmailProperties may be expanded in the future to supply details like when the message was added
 * to the local store, checksums, and so forth.
 */
 G_GNUC_NO_INLINE static GType
geary_email_properties_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyEmailPropertiesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_email_properties_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyEmailProperties), 0, (GInstanceInitFunc) geary_email_properties_instance_init, NULL };
	GType geary_email_properties_type_id;
	geary_email_properties_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "GearyEmailProperties", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	GearyEmailProperties_private_offset = g_type_add_instance_private (geary_email_properties_type_id, sizeof (GearyEmailPropertiesPrivate));
	return geary_email_properties_type_id;
}

GType
geary_email_properties_get_type (void)
{
	static gsize geary_email_properties_type_id__once = 0;
	if (g_once_init_enter (&geary_email_properties_type_id__once)) {
		GType geary_email_properties_type_id;
		geary_email_properties_type_id = geary_email_properties_get_type_once ();
		g_once_init_leave (&geary_email_properties_type_id__once, geary_email_properties_type_id);
	}
	return geary_email_properties_type_id__once;
}

static void
_vala_geary_email_properties_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	GearyEmailProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_TYPE_EMAIL_PROPERTIES, GearyEmailProperties);
	switch (property_id) {
		case GEARY_EMAIL_PROPERTIES_DATE_RECEIVED_PROPERTY:
		g_value_set_boxed (value, geary_email_properties_get_date_received (self));
		break;
		case GEARY_EMAIL_PROPERTIES_TOTAL_BYTES_PROPERTY:
		g_value_set_int64 (value, geary_email_properties_get_total_bytes (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_geary_email_properties_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	GearyEmailProperties * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_TYPE_EMAIL_PROPERTIES, GearyEmailProperties);
	switch (property_id) {
		case GEARY_EMAIL_PROPERTIES_DATE_RECEIVED_PROPERTY:
		geary_email_properties_set_date_received (self, g_value_get_boxed (value));
		break;
		case GEARY_EMAIL_PROPERTIES_TOTAL_BYTES_PROPERTY:
		geary_email_properties_set_total_bytes (self, g_value_get_int64 (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

