/* rygel-ruih-ui-elem.c generated by valac 0.42.2, the Vala compiler
 * generated from rygel-ruih-ui-elem.vala, do not modify */

/*
 * Copyright (C) 2013  Cable Television Laboratories, Inc.
 *
 * Author: Neha Shanbhag <N.Shanbhag@cablelabs.com>
 * Contact: http://www.cablelabs.com/
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Rygel is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */


#include <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <libxml/tree.h>
#include <rygel-core.h>
#include <glib/gi18n-lib.h>


#define TYPE_UI_LISTING (ui_listing_get_type ())
#define UI_LISTING(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UI_LISTING, UIListing))
#define UI_LISTING_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UI_LISTING, UIListingClass))
#define IS_UI_LISTING(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UI_LISTING))
#define IS_UI_LISTING_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UI_LISTING))
#define UI_LISTING_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UI_LISTING, UIListingClass))

typedef struct _UIListing UIListing;
typedef struct _UIListingClass UIListingClass;
typedef struct _UIListingPrivate UIListingPrivate;

#define TYPE_PROTOCOL_ELEM (protocol_elem_get_type ())
#define PROTOCOL_ELEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_PROTOCOL_ELEM, ProtocolElem))
#define PROTOCOL_ELEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_PROTOCOL_ELEM, ProtocolElemClass))
#define IS_PROTOCOL_ELEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_PROTOCOL_ELEM))
#define IS_PROTOCOL_ELEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_PROTOCOL_ELEM))
#define PROTOCOL_ELEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_PROTOCOL_ELEM, ProtocolElemClass))

typedef struct _ProtocolElem ProtocolElem;
typedef struct _ProtocolElemClass ProtocolElemClass;

#define TYPE_FILTER_ENTRY (filter_entry_get_type ())
#define FILTER_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FILTER_ENTRY, FilterEntry))
#define FILTER_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FILTER_ENTRY, FilterEntryClass))
#define IS_FILTER_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FILTER_ENTRY))
#define IS_FILTER_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FILTER_ENTRY))
#define FILTER_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FILTER_ENTRY, FilterEntryClass))

typedef struct _FilterEntry FilterEntry;
typedef struct _FilterEntryClass FilterEntryClass;

#define TYPE_UI_ELEM (ui_elem_get_type ())
#define UI_ELEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_UI_ELEM, UIElem))
#define UI_ELEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_UI_ELEM, UIElemClass))
#define IS_UI_ELEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_UI_ELEM))
#define IS_UI_ELEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_UI_ELEM))
#define UI_ELEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_UI_ELEM, UIElemClass))

typedef struct _UIElem UIElem;
typedef struct _UIElemClass UIElemClass;
typedef struct _UIElemPrivate UIElemPrivate;

#define TYPE_ICON_ELEM (icon_elem_get_type ())
#define ICON_ELEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ICON_ELEM, IconElem))
#define ICON_ELEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ICON_ELEM, IconElemClass))
#define IS_ICON_ELEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ICON_ELEM))
#define IS_ICON_ELEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ICON_ELEM))
#define ICON_ELEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ICON_ELEM, IconElemClass))

typedef struct _IconElem IconElem;
typedef struct _IconElemClass IconElemClass;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _rygel_xml_utils_iterator_unref0(var) ((var == NULL) ? NULL : (var = (rygel_xml_utils_iterator_unref (var), NULL)))
#define _ui_listing_unref0(var) ((var == NULL) ? NULL : (var = (ui_listing_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

struct _UIListing {
	GTypeInstance parent_instance;
	volatile int ref_count;
	UIListingPrivate * priv;
};

struct _UIListingClass {
	GTypeClass parent_class;
	void (*finalize) (UIListing *self);
	gboolean (*match) (UIListing* self, GeeArrayList* protocols, GeeArrayList* filters);
	gchar* (*to_ui_listing) (UIListing* self, GeeArrayList* filters);
};

struct _UIElem {
	UIListing parent_instance;
	UIElemPrivate * priv;
};

struct _UIElemClass {
	UIListingClass parent_class;
};

struct _UIElemPrivate {
	gchar* id;
	gchar* name;
	gchar* description;
	gchar* fork;
	gchar* lifetime;
	GeeArrayList* icons;
	GeeArrayList* protocols;
};

