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

enum  {
	GEARY_IMAP_QUOTED_STRING_PARAMETER_0_PROPERTY,
	GEARY_IMAP_QUOTED_STRING_PARAMETER_NUM_PROPERTIES
};
static GParamSpec* geary_imap_quoted_string_parameter_properties[GEARY_IMAP_QUOTED_STRING_PARAMETER_NUM_PROPERTIES];

static gpointer geary_imap_quoted_string_parameter_parent_class = NULL;

static gchar* geary_imap_quoted_string_parameter_real_to_string (GearyImapParameter* base);
static void geary_imap_quoted_string_parameter_real_serialize (GearyImapParameter* base,
                                                        GearyImapSerializer* ser,
                                                        GCancellable* cancellable,
                                                        GError** error);
static GType geary_imap_quoted_string_parameter_get_type_once (void);

GearyImapQuotedStringParameter*
geary_imap_quoted_string_parameter_construct (GType object_type,
                                              const gchar* ascii)
{
	GearyImapQuotedStringParameter * self = NULL;
	g_return_val_if_fail (ascii != NULL, NULL);
	self = (GearyImapQuotedStringParameter*) geary_imap_string_parameter_construct (object_type, ascii);
	return self;
}

GearyImapQuotedStringParameter*
geary_imap_quoted_string_parameter_new (const gchar* ascii)
{
	return geary_imap_quoted_string_parameter_construct (GEARY_IMAP_TYPE_QUOTED_STRING_PARAMETER, ascii);
}

/**
     * {@inheritDoc}
     */
static gchar*
geary_imap_quoted_string_parameter_real_to_string (GearyImapParameter* base)
{
	GearyImapQuotedStringParameter * self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_TYPE_QUOTED_STRING_PARAMETER, GearyImapQuotedStringParameter);
	_tmp0_ = geary_imap_string_parameter_get_ascii (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_STRING_PARAMETER, GearyImapStringParameter));
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strdup_printf ("\"%s\"", _tmp1_);
	result = _tmp2_;
	return result;
}

/**
     * {@inheritDoc}
     */
static void
geary_imap_quoted_string_parameter_real_serialize (GearyImapParameter* base,
                                                   GearyImapSerializer* ser,
                                                   GCancellable* cancellable,
                                                   GError** error)
{
	GearyImapQuotedStringParameter * self;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_TYPE_QUOTED_STRING_PARAMETER, GearyImapQuotedStringParameter);
	g_return_if_fail (GEARY_IMAP_IS_SERIALIZER (ser));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_tmp0_ = geary_imap_string_parameter_get_ascii (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_STRING_PARAMETER, GearyImapStringParameter));
	_tmp1_ = _tmp0_;
	geary_imap_serializer_push_quoted_string (ser, _tmp1_, cancellable, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

static void
geary_imap_quoted_string_parameter_class_init (GearyImapQuotedStringParameterClass * klass,
                                               gpointer klass_data)
{
	geary_imap_quoted_string_parameter_parent_class = g_type_class_peek_parent (klass);
	((GearyImapParameterClass *) klass)->to_string = (gchar* (*) (GearyImapParameter*)) geary_imap_quoted_string_parameter_real_to_string;
	((GearyImapParameterClass *) klass)->serialize = (void (*) (GearyImapParameter*, GearyImapSerializer*, GCancellable*, GError**)) geary_imap_quoted_string_parameter_real_serialize;
}

static void
geary_imap_quoted_string_parameter_instance_init (GearyImapQuotedStringParameter * self,
                                                  gpointer klass)
{
}

/**
 * A representation of an IMAP quoted string.
 *
 * This class does not check if quoting is required.  Use {@link DataFormat.is_quoting_required}
 * or {@link StringParameter.get_best_for}.
 *
 * {@link Deserializer} will never generate this {@link Parameter}.
 *
 * See [[http://tools.ietf.org/html/rfc3501#section-4.3]].
 */
 G_GNUC_NO_INLINE static GType
geary_imap_quoted_string_parameter_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapQuotedStringParameterClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_quoted_string_parameter_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapQuotedStringParameter), 0, (GInstanceInitFunc) geary_imap_quoted_string_parameter_instance_init, NULL };
	GType geary_imap_quoted_string_parameter_type_id;
	geary_imap_quoted_string_parameter_type_id = g_type_register_static (GEARY_IMAP_TYPE_STRING_PARAMETER, "GearyImapQuotedStringParameter", &g_define_type_info, 0);
	return geary_imap_quoted_string_parameter_type_id;
}

GType
geary_imap_quoted_string_parameter_get_type (void)
{
	static gsize geary_imap_quoted_string_parameter_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_quoted_string_parameter_type_id__once)) {
		GType geary_imap_quoted_string_parameter_type_id;
		geary_imap_quoted_string_parameter_type_id = geary_imap_quoted_string_parameter_get_type_once ();
		g_once_init_leave (&geary_imap_quoted_string_parameter_type_id__once, geary_imap_quoted_string_parameter_type_id);
	}
	return geary_imap_quoted_string_parameter_type_id__once;
}

