/* rygel-media-export-db-container.c generated by valac 0.56.19, the Vala compiler
 * generated from rygel-media-export-db-container.vala, do not modify */

/*
 * Copyright (C) 2009 Jens Georg <mail@jensge.org>.
 *
 * Author: 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.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-media-export.h"
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "rygel-server.h"
#include <gio/gio.h>
#include "rygel-db.h"

#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_MEDIA_EXPORT_DB_CONTAINER_0_PROPERTY,
	RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES_PROPERTY,
	RYGEL_MEDIA_EXPORT_DB_CONTAINER_NUM_PROPERTIES
};
static GParamSpec* rygel_media_export_db_container_properties[RYGEL_MEDIA_EXPORT_DB_CONTAINER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _RygelMediaExportDbContainerGetChildrenData RygelMediaExportDbContainerGetChildrenData;
#define _rygel_search_expression_unref0(var) ((var == NULL) ? NULL : (var = (rygel_search_expression_unref (var), NULL)))
typedef struct _RygelMediaExportDbContainerSearchData RygelMediaExportDbContainerSearchData;
typedef struct _RygelMediaExportDbContainerFindObjectData RygelMediaExportDbContainerFindObjectData;

struct _RygelMediaExportDBContainerPrivate {
	GeeArrayList* _search_classes;
};

struct _RygelMediaExportDbContainerGetChildrenData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportDBContainer* self;
	guint offset;
	guint max_count;
	gchar* sort_criteria;
	GCancellable* cancellable;
	RygelMediaObjects* result;
	RygelMediaObjects* _tmp0_;
	RygelMediaExportMediaCache* _tmp1_;
	RygelMediaObjects* _tmp2_;
	RygelMediaObjects* _tmp3_;
	GError* _inner_error0_;
};

struct _RygelMediaExportDbContainerSearchData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportDBContainer* self;
	RygelSearchExpression* expression;
	guint offset;
	guint max_count;
	gchar* sort_criteria;
	GCancellable* cancellable;
	guint total_matches;
	RygelMediaObjects* result;
	RygelMediaObjects* children;
	RygelMediaObjects* _tmp0_;
	RygelMediaExportMediaCache* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	guint _tmp4_;
	RygelMediaObjects* _tmp5_;
	RygelMediaObjects* _tmp6_;
	GError* _error_;
	GError* _tmp7_;
	RygelMediaObjects* _tmp8_;
	guint _tmp9_;
	RygelMediaObjects* _tmp10_;
	RygelMediaObjects* _tmp11_;
	GError* _tmp12_;
	GError* _tmp13_;
	GError* _inner_error0_;
};

struct _RygelMediaExportDbContainerFindObjectData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportDBContainer* self;
	gchar* id;
	GCancellable* cancellable;
	RygelMediaObject* result;
	RygelMediaObject* _tmp0_;
	RygelMediaExportMediaCache* _tmp1_;
	RygelMediaObject* _tmp2_;
	RygelMediaObject* _tmp3_;
	GError* _inner_error0_;
};

static gint RygelMediaExportDBContainer_private_offset;
static gpointer rygel_media_export_db_container_parent_class = NULL;
static RygelSearchableContainerIface * rygel_media_export_db_container_rygel_searchable_container_parent_iface = NULL;

static void rygel_media_export_db_container_real_constructed (GObject* base);
static void __lambda5_ (RygelMediaExportDBContainer* self);
static void ___lambda5__rygel_media_container_container_updated (RygelMediaContainer* _sender,
                                                          RygelMediaContainer* container,
                                                          RygelMediaObject* object,
                                                          RygelObjectEventType event_type,
                                                          gboolean sub_tree_update,
                                                          gpointer self);
static gint rygel_media_export_db_container_real_count_children (RygelMediaExportDBContainer* self);
static void rygel_media_export_db_container_real_get_children_data_free (gpointer _data);
static void rygel_media_export_db_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_db_container_real_get_children_co (RygelMediaExportDbContainerGetChildrenData* _data_);
static void rygel_media_export_db_container_real_search_data_free (gpointer _data);
static void rygel_media_export_db_container_real_search (RygelMediaExportDBContainer* self,
                                                  RygelSearchExpression* expression,
                                                  guint offset,
                                                  guint max_count,
                                                  const gchar* sort_criteria,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static gboolean rygel_media_export_db_container_real_search_co (RygelMediaExportDbContainerSearchData* _data_);
static void rygel_media_export_db_container_search_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void rygel_media_export_db_container_real_find_object_data_free (gpointer _data);
static void rygel_media_export_db_container_real_find_object (RygelMediaContainer* base,
                                                       const gchar* id,
                                                       GCancellable* cancellable,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static gboolean rygel_media_export_db_container_real_find_object_co (RygelMediaExportDbContainerFindObjectData* _data_);
static void rygel_media_export_db_container_finalize (GObject * obj);
static GType rygel_media_export_db_container_get_type_once (void);
static void _vala_rygel_media_export_db_container_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_rygel_media_export_db_container_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);

static inline gpointer
rygel_media_export_db_container_get_instance_private (RygelMediaExportDBContainer* self)
{
	return G_STRUCT_MEMBER_P (self, RygelMediaExportDBContainer_private_offset);
}

RygelMediaExportDBContainer*
rygel_media_export_db_container_construct (GType object_type,
                                           const gchar* id,
                                           const gchar* title)
{
	RygelMediaExportDBContainer * self = NULL;
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	self = (RygelMediaExportDBContainer*) g_object_new (object_type, "id", id, "parent", NULL, "title", title, "child-count", 0, NULL);
	return self;
}

RygelMediaExportDBContainer*
rygel_media_export_db_container_new (const gchar* id,
                                     const gchar* title)
{
	return rygel_media_export_db_container_construct (RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, id, title);
}

static void
__lambda5_ (RygelMediaExportDBContainer* self)
{
	rygel_media_container_set_child_count ((RygelMediaContainer*) self, rygel_media_export_db_container_count_children (self));
}

static void
___lambda5__rygel_media_container_container_updated (RygelMediaContainer* _sender,
                                                     RygelMediaContainer* container,
                                                     RygelMediaObject* object,
                                                     RygelObjectEventType event_type,
                                                     gboolean sub_tree_update,
                                                     gpointer self)
{
	__lambda5_ ((RygelMediaExportDBContainer*) self);
}

static void
rygel_media_export_db_container_real_constructed (GObject* base)
{
	RygelMediaExportDBContainer * self;
	RygelMediaExportMediaCache* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeArrayList* _tmp4_;
	GeeArrayList* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeArrayList* _tmp8_;
	GeeArrayList* _tmp9_;
	GeeArrayList* _tmp10_;
	GeeArrayList* _tmp11_;
	GeeArrayList* _tmp12_;
	GeeArrayList* _tmp13_;
	GeeArrayList* _tmp14_;
	GeeArrayList* _tmp15_;
	GeeArrayList* _tmp16_;
	self = (RygelMediaExportDBContainer*) base;
	G_OBJECT_CLASS (rygel_media_export_db_container_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_TYPE_MEDIA_CONTAINER, RygelMediaContainer));
	_tmp0_ = rygel_media_export_media_cache_get_default ();
	_g_object_unref0 (self->media_db);
	self->media_db = _tmp0_;
	_tmp1_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp2_ = _tmp1_;
	rygel_searchable_container_set_search_classes ((RygelSearchableContainer*) self, _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self);
	_tmp4_ = _tmp3_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp4_, RYGEL_IMAGE_ITEM_UPNP_CLASS);
	_tmp5_ = rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self);
	_tmp6_ = _tmp5_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp6_, RYGEL_PHOTO_ITEM_UPNP_CLASS);
	_tmp7_ = rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self);
	_tmp8_ = _tmp7_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp8_, RYGEL_VIDEO_ITEM_UPNP_CLASS);
	_tmp9_ = rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self);
	_tmp10_ = _tmp9_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, RYGEL_AUDIO_ITEM_UPNP_CLASS);
	_tmp11_ = rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self);
	_tmp12_ = _tmp11_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp12_, RYGEL_MUSIC_ITEM_UPNP_CLASS);
	_tmp13_ = rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self);
	_tmp14_ = _tmp13_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp14_, RYGEL_PLAYLIST_ITEM_UPNP_CLASS);
	_tmp15_ = rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self);
	_tmp16_ = _tmp15_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp16_, RYGEL_MEDIA_CONTAINER_UPNP_CLASS);
	g_signal_connect_object ((RygelMediaContainer*) self, "container-updated", (GCallback) ___lambda5__rygel_media_container_container_updated, self, 0);
	rygel_media_container_set_child_count ((RygelMediaContainer*) self, rygel_media_export_db_container_count_children (self));
}

static gint
rygel_media_export_db_container_real_count_children (RygelMediaExportDBContainer* self)
{
	gint _tmp7_ = -1;
	GError* _inner_error0_ = NULL;
	gint result;
	{
		gint _tmp0_ = 0;
		RygelMediaExportMediaCache* _tmp1_;
		const gchar* _tmp2_;
		const gchar* _tmp3_;
		_tmp1_ = self->media_db;
		_tmp2_ = rygel_media_object_get_id ((RygelMediaObject*) self);
		_tmp3_ = _tmp2_;
		_tmp0_ = rygel_media_export_media_cache_get_child_count (_tmp1_, _tmp3_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gint _tmp4_ = -1;
			if (_inner_error0_->domain == RYGEL_DATABASE_DATABASE_ERROR) {
				goto __catch0_rygel_database_database_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp4_;
		}
		result = _tmp0_;
		return result;
	}
	goto __finally0;
	__catch0_rygel_database_database_error:
	{
		GError* _error_ = NULL;
		GError* _tmp5_;
		const gchar* _tmp6_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp5_ = _error_;
		_tmp6_ = _tmp5_->message;
		g_debug ("rygel-media-export-db-container.vala:63: Could not get child count fro" \
"m database: %s", _tmp6_);
		result = 0;
		_g_error_free0 (_error_);
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return _tmp7_;
}

gint
rygel_media_export_db_container_count_children (RygelMediaExportDBContainer* self)
{
	RygelMediaExportDBContainerClass* _klass_;
	g_return_val_if_fail (self != NULL, -1);
	_klass_ = RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->count_children) {
		return _klass_->count_children (self);
	}
	return -1;
}

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

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

static void
rygel_media_export_db_container_real_get_children (RygelMediaContainer* base,
                                                   guint offset,
                                                   guint max_count,
                                                   const gchar* sort_criteria,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	RygelMediaExportDBContainer * self;
	RygelMediaExportDbContainerGetChildrenData* _data_;
	RygelMediaExportDBContainer* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (sort_criteria != NULL);
	self = (RygelMediaExportDBContainer*) base;
	_data_ = g_slice_new0 (RygelMediaExportDbContainerGetChildrenData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_db_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_media_export_db_container_real_get_children_co (_data_);
}

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

static gboolean
rygel_media_export_db_container_real_get_children_co (RygelMediaExportDbContainerGetChildrenData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->media_db;
	_data_->_tmp2_ = rygel_media_export_media_cache_get_children (_data_->_tmp1_, (RygelMediaContainer*) _data_->self, _data_->sort_criteria, (glong) _data_->offset, (glong) _data_->max_count, &_data_->_inner_error0_);
	_data_->_tmp0_ = _data_->_tmp2_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_data_->result = _data_->_tmp3_;
	_g_object_unref0 (_data_->_tmp0_);
	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_media_export_db_container_real_search_data_free (gpointer _data)
{
	RygelMediaExportDbContainerSearchData* _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 (RygelMediaExportDbContainerSearchData, _data_);
}

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

static void
rygel_media_export_db_container_real_search (RygelMediaExportDBContainer* self,
                                             RygelSearchExpression* expression,
                                             guint offset,
                                             guint max_count,
                                             const gchar* sort_criteria,
                                             GCancellable* cancellable,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	RygelMediaExportDbContainerSearchData* _data_;
	RygelMediaExportDBContainer* _tmp0_;
	RygelSearchExpression* _tmp1_;
	gchar* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (sort_criteria != NULL);
	_data_ = g_slice_new0 (RygelMediaExportDbContainerSearchData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_db_container_real_search_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_;
	_data_->offset = offset;
	_data_->max_count = max_count;
	_tmp2_ = g_strdup (sort_criteria);
	_g_free0 (_data_->sort_criteria);
	_data_->sort_criteria = _tmp2_;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp3_;
	rygel_media_export_db_container_real_search_co (_data_);
}

static RygelMediaObjects*
rygel_media_export_db_container_real_search_finish (RygelMediaExportDBContainer* self,
                                                    GAsyncResult* _res_,
                                                    guint* total_matches,
                                                    GError** error)
{
	RygelMediaObjects* result;
	RygelMediaExportDbContainerSearchData* _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_media_export_db_container_search_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	RygelMediaExportDbContainerSearchData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_media_export_db_container_real_search_co (_data_);
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

static gboolean
rygel_media_export_db_container_real_search_co (RygelMediaExportDbContainerSearchData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->children = NULL;
	{
		_data_->_tmp1_ = _data_->self->media_db;
		_data_->_tmp2_ = rygel_media_object_get_id ((RygelMediaObject*) _data_->self);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = 0U;
		_data_->_tmp5_ = rygel_media_export_media_cache_get_objects_by_search_expression (_data_->_tmp1_, _data_->expression, _data_->_tmp3_, _data_->sort_criteria, _data_->offset, _data_->max_count, &_data_->_tmp4_, &_data_->_inner_error0_);
		_data_->total_matches = _data_->_tmp4_;
		_data_->_tmp0_ = _data_->_tmp5_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR) {
				goto __catch0_rygel_media_export_media_cache_error;
			}
			goto __finally0;
		}
		_data_->_tmp6_ = _data_->_tmp0_;
		_data_->_tmp0_ = NULL;
		_g_object_unref0 (_data_->children);
		_data_->children = _data_->_tmp6_;
		_g_object_unref0 (_data_->_tmp0_);
	}
	goto __finally0;
	__catch0_rygel_media_export_media_cache_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp7_ = _data_->_error_;
		if (g_error_matches (_data_->_tmp7_, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH)) {
			_data_->_tmp9_ = 0U;
			_data_->_state_ = 1;
			rygel_searchable_container_simple_search ((RygelSearchableContainer*) _data_->self, _data_->expression, _data_->offset, _data_->max_count, _data_->sort_criteria, _data_->cancellable, rygel_media_export_db_container_search_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp10_ = rygel_searchable_container_simple_search_finish ((RygelSearchableContainer*) _data_->self, _data_->_res_, &_data_->_tmp9_, &_data_->_inner_error0_);
			_data_->total_matches = _data_->_tmp9_;
			_data_->_tmp8_ = _data_->_tmp10_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_error_free0 (_data_->_error_);
				goto __finally0;
			}
			_data_->_tmp11_ = _data_->_tmp8_;
			_data_->_tmp8_ = NULL;
			_g_object_unref0 (_data_->children);
			_data_->children = _data_->_tmp11_;
			_g_object_unref0 (_data_->_tmp8_);
		} else {
			_data_->_tmp12_ = _data_->_error_;
			_data_->_tmp13_ = _g_error_copy0 (_data_->_tmp12_);
			_data_->_inner_error0_ = _data_->_tmp13_;
			_g_error_free0 (_data_->_error_);
			goto __finally0;
		}
		_g_error_free0 (_data_->_error_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->children);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->children;
	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;
}

void
rygel_media_export_db_container_search (RygelMediaExportDBContainer* self,
                                        RygelSearchExpression* expression,
                                        guint offset,
                                        guint max_count,
                                        const gchar* sort_criteria,
                                        GCancellable* cancellable,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	RygelMediaExportDBContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->search) {
		_klass_->search (self, expression, offset, max_count, sort_criteria, cancellable, _callback_, _user_data_);
	}
}

RygelMediaObjects*
rygel_media_export_db_container_search_finish (RygelMediaExportDBContainer* self,
                                               GAsyncResult* _res_,
                                               guint* total_matches,
                                               GError** error)
{
	RygelMediaExportDBContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->search_finish) {
		return _klass_->search_finish (self, _res_, total_matches, error);
	}
	return NULL;
}

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

static void
rygel_media_export_db_container_real_find_object (RygelMediaContainer* base,
                                                  const gchar* id,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	RygelMediaExportDBContainer * self;
	RygelMediaExportDbContainerFindObjectData* _data_;
	RygelMediaExportDBContainer* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (id != NULL);
	self = (RygelMediaExportDBContainer*) base;
	_data_ = g_slice_new0 (RygelMediaExportDbContainerFindObjectData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_db_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_media_export_db_container_real_find_object_co (_data_);
}

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

static gboolean
rygel_media_export_db_container_real_find_object_co (RygelMediaExportDbContainerFindObjectData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->media_db;
	_data_->_tmp2_ = rygel_media_export_media_cache_get_object (_data_->_tmp1_, _data_->id, &_data_->_inner_error0_);
	_data_->_tmp0_ = _data_->_tmp2_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_data_->result = _data_->_tmp3_;
	_g_object_unref0 (_data_->_tmp0_);
	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 GeeArrayList*
rygel_media_export_db_container_real_get_search_classes (RygelSearchableContainer* base)
{
	GeeArrayList* result;
	RygelMediaExportDBContainer* self;
	GeeArrayList* _tmp0_;
	self = (RygelMediaExportDBContainer*) base;
	_tmp0_ = self->priv->_search_classes;
	result = _tmp0_;
	return result;
}

static void
rygel_media_export_db_container_real_set_search_classes (RygelSearchableContainer* base,
                                                         GeeArrayList* value)
{
	RygelMediaExportDBContainer* self;
	GeeArrayList* old_value;
	self = (RygelMediaExportDBContainer*) base;
	old_value = rygel_media_export_db_container_real_get_search_classes (base);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_search_classes);
		self->priv->_search_classes = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, rygel_media_export_db_container_properties[RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES_PROPERTY]);
	}
}

static void
rygel_media_export_db_container_class_init (RygelMediaExportDBContainerClass * klass,
                                            gpointer klass_data)
{
	rygel_media_export_db_container_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelMediaExportDBContainer_private_offset);
	((GObjectClass *) klass)->constructed = (void (*) (GObject*)) rygel_media_export_db_container_real_constructed;
	((RygelMediaExportDBContainerClass *) klass)->count_children = (gint (*) (RygelMediaExportDBContainer*)) rygel_media_export_db_container_real_count_children;
	((RygelMediaContainerClass *) klass)->get_children = (void (*) (RygelMediaContainer*, guint, guint, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_db_container_real_get_children;
	((RygelMediaContainerClass *) klass)->get_children_finish = (RygelMediaObjects* (*) (RygelMediaContainer*, GAsyncResult*, GError**)) rygel_media_export_db_container_get_children_finish;
	((RygelMediaExportDBContainerClass *) klass)->search = (void (*) (RygelMediaExportDBContainer*, RygelSearchExpression*, guint, guint, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_db_container_real_search;
	((RygelMediaExportDBContainerClass *) klass)->search_finish = (RygelMediaObjects* (*) (RygelMediaExportDBContainer*, GAsyncResult*, guint*, GError**)) rygel_media_export_db_container_real_search_finish;
	((RygelMediaContainerClass *) klass)->find_object = (void (*) (RygelMediaContainer*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_db_container_real_find_object;
	((RygelMediaContainerClass *) klass)->find_object_finish = (RygelMediaObject* (*) (RygelMediaContainer*, GAsyncResult*, GError**)) rygel_media_export_db_container_find_object_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_db_container_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_db_container_set_property;
	G_OBJECT_CLASS (klass)->finalize = rygel_media_export_db_container_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES_PROPERTY, rygel_media_export_db_container_properties[RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES_PROPERTY] = g_param_spec_object ("search-classes", "search-classes", "search-classes", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
rygel_media_export_db_container_rygel_searchable_container_interface_init (RygelSearchableContainerIface * iface,
                                                                           gpointer iface_data)
{
	rygel_media_export_db_container_rygel_searchable_container_parent_iface = g_type_interface_peek_parent (iface);
	iface->search = (void (*) (RygelSearchableContainer*, RygelSearchExpression*, guint, guint, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_db_container_search;
	iface->search_finish = (RygelMediaObjects* (*) (RygelSearchableContainer*, GAsyncResult*, guint*, GError**)) rygel_media_export_db_container_search_finish;
	iface->get_search_classes = rygel_media_export_db_container_real_get_search_classes;
	iface->set_search_classes = rygel_media_export_db_container_real_set_search_classes;
}

static void
rygel_media_export_db_container_instance_init (RygelMediaExportDBContainer * self,
                                               gpointer klass)
{
	self->priv = rygel_media_export_db_container_get_instance_private (self);
}

static void
rygel_media_export_db_container_finalize (GObject * obj)
{
	RygelMediaExportDBContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer);
	_g_object_unref0 (self->media_db);
	_g_object_unref0 (self->priv->_search_classes);
	G_OBJECT_CLASS (rygel_media_export_db_container_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
rygel_media_export_db_container_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportDBContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_db_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportDBContainer), 0, (GInstanceInitFunc) rygel_media_export_db_container_instance_init, NULL };
	static const GInterfaceInfo rygel_searchable_container_info = { (GInterfaceInitFunc) rygel_media_export_db_container_rygel_searchable_container_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType rygel_media_export_db_container_type_id;
	rygel_media_export_db_container_type_id = g_type_register_static (RYGEL_TYPE_MEDIA_CONTAINER, "RygelMediaExportDBContainer", &g_define_type_info, 0);
	g_type_add_interface_static (rygel_media_export_db_container_type_id, RYGEL_TYPE_SEARCHABLE_CONTAINER, &rygel_searchable_container_info);
	RygelMediaExportDBContainer_private_offset = g_type_add_instance_private (rygel_media_export_db_container_type_id, sizeof (RygelMediaExportDBContainerPrivate));
	return rygel_media_export_db_container_type_id;
}

GType
rygel_media_export_db_container_get_type (void)
{
	static volatile gsize rygel_media_export_db_container_type_id__once = 0;
	if (g_once_init_enter (&rygel_media_export_db_container_type_id__once)) {
		GType rygel_media_export_db_container_type_id;
		rygel_media_export_db_container_type_id = rygel_media_export_db_container_get_type_once ();
		g_once_init_leave (&rygel_media_export_db_container_type_id__once, rygel_media_export_db_container_type_id);
	}
	return rygel_media_export_db_container_type_id__once;
}

static void
_vala_rygel_media_export_db_container_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	RygelMediaExportDBContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer);
	switch (property_id) {
		case RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES_PROPERTY:
		g_value_set_object (value, rygel_searchable_container_get_search_classes ((RygelSearchableContainer*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_rygel_media_export_db_container_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	RygelMediaExportDBContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer);
	switch (property_id) {
		case RYGEL_MEDIA_EXPORT_DB_CONTAINER_SEARCH_CLASSES_PROPERTY:
		rygel_searchable_container_set_search_classes ((RygelSearchableContainer*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