typedef enum  {
	RYGEL_RUIH_SERVICE_ERROR_OPERATION_REJECTED = 701,
	RYGEL_RUIH_SERVICE_ERROR_INVALID_FILTER = 702
} RygelRuihServiceError;
#define RYGEL_RUIH_SERVICE_ERROR rygel_ruih_service_error_quark ()

static gint UIElem_private_offset;
static gpointer ui_elem_parent_class = NULL;

gpointer ui_listing_ref (gpointer instance);
void ui_listing_unref (gpointer instance);
GParamSpec* param_spec_ui_listing (const gchar* name,
                                   const gchar* nick,
                                   const gchar* blurb,
                                   GType object_type,
                                   GParamFlags flags);
void value_set_ui_listing (GValue* value,
                           gpointer v_object);
void value_take_ui_listing (GValue* value,
                            gpointer v_object);
gpointer value_get_ui_listing (const GValue* value);
GType ui_listing_get_type (void) G_GNUC_CONST;
GType protocol_elem_get_type (void) G_GNUC_CONST;
gpointer filter_entry_ref (gpointer instance);
void filter_entry_unref (gpointer instance);
GParamSpec* param_spec_filter_entry (const gchar* name,
                                     const gchar* nick,
                                     const gchar* blurb,
                                     GType object_type,
                                     GParamFlags flags);
void value_set_filter_entry (GValue* value,
                             gpointer v_object);
void value_take_filter_entry (GValue* value,
                              gpointer v_object);
gpointer value_get_filter_entry (const GValue* value);
GType filter_entry_get_type (void) G_GNUC_CONST;
GType ui_elem_get_type (void) G_GNUC_CONST;
GType icon_elem_get_type (void) G_GNUC_CONST;
GQuark rygel_ruih_service_error_quark (void);
UIElem* ui_elem_new (xmlNode* node,
                     GError** error);
UIElem* ui_elem_construct (GType object_type,
                           xmlNode* node,
                           GError** error);
UIListing* ui_listing_construct (GType object_type);
#define UI_LISTING_UIID "uiID"
#define UI_LISTING_NAME "name"
#define UI_LISTING_DESCRIPTION "description"
#define UI_LISTING_ICONLIST "iconList"
#define UI_LISTING_FORK "fork"
#define UI_LISTING_LIFETIME "lifetime"
#define UI_LISTING_PROTOCOL "protocol"
#define UI_LISTING_ICON "icon"
IconElem* icon_elem_new (xmlNode* node,
                         GError** error);
IconElem* icon_elem_construct (GType object_type,
                               xmlNode* node,
                               GError** error);
ProtocolElem* protocol_elem_new (xmlNode* node,
                                 GError** error);
ProtocolElem* protocol_elem_construct (GType object_type,
                                       xmlNode* node,
                                       GError** error);
static gboolean ui_elem_real_match (UIListing* base,
                             GeeArrayList* protocol_elements,
                             GeeArrayList* filters);
gboolean ui_listing_match (UIListing* self,
                           GeeArrayList* protocols,
                           GeeArrayList* filters);
static gchar* ui_elem_real_to_ui_listing (UIListing* base,
                                   GeeArrayList* filters);
gboolean ui_listing_filters_match (UIListing* self,
                                   GeeArrayList* filters,
                                   const gchar* name,
                                   const gchar* value);
#define UI_LISTING_UI "ui"
gchar* ui_listing_to_xml (UIListing* self,
                          GeeHashMap* hash_map);
gchar* ui_listing_to_ui_listing (UIListing* self,
                                 GeeArrayList* filters);
static void ui_elem_finalize (UIListing * obj);


static inline gpointer
ui_elem_get_instance_private (UIElem* self)
{
	return G_STRUCT_MEMBER_P (self, UIElem_private_offset);
}


