/* imap-login-command.c generated by valac 0.56.3, the Vala compiler
 * generated from imap-login-command.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_LOGIN_COMMAND_0_PROPERTY,
	GEARY_IMAP_LOGIN_COMMAND_NUM_PROPERTIES
};
static GParamSpec* geary_imap_login_command_properties[GEARY_IMAP_LOGIN_COMMAND_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

static gpointer geary_imap_login_command_parent_class = NULL;

static gchar* geary_imap_login_command_real_to_string (GearyImapCommand* base);
static GType geary_imap_login_command_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

GearyImapLoginCommand*
geary_imap_login_command_construct (GType object_type,
                                    const gchar* user,
                                    const gchar* pass,
                                    GCancellable* should_send)
{
	GearyImapLoginCommand * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	g_return_val_if_fail (user != NULL, NULL);
	g_return_val_if_fail (pass != NULL, NULL);
	g_return_val_if_fail ((should_send == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (should_send, g_cancellable_get_type ()), NULL);
	_tmp0_ = g_strdup (user);
	_tmp1_ = g_strdup (pass);
	_tmp2_ = g_new0 (gchar*, 2 + 1);
	_tmp2_[0] = _tmp0_;
	_tmp2_[1] = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 2;
	self = (GearyImapLoginCommand*) geary_imap_command_construct (object_type, GEARY_IMAP_LOGIN_COMMAND_NAME, _tmp3_, (gint) 2, should_send);
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	return self;
}

GearyImapLoginCommand*
geary_imap_login_command_new (const gchar* user,
                              const gchar* pass,
                              GCancellable* should_send)
{
	return geary_imap_login_command_construct (GEARY_IMAP_TYPE_LOGIN_COMMAND, user, pass, should_send);
}

static gchar*
geary_imap_login_command_real_to_string (GearyImapCommand* base)
{
	GearyImapLoginCommand * self;
	GearyImapTag* _tmp0_;
	GearyImapTag* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_TYPE_LOGIN_COMMAND, GearyImapLoginCommand);
	_tmp0_ = geary_imap_command_get_tag (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_COMMAND, GearyImapCommand));
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_imap_parameter_to_string (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEARY_IMAP_TYPE_PARAMETER, GearyImapParameter));
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_imap_command_get_name (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_COMMAND, GearyImapCommand));
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strdup_printf ("%s %s <user> <pass>", _tmp3_, _tmp5_);
	_tmp7_ = _tmp6_;
	_g_free0 (_tmp3_);
	result = _tmp7_;
	return result;
}

static void
geary_imap_login_command_class_init (GearyImapLoginCommandClass * klass,
                                     gpointer klass_data)
{
	geary_imap_login_command_parent_class = g_type_class_peek_parent (klass);
	((GearyImapCommandClass *) klass)->to_string = (gchar* (*) (GearyImapCommand*)) geary_imap_login_command_real_to_string;
}

static void
geary_imap_login_command_instance_init (GearyImapLoginCommand * self,
                                        gpointer klass)
{
}

/**
 * See [[http://tools.ietf.org/html/rfc3501#section-6.2.3]]
 */
 G_GNUC_NO_INLINE static GType
geary_imap_login_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapLoginCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_login_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapLoginCommand), 0, (GInstanceInitFunc) geary_imap_login_command_instance_init, NULL };
	GType geary_imap_login_command_type_id;
	geary_imap_login_command_type_id = g_type_register_static (GEARY_IMAP_TYPE_COMMAND, "GearyImapLoginCommand", &g_define_type_info, 0);
	return geary_imap_login_command_type_id;
}

GType
geary_imap_login_command_get_type (void)
{
	static gsize geary_imap_login_command_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_login_command_type_id__once)) {
		GType geary_imap_login_command_type_id;
		geary_imap_login_command_type_id = geary_imap_login_command_get_type_once ();
		g_once_init_leave (&geary_imap_login_command_type_id__once, geary_imap_login_command_type_id);
	}
	return geary_imap_login_command_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

