/* rygel-ruih-ui-elem.c generated by valac 0.56.19, 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 "rygel-ruih.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <libxml/tree.h>
#include "rygel-core.h"
#include <glib/gi18n-lib.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

#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 _UIElemPrivate {
	gchar* id;
	gchar* name;
	gchar* description;
	gchar* fork;
	gchar* lifetime;
	GeeArrayList* icons;
	GeeArrayList* protocols;
};

static gint UIElem_private_offset;
static gpointer ui_elem_parent_class = NULL;

static gboolean ui_elem_real_match (UIListing* base,
                             GeeArrayList* protocol_elements,
                             GeeArrayList* filters);
static gchar* ui_elem_real_to_ui_listing (UIListing* base,
                                   GeeArrayList* filters);
static void ui_elem_finalize (UIListing * obj);
static GType ui_elem_get_type_once (void);

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_error0_ = 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_;
			gchar* node_name = NULL;
			xmlNode* _tmp10_;
			const gchar* _tmp11_;
			gchar* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			GQuark _tmp16_ = 0U;
			static GQuark _tmp15_label0 = 0;
			static GQuark _tmp15_label1 = 0;
			static GQuark _tmp15_label2 = 0;
			static GQuark _tmp15_label3 = 0;
			static GQuark _tmp15_label4 = 0;
			static GQuark _tmp15_label5 = 0;
			static GQuark _tmp15_label6 = 0;
			_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;
			if (_tmp9_->type == XML_TEXT_NODE) {
				continue;
			}
			_tmp10_ = child_node;
			_tmp11_ = _tmp10_->name;
			_tmp12_ = g_strdup (_tmp11_);
			node_name = _tmp12_;
			_tmp13_ = node_name;
			_tmp14_ = _tmp13_;
			_tmp16_ = (NULL == _tmp14_) ? 0 : g_quark_from_string (_tmp14_);
			if (_tmp16_ == ((0 != _tmp15_label0) ? _tmp15_label0 : (_tmp15_label0 = g_quark_from_static_string (UI_LISTING_UIID)))) {
				switch (0) {
					default:
					{
						xmlNode* _tmp17_;
						gchar* _tmp18_;
						_tmp17_ = child_node;
						_tmp18_ = (gchar*) xmlNodeGetContent (_tmp17_);
						_g_free0 (self->priv->id);
						self->priv->id = _tmp18_;
						break;
					}
				}
			} else if (_tmp16_ == ((0 != _tmp15_label1) ? _tmp15_label1 : (_tmp15_label1 = g_quark_from_static_string (UI_LISTING_NAME)))) {
				switch (0) {
					default:
					{
						xmlNode* _tmp19_;
						gchar* _tmp20_;
						_tmp19_ = child_node;
						_tmp20_ = (gchar*) xmlNodeGetContent (_tmp19_);
						_g_free0 (self->priv->name);
						self->priv->name = _tmp20_;
						break;
					}
				}
			} else if (_tmp16_ == ((0 != _tmp15_label2) ? _tmp15_label2 : (_tmp15_label2 = g_quark_from_static_string (UI_LISTING_DESCRIPTION)))) {
				switch (0) {
					default:
					{
						xmlNode* _tmp21_;
						gchar* _tmp22_;
						_tmp21_ = child_node;
						_tmp22_ = (gchar*) xmlNodeGetContent (_tmp21_);
						_g_free0 (self->priv->description);
						self->priv->description = _tmp22_;
						break;
					}
				}
			} else if (_tmp16_ == ((0 != _tmp15_label3) ? _tmp15_label3 : (_tmp15_label3 = g_quark_from_static_string (UI_LISTING_ICONLIST)))) {
				switch (0) {
					default:
					{
						RygelXMLUtilsChildIterator* it = NULL;
						xmlNode* _tmp23_;
						RygelXMLUtilsChildIterator* _tmp24_;
						_tmp23_ = child_node;
						_tmp24_ = rygel_xml_utils_child_iterator_new (_tmp23_);
						it = _tmp24_;
						{
							RygelXMLUtilsIterator* _icon_node_it = NULL;
							RygelXMLUtilsChildIterator* _tmp25_;
							RygelXMLUtilsIterator* _tmp26_;
							_tmp25_ = it;
							_tmp26_ = rygel_xml_utils_iterator_iterator ((RygelXMLUtilsIterator*) _tmp25_);
							_icon_node_it = _tmp26_;
							while (TRUE) {
								RygelXMLUtilsIterator* _tmp27_;
								xmlNode* icon_node = NULL;
								RygelXMLUtilsIterator* _tmp28_;
								xmlNode* _tmp29_;
								xmlNode* _tmp30_;
								const gchar* _tmp31_;
								_tmp27_ = _icon_node_it;
								if (!rygel_xml_utils_iterator_next (_tmp27_)) {
									break;
								}
								_tmp28_ = _icon_node_it;
								_tmp29_ = rygel_xml_utils_iterator_get (_tmp28_);
								icon_node = _tmp29_;
								_tmp30_ = icon_node;
								_tmp31_ = _tmp30_->name;
								if (g_strcmp0 (_tmp31_, UI_LISTING_ICON) == 0) {
									IconElem* _tmp32_ = NULL;
									xmlNode* _tmp33_;
									IconElem* _tmp34_;
									GeeArrayList* _tmp35_;
									_tmp33_ = icon_node;
									_tmp34_ = icon_elem_new (_tmp33_, &_inner_error0_);
									_tmp32_ = _tmp34_;
									if (G_UNLIKELY (_inner_error0_ != NULL)) {
										if (_inner_error0_->domain == RYGEL_RUIH_SERVICE_ERROR) {
											g_propagate_error (error, _inner_error0_);
											_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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
											g_clear_error (&_inner_error0_);
											return NULL;
										}
									}
									_tmp35_ = self->priv->icons;
									gee_abstract_collection_add ((GeeAbstractCollection*) _tmp35_, _tmp32_);
									_ui_listing_unref0 (_tmp32_);
								}
							}
							_rygel_xml_utils_iterator_unref0 (_icon_node_it);
						}
						_rygel_xml_utils_iterator_unref0 (it);
						break;
					}
				}
			} else if (_tmp16_ == ((0 != _tmp15_label4) ? _tmp15_label4 : (_tmp15_label4 = g_quark_from_static_string (UI_LISTING_FORK)))) {
				switch (0) {
					default:
					{
						xmlNode* _tmp36_;
						gchar* _tmp37_;
						_tmp36_ = child_node;
						_tmp37_ = (gchar*) xmlNodeGetContent (_tmp36_);
						_g_free0 (self->priv->fork);
						self->priv->fork = _tmp37_;
						break;
					}
				}
			} else if (_tmp16_ == ((0 != _tmp15_label5) ? _tmp15_label5 : (_tmp15_label5 = g_quark_from_static_string (UI_LISTING_LIFETIME)))) {
				switch (0) {
					default:
					{
						xmlNode* _tmp38_;
						gchar* _tmp39_;
						_tmp38_ = child_node;
						_tmp39_ = (gchar*) xmlNodeGetContent (_tmp38_);
						_g_free0 (self->priv->lifetime);
						self->priv->lifetime = _tmp39_;
						break;
					}
				}
			} else if (_tmp16_ == ((0 != _tmp15_label6) ? _tmp15_label6 : (_tmp15_label6 = g_quark_from_static_string (UI_LISTING_PROTOCOL)))) {
				switch (0) {
					default:
					{
						ProtocolElem* _tmp40_ = NULL;
						xmlNode* _tmp41_;
						ProtocolElem* _tmp42_;
						GeeArrayList* _tmp43_;
						_tmp41_ = child_node;
						_tmp42_ = protocol_elem_new (_tmp41_, &_inner_error0_);
						_tmp40_ = _tmp42_;
						if (G_UNLIKELY (_inner_error0_ != NULL)) {
							if (_inner_error0_->domain == RYGEL_RUIH_SERVICE_ERROR) {
								g_propagate_error (error, _inner_error0_);
								_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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
								g_clear_error (&_inner_error0_);
								return NULL;
							}
						}
						_tmp43_ = self->priv->protocols;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp43_, _tmp40_);
						_ui_listing_unref0 (_tmp40_);
						break;
					}
				}
			} else {
				switch (0) {
					default:
					{
						gchar* msg = NULL;
						gchar* _tmp44_;
						const gchar* _tmp45_;
						const gchar* _tmp46_;
						gchar* _tmp47_;
						gchar* _tmp48_;
						GError* _tmp49_;
						GError* _tmp50_;
						_tmp44_ = g_strdup (_ ("Unable to parse UI data — unexpected node: %s"));
						msg = _tmp44_;
						_tmp45_ = msg;
						_tmp46_ = node_name;
						_tmp47_ = g_strdup_printf (_tmp45_, _tmp46_);
						_tmp48_ = _tmp47_;
						_tmp49_ = g_error_new_literal (RYGEL_RUIH_SERVICE_ERROR, RYGEL_RUIH_SERVICE_ERROR_OPERATION_REJECTED, _tmp48_);
						_tmp50_ = _tmp49_;
						_g_free0 (_tmp48_);
						_inner_error0_ = _tmp50_;
						if (_inner_error0_->domain == RYGEL_RUIH_SERVICE_ERROR) {
							g_propagate_error (error, _inner_error0_);
							_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_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
							g_clear_error (&_inner_error0_);
							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 gboolean
ui_elem_real_match (UIListing* base,
                    GeeArrayList* protocol_elements,
                    GeeArrayList* filters)
{
	UIElem * self;
	gboolean _tmp0_ = FALSE;
	gboolean result;
	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;
		gint _proto_size = 0;
		GeeArrayList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _proto_index = 0;
		_proto_list = protocol_elements;
		_tmp3_ = _proto_list;
		_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_proto_size = _tmp5_;
		_proto_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			ProtocolElem* proto = NULL;
			GeeArrayList* _tmp8_;
			gpointer _tmp9_;
			ProtocolElem* _tmp10_;
			GeeArrayList* _tmp11_;
			_proto_index = _proto_index + 1;
			_tmp6_ = _proto_index;
			_tmp7_ = _proto_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _proto_list;
			_tmp9_ = gee_abstract_list_get ((GeeAbstractList*) _tmp8_, _proto_index);
			proto = (ProtocolElem*) _tmp9_;
			_tmp10_ = proto;
			_tmp11_ = self->priv->protocols;
			if (ui_listing_match ((UIListing*) _tmp10_, _tmp11_, filters)) {
				result = TRUE;
				_ui_listing_unref0 (proto);
				return result;
			}
			_ui_listing_unref0 (proto);
		}
	}
	result = FALSE;
	return result;
}

static gchar*
ui_elem_real_to_ui_listing (UIListing* base,
                            GeeArrayList* filters)
{
	UIElem * self;
	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* _tmp41_;
	const gchar* _tmp42_;
	gint _tmp43_;
	gint _tmp44_;
	GString* protocol_sb = NULL;
	GString* _tmp50_;
	GeeArrayList* _tmp51_;
	gint _tmp52_;
	gint _tmp53_;
	GString* _tmp73_;
	gchar* result;
	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_;
		gint _icon_size = 0;
		GeeArrayList* _tmp30_;
		gint _tmp31_;
		gint _tmp32_;
		gint _icon_index = 0;
		_tmp29_ = self->priv->icons;
		_icon_list = _tmp29_;
		_tmp30_ = _icon_list;
		_tmp31_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp30_);
		_tmp32_ = _tmp31_;
		_icon_size = _tmp32_;
		_icon_index = -1;
		while (TRUE) {
			gint _tmp33_;
			gint _tmp34_;
			IconElem* icon = NULL;
			GeeArrayList* _tmp35_;
			gpointer _tmp36_;
			GString* _tmp37_;
			IconElem* _tmp38_;
			gchar* _tmp39_;
			gchar* _tmp40_;
			_icon_index = _icon_index + 1;
			_tmp33_ = _icon_index;
			_tmp34_ = _icon_size;
			if (!(_tmp33_ < _tmp34_)) {
				break;
			}
			_tmp35_ = _icon_list;
			_tmp36_ = gee_abstract_list_get ((GeeAbstractList*) _tmp35_, _icon_index);
			icon = (IconElem*) _tmp36_;
			_tmp37_ = icon_sb;
			_tmp38_ = icon;
			_tmp39_ = ui_listing_to_ui_listing ((UIListing*) _tmp38_, filters);
			_tmp40_ = _tmp39_;
			g_string_append (_tmp37_, _tmp40_);
			_g_free0 (_tmp40_);
			_ui_listing_unref0 (icon);
		}
	}
	_tmp41_ = icon_sb;
	_tmp42_ = _tmp41_->str;
	_tmp43_ = strlen (_tmp42_);
	_tmp44_ = _tmp43_;
	if (_tmp44_ > 0) {
		GString* _tmp45_;
		GString* _tmp46_;
		GString* _tmp47_;
		const gchar* _tmp48_;
		GString* _tmp49_;
		match = TRUE;
		_tmp45_ = sb;
		g_string_append (_tmp45_, "<" UI_LISTING_ICONLIST ">\n");
		_tmp46_ = sb;
		_tmp47_ = icon_sb;
		_tmp48_ = _tmp47_->str;
		g_string_append (_tmp46_, _tmp48_);
		_tmp49_ = sb;
		g_string_append (_tmp49_, "</" UI_LISTING_ICONLIST ">\n");
	}
	_tmp50_ = g_string_new ("");
	protocol_sb = _tmp50_;
	_tmp51_ = self->priv->protocols;
	_tmp52_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp51_);
	_tmp53_ = _tmp52_;
	if (_tmp53_ > 0) {
		GString* _tmp66_;
		const gchar* _tmp67_;
		gint _tmp68_;
		gint _tmp69_;
		{
			GeeArrayList* _protocol_list = NULL;
			GeeArrayList* _tmp54_;
			gint _protocol_size = 0;
			GeeArrayList* _tmp55_;
			gint _tmp56_;
			gint _tmp57_;
			gint _protocol_index = 0;
			_tmp54_ = self->priv->protocols;
			_protocol_list = _tmp54_;
			_tmp55_ = _protocol_list;
			_tmp56_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp55_);
			_tmp57_ = _tmp56_;
			_protocol_size = _tmp57_;
			_protocol_index = -1;
			while (TRUE) {
				gint _tmp58_;
				gint _tmp59_;
				ProtocolElem* protocol = NULL;
				GeeArrayList* _tmp60_;
				gpointer _tmp61_;
				GString* _tmp62_;
				ProtocolElem* _tmp63_;
				gchar* _tmp64_;
				gchar* _tmp65_;
				_protocol_index = _protocol_index + 1;
				_tmp58_ = _protocol_index;
				_tmp59_ = _protocol_size;
				if (!(_tmp58_ < _tmp59_)) {
					break;
				}
				_tmp60_ = _protocol_list;
				_tmp61_ = gee_abstract_list_get ((GeeAbstractList*) _tmp60_, _protocol_index);
				protocol = (ProtocolElem*) _tmp61_;
				_tmp62_ = protocol_sb;
				_tmp63_ = protocol;
				_tmp64_ = ui_listing_to_ui_listing ((UIListing*) _tmp63_, filters);
				_tmp65_ = _tmp64_;
				g_string_append (_tmp62_, _tmp65_);
				_g_free0 (_tmp65_);
				_ui_listing_unref0 (protocol);
			}
		}
		_tmp66_ = protocol_sb;
		_tmp67_ = _tmp66_->str;
		_tmp68_ = strlen (_tmp67_);
		_tmp69_ = _tmp68_;
		if (_tmp69_ > 0) {
			GString* _tmp70_;
			GString* _tmp71_;
			const gchar* _tmp72_;
			match = TRUE;
			_tmp70_ = sb;
			_tmp71_ = protocol_sb;
			_tmp72_ = _tmp71_->str;
			g_string_append (_tmp70_, _tmp72_);
		}
	}
	_tmp73_ = sb;
	g_string_append (_tmp73_, "</" UI_LISTING_UI ">\n");
	if (match) {
		GString* _tmp74_;
		const gchar* _tmp75_;
		gchar* _tmp76_;
		_tmp74_ = sb;
		_tmp75_ = _tmp74_->str;
		_tmp76_ = g_strdup (_tmp75_);
		result = _tmp76_;
		_g_string_free0 (protocol_sb);
		_g_string_free0 (icon_sb);
		_g_string_free0 (sb);
		_g_object_unref0 (elements);
		return result;
	} else {
		gchar* _tmp77_;
		_tmp77_ = g_strdup ("");
		result = _tmp77_;
		_g_string_free0 (protocol_sb);
		_g_string_free0 (icon_sb);
		_g_string_free0 (sb);
		_g_object_unref0 (elements);
		return result;
	}
}

static void
ui_elem_class_init (UIElemClass * klass,
                    gpointer klass_data)
{
	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,
                       gpointer klass)
{
	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);
}

 G_GNUC_NO_INLINE static GType
ui_elem_get_type_once (void)
{
	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));
	return ui_elem_type_id;
}

GType
ui_elem_get_type (void)
{
	static volatile gsize ui_elem_type_id__once = 0;
	if (g_once_init_enter (&ui_elem_type_id__once)) {
		GType ui_elem_type_id;
		ui_elem_type_id = ui_elem_get_type_once ();
		g_once_init_leave (&ui_elem_type_id__once, ui_elem_type_id);
	}
	return ui_elem_type_id__once;
}

