/* imap-nil-parameter.c generated by valac 0.56.19, the Vala compiler
 * generated from imap-nil-parameter.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 <gio/gio.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_IMAP_NIL_PARAMETER_0_PROPERTY,
	GEARY_IMAP_NIL_PARAMETER_NUM_PROPERTIES
};
static GParamSpec* geary_imap_nil_parameter_properties[GEARY_IMAP_NIL_PARAMETER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer geary_imap_nil_parameter_parent_class = NULL;
static GearyImapNilParameter* geary_imap_nil_parameter__instance;
static GearyImapNilParameter* geary_imap_nil_parameter__instance = NULL;

static GearyImapNilParameter* geary_imap_nil_parameter_new (void);
static GearyImapNilParameter* geary_imap_nil_parameter_construct (GType object_type);
static void geary_imap_nil_parameter_real_serialize (GearyImapParameter* base,
                                              GearyImapSerializer* ser,
                                              GCancellable* cancellable,
                                              GError** error);
static gchar* geary_imap_nil_parameter_real_to_string (GearyImapParameter* base);
static void geary_imap_nil_parameter_finalize (GObject * obj);
static GType geary_imap_nil_parameter_get_type_once (void);
static void _vala_geary_imap_nil_parameter_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);

GearyImapNilParameter*
geary_imap_nil_parameter_get_instance (void)
{
	GearyImapNilParameter* result;
	GearyImapNilParameter* _tmp0_;
	GearyImapNilParameter* _tmp2_;
	_tmp0_ = geary_imap_nil_parameter__instance;
	if (_tmp0_ == NULL) {
		GearyImapNilParameter* _tmp1_;
		_tmp1_ = geary_imap_nil_parameter_new ();
		_g_object_unref0 (geary_imap_nil_parameter__instance);
		geary_imap_nil_parameter__instance = _tmp1_;
	}
	_tmp2_ = geary_imap_nil_parameter__instance;
	result = _tmp2_;
	return result;
}

static GearyImapNilParameter*
geary_imap_nil_parameter_construct (GType object_type)
{
	GearyImapNilParameter * self = NULL;
	self = (GearyImapNilParameter*) geary_imap_parameter_construct (object_type);
	return self;
}

static GearyImapNilParameter*
geary_imap_nil_parameter_new (void)
{
	return geary_imap_nil_parameter_construct (GEARY_IMAP_TYPE_NIL_PARAMETER);
}

/**
     * See note at {@link NilParameter} for comparison rules of "NIL".
     *
     * In particular, this should not be used when expecting an atom.  A mailbox name of NIL
     * means that the mailbox is actually named NIL and does not represent an empty string or empty
     * list.
     */
gboolean
geary_imap_nil_parameter_is_nil (GearyImapStringParameter* stringp)
{
	gboolean result;
	g_return_val_if_fail (GEARY_IMAP_IS_STRING_PARAMETER (stringp), FALSE);
	result = geary_imap_string_parameter_equals_ci (stringp, GEARY_IMAP_NIL_PARAMETER_VALUE);
	return result;
}

/**
     * {@inheritDoc}
     */
static void
geary_imap_nil_parameter_real_serialize (GearyImapParameter* base,
                                         GearyImapSerializer* ser,
                                         GCancellable* cancellable,
                                         GError** error)
{
	GearyImapNilParameter * self;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_TYPE_NIL_PARAMETER, GearyImapNilParameter);
	g_return_if_fail (GEARY_IMAP_IS_SERIALIZER (ser));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	geary_imap_serializer_push_nil (ser, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

/**
     * {@inheritDoc}
     */
static gchar*
geary_imap_nil_parameter_real_to_string (GearyImapParameter* base)
{
	GearyImapNilParameter * self;
	gchar* _tmp0_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_TYPE_NIL_PARAMETER, GearyImapNilParameter);
	_tmp0_ = g_strdup (GEARY_IMAP_NIL_PARAMETER_VALUE);
	result = _tmp0_;
	return result;
}

static void
geary_imap_nil_parameter_class_init (GearyImapNilParameterClass * klass,
                                     gpointer klass_data)
{
	geary_imap_nil_parameter_parent_class = g_type_class_peek_parent (klass);
	((GearyImapParameterClass *) klass)->serialize = (void (*) (GearyImapParameter*, GearyImapSerializer*, GCancellable*, GError**)) geary_imap_nil_parameter_real_serialize;
	((GearyImapParameterClass *) klass)->to_string = (gchar* (*) (GearyImapParameter*)) geary_imap_nil_parameter_real_to_string;
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_imap_nil_parameter_get_property;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_nil_parameter_finalize;
}

static void
geary_imap_nil_parameter_instance_init (GearyImapNilParameter * self,
                                        gpointer klass)
{
}

static void
geary_imap_nil_parameter_finalize (GObject * obj)
{
	GearyImapNilParameter * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_TYPE_NIL_PARAMETER, GearyImapNilParameter);
	G_OBJECT_CLASS (geary_imap_nil_parameter_parent_class)->finalize (obj);
}

/**
 * The representation of IMAP's NIL value.
 *
 * Note that NIL 'represents the non-existence of a particular data item that is represented as a
 * string or parenthesized list, as distinct from the empty string "" or the empty parenthesized
 * list () ... NIL is never used for any data item which takes the form of an atom."
 *
 * Since there's only one form of a NilParameter, it should be retrieved via the {@link instance}
 * property.
 *
 * See [[http://tools.ietf.org/html/rfc3501#section-4.5]]
 */
 G_GNUC_NO_INLINE static GType
geary_imap_nil_parameter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapNilParameterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_nil_parameter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapNilParameter), 0, (GInstanceInitFunc) geary_imap_nil_parameter_instance_init, NULL };
	GType geary_imap_nil_parameter_type_id;
	geary_imap_nil_parameter_type_id = g_type_register_static (GEARY_IMAP_TYPE_PARAMETER, "GearyImapNilParameter", &g_define_type_info, 0);
	return geary_imap_nil_parameter_type_id;
}

GType
geary_imap_nil_parameter_get_type (void)
{
	static gsize geary_imap_nil_parameter_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_nil_parameter_type_id__once)) {
		GType geary_imap_nil_parameter_type_id;
		geary_imap_nil_parameter_type_id = geary_imap_nil_parameter_get_type_once ();
		g_once_init_leave (&geary_imap_nil_parameter_type_id__once, geary_imap_nil_parameter_type_id);
	}
	return geary_imap_nil_parameter_type_id__once;
}

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

