/* rygel-ruih-protocol-elem.c generated by valac 0.31.1.6-4f062, the Vala compiler
 * generated from rygel-ruih-protocol-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 <glib/gi18n-lib.h>
#include <rygel-core.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;
typedef struct _ProtocolElemPrivate ProtocolElemPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _ui_listing_unref0(var) ((var == NULL) ? NULL : (var = (ui_listing_unref (var), NULL)))
#define _rygel_xml_utils_iterator_unref0(var) ((var == NULL) ? NULL : (var = (rygel_xml_utils_iterator_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 _ProtocolElem {
	UIListing parent_instance;
	ProtocolElemPrivate * priv;
};

struct _ProtocolElemClass {
	UIListingClass parent_class;
};

struct _ProtocolElemPrivate {
	gchar* short_name;
	gchar* protocol_info;
	GeeArrayList* uris;
};

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 protocol_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;
#define PROTOCOL_ELEM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_PROTOCOL_ELEM, ProtocolElemPrivate))
enum  {
	PROTOCOL_ELEM_DUMMY_PROPERTY
};
GQuark rygel_ruih_service_error_quark (void);
ProtocolElem* protocol_elem_new (xmlNode* node, GError** error);
ProtocolElem* protocol_elem_construct (GType object_type, xmlNode* node, GError** error);
UIListing* ui_listing_construct (GType object_type);
#define UI_LISTING_SHORT_NAME "shortName"
#define UI_LISTING_URI "uri"
#define UI_LISTING_PROTOCOL_INFO "protocolInfo"
gchar* protocol_elem_get_short_name (ProtocolElem* self);
gchar* protocol_elem_get_protocol_info (ProtocolElem* self);
static gboolean protocol_elem_real_match (UIListing* base, GeeArrayList* protocols, GeeArrayList* filters);
static gchar* protocol_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_PROTOCOL "protocol"
gchar* ui_listing_to_xml (UIListing* self, GeeHashMap* hash_map);
static void protocol_elem_finalize (UIListing* obj);


ProtocolElem* protocol_elem_construct (GType object_type, xmlNode* node, GError** error) {
	ProtocolElem* self = NULL;
	GeeArrayList* _tmp0_ = NULL;
	GError * _inner_error_ = NULL;
	self = (ProtocolElem*) ui_listing_construct (object_type);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->uris);
	self->priv->uris = _tmp0_;
	{
		xmlAttr* prop = NULL;
		xmlNode* _tmp1_ = NULL;
		xmlAttr* _tmp2_ = NULL;
		_tmp1_ = node;
		_tmp2_ = _tmp1_->properties;
		prop = _tmp2_;
		{
			gboolean _tmp3_ = FALSE;
			_tmp3_ = TRUE;
			while (TRUE) {
				xmlAttr* _tmp6_ = NULL;
				gchar* attr_name = NULL;
				xmlAttr* _tmp7_ = NULL;
				const gchar* _tmp8_ = NULL;
				gchar* _tmp9_ = NULL;
				const gchar* _tmp10_ = NULL;
				const gchar* _tmp11_ = NULL;
				GQuark _tmp13_ = 0U;
				if (!_tmp3_) {
					xmlAttr* _tmp4_ = NULL;
					xmlAttr* _tmp5_ = NULL;
					_tmp4_ = prop;
					_tmp5_ = _tmp4_->next;
					prop = _tmp5_;
				}
				_tmp3_ = FALSE;
				_tmp6_ = prop;
				if (!(_tmp6_ != NULL)) {
					break;
				}
				_tmp7_ = prop;
				_tmp8_ = _tmp7_->name;
				_tmp9_ = g_strdup (_tmp8_);
				attr_name = _tmp9_;
				_tmp10_ = attr_name;
				_tmp11_ = _tmp10_;
				_tmp13_ = (NULL == _tmp11_) ? 0 : g_quark_from_string (_tmp11_);
				if (_tmp13_ == g_quark_from_string (UI_LISTING_SHORT_NAME)) {
					switch (0) {
						default:
						{
							xmlAttr* _tmp14_ = NULL;
							xmlNode* _tmp15_ = NULL;
							const gchar* _tmp16_ = NULL;
							gchar* _tmp17_ = NULL;
							_tmp14_ = prop;
							_tmp15_ = _tmp14_->children;
							_tmp16_ = _tmp15_->content;
							_tmp17_ = g_strdup (_tmp16_);
							_g_free0 (self->priv->short_name);
							self->priv->short_name = _tmp17_;
							break;
						}
					}
				} else {
					switch (0) {
						default:
						{
							gchar* msg = NULL;
							const gchar* _tmp18_ = NULL;
							gchar* _tmp19_ = NULL;
							const gchar* _tmp20_ = NULL;
							const gchar* _tmp21_ = NULL;
							gchar* _tmp22_ = NULL;
							gchar* _tmp23_ = NULL;
							GError* _tmp24_ = NULL;
							GError* _tmp25_ = NULL;
							_tmp18_ = _ ("Unable to parse Protocol data - unexpected attribute: %s");
							_tmp19_ = g_strdup (_tmp18_);
							msg = _tmp19_;
							_tmp20_ = msg;
							_tmp21_ = attr_name;
							_tmp22_ = g_strdup_printf (_tmp20_, _tmp21_);
							_tmp23_ = _tmp22_;
							_tmp24_ = g_error_new_literal (RYGEL_RUIH_SERVICE_ERROR, RYGEL_RUIH_SERVICE_ERROR_OPERATION_REJECTED, _tmp23_);
							_tmp25_ = _tmp24_;
							_g_free0 (_tmp23_);
							_inner_error_ = _tmp25_;
							if (_inner_error_->domain == RYGEL_RUIH_SERVICE_ERROR) {
								g_propagate_error (error, _inner_error_);
								_g_free0 (msg);
								_g_free0 (attr_name);
								_ui_listing_unref0 (self);
								return NULL;
							} else {
								_g_free0 (msg);
								_g_free0 (attr_name);
								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 (attr_name);
			}
		}
	}
	{
		RygelXMLUtilsIterator* _child_node_it = NULL;
		xmlNode* _tmp26_ = NULL;
		RygelXMLUtilsChildIterator* _tmp27_ = NULL;
		RygelXMLUtilsChildIterator* _tmp28_ = NULL;
		RygelXMLUtilsIterator* _tmp29_ = NULL;
		RygelXMLUtilsIterator* _tmp30_ = NULL;
		_tmp26_ = node;
		_tmp27_ = rygel_xml_utils_child_iterator_new (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = rygel_xml_utils_iterator_iterator ((RygelXMLUtilsIterator*) _tmp28_);
		_tmp30_ = _tmp29_;
		_rygel_xml_utils_iterator_unref0 (_tmp28_);
		_child_node_it = _tmp30_;
		while (TRUE) {
			RygelXMLUtilsIterator* _tmp31_ = NULL;
			gboolean _tmp32_ = FALSE;
			xmlNode* child_node = NULL;
			RygelXMLUtilsIterator* _tmp33_ = NULL;
			xmlNode* _tmp34_ = NULL;
			xmlNode* _tmp35_ = NULL;
			xmlElementType _tmp36_ = 0;
			gchar* node_name = NULL;
			xmlNode* _tmp37_ = NULL;
			const gchar* _tmp38_ = NULL;
			gchar* _tmp39_ = NULL;
			const gchar* _tmp40_ = NULL;
			const gchar* _tmp41_ = NULL;
			GQuark _tmp43_ = 0U;
			_tmp31_ = _child_node_it;
			_tmp32_ = rygel_xml_utils_iterator_next (_tmp31_);
			if (!_tmp32_) {
				break;
			}
			_tmp33_ = _child_node_it;
			_tmp34_ = rygel_xml_utils_iterator_get (_tmp33_);
			child_node = _tmp34_;
			_tmp35_ = child_node;
			_tmp36_ = _tmp35_->type;
			if (_tmp36_ == XML_TEXT_NODE) {
				continue;
			}
			_tmp37_ = child_node;
			_tmp38_ = _tmp37_->name;
			_tmp39_ = g_strdup (_tmp38_);
			node_name = _tmp39_;
			_tmp40_ = node_name;
			_tmp41_ = _tmp40_;
			_tmp43_ = (NULL == _tmp41_) ? 0 : g_quark_from_string (_tmp41_);
			if (_tmp43_ == g_quark_from_string (UI_LISTING_URI)) {
				switch (0) {
					default:
					{
						GeeArrayList* _tmp44_ = NULL;
						xmlNode* _tmp45_ = NULL;
						gchar* _tmp46_ = NULL;
						gchar* _tmp47_ = NULL;
						_tmp44_ = self->priv->uris;
						_tmp45_ = child_node;
						_tmp46_ = (gchar*) xmlNodeGetContent (_tmp45_);
						_tmp47_ = _tmp46_;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp44_, _tmp47_);
						_g_free0 (_tmp47_);
						break;
					}
				}
			} else if (_tmp43_ == g_quark_from_string (UI_LISTING_PROTOCOL_INFO)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp48_ = NULL;
						gchar* _tmp49_ = NULL;
						_tmp48_ = child_node;
						_tmp49_ = (gchar*) xmlNodeGetContent (_tmp48_);
						_g_free0 (self->priv->protocol_info);
						self->priv->protocol_info = _tmp49_;
						break;
					}
				}
			} else {
				switch (0) {
					default:
					{
						gchar* msg = NULL;
						const gchar* _tmp50_ = NULL;
						gchar* _tmp51_ = NULL;
						const gchar* _tmp52_ = NULL;
						const gchar* _tmp53_ = NULL;
						gchar* _tmp54_ = NULL;
						gchar* _tmp55_ = NULL;
						GError* _tmp56_ = NULL;
						GError* _tmp57_ = NULL;
						_tmp50_ = _ ("Unable to parse Protocol data - unexpected node: %s");
						_tmp51_ = g_strdup (_tmp50_);
						msg = _tmp51_;
						_tmp52_ = msg;
						_tmp53_ = node_name;
						_tmp54_ = g_strdup_printf (_tmp52_, _tmp53_);
						_tmp55_ = _tmp54_;
						_tmp56_ = g_error_new_literal (RYGEL_RUIH_SERVICE_ERROR, RYGEL_RUIH_SERVICE_ERROR_OPERATION_REJECTED, _tmp55_);
						_tmp57_ = _tmp56_;
						_g_free0 (_tmp55_);
						_inner_error_ = _tmp57_;
						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;
}


ProtocolElem* protocol_elem_new (xmlNode* node, GError** error) {
	return protocol_elem_construct (TYPE_PROTOCOL_ELEM, node, error);
}


gchar* protocol_elem_get_short_name (ProtocolElem* self) {
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->short_name;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}


gchar* protocol_elem_get_protocol_info (ProtocolElem* self) {
	gchar* result = NULL;
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->protocol_info;
	_tmp1_ = g_strdup (_tmp0_);
	result = _tmp1_;
	return result;
}


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


static gboolean protocol_elem_real_match (UIListing* base, GeeArrayList* protocols, GeeArrayList* filters) {
	ProtocolElem * self;
	gboolean result = FALSE;
	gboolean _tmp0_ = FALSE;
	GeeArrayList* _tmp1_ = NULL;
	self = (ProtocolElem*) base;
	g_return_val_if_fail (filters != NULL, FALSE);
	_tmp1_ = protocols;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GeeArrayList* _tmp2_ = NULL;
		gint _tmp3_ = 0;
		gint _tmp4_ = 0;
		_tmp2_ = protocols;
		_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_ = protocols;
		_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;
			const gchar* _tmp16_ = NULL;
			ProtocolElem* _tmp17_ = NULL;
			gchar* _tmp18_ = NULL;
			gchar* _tmp19_ = NULL;
			gboolean _tmp20_ = 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_ = self->priv->short_name;
			_tmp17_ = proto;
			_tmp18_ = protocol_elem_get_short_name (_tmp17_);
			_tmp19_ = _tmp18_;
			_tmp20_ = g_strcmp0 (_tmp16_, _tmp19_) == 0;
			_g_free0 (_tmp19_);
			if (_tmp20_) {
				gboolean _tmp21_ = FALSE;
				ProtocolElem* _tmp22_ = NULL;
				gchar* _tmp23_ = NULL;
				gchar* _tmp24_ = NULL;
				gboolean _tmp25_ = FALSE;
				_tmp22_ = proto;
				_tmp23_ = protocol_elem_get_protocol_info (_tmp22_);
				_tmp24_ = _tmp23_;
				_tmp25_ = _tmp24_ != NULL;
				_g_free0 (_tmp24_);
				if (_tmp25_) {
					ProtocolElem* _tmp26_ = NULL;
					gchar* _tmp27_ = NULL;
					gchar* _tmp28_ = NULL;
					const gchar* _tmp29_ = NULL;
					gint _tmp30_ = 0;
					gint _tmp31_ = 0;
					_tmp26_ = proto;
					_tmp27_ = protocol_elem_get_protocol_info (_tmp26_);
					_tmp28_ = _tmp27_;
					_tmp29_ = g_strstrip (_tmp28_);
					_tmp30_ = strlen (_tmp29_);
					_tmp31_ = _tmp30_;
					_tmp21_ = _tmp31_ > 0;
					_g_free0 (_tmp28_);
				} else {
					_tmp21_ = FALSE;
				}
				if (_tmp21_) {
					ProtocolElem* _tmp32_ = NULL;
					gchar* _tmp33_ = NULL;
					gchar* _tmp34_ = NULL;
					const gchar* _tmp35_ = NULL;
					gboolean _tmp36_ = FALSE;
					_tmp32_ = proto;
					_tmp33_ = protocol_elem_get_protocol_info (_tmp32_);
					_tmp34_ = _tmp33_;
					_tmp35_ = self->priv->protocol_info;
					_tmp36_ = g_strcmp0 (_tmp34_, _tmp35_) == 0;
					_g_free0 (_tmp34_);
					if (_tmp36_) {
						result = TRUE;
						_ui_listing_unref0 (proto);
						_g_object_unref0 (_proto_list);
						return result;
					}
				} else {
					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* protocol_elem_real_to_ui_listing (UIListing* base, GeeArrayList* filters) {
	ProtocolElem * self;
	gchar* result = NULL;
	gboolean matches = FALSE;
	GeeHashMap* elements = NULL;
	GeeHashMap* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_ = NULL;
	gboolean _tmp6_ = FALSE;
	const gchar* _tmp7_ = NULL;
	GString* sb = NULL;
	GString* _tmp13_ = NULL;
	gboolean _tmp14_ = FALSE;
	GString* _tmp48_ = NULL;
	const gchar* _tmp49_ = NULL;
	gchar* _tmp50_ = NULL;
	self = (ProtocolElem*) base;
	g_return_val_if_fail (filters != NULL, NULL);
	matches = FALSE;
	_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_;
	_tmp2_ = self->priv->short_name;
	if (_tmp2_ != NULL) {
		GeeArrayList* _tmp3_ = NULL;
		const gchar* _tmp4_ = NULL;
		gboolean _tmp5_ = FALSE;
		_tmp3_ = filters;
		_tmp4_ = self->priv->short_name;
		_tmp5_ = ui_listing_filters_match ((UIListing*) self, _tmp3_, UI_LISTING_SHORT_NAME, _tmp4_);
		_tmp1_ = _tmp5_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		matches = TRUE;
	}
	_tmp7_ = self->priv->protocol_info;
	if (_tmp7_ != NULL) {
		GeeArrayList* _tmp8_ = NULL;
		const gchar* _tmp9_ = NULL;
		gboolean _tmp10_ = FALSE;
		_tmp8_ = filters;
		_tmp9_ = self->priv->protocol_info;
		_tmp10_ = ui_listing_filters_match ((UIListing*) self, _tmp8_, UI_LISTING_PROTOCOL_INFO, _tmp9_);
		_tmp6_ = _tmp10_;
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		GeeHashMap* _tmp11_ = NULL;
		const gchar* _tmp12_ = NULL;
		_tmp11_ = elements;
		_tmp12_ = self->priv->protocol_info;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp11_, UI_LISTING_PROTOCOL_INFO, _tmp12_);
		matches = TRUE;
	}
	_tmp13_ = g_string_new ("");
	sb = _tmp13_;
	_tmp14_ = matches;
	if (_tmp14_) {
		GString* _tmp15_ = NULL;
		const gchar* _tmp16_ = NULL;
		gchar* _tmp17_ = NULL;
		gchar* _tmp18_ = NULL;
		gchar* _tmp19_ = NULL;
		gchar* _tmp20_ = NULL;
		GeeArrayList* _tmp21_ = NULL;
		gint _tmp22_ = 0;
		gint _tmp23_ = 0;
		GString* _tmp43_ = NULL;
		GeeHashMap* _tmp44_ = NULL;
		gchar* _tmp45_ = NULL;
		gchar* _tmp46_ = NULL;
		GString* _tmp47_ = NULL;
		_tmp15_ = sb;
		_tmp16_ = self->priv->short_name;
		_tmp17_ = g_strconcat ("<" UI_LISTING_PROTOCOL " " UI_LISTING_SHORT_NAME "=\"", _tmp16_, NULL);
		_tmp18_ = _tmp17_;
		_tmp19_ = g_strconcat (_tmp18_, "\">\n", NULL);
		_tmp20_ = _tmp19_;
		g_string_append (_tmp15_, _tmp20_);
		_g_free0 (_tmp20_);
		_g_free0 (_tmp18_);
		_tmp21_ = self->priv->uris;
		_tmp22_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp21_);
		_tmp23_ = _tmp22_;
		if (_tmp23_ > 0) {
			{
				GeeArrayList* _uri_list = NULL;
				GeeArrayList* _tmp24_ = NULL;
				GeeArrayList* _tmp25_ = NULL;
				gint _uri_size = 0;
				GeeArrayList* _tmp26_ = NULL;
				gint _tmp27_ = 0;
				gint _tmp28_ = 0;
				gint _uri_index = 0;
				_tmp24_ = self->priv->uris;
				_tmp25_ = _g_object_ref0 (_tmp24_);
				_uri_list = _tmp25_;
				_tmp26_ = _uri_list;
				_tmp27_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp26_);
				_tmp28_ = _tmp27_;
				_uri_size = _tmp28_;
				_uri_index = -1;
				while (TRUE) {
					gint _tmp29_ = 0;
					gint _tmp30_ = 0;
					gint _tmp31_ = 0;
					gchar* uri = NULL;
					GeeArrayList* _tmp32_ = NULL;
					gint _tmp33_ = 0;
					gpointer _tmp34_ = NULL;
					GString* _tmp35_ = NULL;
					GString* _tmp36_ = NULL;
					GString* _tmp37_ = NULL;
					GString* _tmp38_ = NULL;
					const gchar* _tmp39_ = NULL;
					GString* _tmp40_ = NULL;
					GString* _tmp41_ = NULL;
					GString* _tmp42_ = NULL;
					_tmp29_ = _uri_index;
					_uri_index = _tmp29_ + 1;
					_tmp30_ = _uri_index;
					_tmp31_ = _uri_size;
					if (!(_tmp30_ < _tmp31_)) {
						break;
					}
					_tmp32_ = _uri_list;
					_tmp33_ = _uri_index;
					_tmp34_ = gee_abstract_list_get ((GeeAbstractList*) _tmp32_, _tmp33_);
					uri = (gchar*) _tmp34_;
					_tmp35_ = sb;
					_tmp36_ = g_string_append (_tmp35_, "<");
					_tmp37_ = g_string_append (_tmp36_, UI_LISTING_URI);
					_tmp38_ = g_string_append (_tmp37_, ">");
					_tmp39_ = uri;
					_tmp40_ = g_string_append (_tmp38_, _tmp39_);
					_tmp41_ = g_string_append (_tmp40_, "</");
					_tmp42_ = g_string_append (_tmp41_, UI_LISTING_URI);
					g_string_append (_tmp42_, ">\n");
					_g_free0 (uri);
				}
				_g_object_unref0 (_uri_list);
			}
		}
		_tmp43_ = sb;
		_tmp44_ = elements;
		_tmp45_ = ui_listing_to_xml ((UIListing*) self, _tmp44_);
		_tmp46_ = _tmp45_;
		g_string_append (_tmp43_, _tmp46_);
		_g_free0 (_tmp46_);
		_tmp47_ = sb;
		g_string_append (_tmp47_, "</" UI_LISTING_PROTOCOL ">\n");
	}
	_tmp48_ = sb;
	_tmp49_ = _tmp48_->str;
	_tmp50_ = g_strdup (_tmp49_);
	result = _tmp50_;
	_g_string_free0 (sb);
	_g_object_unref0 (elements);
	return result;
}


static void protocol_elem_class_init (ProtocolElemClass * klass) {
	protocol_elem_parent_class = g_type_class_peek_parent (klass);
	((UIListingClass *) klass)->finalize = protocol_elem_finalize;
	g_type_class_add_private (klass, sizeof (ProtocolElemPrivate));
	((UIListingClass *) klass)->match = protocol_elem_real_match;
	((UIListingClass *) klass)->to_ui_listing = protocol_elem_real_to_ui_listing;
}


static void protocol_elem_instance_init (ProtocolElem * self) {
	self->priv = PROTOCOL_ELEM_GET_PRIVATE (self);
	self->priv->short_name = NULL;
	self->priv->protocol_info = NULL;
}


static void protocol_elem_finalize (UIListing* obj) {
	ProtocolElem * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_PROTOCOL_ELEM, ProtocolElem);
	_g_free0 (self->priv->short_name);
	_g_free0 (self->priv->protocol_info);
	_g_object_unref0 (self->priv->uris);
	UI_LISTING_CLASS (protocol_elem_parent_class)->finalize (obj);
}


GType protocol_elem_get_type (void) {
	static volatile gsize protocol_elem_type_id__volatile = 0;
	if (g_once_init_enter (&protocol_elem_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ProtocolElemClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) protocol_elem_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtocolElem), 0, (GInstanceInitFunc) protocol_elem_instance_init, NULL };
		GType protocol_elem_type_id;
		protocol_elem_type_id = g_type_register_static (TYPE_UI_LISTING, "ProtocolElem", &g_define_type_info, 0);
		g_once_init_leave (&protocol_elem_type_id__volatile, protocol_elem_type_id);
	}
	return protocol_elem_type_id__volatile;
}