UIElem*
ui_elem_construct (GType object_type,
                   xmlNode* node,
                   GError** error)
{
	UIElem* self = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	GError * _inner_error_ = NULL;
	self = (UIElem*) ui_listing_construct (object_type);
	_tmp0_ = gee_array_list_new (TYPE_ICON_ELEM, (GBoxedCopyFunc) ui_listing_ref, (GDestroyNotify) ui_listing_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->icons);
	self->priv->icons = _tmp0_;
	_tmp1_ = gee_array_list_new (TYPE_PROTOCOL_ELEM, (GBoxedCopyFunc) ui_listing_ref, (GDestroyNotify) ui_listing_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->protocols);
	self->priv->protocols = _tmp1_;
	{
		RygelXMLUtilsIterator* _child_node_it = NULL;
		RygelXMLUtilsChildIterator* _tmp2_;
		RygelXMLUtilsChildIterator* _tmp3_;
		RygelXMLUtilsIterator* _tmp4_;
		RygelXMLUtilsIterator* _tmp5_;
		_tmp2_ = rygel_xml_utils_child_iterator_new (node);
		_tmp3_ = _tmp2_;
		_tmp4_ = rygel_xml_utils_iterator_iterator ((RygelXMLUtilsIterator*) _tmp3_);
		_tmp5_ = _tmp4_;
		_rygel_xml_utils_iterator_unref0 (_tmp3_);
		_child_node_it = _tmp5_;
		while (TRUE) {
			RygelXMLUtilsIterator* _tmp6_;
			xmlNode* child_node = NULL;
			RygelXMLUtilsIterator* _tmp7_;
			xmlNode* _tmp8_;
			xmlNode* _tmp9_;
			xmlElementType _tmp10_;
			gchar* node_name = NULL;
			xmlNode* _tmp11_;
			const gchar* _tmp12_;
			gchar* _tmp13_;
			const gchar* _tmp14_;
			const gchar* _tmp15_;
			GQuark _tmp17_ = 0U;
			_tmp6_ = _child_node_it;
			if (!rygel_xml_utils_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _child_node_it;
			_tmp8_ = rygel_xml_utils_iterator_get (_tmp7_);
			child_node = _tmp8_;
			_tmp9_ = child_node;
			_tmp10_ = _tmp9_->type;
			if (_tmp10_ == XML_TEXT_NODE) {
				continue;
			}
			_tmp11_ = child_node;
			_tmp12_ = _tmp11_->name;
			_tmp13_ = g_strdup (_tmp12_);
			node_name = _tmp13_;
			_tmp14_ = node_name;
			_tmp15_ = _tmp14_;
			_tmp17_ = (NULL == _tmp15_) ? 0 : g_quark_from_string (_tmp15_);
			if (_tmp17_ == g_quark_from_string (UI_LISTING_UIID)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp18_;
						gchar* _tmp19_;
						_tmp18_ = child_node;
						_tmp19_ = (gchar*) xmlNodeGetContent (_tmp18_);
						_g_free0 (self->priv->id);
						self->priv->id = _tmp19_;
						break;
					}
				}
			} else if (_tmp17_ == g_quark_from_string (UI_LISTING_NAME)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp20_;
						gchar* _tmp21_;
						_tmp20_ = child_node;
						_tmp21_ = (gchar*) xmlNodeGetContent (_tmp20_);
						_g_free0 (self->priv->name);
						self->priv->name = _tmp21_;
						break;
					}
				}
			} else if (_tmp17_ == g_quark_from_string (UI_LISTING_DESCRIPTION)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp22_;
						gchar* _tmp23_;
						_tmp22_ = child_node;
						_tmp23_ = (gchar*) xmlNodeGetContent (_tmp22_);
						_g_free0 (self->priv->description);
						self->priv->description = _tmp23_;
						break;
					}
				}
			} else if (_tmp17_ == g_quark_from_string (UI_LISTING_ICONLIST)) {
				switch (0) {
					default:
					{
						RygelXMLUtilsChildIterator* it = NULL;
						xmlNode* _tmp24_;
						RygelXMLUtilsChildIterator* _tmp25_;
						_tmp24_ = child_node;
						_tmp25_ = rygel_xml_utils_child_iterator_new (_tmp24_);
						it = _tmp25_;
						{
							RygelXMLUtilsIterator* _icon_node_it = NULL;
							RygelXMLUtilsChildIterator* _tmp26_;
							RygelXMLUtilsIterator* _tmp27_;
							_tmp26_ = it;
							_tmp27_ = rygel_xml_utils_iterator_iterator ((RygelXMLUtilsIterator*) _tmp26_);
							_icon_node_it = _tmp27_;
							while (TRUE) {
								RygelXMLUtilsIterator* _tmp28_;
								xmlNode* icon_node = NULL;
								RygelXMLUtilsIterator* _tmp29_;
								xmlNode* _tmp30_;
								xmlNode* _tmp31_;
								const gchar* _tmp32_;
								_tmp28_ = _icon_node_it;
								if (!rygel_xml_utils_iterator_next (_tmp28_)) {
									break;
								}
								_tmp29_ = _icon_node_it;
								_tmp30_ = rygel_xml_utils_iterator_get (_tmp29_);
								icon_node = _tmp30_;
								_tmp31_ = icon_node;
								_tmp32_ = _tmp31_->name;
								if (g_strcmp0 (_tmp32_, UI_LISTING_ICON) == 0) {
									IconElem* _tmp33_ = NULL;
									xmlNode* _tmp34_;
									IconElem* _tmp35_;
									GeeArrayList* _tmp36_;
									_tmp34_ = icon_node;
									_tmp35_ = icon_elem_new (_tmp34_, &_inner_error_);
									_tmp33_ = _tmp35_;
									if (G_UNLIKELY (_inner_error_ != NULL)) {
										if (_inner_error_->domain == RYGEL_RUIH_SERVICE_ERROR) {
											g_propagate_error (error, _inner_error_);
											_rygel_xml_utils_iterator_unref0 (_icon_node_it);
											_rygel_xml_utils_iterator_unref0 (it);
											_g_free0 (node_name);
											_rygel_xml_utils_iterator_unref0 (_child_node_it);
											_ui_listing_unref0 (self);
											return NULL;
										} else {
											_rygel_xml_utils_iterator_unref0 (_icon_node_it);
											_rygel_xml_utils_iterator_unref0 (it);
											_g_free0 (node_name);
											_rygel_xml_utils_iterator_unref0 (_child_node_it);
											g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
											g_clear_error (&_inner_error_);
											return NULL;
										}
									}
									_tmp36_ = self->priv->icons;
									gee_abstract_collection_add ((GeeAbstractCollection*) _tmp36_, _tmp33_);
									_ui_listing_unref0 (_tmp33_);
								}
							}
							_rygel_xml_utils_iterator_unref0 (_icon_node_it);
						}
						_rygel_xml_utils_iterator_unref0 (it);
						break;
					}
				}
			} else if (_tmp17_ == g_quark_from_string (UI_LISTING_FORK)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp37_;
						gchar* _tmp38_;
						_tmp37_ = child_node;
						_tmp38_ = (gchar*) xmlNodeGetContent (_tmp37_);
						_g_free0 (self->priv->fork);
						self->priv->fork = _tmp38_;
						break;
					}
				}
			} else if (_tmp17_ == g_quark_from_string (UI_LISTING_LIFETIME)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp39_;
						gchar* _tmp40_;
						_tmp39_ = child_node;
						_tmp40_ = (gchar*) xmlNodeGetContent (_tmp39_);
						_g_free0 (self->priv->lifetime);
						self->priv->lifetime = _tmp40_;
						break;
					}
				}
			} else if (_tmp17_ == g_quark_from_string (UI_LISTING_PROTOCOL)) {
				switch (0) {
					default:
					{
						ProtocolElem* _tmp41_ = NULL;
						xmlNode* _tmp42_;
						ProtocolElem* _tmp43_;
						GeeArrayList* _tmp44_;
						_tmp42_ = child_node;
						_tmp43_ = protocol_elem_new (_tmp42_, &_inner_error_);
						_tmp41_ = _tmp43_;
						if (G_UNLIKELY (_inner_error_ != NULL)) {
							if (_inner_error_->domain == RYGEL_RUIH_SERVICE_ERROR) {
								g_propagate_error (error, _inner_error_);
								_g_free0 (node_name);
								_rygel_xml_utils_iterator_unref0 (_child_node_it);
								_ui_listing_unref0 (self);
								return NULL;
							} else {
								_g_free0 (node_name);
								_rygel_xml_utils_iterator_unref0 (_child_node_it);
								g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
								g_clear_error (&_inner_error_);
								return NULL;
							}
						}
						_tmp44_ = self->priv->protocols;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp44_, _tmp41_);
						_ui_listing_unref0 (_tmp41_);
						break;
					}
				}
			} else {
				switch (0) {
					default:
					{
						gchar* msg = NULL;
						gchar* _tmp45_;
						const gchar* _tmp46_;
						const gchar* _tmp47_;
						gchar* _tmp48_;
						gchar* _tmp49_;
						GError* _tmp50_;
						GError* _tmp51_;
						_tmp45_ = g_strdup (_ ("Unable to parse UI data — unexpected node: %s"));
						msg = _tmp45_;
						_tmp46_ = msg;
						_tmp47_ = node_name;
						_tmp48_ = g_strdup_printf (_tmp46_, _tmp47_);
						_tmp49_ = _tmp48_;
						_tmp50_ = g_error_new_literal (RYGEL_RUIH_SERVICE_ERROR, RYGEL_RUIH_SERVICE_ERROR_OPERATION_REJECTED, _tmp49_);
						_tmp51_ = _tmp50_;
						_g_free0 (_tmp49_);
						_inner_error_ = _tmp51_;
						if (_inner_error_->domain == RYGEL_RUIH_SERVICE_ERROR) {
							g_propagate_error (error, _inner_error_);
							_g_free0 (msg);
							_g_free0 (node_name);
							_rygel_xml_utils_iterator_unref0 (_child_node_it);
							_ui_listing_unref0 (self);
							return NULL;
						} else {
							_g_free0 (msg);
							_g_free0 (node_name);
							_rygel_xml_utils_iterator_unref0 (_child_node_it);
							g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
							g_clear_error (&_inner_error_);
							return NULL;
						}
						_g_free0 (msg);
					}
				}
			}
			_g_free0 (node_name);
		}
		_rygel_xml_utils_iterator_unref0 (_child_node_it);
	}
	return self;
}


