/* localsearch-search-container.c generated by valac 0.56.19, the Vala compiler
 * generated from localsearch-search-container.vala, do not modify */

/*
 * Copyright (C) 2008 Zeeshan Ali <zeenix@gmail.com>.
 * Copyright (C) 2008-2012 Nokia Corporation.
 * Copyright (C) 2010 MediaNet Inh.
 *
 * Authors: Zeeshan Ali <zeenix@gmail.com>
 *          Sunil Mohan Adapa <sunil@medhas.org>
 *         Jens Georg <jensg@openismus.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 "rygel-localsearch.h"
#include "rygel-server.h"
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib-object.h>
#include <libgupnp-av/gupnp-av.h>
#include <tinysparql.h>
#include <glib/gi18n-lib.h>

#define RYGEL_LOCAL_SEARCH_SEARCH_CONTAINER_MODIFIED_PROPERTY "nfo:fileLastModified"
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	RYGEL_LOCAL_SEARCH_SEARCH_CONTAINER_0_PROPERTY,
	RYGEL_LOCAL_SEARCH_SEARCH_CONTAINER_NUM_PROPERTIES
};
static GParamSpec* rygel_local_search_search_container_properties[RYGEL_LOCAL_SEARCH_SEARCH_CONTAINER_NUM_PROPERTIES];
#define _rygel_local_search_query_unref0(var) ((var == NULL) ? NULL : (var = (rygel_local_search_query_unref (var), NULL)))
#define _rygel_local_search_item_factory_unref0(var) ((var == NULL) ? NULL : (var = (rygel_local_search_item_factory_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _rygel_local_search_query_triplet_unref0(var) ((var == NULL) ? NULL : (var = (rygel_local_search_query_triplet_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _rygel_search_expression_unref0(var) ((var == NULL) ? NULL : (var = (rygel_search_expression_unref (var), NULL)))
typedef struct _RygelLocalSearchSearchContainerGetChildrenData RygelLocalSearchSearchContainerGetChildrenData;
typedef struct _RygelLocalSearchSearchContainerExecuteQueryData RygelLocalSearchSearchContainerExecuteQueryData;
typedef struct _RygelLocalSearchSearchContainerFindObjectData RygelLocalSearchSearchContainerFindObjectData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _RygelLocalSearchSearchContainerGetChildrenCountData RygelLocalSearchSearchContainerGetChildrenCountData;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

struct _RygelLocalSearchSearchContainerGetChildrenData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelLocalSearchSearchContainer* self;
	guint offset;
	guint max_count;
	gchar* sort_criteria;
	GCancellable* cancellable;
	RygelMediaObjects* result;
	RygelRelationalExpression* expression;
	RygelRelationalExpression* _tmp0_;
	gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	guint total_matches;
	RygelMediaObjects* _tmp5_;
	guint _tmp6_;
	RygelMediaObjects* _tmp7_;
	RygelMediaObjects* _tmp8_;
	GError* _inner_error0_;
};

struct _RygelLocalSearchSearchContainerExecuteQueryData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelLocalSearchSearchContainer* self;
	RygelSearchExpression* expression;
	gchar* sort_criteria;
	guint offset;
	guint max_count;
	GCancellable* cancellable;
	guint total_matches;
	RygelMediaObjects* result;
	RygelMediaObjects* results;
	RygelMediaObjects* _tmp0_;
	RygelLocalSearchSelectionQuery* query;
	RygelLocalSearchSelectionQuery* _tmp1_;
	RygelLocalSearchSelectionQuery* _tmp2_;
	RygelLocalSearchSelectionQuery* _tmp3_;
	TrackerSparqlConnection* _tmp4_;
	gboolean _tmp5_;
	RygelLocalSearchSelectionQuery* _tmp6_;
	TrackerSparqlCursor* _tmp7_;
	gchar* id;
	RygelLocalSearchSelectionQuery* _tmp8_;
	TrackerSparqlCursor* _tmp9_;
	const gchar* _tmp10_;
	gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* uri;
	RygelLocalSearchSelectionQuery* _tmp14_;
	TrackerSparqlCursor* _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_;
	RygelMediaFileItem* item;
	RygelLocalSearchItemFactory* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	RygelLocalSearchSelectionQuery* _tmp21_;
	TrackerSparqlCursor* _tmp22_;
	RygelMediaFileItem* _tmp23_;
	RygelMediaObjects* _tmp24_;
	RygelMediaFileItem* _tmp25_;
	RygelLocalSearchSelectionQuery* _tmp26_;
	TrackerSparqlCursor* _tmp27_;
	RygelMediaObjects* _tmp28_;
	gint _tmp29_;
	gint _tmp30_;
	GError* _inner_error0_;
};

struct _RygelLocalSearchSearchContainerFindObjectData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelLocalSearchSearchContainer* self;
	gchar* id;
	GCancellable* cancellable;
	RygelMediaObject* result;
	RygelRelationalExpression* expression;
	RygelRelationalExpression* _tmp0_;
	RygelRelationalExpression* _tmp1_;
	RygelRelationalExpression* _tmp2_;
	gchar* _tmp3_;
	RygelRelationalExpression* _tmp4_;
	gchar* _tmp5_;
	guint total_matches;
	RygelMediaObjects* results;
	RygelRelationalExpression* _tmp6_;
	guint _tmp7_;
	RygelMediaObjects* _tmp8_;
	RygelMediaObjects* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	RygelMediaObjects* _tmp12_;
	gpointer _tmp13_;
	GError* _inner_error0_;
};

struct _RygelLocalSearchSearchContainerGetChildrenCountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelLocalSearchSearchContainer* self;
	RygelLocalSearchSelectionQuery* query;
	RygelLocalSearchSelectionQuery* _tmp0_;
	RygelLocalSearchSelectionQuery* _tmp1_;
	RygelLocalSearchSelectionQuery* _tmp2_;
	GeeArrayList* _tmp3_;
	RygelLocalSearchSelectionQuery* _tmp4_;
	GeeArrayList* _tmp5_;
	RygelLocalSearchSelectionQuery* _tmp6_;
	TrackerSparqlConnection* _tmp7_;
	gboolean _tmp8_;
	RygelLocalSearchSelectionQuery* _tmp9_;
	TrackerSparqlCursor* _tmp10_;
	RygelLocalSearchSelectionQuery* _tmp11_;
	TrackerSparqlCursor* _tmp12_;
	const gchar* _tmp13_;
	RygelLocalSearchSelectionQuery* _tmp14_;
	TrackerSparqlCursor* _tmp15_;
	GError* _error_;
	RygelLocalSearchItemFactory* _tmp16_;
	const gchar* _tmp17_;
	GError* _tmp18_;
	const gchar* _tmp19_;
	GError* _inner_error0_;
};

static gpointer rygel_local_search_search_container_parent_class = NULL;
static GeeHashMap* rygel_local_search_search_container_update_id_hash;
static GeeHashMap* rygel_local_search_search_container_update_id_hash = NULL;

static void __lambda4_ (RygelLocalSearchSearchContainer* self,
                 RygelMediaContainer* container,
                 RygelMediaObject* origin);
static void ___lambda4__rygel_media_container_container_updated (RygelMediaContainer* _sender,
                                                          RygelMediaContainer* container,
                                                          RygelMediaObject* object,
                                                          RygelObjectEventType event_type,
                                                          gboolean sub_tree_update,
                                                          gpointer self);
VALA_EXTERN void rygel_local_search_search_container_get_children_count (RygelLocalSearchSearchContainer* self,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
VALA_EXTERN void rygel_local_search_search_container_get_children_count_finish (RygelLocalSearchSearchContainer* self,
                                                                    GAsyncResult* _res_);
static void rygel_local_search_search_container_real_get_children_data_free (gpointer _data);
static void rygel_local_search_search_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_local_search_search_container_real_get_children_co (RygelLocalSearchSearchContainerGetChildrenData* _data_);
static void rygel_local_search_search_container_get_children_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_);
static void rygel_local_search_search_container_execute_query_data_free (gpointer _data);
static gboolean rygel_local_search_search_container_execute_query_co (RygelLocalSearchSearchContainerExecuteQueryData* _data_);
static RygelLocalSearchSelectionQuery* rygel_local_search_search_container_create_query (RygelLocalSearchSearchContainer* self,
                                                                                  RygelRelationalExpression* expression,
                                                                                  gint offset,
                                                                                  gint max_count,
                                                                                  const gchar* sort_criteria);
static void rygel_local_search_search_container_execute_query_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
static void rygel_local_search_search_container_real_find_object_data_free (gpointer _data);
static void rygel_local_search_search_container_real_find_object (RygelMediaContainer* base,
                                                           const gchar* id,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
static gboolean rygel_local_search_search_container_real_find_object_co (RygelLocalSearchSearchContainerFindObjectData* _data_);
static gboolean rygel_local_search_search_container_is_our_child (RygelLocalSearchSearchContainer* self,
                                                           const gchar* id);
static void rygel_local_search_search_container_find_object_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static void rygel_local_search_search_container_get_children_count_data_free (gpointer _data);
static gboolean rygel_local_search_search_container_get_children_count_co (RygelLocalSearchSearchContainerGetChildrenCountData* _data_);
static void rygel_local_search_search_container_get_children_count_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_);
static RygelLocalSearchSelectionQuery* rygel_local_search_search_container_create_sorted_query (RygelLocalSearchSearchContainer* self,
                                                                                         const gchar* sort_criteria);
static gchar* rygel_local_search_search_container_create_filter_for_child (RygelLocalSearchSearchContainer* self,
                                                                    RygelRelationalExpression* expression);
static gchar* rygel_local_search_search_container_urn_to_utf8 (RygelLocalSearchSearchContainer* self,
                                                        const gchar* urn);
static void rygel_local_search_search_container_finalize (GObject * obj);
static GType rygel_local_search_search_container_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static void
__lambda4_ (RygelLocalSearchSearchContainer* self,
            RygelMediaContainer* container,
            RygelMediaObject* origin)
{
	g_return_if_fail (container != NULL);
	g_return_if_fail (origin != NULL);
	if (origin == G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObject)) {
		GeeHashMap* _tmp0_;
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		_tmp0_ = rygel_local_search_search_container_update_id_hash;
		_tmp1_ = rygel_media_object_get_id ((RygelMediaObject*) self);
		_tmp2_ = _tmp1_;
		gee_abstract_map_set ((GeeAbstractMap*) _tmp0_, _tmp2_, (gpointer) ((guintptr) ((RygelMediaContainer*) self)->update_id));
	}
}

static void
___lambda4__rygel_media_container_container_updated (RygelMediaContainer* _sender,
                                                     RygelMediaContainer* container,
                                                     RygelMediaObject* object,
                                                     RygelObjectEventType event_type,
                                                     gboolean sub_tree_update,
                                                     gpointer self)
{
	__lambda4_ ((RygelLocalSearchSearchContainer*) self, container, object);
}

static gpointer
_rygel_local_search_item_factory_ref0 (gpointer self)
{
	return self ? rygel_local_search_item_factory_ref (self) : NULL;
}

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

RygelLocalSearchSearchContainer*
rygel_local_search_search_container_construct (GType object_type,
                                               const gchar* id,
                                               RygelMediaContainer* parent,
                                               const gchar* title,
                                               RygelLocalSearchItemFactory* item_factory,
                                               RygelLocalSearchQueryTriplets* triplets,
                                               GeeArrayList* filters)
{
	RygelLocalSearchSearchContainer * self = NULL;
	GeeHashMap* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	RygelLocalSearchItemFactory* _tmp7_;
	GeeArrayList* variables = NULL;
	GeeArrayList* _tmp8_;
	GeeArrayList* _tmp9_;
	RygelLocalSearchQueryTriplets* our_triplets = NULL;
	RygelLocalSearchQueryTriplets* _tmp12_;
	const gchar* _tmp13_;
	RygelLocalSearchQueryTriplet* _tmp14_;
	RygelLocalSearchQueryTriplet* _tmp15_;
	RygelLocalSearchQueryTriplets* _tmp16_;
	RygelLocalSearchQueryTriplet* _tmp17_;
	RygelLocalSearchQueryTriplet* _tmp18_;
	RygelLocalSearchUPnPPropertyMap* property_map = NULL;
	RygelLocalSearchUPnPPropertyMap* _tmp19_;
	gchar* order_by = NULL;
	gchar* _tmp34_;
	GeeArrayList* _tmp35_;
	RygelLocalSearchQueryTriplets* _tmp36_;
	RygelLocalSearchItemFactory* _tmp37_;
	const gchar* _tmp38_;
	RygelLocalSearchSelectionQuery* _tmp39_;
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (parent != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	g_return_val_if_fail (item_factory != NULL, NULL);
	self = (RygelLocalSearchSearchContainer*) rygel_simple_container_construct (object_type, id, parent, title);
	_tmp0_ = rygel_local_search_search_container_update_id_hash;
	_tmp1_ = rygel_media_object_get_id ((RygelMediaObject*) self);
	_tmp2_ = _tmp1_;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp0_, _tmp2_)) {
		GeeHashMap* _tmp3_;
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		gpointer _tmp6_;
		_tmp3_ = rygel_local_search_search_container_update_id_hash;
		_tmp4_ = rygel_media_object_get_id ((RygelMediaObject*) self);
		_tmp5_ = _tmp4_;
		_tmp6_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp3_, _tmp5_);
		((RygelMediaContainer*) self)->update_id = (guint32) ((guint) ((guintptr) _tmp6_));
	}
	g_signal_connect_object ((RygelMediaContainer*) self, "container-updated", (GCallback) ___lambda4__rygel_media_container_container_updated, self, 0);
	_tmp7_ = _rygel_local_search_item_factory_ref0 (item_factory);
	_rygel_local_search_item_factory_unref0 (self->item_factory);
	self->item_factory = _tmp7_;
	_tmp8_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	variables = _tmp8_;
	_tmp9_ = variables;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, RYGEL_LOCAL_SEARCH_SELECTION_QUERY_ITEM_VARIABLE);
	if (triplets != NULL) {
		RygelLocalSearchQueryTriplets* _tmp10_;
		_tmp10_ = _g_object_ref0 (triplets);
		_g_object_unref0 (our_triplets);
		our_triplets = _tmp10_;
	} else {
		RygelLocalSearchQueryTriplets* _tmp11_;
		_tmp11_ = rygel_local_search_query_triplets_new ();
		_g_object_unref0 (our_triplets);
		our_triplets = _tmp11_;
	}
	_tmp12_ = our_triplets;
	_tmp13_ = item_factory->category;
	_tmp14_ = rygel_local_search_query_triplet_new (RYGEL_LOCAL_SEARCH_SELECTION_QUERY_ITEM_VARIABLE, "a", _tmp13_);
	_tmp15_ = _tmp14_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, _tmp15_);
	_rygel_local_search_query_triplet_unref0 (_tmp15_);
	_tmp16_ = our_triplets;
	_tmp17_ = rygel_local_search_query_triplet_new (RYGEL_LOCAL_SEARCH_SELECTION_QUERY_ITEM_VARIABLE, "nie:isStoredAs", RYGEL_LOCAL_SEARCH_SELECTION_QUERY_STORAGE_VARIABLE);
	_tmp18_ = _tmp17_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp16_, _tmp18_);
	_rygel_local_search_query_triplet_unref0 (_tmp18_);
	_tmp19_ = rygel_local_search_upn_pproperty_map_get_property_map ();
	property_map = _tmp19_;
	{
		GeeArrayList* _property_list = NULL;
		RygelLocalSearchItemFactory* _tmp20_;
		GeeArrayList* _tmp21_;
		gint _property_size = 0;
		GeeArrayList* _tmp22_;
		gint _tmp23_;
		gint _tmp24_;
		gint _property_index = 0;
		_tmp20_ = self->item_factory;
		_tmp21_ = _tmp20_->properties;
		_property_list = _tmp21_;
		_tmp22_ = _property_list;
		_tmp23_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp22_);
		_tmp24_ = _tmp23_;
		_property_size = _tmp24_;
		_property_index = -1;
		while (TRUE) {
			gint _tmp25_;
			gint _tmp26_;
			gchar* property = NULL;
			GeeArrayList* _tmp27_;
			gpointer _tmp28_;
			GeeArrayList* _tmp29_;
			RygelLocalSearchUPnPPropertyMap* _tmp30_;
			const gchar* _tmp31_;
			gchar* _tmp32_;
			gchar* _tmp33_;
			_property_index = _property_index + 1;
			_tmp25_ = _property_index;
			_tmp26_ = _property_size;
			if (!(_tmp25_ < _tmp26_)) {
				break;
			}
			_tmp27_ = _property_list;
			_tmp28_ = gee_abstract_list_get ((GeeAbstractList*) _tmp27_, _property_index);
			property = (gchar*) _tmp28_;
			_tmp29_ = variables;
			_tmp30_ = property_map;
			_tmp31_ = property;
			_tmp32_ = rygel_local_search_upn_pproperty_map_get (_tmp30_, _tmp31_);
			_tmp33_ = _tmp32_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp29_, _tmp33_);
			_g_free0 (_tmp33_);
			_g_free0 (property);
		}
	}
	_tmp34_ = g_strdup (RYGEL_LOCAL_SEARCH_SEARCH_CONTAINER_MODIFIED_PROPERTY "(" RYGEL_LOCAL_SEARCH_SELECTION_QUERY_STORAGE_VARIABLE ")");
	order_by = _tmp34_;
	_tmp35_ = variables;
	_tmp36_ = our_triplets;
	_tmp37_ = self->item_factory;
	_tmp38_ = _tmp37_->graph;
	_tmp39_ = rygel_local_search_selection_query_new (_tmp35_, _tmp36_, filters, _tmp38_, order_by, 0, -1);
	_rygel_local_search_query_unref0 (self->query);
	self->query = _tmp39_;
	rygel_local_search_search_container_get_children_count (self, NULL, NULL);
	_g_free0 (order_by);
	_g_object_unref0 (property_map);
	_g_object_unref0 (our_triplets);
	_g_object_unref0 (variables);
	return self;
}

RygelLocalSearchSearchContainer*
rygel_local_search_search_container_new (const gchar* id,
                                         RygelMediaContainer* parent,
                                         const gchar* title,
                                         RygelLocalSearchItemFactory* item_factory,
                                         RygelLocalSearchQueryTriplets* triplets,
                                         GeeArrayList* filters)
{
	return rygel_local_search_search_container_construct (RYGEL_LOCAL_SEARCH_TYPE_SEARCH_CONTAINER, id, parent, title, item_factory, triplets, filters);
}

static void
rygel_local_search_search_container_real_get_children_data_free (gpointer _data)
{
	RygelLocalSearchSearchContainerGetChildrenData* _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 (RygelLocalSearchSearchContainerGetChildrenData, _data_);
}

static void
rygel_local_search_search_container_real_get_children (RygelMediaContainer* base,
                                                       guint offset,
                                                       guint max_count,
                                                       const gchar* sort_criteria,
                                                       GCancellable* cancellable,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	RygelLocalSearchSearchContainer * self;
	RygelLocalSearchSearchContainerGetChildrenData* _data_;
	RygelLocalSearchSearchContainer* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (sort_criteria != NULL);
	self = (RygelLocalSearchSearchContainer*) base;
	_data_ = g_slice_new0 (RygelLocalSearchSearchContainerGetChildrenData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_local_search_search_container_real_get_children_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->offset = offset;
	_data_->max_count = max_count;
	_tmp1_ = g_strdup (sort_criteria);
	_g_free0 (_data_->sort_criteria);
	_data_->sort_criteria = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	rygel_local_search_search_container_real_get_children_co (_data_);
}

static RygelMediaObjects*
rygel_local_search_search_container_get_children_finish (RygelMediaContainer* base,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	RygelMediaObjects* result;
	RygelLocalSearchSearchContainerGetChildrenData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
rygel_local_search_search_container_get_children_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_)
{
	RygelLocalSearchSearchContainerGetChildrenData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_local_search_search_container_real_get_children_co (_data_);
}

static gboolean
rygel_local_search_search_container_real_get_children_co (RygelLocalSearchSearchContainerGetChildrenData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = rygel_relational_expression_new ();
	_data_->expression = _data_->_tmp0_;
	((RygelSearchExpression*) _data_->expression)->op = (gpointer) ((gintptr) GUPNP_SEARCH_CRITERIA_OP_EQ);
	_data_->_tmp1_ = g_strdup ("@parentID");
	_g_free0 (((RygelSearchExpression*) _data_->expression)->operand1);
	((RygelSearchExpression*) _data_->expression)->operand1 = _data_->_tmp1_;
	_data_->_tmp2_ = rygel_media_object_get_id ((RygelMediaObject*) _data_->self);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = g_strdup (_data_->_tmp3_);
	_g_free0 (((RygelSearchExpression*) _data_->expression)->operand2);
	((RygelSearchExpression*) _data_->expression)->operand2 = _data_->_tmp4_;
	_data_->_tmp6_ = 0U;
	_data_->_state_ = 1;
	rygel_local_search_search_container_execute_query (_data_->self, (RygelSearchExpression*) _data_->expression, _data_->sort_criteria, _data_->offset, _data_->max_count, _data_->cancellable, rygel_local_search_search_container_get_children_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp7_ = rygel_local_search_search_container_execute_query_finish (_data_->self, _data_->_res_, &_data_->_tmp6_, &_data_->_inner_error0_);
	_data_->total_matches = _data_->_tmp6_;
	_data_->_tmp5_ = _data_->_tmp7_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_rygel_search_expression_unref0 (_data_->expression);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp8_ = _data_->_tmp5_;
	_data_->_tmp5_ = NULL;
	_data_->result = _data_->_tmp8_;
	_g_object_unref0 (_data_->_tmp5_);
	_rygel_search_expression_unref0 (_data_->expression);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
rygel_local_search_search_container_execute_query_data_free (gpointer _data)
{
	RygelLocalSearchSearchContainerExecuteQueryData* _data_;
	_data_ = _data;
	_rygel_search_expression_unref0 (_data_->expression);
	_g_free0 (_data_->sort_criteria);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelLocalSearchSearchContainerExecuteQueryData, _data_);
}

static gpointer
_rygel_search_expression_ref0 (gpointer self)
{
	return self ? rygel_search_expression_ref (self) : NULL;
}

void
rygel_local_search_search_container_execute_query (RygelLocalSearchSearchContainer* self,
                                                   RygelSearchExpression* expression,
                                                   const gchar* sort_criteria,
                                                   guint offset,
                                                   guint max_count,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	RygelLocalSearchSearchContainerExecuteQueryData* _data_;
	RygelLocalSearchSearchContainer* _tmp0_;
	RygelSearchExpression* _tmp1_;
	gchar* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (sort_criteria != NULL);
	_data_ = g_slice_new0 (RygelLocalSearchSearchContainerExecuteQueryData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_local_search_search_container_execute_query_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _rygel_search_expression_ref0 (expression);
	_rygel_search_expression_unref0 (_data_->expression);
	_data_->expression = _tmp1_;
	_tmp2_ = g_strdup (sort_criteria);
	_g_free0 (_data_->sort_criteria);
	_data_->sort_criteria = _tmp2_;
	_data_->offset = offset;
	_data_->max_count = max_count;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp3_;
	rygel_local_search_search_container_execute_query_co (_data_);
}

RygelMediaObjects*
rygel_local_search_search_container_execute_query_finish (RygelLocalSearchSearchContainer* self,
                                                          GAsyncResult* _res_,
                                                          guint* total_matches,
                                                          GError** error)
{
	RygelMediaObjects* result;
	RygelLocalSearchSearchContainerExecuteQueryData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	if (total_matches) {
		*total_matches = _data_->total_matches;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
rygel_local_search_search_container_execute_query_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	RygelLocalSearchSearchContainerExecuteQueryData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_local_search_search_container_execute_query_co (_data_);
}

static gboolean
rygel_local_search_search_container_execute_query_co (RygelLocalSearchSearchContainerExecuteQueryData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = rygel_media_objects_new ();
	_data_->results = _data_->_tmp0_;
	_data_->_tmp1_ = rygel_local_search_search_container_create_query (_data_->self, G_TYPE_CHECK_INSTANCE_TYPE (_data_->expression, RYGEL_TYPE_RELATIONAL_EXPRESSION) ? ((RygelRelationalExpression*) _data_->expression) : NULL, (gint) _data_->offset, (gint) _data_->max_count, _data_->sort_criteria);
	_data_->query = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->query;
	if (_data_->_tmp2_ != NULL) {
		_data_->_tmp3_ = _data_->query;
		_data_->_tmp4_ = rygel_local_search_root_container_connection;
		_data_->_state_ = 1;
		rygel_local_search_query_execute ((RygelLocalSearchQuery*) _data_->_tmp3_, _data_->_tmp4_, rygel_local_search_search_container_execute_query_ready, _data_);
		return FALSE;
		_state_1:
		rygel_local_search_query_execute_finish ((RygelLocalSearchQuery*) _data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_rygel_local_search_query_unref0 (_data_->query);
			_g_object_unref0 (_data_->results);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		while (TRUE) {
			_data_->_tmp6_ = _data_->query;
			_data_->_tmp7_ = _data_->_tmp6_->result;
			_data_->_state_ = 2;
			tracker_sparql_cursor_next_async (_data_->_tmp7_, NULL, rygel_local_search_search_container_execute_query_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp5_ = tracker_sparql_cursor_next_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_rygel_local_search_query_unref0 (_data_->query);
				_g_object_unref0 (_data_->results);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			if (!_data_->_tmp5_) {
				break;
			}
			_data_->_tmp8_ = _data_->query;
			_data_->_tmp9_ = _data_->_tmp8_->result;
			_data_->_tmp10_ = tracker_sparql_cursor_get_string (_data_->_tmp9_, 0, NULL);
			_data_->_tmp11_ = g_strdup (_data_->_tmp10_);
			_data_->id = _data_->_tmp11_;
			_data_->_tmp12_ = _data_->id;
			_data_->_tmp13_ = rygel_local_search_search_container_create_child_id_for_urn (_data_->self, _data_->_tmp12_);
			_g_free0 (_data_->id);
			_data_->id = _data_->_tmp13_;
			_data_->_tmp14_ = _data_->query;
			_data_->_tmp15_ = _data_->_tmp14_->result;
			_data_->_tmp16_ = tracker_sparql_cursor_get_string (_data_->_tmp15_, 1, NULL);
			_data_->_tmp17_ = g_strdup (_data_->_tmp16_);
			_data_->uri = _data_->_tmp17_;
			_data_->_tmp18_ = _data_->self->item_factory;
			_data_->_tmp19_ = _data_->id;
			_data_->_tmp20_ = _data_->uri;
			_data_->_tmp21_ = _data_->query;
			_data_->_tmp22_ = _data_->_tmp21_->result;
			_data_->_tmp23_ = rygel_local_search_item_factory_create (_data_->_tmp18_, _data_->_tmp19_, _data_->_tmp20_, _data_->self, _data_->_tmp22_, &_data_->_inner_error0_);
			_data_->item = _data_->_tmp23_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_free0 (_data_->uri);
				_g_free0 (_data_->id);
				_rygel_local_search_query_unref0 (_data_->query);
				_g_object_unref0 (_data_->results);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp24_ = _data_->results;
			_data_->_tmp25_ = _data_->item;
			gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp24_, (RygelMediaObject*) _data_->_tmp25_);
			_g_object_unref0 (_data_->item);
			_g_free0 (_data_->uri);
			_g_free0 (_data_->id);
		}
		_data_->_tmp26_ = _data_->query;
		_data_->_tmp27_ = _data_->_tmp26_->result;
		tracker_sparql_cursor_close (_data_->_tmp27_);
	}
	_data_->_tmp28_ = _data_->results;
	_data_->_tmp29_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp28_);
	_data_->_tmp30_ = _data_->_tmp29_;
	_data_->total_matches = (guint) _data_->_tmp30_;
	_data_->result = _data_->results;
	_rygel_local_search_query_unref0 (_data_->query);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
rygel_local_search_search_container_real_find_object_data_free (gpointer _data)
{
	RygelLocalSearchSearchContainerFindObjectData* _data_;
	_data_ = _data;
	_g_free0 (_data_->id);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelLocalSearchSearchContainerFindObjectData, _data_);
}

static void
rygel_local_search_search_container_real_find_object (RygelMediaContainer* base,
                                                      const gchar* id,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	RygelLocalSearchSearchContainer * self;
	RygelLocalSearchSearchContainerFindObjectData* _data_;
	RygelLocalSearchSearchContainer* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (id != NULL);
	self = (RygelLocalSearchSearchContainer*) base;
	_data_ = g_slice_new0 (RygelLocalSearchSearchContainerFindObjectData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_local_search_search_container_real_find_object_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (id);
	_g_free0 (_data_->id);
	_data_->id = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	rygel_local_search_search_container_real_find_object_co (_data_);
}

static RygelMediaObject*
rygel_local_search_search_container_find_object_finish (RygelMediaContainer* base,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	RygelMediaObject* result;
	RygelLocalSearchSearchContainerFindObjectData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
rygel_local_search_search_container_find_object_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	RygelLocalSearchSearchContainerFindObjectData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_local_search_search_container_real_find_object_co (_data_);
}

static gboolean
rygel_local_search_search_container_real_find_object_co (RygelLocalSearchSearchContainerFindObjectData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (!rygel_local_search_search_container_is_our_child (_data_->self, _data_->id)) {
		_data_->result = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp0_ = rygel_relational_expression_new ();
	_data_->expression = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->expression;
	((RygelSearchExpression*) _data_->_tmp1_)->op = (gpointer) ((gintptr) GUPNP_SEARCH_CRITERIA_OP_EQ);
	_data_->_tmp2_ = _data_->expression;
	_data_->_tmp3_ = g_strdup ("@id");
	_g_free0 (((RygelSearchExpression*) _data_->_tmp2_)->operand1);
	((RygelSearchExpression*) _data_->_tmp2_)->operand1 = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->expression;
	_data_->_tmp5_ = g_strdup (_data_->id);
	_g_free0 (((RygelSearchExpression*) _data_->_tmp4_)->operand2);
	((RygelSearchExpression*) _data_->_tmp4_)->operand2 = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->expression;
	_data_->_tmp7_ = 0U;
	_data_->_state_ = 1;
	rygel_local_search_search_container_execute_query (_data_->self, (RygelSearchExpression*) _data_->_tmp6_, "", (guint) 0, (guint) 1, _data_->cancellable, rygel_local_search_search_container_find_object_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp8_ = rygel_local_search_search_container_execute_query_finish (_data_->self, _data_->_res_, &_data_->_tmp7_, &_data_->_inner_error0_);
	_data_->total_matches = _data_->_tmp7_;
	_data_->results = _data_->_tmp8_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_rygel_search_expression_unref0 (_data_->expression);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp9_ = _data_->results;
	_data_->_tmp10_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp9_);
	_data_->_tmp11_ = _data_->_tmp10_;
	if (_data_->_tmp11_ > 0) {
		_data_->_tmp12_ = _data_->results;
		_data_->_tmp13_ = gee_abstract_list_get ((GeeAbstractList*) _data_->_tmp12_, 0);
		_data_->result = (RygelMediaObject*) _data_->_tmp13_;
		_g_object_unref0 (_data_->results);
		_rygel_search_expression_unref0 (_data_->expression);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	} else {
		_data_->result = NULL;
		_g_object_unref0 (_data_->results);
		_rygel_search_expression_unref0 (_data_->expression);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
}

gchar*
rygel_local_search_search_container_create_child_id_for_urn (RygelLocalSearchSearchContainer* self,
                                                             const gchar* urn)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (urn != NULL, NULL);
	_tmp0_ = rygel_media_object_get_id ((RygelMediaObject*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat (_tmp1_, ",", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_strconcat (_tmp3_, urn, NULL);
	_tmp5_ = _tmp4_;
	_g_free0 (_tmp3_);
	result = _tmp5_;
	return result;
}

gchar*
rygel_local_search_search_container_get_item_info (RygelLocalSearchSearchContainer* self,
                                                   const gchar* item_id,
                                                   gchar** parent_id)
{
	gchar* _vala_parent_id = NULL;
	gchar** tokens = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint tokens_length1;
	gint _tokens_size_;
	gboolean _tmp2_ = FALSE;
	gchar** _tmp3_;
	gint _tmp3__length1;
	const gchar* _tmp4_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (item_id != NULL, NULL);
	_tmp1_ = _tmp0_ = g_strsplit (item_id, ",", 2);
	tokens = _tmp1_;
	tokens_length1 = _vala_array_length (_tmp0_);
	_tokens_size_ = tokens_length1;
	_tmp3_ = tokens;
	_tmp3__length1 = tokens_length1;
	_tmp4_ = _tmp3_[0];
	if (_tmp4_ != NULL) {
		gchar** _tmp5_;
		gint _tmp5__length1;
		const gchar* _tmp6_;
		_tmp5_ = tokens;
		_tmp5__length1 = tokens_length1;
		_tmp6_ = _tmp5_[1];
		_tmp2_ = _tmp6_ != NULL;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		gchar** _tmp7_;
		gint _tmp7__length1;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		gchar** _tmp10_;
		gint _tmp10__length1;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp7_ = tokens;
		_tmp7__length1 = tokens_length1;
		_tmp8_ = _tmp7_[0];
		_tmp9_ = g_strdup (_tmp8_);
		_g_free0 (_vala_parent_id);
		_vala_parent_id = _tmp9_;
		_tmp10_ = tokens;
		_tmp10__length1 = tokens_length1;
		_tmp11_ = _tmp10_[1];
		_tmp12_ = g_strdup (_tmp11_);
		result = _tmp12_;
		tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
		if (parent_id) {
			*parent_id = _vala_parent_id;
		} else {
			_g_free0 (_vala_parent_id);
		}
		return result;
	} else {
		_g_free0 (_vala_parent_id);
		_vala_parent_id = NULL;
		result = NULL;
		tokens = (_vala_array_free (tokens, tokens_length1, (GDestroyNotify) g_free), NULL);
		if (parent_id) {
			*parent_id = _vala_parent_id;
		} else {
			_g_free0 (_vala_parent_id);
		}
		return result;
	}
}

static void
rygel_local_search_search_container_get_children_count_data_free (gpointer _data)
{
	RygelLocalSearchSearchContainerGetChildrenCountData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelLocalSearchSearchContainerGetChildrenCountData, _data_);
}

void
rygel_local_search_search_container_get_children_count (RygelLocalSearchSearchContainer* self,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	RygelLocalSearchSearchContainerGetChildrenCountData* _data_;
	RygelLocalSearchSearchContainer* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (RygelLocalSearchSearchContainerGetChildrenCountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_local_search_search_container_get_children_count_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	rygel_local_search_search_container_get_children_count_co (_data_);
}

void
rygel_local_search_search_container_get_children_count_finish (RygelLocalSearchSearchContainer* self,
                                                               GAsyncResult* _res_)
{
	RygelLocalSearchSearchContainerGetChildrenCountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
rygel_local_search_search_container_get_children_count_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_)
{
	RygelLocalSearchSearchContainerGetChildrenCountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_local_search_search_container_get_children_count_co (_data_);
}

static gboolean
rygel_local_search_search_container_get_children_count_co (RygelLocalSearchSearchContainerGetChildrenCountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->query;
		_data_->_tmp1_ = rygel_local_search_selection_query_new_clone (_data_->_tmp0_);
		_data_->query = _data_->_tmp1_;
		_data_->_tmp2_ = _data_->query;
		_data_->_tmp3_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
		_g_object_unref0 (_data_->_tmp2_->variables);
		_data_->_tmp2_->variables = _data_->_tmp3_;
		_data_->_tmp4_ = _data_->query;
		_data_->_tmp5_ = _data_->_tmp4_->variables;
		gee_abstract_collection_add ((GeeAbstractCollection*) _data_->_tmp5_, "COUNT(" RYGEL_LOCAL_SEARCH_SELECTION_QUERY_ITEM_VARIABLE ") AS ?x");
		_data_->_tmp6_ = _data_->query;
		_data_->_tmp7_ = rygel_local_search_root_container_connection;
		_data_->_state_ = 1;
		rygel_local_search_query_execute ((RygelLocalSearchQuery*) _data_->_tmp6_, _data_->_tmp7_, rygel_local_search_search_container_get_children_count_ready, _data_);
		return FALSE;
		_state_1:
		rygel_local_search_query_execute_finish ((RygelLocalSearchQuery*) _data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_rygel_local_search_query_unref0 (_data_->query);
			goto __catch0_g_error;
		}
		_data_->_tmp9_ = _data_->query;
		_data_->_tmp10_ = _data_->_tmp9_->result;
		_data_->_tmp8_ = tracker_sparql_cursor_next (_data_->_tmp10_, NULL, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_rygel_local_search_query_unref0 (_data_->query);
			goto __catch0_g_error;
		}
		if (_data_->_tmp8_) {
			_data_->_tmp11_ = _data_->query;
			_data_->_tmp12_ = _data_->_tmp11_->result;
			_data_->_tmp13_ = tracker_sparql_cursor_get_string (_data_->_tmp12_, 0, NULL);
			rygel_media_container_set_child_count ((RygelMediaContainer*) _data_->self, atoi (_data_->_tmp13_));
			rygel_media_container_updated ((RygelMediaContainer*) _data_->self, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
		}
		_data_->_tmp14_ = _data_->query;
		_data_->_tmp15_ = _data_->_tmp14_->result;
		tracker_sparql_cursor_close (_data_->_tmp15_);
		_rygel_local_search_query_unref0 (_data_->query);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp16_ = _data_->self->item_factory;
		_data_->_tmp17_ = _data_->_tmp16_->category;
		_data_->_tmp18_ = _data_->_error_;
		_data_->_tmp19_ = _data_->_tmp18_->message;
		g_critical (_ ("Error getting item count under category “%s”: %s"), _data_->_tmp17_, _data_->_tmp19_);
		_g_error_free0 (_data_->_error_);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gboolean
rygel_local_search_search_container_is_our_child (RygelLocalSearchSearchContainer* self,
                                                  const gchar* id)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (id != NULL, FALSE);
	_tmp0_ = rygel_media_object_get_id ((RygelMediaObject*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_strconcat (_tmp1_, ",", NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = g_str_has_prefix (id, _tmp3_);
	_g_free0 (_tmp3_);
	result = _tmp4_;
	return result;
}

static RygelLocalSearchSelectionQuery*
rygel_local_search_search_container_create_query (RygelLocalSearchSearchContainer* self,
                                                  RygelRelationalExpression* expression,
                                                  gint offset,
                                                  gint max_count,
                                                  const gchar* sort_criteria)
{
	gboolean _tmp0_ = FALSE;
	gconstpointer _tmp1_;
	RygelLocalSearchSelectionQuery* query = NULL;
	gboolean _tmp5_ = FALSE;
	gconstpointer _tmp9_;
	RygelLocalSearchSelectionQuery* _tmp18_;
	RygelLocalSearchSelectionQuery* _tmp19_;
	RygelLocalSearchSelectionQuery* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (sort_criteria != NULL, NULL);
	_tmp1_ = ((RygelSearchExpression*) expression)->operand1;
	if (g_strcmp0 ((const gchar*) _tmp1_, "upnp:class") == 0) {
		RygelLocalSearchItemFactory* _tmp2_;
		const gchar* _tmp3_;
		gconstpointer _tmp4_;
		_tmp2_ = self->item_factory;
		_tmp3_ = _tmp2_->upnp_class;
		_tmp4_ = ((RygelSearchExpression*) expression)->operand2;
		_tmp0_ = !g_str_has_prefix (_tmp3_, (const gchar*) _tmp4_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	}
	if (sort_criteria == NULL) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = g_strcmp0 (sort_criteria, "") == 0;
	}
	if (_tmp5_) {
		RygelLocalSearchSelectionQuery* _tmp6_;
		RygelLocalSearchSelectionQuery* _tmp7_;
		_tmp6_ = self->query;
		_tmp7_ = rygel_local_search_selection_query_new_clone (_tmp6_);
		_rygel_local_search_query_unref0 (query);
		query = _tmp7_;
	} else {
		RygelLocalSearchSelectionQuery* _tmp8_;
		_tmp8_ = rygel_local_search_search_container_create_sorted_query (self, sort_criteria);
		_rygel_local_search_query_unref0 (query);
		query = _tmp8_;
	}
	_tmp9_ = ((RygelSearchExpression*) expression)->operand1;
	if (g_strcmp0 ((const gchar*) _tmp9_, "@parentID") == 0) {
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		_tmp10_ = rygel_media_object_get_id ((RygelMediaObject*) self);
		_tmp11_ = _tmp10_;
		if (!rygel_relational_expression_compare_string (expression, _tmp11_)) {
			result = NULL;
			_rygel_local_search_query_unref0 (query);
			return result;
		}
	} else {
		gconstpointer _tmp12_;
		_tmp12_ = ((RygelSearchExpression*) expression)->operand1;
		if (g_strcmp0 ((const gchar*) _tmp12_, "upnp:class") != 0) {
			gchar* filter = NULL;
			gchar* _tmp13_;
			const gchar* _tmp14_;
			_tmp13_ = rygel_local_search_search_container_create_filter_for_child (self, expression);
			filter = _tmp13_;
			_tmp14_ = filter;
			if (_tmp14_ != NULL) {
				RygelLocalSearchSelectionQuery* _tmp15_;
				GeeArrayList* _tmp16_;
				const gchar* _tmp17_;
				_tmp15_ = query;
				_tmp16_ = _tmp15_->filters;
				_tmp17_ = filter;
				gee_abstract_list_insert ((GeeAbstractList*) _tmp16_, 0, _tmp17_);
			} else {
				result = NULL;
				_g_free0 (filter);
				_rygel_local_search_query_unref0 (query);
				return result;
			}
			_g_free0 (filter);
		}
	}
	_tmp18_ = query;
	_tmp18_->offset = offset;
	_tmp19_ = query;
	_tmp19_->max_count = max_count;
	result = query;
	return result;
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static RygelLocalSearchSelectionQuery*
rygel_local_search_search_container_create_sorted_query (RygelLocalSearchSearchContainer* self,
                                                         const gchar* sort_criteria)
{
	RygelLocalSearchUPnPPropertyMap* key_chain_map = NULL;
	RygelLocalSearchUPnPPropertyMap* _tmp0_;
	gchar** sort_props = NULL;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint sort_props_length1;
	gint _sort_props_size_;
	gchar* order = NULL;
	gchar* _tmp3_;
	GeeArrayList* variables = NULL;
	GeeArrayList* _tmp4_;
	GeeArrayList* filters = NULL;
	GeeArrayList* _tmp5_;
	GeeArrayList* _tmp6_;
	RygelLocalSearchSelectionQuery* _tmp7_;
	GeeArrayList* _tmp8_;
	GeeArrayList* _tmp9_;
	RygelLocalSearchSelectionQuery* _tmp10_;
	GeeArrayList* _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	const gchar* _tmp36_;
	GeeArrayList* _tmp40_;
	RygelLocalSearchSelectionQuery* _tmp41_;
	RygelLocalSearchQueryTriplets* _tmp42_;
	RygelLocalSearchQueryTriplets* _tmp43_;
	RygelLocalSearchQueryTriplets* _tmp44_;
	GeeArrayList* _tmp45_;
	RygelLocalSearchItemFactory* _tmp46_;
	const gchar* _tmp47_;
	const gchar* _tmp48_;
	RygelLocalSearchSelectionQuery* _tmp49_;
	RygelLocalSearchSelectionQuery* _tmp50_;
	RygelLocalSearchSelectionQuery* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (sort_criteria != NULL, NULL);
	_tmp0_ = rygel_local_search_upn_pproperty_map_get_property_map ();
	key_chain_map = _tmp0_;
	_tmp2_ = _tmp1_ = g_strsplit (sort_criteria, ",", 0);
	sort_props = _tmp2_;
	sort_props_length1 = _vala_array_length (_tmp1_);
	_sort_props_size_ = sort_props_length1;
	_tmp3_ = g_strdup ("");
	order = _tmp3_;
	_tmp4_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	variables = _tmp4_;
	_tmp5_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	filters = _tmp5_;
	_tmp6_ = variables;
	_tmp7_ = self->query;
	_tmp8_ = _tmp7_->variables;
	gee_array_list_add_all (_tmp6_, (GeeCollection*) _tmp8_);
	_tmp9_ = filters;
	_tmp10_ = self->query;
	_tmp11_ = _tmp10_->filters;
	gee_array_list_add_all (_tmp9_, (GeeCollection*) _tmp11_);
	_tmp12_ = sort_props;
	_tmp12__length1 = sort_props_length1;
	{
		gchar** s_collection = NULL;
		gint s_collection_length1 = 0;
		gint _s_collection_size_ = 0;
		gint s_it = 0;
		s_collection = _tmp12_;
		s_collection_length1 = _tmp12__length1;
		for (s_it = 0; s_it < s_collection_length1; s_it = s_it + 1) {
			gchar* _tmp13_;
			gchar* s = NULL;
			_tmp13_ = g_strdup (s_collection[s_it]);
			s = _tmp13_;
			{
				gchar* key = NULL;
				RygelLocalSearchUPnPPropertyMap* _tmp14_;
				const gchar* _tmp15_;
				gchar* _tmp16_;
				gchar* _tmp17_;
				gchar* _tmp18_;
				gchar* _tmp19_;
				gboolean _tmp20_ = FALSE;
				const gchar* _tmp21_;
				const gchar* _tmp23_;
				_tmp14_ = key_chain_map;
				_tmp15_ = s;
				_tmp16_ = string_substring (_tmp15_, (glong) 1, (glong) -1);
				_tmp17_ = _tmp16_;
				_tmp18_ = rygel_local_search_upn_pproperty_map_get (_tmp14_, _tmp17_);
				_tmp19_ = _tmp18_;
				_g_free0 (_tmp17_);
				key = _tmp19_;
				_tmp21_ = key;
				if (string_index_of (_tmp21_, RYGEL_LOCAL_SEARCH_SELECTION_QUERY_ITEM_VARIABLE, 0) == 0) {
					_tmp20_ = TRUE;
				} else {
					const gchar* _tmp22_;
					_tmp22_ = key;
					_tmp20_ = string_index_of (_tmp22_, RYGEL_LOCAL_SEARCH_SELECTION_QUERY_STORAGE_VARIABLE, 0) == 0;
				}
				if (_tmp20_) {
					_g_free0 (key);
					_g_free0 (s);
					continue;
				}
				_tmp23_ = s;
				if (g_str_has_prefix (_tmp23_, "-")) {
					const gchar* _tmp24_;
					const gchar* _tmp25_;
					gchar* _tmp26_;
					gchar* _tmp27_;
					gchar* _tmp28_;
					gchar* _tmp29_;
					gchar* _tmp30_;
					_tmp24_ = order;
					_tmp25_ = key;
					_tmp26_ = g_strconcat ("DESC (", _tmp25_, NULL);
					_tmp27_ = _tmp26_;
					_tmp28_ = g_strconcat (_tmp27_, ") ", NULL);
					_tmp29_ = _tmp28_;
					_tmp30_ = g_strconcat (_tmp24_, _tmp29_, NULL);
					_g_free0 (order);
					order = _tmp30_;
					_g_free0 (_tmp29_);
					_g_free0 (_tmp27_);
				} else {
					const gchar* _tmp31_;
					const gchar* _tmp32_;
					gchar* _tmp33_;
					gchar* _tmp34_;
					gchar* _tmp35_;
					_tmp31_ = order;
					_tmp32_ = key;
					_tmp33_ = g_strconcat (_tmp32_, " ", NULL);
					_tmp34_ = _tmp33_;
					_tmp35_ = g_strconcat (_tmp31_, _tmp34_, NULL);
					_g_free0 (order);
					order = _tmp35_;
					_g_free0 (_tmp34_);
				}
				_g_free0 (key);
				_g_free0 (s);
			}
		}
	}
	_tmp36_ = order;
	if (g_strcmp0 (_tmp36_, "") == 0) {
		RygelLocalSearchSelectionQuery* _tmp37_;
		const gchar* _tmp38_;
		gchar* _tmp39_;
		_tmp37_ = self->query;
		_tmp38_ = _tmp37_->order_by;
		_tmp39_ = g_strdup (_tmp38_);
		_g_free0 (order);
		order = _tmp39_;
	}
	_tmp40_ = variables;
	_tmp41_ = self->query;
	_tmp42_ = ((RygelLocalSearchQuery*) _tmp41_)->triplets;
	_tmp43_ = rygel_local_search_query_triplets_new_clone (_tmp42_);
	_tmp44_ = _tmp43_;
	_tmp45_ = filters;
	_tmp46_ = self->item_factory;
	_tmp47_ = _tmp46_->graph;
	_tmp48_ = order;
	_tmp49_ = rygel_local_search_selection_query_new (_tmp40_, _tmp44_, _tmp45_, _tmp47_, _tmp48_, 0, -1);
	_tmp50_ = _tmp49_;
	_g_object_unref0 (_tmp44_);
	result = _tmp50_;
	_g_object_unref0 (filters);
	_g_object_unref0 (variables);
	_g_free0 (order);
	sort_props = (_vala_array_free (sort_props, sort_props_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (key_chain_map);
	return result;
}

static gunichar
string_get_char (const gchar* self,
                 glong index)
{
	gunichar result;
	g_return_val_if_fail (self != NULL, 0U);
	result = g_utf8_get_char (((gchar*) self) + index);
	return result;
}

static gchar*
rygel_local_search_search_container_urn_to_utf8 (RygelLocalSearchSearchContainer* self,
                                                 const gchar* urn)
{
	GString* urn_builder = NULL;
	GString* _tmp0_;
	const gchar* s = NULL;
	GString* _tmp8_;
	const gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (urn != NULL, NULL);
	_tmp0_ = g_string_new ("");
	urn_builder = _tmp0_;
	s = urn;
	{
		gboolean _tmp1_ = FALSE;
		_tmp1_ = TRUE;
		while (TRUE) {
			const gchar* _tmp4_;
			gunichar character = 0U;
			const gchar* _tmp5_;
			gboolean _tmp6_ = FALSE;
			if (!_tmp1_) {
				const gchar* _tmp2_;
				const gchar* _tmp3_;
				_tmp2_ = s;
				_tmp3_ = g_utf8_next_char (_tmp2_);
				s = _tmp3_;
			}
			_tmp1_ = FALSE;
			_tmp4_ = s;
			if (!(string_get_char (_tmp4_, (glong) 0) != ((gunichar) 0))) {
				break;
			}
			_tmp5_ = s;
			character = string_get_char (_tmp5_, (glong) 0);
			if (g_unichar_iscntrl (character)) {
				_tmp6_ = TRUE;
			} else {
				_tmp6_ = !g_unichar_validate (character);
			}
			if (!_tmp6_) {
				GString* _tmp7_;
				_tmp7_ = urn_builder;
				g_string_append_unichar (_tmp7_, character);
			}
		}
	}
	_tmp8_ = urn_builder;
	_tmp9_ = _tmp8_->str;
	_tmp10_ = g_strdup (_tmp9_);
	result = _tmp10_;
	_g_string_free0 (urn_builder);
	return result;
}

static gchar*
rygel_local_search_search_container_create_filter_for_child (RygelLocalSearchSearchContainer* self,
                                                             RygelRelationalExpression* expression)
{
	gchar* filter = NULL;
	gchar* variable = NULL;
	gchar* value = NULL;
	gconstpointer _tmp0_;
	gboolean _tmp24_ = FALSE;
	const gchar* _tmp25_;
	gconstpointer _tmp27_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (expression != NULL, NULL);
	filter = NULL;
	variable = NULL;
	value = NULL;
	_tmp0_ = ((RygelSearchExpression*) expression)->operand1;
	if (g_strcmp0 ((const gchar*) _tmp0_, "@id") == 0) {
		gchar* _tmp1_;
		gchar* parent_id = NULL;
		gchar* urn = NULL;
		gconstpointer _tmp2_;
		gchar* _tmp3_ = NULL;
		gchar* _tmp4_;
		const gchar* _tmp5_;
		gboolean _tmp8_ = FALSE;
		gboolean _tmp9_ = FALSE;
		const gchar* _tmp10_;
		const gchar* _tmp15_;
		gchar* _tmp16_;
		gconstpointer _tmp17_;
		_tmp1_ = g_strdup (RYGEL_LOCAL_SEARCH_SELECTION_QUERY_ITEM_VARIABLE);
		_g_free0 (variable);
		variable = _tmp1_;
		_tmp2_ = ((RygelSearchExpression*) expression)->operand2;
		_tmp4_ = rygel_local_search_search_container_get_item_info (self, (const gchar*) _tmp2_, &_tmp3_);
		_g_free0 (parent_id);
		parent_id = _tmp3_;
		urn = _tmp4_;
		_tmp5_ = urn;
		if (!g_utf8_validate (_tmp5_, (gssize) -1, NULL)) {
			const gchar* _tmp6_;
			gchar* _tmp7_;
			_tmp6_ = urn;
			_tmp7_ = rygel_local_search_search_container_urn_to_utf8 (self, _tmp6_);
			_g_free0 (urn);
			urn = _tmp7_;
		}
		_tmp10_ = urn;
		if (_tmp10_ == NULL) {
			_tmp9_ = TRUE;
		} else {
			const gchar* _tmp11_;
			_tmp11_ = parent_id;
			_tmp9_ = _tmp11_ == NULL;
		}
		if (_tmp9_) {
			_tmp8_ = TRUE;
		} else {
			const gchar* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			_tmp12_ = parent_id;
			_tmp13_ = rygel_media_object_get_id ((RygelMediaObject*) self);
			_tmp14_ = _tmp13_;
			_tmp8_ = g_strcmp0 (_tmp12_, _tmp14_) != 0;
		}
		if (_tmp8_) {
			result = NULL;
			_g_free0 (urn);
			_g_free0 (parent_id);
			_g_free0 (value);
			_g_free0 (variable);
			_g_free0 (filter);
			return result;
		}
		_tmp15_ = urn;
		_tmp16_ = rygel_local_search_query_escape_string (_tmp15_);
		_g_free0 (urn);
		urn = _tmp16_;
		_tmp17_ = ((RygelSearchExpression*) expression)->op;
		switch ((GUPnPSearchCriteriaOp) ((gintptr) _tmp17_)) {
			case GUPNP_SEARCH_CRITERIA_OP_EQ:
			{
				const gchar* _tmp18_;
				gchar* _tmp19_;
				gchar* _tmp20_;
				gchar* _tmp21_;
				_tmp18_ = urn;
				_tmp19_ = g_strconcat ("<", _tmp18_, NULL);
				_tmp20_ = _tmp19_;
				_tmp21_ = g_strconcat (_tmp20_, ">", NULL);
				_g_free0 (value);
				value = _tmp21_;
				_g_free0 (_tmp20_);
				break;
			}
			case GUPNP_SEARCH_CRITERIA_OP_CONTAINS:
			{
				gconstpointer _tmp22_;
				gchar* _tmp23_;
				_tmp22_ = ((RygelSearchExpression*) expression)->operand2;
				_tmp23_ = g_strdup ((const gchar*) _tmp22_);
				_g_free0 (value);
				value = _tmp23_;
				break;
			}
			default:
			{
				break;
			}
		}
		_g_free0 (urn);
		_g_free0 (parent_id);
	}
	_tmp25_ = variable;
	if (_tmp25_ == NULL) {
		_tmp24_ = TRUE;
	} else {
		const gchar* _tmp26_;
		_tmp26_ = value;
		_tmp24_ = _tmp26_ == NULL;
	}
	if (_tmp24_) {
		result = NULL;
		_g_free0 (value);
		_g_free0 (variable);
		_g_free0 (filter);
		return result;
	}
	_tmp27_ = ((RygelSearchExpression*) expression)->op;
	switch ((GUPnPSearchCriteriaOp) ((gintptr) _tmp27_)) {
		case GUPNP_SEARCH_CRITERIA_OP_EQ:
		{
			const gchar* _tmp28_;
			gchar* _tmp29_;
			gchar* _tmp30_;
			const gchar* _tmp31_;
			gchar* _tmp32_;
			_tmp28_ = variable;
			_tmp29_ = g_strconcat (_tmp28_, " = ", NULL);
			_tmp30_ = _tmp29_;
			_tmp31_ = value;
			_tmp32_ = g_strconcat (_tmp30_, _tmp31_, NULL);
			_g_free0 (filter);
			filter = _tmp32_;
			_g_free0 (_tmp30_);
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_CONTAINS:
		{
			gchar* regex = NULL;
			const gchar* _tmp33_;
			gchar* _tmp34_;
			const gchar* _tmp35_;
			gchar* _tmp36_;
			gchar* _tmp37_;
			gchar* _tmp38_;
			gchar* _tmp39_;
			const gchar* _tmp40_;
			gchar* _tmp41_;
			gchar* _tmp42_;
			gchar* _tmp43_;
			_tmp33_ = value;
			_tmp34_ = rygel_local_search_query_escape_regex (_tmp33_);
			regex = _tmp34_;
			_tmp35_ = variable;
			_tmp36_ = g_strconcat ("regex(", _tmp35_, NULL);
			_tmp37_ = _tmp36_;
			_tmp38_ = g_strconcat (_tmp37_, ", \"", NULL);
			_tmp39_ = _tmp38_;
			_tmp40_ = regex;
			_tmp41_ = g_strconcat (_tmp39_, _tmp40_, NULL);
			_tmp42_ = _tmp41_;
			_tmp43_ = g_strconcat (_tmp42_, "\", \"i\")", NULL);
			_g_free0 (filter);
			filter = _tmp43_;
			_g_free0 (_tmp42_);
			_g_free0 (_tmp39_);
			_g_free0 (_tmp37_);
			_g_free0 (regex);
			break;
		}
		default:
		{
			break;
		}
	}
	result = filter;
	_g_free0 (value);
	_g_free0 (variable);
	return result;
}

static void
rygel_local_search_search_container_class_init (RygelLocalSearchSearchContainerClass * klass,
                                                gpointer klass_data)
{
	GeeHashMap* _tmp0_;
	rygel_local_search_search_container_parent_class = g_type_class_peek_parent (klass);
	((RygelMediaContainerClass *) klass)->get_children = (void (*) (RygelMediaContainer*, guint, guint, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_local_search_search_container_real_get_children;
	((RygelMediaContainerClass *) klass)->get_children_finish = (RygelMediaObjects* (*) (RygelMediaContainer*, GAsyncResult*, GError**)) rygel_local_search_search_container_get_children_finish;
	((RygelMediaContainerClass *) klass)->find_object = (void (*) (RygelMediaContainer*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_local_search_search_container_real_find_object;
	((RygelMediaContainerClass *) klass)->find_object_finish = (RygelMediaObject* (*) (RygelMediaContainer*, GAsyncResult*, GError**)) rygel_local_search_search_container_find_object_finish;
	G_OBJECT_CLASS (klass)->finalize = rygel_local_search_search_container_finalize;
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_UINT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (rygel_local_search_search_container_update_id_hash);
	rygel_local_search_search_container_update_id_hash = _tmp0_;
}

static void
rygel_local_search_search_container_instance_init (RygelLocalSearchSearchContainer * self,
                                                   gpointer klass)
{
}

static void
rygel_local_search_search_container_finalize (GObject * obj)
{
	RygelLocalSearchSearchContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_LOCAL_SEARCH_TYPE_SEARCH_CONTAINER, RygelLocalSearchSearchContainer);
	_rygel_local_search_query_unref0 (self->query);
	_rygel_local_search_item_factory_unref0 (self->item_factory);
	G_OBJECT_CLASS (rygel_local_search_search_container_parent_class)->finalize (obj);
}

/**
 * A container listing a LocalSearch search result.
 */
 G_GNUC_NO_INLINE static GType
rygel_local_search_search_container_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelLocalSearchSearchContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_local_search_search_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelLocalSearchSearchContainer), 0, (GInstanceInitFunc) rygel_local_search_search_container_instance_init, NULL };
	GType rygel_local_search_search_container_type_id;
	rygel_local_search_search_container_type_id = g_type_register_static (RYGEL_TYPE_SIMPLE_CONTAINER, "RygelLocalSearchSearchContainer", &g_define_type_info, 0);
	return rygel_local_search_search_container_type_id;
}

GType
rygel_local_search_search_container_get_type (void)
{
	static volatile gsize rygel_local_search_search_container_type_id__once = 0;
	if (g_once_init_enter (&rygel_local_search_search_container_type_id__once)) {
		GType rygel_local_search_search_container_type_id;
		rygel_local_search_search_container_type_id = rygel_local_search_search_container_get_type_once ();
		g_once_init_leave (&rygel_local_search_search_container_type_id__once, rygel_local_search_search_container_type_id);
	}
	return rygel_local_search_search_container_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

