/* rygel-media-export-node-query-container.c generated by valac 0.25.1.16-16e7a, the Vala compiler
 * generated from rygel-media-export-node-query-container.vala, do not modify */

/*
 * Copyright (C) 2011 Jens Georg <mail@jensge.org>.
 *
 * 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 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 program; 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 <rygel-server.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib/gi18n-lib.h>


#define RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER (rygel_media_export_db_container_get_type ())
#define RYGEL_MEDIA_EXPORT_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer))
#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))
#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
#define RYGEL_MEDIA_EXPORT_IS_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER))
#define RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainerClass))

typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
typedef struct _RygelMediaExportDBContainerPrivate RygelMediaExportDBContainerPrivate;

#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE (rygel_media_export_media_cache_get_type ())
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache))
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))
#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE))
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCacheClass))

typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;

#define RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER (rygel_media_export_query_container_get_type ())
#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainer))
#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))
#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER))
#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, RygelMediaExportQueryContainerClass))

typedef struct _RygelMediaExportQueryContainer RygelMediaExportQueryContainer;
typedef struct _RygelMediaExportQueryContainerClass RygelMediaExportQueryContainerClass;
typedef struct _RygelMediaExportQueryContainerPrivate RygelMediaExportQueryContainerPrivate;

#define RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER (rygel_media_export_node_query_container_get_type ())
#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainer))
#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainerClass))
#define RYGEL_MEDIA_EXPORT_IS_NODE_QUERY_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER))
#define RYGEL_MEDIA_EXPORT_IS_NODE_QUERY_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER))
#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainerClass))

typedef struct _RygelMediaExportNodeQueryContainer RygelMediaExportNodeQueryContainer;
typedef struct _RygelMediaExportNodeQueryContainerClass RygelMediaExportNodeQueryContainerClass;
typedef struct _RygelMediaExportNodeQueryContainerPrivate RygelMediaExportNodeQueryContainerPrivate;
#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_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY (rygel_media_export_query_container_factory_get_type ())
#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactory))
#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))
#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
#define RYGEL_MEDIA_EXPORT_IS_QUERY_CONTAINER_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY))
#define RYGEL_MEDIA_EXPORT_QUERY_CONTAINER_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER_FACTORY, RygelMediaExportQueryContainerFactoryClass))

typedef struct _RygelMediaExportQueryContainerFactory RygelMediaExportQueryContainerFactory;
typedef struct _RygelMediaExportQueryContainerFactoryClass RygelMediaExportQueryContainerFactoryClass;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _RygelMediaExportNodeQueryContainerGetChildrenData RygelMediaExportNodeQueryContainerGetChildrenData;

struct _RygelMediaExportDBContainer {
	RygelMediaContainer parent_instance;
	RygelMediaExportDBContainerPrivate * priv;
	RygelMediaExportMediaCache* media_db;
};

struct _RygelMediaExportDBContainerClass {
	RygelMediaContainerClass parent_class;
	gint (*count_children) (RygelMediaExportDBContainer* self);
	void (*search) (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	RygelMediaObjects* (*search_finish) (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error);
};

struct _RygelMediaExportQueryContainer {
	RygelMediaExportDBContainer parent_instance;
	RygelMediaExportQueryContainerPrivate * priv;
};

struct _RygelMediaExportQueryContainerClass {
	RygelMediaExportDBContainerClass parent_class;
};

struct _RygelMediaExportNodeQueryContainer {
	RygelMediaExportQueryContainer parent_instance;
	RygelMediaExportNodeQueryContainerPrivate * priv;
};

struct _RygelMediaExportNodeQueryContainerClass {
	RygelMediaExportQueryContainerClass parent_class;
};

struct _RygelMediaExportNodeQueryContainerPrivate {
	gchar* _template;
	gchar* _attribute;
};

struct _RygelMediaExportNodeQueryContainerGetChildrenData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	RygelMediaExportNodeQueryContainer* self;
	guint offset;
	guint max_count;
	gchar* sort_criteria;
	GCancellable* cancellable;
	RygelMediaObjects* result;
	RygelMediaObjects* children;
	RygelMediaObjects* _tmp0_;
	RygelMediaExportQueryContainerFactory* factory;
	RygelMediaExportQueryContainerFactory* _tmp1_;
	GeeList* data;
	RygelMediaExportMediaCache* _tmp2_;
	const gchar* _tmp3_;
	RygelSearchExpression* _tmp4_;
	RygelSearchExpression* _tmp5_;
	const gchar* _tmp6_;
	guint _tmp7_;
	guint _tmp8_;
	gboolean _tmp9_;
	GeeList* _tmp10_;
	GeeList* _meta_data_list;
	GeeList* _tmp11_;
	gint _meta_data_size;
	GeeList* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	gint _meta_data_index;
	gint _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	gchar* meta_data;
	GeeList* _tmp18_;
	gint _tmp19_;
	gpointer _tmp20_;
	gchar* id;
	RygelMediaContainer* container;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	RygelMediaExportQueryContainer* _tmp26_;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	gchar* _tmp31_;
	const gchar* _tmp32_;
	const gchar* _tmp33_;
	RygelMediaExportQueryContainer* _tmp34_;
	RygelMediaContainer* _tmp35_;
	RygelMediaContainer* _tmp36_;
	GError * _inner_error_;
};


static gpointer rygel_media_export_node_query_container_parent_class = NULL;

GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
GType rygel_media_export_query_container_get_type (void) G_GNUC_CONST;
GType rygel_media_export_node_query_container_get_type (void) G_GNUC_CONST;
#define RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainerPrivate))
enum  {
	RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_DUMMY_PROPERTY,
	RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_TEMPLATE,
	RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_ATTRIBUTE
};
RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_new (RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute);
RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_construct (GType object_type, RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute);
static void rygel_media_export_node_query_container_real_get_children_data_free (gpointer _data);
static void rygel_media_export_node_query_container_real_get_children (RygelMediaContainer* base, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
static gboolean rygel_media_export_node_query_container_real_get_children_co (RygelMediaExportNodeQueryContainerGetChildrenData* _data_);
GType rygel_media_export_query_container_factory_get_type (void) G_GNUC_CONST;
RygelMediaExportQueryContainerFactory* rygel_media_export_query_container_factory_get_default (void);
GeeList* rygel_media_export_media_cache_get_object_attribute_by_search_expression (RygelMediaExportMediaCache* self, const gchar* attribute, RygelSearchExpression* expression, const gchar* sort_criteria, glong offset, guint max_count, gboolean add_all_container, GError** error);
static const gchar* rygel_media_export_node_query_container_get_attribute (RygelMediaExportNodeQueryContainer* self);
RygelSearchExpression* rygel_media_export_query_container_get_expression (RygelMediaExportQueryContainer* self);
static gboolean rygel_media_export_node_query_container_add_all_container (RygelMediaExportNodeQueryContainer* self);
static const gchar* rygel_media_export_node_query_container_get_template (RygelMediaExportNodeQueryContainer* self);
RygelMediaExportQueryContainer* rygel_media_export_query_container_factory_create_from_description_id (RygelMediaExportQueryContainerFactory* self, const gchar* definition_id, const gchar* name);
static gint rygel_media_export_node_query_container_real_count_children (RygelMediaExportDBContainer* base);
static void rygel_media_export_node_query_container_set_template (RygelMediaExportNodeQueryContainer* self, const gchar* value);
static void rygel_media_export_node_query_container_set_attribute (RygelMediaExportNodeQueryContainer* self, const gchar* value);
static void rygel_media_export_node_query_container_finalize (GObject* obj);
static void _vala_rygel_media_export_node_query_container_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
static void _vala_rygel_media_export_node_query_container_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);


RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_construct (GType object_type, RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute) {
	RygelMediaExportNodeQueryContainer * self = NULL;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	RygelSearchExpression* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	const gchar* _tmp4_ = NULL;
	g_return_val_if_fail (expression != NULL, NULL);
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (name != NULL, NULL);
	g_return_val_if_fail (template != NULL, NULL);
	g_return_val_if_fail (attribute != NULL, NULL);
	_tmp0_ = id;
	_tmp1_ = name;
	_tmp2_ = expression;
	_tmp3_ = template;
	_tmp4_ = attribute;
	self = (RygelMediaExportNodeQueryContainer*) g_object_new (object_type, "id", _tmp0_, "title", _tmp1_, "parent", NULL, "child-count", 0, "expression", _tmp2_, "template", _tmp3_, "attribute", _tmp4_, NULL);
	return self;
}


RygelMediaExportNodeQueryContainer* rygel_media_export_node_query_container_new (RygelSearchExpression* expression, const gchar* id, const gchar* name, const gchar* template, const gchar* attribute) {
	return rygel_media_export_node_query_container_construct (RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, expression, id, name, template, attribute);
}


static void rygel_media_export_node_query_container_real_get_children_data_free (gpointer _data) {
	RygelMediaExportNodeQueryContainerGetChildrenData* _data_;
	_data_ = _data;
	_g_free0 (_data_->sort_criteria);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelMediaExportNodeQueryContainerGetChildrenData, _data_);
}


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


static void rygel_media_export_node_query_container_real_get_children (RygelMediaContainer* base, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	RygelMediaExportNodeQueryContainer * self;
	RygelMediaExportNodeQueryContainerGetChildrenData* _data_;
	RygelMediaExportNodeQueryContainer* _tmp0_ = NULL;
	guint _tmp1_ = 0U;
	guint _tmp2_ = 0U;
	const gchar* _tmp3_ = NULL;
	gchar* _tmp4_ = NULL;
	GCancellable* _tmp5_ = NULL;
	GCancellable* _tmp6_ = NULL;
	self = (RygelMediaExportNodeQueryContainer*) base;
	_data_ = g_slice_new0 (RygelMediaExportNodeQueryContainerGetChildrenData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_node_query_container_real_get_children);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_node_query_container_real_get_children_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = offset;
	_data_->offset = _tmp1_;
	_tmp2_ = max_count;
	_data_->max_count = _tmp2_;
	_tmp3_ = sort_criteria;
	_tmp4_ = g_strdup (_tmp3_);
	_g_free0 (_data_->sort_criteria);
	_data_->sort_criteria = _tmp4_;
	_tmp5_ = cancellable;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp6_;
	rygel_media_export_node_query_container_real_get_children_co (_data_);
}


static RygelMediaObjects* rygel_media_export_node_query_container_real_get_children_finish (RygelMediaContainer* base, GAsyncResult* _res_, GError** error) {
	RygelMediaObjects* result;
	RygelMediaExportNodeQueryContainerGetChildrenData* _data_;
	if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (_res_), error)) {
		return NULL;
	}
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
	result = _data_->result;
	_data_->result = NULL;
	return result;
}


static gchar* string_replace (const gchar* self, const gchar* old, const gchar* replacement) {
	gchar* result = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	{
		GRegex* regex = NULL;
		const gchar* _tmp0_ = NULL;
		gchar* _tmp1_ = NULL;
		gchar* _tmp2_ = NULL;
		GRegex* _tmp3_ = NULL;
		GRegex* _tmp4_ = NULL;
		gchar* _tmp5_ = NULL;
		GRegex* _tmp6_ = NULL;
		const gchar* _tmp7_ = NULL;
		gchar* _tmp8_ = NULL;
		gchar* _tmp9_ = NULL;
		_tmp0_ = old;
		_tmp1_ = g_regex_escape_string (_tmp0_, -1);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_regex_new (_tmp2_, 0, 0, &_inner_error_);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		regex = _tmp4_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch53_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp6_ = regex;
		_tmp7_ = replacement;
		_tmp8_ = g_regex_replace_literal (_tmp6_, self, (gssize) (-1), 0, _tmp7_, 0, &_inner_error_);
		_tmp5_ = _tmp8_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error_->domain == G_REGEX_ERROR) {
				goto __catch53_g_regex_error;
			}
			_g_regex_unref0 (regex);
			g_critical ("file %s: line %d: unexpected 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;
		}
		_tmp9_ = _tmp5_;
		_tmp5_ = NULL;
		result = _tmp9_;
		_g_free0 (_tmp5_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally53;
	__catch53_g_regex_error:
	{
		GError* e = NULL;
		e = _inner_error_;
		_inner_error_ = NULL;
		g_assert_not_reached ();
		_g_error_free0 (e);
	}
	__finally53:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		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;
	}
}


static gboolean rygel_media_export_node_query_container_real_get_children_co (RygelMediaExportNodeQueryContainerGetChildrenData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = rygel_media_objects_new ();
	_data_->children = _data_->_tmp0_;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = rygel_media_export_query_container_factory_get_default ();
	_data_->factory = _data_->_tmp1_;
	_data_->_tmp2_ = NULL;
	_data_->_tmp2_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = _data_->self->priv->_attribute;
	_data_->_tmp4_ = NULL;
	_data_->_tmp4_ = rygel_media_export_query_container_get_expression ((RygelMediaExportQueryContainer*) _data_->self);
	_data_->_tmp5_ = NULL;
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = _data_->sort_criteria;
	_data_->_tmp7_ = 0U;
	_data_->_tmp7_ = _data_->offset;
	_data_->_tmp8_ = 0U;
	_data_->_tmp8_ = _data_->max_count;
	_data_->_tmp9_ = FALSE;
	_data_->_tmp9_ = rygel_media_export_node_query_container_add_all_container (_data_->self);
	_data_->_tmp10_ = NULL;
	_data_->_tmp10_ = rygel_media_export_media_cache_get_object_attribute_by_search_expression (_data_->_tmp2_, _data_->_tmp3_, _data_->_tmp5_, _data_->_tmp6_, (glong) _data_->_tmp7_, _data_->_tmp8_, _data_->_tmp9_, &_data_->_inner_error_);
	_data_->data = _data_->_tmp10_;
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		g_simple_async_result_set_from_error (_data_->_async_result, _data_->_inner_error_);
		g_error_free (_data_->_inner_error_);
		_g_object_unref0 (_data_->factory);
		_g_object_unref0 (_data_->children);
		if (_data_->_state_ == 0) {
			g_simple_async_result_complete_in_idle (_data_->_async_result);
		} else {
			g_simple_async_result_complete (_data_->_async_result);
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->_tmp11_ = NULL;
		_data_->_tmp11_ = _g_object_ref0 (_data_->data);
		_data_->_meta_data_list = _data_->_tmp11_;
		_data_->_tmp12_ = NULL;
		_data_->_tmp12_ = _data_->_meta_data_list;
		_data_->_tmp13_ = 0;
		_data_->_tmp13_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp12_);
		_data_->_tmp14_ = 0;
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_meta_data_size = _data_->_tmp14_;
		_data_->_meta_data_index = -1;
		while (TRUE) {
			_data_->_tmp15_ = 0;
			_data_->_tmp15_ = _data_->_meta_data_index;
			_data_->_meta_data_index = _data_->_tmp15_ + 1;
			_data_->_tmp16_ = 0;
			_data_->_tmp16_ = _data_->_meta_data_index;
			_data_->_tmp17_ = 0;
			_data_->_tmp17_ = _data_->_meta_data_size;
			if (!(_data_->_tmp16_ < _data_->_tmp17_)) {
				break;
			}
			_data_->_tmp18_ = NULL;
			_data_->_tmp18_ = _data_->_meta_data_list;
			_data_->_tmp19_ = 0;
			_data_->_tmp19_ = _data_->_meta_data_index;
			_data_->_tmp20_ = NULL;
			_data_->_tmp20_ = gee_list_get (_data_->_tmp18_, _data_->_tmp19_);
			_data_->meta_data = (gchar*) _data_->_tmp20_;
			_data_->_tmp21_ = NULL;
			_data_->_tmp21_ = _data_->meta_data;
			if (g_strcmp0 (_data_->_tmp21_, "all_place_holder") == 0) {
				_data_->_tmp22_ = NULL;
				_data_->_tmp22_ = _data_->self->priv->_template;
				_data_->_tmp23_ = NULL;
				_data_->_tmp23_ = string_replace (_data_->_tmp22_, ",upnp:album,%s", "");
				_g_free0 (_data_->id);
				_data_->id = _data_->_tmp23_;
				_data_->_tmp24_ = NULL;
				_data_->_tmp24_ = _data_->id;
				_data_->_tmp25_ = NULL;
				_data_->_tmp25_ = _ ("All");
				_data_->_tmp26_ = NULL;
				_data_->_tmp26_ = rygel_media_export_query_container_factory_create_from_description_id (_data_->factory, _data_->_tmp24_, _data_->_tmp25_);
				_g_object_unref0 (_data_->container);
				_data_->container = (RygelMediaContainer*) _data_->_tmp26_;
			} else {
				_data_->_tmp27_ = NULL;
				_data_->_tmp27_ = _data_->meta_data;
				_data_->_tmp28_ = NULL;
				_data_->_tmp28_ = g_uri_escape_string (_data_->_tmp27_, "", TRUE);
				_g_free0 (_data_->id);
				_data_->id = _data_->_tmp28_;
				_data_->_tmp29_ = NULL;
				_data_->_tmp29_ = _data_->self->priv->_template;
				_data_->_tmp30_ = NULL;
				_data_->_tmp30_ = _data_->id;
				_data_->_tmp31_ = NULL;
				_data_->_tmp31_ = string_replace (_data_->_tmp29_, "%s", _data_->_tmp30_);
				_g_free0 (_data_->id);
				_data_->id = _data_->_tmp31_;
				_data_->_tmp32_ = NULL;
				_data_->_tmp32_ = _data_->id;
				_data_->_tmp33_ = NULL;
				_data_->_tmp33_ = _data_->meta_data;
				_data_->_tmp34_ = NULL;
				_data_->_tmp34_ = rygel_media_export_query_container_factory_create_from_description_id (_data_->factory, _data_->_tmp32_, _data_->_tmp33_);
				_g_object_unref0 (_data_->container);
				_data_->container = (RygelMediaContainer*) _data_->_tmp34_;
			}
			_data_->_tmp35_ = NULL;
			_data_->_tmp35_ = _data_->container;
			rygel_media_object_set_parent ((RygelMediaObject*) _data_->_tmp35_, (RygelMediaContainer*) _data_->self);
			_data_->_tmp36_ = NULL;
			_data_->_tmp36_ = _data_->container;
			gee_abstract_collection_add ((GeeAbstractCollection*) _data_->children, (RygelMediaObject*) _data_->_tmp36_);
			_g_object_unref0 (_data_->container);
			_g_free0 (_data_->id);
			_g_free0 (_data_->meta_data);
		}
		_g_object_unref0 (_data_->_meta_data_list);
	}
	_data_->result = _data_->children;
	_g_object_unref0 (_data_->data);
	_g_object_unref0 (_data_->factory);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
	_g_object_unref0 (_data_->data);
	_g_object_unref0 (_data_->factory);
	_g_object_unref0 (_data_->children);
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static gint rygel_media_export_node_query_container_real_count_children (RygelMediaExportDBContainer* base) {
	RygelMediaExportNodeQueryContainer * self;
	gint result = 0;
	GError * _inner_error_ = NULL;
	self = (RygelMediaExportNodeQueryContainer*) base;
	{
		GeeList* data = NULL;
		RygelMediaExportMediaCache* _tmp0_ = NULL;
		const gchar* _tmp1_ = NULL;
		RygelSearchExpression* _tmp2_ = NULL;
		RygelSearchExpression* _tmp3_ = NULL;
		gboolean _tmp4_ = FALSE;
		GeeList* _tmp5_ = NULL;
		gint _tmp6_ = 0;
		gint _tmp7_ = 0;
		_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
		_tmp1_ = self->priv->_attribute;
		_tmp2_ = rygel_media_export_query_container_get_expression ((RygelMediaExportQueryContainer*) self);
		_tmp3_ = _tmp2_;
		_tmp4_ = rygel_media_export_node_query_container_add_all_container (self);
		_tmp5_ = rygel_media_export_media_cache_get_object_attribute_by_search_expression (_tmp0_, _tmp1_, _tmp3_, "+dc:title", (glong) 0, (guint) (-1), _tmp4_, &_inner_error_);
		data = _tmp5_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch54_g_error;
		}
		_tmp6_ = gee_collection_get_size ((GeeCollection*) data);
		_tmp7_ = _tmp6_;
		result = _tmp7_;
		_g_object_unref0 (data);
		return result;
	}
	goto __finally54;
	__catch54_g_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp8_ = NULL;
		GError* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp8_ = _ ("Failed to get child count: %s");
		_tmp9_ = _error_;
		_tmp10_ = _tmp9_->message;
		g_warning (_tmp8_, _tmp10_);
		result = 0;
		_g_error_free0 (_error_);
		return result;
	}
	__finally54:
	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 0;
}


static gboolean rygel_media_export_node_query_container_add_all_container (RygelMediaExportNodeQueryContainer* self) {
	gboolean result = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	result = FALSE;
	return result;
}


static const gchar* rygel_media_export_node_query_container_get_template (RygelMediaExportNodeQueryContainer* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_template;
	result = _tmp0_;
	return result;
}


static void rygel_media_export_node_query_container_set_template (RygelMediaExportNodeQueryContainer* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_template);
	self->priv->_template = _tmp1_;
	g_object_notify ((GObject *) self, "template");
}


static const gchar* rygel_media_export_node_query_container_get_attribute (RygelMediaExportNodeQueryContainer* self) {
	const gchar* result;
	const gchar* _tmp0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_attribute;
	result = _tmp0_;
	return result;
}


static void rygel_media_export_node_query_container_set_attribute (RygelMediaExportNodeQueryContainer* self, const gchar* value) {
	const gchar* _tmp0_ = NULL;
	gchar* _tmp1_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->_attribute);
	self->priv->_attribute = _tmp1_;
	g_object_notify ((GObject *) self, "attribute");
}


static void rygel_media_export_node_query_container_class_init (RygelMediaExportNodeQueryContainerClass * klass) {
	rygel_media_export_node_query_container_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelMediaExportNodeQueryContainerPrivate));
	((RygelMediaContainerClass *) klass)->get_children = rygel_media_export_node_query_container_real_get_children;
	((RygelMediaContainerClass *) klass)->get_children_finish = rygel_media_export_node_query_container_real_get_children_finish;
	((RygelMediaExportDBContainerClass *) klass)->count_children = rygel_media_export_node_query_container_real_count_children;
	G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_node_query_container_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_node_query_container_set_property;
	G_OBJECT_CLASS (klass)->finalize = rygel_media_export_node_query_container_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_TEMPLATE, g_param_spec_string ("template", "template", "template", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_ATTRIBUTE, g_param_spec_string ("attribute", "attribute", "attribute", NULL, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}


static void rygel_media_export_node_query_container_instance_init (RygelMediaExportNodeQueryContainer * self) {
	self->priv = RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_GET_PRIVATE (self);
}


static void rygel_media_export_node_query_container_finalize (GObject* obj) {
	RygelMediaExportNodeQueryContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainer);
	_g_free0 (self->priv->_template);
	_g_free0 (self->priv->_attribute);
	G_OBJECT_CLASS (rygel_media_export_node_query_container_parent_class)->finalize (obj);
}


GType rygel_media_export_node_query_container_get_type (void) {
	static volatile gsize rygel_media_export_node_query_container_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_node_query_container_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportNodeQueryContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_node_query_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportNodeQueryContainer), 0, (GInstanceInitFunc) rygel_media_export_node_query_container_instance_init, NULL };
		GType rygel_media_export_node_query_container_type_id;
		rygel_media_export_node_query_container_type_id = g_type_register_static (RYGEL_MEDIA_EXPORT_TYPE_QUERY_CONTAINER, "RygelMediaExportNodeQueryContainer", &g_define_type_info, 0);
		g_once_init_leave (&rygel_media_export_node_query_container_type_id__volatile, rygel_media_export_node_query_container_type_id);
	}
	return rygel_media_export_node_query_container_type_id__volatile;
}


static void _vala_rygel_media_export_node_query_container_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
	RygelMediaExportNodeQueryContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainer);
	switch (property_id) {
		case RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_TEMPLATE:
		g_value_set_string (value, rygel_media_export_node_query_container_get_template (self));
		break;
		case RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_ATTRIBUTE:
		g_value_set_string (value, rygel_media_export_node_query_container_get_attribute (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}


static void _vala_rygel_media_export_node_query_container_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
	RygelMediaExportNodeQueryContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_NODE_QUERY_CONTAINER, RygelMediaExportNodeQueryContainer);
	switch (property_id) {
		case RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_TEMPLATE:
		rygel_media_export_node_query_container_set_template (self, g_value_get_string (value));
		break;
		case RYGEL_MEDIA_EXPORT_NODE_QUERY_CONTAINER_ATTRIBUTE:
		rygel_media_export_node_query_container_set_attribute (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}