UIElem*
ui_elem_new (xmlNode* node,
             GError** error)
{
	return ui_elem_construct (TYPE_UI_ELEM, node, error);
}


static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}


static gboolean
ui_elem_real_match (UIListing* base,
                    GeeArrayList* protocol_elements,
                    GeeArrayList* filters)
{
	UIElem * self;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	self = (UIElem*) base;
	g_return_val_if_fail (filters != NULL, FALSE);
	if (protocol_elements == NULL) {
		_tmp0_ = TRUE;
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) protocol_elements);
		_tmp2_ = _tmp1_;
		_tmp0_ = _tmp2_ == 0;
	}
	if (_tmp0_) {
		result = TRUE;
		return result;
	}
	{
		GeeArrayList* _proto_list = NULL;
		GeeArrayList* _tmp3_;
		gint _proto_size = 0;
		GeeArrayList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gint _proto_index = 0;
		_tmp3_ = _g_object_ref0 (protocol_elements);
		_proto_list = _tmp3_;
		_tmp4_ = _proto_list;
		_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_proto_size = _tmp6_;
		_proto_index = -1;
		while (TRUE) {
			gint _tmp7_;
			gint _tmp8_;
			gint _tmp9_;
			ProtocolElem* proto = NULL;
			GeeArrayList* _tmp10_;
			gint _tmp11_;
			gpointer _tmp12_;
			ProtocolElem* _tmp13_;
			GeeArrayList* _tmp14_;
			_tmp7_ = _proto_index;
			_proto_index = _tmp7_ + 1;
			_tmp8_ = _proto_index;
			_tmp9_ = _proto_size;
			if (!(_tmp8_ < _tmp9_)) {
				break;
			}
			_tmp10_ = _proto_list;
			_tmp11_ = _proto_index;
			_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp10_, _tmp11_);
			proto = (ProtocolElem*) _tmp12_;
			_tmp13_ = proto;
			_tmp14_ = self->priv->protocols;
			if (ui_listing_match ((UIListing*) _tmp13_, _tmp14_, filters)) {
				result = TRUE;
				_ui_listing_unref0 (proto);
				_g_object_unref0 (_proto_list);
				return result;
			}
			_ui_listing_unref0 (proto);
		}
		_g_object_unref0 (_proto_list);
	}
	result = FALSE;
	return result;
}


