/* rygel-ruih-protocol-elem.c generated by valac 0.40.8, 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))
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;
		xmlAttr* _tmp1_;
		_tmp1_ = node->properties;
		prop = _tmp1_;
		{
			gboolean _tmp2_ = FALSE;
			_tmp2_ = TRUE;
			while (TRUE) {
				xmlAttr* _tmp5_;
				gchar* attr_name = NULL;
				xmlAttr* _tmp6_;
				const gchar* _tmp7_;
				gchar* _tmp8_;
				const gchar* _tmp9_;
				const gchar* _tmp10_;
				GQuark _tmp12_ = 0U;
				if (!_tmp2_) {
					xmlAttr* _tmp3_;
					xmlAttr* _tmp4_;
					_tmp3_ = prop;
					_tmp4_ = _tmp3_->next;
					prop = _tmp4_;
				}
				_tmp2_ = FALSE;
				_tmp5_ = prop;
				if (!(_tmp5_ != NULL)) {
					break;
				}
				_tmp6_ = prop;
				_tmp7_ = _tmp6_->name;
				_tmp8_ = g_strdup (_tmp7_);
				attr_name = _tmp8_;
				_tmp9_ = attr_name;
				_tmp10_ = _tmp9_;
				_tmp12_ = (NULL == _tmp10_) ? 0 : g_quark_from_string (_tmp10_);
				if (_tmp12_ == g_quark_from_string (UI_LISTING_SHORT_NAME)) {
					switch (0) {
						default:
						{
							xmlAttr* _tmp13_;
							xmlNode* _tmp14_;
							const gchar* _tmp15_;
							gchar* _tmp16_;
							_tmp13_ = prop;
							_tmp14_ = _tmp13_->children;
							_tmp15_ = _tmp14_->content;
							_tmp16_ = g_strdup (_tmp15_);
							_g_free0 (self->priv->short_name);
							self->priv->short_name = _tmp16_;
							break;
						}
					}
				} else {
					switch (0) {
						default:
						{
							gchar* msg = NULL;
							gchar* _tmp17_;
							const gchar* _tmp18_;
							const gchar* _tmp19_;
							gchar* _tmp20_;
							gchar* _tmp21_;
							GError* _tmp22_;
							GError* _tmp23_;
							_tmp17_ = g_strdup (_ ("Unable to parse Protocol data — unexpected attribute: %s"));
							msg = _tmp17_;
							_tmp18_ = msg;
							_tmp19_ = attr_name;
							_tmp20_ = g_strdup_printf (_tmp18_, _tmp19_);
							_tmp21_ = _tmp20_;
							_tmp22_ = g_error_new_literal (RYGEL_RUIH_SERVICE_ERROR, RYGEL_RUIH_SERVICE_ERROR_OPERATION_REJECTED, _tmp21_);
							_tmp23_ = _tmp22_;
							_g_free0 (_tmp21_);
							_inner_error_ = _tmp23_;
							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;
		RygelXMLUtilsChildIterator* _tmp24_;
		RygelXMLUtilsChildIterator* _tmp25_;
		RygelXMLUtilsIterator* _tmp26_;
		RygelXMLUtilsIterator* _tmp27_;
		_tmp24_ = rygel_xml_utils_child_iterator_new (node);
		_tmp25_ = _tmp24_;
		_tmp26_ = rygel_xml_utils_iterator_iterator ((RygelXMLUtilsIterator*) _tmp25_);
		_tmp27_ = _tmp26_;
		_rygel_xml_utils_iterator_unref0 (_tmp25_);
		_child_node_it = _tmp27_;
		while (TRUE) {
			RygelXMLUtilsIterator* _tmp28_;
			xmlNode* child_node = NULL;
			RygelXMLUtilsIterator* _tmp29_;
			xmlNode* _tmp30_;
			xmlNode* _tmp31_;
			xmlElementType _tmp32_;
			gchar* node_name = NULL;
			xmlNode* _tmp33_;
			const gchar* _tmp34_;
			gchar* _tmp35_;
			const gchar* _tmp36_;
			const gchar* _tmp37_;
			GQuark _tmp39_ = 0U;
			_tmp28_ = _child_node_it;
			if (!rygel_xml_utils_iterator_next (_tmp28_)) {
				break;
			}
			_tmp29_ = _child_node_it;
			_tmp30_ = rygel_xml_utils_iterator_get (_tmp29_);
			child_node = _tmp30_;
			_tmp31_ = child_node;
			_tmp32_ = _tmp31_->type;
			if (_tmp32_ == XML_TEXT_NODE) {
				continue;
			}
			_tmp33_ = child_node;
			_tmp34_ = _tmp33_->name;
			_tmp35_ = g_strdup (_tmp34_);
			node_name = _tmp35_;
			_tmp36_ = node_name;
			_tmp37_ = _tmp36_;
			_tmp39_ = (NULL == _tmp37_) ? 0 : g_quark_from_string (_tmp37_);
			if (_tmp39_ == g_quark_from_string (UI_LISTING_URI)) {
				switch (0) {
					default:
					{
						GeeArrayList* _tmp40_;
						xmlNode* _tmp41_;
						gchar* _tmp42_;
						gchar* _tmp43_;
						_tmp40_ = self->priv->uris;
						_tmp41_ = child_node;
						_tmp42_ = (gchar*) xmlNodeGetContent (_tmp41_);
						_tmp43_ = _tmp42_;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp40_, _tmp43_);
						_g_free0 (_tmp43_);
						break;
					}
				}
			} else if (_tmp39_ == g_quark_from_string (UI_LISTING_PROTOCOL_INFO)) {
				switch (0) {
					default:
					{
						xmlNode* _tmp44_;
						gchar* _tmp45_;
						_tmp44_ = child_node;
						_tmp45_ = (gchar*) xmlNodeGetContent (_tmp44_);
						_g_free0 (self->priv->protocol_info);
						self->priv->protocol_info = _tmp45_;
						break;
					}
				}
			} else {
				switch (0) {
					default:
					{
						gchar* msg = NULL;
						gchar* _tmp46_;
						const gchar* _tmp47_;
						const gchar* _tmp48_;
						gchar* _tmp49_;
						gchar* _tmp50_;
						GError* _tmp51_;
						GError* _tmp52_;
						_tmp46_ = g_strdup (_ ("Unable to parse Protocol data — unexpected node: %s"));
						msg = _tmp46_;
						_tmp47_ = msg;
						_tmp48_ = node_name;
						_tmp49_ = g_strdup_printf (_tmp47_, _tmp48_);
						_tmp50_ = _tmp49_;
						_tmp51_ = g_error_new_literal (RYGEL_RUIH_SERVICE_ERROR, RYGEL_RUIH_SERVICE_ERROR_OPERATION_REJECTED, _tmp50_);
						_tmp52_ = _tmp51_;
						_g_free0 (_tmp50_);
						_inner_error_ = _tmp52_;
						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;
	self = (ProtocolElem*) base;
	g_return_val_if_fail (filters != NULL, FALSE);
	if (protocols == NULL) {
		_tmp0_ = TRUE;
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) protocols);
		_tmp2_ = _tmp1_;
		_tmp0_ = _tmp2_ == 0;
	}
	if (_tmp0_) {
		result = TRUE;
		return result;
	}
	{
		GeeArrayList* _proto_list = NULL;
		GeeArrayList* _tmp3_;
		gint _proto_size = 0;
		GeeArrayList* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		gint _proto_index = 0;
		_tmp3_ = _g_object_ref0 (protocols);
		_proto_list = _tmp3_;
		_tmp4_ = _proto_list;
		_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
		_tmp6_ = _tmp5_;
		_proto_size = _tmp6_;
		_proto_index = -1;
		while (TRUE) {
			gint _tmp7_;
			gint _tmp8_;
			gint _tmp9_;
			ProtocolElem* proto = NULL;
			GeeArrayList* _tmp10_;
			gint _tmp11_;
			gpointer _tmp12_;
			const gchar* _tmp13_;
			ProtocolElem* _tmp14_;
			gchar* _tmp15_;
			gchar* _tmp16_;
			gboolean _tmp17_;
			_tmp7_ = _proto_index;
			_proto_index = _tmp7_ + 1;
			_tmp8_ = _proto_index;
			_tmp9_ = _proto_size;
			if (!(_tmp8_ < _tmp9_)) {
				break;
			}
			_tmp10_ = _proto_list;
			_tmp11_ = _proto_index;
			_tmp12_ = gee_abstract_list_get ((GeeAbstractList*) _tmp10_, _tmp11_);
			proto = (ProtocolElem*) _tmp12_;
			_tmp13_ = self->priv->short_name;
			_tmp14_ = proto;
			_tmp15_ = protocol_elem_get_short_name (_tmp14_);
			_tmp16_ = _tmp15_;
			_tmp17_ = g_strcmp0 (_tmp13_, _tmp16_) == 0;
			_g_free0 (_tmp16_);
			if (_tmp17_) {
				gboolean _tmp18_ = FALSE;
				ProtocolElem* _tmp19_;
				gchar* _tmp20_;
				gchar* _tmp21_;
				gboolean _tmp22_;
				_tmp19_ = proto;
				_tmp20_ = protocol_elem_get_protocol_info (_tmp19_);
				_tmp21_ = _tmp20_;
				_tmp22_ = _tmp21_ != NULL;
				_g_free0 (_tmp21_);
				if (_tmp22_) {
					ProtocolElem* _tmp23_;
					gchar* _tmp24_;
					gchar* _tmp25_;
					const gchar* _tmp26_;
					gint _tmp27_;
					gint _tmp28_;
					_tmp23_ = proto;
					_tmp24_ = protocol_elem_get_protocol_info (_tmp23_);
					_tmp25_ = _tmp24_;
					_tmp26_ = g_strstrip (_tmp25_);
					_tmp27_ = strlen (_tmp26_);
					_tmp28_ = _tmp27_;
					_tmp18_ = _tmp28_ > 0;
					_g_free0 (_tmp25_);
				} else {
					_tmp18_ = FALSE;
				}
				if (_tmp18_) {
					ProtocolElem* _tmp29_;
					gchar* _tmp30_;
					gchar* _tmp31_;
					const gchar* _tmp32_;
					gboolean _tmp33_;
					_tmp29_ = proto;
					_tmp30_ = protocol_elem_get_protocol_info (_tmp29_);
					_tmp31_ = _tmp30_;
					_tmp32_ = self->priv->protocol_info;
					_tmp33_ = g_strcmp0 (_tmp31_, _tmp32_) == 0;
					_g_free0 (_tmp31_);
					if (_tmp33_) {
						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 _tmp4_ = FALSE;
	const gchar* _tmp5_;
	GString* sb = NULL;
	GString* _tmp9_;
	gboolean _tmp10_;
	GString* _tmp44_;
	const gchar* _tmp45_;
	gchar* _tmp46_;
	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) {
		const gchar* _tmp3_;
		_tmp3_ = self->priv->short_name;
		_tmp1_ = ui_listing_filters_match ((UIListing*) self, filters, UI_LISTING_SHORT_NAME, _tmp3_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		matches = TRUE;
	}
	_tmp5_ = self->priv->protocol_info;
	if (_tmp5_ != NULL) {
		const gchar* _tmp6_;
		_tmp6_ = self->priv->protocol_info;
		_tmp4_ = ui_listing_filters_match ((UIListing*) self, filters, UI_LISTING_PROTOCOL_INFO, _tmp6_);
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		GeeHashMap* _tmp7_;
		const gchar* _tmp8_;
		_tmp7_ = elements;
		_tmp8_ = self->priv->protocol_info;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp7_, UI_LISTING_PROTOCOL_INFO, _tmp8_);
		matches = TRUE;
	}
	_tmp9_ = g_string_new ("");
	sb = _tmp9_;
	_tmp10_ = matches;
	if (_tmp10_) {
		GString* _tmp11_;
		const gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		GeeArrayList* _tmp17_;
		gint _tmp18_;
		gint _tmp19_;
		GString* _tmp39_;
		GeeHashMap* _tmp40_;
		gchar* _tmp41_;
		gchar* _tmp42_;
		GString* _tmp43_;
		_tmp11_ = sb;
		_tmp12_ = self->priv->short_name;
		_tmp13_ = g_strconcat ("<" UI_LISTING_PROTOCOL " " UI_LISTING_SHORT_NAME "=\"", _tmp12_, NULL);
		_tmp14_ = _tmp13_;
		_tmp15_ = g_strconcat (_tmp14_, "\">\n", NULL);
		_tmp16_ = _tmp15_;
		g_string_append (_tmp11_, _tmp16_);
		_g_free0 (_tmp16_);
		_g_free0 (_tmp14_);
		_tmp17_ = self->priv->uris;
		_tmp18_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp17_);
		_tmp19_ = _tmp18_;
		if (_tmp19_ > 0) {
			{
				GeeArrayList* _uri_list = NULL;
				GeeArrayList* _tmp20_;
				GeeArrayList* _tmp21_;
				gint _uri_size = 0;
				GeeArrayList* _tmp22_;
				gint _tmp23_;
				gint _tmp24_;
				gint _uri_index = 0;
				_tmp20_ = self->priv->uris;
				_tmp21_ = _g_object_ref0 (_tmp20_);
				_uri_list = _tmp21_;
				_tmp22_ = _uri_list;
				_tmp23_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp22_);
				_tmp24_ = _tmp23_;
				_uri_size = _tmp24_;
				_uri_index = -1;
				while (TRUE) {
					gint _tmp25_;
					gint _tmp26_;
					gint _tmp27_;
					gchar* uri = NULL;
					GeeArrayList* _tmp28_;
					gint _tmp29_;
					gpointer _tmp30_;
					GString* _tmp31_;
					GString* _tmp32_;
					GString* _tmp33_;
					GString* _tmp34_;
					const gchar* _tmp35_;
					GString* _tmp36_;
					GString* _tmp37_;
					GString* _tmp38_;
					_tmp25_ = _uri_index;
					_uri_index = _tmp25_ + 1;
					_tmp26_ = _uri_index;
					_tmp27_ = _uri_size;
					if (!(_tmp26_ < _tmp27_)) {
						break;
					}
					_tmp28_ = _uri_list;
					_tmp29_ = _uri_index;
					_tmp30_ = gee_abstract_list_get ((GeeAbstractList*) _tmp28_, _tmp29_);
					uri = (gchar*) _tmp30_;
					_tmp31_ = sb;
					_tmp32_ = g_string_append (_tmp31_, "<");
					_tmp33_ = g_string_append (_tmp32_, UI_LISTING_URI);
					_tmp34_ = g_string_append (_tmp33_, ">");
					_tmp35_ = uri;
					_tmp36_ = g_string_append (_tmp34_, _tmp35_);
					_tmp37_ = g_string_append (_tmp36_, "</");
					_tmp38_ = g_string_append (_tmp37_, UI_LISTING_URI);
					g_string_append (_tmp38_, ">\n");
					_g_free0 (uri);
				}
				_g_object_unref0 (_uri_list);
			}
		}
		_tmp39_ = sb;
		_tmp40_ = elements;
		_tmp41_ = ui_listing_to_xml ((UIListing*) self, _tmp40_);
		_tmp42_ = _tmp41_;
		g_string_append (_tmp39_, _tmp42_);
		_g_free0 (_tmp42_);
		_tmp43_ = sb;
		g_string_append (_tmp43_, "</" UI_LISTING_PROTOCOL ">\n");
	}
	_tmp44_ = sb;
	_tmp45_ = _tmp44_->str;
	_tmp46_ = g_strdup (_tmp45_);
	result = _tmp46_;
	_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;
}



