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


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_;
	gchar* _tmp1_;
	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_;
	gchar* _tmp1_;
	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_;
	self = (ProtocolElem*) base;
	g_return_val_if_fail (filters != NULL, FALSE);
	_tmp1_ = protocols;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		GeeArrayList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp2_ = protocols;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == 0;
	}
	if (_tmp0_) {
		result = TRUE;
		return result;
	}
	{
		GeeArrayList* _proto_list = NULL;
		GeeArrayList* _tmp5_;
		GeeArrayList* _tmp6_;
		gint _proto_size = 0;
		GeeArrayList* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		gint _proto_index = 0;
		_tmp5_ = protocols;
		_tmp6_ = _g_object_ref0 (_tmp5_);
		_proto_list = _tmp6_;
		_tmp7_ = _proto_list;
		_tmp8_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp7_);
		_tmp9_ = _tmp8_;
		_proto_size = _tmp9_;
		_proto_index = -1;
		while (TRUE) {
			gint _tmp10_;
			gint _tmp11_;
			gint _tmp12_;
			ProtocolElem* proto = NULL;
			GeeArrayList* _tmp13_;
			gint _tmp14_;
			gpointer _tmp15_;
			const gchar* _tmp16_;
			ProtocolElem* _tmp17_;
			gchar* _tmp18_;
			gchar* _tmp19_;
			gboolean _tmp20_;
			_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_;
				gchar* _tmp23_;
				gchar* _tmp24_;
				gboolean _tmp25_;
				_tmp22_ = proto;
				_tmp23_ = protocol_elem_get_protocol_info (_tmp22_);
				_tmp24_ = _tmp23_;
				_tmp25_ = _tmp24_ != NULL;
				_g_free0 (_tmp24_);
				if (_tmp25_) {
					ProtocolElem* _tmp26_;
					gchar* _tmp27_;
					gchar* _tmp28_;
					const gchar* _tmp29_;
					gint _tmp30_;
					gint _tmp31_;
					_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_;
					gchar* _tmp33_;
					gchar* _tmp34_;
					const gchar* _tmp35_;
					gboolean _tmp36_;
					_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_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gboolean _tmp6_ = FALSE;
	const gchar* _tmp7_;
	GString* sb = NULL;
	GString* _tmp13_;
	gboolean _tmp14_;
	GString* _tmp48_;
	const gchar* _tmp49_;
	gchar* _tmp50_;
	self = (ProtocolElem*) base;
	g_return_val_if_fail (filters != NULL, NULL);
	matches = FALSE;
	_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_;
	_tmp2_ = self->priv->short_name;
	if (_tmp2_ != NULL) {
		GeeArrayList* _tmp3_;
		const gchar* _tmp4_;
		gboolean _tmp5_;
		_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_;
		const gchar* _tmp9_;
		gboolean _tmp10_;
		_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_;
		const gchar* _tmp12_;
		_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_;
		const gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		gchar* _tmp20_;
		GeeArrayList* _tmp21_;
		gint _tmp22_;
		gint _tmp23_;
		GString* _tmp43_;
		GeeHashMap* _tmp44_;
		gchar* _tmp45_;
		gchar* _tmp46_;
		GString* _tmp47_;
		_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 ((GeeAbstractCollection*) _tmp21_);
		_tmp23_ = _tmp22_;
		if (_tmp23_ > 0) {
			{
				GeeArrayList* _uri_list = NULL;
				GeeArrayList* _tmp24_;
				GeeArrayList* _tmp25_;
				gint _uri_size = 0;
				GeeArrayList* _tmp26_;
				gint _tmp27_;
				gint _tmp28_;
				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 ((GeeAbstractCollection*) _tmp26_);
				_tmp28_ = _tmp27_;
				_uri_size = _tmp28_;
				_uri_index = -1;
				while (TRUE) {
					gint _tmp29_;
					gint _tmp30_;
					gint _tmp31_;
					gchar* uri = NULL;
					GeeArrayList* _tmp32_;
					gint _tmp33_;
					gpointer _tmp34_;
					GString* _tmp35_;
					GString* _tmp36_;
					GString* _tmp37_;
					GString* _tmp38_;
					const gchar* _tmp39_;
					GString* _tmp40_;
					GString* _tmp41_;
					GString* _tmp42_;
					_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 = (gboolean (*) (UIListing *, GeeArrayList*, GeeArrayList*)) protocol_elem_real_match;
	((UIListingClass *) klass)->to_ui_listing = (gchar* (*) (UIListing *, GeeArrayList*)) 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;
}