static gchar*
ui_elem_real_to_ui_listing (UIListing* base,
                            GeeArrayList* filters)
{
	UIElem * self;
	gchar* result = NULL;
	GeeHashMap* elements = NULL;
	GeeHashMap* _tmp0_;
	gboolean match = FALSE;
	GeeHashMap* _tmp1_;
	const gchar* _tmp2_;
	GeeHashMap* _tmp3_;
	const gchar* _tmp4_;
	GeeHashMap* _tmp5_;
	const gchar* _tmp6_;
	GeeHashMap* _tmp7_;
	const gchar* _tmp8_;
	GeeHashMap* _tmp9_;
	const gchar* _tmp10_;
	gboolean _tmp11_ = FALSE;
	const gchar* _tmp12_;
	gboolean _tmp14_ = FALSE;
	const gchar* _tmp15_;
	gboolean _tmp17_ = FALSE;
	const gchar* _tmp18_;
	gboolean _tmp20_ = FALSE;
	const gchar* _tmp21_;
	GString* sb = NULL;
	GString* _tmp23_;
	GString* _tmp24_;
	GeeHashMap* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	GString* icon_sb = NULL;
	GString* _tmp28_;
	GString* _tmp44_;
	const gchar* _tmp45_;
	gint _tmp46_;
	gint _tmp47_;
	GString* protocol_sb = NULL;
	GString* _tmp53_;
	GeeArrayList* _tmp54_;
	gint _tmp55_;
	gint _tmp56_;
	GString* _tmp79_;
	gboolean _tmp80_;
	self = (UIElem*) base;
	g_return_val_if_fail (filters != NULL, NULL);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	elements = _tmp0_;
	match = FALSE;
	_tmp1_ = elements;
	_tmp2_ = self->priv->id;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp1_, UI_LISTING_UIID, _tmp2_);
	_tmp3_ = elements;
	_tmp4_ = self->priv->name;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp3_, UI_LISTING_NAME, _tmp4_);
	_tmp5_ = elements;
	_tmp6_ = self->priv->description;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp5_, UI_LISTING_DESCRIPTION, _tmp6_);
	_tmp7_ = elements;
	_tmp8_ = self->priv->fork;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp7_, UI_LISTING_FORK, _tmp8_);
	_tmp9_ = elements;
	_tmp10_ = self->priv->lifetime;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp9_, UI_LISTING_LIFETIME, _tmp10_);
	_tmp12_ = self->priv->name;
	if (_tmp12_ != NULL) {
		const gchar* _tmp13_;
		_tmp13_ = self->priv->name;
		_tmp11_ = ui_listing_filters_match ((UIListing*) self, filters, UI_LISTING_NAME, _tmp13_);
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		match = TRUE;
	}
	_tmp15_ = self->priv->description;
	if (_tmp15_ != NULL) {
		const gchar* _tmp16_;
		_tmp16_ = self->priv->description;
		_tmp14_ = ui_listing_filters_match ((UIListing*) self, filters, UI_LISTING_DESCRIPTION, _tmp16_);
	} else {
		_tmp14_ = FALSE;
	}
	if (_tmp14_) {
		match = TRUE;
	}
	_tmp18_ = self->priv->fork;
	if (_tmp18_ != NULL) {
		const gchar* _tmp19_;
		_tmp19_ = self->priv->fork;
		_tmp17_ = ui_listing_filters_match ((UIListing*) self, filters, UI_LISTING_FORK, _tmp19_);
	} else {
		_tmp17_ = FALSE;
	}
	if (_tmp17_) {
		match = TRUE;
	}
	_tmp21_ = self->priv->lifetime;
	if (_tmp21_ != NULL) {
		const gchar* _tmp22_;
		_tmp22_ = self->priv->lifetime;
		_tmp20_ = ui_listing_filters_match ((UIListing*) self, filters, UI_LISTING_LIFETIME, _tmp22_);
	} else {
		_tmp20_ = FALSE;
	}
	if (_tmp20_) {
		match = TRUE;
	}
	_tmp23_ = g_string_new ("<" UI_LISTING_UI ">\n");
	sb = _tmp23_;
	_tmp24_ = sb;
	_tmp25_ = elements;
	_tmp26_ = ui_listing_to_xml ((UIListing*) self, _tmp25_);
	_tmp27_ = _tmp26_;
	g_string_append (_tmp24_, _tmp27_);
	_g_free0 (_tmp27_);
	_tmp28_ = g_string_new ("");
	icon_sb = _tmp28_;
	{
		GeeArrayList* _icon_list = NULL;
		GeeArrayList* _tmp29_;
		GeeArrayList* _tmp30_;
		gint _icon_size = 0;
		GeeArrayList* _tmp31_;
		gint _tmp32_;
		gint _tmp33_;
		gint _icon_index = 0;
		_tmp29_ = self->priv->icons;
		_tmp30_ = _g_object_ref0 (_tmp29_);
		_icon_list = _tmp30_;
		_tmp31_ = _icon_list;
		_tmp32_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp31_);
		_tmp33_ = _tmp32_;
		_icon_size = _tmp33_;
		_icon_index = -1;
		while (TRUE) {
			gint _tmp34_;
			gint _tmp35_;
			gint _tmp36_;
			IconElem* icon = NULL;
			GeeArrayList* _tmp37_;
			gint _tmp38_;
			gpointer _tmp39_;
			GString* _tmp40_;
			IconElem* _tmp41_;
			gchar* _tmp42_;
			gchar* _tmp43_;
			_tmp34_ = _icon_index;
			_icon_index = _tmp34_ + 1;
			_tmp35_ = _icon_index;
			_tmp36_ = _icon_size;
			if (!(_tmp35_ < _tmp36_)) {
				break;
			}
			_tmp37_ = _icon_list;
			_tmp38_ = _icon_index;
			_tmp39_ = gee_abstract_list_get ((GeeAbstractList*) _tmp37_, _tmp38_);
			icon = (IconElem*) _tmp39_;
			_tmp40_ = icon_sb;
			_tmp41_ = icon;
			_tmp42_ = ui_listing_to_ui_listing ((UIListing*) _tmp41_, filters);
			_tmp43_ = _tmp42_;
			g_string_append (_tmp40_, _tmp43_);
			_g_free0 (_tmp43_);
			_ui_listing_unref0 (icon);
		}
		_g_object_unref0 (_icon_list);
	}
	_tmp44_ = icon_sb;
	_tmp45_ = _tmp44_->str;
	_tmp46_ = strlen (_tmp45_);
	_tmp47_ = _tmp46_;
	if (_tmp47_ > 0) {
		GString* _tmp48_;
		GString* _tmp49_;
		GString* _tmp50_;
		const gchar* _tmp51_;
		GString* _tmp52_;
		match = TRUE;
		_tmp48_ = sb;
		g_string_append (_tmp48_, "<" UI_LISTING_ICONLIST ">\n");
		_tmp49_ = sb;
		_tmp50_ = icon_sb;
		_tmp51_ = _tmp50_->str;
		g_string_append (_tmp49_, _tmp51_);
		_tmp52_ = sb;
		g_string_append (_tmp52_, "</" UI_LISTING_ICONLIST ">\n");
	}
	_tmp53_ = g_string_new ("");
	protocol_sb = _tmp53_;
	_tmp54_ = self->priv->protocols;
	_tmp55_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp54_);
	_tmp56_ = _tmp55_;
	if (_tmp56_ > 0) {
		GString* _tmp72_;
		const gchar* _tmp73_;
		gint _tmp74_;
		gint _tmp75_;
		{
			GeeArrayList* _protocol_list = NULL;
			GeeArrayList* _tmp57_;
			GeeArrayList* _tmp58_;
			gint _protocol_size = 0;
			GeeArrayList* _tmp59_;
			gint _tmp60_;
			gint _tmp61_;
			gint _protocol_index = 0;
			_tmp57_ = self->priv->protocols;
			_tmp58_ = _g_object_ref0 (_tmp57_);
			_protocol_list = _tmp58_;
			_tmp59_ = _protocol_list;
			_tmp60_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp59_);
			_tmp61_ = _tmp60_;
			_protocol_size = _tmp61_;
			_protocol_index = -1;
			while (TRUE) {
				gint _tmp62_;
				gint _tmp63_;
				gint _tmp64_;
				ProtocolElem* protocol = NULL;
				GeeArrayList* _tmp65_;
				gint _tmp66_;
				gpointer _tmp67_;
				GString* _tmp68_;
				ProtocolElem* _tmp69_;
				gchar* _tmp70_;
				gchar* _tmp71_;
				_tmp62_ = _protocol_index;
				_protocol_index = _tmp62_ + 1;
				_tmp63_ = _protocol_index;
				_tmp64_ = _protocol_size;
				if (!(_tmp63_ < _tmp64_)) {
					break;
				}
				_tmp65_ = _protocol_list;
				_tmp66_ = _protocol_index;
				_tmp67_ = gee_abstract_list_get ((GeeAbstractList*) _tmp65_, _tmp66_);
				protocol = (ProtocolElem*) _tmp67_;
				_tmp68_ = protocol_sb;
				_tmp69_ = protocol;
				_tmp70_ = ui_listing_to_ui_listing ((UIListing*) _tmp69_, filters);
				_tmp71_ = _tmp70_;
				g_string_append (_tmp68_, _tmp71_);
				_g_free0 (_tmp71_);
				_ui_listing_unref0 (protocol);
			}
			_g_object_unref0 (_protocol_list);
		}
		_tmp72_ = protocol_sb;
		_tmp73_ = _tmp72_->str;
		_tmp74_ = strlen (_tmp73_);
		_tmp75_ = _tmp74_;
		if (_tmp75_ > 0) {
			GString* _tmp76_;
			GString* _tmp77_;
			const gchar* _tmp78_;
			match = TRUE;
			_tmp76_ = sb;
			_tmp77_ = protocol_sb;
			_tmp78_ = _tmp77_->str;
			g_string_append (_tmp76_, _tmp78_);
		}
	}
	_tmp79_ = sb;
	g_string_append (_tmp79_, "</" UI_LISTING_UI ">\n");
	_tmp80_ = match;
	if (_tmp80_) {
		GString* _tmp81_;
		const gchar* _tmp82_;
		gchar* _tmp83_;
		_tmp81_ = sb;
		_tmp82_ = _tmp81_->str;
		_tmp83_ = g_strdup (_tmp82_);
		result = _tmp83_;
		_g_string_free0 (protocol_sb);
		_g_string_free0 (icon_sb);
		_g_string_free0 (sb);
		_g_object_unref0 (elements);
		return result;
	} else {
		gchar* _tmp84_;
		_tmp84_ = g_strdup ("");
		result = _tmp84_;
		_g_string_free0 (protocol_sb);
		_g_string_free0 (icon_sb);
		_g_string_free0 (sb);
		_g_object_unref0 (elements);
		return result;
	}
	_g_string_free0 (protocol_sb);
	_g_string_free0 (icon_sb);
	_g_string_free0 (sb);
	_g_object_unref0 (elements);
}


