/* rygel-ruih-ui-elem.c generated by valac 0.32.1, 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 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;
#define UI_ELEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_UI_ELEM, UIElemPrivate))
enum  {
	UI_ELEM_DUMMY_PROPERTY
};
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);


UIElem* ui_elem_construct (GType object_type, xmlNode* node, GError** error) {
	UIElem* self = NULL;
	GeeArrayList* _tmp0_ = NULL;
	GeeArrayList* _tmp1_ = NULL;
	GError * _inner_error_ = NULL;
	self = (UIElem*) ui_listing_construct (object_type);
	_tmp0_ = gee_array_list_new (TYPE_ICON_ELEM, (GBoxedCopyFunc) ui_listing_ref, 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, ui_listing_unref, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->protocols);
	self->priv->protocols = _tmp1_;
	{
		RygelXMLUtilsIterator* _child_node_it = NULL;
		xmlNode* _tmp2_ = NULL;
		RygelXMLUtilsChildIterator* _tmp3_ = NULL;
		RygelXMLUtilsChildIterator* _tmp4_ = NULL;
		RygelXMLUtilsIterator* _tmp5_ = NULL;
		RygelXMLUtilsIterator* _tmp6_ = NULL;
		_tmp2_ = node;
		_tmp3_ = rygel_xml_utils_child_iterator_new (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = rygel_xml_utils_iterator_iterator ((RygelXMLUtilsIterator*) _tmp4_);
		_tmp6_ = _tmp5_;
		_rygel_xml_utils_iterator_unref0 (_tmp4_);
		_child_node_it = _tmp6_;
		while (TRUE) {
			RygelXMLUtilsIterator* _tmp7_ = NULL;
			gboolean _tmp8_ = FALSE;
			xmlNode* child_node = NULL;
			RygelXMLUtilsIterator* _tmp9_ = NULL;
			xmlNode* _tmp10_ = NULL;
			xmlNode* _tmp11_ = NULL;
			xmlElementType _tmp12_ = 0;
			gchar* node_name = NULL;
			xmlNode* _tmp13_ = NULL;
			const gchar* _tmp14_ = NULL;
			gchar* _tmp15_ = NULL;
			const gchar* _tmp16_ = NULL;
			const gchar* _tmp17_ = NULL;
			GQuark _tmp19_ = 0U;
			_tmp7_ = _child_node_it;
			_tmp8_ = rygel_xml_utils_iterator_next (_tmp7_);
			if (!_tmp8_) {
				break;
			}
			_tmp9_ = _child_node_it;
			_tmp10_ = rygel_xml_utils_iterator_get (_tmp9_);
			child_node = _tmp10_;
			_tmp11_ = child_node;
			_tmp12_ = _tmp11_->type;
			if (_tmp12_ == XML_TEXT_NODE) {
				continue;
			}
			_tmp13_ = child_node;
			_tmp14_ = _tmp13_->name;
			_tmp15_ = g_strdup (_tmp14_);
			node_name = _tmp15_;
			_tmp16_ = node_name;
			_tmp17_ = _tmp16_;
			_tmp19_ = (NULL == _tmp17_) ? 0 : g_quark_from_string (_tmp17_);
			if (_tmp19_ == g_quark_from_string (UI_LISTING_UIID)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp20_ = NULL;
						gchar* _tmp21_ = NULL;
						_tmp20_ = child_node;
						_tmp21_ = (gchar*) xmlNodeGetContent (_tmp20_);
						_g_free0 (self->priv->id);
						self->priv->id = _tmp21_;
						break;
					}
				}
			} else if (_tmp19_ == g_quark_from_string (UI_LISTING_NAME)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp22_ = NULL;
						gchar* _tmp23_ = NULL;
						_tmp22_ = child_node;
						_tmp23_ = (gchar*) xmlNodeGetContent (_tmp22_);
						_g_free0 (self->priv->name);
						self->priv->name = _tmp23_;
						break;
					}
				}
			} else if (_tmp19_ == g_quark_from_string (UI_LISTING_DESCRIPTION)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp24_ = NULL;
						gchar* _tmp25_ = NULL;
						_tmp24_ = child_node;
						_tmp25_ = (gchar*) xmlNodeGetContent (_tmp24_);
						_g_free0 (self->priv->description);
						self->priv->description = _tmp25_;
						break;
					}
				}
			} else if (_tmp19_ == g_quark_from_string (UI_LISTING_ICONLIST)) {
				switch (0) {
					default:
					{
						RygelXMLUtilsChildIterator* it = NULL;
						xmlNode* _tmp26_ = NULL;
						RygelXMLUtilsChildIterator* _tmp27_ = NULL;
						_tmp26_ = child_node;
						_tmp27_ = rygel_xml_utils_child_iterator_new (_tmp26_);
						it = _tmp27_;
						{
							RygelXMLUtilsIterator* _icon_node_it = NULL;
							RygelXMLUtilsChildIterator* _tmp28_ = NULL;
							RygelXMLUtilsIterator* _tmp29_ = NULL;
							_tmp28_ = it;
							_tmp29_ = rygel_xml_utils_iterator_iterator ((RygelXMLUtilsIterator*) _tmp28_);
							_icon_node_it = _tmp29_;
							while (TRUE) {
								RygelXMLUtilsIterator* _tmp30_ = NULL;
								gboolean _tmp31_ = FALSE;
								xmlNode* icon_node = NULL;
								RygelXMLUtilsIterator* _tmp32_ = NULL;
								xmlNode* _tmp33_ = NULL;
								xmlNode* _tmp34_ = NULL;
								const gchar* _tmp35_ = NULL;
								_tmp30_ = _icon_node_it;
								_tmp31_ = rygel_xml_utils_iterator_next (_tmp30_);
								if (!_tmp31_) {
									break;
								}
								_tmp32_ = _icon_node_it;
								_tmp33_ = rygel_xml_utils_iterator_get (_tmp32_);
								icon_node = _tmp33_;
								_tmp34_ = icon_node;
								_tmp35_ = _tmp34_->name;
								if (g_strcmp0 (_tmp35_, UI_LISTING_ICON) == 0) {
									IconElem* _tmp36_ = NULL;
									xmlNode* _tmp37_ = NULL;
									IconElem* _tmp38_ = NULL;
									GeeArrayList* _tmp39_ = NULL;
									_tmp37_ = icon_node;
									_tmp38_ = icon_elem_new (_tmp37_, &_inner_error_);
									_tmp36_ = _tmp38_;
									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;
										}
									}
									_tmp39_ = self->priv->icons;
									gee_abstract_collection_add ((GeeAbstractCollection*) _tmp39_, _tmp36_);
									_ui_listing_unref0 (_tmp36_);
								}
							}
							_rygel_xml_utils_iterator_unref0 (_icon_node_it);
						}
						_rygel_xml_utils_iterator_unref0 (it);
						break;
					}
				}
			} else if (_tmp19_ == g_quark_from_string (UI_LISTING_FORK)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp40_ = NULL;
						gchar* _tmp41_ = NULL;
						_tmp40_ = child_node;
						_tmp41_ = (gchar*) xmlNodeGetContent (_tmp40_);
						_g_free0 (self->priv->fork);
						self->priv->fork = _tmp41_;
						break;
					}
				}
			} else if (_tmp19_ == g_quark_from_string (UI_LISTING_LIFETIME)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp42_ = NULL;
						gchar* _tmp43_ = NULL;
						_tmp42_ = child_node;
						_tmp43_ = (gchar*) xmlNodeGetContent (_tmp42_);
						_g_free0 (self->priv->lifetime);
						self->priv->lifetime = _tmp43_;
						break;
					}
				}
			} else if (_tmp19_ == g_quark_from_string (UI_LISTING_PROTOCOL)) {
				switch (0) {
					default:
					{
						ProtocolElem* _tmp44_ = NULL;
						xmlNode* _tmp45_ = NULL;
						ProtocolElem* _tmp46_ = NULL;
						GeeArrayList* _tmp47_ = NULL;
						_tmp45_ = child_node;
						_tmp46_ = protocol_elem_new (_tmp45_, &_inner_error_);
						_tmp44_ = _tmp46_;
						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;
							}
						}
						_tmp47_ = self->priv->protocols;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp47_, _tmp44_);
						_ui_listing_unref0 (_tmp44_);
						break;
					}
				}
			} else {
				switch (0) {
					default:
					{
						gchar* msg = NULL;
						const gchar* _tmp48_ = NULL;
						gchar* _tmp49_ = NULL;
						const gchar* _tmp50_ = NULL;
						const gchar* _tmp51_ = NULL;
						gchar* _tmp52_ = NULL;
						gchar* _tmp53_ = NULL;
						GError* _tmp54_ = NULL;
						GError* _tmp55_ = NULL;
						_tmp48_ = _ ("Unable to parse UI data - unexpected node: %s");
						_tmp49_ = g_strdup (_tmp48_);
						msg = _tmp49_;
						_tmp50_ = msg;
						_tmp51_ = node_name;
						_tmp52_ = g_strdup_printf (_tmp50_, _tmp51_);
						_tmp53_ = _tmp52_;
						_tmp54_ = g_error_new_literal (RYGEL_RUIH_SERVICE_ERROR, RYGEL_RUIH_SERVICE_ERROR_OPERATION_REJECTED, _tmp53_);
						_tmp55_ = _tmp54_;
						_g_free0 (_tmp53_);
						_inner_error_ = _tmp55_;
						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;
	GeeArrayList* _tmp1_ = NULL;
	self = (UIElem*) base;
	g_return_val_if_fail (filters != NULL, FALSE);
	_tmp1_ = protocol_elements;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GeeArrayList* _tmp2_ = NULL;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		_tmp2_ = protocol_elements;
		_tmp3_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == 0;
	}
	if (_tmp0_) {
		result = TRUE;
		return result;
	}
	{
		GeeArrayList* _proto_list = NULL;
		GeeArrayList* _tmp5_ = NULL;
		GeeArrayList* _tmp6_ = NULL;
		gint _proto_size = 0;
		GeeArrayList* _tmp7_ = NULL;
		gint _tmp8_ = 0;
		gint _tmp9_ = 0;
		gint _proto_index = 0;
		_tmp5_ = protocol_elements;
		_tmp6_ = _g_object_ref0 (_tmp5_);
		_proto_list = _tmp6_;
		_tmp7_ = _proto_list;
		_tmp8_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp7_);
		_tmp9_ = _tmp8_;
		_proto_size = _tmp9_;
		_proto_index = -1;
		while (TRUE) {
			gint _tmp10_ = 0;
			gint _tmp11_ = 0;
			gint _tmp12_ = 0;
			ProtocolElem* proto = NULL;
			GeeArrayList* _tmp13_ = NULL;
			gint _tmp14_ = 0;
			gpointer _tmp15_ = NULL;
			ProtocolElem* _tmp16_ = NULL;
			GeeArrayList* _tmp17_ = NULL;
			GeeArrayList* _tmp18_ = NULL;
			gboolean _tmp19_ = FALSE;
			_tmp10_ = _proto_index;
			_proto_index = _tmp10_ + 1;
			_tmp11_ = _proto_index;
			_tmp12_ = _proto_size;
			if (!(_tmp11_ < _tmp12_)) {
				break;
			}
			_tmp13_ = _proto_list;
			_tmp14_ = _proto_index;
			_tmp15_ = gee_abstract_list_get ((GeeAbstractList*) _tmp13_, _tmp14_);
			proto = (ProtocolElem*) _tmp15_;
			_tmp16_ = proto;
			_tmp17_ = self->priv->protocols;
			_tmp18_ = filters;
			_tmp19_ = ui_listing_match ((UIListing*) _tmp16_, _tmp17_, _tmp18_);
			if (_tmp19_) {
				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_ = NULL;
	gboolean match = FALSE;
	GeeHashMap* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	GeeHashMap* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	GeeHashMap* _tmp5_ = NULL;
	const gchar* _tmp6_ = NULL;
	GeeHashMap* _tmp7_ = NULL;
	const gchar* _tmp8_ = NULL;
	GeeHashMap* _tmp9_ = NULL;
	const gchar* _tmp10_ = NULL;
	gboolean _tmp11_ = FALSE;
	const gchar* _tmp12_ = NULL;
	gboolean _tmp16_ = FALSE;
	const gchar* _tmp17_ = NULL;
	gboolean _tmp21_ = FALSE;
	const gchar* _tmp22_ = NULL;
	gboolean _tmp26_ = FALSE;
	const gchar* _tmp27_ = NULL;
	GString* sb = NULL;
	GString* _tmp31_ = NULL;
	GString* _tmp32_ = NULL;
	GeeHashMap* _tmp33_ = NULL;
	gchar* _tmp34_ = NULL;
	gchar* _tmp35_ = NULL;
	GString* icon_sb = NULL;
	GString* _tmp36_ = NULL;
	GString* _tmp53_ = NULL;
	const gchar* _tmp54_ = NULL;
	gint _tmp55_ = 0;
	gint _tmp56_ = 0;
	GString* protocol_sb = NULL;
	GString* _tmp62_ = NULL;
	GeeArrayList* _tmp63_ = NULL;
	gint _tmp64_ = 0;
	gint _tmp65_ = 0;
	GString* _tmp89_ = NULL;
	gboolean _tmp90_ = FALSE;
	self = (UIElem*) base;
	g_return_val_if_fail (filters != NULL, NULL);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, 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) {
		GeeArrayList* _tmp13_ = NULL;
		const gchar* _tmp14_ = NULL;
		gboolean _tmp15_ = FALSE;
		_tmp13_ = filters;
		_tmp14_ = self->priv->name;
		_tmp15_ = ui_listing_filters_match ((UIListing*) self, _tmp13_, UI_LISTING_NAME, _tmp14_);
		_tmp11_ = _tmp15_;
	} else {
		_tmp11_ = FALSE;
	}
	if (_tmp11_) {
		match = TRUE;
	}
	_tmp17_ = self->priv->description;
	if (_tmp17_ != NULL) {
		GeeArrayList* _tmp18_ = NULL;
		const gchar* _tmp19_ = NULL;
		gboolean _tmp20_ = FALSE;
		_tmp18_ = filters;
		_tmp19_ = self->priv->description;
		_tmp20_ = ui_listing_filters_match ((UIListing*) self, _tmp18_, UI_LISTING_DESCRIPTION, _tmp19_);
		_tmp16_ = _tmp20_;
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		match = TRUE;
	}
	_tmp22_ = self->priv->fork;
	if (_tmp22_ != NULL) {
		GeeArrayList* _tmp23_ = NULL;
		const gchar* _tmp24_ = NULL;
		gboolean _tmp25_ = FALSE;
		_tmp23_ = filters;
		_tmp24_ = self->priv->fork;
		_tmp25_ = ui_listing_filters_match ((UIListing*) self, _tmp23_, UI_LISTING_FORK, _tmp24_);
		_tmp21_ = _tmp25_;
	} else {
		_tmp21_ = FALSE;
	}
	if (_tmp21_) {
		match = TRUE;
	}
	_tmp27_ = self->priv->lifetime;
	if (_tmp27_ != NULL) {
		GeeArrayList* _tmp28_ = NULL;
		const gchar* _tmp29_ = NULL;
		gboolean _tmp30_ = FALSE;
		_tmp28_ = filters;
		_tmp29_ = self->priv->lifetime;
		_tmp30_ = ui_listing_filters_match ((UIListing*) self, _tmp28_, UI_LISTING_LIFETIME, _tmp29_);
		_tmp26_ = _tmp30_;
	} else {
		_tmp26_ = FALSE;
	}
	if (_tmp26_) {
		match = TRUE;
	}
	_tmp31_ = g_string_new ("<" UI_LISTING_UI ">\n");
	sb = _tmp31_;
	_tmp32_ = sb;
	_tmp33_ = elements;
	_tmp34_ = ui_listing_to_xml ((UIListing*) self, _tmp33_);
	_tmp35_ = _tmp34_;
	g_string_append (_tmp32_, _tmp35_);
	_g_free0 (_tmp35_);
	_tmp36_ = g_string_new ("");
	icon_sb = _tmp36_;
	{
		GeeArrayList* _icon_list = NULL;
		GeeArrayList* _tmp37_ = NULL;
		GeeArrayList* _tmp38_ = NULL;
		gint _icon_size = 0;
		GeeArrayList* _tmp39_ = NULL;
		gint _tmp40_ = 0;
		gint _tmp41_ = 0;
		gint _icon_index = 0;
		_tmp37_ = self->priv->icons;
		_tmp38_ = _g_object_ref0 (_tmp37_);
		_icon_list = _tmp38_;
		_tmp39_ = _icon_list;
		_tmp40_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp39_);
		_tmp41_ = _tmp40_;
		_icon_size = _tmp41_;
		_icon_index = -1;
		while (TRUE) {
			gint _tmp42_ = 0;
			gint _tmp43_ = 0;
			gint _tmp44_ = 0;
			IconElem* icon = NULL;
			GeeArrayList* _tmp45_ = NULL;
			gint _tmp46_ = 0;
			gpointer _tmp47_ = NULL;
			GString* _tmp48_ = NULL;
			IconElem* _tmp49_ = NULL;
			GeeArrayList* _tmp50_ = NULL;
			gchar* _tmp51_ = NULL;
			gchar* _tmp52_ = NULL;
			_tmp42_ = _icon_index;
			_icon_index = _tmp42_ + 1;
			_tmp43_ = _icon_index;
			_tmp44_ = _icon_size;
			if (!(_tmp43_ < _tmp44_)) {
				break;
			}
			_tmp45_ = _icon_list;
			_tmp46_ = _icon_index;
			_tmp47_ = gee_abstract_list_get ((GeeAbstractList*) _tmp45_, _tmp46_);
			icon = (IconElem*) _tmp47_;
			_tmp48_ = icon_sb;
			_tmp49_ = icon;
			_tmp50_ = filters;
			_tmp51_ = ui_listing_to_ui_listing ((UIListing*) _tmp49_, _tmp50_);
			_tmp52_ = _tmp51_;
			g_string_append (_tmp48_, _tmp52_);
			_g_free0 (_tmp52_);
			_ui_listing_unref0 (icon);
		}
		_g_object_unref0 (_icon_list);
	}
	_tmp53_ = icon_sb;
	_tmp54_ = _tmp53_->str;
	_tmp55_ = strlen (_tmp54_);
	_tmp56_ = _tmp55_;
	if (_tmp56_ > 0) {
		GString* _tmp57_ = NULL;
		GString* _tmp58_ = NULL;
		GString* _tmp59_ = NULL;
		const gchar* _tmp60_ = NULL;
		GString* _tmp61_ = NULL;
		match = TRUE;
		_tmp57_ = sb;
		g_string_append (_tmp57_, "<" UI_LISTING_ICONLIST ">\n");
		_tmp58_ = sb;
		_tmp59_ = icon_sb;
		_tmp60_ = _tmp59_->str;
		g_string_append (_tmp58_, _tmp60_);
		_tmp61_ = sb;
		g_string_append (_tmp61_, "</" UI_LISTING_ICONLIST ">\n");
	}
	_tmp62_ = g_string_new ("");
	protocol_sb = _tmp62_;
	_tmp63_ = self->priv->protocols;
	_tmp64_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp63_);
	_tmp65_ = _tmp64_;
	if (_tmp65_ > 0) {
		GString* _tmp82_ = NULL;
		const gchar* _tmp83_ = NULL;
		gint _tmp84_ = 0;
		gint _tmp85_ = 0;
		{
			GeeArrayList* _protocol_list = NULL;
			GeeArrayList* _tmp66_ = NULL;
			GeeArrayList* _tmp67_ = NULL;
			gint _protocol_size = 0;
			GeeArrayList* _tmp68_ = NULL;
			gint _tmp69_ = 0;
			gint _tmp70_ = 0;
			gint _protocol_index = 0;
			_tmp66_ = self->priv->protocols;
			_tmp67_ = _g_object_ref0 (_tmp66_);
			_protocol_list = _tmp67_;
			_tmp68_ = _protocol_list;
			_tmp69_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp68_);
			_tmp70_ = _tmp69_;
			_protocol_size = _tmp70_;
			_protocol_index = -1;
			while (TRUE) {
				gint _tmp71_ = 0;
				gint _tmp72_ = 0;
				gint _tmp73_ = 0;
				ProtocolElem* protocol = NULL;
				GeeArrayList* _tmp74_ = NULL;
				gint _tmp75_ = 0;
				gpointer _tmp76_ = NULL;
				GString* _tmp77_ = NULL;
				ProtocolElem* _tmp78_ = NULL;
				GeeArrayList* _tmp79_ = NULL;
				gchar* _tmp80_ = NULL;
				gchar* _tmp81_ = NULL;
				_tmp71_ = _protocol_index;
				_protocol_index = _tmp71_ + 1;
				_tmp72_ = _protocol_index;
				_tmp73_ = _protocol_size;
				if (!(_tmp72_ < _tmp73_)) {
					break;
				}
				_tmp74_ = _protocol_list;
				_tmp75_ = _protocol_index;
				_tmp76_ = gee_abstract_list_get ((GeeAbstractList*) _tmp74_, _tmp75_);
				protocol = (ProtocolElem*) _tmp76_;
				_tmp77_ = protocol_sb;
				_tmp78_ = protocol;
				_tmp79_ = filters;
				_tmp80_ = ui_listing_to_ui_listing ((UIListing*) _tmp78_, _tmp79_);
				_tmp81_ = _tmp80_;
				g_string_append (_tmp77_, _tmp81_);
				_g_free0 (_tmp81_);
				_ui_listing_unref0 (protocol);
			}
			_g_object_unref0 (_protocol_list);
		}
		_tmp82_ = protocol_sb;
		_tmp83_ = _tmp82_->str;
		_tmp84_ = strlen (_tmp83_);
		_tmp85_ = _tmp84_;
		if (_tmp85_ > 0) {
			GString* _tmp86_ = NULL;
			GString* _tmp87_ = NULL;
			const gchar* _tmp88_ = NULL;
			match = TRUE;
			_tmp86_ = sb;
			_tmp87_ = protocol_sb;
			_tmp88_ = _tmp87_->str;
			g_string_append (_tmp86_, _tmp88_);
		}
	}
	_tmp89_ = sb;
	g_string_append (_tmp89_, "</" UI_LISTING_UI ">\n");
	_tmp90_ = match;
	if (_tmp90_) {
		GString* _tmp91_ = NULL;
		const gchar* _tmp92_ = NULL;
		gchar* _tmp93_ = NULL;
		_tmp91_ = sb;
		_tmp92_ = _tmp91_->str;
		_tmp93_ = g_strdup (_tmp92_);
		result = _tmp93_;
		_g_string_free0 (protocol_sb);
		_g_string_free0 (icon_sb);
		_g_string_free0 (sb);
		_g_object_unref0 (elements);
		return result;
	} else {
		gchar* _tmp94_ = NULL;
		_tmp94_ = g_strdup ("");
		result = _tmp94_;
		_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_add_private (klass, sizeof (UIElemPrivate));
	((UIListingClass *) klass)->match = ui_elem_real_match;
	((UIListingClass *) klass)->to_ui_listing = ui_elem_real_to_ui_listing;
}


static void ui_elem_instance_init (UIElem * self) {
	self->priv = UI_ELEM_GET_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);
		g_once_init_leave (&ui_elem_type_id__volatile, ui_elem_type_id);
	}
	return ui_elem_type_id__volatile;
}



