/* imap-search-criteria.c generated by valac 0.56.19, the Vala compiler
 * generated from imap-search-criteria.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-object.h>
#include <glib.h>
#include <gee.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_SEARCH_CRITERIA_0_PROPERTY,
	GEARY_IMAP_SEARCH_CRITERIA_NUM_PROPERTIES
};
static GParamSpec* geary_imap_search_criteria_properties[GEARY_IMAP_SEARCH_CRITERIA_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

static gpointer geary_imap_search_criteria_parent_class = NULL;

static GType geary_imap_search_criteria_get_type_once (void);

GearyImapSearchCriteria*
geary_imap_search_criteria_construct (GType object_type,
                                      GearyImapSearchCriterion* first)
{
	GearyImapSearchCriteria * self = NULL;
	g_return_val_if_fail ((first == NULL) || GEARY_IMAP_IS_SEARCH_CRITERION (first), NULL);
	self = (GearyImapSearchCriteria*) geary_imap_list_parameter_construct (object_type);
	if (first != NULL) {
		GeeList* _tmp0_;
		GeeList* _tmp1_;
		_tmp0_ = geary_imap_search_criterion_to_parameters (first);
		_tmp1_ = _tmp0_;
		geary_imap_list_parameter_add_all (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_LIST_PARAMETER, GearyImapListParameter), G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection));
		_g_object_unref0 (_tmp1_);
	}
	return self;
}

GearyImapSearchCriteria*
geary_imap_search_criteria_new (GearyImapSearchCriterion* first)
{
	return geary_imap_search_criteria_construct (GEARY_IMAP_TYPE_SEARCH_CRITERIA, first);
}

/**
     * Clears the {@link SearchCriteria} and sets the supplied {@link SearchCriterion} to the first
     * in the list.
     *
     * @return This SearchCriteria for chaining.
     */
GearyImapSearchCriteria*
geary_imap_search_criteria_is_ (GearyImapSearchCriteria* self,
                                GearyImapSearchCriterion* first)
{
	GeeList* _tmp0_;
	GeeList* _tmp1_;
	GearyImapSearchCriteria* result;
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERIA (self), NULL);
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERION (first), NULL);
	geary_imap_list_parameter_clear (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_LIST_PARAMETER, GearyImapListParameter));
	_tmp0_ = geary_imap_search_criterion_to_parameters (first);
	_tmp1_ = _tmp0_;
	geary_imap_list_parameter_add_all (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_LIST_PARAMETER, GearyImapListParameter), G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection));
	_g_object_unref0 (_tmp1_);
	result = self;
	return result;
}

/**
     * AND another {@link SearchCriterion} to the {@link SearchCriteria}.
     *
     * @return This SearchCriteria for chaining.
     */
GearyImapSearchCriteria*
geary_imap_search_criteria_and (GearyImapSearchCriteria* self,
                                GearyImapSearchCriterion* next)
{
	GeeList* _tmp0_;
	GeeList* _tmp1_;
	GearyImapSearchCriteria* result;
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERIA (self), NULL);
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERION (next), NULL);
	_tmp0_ = geary_imap_search_criterion_to_parameters (next);
	_tmp1_ = _tmp0_;
	geary_imap_list_parameter_add_all (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_LIST_PARAMETER, GearyImapListParameter), G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection));
	_g_object_unref0 (_tmp1_);
	result = self;
	return result;
}

/**
     * OR two {@link SearchCriterion}s to the {@link SearchCriteria}.
     *
     * @return This SearchCriteria for chaining.
     */
GearyImapSearchCriteria*
geary_imap_search_criteria_or (GearyImapSearchCriteria* self,
                               GearyImapSearchCriterion* a,
                               GearyImapSearchCriterion* b)
{
	GearyImapSearchCriterion* _tmp0_;
	GearyImapSearchCriterion* _tmp1_;
	GeeList* _tmp2_;
	GeeList* _tmp3_;
	GearyImapSearchCriteria* result;
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERIA (self), NULL);
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERION (a), NULL);
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERION (b), NULL);
	_tmp0_ = geary_imap_search_criterion_or (a, b);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_imap_search_criterion_to_parameters (_tmp1_);
	_tmp3_ = _tmp2_;
	geary_imap_list_parameter_add_all (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_LIST_PARAMETER, GearyImapListParameter), G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_COLLECTION, GeeCollection));
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	result = self;
	return result;
}

/**
     * NOT another {@link SearchCriterion} to the {@link SearchCriteria}.
     *
     * @return This SearchCriteria for chaining.
     */
GearyImapSearchCriteria*
geary_imap_search_criteria_not (GearyImapSearchCriteria* self,
                                GearyImapSearchCriterion* next)
{
	GearyImapSearchCriterion* _tmp0_;
	GearyImapSearchCriterion* _tmp1_;
	GeeList* _tmp2_;
	GeeList* _tmp3_;
	GearyImapSearchCriteria* result;
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERIA (self), NULL);
	g_return_val_if_fail (GEARY_IMAP_IS_SEARCH_CRITERION (next), NULL);
	_tmp0_ = geary_imap_search_criterion_not (next);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_imap_search_criterion_to_parameters (_tmp1_);
	_tmp3_ = _tmp2_;
	geary_imap_list_parameter_add_all (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_IMAP_TYPE_LIST_PARAMETER, GearyImapListParameter), G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_COLLECTION, GeeCollection));
	_g_object_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	result = self;
	return result;
}

static void
geary_imap_search_criteria_class_init (GearyImapSearchCriteriaClass * klass,
                                       gpointer klass_data)
{
	geary_imap_search_criteria_parent_class = g_type_class_peek_parent (klass);
}

static void
geary_imap_search_criteria_instance_init (GearyImapSearchCriteria * self,
                                          gpointer klass)
{
}

/**
 * A collection of one or more {@link SearchCriterion} for a {@link SearchCommand}.
 *
 * Criterion are added to the SearchCriteria one at a time with the {@link and}, {@link or}, and/or
 * {@link not} methods.  Both methods return the SearchCriteria object, and so chaining can be used
 * for convenience:
 *
 * SearchCriteria criteria = new SearchCriteria();
 * criteria.is_(SearchCriterion.new_messages()).and(SearchCriterion.has_flag(MessageFlag.DRAFT));
 *
 * The or() method requires both criterion be passed:
 *
 * SearchCriteria criteria = new SearchCriteria();
 * criteria.or(SearchCriterion.old_messages(), SearchCriterion.body("attachment"));
 *
 * and() and or() can be mixed in a single SearchCriteria.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_search_criteria_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapSearchCriteriaClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_search_criteria_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapSearchCriteria), 0, (GInstanceInitFunc) geary_imap_search_criteria_instance_init, NULL };
	GType geary_imap_search_criteria_type_id;
	geary_imap_search_criteria_type_id = g_type_register_static (GEARY_IMAP_TYPE_LIST_PARAMETER, "GearyImapSearchCriteria", &g_define_type_info, 0);
	return geary_imap_search_criteria_type_id;
}

GType
geary_imap_search_criteria_get_type (void)
{
	static gsize geary_imap_search_criteria_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_search_criteria_type_id__once)) {
		GType geary_imap_search_criteria_type_id;
		geary_imap_search_criteria_type_id = geary_imap_search_criteria_get_type_once ();
		g_once_init_leave (&geary_imap_search_criteria_type_id__once, geary_imap_search_criteria_type_id);
	}
	return geary_imap_search_criteria_type_id__once;
}