static void
ui_elem_class_init (UIElemClass * klass)
{
	ui_elem_parent_class = g_type_class_peek_parent (klass);
	((UIListingClass *) klass)->finalize = ui_elem_finalize;
	g_type_class_adjust_private_offset (klass, &UIElem_private_offset);
	((UIListingClass *) klass)->match = (gboolean (*) (UIListing *, GeeArrayList*, GeeArrayList*)) ui_elem_real_match;
	((UIListingClass *) klass)->to_ui_listing = (gchar* (*) (UIListing *, GeeArrayList*)) ui_elem_real_to_ui_listing;
}


static void
ui_elem_instance_init (UIElem * self)
{
	self->priv = ui_elem_get_instance_private (self);
	self->priv->id = NULL;
	self->priv->name = NULL;
	self->priv->description = NULL;
	self->priv->fork = NULL;
	self->priv->lifetime = NULL;
}


static void
ui_elem_finalize (UIListing * obj)
{
	UIElem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_UI_ELEM, UIElem);
	_g_free0 (self->priv->id);
	_g_free0 (self->priv->name);
	_g_free0 (self->priv->description);
	_g_free0 (self->priv->fork);
	_g_free0 (self->priv->lifetime);
	_g_object_unref0 (self->priv->icons);
	_g_object_unref0 (self->priv->protocols);
	UI_LISTING_CLASS (ui_elem_parent_class)->finalize (obj);
}


GType
ui_elem_get_type (void)
{
	static volatile gsize ui_elem_type_id__volatile = 0;
	if (g_once_init_enter (&ui_elem_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (UIElemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) ui_elem_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (UIElem), 0, (GInstanceInitFunc) ui_elem_instance_init, NULL };
		GType ui_elem_type_id;
		ui_elem_type_id = g_type_register_static (TYPE_UI_LISTING, "UIElem", &g_define_type_info, 0);
		UIElem_private_offset = g_type_add_instance_private (ui_elem_type_id, sizeof (UIElemPrivate));
		g_once_init_leave (&ui_elem_type_id__volatile, ui_elem_type_id);
	}
	return ui_elem_type_id__volatile;
}



