/* smtp-capabilities.c generated by valac 0.56.3, the Vala compiler
 * generated from smtp-capabilities.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 <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>

enum  {
	GEARY_SMTP_CAPABILITIES_0_PROPERTY,
	GEARY_SMTP_CAPABILITIES_NUM_PROPERTIES
};
static GParamSpec* geary_smtp_capabilities_properties[GEARY_SMTP_CAPABILITIES_NUM_PROPERTIES];
#define _geary_smtp_response_line_unref0(var) ((var == NULL) ? NULL : (var = (geary_smtp_response_line_unref (var), NULL)))

static gpointer geary_smtp_capabilities_parent_class = NULL;

static GType geary_smtp_capabilities_get_type_once (void);

GearySmtpCapabilities*
geary_smtp_capabilities_construct (GType object_type)
{
	GearySmtpCapabilities * self = NULL;
	self = (GearySmtpCapabilities*) geary_generic_capabilities_construct (object_type, GEARY_SMTP_CAPABILITIES_NAME_SEPARATOR, GEARY_SMTP_CAPABILITIES_VALUE_SEPARATOR);
	return self;
}

GearySmtpCapabilities*
geary_smtp_capabilities_new (void)
{
	return geary_smtp_capabilities_construct (GEARY_SMTP_TYPE_CAPABILITIES);
}

/**
     * Returns number of response lines added.
     */
gint
geary_smtp_capabilities_add_ehlo_response (GearySmtpCapabilities* self,
                                           GearySmtpResponse* response)
{
	gint count = 0;
	gint result;
	g_return_val_if_fail (GEARY_SMTP_IS_CAPABILITIES (self), 0);
	g_return_val_if_fail (GEARY_SMTP_IS_RESPONSE (response), 0);
	count = 0;
	{
		gint ctr = 0;
		ctr = 1;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				GeeList* _tmp2_;
				GeeList* _tmp3_;
				gint _tmp4_;
				gint _tmp5_;
				GeeList* _tmp6_;
				GeeList* _tmp7_;
				gpointer _tmp8_;
				GearySmtpResponseLine* _tmp9_;
				gboolean _tmp10_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = ctr;
					ctr = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = geary_smtp_response_get_lines (response);
				_tmp3_ = _tmp2_;
				_tmp4_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_COLLECTION, GeeCollection));
				_tmp5_ = _tmp4_;
				if (!(ctr < _tmp5_)) {
					break;
				}
				_tmp6_ = geary_smtp_response_get_lines (response);
				_tmp7_ = _tmp6_;
				_tmp8_ = gee_list_get (_tmp7_, ctr);
				_tmp9_ = (GearySmtpResponseLine*) _tmp8_;
				_tmp10_ = geary_smtp_capabilities_add_response_line (self, _tmp9_);
				_geary_smtp_response_line_unref0 (_tmp9_);
				if (_tmp10_) {
					gint _tmp11_;
					_tmp11_ = count;
					count = _tmp11_ + 1;
				}
			}
		}
	}
	result = count;
	return result;
}

gboolean
geary_smtp_capabilities_add_response_line (GearySmtpCapabilities* self,
                                           GearySmtpResponseLine* line)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean result;
	g_return_val_if_fail (GEARY_SMTP_IS_CAPABILITIES (self), FALSE);
	g_return_val_if_fail (GEARY_SMTP_IS_RESPONSE_LINE (line), FALSE);
	_tmp1_ = geary_smtp_response_line_get_explanation (line);
	_tmp2_ = _tmp1_;
	if (!geary_string_is_empty (_tmp2_)) {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = geary_smtp_response_line_get_explanation (line);
		_tmp4_ = _tmp3_;
		_tmp0_ = geary_generic_capabilities_parse_and_add_capability (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_GENERIC_CAPABILITIES, GearyGenericCapabilities), _tmp4_);
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
geary_smtp_capabilities_class_init (GearySmtpCapabilitiesClass * klass,
                                    gpointer klass_data)
{
	geary_smtp_capabilities_parent_class = g_type_class_peek_parent (klass);
}

static void
geary_smtp_capabilities_instance_init (GearySmtpCapabilities * self,
                                       gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
geary_smtp_capabilities_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearySmtpCapabilitiesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_smtp_capabilities_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearySmtpCapabilities), 0, (GInstanceInitFunc) geary_smtp_capabilities_instance_init, NULL };
	GType geary_smtp_capabilities_type_id;
	geary_smtp_capabilities_type_id = g_type_register_static (GEARY_TYPE_GENERIC_CAPABILITIES, "GearySmtpCapabilities", &g_define_type_info, 0);
	return geary_smtp_capabilities_type_id;
}

GType
geary_smtp_capabilities_get_type (void)
{
	static gsize geary_smtp_capabilities_type_id__once = 0;
	if (g_once_init_enter (&geary_smtp_capabilities_type_id__once)) {
		GType geary_smtp_capabilities_type_id;
		geary_smtp_capabilities_type_id = geary_smtp_capabilities_get_type_once ();
		g_once_init_leave (&geary_smtp_capabilities_type_id__once, geary_smtp_capabilities_type_id);
	}
	return geary_smtp_capabilities_type_id__once;
}

