/* imap-namespace.c generated by valac 0.56.19, the Vala compiler
 * generated from imap-namespace.vala, do not modify */

/*
 * Copyright 2016 Michael Gratton <mike@vee.net>
 *
 * 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 <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_IMAP_NAMESPACE_0_PROPERTY,
	GEARY_IMAP_NAMESPACE_PREFIX_PROPERTY,
	GEARY_IMAP_NAMESPACE_DELIM_PROPERTY,
	GEARY_IMAP_NAMESPACE_NUM_PROPERTIES
};
static GParamSpec* geary_imap_namespace_properties[GEARY_IMAP_NAMESPACE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _GearyImapNamespacePrivate {
	gchar* _prefix;
	gchar* _delim;
};

static gint GearyImapNamespace_private_offset;
static gpointer geary_imap_namespace_parent_class = NULL;

static void geary_imap_namespace_set_prefix (GearyImapNamespace* self,
                                      const gchar* value);
static void geary_imap_namespace_set_delim (GearyImapNamespace* self,
                                     const gchar* value);
static void geary_imap_namespace_finalize (GObject * obj);
static GType geary_imap_namespace_get_type_once (void);
static void _vala_geary_imap_namespace_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec);
static void _vala_geary_imap_namespace_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec);

static inline gpointer
geary_imap_namespace_get_instance_private (GearyImapNamespace* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapNamespace_private_offset);
}

const gchar*
geary_imap_namespace_get_prefix (GearyImapNamespace* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_IS_NAMESPACE (self), NULL);
	_tmp0_ = self->priv->_prefix;
	result = _tmp0_;
	return result;
}

static void
geary_imap_namespace_set_prefix (GearyImapNamespace* self,
                                 const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (GEARY_IMAP_IS_NAMESPACE (self));
	old_value = geary_imap_namespace_get_prefix (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_prefix);
		self->priv->_prefix = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_namespace_properties[GEARY_IMAP_NAMESPACE_PREFIX_PROPERTY]);
	}
}

const gchar*
geary_imap_namespace_get_delim (GearyImapNamespace* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_IS_NAMESPACE (self), NULL);
	_tmp0_ = self->priv->_delim;
	result = _tmp0_;
	return result;
}

static void
geary_imap_namespace_set_delim (GearyImapNamespace* self,
                                const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (GEARY_IMAP_IS_NAMESPACE (self));
	old_value = geary_imap_namespace_get_delim (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_delim);
		self->priv->_delim = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_namespace_properties[GEARY_IMAP_NAMESPACE_DELIM_PROPERTY]);
	}
}

GearyImapNamespace*
geary_imap_namespace_construct (GType object_type,
                                const gchar* prefix,
                                const gchar* delim)
{
	GearyImapNamespace * self = NULL;
	g_return_val_if_fail (prefix != NULL, NULL);
	self = (GearyImapNamespace*) geary_base_object_construct (object_type);
	geary_imap_namespace_set_prefix (self, prefix);
	geary_imap_namespace_set_delim (self, delim);
	return self;
}

GearyImapNamespace*
geary_imap_namespace_new (const gchar* prefix,
                          const gchar* delim)
{
	return geary_imap_namespace_construct (GEARY_IMAP_TYPE_NAMESPACE, prefix, delim);
}

gchar*
geary_imap_namespace_to_string (GearyImapNamespace* self)
{
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (GEARY_IMAP_IS_NAMESPACE (self), NULL);
	_tmp1_ = self->priv->_delim;
	_tmp0_ = _tmp1_;
	if (_tmp0_ == NULL) {
		_tmp0_ = "NIL";
	}
	_tmp2_ = self->priv->_prefix;
	_tmp3_ = g_strdup_printf ("(%s,%s)", _tmp2_, _tmp0_);
	result = _tmp3_;
	return result;
}

static void
geary_imap_namespace_class_init (GearyImapNamespaceClass * klass,
                                 gpointer klass_data)
{
	geary_imap_namespace_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapNamespace_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_imap_namespace_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_geary_imap_namespace_set_property;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_namespace_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_NAMESPACE_PREFIX_PROPERTY, geary_imap_namespace_properties[GEARY_IMAP_NAMESPACE_PREFIX_PROPERTY] = g_param_spec_string ("prefix", "prefix", "prefix", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_NAMESPACE_DELIM_PROPERTY, geary_imap_namespace_properties[GEARY_IMAP_NAMESPACE_DELIM_PROPERTY] = g_param_spec_string ("delim", "delim", "delim", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
geary_imap_namespace_instance_init (GearyImapNamespace * self,
                                    gpointer klass)
{
	self->priv = geary_imap_namespace_get_instance_private (self);
}

static void
geary_imap_namespace_finalize (GObject * obj)
{
	GearyImapNamespace * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_TYPE_NAMESPACE, GearyImapNamespace);
	_g_free0 (self->priv->_prefix);
	_g_free0 (self->priv->_delim);
	G_OBJECT_CLASS (geary_imap_namespace_parent_class)->finalize (obj);
}

/**
 * Namespace component in a response for a NAMESPACE command.
 *
 * @see Geary.Imap.NamespaceCommand
 */
 G_GNUC_NO_INLINE static GType
geary_imap_namespace_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapNamespaceClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_namespace_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapNamespace), 0, (GInstanceInitFunc) geary_imap_namespace_instance_init, NULL };
	GType geary_imap_namespace_type_id;
	geary_imap_namespace_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "GearyImapNamespace", &g_define_type_info, 0);
	GearyImapNamespace_private_offset = g_type_add_instance_private (geary_imap_namespace_type_id, sizeof (GearyImapNamespacePrivate));
	return geary_imap_namespace_type_id;
}

GType
geary_imap_namespace_get_type (void)
{
	static gsize geary_imap_namespace_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_namespace_type_id__once)) {
		GType geary_imap_namespace_type_id;
		geary_imap_namespace_type_id = geary_imap_namespace_get_type_once ();
		g_once_init_leave (&geary_imap_namespace_type_id__once, geary_imap_namespace_type_id);
	}
	return geary_imap_namespace_type_id__once;
}

static void
_vala_geary_imap_namespace_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec)
{
	GearyImapNamespace * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_TYPE_NAMESPACE, GearyImapNamespace);
	switch (property_id) {
		case GEARY_IMAP_NAMESPACE_PREFIX_PROPERTY:
		g_value_set_string (value, geary_imap_namespace_get_prefix (self));
		break;
		case GEARY_IMAP_NAMESPACE_DELIM_PROPERTY:
		g_value_set_string (value, geary_imap_namespace_get_delim (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_geary_imap_namespace_set_property (GObject * object,
                                         guint property_id,
                                         const GValue * value,
                                         GParamSpec * pspec)
{
	GearyImapNamespace * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_TYPE_NAMESPACE, GearyImapNamespace);
	switch (property_id) {
		case GEARY_IMAP_NAMESPACE_PREFIX_PROPERTY:
		geary_imap_namespace_set_prefix (self, g_value_get_string (value));
		break;
		case GEARY_IMAP_NAMESPACE_DELIM_PROPERTY:
		geary_imap_namespace_set_delim (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

