/* rygel-media-export-media-cache.c generated by valac 0.17.2.19-5f50d, the Vala compiler
 * generated from rygel-media-export-media-cache.vala, do not modify */

/*
 * Copyright (C) 2009,2010 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 of the License, or
 * (at your option) any later version.
 *
 * Rygel is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#include <glib.h>
#include <glib-object.h>
#include <string.h>
#include <gee.h>
#include <stdlib.h>
#include <gio/gio.h>
#include <rygel-server.h>
#include <glib/gi18n-lib.h>
#include <sqlite3.h>
#include <libgupnp-av/gupnp-av.h>


#define RYGEL_MEDIA_EXPORT_TYPE_OBJECT_TYPE (rygel_media_export_object_type_get_type ())

#define RYGEL_MEDIA_EXPORT_TYPE_EXISTS_CACHE_ENTRY (rygel_media_export_exists_cache_entry_get_type ())
typedef struct _RygelMediaExportExistsCacheEntry RygelMediaExportExistsCacheEntry;

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

typedef struct _RygelMediaExportMediaCache RygelMediaExportMediaCache;
typedef struct _RygelMediaExportMediaCacheClass RygelMediaExportMediaCacheClass;
typedef struct _RygelMediaExportMediaCachePrivate RygelMediaExportMediaCachePrivate;

#define RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER (rygel_media_export_sqlite_wrapper_get_type ())
#define RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapper))
#define RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapperClass))
#define RYGEL_MEDIA_EXPORT_IS_SQLITE_WRAPPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER))
#define RYGEL_MEDIA_EXPORT_IS_SQLITE_WRAPPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER))
#define RYGEL_MEDIA_EXPORT_SQLITE_WRAPPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQLITE_WRAPPER, RygelMediaExportSqliteWrapperClass))

typedef struct _RygelMediaExportSqliteWrapper RygelMediaExportSqliteWrapper;
typedef struct _RygelMediaExportSqliteWrapperClass RygelMediaExportSqliteWrapperClass;

#define RYGEL_MEDIA_EXPORT_TYPE_DATABASE (rygel_media_export_database_get_type ())
#define RYGEL_MEDIA_EXPORT_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE, RygelMediaExportDatabase))
#define RYGEL_MEDIA_EXPORT_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE, RygelMediaExportDatabaseClass))
#define RYGEL_MEDIA_EXPORT_IS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE))
#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE))
#define RYGEL_MEDIA_EXPORT_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE, RygelMediaExportDatabaseClass))

typedef struct _RygelMediaExportDatabase RygelMediaExportDatabase;
typedef struct _RygelMediaExportDatabaseClass RygelMediaExportDatabaseClass;

#define RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY (rygel_media_export_object_factory_get_type ())
#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactory))
#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactoryClass))
#define RYGEL_MEDIA_EXPORT_IS_OBJECT_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY))
#define RYGEL_MEDIA_EXPORT_IS_OBJECT_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY))
#define RYGEL_MEDIA_EXPORT_OBJECT_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_OBJECT_FACTORY, RygelMediaExportObjectFactoryClass))

typedef struct _RygelMediaExportObjectFactory RygelMediaExportObjectFactory;
typedef struct _RygelMediaExportObjectFactoryClass RygelMediaExportObjectFactoryClass;

#define RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY (rygel_media_export_sql_factory_get_type ())
#define RYGEL_MEDIA_EXPORT_SQL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactory))
#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactoryClass))
#define RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY))
#define RYGEL_MEDIA_EXPORT_IS_SQL_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY))
#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FACTORY, RygelMediaExportSQLFactoryClass))

typedef struct _RygelMediaExportSQLFactory RygelMediaExportSQLFactory;
typedef struct _RygelMediaExportSQLFactoryClass RygelMediaExportSQLFactoryClass;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define RYGEL_MEDIA_EXPORT_TYPE_SQL_STRING (rygel_media_export_sql_string_get_type ())
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR (rygel_media_export_database_cursor_get_type ())
#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursor))
#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorClass))
#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR))
#define RYGEL_MEDIA_EXPORT_IS_DATABASE_CURSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR))
#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_DATABASE_CURSOR, RygelMediaExportDatabaseCursorClass))

typedef struct _RygelMediaExportDatabaseCursor RygelMediaExportDatabaseCursor;
typedef struct _RygelMediaExportDatabaseCursorClass RygelMediaExportDatabaseCursorClass;

#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR (rygel_media_export_database_cursor_iterator_get_type ())
#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIterator))
#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIteratorClass))
#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR))
#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_IS_ITERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR))
#define RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_ITERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_DATABASE_CURSOR_TYPE_ITERATOR, RygelMediaExportDatabaseCursorIteratorClass))

typedef struct _RygelMediaExportDatabaseCursorIterator RygelMediaExportDatabaseCursorIterator;
typedef struct _RygelMediaExportDatabaseCursorIteratorClass RygelMediaExportDatabaseCursorIteratorClass;
#define _rygel_media_export_database_cursor_iterator_unref0(var) ((var == NULL) ? NULL : (var = (rygel_media_export_database_cursor_iterator_unref (var), NULL)))
#define _rygel_media_export_exists_cache_entry_free0(var) ((var == NULL) ? NULL : (var = (rygel_media_export_exists_cache_entry_free (var), NULL)))
#define _g_value_array_free0(var) ((var == NULL) ? NULL : (var = (g_value_array_free (var), NULL)))

#define RYGEL_MEDIA_EXPORT_TYPE_DETAIL_COLUMN (rygel_media_export_detail_column_get_type ())

#define RYGEL_TYPE_NULL_CONTAINER (rygel_null_container_get_type ())
#define RYGEL_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainer))
#define RYGEL_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainerClass))
#define RYGEL_IS_NULL_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_NULL_CONTAINER))
#define RYGEL_IS_NULL_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_NULL_CONTAINER))
#define RYGEL_NULL_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_NULL_CONTAINER, RygelNullContainerClass))

typedef struct _RygelNullContainer RygelNullContainer;
typedef struct _RygelNullContainerClass RygelNullContainerClass;

#define RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER (rygel_media_export_media_cache_upgrader_get_type ())
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgrader))
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgraderClass))
#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER))
#define RYGEL_MEDIA_EXPORT_IS_MEDIA_CACHE_UPGRADER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER))
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_UPGRADER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE_UPGRADER, RygelMediaExportMediaCacheUpgraderClass))

typedef struct _RygelMediaExportMediaCacheUpgrader RygelMediaExportMediaCacheUpgrader;
typedef struct _RygelMediaExportMediaCacheUpgraderClass RygelMediaExportMediaCacheUpgraderClass;
#define _rygel_media_export_media_cache_upgrader_unref0(var) ((var == NULL) ? NULL : (var = (rygel_media_export_media_cache_upgrader_unref (var), NULL)))

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

typedef struct _RygelMediaExportDBContainer RygelMediaExportDBContainer;
typedef struct _RygelMediaExportDBContainerClass RygelMediaExportDBContainerClass;
#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))

#define RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR (rygel_media_export_sql_operator_get_type ())
#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperator))
#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperatorClass))
#define RYGEL_MEDIA_EXPORT_IS_SQL_OPERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR))
#define RYGEL_MEDIA_EXPORT_IS_SQL_OPERATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR))
#define RYGEL_MEDIA_EXPORT_SQL_OPERATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_OPERATOR, RygelMediaExportSqlOperatorClass))

typedef struct _RygelMediaExportSqlOperator RygelMediaExportSqlOperator;
typedef struct _RygelMediaExportSqlOperatorClass RygelMediaExportSqlOperatorClass;

#define RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION (rygel_media_export_sql_function_get_type ())
#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunction))
#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunctionClass))
#define RYGEL_MEDIA_EXPORT_IS_SQL_FUNCTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION))
#define RYGEL_MEDIA_EXPORT_IS_SQL_FUNCTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION))
#define RYGEL_MEDIA_EXPORT_SQL_FUNCTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_SQL_FUNCTION, RygelMediaExportSqlFunctionClass))

typedef struct _RygelMediaExportSqlFunction RygelMediaExportSqlFunction;
typedef struct _RygelMediaExportSqlFunctionClass RygelMediaExportSqlFunctionClass;

typedef enum  {
	RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_SQLITE_ERROR,
	RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_GENERAL_ERROR,
	RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_INVALID_TYPE,
	RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH
} RygelMediaExportMediaCacheError;
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR rygel_media_export_media_cache_error_quark ()
typedef enum  {
	RYGEL_MEDIA_EXPORT_OBJECT_TYPE_CONTAINER,
	RYGEL_MEDIA_EXPORT_OBJECT_TYPE_ITEM
} RygelMediaExportObjectType;

struct _RygelMediaExportExistsCacheEntry {
	gint64 mtime;
	gint64 size;
};

struct _RygelMediaExportMediaCache {
	GObject parent_instance;
	RygelMediaExportMediaCachePrivate * priv;
};

struct _RygelMediaExportMediaCacheClass {
	GObjectClass parent_class;
};

struct _RygelMediaExportMediaCachePrivate {
	RygelMediaExportDatabase* db;
	RygelMediaExportObjectFactory* factory;
	RygelMediaExportSQLFactory* sql;
	GeeHashMap* exists_cache;
};

typedef enum  {
	RYGEL_MEDIA_EXPORT_DATABASE_ERROR_IO_ERROR,
	RYGEL_MEDIA_EXPORT_DATABASE_ERROR_SQLITE_ERROR
} RygelMediaExportDatabaseError;
#define RYGEL_MEDIA_EXPORT_DATABASE_ERROR rygel_media_export_database_error_quark ()
typedef enum  {
	RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA,
	RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT,
	RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE,
	RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT,
	RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN,
	RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER,
	RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR,
	RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER,
	RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR,
	RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN,
	RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT,
	RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS,
	RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS,
	RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_METADATA,
	RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE,
	RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE,
	RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON,
	RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON,
	RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA,
	RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE,
	RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS
} RygelMediaExportSQLString;

typedef enum  {
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TYPE,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TITLE,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SIZE,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_MIME_TYPE,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_WIDTH,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_HEIGHT,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CLASS,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ALBUM,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DATE,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITRATE,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SAMPLE_FREQ,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITS_PER_SAMPLE,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CHANNELS,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TRACK,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_COLOR_DEPTH,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DURATION,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_PARENT,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TIMESTAMP,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_URI,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DLNA_PROFILE,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_GENRE
} RygelMediaExportDetailColumn;


static gpointer rygel_media_export_media_cache_parent_class = NULL;
static RygelMediaExportMediaCache* rygel_media_export_media_cache_instance;
static RygelMediaExportMediaCache* rygel_media_export_media_cache_instance = NULL;

GQuark rygel_media_export_media_cache_error_quark (void);
GType rygel_media_export_object_type_get_type (void) G_GNUC_CONST;
GType rygel_media_export_exists_cache_entry_get_type (void) G_GNUC_CONST;
RygelMediaExportExistsCacheEntry* rygel_media_export_exists_cache_entry_dup (const RygelMediaExportExistsCacheEntry* self);
void rygel_media_export_exists_cache_entry_free (RygelMediaExportExistsCacheEntry* self);
GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
GType rygel_media_export_sqlite_wrapper_get_type (void) G_GNUC_CONST;
GType rygel_media_export_database_get_type (void) G_GNUC_CONST;
GType rygel_media_export_object_factory_get_type (void) G_GNUC_CONST;
GType rygel_media_export_sql_factory_get_type (void) G_GNUC_CONST;
#define RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCachePrivate))
enum  {
	RYGEL_MEDIA_EXPORT_MEDIA_CACHE_DUMMY_PROPERTY
};
static RygelMediaExportMediaCache* rygel_media_export_media_cache_new (GError** error);
static RygelMediaExportMediaCache* rygel_media_export_media_cache_construct (GType object_type, GError** error);
RygelMediaExportSQLFactory* rygel_media_export_sql_factory_new (void);
RygelMediaExportSQLFactory* rygel_media_export_sql_factory_construct (GType object_type);
static void rygel_media_export_media_cache_open_db (RygelMediaExportMediaCache* self, const gchar* name, GError** error);
RygelMediaExportObjectFactory* rygel_media_export_object_factory_new (void);
RygelMediaExportObjectFactory* rygel_media_export_object_factory_construct (GType object_type);
GQuark rygel_media_export_database_error_quark (void);
static void rygel_media_export_media_cache_get_exists_cache (RygelMediaExportMediaCache* self, GError** error);
gchar* rygel_media_export_media_cache_get_id (GFile* file);
RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error);
void rygel_media_export_media_cache_remove_by_id (RygelMediaExportMediaCache* self, const gchar* id, GError** error);
void rygel_media_export_database_exec (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
GType rygel_media_export_sql_string_get_type (void) G_GNUC_CONST;
const gchar* rygel_media_export_sql_factory_make (RygelMediaExportSQLFactory* self, RygelMediaExportSQLString query);
static void _vala_GValue_array_free (GValue* array, gint array_length);
void rygel_media_export_media_cache_remove_object (RygelMediaExportMediaCache* self, RygelMediaObject* object, GError** error);
void rygel_media_export_media_cache_save_container (RygelMediaExportMediaCache* self, RygelMediaContainer* container, GError** error);
void rygel_media_export_database_begin (RygelMediaExportDatabase* self, GError** error);
static void rygel_media_export_media_cache_create_object (RygelMediaExportMediaCache* self, RygelMediaObject* item, GError** error);
void rygel_media_export_database_commit (RygelMediaExportDatabase* self, GError** error);
void rygel_media_export_database_rollback (RygelMediaExportDatabase* self);
void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
static void rygel_media_export_media_cache_save_metadata (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error);
RygelMediaObject* rygel_media_export_media_cache_get_object (RygelMediaExportMediaCache* self, const gchar* object_id, GError** error);
GType rygel_media_export_database_cursor_get_type (void) G_GNUC_CONST;
static RygelMediaExportDatabaseCursor* rygel_media_export_media_cache_exec_cursor (RygelMediaExportMediaCache* self, RygelMediaExportSQLString id, GValue* values, int values_length1, GError** error);
gpointer rygel_media_export_database_cursor_iterator_ref (gpointer instance);
void rygel_media_export_database_cursor_iterator_unref (gpointer instance);
GParamSpec* rygel_media_export_database_cursor_param_spec_iterator (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_media_export_database_cursor_value_set_iterator (GValue* value, gpointer v_object);
void rygel_media_export_database_cursor_value_take_iterator (GValue* value, gpointer v_object);
gpointer rygel_media_export_database_cursor_value_get_iterator (const GValue* value);
GType rygel_media_export_database_cursor_iterator_get_type (void) G_GNUC_CONST;
RygelMediaExportDatabaseCursorIterator* rygel_media_export_database_cursor_iterator (RygelMediaExportDatabaseCursor* self);
gboolean rygel_media_export_database_cursor_iterator_next (RygelMediaExportDatabaseCursorIterator* self);
sqlite3_stmt* rygel_media_export_database_cursor_iterator_get (RygelMediaExportDatabaseCursorIterator* self, GError** error);
static RygelMediaObject* rygel_media_export_media_cache_get_object_from_statement (RygelMediaExportMediaCache* self, RygelMediaContainer* parent, sqlite3_stmt* statement);
RygelMediaContainer* rygel_media_export_media_cache_get_container (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
gint rygel_media_export_media_cache_get_child_count (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
static gint rygel_media_export_media_cache_query_value (RygelMediaExportMediaCache* self, RygelMediaExportSQLString id, GValue* values, int values_length1, GError** error);
gboolean rygel_media_export_media_cache_exists (RygelMediaExportMediaCache* self, GFile* file, gint64* timestamp, gint64* size, GError** error);
sqlite3_stmt* rygel_media_export_database_cursor_next (RygelMediaExportDatabaseCursor* self, GError** error);
RygelMediaObjects* rygel_media_export_media_cache_get_children (RygelMediaExportMediaCache* self, RygelMediaContainer* container, glong offset, glong max_count, GError** error);
RygelMediaObjects* rygel_media_export_media_cache_get_objects_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, guint offset, guint max_count, guint* total_matches, GError** error);
static gchar* rygel_media_export_media_cache_translate_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, GValueArray* args, const gchar* prefix, GError** error);
static guint rygel_media_export_media_cache_modify_limit (RygelMediaExportMediaCache* self, guint max_count);
glong rygel_media_export_media_cache_get_object_count_by_filter (RygelMediaExportMediaCache* self, const gchar* filter, GValueArray* args, const gchar* container_id, GError** error);
RygelMediaObjects* rygel_media_export_media_cache_get_objects_by_filter (RygelMediaExportMediaCache* self, const gchar* filter, GValueArray* args, const gchar* container_id, glong offset, glong max_count, GError** error);
glong rygel_media_export_media_cache_get_object_count_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, GError** error);
gint rygel_media_export_database_query_value (RygelMediaExportDatabase* self, const gchar* sql, GValue* args, int args_length1, GError** error);
RygelMediaExportDatabaseCursor* rygel_media_export_database_exec_cursor (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
GType rygel_media_export_detail_column_get_type (void) G_GNUC_CONST;
RygelNullContainer* rygel_null_container_new (void);
RygelNullContainer* rygel_null_container_construct (GType object_type);
GType rygel_null_container_get_type (void) G_GNUC_CONST;
void rygel_media_export_media_cache_debug_statistics (RygelMediaExportMediaCache* self);
GeeArrayList* rygel_media_export_media_cache_get_child_ids (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error);
GeeList* rygel_media_export_media_cache_get_meta_data_column_by_filter (RygelMediaExportMediaCache* self, const gchar* column, const gchar* filter, GValueArray* args, glong offset, glong max_count, GError** error);
GeeList* rygel_media_export_media_cache_get_object_attribute_by_search_expression (RygelMediaExportMediaCache* self, const gchar* attribute, RygelSearchExpression* expression, glong offset, guint max_count, GError** error);
static gchar* rygel_media_export_media_cache_map_operand_to_column (RygelMediaExportMediaCache* self, const gchar* operand, gchar** collate, GError** error);
void rygel_media_export_media_cache_flag_object (RygelMediaExportMediaCache* self, GFile* file, const gchar* flag, GError** error);
GeeList* rygel_media_export_media_cache_get_flagged_uris (RygelMediaExportMediaCache* self, const gchar* flag, GError** error);
RygelMediaExportDatabase* rygel_media_export_database_new (const gchar* name, GError** error);
RygelMediaExportDatabase* rygel_media_export_database_construct (GType object_type, const gchar* name, GError** error);
#define RYGEL_MEDIA_EXPORT_SQL_FACTORY_schema_version "10"
RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_new (RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql);
RygelMediaExportMediaCacheUpgrader* rygel_media_export_media_cache_upgrader_construct (GType object_type, RygelMediaExportDatabase* database, RygelMediaExportSQLFactory* sql);
gpointer rygel_media_export_media_cache_upgrader_ref (gpointer instance);
void rygel_media_export_media_cache_upgrader_unref (gpointer instance);
GParamSpec* rygel_media_export_param_spec_media_cache_upgrader (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void rygel_media_export_value_set_media_cache_upgrader (GValue* value, gpointer v_object);
void rygel_media_export_value_take_media_cache_upgrader (GValue* value, gpointer v_object);
gpointer rygel_media_export_value_get_media_cache_upgrader (const GValue* value);
GType rygel_media_export_media_cache_upgrader_get_type (void) G_GNUC_CONST;
gboolean rygel_media_export_media_cache_upgrader_needs_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint* current_version, GError** error);
void rygel_media_export_media_cache_upgrader_upgrade (RygelMediaExportMediaCacheUpgrader* self, gint old_version);
void rygel_media_export_media_cache_upgrader_fix_schema (RygelMediaExportMediaCacheUpgrader* self, GError** error);
void rygel_media_export_media_cache_upgrader_ensure_indices (RygelMediaExportMediaCacheUpgrader* self);
static gboolean rygel_media_export_media_cache_create_schema (RygelMediaExportMediaCache* self);
void rygel_media_export_database_null (GValue* result);
void rygel_media_export_database_analyze (RygelMediaExportDatabase* self);
GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
RygelMediaExportDBContainer* rygel_media_export_object_factory_get_container (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, const gchar* id, const gchar* title, guint child_count, const gchar* uri);
RygelMediaItem* rygel_media_export_object_factory_get_item (RygelMediaExportObjectFactory* self, RygelMediaExportMediaCache* media_db, RygelMediaContainer* parent, const gchar* id, const gchar* title, const gchar* upnp_class);
static void rygel_media_export_media_cache_fill_item (RygelMediaExportMediaCache* self, sqlite3_stmt* statement, RygelMediaItem* item);
static gchar* rygel_media_export_media_cache_search_expression_to_sql (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, GValueArray* args, GError** error);
static gchar* rygel_media_export_media_cache_logical_expression_to_sql (RygelMediaExportMediaCache* self, RygelLogicalExpression* expression, GValueArray* args, GError** error);
static gchar* rygel_media_export_media_cache_relational_expression_to_sql (RygelMediaExportMediaCache* self, RygelRelationalExpression* exp, GValueArray* args, GError** error);
static void _vala_GValue_free (GValue* self);
GType rygel_media_export_sql_operator_get_type (void) G_GNUC_CONST;
RygelMediaExportSqlOperator* rygel_media_export_sql_operator_new_from_search_criteria_op (GUPnPSearchCriteriaOp op, const gchar* arg, const gchar* collate);
RygelMediaExportSqlOperator* rygel_media_export_sql_operator_construct_from_search_criteria_op (GType object_type, GUPnPSearchCriteriaOp op, const gchar* arg, const gchar* collate);
RygelMediaExportSqlFunction* rygel_media_export_sql_function_new (const gchar* name, const gchar* arg);
RygelMediaExportSqlFunction* rygel_media_export_sql_function_construct (GType object_type, const gchar* name, const gchar* arg);
GType rygel_media_export_sql_function_get_type (void) G_GNUC_CONST;
RygelMediaExportSqlOperator* rygel_media_export_sql_operator_new (const gchar* name, const gchar* arg, const gchar* collate);
RygelMediaExportSqlOperator* rygel_media_export_sql_operator_construct (GType object_type, const gchar* name, const gchar* arg, const gchar* collate);
gchar* rygel_media_export_sql_operator_to_string (RygelMediaExportSqlOperator* self);
static void rygel_media_export_media_cache_finalize (GObject* obj);


GQuark rygel_media_export_media_cache_error_quark (void) {
	return g_quark_from_static_string ("rygel_media_export_media_cache_error-quark");
}


GType rygel_media_export_object_type_get_type (void) {
	static volatile gsize rygel_media_export_object_type_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_object_type_type_id__volatile)) {
		static const GEnumValue values[] = {{RYGEL_MEDIA_EXPORT_OBJECT_TYPE_CONTAINER, "RYGEL_MEDIA_EXPORT_OBJECT_TYPE_CONTAINER", "container"}, {RYGEL_MEDIA_EXPORT_OBJECT_TYPE_ITEM, "RYGEL_MEDIA_EXPORT_OBJECT_TYPE_ITEM", "item"}, {0, NULL, NULL}};
		GType rygel_media_export_object_type_type_id;
		rygel_media_export_object_type_type_id = g_enum_register_static ("RygelMediaExportObjectType", values);
		g_once_init_leave (&rygel_media_export_object_type_type_id__volatile, rygel_media_export_object_type_type_id);
	}
	return rygel_media_export_object_type_type_id__volatile;
}


RygelMediaExportExistsCacheEntry* rygel_media_export_exists_cache_entry_dup (const RygelMediaExportExistsCacheEntry* self) {
	RygelMediaExportExistsCacheEntry* dup;
	dup = g_new0 (RygelMediaExportExistsCacheEntry, 1);
	memcpy (dup, self, sizeof (RygelMediaExportExistsCacheEntry));
	return dup;
}


void rygel_media_export_exists_cache_entry_free (RygelMediaExportExistsCacheEntry* self) {
	g_free (self);
}


GType rygel_media_export_exists_cache_entry_get_type (void) {
	static volatile gsize rygel_media_export_exists_cache_entry_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_exists_cache_entry_type_id__volatile)) {
		GType rygel_media_export_exists_cache_entry_type_id;
		rygel_media_export_exists_cache_entry_type_id = g_boxed_type_register_static ("RygelMediaExportExistsCacheEntry", (GBoxedCopyFunc) rygel_media_export_exists_cache_entry_dup, (GBoxedFreeFunc) rygel_media_export_exists_cache_entry_free);
		g_once_init_leave (&rygel_media_export_exists_cache_entry_type_id__volatile, rygel_media_export_exists_cache_entry_type_id);
	}
	return rygel_media_export_exists_cache_entry_type_id__volatile;
}


static RygelMediaExportMediaCache* rygel_media_export_media_cache_construct (GType object_type, GError** error) {
	RygelMediaExportMediaCache * self = NULL;
	RygelMediaExportSQLFactory* _tmp0_;
	RygelMediaExportObjectFactory* _tmp1_;
	GError * _inner_error_ = NULL;
	self = (RygelMediaExportMediaCache*) g_object_new (object_type, NULL);
	_tmp0_ = rygel_media_export_sql_factory_new ();
	_g_object_unref0 (self->priv->sql);
	self->priv->sql = _tmp0_;
	rygel_media_export_media_cache_open_db (self, "media-export", &_inner_error_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (self);
		return NULL;
	}
	_tmp1_ = rygel_media_export_object_factory_new ();
	_g_object_unref0 (self->priv->factory);
	self->priv->factory = _tmp1_;
	rygel_media_export_media_cache_get_exists_cache (self, &_inner_error_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (self);
		return NULL;
	}
	return self;
}


static RygelMediaExportMediaCache* rygel_media_export_media_cache_new (GError** error) {
	return rygel_media_export_media_cache_construct (RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, error);
}


gchar* rygel_media_export_media_cache_get_id (GFile* file) {
	gchar* result = NULL;
	GFile* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* _tmp4_;
	g_return_val_if_fail (file != NULL, NULL);
	_tmp0_ = file;
	_tmp1_ = g_file_get_uri (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_compute_checksum_for_string (G_CHECKSUM_MD5, _tmp2_, (gsize) (-1));
	_tmp4_ = _tmp3_;
	_g_free0 (_tmp2_);
	result = _tmp4_;
	return result;
}


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


RygelMediaExportMediaCache* rygel_media_export_media_cache_get_default (GError** error) {
	RygelMediaExportMediaCache* result = NULL;
	RygelMediaExportMediaCache* _tmp0_;
	RygelMediaExportMediaCache* _tmp3_;
	RygelMediaExportMediaCache* _tmp4_;
	GError * _inner_error_ = NULL;
	_tmp0_ = rygel_media_export_media_cache_instance;
	if (_tmp0_ == NULL) {
		RygelMediaExportMediaCache* _tmp1_;
		RygelMediaExportMediaCache* _tmp2_;
		_tmp1_ = rygel_media_export_media_cache_new (&_inner_error_);
		_tmp2_ = _tmp1_;
		if (_inner_error_ != NULL) {
			g_propagate_error (error, _inner_error_);
			return NULL;
		}
		_g_object_unref0 (rygel_media_export_media_cache_instance);
		rygel_media_export_media_cache_instance = _tmp2_;
	}
	_tmp3_ = rygel_media_export_media_cache_instance;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	result = _tmp4_;
	return result;
}


static void _vala_GValue_array_free (GValue* array, gint array_length) {
	if (array != NULL) {
		int i;
		for (i = 0; i < array_length; i = i + 1) {
			g_value_unset (&array[i]);
		}
	}
	g_free (array);
}


void rygel_media_export_media_cache_remove_by_id (RygelMediaExportMediaCache* self, const gchar* id, GError** error) {
	const gchar* _tmp0_;
	GValue _tmp1_ = {0};
	GValue* _tmp2_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	RygelMediaExportDatabase* _tmp3_;
	RygelMediaExportSQLFactory* _tmp4_;
	const gchar* _tmp5_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (id != NULL);
	_tmp0_ = id;
	g_value_init (&_tmp1_, G_TYPE_STRING);
	g_value_set_string (&_tmp1_, _tmp0_);
	_tmp2_ = g_new0 (GValue, 1);
	_tmp2_[0] = _tmp1_;
	values = _tmp2_;
	values_length1 = 1;
	_values_size_ = values_length1;
	_tmp3_ = self->priv->db;
	_tmp4_ = self->priv->sql;
	_tmp5_ = rygel_media_export_sql_factory_make (_tmp4_, RYGEL_MEDIA_EXPORT_SQL_STRING_DELETE);
	rygel_media_export_database_exec (_tmp3_, _tmp5_, values, values_length1, &_inner_error_);
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			return;
		} else {
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	values = (_vala_GValue_array_free (values, values_length1), NULL);
}


void rygel_media_export_media_cache_remove_object (RygelMediaExportMediaCache* self, RygelMediaObject* object, GError** error) {
	RygelMediaObject* _tmp0_;
	const gchar* _tmp1_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = object;
	_tmp1_ = _tmp0_->id;
	rygel_media_export_media_cache_remove_by_id (self, _tmp1_, &_inner_error_);
	if (_inner_error_ != NULL) {
		if ((_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) || (_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR)) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
}


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


void rygel_media_export_media_cache_save_container (RygelMediaExportMediaCache* self, RygelMediaContainer* container, GError** error) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (container != NULL);
	{
		RygelMediaExportDatabase* _tmp0_;
		RygelMediaContainer* _tmp1_;
		RygelMediaExportDatabase* _tmp2_;
		_tmp0_ = self->priv->db;
		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
				goto __catch5_rygel_media_export_database_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_tmp1_ = container;
		rygel_media_export_media_cache_create_object (self, (RygelMediaObject*) _tmp1_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
				goto __catch5_rygel_media_export_database_error;
			}
			goto __finally5;
		}
		_tmp2_ = self->priv->db;
		rygel_media_export_database_commit (_tmp2_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
				goto __catch5_rygel_media_export_database_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	goto __finally5;
	__catch5_rygel_media_export_database_error:
	{
		GError* _error_ = NULL;
		RygelMediaExportDatabase* _tmp3_;
		GError* _tmp4_;
		GError* _tmp5_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = self->priv->db;
		rygel_media_export_database_rollback (_tmp3_);
		_tmp4_ = _error_;
		_tmp5_ = _g_error_copy0 (_tmp4_);
		_inner_error_ = _tmp5_;
		_g_error_free0 (_error_);
		goto __finally5;
	}
	__finally5:
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return;
	}
}


void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	{
		RygelMediaExportDatabase* _tmp0_;
		RygelMediaItem* _tmp1_;
		RygelMediaItem* _tmp2_;
		RygelMediaExportDatabase* _tmp3_;
		_tmp0_ = self->priv->db;
		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
				goto __catch6_rygel_media_export_database_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
		_tmp1_ = item;
		rygel_media_export_media_cache_save_metadata (self, _tmp1_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
				goto __catch6_rygel_media_export_database_error;
			}
			goto __finally6;
		}
		_tmp2_ = item;
		rygel_media_export_media_cache_create_object (self, (RygelMediaObject*) _tmp2_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
				goto __catch6_rygel_media_export_database_error;
			}
			goto __finally6;
		}
		_tmp3_ = self->priv->db;
		rygel_media_export_database_commit (_tmp3_, &_inner_error_);
		if (_inner_error_ != NULL) {
			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
				goto __catch6_rygel_media_export_database_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	goto __finally6;
	__catch6_rygel_media_export_database_error:
	{
		GError* _error_ = NULL;
		const gchar* _tmp4_ = NULL;
		RygelMediaItem* _tmp5_;
		const gchar* _tmp6_;
		GError* _tmp7_;
		const gchar* _tmp8_;
		RygelMediaExportDatabase* _tmp9_;
		GError* _tmp10_;
		GError* _tmp11_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp4_ = _ ("Failed to add item with ID %s: %s");
		_tmp5_ = item;
		_tmp6_ = ((RygelMediaObject*) _tmp5_)->id;
		_tmp7_ = _error_;
		_tmp8_ = _tmp7_->message;
		g_warning (_tmp4_, _tmp6_, _tmp8_);
		_tmp9_ = self->priv->db;
		rygel_media_export_database_rollback (_tmp9_);
		_tmp10_ = _error_;
		_tmp11_ = _g_error_copy0 (_tmp10_);
		_inner_error_ = _tmp11_;
		_g_error_free0 (_error_);
		goto __finally6;
	}
	__finally6:
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return;
	}
}


RygelMediaObject* rygel_media_export_media_cache_get_object (RygelMediaExportMediaCache* self, const gchar* object_id, GError** error) {
	RygelMediaObject* result = NULL;
	const gchar* _tmp0_;
	GValue _tmp1_ = {0};
	GValue* _tmp2_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	RygelMediaObject* parent;
	GValue* _tmp3_;
	gint _tmp3__length1;
	RygelMediaExportDatabaseCursor* _tmp4_ = NULL;
	RygelMediaExportDatabaseCursor* cursor;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (object_id != NULL, NULL);
	_tmp0_ = object_id;
	g_value_init (&_tmp1_, G_TYPE_STRING);
	g_value_set_string (&_tmp1_, _tmp0_);
	_tmp2_ = g_new0 (GValue, 1);
	_tmp2_[0] = _tmp1_;
	values = _tmp2_;
	values_length1 = 1;
	_values_size_ = values_length1;
	parent = NULL;
	_tmp3_ = values;
	_tmp3__length1 = values_length1;
	_tmp4_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT, _tmp3_, _tmp3__length1, &_inner_error_);
	cursor = _tmp4_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (parent);
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			return NULL;
		} else {
			_g_object_unref0 (parent);
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	{
		RygelMediaExportDatabaseCursor* _tmp5_;
		RygelMediaExportDatabaseCursorIterator* _tmp6_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp5_ = cursor;
		_tmp6_ = rygel_media_export_database_cursor_iterator (_tmp5_);
		_statement_it = _tmp6_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp7_;
			gboolean _tmp8_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp9_;
			sqlite3_stmt* _tmp10_ = NULL;
			sqlite3_stmt* statement;
			RygelMediaObject* _tmp11_;
			RygelMediaContainer* _tmp12_;
			RygelMediaContainer* parent_container;
			RygelMediaContainer* _tmp13_;
			sqlite3_stmt* _tmp14_;
			RygelMediaObject* _tmp15_ = NULL;
			RygelMediaObject* object;
			RygelMediaObject* _tmp16_;
			RygelMediaContainer* _tmp17_;
			RygelMediaObject* _tmp18_;
			RygelMediaObject* _tmp19_;
			_tmp7_ = _statement_it;
			_tmp8_ = rygel_media_export_database_cursor_iterator_next (_tmp7_);
			if (!_tmp8_) {
				break;
			}
			_tmp9_ = _statement_it;
			_tmp10_ = rygel_media_export_database_cursor_iterator_get (_tmp9_, &_inner_error_);
			statement = _tmp10_;
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
					g_propagate_error (error, _inner_error_);
					_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
					_g_object_unref0 (cursor);
					_g_object_unref0 (parent);
					values = (_vala_GValue_array_free (values, values_length1), NULL);
					return NULL;
				} else {
					_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
					_g_object_unref0 (cursor);
					_g_object_unref0 (parent);
					values = (_vala_GValue_array_free (values, values_length1), NULL);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return NULL;
				}
			}
			_tmp11_ = parent;
			_tmp12_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp11_) : NULL);
			parent_container = _tmp12_;
			_tmp13_ = parent_container;
			_tmp14_ = statement;
			_tmp15_ = rygel_media_export_media_cache_get_object_from_statement (self, _tmp13_, _tmp14_);
			object = _tmp15_;
			_tmp16_ = object;
			_tmp17_ = parent_container;
			rygel_media_object_set_parent_ref (_tmp16_, _tmp17_);
			_tmp18_ = object;
			_tmp19_ = _g_object_ref0 (_tmp18_);
			_g_object_unref0 (parent);
			parent = _tmp19_;
			_g_object_unref0 (object);
			_g_object_unref0 (parent_container);
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	result = parent;
	_g_object_unref0 (cursor);
	values = (_vala_GValue_array_free (values, values_length1), NULL);
	return result;
}


RygelMediaContainer* rygel_media_export_media_cache_get_container (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error) {
	RygelMediaContainer* result = NULL;
	const gchar* _tmp0_;
	RygelMediaObject* _tmp1_ = NULL;
	RygelMediaObject* object;
	gboolean _tmp2_ = FALSE;
	RygelMediaObject* _tmp3_;
	gboolean _tmp5_;
	RygelMediaObject* _tmp8_;
	RygelMediaContainer* _tmp9_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (container_id != NULL, NULL);
	_tmp0_ = container_id;
	_tmp1_ = rygel_media_export_media_cache_get_object (self, _tmp0_, &_inner_error_);
	object = _tmp1_;
	if (_inner_error_ != NULL) {
		if ((_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) || (_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR)) {
			g_propagate_error (error, _inner_error_);
			return NULL;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	_tmp3_ = object;
	if (_tmp3_ != NULL) {
		RygelMediaObject* _tmp4_;
		_tmp4_ = object;
		_tmp2_ = !G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, RYGEL_TYPE_MEDIA_CONTAINER);
	} else {
		_tmp2_ = FALSE;
	}
	_tmp5_ = _tmp2_;
	if (_tmp5_) {
		const gchar* _tmp6_;
		GError* _tmp7_;
		_tmp6_ = container_id;
		_tmp7_ = g_error_new (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_INVALID_TYPE, "Object with id %s is " "not a MediaContainer", _tmp6_);
		_inner_error_ = _tmp7_;
		if ((_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) || (_inner_error_->domain == RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR)) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (object);
			return NULL;
		} else {
			_g_object_unref0 (object);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	_tmp8_ = object;
	_tmp9_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp8_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp8_) : NULL);
	result = _tmp9_;
	_g_object_unref0 (object);
	return result;
}


gint rygel_media_export_media_cache_get_child_count (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error) {
	gint result = 0;
	const gchar* _tmp0_;
	GValue _tmp1_ = {0};
	GValue* _tmp2_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	gint _tmp3_ = 0;
	gint _tmp4_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (container_id != NULL, 0);
	_tmp0_ = container_id;
	g_value_init (&_tmp1_, G_TYPE_STRING);
	g_value_set_string (&_tmp1_, _tmp0_);
	_tmp2_ = g_new0 (GValue, 1);
	_tmp2_[0] = _tmp1_;
	values = _tmp2_;
	values_length1 = 1;
	_values_size_ = values_length1;
	_tmp3_ = rygel_media_export_media_cache_query_value (self, RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_COUNT, values, values_length1, &_inner_error_);
	_tmp4_ = _tmp3_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			return 0;
		} else {
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return 0;
		}
	}
	result = _tmp4_;
	values = (_vala_GValue_array_free (values, values_length1), NULL);
	return result;
}


gboolean rygel_media_export_media_cache_exists (RygelMediaExportMediaCache* self, GFile* file, gint64* timestamp, gint64* size, GError** error) {
	gint64 _vala_timestamp = 0LL;
	gint64 _vala_size = 0LL;
	gboolean result = FALSE;
	GFile* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* uri;
	const gchar* _tmp2_;
	GValue _tmp3_ = {0};
	GValue* _tmp4_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	GeeHashMap* _tmp5_;
	const gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	GValue* _tmp17_;
	gint _tmp17__length1;
	RygelMediaExportDatabaseCursor* _tmp18_ = NULL;
	RygelMediaExportDatabaseCursor* cursor;
	RygelMediaExportDatabaseCursor* _tmp19_;
	sqlite3_stmt* _tmp20_ = NULL;
	sqlite3_stmt* statement;
	sqlite3_stmt* _tmp21_;
	gint64 _tmp22_ = 0LL;
	sqlite3_stmt* _tmp23_;
	gint64 _tmp24_ = 0LL;
	sqlite3_stmt* _tmp25_;
	gint _tmp26_ = 0;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (file != NULL, FALSE);
	_tmp0_ = file;
	_tmp1_ = g_file_get_uri (_tmp0_);
	uri = _tmp1_;
	_tmp2_ = uri;
	g_value_init (&_tmp3_, G_TYPE_STRING);
	g_value_set_string (&_tmp3_, _tmp2_);
	_tmp4_ = g_new0 (GValue, 1);
	_tmp4_[0] = _tmp3_;
	values = _tmp4_;
	values_length1 = 1;
	_values_size_ = values_length1;
	_tmp5_ = self->priv->exists_cache;
	_tmp6_ = uri;
	_tmp7_ = gee_abstract_map_has_key ((GeeAbstractMap*) _tmp5_, _tmp6_);
	if (_tmp7_) {
		GeeHashMap* _tmp8_;
		const gchar* _tmp9_;
		gpointer _tmp10_ = NULL;
		RygelMediaExportExistsCacheEntry* entry;
		GeeHashMap* _tmp11_;
		const gchar* _tmp12_;
		RygelMediaExportExistsCacheEntry* _tmp13_;
		gint64 _tmp14_;
		RygelMediaExportExistsCacheEntry* _tmp15_;
		gint64 _tmp16_;
		_tmp8_ = self->priv->exists_cache;
		_tmp9_ = uri;
		_tmp10_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp8_, _tmp9_);
		entry = (RygelMediaExportExistsCacheEntry*) _tmp10_;
		_tmp11_ = self->priv->exists_cache;
		_tmp12_ = uri;
		gee_abstract_map_unset ((GeeAbstractMap*) _tmp11_, _tmp12_, NULL);
		_tmp13_ = entry;
		_tmp14_ = (*_tmp13_).mtime;
		_vala_timestamp = _tmp14_;
		_tmp15_ = entry;
		_tmp16_ = (*_tmp15_).size;
		_vala_size = _tmp16_;
		result = TRUE;
		_rygel_media_export_exists_cache_entry_free0 (entry);
		values = (_vala_GValue_array_free (values, values_length1), NULL);
		_g_free0 (uri);
		if (timestamp) {
			*timestamp = _vala_timestamp;
		}
		if (size) {
			*size = _vala_size;
		}
		return result;
	}
	_tmp17_ = values;
	_tmp17__length1 = values_length1;
	_tmp18_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS, _tmp17_, _tmp17__length1, &_inner_error_);
	cursor = _tmp18_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			_g_free0 (uri);
			return FALSE;
		} else {
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			_g_free0 (uri);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
	}
	_tmp19_ = cursor;
	_tmp20_ = rygel_media_export_database_cursor_next (_tmp19_, &_inner_error_);
	statement = _tmp20_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			_g_object_unref0 (cursor);
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			_g_free0 (uri);
			return FALSE;
		} else {
			_g_object_unref0 (cursor);
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			_g_free0 (uri);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return FALSE;
		}
	}
	_tmp21_ = statement;
	_tmp22_ = sqlite3_column_int64 (_tmp21_, 1);
	_vala_timestamp = _tmp22_;
	_tmp23_ = statement;
	_tmp24_ = sqlite3_column_int64 (_tmp23_, 2);
	_vala_size = _tmp24_;
	_tmp25_ = statement;
	_tmp26_ = sqlite3_column_int (_tmp25_, 0);
	result = _tmp26_ == 1;
	_g_object_unref0 (cursor);
	values = (_vala_GValue_array_free (values, values_length1), NULL);
	_g_free0 (uri);
	if (timestamp) {
		*timestamp = _vala_timestamp;
	}
	if (size) {
		*size = _vala_size;
	}
	return result;
}


RygelMediaObjects* rygel_media_export_media_cache_get_children (RygelMediaExportMediaCache* self, RygelMediaContainer* container, glong offset, glong max_count, GError** error) {
	RygelMediaObjects* result = NULL;
	RygelMediaObjects* _tmp0_;
	RygelMediaObjects* children;
	RygelMediaContainer* _tmp1_;
	const gchar* _tmp2_;
	GValue _tmp3_ = {0};
	glong _tmp4_;
	GValue _tmp5_ = {0};
	glong _tmp6_;
	GValue _tmp7_ = {0};
	GValue* _tmp8_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	GValue* _tmp9_;
	gint _tmp9__length1;
	RygelMediaExportDatabaseCursor* _tmp10_ = NULL;
	RygelMediaExportDatabaseCursor* cursor;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (container != NULL, NULL);
	_tmp0_ = rygel_media_objects_new ();
	children = _tmp0_;
	_tmp1_ = container;
	_tmp2_ = ((RygelMediaObject*) _tmp1_)->id;
	g_value_init (&_tmp3_, G_TYPE_STRING);
	g_value_set_string (&_tmp3_, _tmp2_);
	_tmp4_ = offset;
	g_value_init (&_tmp5_, G_TYPE_LONG);
	g_value_set_long (&_tmp5_, _tmp4_);
	_tmp6_ = max_count;
	g_value_init (&_tmp7_, G_TYPE_LONG);
	g_value_set_long (&_tmp7_, _tmp6_);
	_tmp8_ = g_new0 (GValue, 3);
	_tmp8_[0] = _tmp3_;
	_tmp8_[1] = _tmp5_;
	_tmp8_[2] = _tmp7_;
	values = _tmp8_;
	values_length1 = 3;
	_values_size_ = values_length1;
	_tmp9_ = values;
	_tmp9__length1 = values_length1;
	_tmp10_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN, _tmp9_, _tmp9__length1, &_inner_error_);
	cursor = _tmp10_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		values = (_vala_GValue_array_free (values, values_length1), NULL);
		_g_object_unref0 (children);
		return NULL;
	}
	{
		RygelMediaExportDatabaseCursor* _tmp11_;
		RygelMediaExportDatabaseCursorIterator* _tmp12_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp11_ = cursor;
		_tmp12_ = rygel_media_export_database_cursor_iterator (_tmp11_);
		_statement_it = _tmp12_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp13_;
			gboolean _tmp14_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp15_;
			sqlite3_stmt* _tmp16_ = NULL;
			sqlite3_stmt* statement;
			RygelMediaObjects* _tmp17_;
			RygelMediaContainer* _tmp18_;
			sqlite3_stmt* _tmp19_;
			RygelMediaObject* _tmp20_ = NULL;
			RygelMediaObject* _tmp21_;
			RygelMediaObjects* _tmp22_;
			gpointer _tmp23_ = NULL;
			RygelMediaObject* _tmp24_;
			RygelMediaContainer* _tmp25_;
			_tmp13_ = _statement_it;
			_tmp14_ = rygel_media_export_database_cursor_iterator_next (_tmp13_);
			if (!_tmp14_) {
				break;
			}
			_tmp15_ = _statement_it;
			_tmp16_ = rygel_media_export_database_cursor_iterator_get (_tmp15_, &_inner_error_);
			statement = _tmp16_;
			if (_inner_error_ != NULL) {
				g_propagate_error (error, _inner_error_);
				_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
				_g_object_unref0 (cursor);
				values = (_vala_GValue_array_free (values, values_length1), NULL);
				_g_object_unref0 (children);
				return NULL;
			}
			_tmp17_ = children;
			_tmp18_ = container;
			_tmp19_ = statement;
			_tmp20_ = rygel_media_export_media_cache_get_object_from_statement (self, _tmp18_, _tmp19_);
			_tmp21_ = _tmp20_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp21_);
			_g_object_unref0 (_tmp21_);
			_tmp22_ = children;
			_tmp23_ = gee_abstract_list_last ((GeeAbstractList*) _tmp22_);
			_tmp24_ = (RygelMediaObject*) _tmp23_;
			_tmp25_ = container;
			rygel_media_object_set_parent_ref (_tmp24_, _tmp25_);
			_g_object_unref0 (_tmp24_);
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	result = children;
	_g_object_unref0 (cursor);
	values = (_vala_GValue_array_free (values, values_length1), NULL);
	return result;
}


RygelMediaObjects* rygel_media_export_media_cache_get_objects_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, guint offset, guint max_count, guint* total_matches, GError** error) {
	guint _vala_total_matches = 0U;
	RygelMediaObjects* result = NULL;
	GValueArray* _tmp0_;
	GValueArray* args;
	RygelSearchExpression* _tmp1_;
	GValueArray* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* filter;
	RygelSearchExpression* _tmp4_;
	guint _tmp20_;
	guint _tmp21_ = 0U;
	guint max_objects;
	const gchar* _tmp22_;
	GValueArray* _tmp23_;
	const gchar* _tmp24_;
	glong _tmp25_ = 0L;
	glong _tmp26_;
	const gchar* _tmp27_;
	GValueArray* _tmp28_;
	const gchar* _tmp29_;
	guint _tmp30_;
	guint _tmp31_;
	RygelMediaObjects* _tmp32_ = NULL;
	RygelMediaObjects* _tmp33_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_value_array_new ((guint) 0);
	args = _tmp0_;
	_tmp1_ = expression;
	_tmp2_ = args;
	_tmp3_ = rygel_media_export_media_cache_translate_search_expression (self, _tmp1_, _tmp2_, "WHERE", &_inner_error_);
	filter = _tmp3_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_value_array_free0 (args);
		return NULL;
	}
	_tmp4_ = expression;
	if (_tmp4_ != NULL) {
		RygelSearchExpression* _tmp5_;
		gchar* _tmp6_ = NULL;
		gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp5_ = expression;
		_tmp6_ = rygel_search_expression_to_string (_tmp5_);
		_tmp7_ = _tmp6_;
		g_debug ("rygel-media-export-media-cache.vala:214: Original search: %s", _tmp7_);
		_g_free0 (_tmp7_);
		_tmp8_ = filter;
		g_debug ("rygel-media-export-media-cache.vala:215: Parsed search expression: %s", _tmp8_);
	}
	{
		gint i;
		i = 0;
		{
			gboolean _tmp9_;
			_tmp9_ = TRUE;
			while (TRUE) {
				gboolean _tmp10_;
				gint _tmp12_;
				GValueArray* _tmp13_;
				guint _tmp14_;
				gint _tmp15_;
				GValueArray* _tmp16_;
				gint _tmp17_;
				GValue* _tmp18_ = NULL;
				const gchar* _tmp19_ = NULL;
				_tmp10_ = _tmp9_;
				if (!_tmp10_) {
					gint _tmp11_;
					_tmp11_ = i;
					i = _tmp11_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp12_ = i;
				_tmp13_ = args;
				_tmp14_ = _tmp13_->n_values;
				if (!(((guint) _tmp12_) < _tmp14_)) {
					break;
				}
				_tmp15_ = i;
				_tmp16_ = args;
				_tmp17_ = i;
				_tmp18_ = g_value_array_get_nth (_tmp16_, (guint) _tmp17_);
				_tmp19_ = g_value_get_string (_tmp18_);
				g_debug ("rygel-media-export-media-cache.vala:219: Arg %d: %s", _tmp15_, _tmp19_);
			}
		}
	}
	_tmp20_ = max_count;
	_tmp21_ = rygel_media_export_media_cache_modify_limit (self, _tmp20_);
	max_objects = _tmp21_;
	_tmp22_ = filter;
	_tmp23_ = args;
	_tmp24_ = container_id;
	_tmp25_ = rygel_media_export_media_cache_get_object_count_by_filter (self, _tmp22_, _tmp23_, _tmp24_, &_inner_error_);
	_tmp26_ = _tmp25_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (filter);
		_g_value_array_free0 (args);
		return NULL;
	}
	_vala_total_matches = (guint) _tmp26_;
	_tmp27_ = filter;
	_tmp28_ = args;
	_tmp29_ = container_id;
	_tmp30_ = offset;
	_tmp31_ = max_objects;
	_tmp32_ = rygel_media_export_media_cache_get_objects_by_filter (self, _tmp27_, _tmp28_, _tmp29_, (glong) _tmp30_, (glong) _tmp31_, &_inner_error_);
	_tmp33_ = _tmp32_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (filter);
		_g_value_array_free0 (args);
		return NULL;
	}
	result = _tmp33_;
	_g_free0 (filter);
	_g_value_array_free0 (args);
	if (total_matches) {
		*total_matches = _vala_total_matches;
	}
	return result;
}


glong rygel_media_export_media_cache_get_object_count_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, GError** error) {
	glong result = 0L;
	GValueArray* _tmp0_;
	GValueArray* args;
	RygelSearchExpression* _tmp1_;
	GValueArray* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* filter;
	RygelSearchExpression* _tmp4_;
	const gchar* _tmp20_;
	GValueArray* _tmp21_;
	const gchar* _tmp22_;
	glong _tmp23_ = 0L;
	glong _tmp24_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, 0L);
	_tmp0_ = g_value_array_new ((guint) 0);
	args = _tmp0_;
	_tmp1_ = expression;
	_tmp2_ = args;
	_tmp3_ = rygel_media_export_media_cache_translate_search_expression (self, _tmp1_, _tmp2_, "WHERE", &_inner_error_);
	filter = _tmp3_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_value_array_free0 (args);
		return 0L;
	}
	_tmp4_ = expression;
	if (_tmp4_ != NULL) {
		RygelSearchExpression* _tmp5_;
		gchar* _tmp6_ = NULL;
		gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp5_ = expression;
		_tmp6_ = rygel_search_expression_to_string (_tmp5_);
		_tmp7_ = _tmp6_;
		g_debug ("rygel-media-export-media-cache.vala:242: Original search: %s", _tmp7_);
		_g_free0 (_tmp7_);
		_tmp8_ = filter;
		g_debug ("rygel-media-export-media-cache.vala:243: Parsed search expression: %s", _tmp8_);
	}
	{
		gint i;
		i = 0;
		{
			gboolean _tmp9_;
			_tmp9_ = TRUE;
			while (TRUE) {
				gboolean _tmp10_;
				gint _tmp12_;
				GValueArray* _tmp13_;
				guint _tmp14_;
				gint _tmp15_;
				GValueArray* _tmp16_;
				gint _tmp17_;
				GValue* _tmp18_ = NULL;
				const gchar* _tmp19_ = NULL;
				_tmp10_ = _tmp9_;
				if (!_tmp10_) {
					gint _tmp11_;
					_tmp11_ = i;
					i = _tmp11_ + 1;
				}
				_tmp9_ = FALSE;
				_tmp12_ = i;
				_tmp13_ = args;
				_tmp14_ = _tmp13_->n_values;
				if (!(((guint) _tmp12_) < _tmp14_)) {
					break;
				}
				_tmp15_ = i;
				_tmp16_ = args;
				_tmp17_ = i;
				_tmp18_ = g_value_array_get_nth (_tmp16_, (guint) _tmp17_);
				_tmp19_ = g_value_get_string (_tmp18_);
				g_debug ("rygel-media-export-media-cache.vala:247: Arg %d: %s", _tmp15_, _tmp19_);
			}
		}
	}
	_tmp20_ = filter;
	_tmp21_ = args;
	_tmp22_ = container_id;
	_tmp23_ = rygel_media_export_media_cache_get_object_count_by_filter (self, _tmp20_, _tmp21_, _tmp22_, &_inner_error_);
	_tmp24_ = _tmp23_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (filter);
		_g_value_array_free0 (args);
		return 0L;
	}
	result = _tmp24_;
	_g_free0 (filter);
	_g_value_array_free0 (args);
	return result;
}


glong rygel_media_export_media_cache_get_object_count_by_filter (RygelMediaExportMediaCache* self, const gchar* filter, GValueArray* args, const gchar* container_id, GError** error) {
	glong result = 0L;
	const gchar* _tmp0_;
	GValueArray* _tmp5_;
	guint _tmp6_;
	const gchar* pattern = NULL;
	RygelMediaExportSQLString string_id = 0;
	const gchar* _tmp7_;
	RygelMediaExportSQLFactory* _tmp8_;
	RygelMediaExportSQLString _tmp9_;
	const gchar* _tmp10_ = NULL;
	RygelMediaExportDatabase* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_ = NULL;
	gchar* _tmp14_;
	GValueArray* _tmp15_;
	GValue* _tmp16_;
	gint _tmp16__length1;
	gint _tmp17_ = 0;
	gint _tmp18_;
	gint _tmp19_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, 0L);
	g_return_val_if_fail (filter != NULL, 0L);
	g_return_val_if_fail (args != NULL, 0L);
	_tmp0_ = container_id;
	if (_tmp0_ != NULL) {
		const gchar* _tmp1_;
		GValue _tmp2_ = {0};
		GValue v;
		GValueArray* _tmp3_;
		GValue _tmp4_;
		_tmp1_ = container_id;
		g_value_init (&_tmp2_, G_TYPE_STRING);
		g_value_set_string (&_tmp2_, _tmp1_);
		v = _tmp2_;
		_tmp3_ = args;
		_tmp4_ = v;
		g_value_array_prepend (_tmp3_, &_tmp4_);
		G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	}
	_tmp5_ = args;
	_tmp6_ = _tmp5_->n_values;
	g_debug ("rygel-media-export-media-cache.vala:265: Parameters to bind: %u", _tmp6_);
	_tmp7_ = container_id;
	if (_tmp7_ != NULL) {
		string_id = RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER_WITH_ANCESTOR;
	} else {
		string_id = RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECT_COUNT_BY_FILTER;
	}
	_tmp8_ = self->priv->sql;
	_tmp9_ = string_id;
	_tmp10_ = rygel_media_export_sql_factory_make (_tmp8_, _tmp9_);
	pattern = _tmp10_;
	_tmp11_ = self->priv->db;
	_tmp12_ = filter;
	_tmp13_ = g_strdup_printf (pattern, _tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = args;
	_tmp16_ = _tmp15_->values;
	_tmp16__length1 = (gint) _tmp15_->n_values;
	_tmp17_ = rygel_media_export_database_query_value (_tmp11_, _tmp14_, _tmp16_, _tmp16__length1, &_inner_error_);
	_tmp18_ = _tmp17_;
	_g_free0 (_tmp14_);
	_tmp19_ = _tmp18_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return 0L;
	}
	result = (glong) _tmp19_;
	return result;
}


RygelMediaObjects* rygel_media_export_media_cache_get_objects_by_filter (RygelMediaExportMediaCache* self, const gchar* filter, GValueArray* args, const gchar* container_id, glong offset, glong max_count, GError** error) {
	RygelMediaObjects* result = NULL;
	RygelMediaObjects* _tmp0_;
	RygelMediaObjects* children;
	glong _tmp1_;
	GValue _tmp2_ = {0};
	GValue v;
	GValueArray* _tmp3_;
	GValue _tmp4_;
	glong _tmp5_;
	GValue _tmp6_ = {0};
	GValueArray* _tmp7_;
	GValue _tmp8_;
	RygelMediaContainer* parent;
	GValueArray* _tmp9_;
	guint _tmp10_;
	const gchar* sql = NULL;
	const gchar* _tmp11_;
	RygelMediaExportDatabase* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_ = NULL;
	gchar* _tmp20_;
	GValueArray* _tmp21_;
	GValue* _tmp22_;
	gint _tmp22__length1;
	RygelMediaExportDatabaseCursor* _tmp23_ = NULL;
	RygelMediaExportDatabaseCursor* _tmp24_;
	RygelMediaExportDatabaseCursor* cursor;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (filter != NULL, NULL);
	g_return_val_if_fail (args != NULL, NULL);
	_tmp0_ = rygel_media_objects_new ();
	children = _tmp0_;
	_tmp1_ = offset;
	g_value_init (&_tmp2_, G_TYPE_LONG);
	g_value_set_long (&_tmp2_, _tmp1_);
	v = _tmp2_;
	_tmp3_ = args;
	_tmp4_ = v;
	g_value_array_append (_tmp3_, &_tmp4_);
	_tmp5_ = max_count;
	g_value_init (&_tmp6_, G_TYPE_LONG);
	g_value_set_long (&_tmp6_, _tmp5_);
	G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	v = _tmp6_;
	_tmp7_ = args;
	_tmp8_ = v;
	g_value_array_append (_tmp7_, &_tmp8_);
	parent = NULL;
	_tmp9_ = args;
	_tmp10_ = _tmp9_->n_values;
	g_debug ("rygel-media-export-media-cache.vala:292: Parameters to bind: %u", _tmp10_);
	_tmp11_ = container_id;
	if (_tmp11_ != NULL) {
		RygelMediaExportSQLFactory* _tmp12_;
		const gchar* _tmp13_ = NULL;
		_tmp12_ = self->priv->sql;
		_tmp13_ = rygel_media_export_sql_factory_make (_tmp12_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR);
		sql = _tmp13_;
	} else {
		RygelMediaExportSQLFactory* _tmp14_;
		const gchar* _tmp15_ = NULL;
		_tmp14_ = self->priv->sql;
		_tmp15_ = rygel_media_export_sql_factory_make (_tmp14_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER);
		sql = _tmp15_;
	}
	_tmp16_ = self->priv->db;
	_tmp17_ = sql;
	_tmp18_ = filter;
	_tmp19_ = g_strdup_printf (_tmp17_, _tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = args;
	_tmp22_ = _tmp21_->values;
	_tmp22__length1 = (gint) _tmp21_->n_values;
	_tmp23_ = rygel_media_export_database_exec_cursor (_tmp16_, _tmp20_, _tmp22_, _tmp22__length1, &_inner_error_);
	_tmp24_ = _tmp23_;
	_g_free0 (_tmp20_);
	cursor = _tmp24_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (parent);
		G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
		_g_object_unref0 (children);
		return NULL;
	}
	{
		RygelMediaExportDatabaseCursor* _tmp25_;
		RygelMediaExportDatabaseCursorIterator* _tmp26_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp25_ = cursor;
		_tmp26_ = rygel_media_export_database_cursor_iterator (_tmp25_);
		_statement_it = _tmp26_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp27_;
			gboolean _tmp28_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp29_;
			sqlite3_stmt* _tmp30_ = NULL;
			sqlite3_stmt* statement;
			sqlite3_stmt* _tmp31_;
			const gchar* _tmp32_ = NULL;
			const gchar* parent_id;
			gboolean _tmp33_ = FALSE;
			RygelMediaContainer* _tmp34_;
			gboolean _tmp38_;
			RygelMediaContainer* _tmp43_;
			_tmp27_ = _statement_it;
			_tmp28_ = rygel_media_export_database_cursor_iterator_next (_tmp27_);
			if (!_tmp28_) {
				break;
			}
			_tmp29_ = _statement_it;
			_tmp30_ = rygel_media_export_database_cursor_iterator_get (_tmp29_, &_inner_error_);
			statement = _tmp30_;
			if (_inner_error_ != NULL) {
				g_propagate_error (error, _inner_error_);
				_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
				_g_object_unref0 (cursor);
				_g_object_unref0 (parent);
				G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
				_g_object_unref0 (children);
				return NULL;
			}
			_tmp31_ = statement;
			_tmp32_ = sqlite3_column_text (_tmp31_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_PARENT);
			parent_id = _tmp32_;
			_tmp34_ = parent;
			if (_tmp34_ == NULL) {
				_tmp33_ = TRUE;
			} else {
				const gchar* _tmp35_;
				RygelMediaContainer* _tmp36_;
				const gchar* _tmp37_;
				_tmp35_ = parent_id;
				_tmp36_ = parent;
				_tmp37_ = ((RygelMediaObject*) _tmp36_)->id;
				_tmp33_ = g_strcmp0 (_tmp35_, _tmp37_) != 0;
			}
			_tmp38_ = _tmp33_;
			if (_tmp38_) {
				RygelNullContainer* _tmp39_;
				RygelMediaContainer* _tmp40_;
				const gchar* _tmp41_;
				gchar* _tmp42_;
				_tmp39_ = rygel_null_container_new ();
				_g_object_unref0 (parent);
				parent = (RygelMediaContainer*) _tmp39_;
				_tmp40_ = parent;
				_tmp41_ = parent_id;
				_tmp42_ = g_strdup (_tmp41_);
				_g_free0 (((RygelMediaObject*) _tmp40_)->id);
				((RygelMediaObject*) _tmp40_)->id = _tmp42_;
			}
			_tmp43_ = parent;
			if (_tmp43_ != NULL) {
				RygelMediaObjects* _tmp44_;
				RygelMediaContainer* _tmp45_;
				sqlite3_stmt* _tmp46_;
				RygelMediaObject* _tmp47_ = NULL;
				RygelMediaObject* _tmp48_;
				RygelMediaObjects* _tmp49_;
				gpointer _tmp50_ = NULL;
				RygelMediaObject* _tmp51_;
				RygelMediaContainer* _tmp52_;
				_tmp44_ = children;
				_tmp45_ = parent;
				_tmp46_ = statement;
				_tmp47_ = rygel_media_export_media_cache_get_object_from_statement (self, _tmp45_, _tmp46_);
				_tmp48_ = _tmp47_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp44_, _tmp48_);
				_g_object_unref0 (_tmp48_);
				_tmp49_ = children;
				_tmp50_ = gee_abstract_list_last ((GeeAbstractList*) _tmp49_);
				_tmp51_ = (RygelMediaObject*) _tmp50_;
				_tmp52_ = parent;
				rygel_media_object_set_parent_ref (_tmp51_, _tmp52_);
				_g_object_unref0 (_tmp51_);
			} else {
				sqlite3_stmt* _tmp53_;
				const gchar* _tmp54_ = NULL;
				const gchar* _tmp55_;
				_tmp53_ = statement;
				_tmp54_ = sqlite3_column_text (_tmp53_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID);
				_tmp55_ = parent_id;
				g_warning ("Inconsistent database: item %s " "has no parent %s", _tmp54_, _tmp55_);
			}
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	result = children;
	_g_object_unref0 (cursor);
	_g_object_unref0 (parent);
	G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	return result;
}


void rygel_media_export_media_cache_debug_statistics (RygelMediaExportMediaCache* self) {
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	{
		RygelMediaExportDatabaseCursor* _tmp0_ = NULL;
		RygelMediaExportDatabaseCursor* cursor;
		g_debug ("rygel-media-export-media-cache.vala:326: Database statistics:");
		_tmp0_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_STATISTICS, NULL, 0, &_inner_error_);
		cursor = _tmp0_;
		if (_inner_error_ != NULL) {
			goto __catch7_g_error;
		}
		{
			RygelMediaExportDatabaseCursor* _tmp1_;
			RygelMediaExportDatabaseCursorIterator* _tmp2_ = NULL;
			RygelMediaExportDatabaseCursorIterator* _statement_it;
			_tmp1_ = cursor;
			_tmp2_ = rygel_media_export_database_cursor_iterator (_tmp1_);
			_statement_it = _tmp2_;
			while (TRUE) {
				RygelMediaExportDatabaseCursorIterator* _tmp3_;
				gboolean _tmp4_ = FALSE;
				RygelMediaExportDatabaseCursorIterator* _tmp5_;
				sqlite3_stmt* _tmp6_ = NULL;
				sqlite3_stmt* statement;
				sqlite3_stmt* _tmp7_;
				const gchar* _tmp8_ = NULL;
				sqlite3_stmt* _tmp9_;
				gint _tmp10_ = 0;
				_tmp3_ = _statement_it;
				_tmp4_ = rygel_media_export_database_cursor_iterator_next (_tmp3_);
				if (!_tmp4_) {
					break;
				}
				_tmp5_ = _statement_it;
				_tmp6_ = rygel_media_export_database_cursor_iterator_get (_tmp5_, &_inner_error_);
				statement = _tmp6_;
				if (_inner_error_ != NULL) {
					_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
					_g_object_unref0 (cursor);
					goto __catch7_g_error;
				}
				_tmp7_ = statement;
				_tmp8_ = sqlite3_column_text (_tmp7_, 0);
				_tmp9_ = statement;
				_tmp10_ = sqlite3_column_int (_tmp9_, 1);
				g_debug ("rygel-media-export-media-cache.vala:329: %s: %d", _tmp8_, _tmp10_);
			}
			_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
		}
		_g_object_unref0 (cursor);
	}
	goto __finally7;
	__catch7_g_error:
	{
		GError* _error_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_g_error_free0 (_error_);
	}
	__finally7:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
}


GeeArrayList* rygel_media_export_media_cache_get_child_ids (RygelMediaExportMediaCache* self, const gchar* container_id, GError** error) {
	GeeArrayList* result = NULL;
	GEqualFunc _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* children;
	const gchar* _tmp2_;
	GValue _tmp3_ = {0};
	GValue* _tmp4_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	GValue* _tmp5_;
	gint _tmp5__length1;
	RygelMediaExportDatabaseCursor* _tmp6_ = NULL;
	RygelMediaExportDatabaseCursor* cursor;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (container_id != NULL, NULL);
	_tmp0_ = g_str_equal;
	_tmp1_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, _tmp0_);
	children = _tmp1_;
	_tmp2_ = container_id;
	g_value_init (&_tmp3_, G_TYPE_STRING);
	g_value_set_string (&_tmp3_, _tmp2_);
	_tmp4_ = g_new0 (GValue, 1);
	_tmp4_[0] = _tmp3_;
	values = _tmp4_;
	values_length1 = 1;
	_values_size_ = values_length1;
	_tmp5_ = values;
	_tmp5__length1 = values_length1;
	_tmp6_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_CHILD_IDS, _tmp5_, _tmp5__length1, &_inner_error_);
	cursor = _tmp6_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			_g_object_unref0 (children);
			return NULL;
		} else {
			values = (_vala_GValue_array_free (values, values_length1), NULL);
			_g_object_unref0 (children);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	{
		RygelMediaExportDatabaseCursor* _tmp7_;
		RygelMediaExportDatabaseCursorIterator* _tmp8_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp7_ = cursor;
		_tmp8_ = rygel_media_export_database_cursor_iterator (_tmp7_);
		_statement_it = _tmp8_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp9_;
			gboolean _tmp10_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp11_;
			sqlite3_stmt* _tmp12_ = NULL;
			sqlite3_stmt* statement;
			GeeArrayList* _tmp13_;
			sqlite3_stmt* _tmp14_;
			const gchar* _tmp15_ = NULL;
			_tmp9_ = _statement_it;
			_tmp10_ = rygel_media_export_database_cursor_iterator_next (_tmp9_);
			if (!_tmp10_) {
				break;
			}
			_tmp11_ = _statement_it;
			_tmp12_ = rygel_media_export_database_cursor_iterator_get (_tmp11_, &_inner_error_);
			statement = _tmp12_;
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
					g_propagate_error (error, _inner_error_);
					_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
					_g_object_unref0 (cursor);
					values = (_vala_GValue_array_free (values, values_length1), NULL);
					_g_object_unref0 (children);
					return NULL;
				} else {
					_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
					_g_object_unref0 (cursor);
					values = (_vala_GValue_array_free (values, values_length1), NULL);
					_g_object_unref0 (children);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return NULL;
				}
			}
			_tmp13_ = children;
			_tmp14_ = statement;
			_tmp15_ = sqlite3_column_text (_tmp14_, 0);
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp13_, _tmp15_);
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	result = children;
	_g_object_unref0 (cursor);
	values = (_vala_GValue_array_free (values, values_length1), NULL);
	return result;
}


GeeList* rygel_media_export_media_cache_get_meta_data_column_by_filter (RygelMediaExportMediaCache* self, const gchar* column, const gchar* filter, GValueArray* args, glong offset, glong max_count, GError** error) {
	GeeList* result = NULL;
	glong _tmp0_;
	GValue _tmp1_ = {0};
	GValue v;
	GValueArray* _tmp2_;
	GValue _tmp3_;
	glong _tmp4_;
	GValue _tmp5_ = {0};
	GValueArray* _tmp6_;
	GValue _tmp7_;
	GeeArrayList* _tmp8_;
	GeeArrayList* data;
	RygelMediaExportSQLFactory* _tmp9_;
	const gchar* _tmp10_ = NULL;
	const gchar* sql;
	RygelMediaExportDatabase* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	gchar* _tmp16_;
	GValueArray* _tmp17_;
	GValue* _tmp18_;
	gint _tmp18__length1;
	RygelMediaExportDatabaseCursor* _tmp19_ = NULL;
	RygelMediaExportDatabaseCursor* _tmp20_;
	RygelMediaExportDatabaseCursor* cursor;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (column != NULL, NULL);
	g_return_val_if_fail (filter != NULL, NULL);
	g_return_val_if_fail (args != NULL, NULL);
	_tmp0_ = offset;
	g_value_init (&_tmp1_, G_TYPE_LONG);
	g_value_set_long (&_tmp1_, _tmp0_);
	v = _tmp1_;
	_tmp2_ = args;
	_tmp3_ = v;
	g_value_array_append (_tmp2_, &_tmp3_);
	_tmp4_ = max_count;
	g_value_init (&_tmp5_, G_TYPE_LONG);
	g_value_set_long (&_tmp5_, _tmp4_);
	G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	v = _tmp5_;
	_tmp6_ = args;
	_tmp7_ = v;
	g_value_array_append (_tmp6_, &_tmp7_);
	_tmp8_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
	data = _tmp8_;
	_tmp9_ = self->priv->sql;
	_tmp10_ = rygel_media_export_sql_factory_make (_tmp9_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_META_DATA_COLUMN);
	sql = _tmp10_;
	_tmp11_ = self->priv->db;
	_tmp12_ = sql;
	_tmp13_ = column;
	_tmp14_ = filter;
	_tmp15_ = g_strdup_printf (_tmp12_, _tmp13_, _tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = args;
	_tmp18_ = _tmp17_->values;
	_tmp18__length1 = (gint) _tmp17_->n_values;
	_tmp19_ = rygel_media_export_database_exec_cursor (_tmp11_, _tmp16_, _tmp18_, _tmp18__length1, &_inner_error_);
	_tmp20_ = _tmp19_;
	_g_free0 (_tmp16_);
	cursor = _tmp20_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_object_unref0 (data);
		G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
		return NULL;
	}
	{
		RygelMediaExportDatabaseCursor* _tmp21_;
		RygelMediaExportDatabaseCursorIterator* _tmp22_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp21_ = cursor;
		_tmp22_ = rygel_media_export_database_cursor_iterator (_tmp21_);
		_statement_it = _tmp22_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp23_;
			gboolean _tmp24_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp25_;
			sqlite3_stmt* _tmp26_ = NULL;
			sqlite3_stmt* statement;
			GeeArrayList* _tmp27_;
			sqlite3_stmt* _tmp28_;
			const gchar* _tmp29_ = NULL;
			_tmp23_ = _statement_it;
			_tmp24_ = rygel_media_export_database_cursor_iterator_next (_tmp23_);
			if (!_tmp24_) {
				break;
			}
			_tmp25_ = _statement_it;
			_tmp26_ = rygel_media_export_database_cursor_iterator_get (_tmp25_, &_inner_error_);
			statement = _tmp26_;
			if (_inner_error_ != NULL) {
				g_propagate_error (error, _inner_error_);
				_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
				_g_object_unref0 (cursor);
				_g_object_unref0 (data);
				G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
				return NULL;
			}
			_tmp27_ = data;
			_tmp28_ = statement;
			_tmp29_ = sqlite3_column_text (_tmp28_, 0);
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp27_, _tmp29_);
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	result = (GeeList*) data;
	_g_object_unref0 (cursor);
	G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
	return result;
}


GeeList* rygel_media_export_media_cache_get_object_attribute_by_search_expression (RygelMediaExportMediaCache* self, const gchar* attribute, RygelSearchExpression* expression, glong offset, guint max_count, GError** error) {
	GeeList* result = NULL;
	GValueArray* _tmp0_;
	GValueArray* args;
	RygelSearchExpression* _tmp1_;
	GValueArray* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* filter;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_ = NULL;
	gchar* column;
	guint _tmp7_;
	guint _tmp8_ = 0U;
	guint max_objects;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	GValueArray* _tmp11_;
	glong _tmp12_;
	guint _tmp13_;
	GeeList* _tmp14_ = NULL;
	GeeList* _tmp15_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (attribute != NULL, NULL);
	_tmp0_ = g_value_array_new ((guint) 0);
	args = _tmp0_;
	_tmp1_ = expression;
	_tmp2_ = args;
	_tmp3_ = rygel_media_export_media_cache_translate_search_expression (self, _tmp1_, _tmp2_, "AND", &_inner_error_);
	filter = _tmp3_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_value_array_free0 (args);
		return NULL;
	}
	_tmp4_ = filter;
	g_debug ("rygel-media-export-media-cache.vala:384: Parsed filter: %s", _tmp4_);
	_tmp5_ = attribute;
	_tmp6_ = rygel_media_export_media_cache_map_operand_to_column (self, _tmp5_, NULL, &_inner_error_);
	column = _tmp6_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (filter);
		_g_value_array_free0 (args);
		return NULL;
	}
	_tmp7_ = max_count;
	_tmp8_ = rygel_media_export_media_cache_modify_limit (self, _tmp7_);
	max_objects = _tmp8_;
	_tmp9_ = column;
	_tmp10_ = filter;
	_tmp11_ = args;
	_tmp12_ = offset;
	_tmp13_ = max_objects;
	_tmp14_ = rygel_media_export_media_cache_get_meta_data_column_by_filter (self, _tmp9_, _tmp10_, _tmp11_, _tmp12_, (glong) _tmp13_, &_inner_error_);
	_tmp15_ = _tmp14_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (column);
		_g_free0 (filter);
		_g_value_array_free0 (args);
		return NULL;
	}
	result = _tmp15_;
	_g_free0 (column);
	_g_free0 (filter);
	_g_value_array_free0 (args);
	return result;
}


void rygel_media_export_media_cache_flag_object (RygelMediaExportMediaCache* self, GFile* file, const gchar* flag, GError** error) {
	const gchar* _tmp0_;
	GValue _tmp1_ = {0};
	GFile* _tmp2_;
	gchar* _tmp3_ = NULL;
	GValue _tmp4_ = {0};
	GValue* _tmp5_ = NULL;
	GValue* args;
	gint args_length1;
	gint _args_size_;
	RygelMediaExportDatabase* _tmp6_;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	g_return_if_fail (flag != NULL);
	_tmp0_ = flag;
	g_value_init (&_tmp1_, G_TYPE_STRING);
	g_value_set_string (&_tmp1_, _tmp0_);
	_tmp2_ = file;
	_tmp3_ = g_file_get_uri (_tmp2_);
	g_value_init (&_tmp4_, G_TYPE_STRING);
	g_value_take_string (&_tmp4_, _tmp3_);
	_tmp5_ = g_new0 (GValue, 2);
	_tmp5_[0] = _tmp1_;
	_tmp5_[1] = _tmp4_;
	args = _tmp5_;
	args_length1 = 2;
	_args_size_ = args_length1;
	_tmp6_ = self->priv->db;
	rygel_media_export_database_exec (_tmp6_, "UPDATE Object SET flags = ? WHERE uri = ?", args, args_length1, &_inner_error_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		args = (_vala_GValue_array_free (args, args_length1), NULL);
		return;
	}
	args = (_vala_GValue_array_free (args, args_length1), NULL);
}


GeeList* rygel_media_export_media_cache_get_flagged_uris (RygelMediaExportMediaCache* self, const gchar* flag, GError** error) {
	GeeList* result = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* uris;
	static const char query[] = "SELECT uri FROM object WHERE flags = ?";
	const gchar* _tmp1_;
	GValue _tmp2_ = {0};
	GValue* _tmp3_ = NULL;
	GValue* args;
	gint args_length1;
	gint _args_size_;
	RygelMediaExportDatabase* _tmp4_;
	GValue* _tmp5_;
	gint _tmp5__length1;
	RygelMediaExportDatabaseCursor* _tmp6_ = NULL;
	RygelMediaExportDatabaseCursor* cursor;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (flag != NULL, NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, NULL);
	uris = _tmp0_;
	_tmp1_ = flag;
	g_value_init (&_tmp2_, G_TYPE_STRING);
	g_value_set_string (&_tmp2_, _tmp1_);
	_tmp3_ = g_new0 (GValue, 1);
	_tmp3_[0] = _tmp2_;
	args = _tmp3_;
	args_length1 = 1;
	_args_size_ = args_length1;
	_tmp4_ = self->priv->db;
	_tmp5_ = args;
	_tmp5__length1 = args_length1;
	_tmp6_ = rygel_media_export_database_exec_cursor (_tmp4_, query, _tmp5_, _tmp5__length1, &_inner_error_);
	cursor = _tmp6_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		args = (_vala_GValue_array_free (args, args_length1), NULL);
		_g_object_unref0 (uris);
		return NULL;
	}
	{
		RygelMediaExportDatabaseCursor* _tmp7_;
		RygelMediaExportDatabaseCursorIterator* _tmp8_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp7_ = cursor;
		_tmp8_ = rygel_media_export_database_cursor_iterator (_tmp7_);
		_statement_it = _tmp8_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp9_;
			gboolean _tmp10_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp11_;
			sqlite3_stmt* _tmp12_ = NULL;
			sqlite3_stmt* statement;
			GeeArrayList* _tmp13_;
			sqlite3_stmt* _tmp14_;
			const gchar* _tmp15_ = NULL;
			_tmp9_ = _statement_it;
			_tmp10_ = rygel_media_export_database_cursor_iterator_next (_tmp9_);
			if (!_tmp10_) {
				break;
			}
			_tmp11_ = _statement_it;
			_tmp12_ = rygel_media_export_database_cursor_iterator_get (_tmp11_, &_inner_error_);
			statement = _tmp12_;
			if (_inner_error_ != NULL) {
				g_propagate_error (error, _inner_error_);
				_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
				_g_object_unref0 (cursor);
				args = (_vala_GValue_array_free (args, args_length1), NULL);
				_g_object_unref0 (uris);
				return NULL;
			}
			_tmp13_ = uris;
			_tmp14_ = statement;
			_tmp15_ = sqlite3_column_text (_tmp14_, 0);
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp13_, _tmp15_);
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	result = (GeeList*) uris;
	_g_object_unref0 (cursor);
	args = (_vala_GValue_array_free (args, args_length1), NULL);
	return result;
}


static void rygel_media_export_media_cache_get_exists_cache (RygelMediaExportMediaCache* self, GError** error) {
	GeeHashMap* _tmp0_;
	RygelMediaExportDatabaseCursor* _tmp1_ = NULL;
	RygelMediaExportDatabaseCursor* cursor;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, RYGEL_MEDIA_EXPORT_TYPE_EXISTS_CACHE_ENTRY, (GBoxedCopyFunc) rygel_media_export_exists_cache_entry_dup, rygel_media_export_exists_cache_entry_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->exists_cache);
	self->priv->exists_cache = _tmp0_;
	_tmp1_ = rygel_media_export_media_cache_exec_cursor (self, RYGEL_MEDIA_EXPORT_SQL_STRING_EXISTS_CACHE, NULL, 0, &_inner_error_);
	cursor = _tmp1_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return;
		}
	}
	{
		RygelMediaExportDatabaseCursor* _tmp2_;
		RygelMediaExportDatabaseCursorIterator* _tmp3_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp2_ = cursor;
		_tmp3_ = rygel_media_export_database_cursor_iterator (_tmp2_);
		_statement_it = _tmp3_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp4_;
			gboolean _tmp5_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp6_;
			sqlite3_stmt* _tmp7_ = NULL;
			sqlite3_stmt* statement;
			RygelMediaExportExistsCacheEntry entry = {0};
			sqlite3_stmt* _tmp8_;
			gint64 _tmp9_ = 0LL;
			sqlite3_stmt* _tmp10_;
			gint64 _tmp11_ = 0LL;
			GeeHashMap* _tmp12_;
			sqlite3_stmt* _tmp13_;
			const gchar* _tmp14_ = NULL;
			RygelMediaExportExistsCacheEntry _tmp15_;
			_tmp4_ = _statement_it;
			_tmp5_ = rygel_media_export_database_cursor_iterator_next (_tmp4_);
			if (!_tmp5_) {
				break;
			}
			_tmp6_ = _statement_it;
			_tmp7_ = rygel_media_export_database_cursor_iterator_get (_tmp6_, &_inner_error_);
			statement = _tmp7_;
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
					g_propagate_error (error, _inner_error_);
					_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
					_g_object_unref0 (cursor);
					return;
				} else {
					_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
					_g_object_unref0 (cursor);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return;
				}
			}
			memset (&entry, 0, sizeof (RygelMediaExportExistsCacheEntry));
			_tmp8_ = statement;
			_tmp9_ = sqlite3_column_int64 (_tmp8_, 1);
			entry.mtime = _tmp9_;
			_tmp10_ = statement;
			_tmp11_ = sqlite3_column_int64 (_tmp10_, 0);
			entry.size = _tmp11_;
			_tmp12_ = self->priv->exists_cache;
			_tmp13_ = statement;
			_tmp14_ = sqlite3_column_text (_tmp13_, 2);
			_tmp15_ = entry;
			gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, _tmp14_, &_tmp15_);
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	_g_object_unref0 (cursor);
}


static guint rygel_media_export_media_cache_modify_limit (RygelMediaExportMediaCache* self, guint max_count) {
	guint result = 0U;
	guint _tmp0_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = max_count;
	if (_tmp0_ == ((guint) 0)) {
		result = (guint) (-1);
		return result;
	} else {
		guint _tmp1_;
		_tmp1_ = max_count;
		result = _tmp1_;
		return result;
	}
}


static void rygel_media_export_media_cache_open_db (RygelMediaExportMediaCache* self, const gchar* name, GError** error) {
	const gchar* _tmp0_;
	RygelMediaExportDatabase* _tmp1_;
	RygelMediaExportDatabase* _tmp2_;
	gint old_version;
	gint _tmp3_ = 0;
	gint current_version;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (name != NULL);
	_tmp0_ = name;
	_tmp1_ = rygel_media_export_database_new (_tmp0_, &_inner_error_);
	_tmp2_ = _tmp1_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return;
	}
	_g_object_unref0 (self->priv->db);
	self->priv->db = _tmp2_;
	old_version = -1;
	_tmp3_ = atoi (RYGEL_MEDIA_EXPORT_SQL_FACTORY_schema_version);
	current_version = _tmp3_;
	{
		RygelMediaExportDatabase* _tmp4_;
		RygelMediaExportSQLFactory* _tmp5_;
		RygelMediaExportMediaCacheUpgrader* _tmp6_;
		RygelMediaExportMediaCacheUpgrader* upgrader;
		RygelMediaExportMediaCacheUpgrader* _tmp7_;
		gint _tmp8_ = 0;
		gboolean _tmp9_ = FALSE;
		gboolean _tmp10_;
		RygelMediaExportMediaCacheUpgrader* _tmp19_;
		_tmp4_ = self->priv->db;
		_tmp5_ = self->priv->sql;
		_tmp6_ = rygel_media_export_media_cache_upgrader_new (_tmp4_, _tmp5_);
		upgrader = _tmp6_;
		_tmp7_ = upgrader;
		_tmp9_ = rygel_media_export_media_cache_upgrader_needs_upgrade (_tmp7_, &_tmp8_, &_inner_error_);
		old_version = _tmp8_;
		_tmp10_ = _tmp9_;
		if (_inner_error_ != NULL) {
			_rygel_media_export_media_cache_upgrader_unref0 (upgrader);
			if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
				goto __catch8_rygel_media_export_database_error;
			}
			goto __finally8;
		}
		if (_tmp10_) {
			RygelMediaExportMediaCacheUpgrader* _tmp11_;
			gint _tmp12_;
			_tmp11_ = upgrader;
			_tmp12_ = old_version;
			rygel_media_export_media_cache_upgrader_upgrade (_tmp11_, _tmp12_);
		} else {
			gint _tmp13_;
			gint _tmp14_;
			_tmp13_ = old_version;
			_tmp14_ = current_version;
			if (_tmp13_ == _tmp14_) {
				RygelMediaExportMediaCacheUpgrader* _tmp15_;
				_tmp15_ = upgrader;
				rygel_media_export_media_cache_upgrader_fix_schema (_tmp15_, &_inner_error_);
				if (_inner_error_ != NULL) {
					_rygel_media_export_media_cache_upgrader_unref0 (upgrader);
					if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
						goto __catch8_rygel_media_export_database_error;
					}
					goto __finally8;
				}
			} else {
				gint _tmp16_;
				gint _tmp17_;
				GError* _tmp18_;
				_tmp16_ = old_version;
				_tmp17_ = current_version;
				g_warning ("The version \"%d\" of the detected database" " is newer than our supported version \"%d\"", _tmp16_, _tmp17_);
				_g_object_unref0 (self->priv->db);
				self->priv->db = NULL;
				_tmp18_ = g_error_new_literal (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_GENERAL_ERROR, "Database format" " not supported");
				_inner_error_ = _tmp18_;
				_rygel_media_export_media_cache_upgrader_unref0 (upgrader);
				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
					goto __catch8_rygel_media_export_database_error;
				}
				goto __finally8;
			}
		}
		_tmp19_ = upgrader;
		rygel_media_export_media_cache_upgrader_ensure_indices (_tmp19_);
		_rygel_media_export_media_cache_upgrader_unref0 (upgrader);
	}
	goto __finally8;
	__catch8_rygel_media_export_database_error:
	{
		GError* _error_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		g_debug ("rygel-media-export-media-cache.vala:458: %s", "Could not find schema version;" " checking for empty database...");
		{
			RygelMediaExportDatabase* _tmp20_;
			gint _tmp21_ = 0;
			gint rows;
			gint _tmp22_;
			_tmp20_ = self->priv->db;
			_tmp21_ = rygel_media_export_database_query_value (_tmp20_, "SELECT count(type) FROM " "sqlite_master WHERE rowid=1", NULL, 0, &_inner_error_);
			rows = _tmp21_;
			if (_inner_error_ != NULL) {
				if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
					goto __catch9_rygel_media_export_database_error;
				}
				_g_error_free0 (_error_);
				g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
				g_clear_error (&_inner_error_);
				return;
			}
			_tmp22_ = rows;
			if (_tmp22_ == 0) {
				gboolean _tmp23_ = FALSE;
				g_debug ("rygel-media-export-media-cache.vala:464: Empty database, creating new " \
"schema version %s", RYGEL_MEDIA_EXPORT_SQL_FACTORY_schema_version);
				_tmp23_ = rygel_media_export_media_cache_create_schema (self);
				if (!_tmp23_) {
					_g_object_unref0 (self->priv->db);
					self->priv->db = NULL;
					_g_error_free0 (_error_);
					return;
				}
			} else {
				g_warning ("rygel-media-export-media-cache.vala:472: Incompatible schema... cannot" \
" proceed");
				_g_object_unref0 (self->priv->db);
				self->priv->db = NULL;
				_g_error_free0 (_error_);
				return;
			}
		}
		goto __finally9;
		__catch9_rygel_media_export_database_error:
		{
			GError* _error_ = NULL;
			GError* _tmp24_;
			const gchar* _tmp25_;
			GError* _tmp26_;
			_error_ = _inner_error_;
			_inner_error_ = NULL;
			_tmp24_ = _error_;
			_tmp25_ = _tmp24_->message;
			g_warning ("rygel-media-export-media-cache.vala:478: Something weird going on: %s", _tmp25_);
			_g_object_unref0 (self->priv->db);
			self->priv->db = NULL;
			_tmp26_ = g_error_new_literal (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_GENERAL_ERROR, "Invalid database");
			_inner_error_ = _tmp26_;
			_g_error_free0 (_error_);
			goto __finally9;
		}
		__finally9:
		if (_inner_error_ != NULL) {
			_g_error_free0 (_error_);
			goto __finally8;
		}
		_g_error_free0 (_error_);
	}
	__finally8:
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return;
	}
}


static void rygel_media_export_media_cache_save_metadata (RygelMediaExportMediaCache* self, RygelMediaItem* item, GError** error) {
	RygelMediaItem* _tmp0_;
	gint64 _tmp1_;
	gint64 _tmp2_;
	GValue _tmp3_ = {0};
	RygelMediaItem* _tmp4_;
	const gchar* _tmp5_;
	GValue _tmp6_ = {0};
	GValue _tmp7_ = {0};
	GValue _tmp8_ = {0};
	RygelMediaItem* _tmp9_;
	const gchar* _tmp10_;
	GValue _tmp11_ = {0};
	GValue _tmp12_ = {0};
	GValue _tmp13_ = {0};
	RygelMediaItem* _tmp14_;
	const gchar* _tmp15_;
	GValue _tmp16_ = {0};
	GValue _tmp17_ = {0};
	GValue _tmp18_ = {0};
	GValue _tmp19_ = {0};
	GValue _tmp20_ = {0};
	GValue _tmp21_ = {0};
	GValue _tmp22_ = {0};
	GValue _tmp23_ = {0};
	RygelMediaItem* _tmp24_;
	const gchar* _tmp25_;
	GValue _tmp26_ = {0};
	RygelMediaItem* _tmp27_;
	const gchar* _tmp28_;
	GValue _tmp29_ = {0};
	GValue _tmp30_ = {0};
	GValue* _tmp31_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	RygelMediaItem* _tmp32_;
	RygelMediaItem* _tmp83_;
	RygelMediaExportDatabase* _tmp112_;
	RygelMediaExportSQLFactory* _tmp113_;
	const gchar* _tmp114_ = NULL;
	GValue* _tmp115_;
	gint _tmp115__length1;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = item;
	_tmp1_ = rygel_media_item_get_size (_tmp0_);
	_tmp2_ = _tmp1_;
	g_value_init (&_tmp3_, G_TYPE_INT64);
	g_value_set_int64 (&_tmp3_, _tmp2_);
	_tmp4_ = item;
	_tmp5_ = _tmp4_->mime_type;
	g_value_init (&_tmp6_, G_TYPE_STRING);
	g_value_set_string (&_tmp6_, _tmp5_);
	g_value_init (&_tmp7_, G_TYPE_INT);
	g_value_set_int (&_tmp7_, -1);
	g_value_init (&_tmp8_, G_TYPE_INT);
	g_value_set_int (&_tmp8_, -1);
	_tmp9_ = item;
	_tmp10_ = ((RygelMediaObject*) _tmp9_)->upnp_class;
	g_value_init (&_tmp11_, G_TYPE_STRING);
	g_value_set_string (&_tmp11_, _tmp10_);
	rygel_media_export_database_null (&_tmp12_);
	rygel_media_export_database_null (&_tmp13_);
	_tmp14_ = item;
	_tmp15_ = _tmp14_->date;
	g_value_init (&_tmp16_, G_TYPE_STRING);
	g_value_set_string (&_tmp16_, _tmp15_);
	g_value_init (&_tmp17_, G_TYPE_INT);
	g_value_set_int (&_tmp17_, -1);
	g_value_init (&_tmp18_, G_TYPE_INT);
	g_value_set_int (&_tmp18_, -1);
	g_value_init (&_tmp19_, G_TYPE_INT);
	g_value_set_int (&_tmp19_, -1);
	g_value_init (&_tmp20_, G_TYPE_INT);
	g_value_set_int (&_tmp20_, -1);
	g_value_init (&_tmp21_, G_TYPE_INT);
	g_value_set_int (&_tmp21_, -1);
	g_value_init (&_tmp22_, G_TYPE_INT);
	g_value_set_int (&_tmp22_, -1);
	g_value_init (&_tmp23_, G_TYPE_INT);
	g_value_set_int (&_tmp23_, -1);
	_tmp24_ = item;
	_tmp25_ = ((RygelMediaObject*) _tmp24_)->id;
	g_value_init (&_tmp26_, G_TYPE_STRING);
	g_value_set_string (&_tmp26_, _tmp25_);
	_tmp27_ = item;
	_tmp28_ = _tmp27_->dlna_profile;
	g_value_init (&_tmp29_, G_TYPE_STRING);
	g_value_set_string (&_tmp29_, _tmp28_);
	rygel_media_export_database_null (&_tmp30_);
	_tmp31_ = g_new0 (GValue, 18);
	_tmp31_[0] = _tmp3_;
	_tmp31_[1] = _tmp6_;
	_tmp31_[2] = _tmp7_;
	_tmp31_[3] = _tmp8_;
	_tmp31_[4] = _tmp11_;
	_tmp31_[5] = _tmp12_;
	_tmp31_[6] = _tmp13_;
	_tmp31_[7] = _tmp16_;
	_tmp31_[8] = _tmp17_;
	_tmp31_[9] = _tmp18_;
	_tmp31_[10] = _tmp19_;
	_tmp31_[11] = _tmp20_;
	_tmp31_[12] = _tmp21_;
	_tmp31_[13] = _tmp22_;
	_tmp31_[14] = _tmp23_;
	_tmp31_[15] = _tmp26_;
	_tmp31_[16] = _tmp29_;
	_tmp31_[17] = _tmp30_;
	values = _tmp31_;
	values_length1 = 18;
	_values_size_ = values_length1;
	_tmp32_ = item;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp32_, RYGEL_TYPE_AUDIO_ITEM)) {
		RygelMediaItem* _tmp33_;
		RygelAudioItem* _tmp34_;
		RygelAudioItem* audio_item;
		GValue* _tmp35_;
		gint _tmp35__length1;
		RygelAudioItem* _tmp36_;
		glong _tmp37_;
		GValue _tmp38_ = {0};
		GValue _tmp39_;
		GValue* _tmp40_;
		gint _tmp40__length1;
		RygelAudioItem* _tmp41_;
		gint _tmp42_;
		GValue _tmp43_ = {0};
		GValue _tmp44_;
		GValue* _tmp45_;
		gint _tmp45__length1;
		RygelAudioItem* _tmp46_;
		gint _tmp47_;
		GValue _tmp48_ = {0};
		GValue _tmp49_;
		GValue* _tmp50_;
		gint _tmp50__length1;
		RygelAudioItem* _tmp51_;
		gint _tmp52_;
		GValue _tmp53_ = {0};
		GValue _tmp54_;
		GValue* _tmp55_;
		gint _tmp55__length1;
		RygelAudioItem* _tmp56_;
		gint _tmp57_;
		GValue _tmp58_ = {0};
		GValue _tmp59_;
		RygelMediaItem* _tmp60_;
		_tmp33_ = item;
		_tmp34_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp33_, RYGEL_TYPE_AUDIO_ITEM) ? ((RygelAudioItem*) _tmp33_) : NULL);
		audio_item = _tmp34_;
		_tmp35_ = values;
		_tmp35__length1 = values_length1;
		_tmp36_ = audio_item;
		_tmp37_ = _tmp36_->duration;
		g_value_init (&_tmp38_, G_TYPE_LONG);
		g_value_set_long (&_tmp38_, _tmp37_);
		G_IS_VALUE (&_tmp35_[14]) ? (g_value_unset (&_tmp35_[14]), NULL) : NULL;
		_tmp35_[14] = _tmp38_;
		_tmp39_ = _tmp35_[14];
		_tmp40_ = values;
		_tmp40__length1 = values_length1;
		_tmp41_ = audio_item;
		_tmp42_ = _tmp41_->bitrate;
		g_value_init (&_tmp43_, G_TYPE_INT);
		g_value_set_int (&_tmp43_, _tmp42_);
		G_IS_VALUE (&_tmp40_[8]) ? (g_value_unset (&_tmp40_[8]), NULL) : NULL;
		_tmp40_[8] = _tmp43_;
		_tmp44_ = _tmp40_[8];
		_tmp45_ = values;
		_tmp45__length1 = values_length1;
		_tmp46_ = audio_item;
		_tmp47_ = _tmp46_->sample_freq;
		g_value_init (&_tmp48_, G_TYPE_INT);
		g_value_set_int (&_tmp48_, _tmp47_);
		G_IS_VALUE (&_tmp45_[9]) ? (g_value_unset (&_tmp45_[9]), NULL) : NULL;
		_tmp45_[9] = _tmp48_;
		_tmp49_ = _tmp45_[9];
		_tmp50_ = values;
		_tmp50__length1 = values_length1;
		_tmp51_ = audio_item;
		_tmp52_ = _tmp51_->bits_per_sample;
		g_value_init (&_tmp53_, G_TYPE_INT);
		g_value_set_int (&_tmp53_, _tmp52_);
		G_IS_VALUE (&_tmp50_[10]) ? (g_value_unset (&_tmp50_[10]), NULL) : NULL;
		_tmp50_[10] = _tmp53_;
		_tmp54_ = _tmp50_[10];
		_tmp55_ = values;
		_tmp55__length1 = values_length1;
		_tmp56_ = audio_item;
		_tmp57_ = _tmp56_->channels;
		g_value_init (&_tmp58_, G_TYPE_INT);
		g_value_set_int (&_tmp58_, _tmp57_);
		G_IS_VALUE (&_tmp55_[11]) ? (g_value_unset (&_tmp55_[11]), NULL) : NULL;
		_tmp55_[11] = _tmp58_;
		_tmp59_ = _tmp55_[11];
		_tmp60_ = item;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp60_, RYGEL_TYPE_MUSIC_ITEM)) {
			RygelMediaItem* _tmp61_;
			RygelMusicItem* _tmp62_;
			RygelMusicItem* music_item;
			GValue* _tmp63_;
			gint _tmp63__length1;
			RygelMusicItem* _tmp64_;
			const gchar* _tmp65_;
			GValue _tmp66_ = {0};
			GValue _tmp67_;
			GValue* _tmp68_;
			gint _tmp68__length1;
			RygelMusicItem* _tmp69_;
			const gchar* _tmp70_;
			GValue _tmp71_ = {0};
			GValue _tmp72_;
			GValue* _tmp73_;
			gint _tmp73__length1;
			RygelMusicItem* _tmp74_;
			const gchar* _tmp75_;
			GValue _tmp76_ = {0};
			GValue _tmp77_;
			GValue* _tmp78_;
			gint _tmp78__length1;
			RygelMusicItem* _tmp79_;
			gint _tmp80_;
			GValue _tmp81_ = {0};
			GValue _tmp82_;
			_tmp61_ = item;
			_tmp62_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp61_, RYGEL_TYPE_MUSIC_ITEM) ? ((RygelMusicItem*) _tmp61_) : NULL);
			music_item = _tmp62_;
			_tmp63_ = values;
			_tmp63__length1 = values_length1;
			_tmp64_ = music_item;
			_tmp65_ = _tmp64_->artist;
			g_value_init (&_tmp66_, G_TYPE_STRING);
			g_value_set_string (&_tmp66_, _tmp65_);
			G_IS_VALUE (&_tmp63_[5]) ? (g_value_unset (&_tmp63_[5]), NULL) : NULL;
			_tmp63_[5] = _tmp66_;
			_tmp67_ = _tmp63_[5];
			_tmp68_ = values;
			_tmp68__length1 = values_length1;
			_tmp69_ = music_item;
			_tmp70_ = _tmp69_->album;
			g_value_init (&_tmp71_, G_TYPE_STRING);
			g_value_set_string (&_tmp71_, _tmp70_);
			G_IS_VALUE (&_tmp68_[6]) ? (g_value_unset (&_tmp68_[6]), NULL) : NULL;
			_tmp68_[6] = _tmp71_;
			_tmp72_ = _tmp68_[6];
			_tmp73_ = values;
			_tmp73__length1 = values_length1;
			_tmp74_ = music_item;
			_tmp75_ = _tmp74_->genre;
			g_value_init (&_tmp76_, G_TYPE_STRING);
			g_value_set_string (&_tmp76_, _tmp75_);
			G_IS_VALUE (&_tmp73_[17]) ? (g_value_unset (&_tmp73_[17]), NULL) : NULL;
			_tmp73_[17] = _tmp76_;
			_tmp77_ = _tmp73_[17];
			_tmp78_ = values;
			_tmp78__length1 = values_length1;
			_tmp79_ = music_item;
			_tmp80_ = _tmp79_->track_number;
			g_value_init (&_tmp81_, G_TYPE_INT);
			g_value_set_int (&_tmp81_, _tmp80_);
			G_IS_VALUE (&_tmp78_[12]) ? (g_value_unset (&_tmp78_[12]), NULL) : NULL;
			_tmp78_[12] = _tmp81_;
			_tmp82_ = _tmp78_[12];
			_g_object_unref0 (music_item);
		}
		_g_object_unref0 (audio_item);
	}
	_tmp83_ = item;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp83_, RYGEL_TYPE_VISUAL_ITEM)) {
		RygelMediaItem* _tmp84_;
		RygelVisualItem* _tmp85_;
		RygelVisualItem* visual_item;
		GValue* _tmp86_;
		gint _tmp86__length1;
		RygelVisualItem* _tmp87_;
		gint _tmp88_;
		gint _tmp89_;
		GValue _tmp90_ = {0};
		GValue _tmp91_;
		GValue* _tmp92_;
		gint _tmp92__length1;
		RygelVisualItem* _tmp93_;
		gint _tmp94_;
		gint _tmp95_;
		GValue _tmp96_ = {0};
		GValue _tmp97_;
		GValue* _tmp98_;
		gint _tmp98__length1;
		RygelVisualItem* _tmp99_;
		gint _tmp100_;
		gint _tmp101_;
		GValue _tmp102_ = {0};
		GValue _tmp103_;
		RygelMediaItem* _tmp104_;
		_tmp84_ = item;
		_tmp85_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp84_, RYGEL_TYPE_VISUAL_ITEM) ? ((RygelVisualItem*) _tmp84_) : NULL);
		visual_item = _tmp85_;
		_tmp86_ = values;
		_tmp86__length1 = values_length1;
		_tmp87_ = visual_item;
		_tmp88_ = rygel_visual_item_get_width (_tmp87_);
		_tmp89_ = _tmp88_;
		g_value_init (&_tmp90_, G_TYPE_INT);
		g_value_set_int (&_tmp90_, _tmp89_);
		G_IS_VALUE (&_tmp86_[2]) ? (g_value_unset (&_tmp86_[2]), NULL) : NULL;
		_tmp86_[2] = _tmp90_;
		_tmp91_ = _tmp86_[2];
		_tmp92_ = values;
		_tmp92__length1 = values_length1;
		_tmp93_ = visual_item;
		_tmp94_ = rygel_visual_item_get_height (_tmp93_);
		_tmp95_ = _tmp94_;
		g_value_init (&_tmp96_, G_TYPE_INT);
		g_value_set_int (&_tmp96_, _tmp95_);
		G_IS_VALUE (&_tmp92_[3]) ? (g_value_unset (&_tmp92_[3]), NULL) : NULL;
		_tmp92_[3] = _tmp96_;
		_tmp97_ = _tmp92_[3];
		_tmp98_ = values;
		_tmp98__length1 = values_length1;
		_tmp99_ = visual_item;
		_tmp100_ = rygel_visual_item_get_color_depth (_tmp99_);
		_tmp101_ = _tmp100_;
		g_value_init (&_tmp102_, G_TYPE_INT);
		g_value_set_int (&_tmp102_, _tmp101_);
		G_IS_VALUE (&_tmp98_[13]) ? (g_value_unset (&_tmp98_[13]), NULL) : NULL;
		_tmp98_[13] = _tmp102_;
		_tmp103_ = _tmp98_[13];
		_tmp104_ = item;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp104_, RYGEL_TYPE_VIDEO_ITEM)) {
			RygelMediaItem* _tmp105_;
			RygelVideoItem* _tmp106_;
			RygelVideoItem* video_item;
			GValue* _tmp107_;
			gint _tmp107__length1;
			RygelVideoItem* _tmp108_;
			const gchar* _tmp109_;
			GValue _tmp110_ = {0};
			GValue _tmp111_;
			_tmp105_ = item;
			_tmp106_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp105_, RYGEL_TYPE_VIDEO_ITEM) ? ((RygelVideoItem*) _tmp105_) : NULL);
			video_item = _tmp106_;
			_tmp107_ = values;
			_tmp107__length1 = values_length1;
			_tmp108_ = video_item;
			_tmp109_ = _tmp108_->author;
			g_value_init (&_tmp110_, G_TYPE_STRING);
			g_value_set_string (&_tmp110_, _tmp109_);
			G_IS_VALUE (&_tmp107_[5]) ? (g_value_unset (&_tmp107_[5]), NULL) : NULL;
			_tmp107_[5] = _tmp110_;
			_tmp111_ = _tmp107_[5];
			_g_object_unref0 (video_item);
		}
		_g_object_unref0 (visual_item);
	}
	_tmp112_ = self->priv->db;
	_tmp113_ = self->priv->sql;
	_tmp114_ = rygel_media_export_sql_factory_make (_tmp113_, RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA);
	_tmp115_ = values;
	_tmp115__length1 = values_length1;
	rygel_media_export_database_exec (_tmp112_, _tmp114_, _tmp115_, _tmp115__length1, &_inner_error_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		values = (_vala_GValue_array_free (values, values_length1), NULL);
		return;
	}
	values = (_vala_GValue_array_free (values, values_length1), NULL);
}


static void rygel_media_export_media_cache_create_object (RygelMediaExportMediaCache* self, RygelMediaObject* item, GError** error) {
	gint type;
	GValue parent = {0};
	RygelMediaObject* _tmp0_;
	RygelMediaObject* _tmp1_;
	RygelMediaContainer* _tmp2_;
	gchar* _tmp8_ = NULL;
	RygelMediaObject* _tmp9_;
	GeeArrayList* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	RygelMediaObject* _tmp16_;
	const gchar* _tmp17_;
	GValue _tmp18_ = {0};
	RygelMediaObject* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	GValue _tmp22_ = {0};
	gint _tmp23_;
	GValue _tmp24_ = {0};
	GValue _tmp25_;
	GValue _tmp26_ = {0};
	RygelMediaObject* _tmp27_;
	guint64 _tmp28_;
	GValue _tmp29_ = {0};
	const gchar* _tmp30_;
	GValue _tmp31_ = {0};
	GValue* _tmp32_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	RygelMediaExportDatabase* _tmp33_;
	RygelMediaExportSQLFactory* _tmp34_;
	const gchar* _tmp35_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (item != NULL);
	type = (gint) RYGEL_MEDIA_EXPORT_OBJECT_TYPE_CONTAINER;
	_tmp0_ = item;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, RYGEL_TYPE_MEDIA_ITEM)) {
		type = (gint) RYGEL_MEDIA_EXPORT_OBJECT_TYPE_ITEM;
	}
	_tmp1_ = item;
	_tmp2_ = _tmp1_->parent;
	if (_tmp2_ == NULL) {
		GValue _tmp3_ = {0};
		rygel_media_export_database_null (&_tmp3_);
		G_IS_VALUE (&parent) ? (g_value_unset (&parent), NULL) : NULL;
		parent = _tmp3_;
	} else {
		RygelMediaObject* _tmp4_;
		RygelMediaContainer* _tmp5_;
		const gchar* _tmp6_;
		GValue _tmp7_ = {0};
		_tmp4_ = item;
		_tmp5_ = _tmp4_->parent;
		_tmp6_ = ((RygelMediaObject*) _tmp5_)->id;
		g_value_init (&_tmp7_, G_TYPE_STRING);
		g_value_set_string (&_tmp7_, _tmp6_);
		G_IS_VALUE (&parent) ? (g_value_unset (&parent), NULL) : NULL;
		parent = _tmp7_;
	}
	_tmp9_ = item;
	_tmp10_ = _tmp9_->uris;
	_tmp11_ = gee_abstract_collection_get_size ((GeeCollection*) _tmp10_);
	_tmp12_ = _tmp11_;
	if (_tmp12_ == 0) {
		_g_free0 (_tmp8_);
		_tmp8_ = NULL;
	} else {
		RygelMediaObject* _tmp13_;
		GeeArrayList* _tmp14_;
		gpointer _tmp15_ = NULL;
		_tmp13_ = item;
		_tmp14_ = _tmp13_->uris;
		_tmp15_ = gee_abstract_list_get ((GeeAbstractList*) _tmp14_, 0);
		_g_free0 (_tmp8_);
		_tmp8_ = (gchar*) _tmp15_;
	}
	_tmp16_ = item;
	_tmp17_ = _tmp16_->id;
	g_value_init (&_tmp18_, G_TYPE_STRING);
	g_value_set_string (&_tmp18_, _tmp17_);
	_tmp19_ = item;
	_tmp20_ = rygel_media_object_get_title (_tmp19_);
	_tmp21_ = _tmp20_;
	g_value_init (&_tmp22_, G_TYPE_STRING);
	g_value_set_string (&_tmp22_, _tmp21_);
	_tmp23_ = type;
	g_value_init (&_tmp24_, G_TYPE_INT);
	g_value_set_int (&_tmp24_, _tmp23_);
	_tmp25_ = parent;
	if (G_IS_VALUE (&_tmp25_)) {
		g_value_init (&_tmp26_, G_VALUE_TYPE (&_tmp25_));
		g_value_copy (&_tmp25_, &_tmp26_);
	} else {
		_tmp26_ = _tmp25_;
	}
	_tmp27_ = item;
	_tmp28_ = _tmp27_->modified;
	g_value_init (&_tmp29_, G_TYPE_UINT64);
	g_value_set_uint64 (&_tmp29_, _tmp28_);
	_tmp30_ = _tmp8_;
	g_value_init (&_tmp31_, G_TYPE_STRING);
	g_value_set_string (&_tmp31_, _tmp30_);
	_tmp32_ = g_new0 (GValue, 6);
	_tmp32_[0] = _tmp18_;
	_tmp32_[1] = _tmp22_;
	_tmp32_[2] = _tmp24_;
	_tmp32_[3] = _tmp26_;
	_tmp32_[4] = _tmp29_;
	_tmp32_[5] = _tmp31_;
	values = _tmp32_;
	values_length1 = 6;
	_values_size_ = values_length1;
	_tmp33_ = self->priv->db;
	_tmp34_ = self->priv->sql;
	_tmp35_ = rygel_media_export_sql_factory_make (_tmp34_, RYGEL_MEDIA_EXPORT_SQL_STRING_INSERT);
	rygel_media_export_database_exec (_tmp33_, _tmp35_, values, values_length1, &_inner_error_);
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		values = (_vala_GValue_array_free (values, values_length1), NULL);
		_g_free0 (_tmp8_);
		G_IS_VALUE (&parent) ? (g_value_unset (&parent), NULL) : NULL;
		return;
	}
	values = (_vala_GValue_array_free (values, values_length1), NULL);
	_g_free0 (_tmp8_);
	G_IS_VALUE (&parent) ? (g_value_unset (&parent), NULL) : NULL;
}


/**
     * Create the current schema.
     *
     * If schema creation fails, schema will be rolled back
     * completely.
     *
     * @returns: true on success, false on failure
     */
static gboolean rygel_media_export_media_cache_create_schema (RygelMediaExportMediaCache* self) {
	gboolean result = FALSE;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, FALSE);
	{
		RygelMediaExportDatabase* _tmp0_;
		RygelMediaExportDatabase* _tmp1_;
		RygelMediaExportSQLFactory* _tmp2_;
		const gchar* _tmp3_ = NULL;
		RygelMediaExportDatabase* _tmp4_;
		RygelMediaExportSQLFactory* _tmp5_;
		const gchar* _tmp6_ = NULL;
		RygelMediaExportDatabase* _tmp7_;
		RygelMediaExportSQLFactory* _tmp8_;
		const gchar* _tmp9_ = NULL;
		RygelMediaExportDatabase* _tmp10_;
		RygelMediaExportSQLFactory* _tmp11_;
		const gchar* _tmp12_ = NULL;
		RygelMediaExportDatabase* _tmp13_;
		RygelMediaExportSQLFactory* _tmp14_;
		const gchar* _tmp15_ = NULL;
		RygelMediaExportDatabase* _tmp16_;
		RygelMediaExportDatabase* _tmp17_;
		_tmp0_ = self->priv->db;
		rygel_media_export_database_begin (_tmp0_, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch10_g_error;
		}
		_tmp1_ = self->priv->db;
		_tmp2_ = self->priv->sql;
		_tmp3_ = rygel_media_export_sql_factory_make (_tmp2_, RYGEL_MEDIA_EXPORT_SQL_STRING_SCHEMA);
		rygel_media_export_database_exec (_tmp1_, _tmp3_, NULL, 0, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch10_g_error;
		}
		_tmp4_ = self->priv->db;
		_tmp5_ = self->priv->sql;
		_tmp6_ = rygel_media_export_sql_factory_make (_tmp5_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_COMMON);
		rygel_media_export_database_exec (_tmp4_, _tmp6_, NULL, 0, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch10_g_error;
		}
		_tmp7_ = self->priv->db;
		_tmp8_ = self->priv->sql;
		_tmp9_ = rygel_media_export_sql_factory_make (_tmp8_, RYGEL_MEDIA_EXPORT_SQL_STRING_TABLE_CLOSURE);
		rygel_media_export_database_exec (_tmp7_, _tmp9_, NULL, 0, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch10_g_error;
		}
		_tmp10_ = self->priv->db;
		_tmp11_ = self->priv->sql;
		_tmp12_ = rygel_media_export_sql_factory_make (_tmp11_, RYGEL_MEDIA_EXPORT_SQL_STRING_INDEX_COMMON);
		rygel_media_export_database_exec (_tmp10_, _tmp12_, NULL, 0, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch10_g_error;
		}
		_tmp13_ = self->priv->db;
		_tmp14_ = self->priv->sql;
		_tmp15_ = rygel_media_export_sql_factory_make (_tmp14_, RYGEL_MEDIA_EXPORT_SQL_STRING_TRIGGER_CLOSURE);
		rygel_media_export_database_exec (_tmp13_, _tmp15_, NULL, 0, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch10_g_error;
		}
		_tmp16_ = self->priv->db;
		rygel_media_export_database_commit (_tmp16_, &_inner_error_);
		if (_inner_error_ != NULL) {
			goto __catch10_g_error;
		}
		_tmp17_ = self->priv->db;
		rygel_media_export_database_analyze (_tmp17_);
		result = TRUE;
		return result;
	}
	goto __finally10;
	__catch10_g_error:
	{
		GError* err = NULL;
		GError* _tmp18_;
		const gchar* _tmp19_;
		RygelMediaExportDatabase* _tmp20_;
		err = _inner_error_;
		_inner_error_ = NULL;
		_tmp18_ = err;
		_tmp19_ = _tmp18_->message;
		g_warning ("rygel-media-export-media-cache.vala:582: Failed to create schema: %s", _tmp19_);
		_tmp20_ = self->priv->db;
		rygel_media_export_database_rollback (_tmp20_);
		_g_error_free0 (err);
	}
	__finally10:
	if (_inner_error_ != NULL) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return FALSE;
	}
	result = FALSE;
	return result;
}


static RygelMediaObject* rygel_media_export_media_cache_get_object_from_statement (RygelMediaExportMediaCache* self, RygelMediaContainer* parent, sqlite3_stmt* statement) {
	RygelMediaObject* result = NULL;
	RygelMediaObject* object;
	sqlite3_stmt* _tmp0_;
	const gchar* _tmp1_ = NULL;
	const gchar* title;
	sqlite3_stmt* _tmp2_;
	const gchar* _tmp3_ = NULL;
	const gchar* object_id;
	sqlite3_stmt* _tmp4_;
	const gchar* _tmp5_ = NULL;
	const gchar* uri;
	sqlite3_stmt* _tmp6_;
	gint _tmp7_ = 0;
	RygelMediaObject* _tmp32_;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (statement != NULL, NULL);
	object = NULL;
	_tmp0_ = statement;
	_tmp1_ = sqlite3_column_text (_tmp0_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TITLE);
	title = _tmp1_;
	_tmp2_ = statement;
	_tmp3_ = sqlite3_column_text (_tmp2_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID);
	object_id = _tmp3_;
	_tmp4_ = statement;
	_tmp5_ = sqlite3_column_text (_tmp4_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_URI);
	uri = _tmp5_;
	_tmp6_ = statement;
	_tmp7_ = sqlite3_column_int (_tmp6_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TYPE);
	switch (_tmp7_) {
		case 0:
		{
			RygelMediaExportObjectFactory* _tmp8_;
			const gchar* _tmp9_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			RygelMediaExportDBContainer* _tmp12_ = NULL;
			RygelMediaObject* _tmp13_;
			RygelMediaContainer* _tmp14_;
			RygelMediaContainer* container;
			const gchar* _tmp15_;
			_tmp8_ = self->priv->factory;
			_tmp9_ = object_id;
			_tmp10_ = title;
			_tmp11_ = uri;
			_tmp12_ = rygel_media_export_object_factory_get_container (_tmp8_, self, _tmp9_, _tmp10_, (guint) 0, _tmp11_);
			_g_object_unref0 (object);
			object = (RygelMediaObject*) _tmp12_;
			_tmp13_ = object;
			_tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp13_) : NULL);
			container = _tmp14_;
			_tmp15_ = uri;
			if (_tmp15_ != NULL) {
				RygelMediaContainer* _tmp16_;
				GeeArrayList* _tmp17_;
				const gchar* _tmp18_;
				_tmp16_ = container;
				_tmp17_ = ((RygelMediaObject*) _tmp16_)->uris;
				_tmp18_ = uri;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp17_, _tmp18_);
			}
			_g_object_unref0 (container);
			break;
		}
		case 1:
		{
			sqlite3_stmt* _tmp19_;
			const gchar* _tmp20_ = NULL;
			const gchar* upnp_class;
			RygelMediaExportObjectFactory* _tmp21_;
			RygelMediaContainer* _tmp22_;
			const gchar* _tmp23_;
			const gchar* _tmp24_;
			const gchar* _tmp25_;
			RygelMediaItem* _tmp26_ = NULL;
			sqlite3_stmt* _tmp27_;
			RygelMediaObject* _tmp28_;
			const gchar* _tmp29_;
			_tmp19_ = statement;
			_tmp20_ = sqlite3_column_text (_tmp19_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CLASS);
			upnp_class = _tmp20_;
			_tmp21_ = self->priv->factory;
			_tmp22_ = parent;
			_tmp23_ = object_id;
			_tmp24_ = title;
			_tmp25_ = upnp_class;
			_tmp26_ = rygel_media_export_object_factory_get_item (_tmp21_, self, _tmp22_, _tmp23_, _tmp24_, _tmp25_);
			_g_object_unref0 (object);
			object = (RygelMediaObject*) _tmp26_;
			_tmp27_ = statement;
			_tmp28_ = object;
			rygel_media_export_media_cache_fill_item (self, _tmp27_, G_TYPE_CHECK_INSTANCE_TYPE (_tmp28_, RYGEL_TYPE_MEDIA_ITEM) ? ((RygelMediaItem*) _tmp28_) : NULL);
			_tmp29_ = uri;
			if (_tmp29_ != NULL) {
				RygelMediaObject* _tmp30_;
				const gchar* _tmp31_;
				_tmp30_ = object;
				_tmp31_ = uri;
				rygel_media_item_add_uri (G_TYPE_CHECK_INSTANCE_TYPE (_tmp30_, RYGEL_TYPE_MEDIA_ITEM) ? ((RygelMediaItem*) _tmp30_) : NULL, _tmp31_);
			}
			break;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
	_tmp32_ = object;
	if (_tmp32_ != NULL) {
		RygelMediaObject* _tmp33_;
		sqlite3_stmt* _tmp34_;
		gint64 _tmp35_ = 0LL;
		_tmp33_ = object;
		_tmp34_ = statement;
		_tmp35_ = sqlite3_column_int64 (_tmp34_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TIMESTAMP);
		_tmp33_->modified = (guint64) _tmp35_;
	}
	result = object;
	return result;
}


static void rygel_media_export_media_cache_fill_item (RygelMediaExportMediaCache* self, sqlite3_stmt* statement, RygelMediaItem* item) {
	RygelMediaItem* _tmp0_;
	sqlite3_stmt* _tmp1_;
	const gchar* _tmp2_ = NULL;
	gchar* _tmp3_;
	RygelMediaItem* _tmp4_;
	sqlite3_stmt* _tmp5_;
	const gchar* _tmp6_ = NULL;
	gchar* _tmp7_;
	RygelMediaItem* _tmp8_;
	sqlite3_stmt* _tmp9_;
	const gchar* _tmp10_ = NULL;
	gchar* _tmp11_;
	RygelMediaItem* _tmp12_;
	sqlite3_stmt* _tmp13_;
	gint64 _tmp14_ = 0LL;
	RygelMediaItem* _tmp15_;
	RygelMediaItem* _tmp52_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (statement != NULL);
	g_return_if_fail (item != NULL);
	_tmp0_ = item;
	_tmp1_ = statement;
	_tmp2_ = sqlite3_column_text (_tmp1_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DATE);
	_tmp3_ = g_strdup (_tmp2_);
	_g_free0 (_tmp0_->date);
	_tmp0_->date = _tmp3_;
	_tmp4_ = item;
	_tmp5_ = statement;
	_tmp6_ = sqlite3_column_text (_tmp5_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_MIME_TYPE);
	_tmp7_ = g_strdup (_tmp6_);
	_g_free0 (_tmp4_->mime_type);
	_tmp4_->mime_type = _tmp7_;
	_tmp8_ = item;
	_tmp9_ = statement;
	_tmp10_ = sqlite3_column_text (_tmp9_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DLNA_PROFILE);
	_tmp11_ = g_strdup (_tmp10_);
	_g_free0 (_tmp8_->dlna_profile);
	_tmp8_->dlna_profile = _tmp11_;
	_tmp12_ = item;
	_tmp13_ = statement;
	_tmp14_ = sqlite3_column_int64 (_tmp13_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SIZE);
	rygel_media_item_set_size (_tmp12_, _tmp14_);
	_tmp15_ = item;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp15_, RYGEL_TYPE_AUDIO_ITEM)) {
		RygelMediaItem* _tmp16_;
		RygelAudioItem* _tmp17_;
		RygelAudioItem* audio_item;
		RygelAudioItem* _tmp18_;
		sqlite3_stmt* _tmp19_;
		gint64 _tmp20_ = 0LL;
		RygelAudioItem* _tmp21_;
		sqlite3_stmt* _tmp22_;
		gint _tmp23_ = 0;
		RygelAudioItem* _tmp24_;
		sqlite3_stmt* _tmp25_;
		gint _tmp26_ = 0;
		RygelAudioItem* _tmp27_;
		sqlite3_stmt* _tmp28_;
		gint _tmp29_ = 0;
		RygelAudioItem* _tmp30_;
		sqlite3_stmt* _tmp31_;
		gint _tmp32_ = 0;
		RygelMediaItem* _tmp33_;
		_tmp16_ = item;
		_tmp17_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp16_, RYGEL_TYPE_AUDIO_ITEM) ? ((RygelAudioItem*) _tmp16_) : NULL);
		audio_item = _tmp17_;
		_tmp18_ = audio_item;
		_tmp19_ = statement;
		_tmp20_ = sqlite3_column_int64 (_tmp19_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DURATION);
		_tmp18_->duration = (glong) _tmp20_;
		_tmp21_ = audio_item;
		_tmp22_ = statement;
		_tmp23_ = sqlite3_column_int (_tmp22_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITRATE);
		_tmp21_->bitrate = _tmp23_;
		_tmp24_ = audio_item;
		_tmp25_ = statement;
		_tmp26_ = sqlite3_column_int (_tmp25_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_SAMPLE_FREQ);
		_tmp24_->sample_freq = _tmp26_;
		_tmp27_ = audio_item;
		_tmp28_ = statement;
		_tmp29_ = sqlite3_column_int (_tmp28_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_BITS_PER_SAMPLE);
		_tmp27_->bits_per_sample = _tmp29_;
		_tmp30_ = audio_item;
		_tmp31_ = statement;
		_tmp32_ = sqlite3_column_int (_tmp31_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_CHANNELS);
		_tmp30_->channels = _tmp32_;
		_tmp33_ = item;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp33_, RYGEL_TYPE_MUSIC_ITEM)) {
			RygelMediaItem* _tmp34_;
			RygelMusicItem* _tmp35_;
			RygelMusicItem* music_item;
			RygelMusicItem* _tmp36_;
			sqlite3_stmt* _tmp37_;
			const gchar* _tmp38_ = NULL;
			gchar* _tmp39_;
			RygelMusicItem* _tmp40_;
			sqlite3_stmt* _tmp41_;
			const gchar* _tmp42_ = NULL;
			gchar* _tmp43_;
			RygelMusicItem* _tmp44_;
			sqlite3_stmt* _tmp45_;
			const gchar* _tmp46_ = NULL;
			gchar* _tmp47_;
			RygelMusicItem* _tmp48_;
			sqlite3_stmt* _tmp49_;
			gint _tmp50_ = 0;
			RygelMusicItem* _tmp51_;
			_tmp34_ = item;
			_tmp35_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp34_, RYGEL_TYPE_MUSIC_ITEM) ? ((RygelMusicItem*) _tmp34_) : NULL);
			music_item = _tmp35_;
			_tmp36_ = music_item;
			_tmp37_ = statement;
			_tmp38_ = sqlite3_column_text (_tmp37_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR);
			_tmp39_ = g_strdup (_tmp38_);
			_g_free0 (_tmp36_->artist);
			_tmp36_->artist = _tmp39_;
			_tmp40_ = music_item;
			_tmp41_ = statement;
			_tmp42_ = sqlite3_column_text (_tmp41_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ALBUM);
			_tmp43_ = g_strdup (_tmp42_);
			_g_free0 (_tmp40_->album);
			_tmp40_->album = _tmp43_;
			_tmp44_ = music_item;
			_tmp45_ = statement;
			_tmp46_ = sqlite3_column_text (_tmp45_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_GENRE);
			_tmp47_ = g_strdup (_tmp46_);
			_g_free0 (_tmp44_->genre);
			_tmp44_->genre = _tmp47_;
			_tmp48_ = music_item;
			_tmp49_ = statement;
			_tmp50_ = sqlite3_column_int (_tmp49_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TRACK);
			_tmp48_->track_number = _tmp50_;
			_tmp51_ = music_item;
			rygel_music_item_lookup_album_art (_tmp51_);
			_g_object_unref0 (music_item);
		}
		_g_object_unref0 (audio_item);
	}
	_tmp52_ = item;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp52_, RYGEL_TYPE_VISUAL_ITEM)) {
		RygelMediaItem* _tmp53_;
		RygelVisualItem* _tmp54_;
		RygelVisualItem* visual_item;
		RygelVisualItem* _tmp55_;
		sqlite3_stmt* _tmp56_;
		gint _tmp57_ = 0;
		RygelVisualItem* _tmp58_;
		sqlite3_stmt* _tmp59_;
		gint _tmp60_ = 0;
		RygelVisualItem* _tmp61_;
		sqlite3_stmt* _tmp62_;
		gint _tmp63_ = 0;
		RygelMediaItem* _tmp64_;
		_tmp53_ = item;
		_tmp54_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp53_, RYGEL_TYPE_VISUAL_ITEM) ? ((RygelVisualItem*) _tmp53_) : NULL);
		visual_item = _tmp54_;
		_tmp55_ = visual_item;
		_tmp56_ = statement;
		_tmp57_ = sqlite3_column_int (_tmp56_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_WIDTH);
		rygel_visual_item_set_width (_tmp55_, _tmp57_);
		_tmp58_ = visual_item;
		_tmp59_ = statement;
		_tmp60_ = sqlite3_column_int (_tmp59_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_HEIGHT);
		rygel_visual_item_set_height (_tmp58_, _tmp60_);
		_tmp61_ = visual_item;
		_tmp62_ = statement;
		_tmp63_ = sqlite3_column_int (_tmp62_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_COLOR_DEPTH);
		rygel_visual_item_set_color_depth (_tmp61_, _tmp63_);
		_tmp64_ = item;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp64_, RYGEL_TYPE_VIDEO_ITEM)) {
			RygelMediaItem* _tmp65_;
			RygelVideoItem* _tmp66_;
			RygelVideoItem* video_item;
			RygelVideoItem* _tmp67_;
			sqlite3_stmt* _tmp68_;
			const gchar* _tmp69_ = NULL;
			gchar* _tmp70_;
			_tmp65_ = item;
			_tmp66_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp65_, RYGEL_TYPE_VIDEO_ITEM) ? ((RygelVideoItem*) _tmp65_) : NULL);
			video_item = _tmp66_;
			_tmp67_ = video_item;
			_tmp68_ = statement;
			_tmp69_ = sqlite3_column_text (_tmp68_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_AUTHOR);
			_tmp70_ = g_strdup (_tmp69_);
			_g_free0 (_tmp67_->author);
			_tmp67_->author = _tmp70_;
			_g_object_unref0 (video_item);
		}
		_g_object_unref0 (visual_item);
	}
}


static gchar* rygel_media_export_media_cache_translate_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, GValueArray* args, const gchar* prefix, GError** error) {
	gchar* result = NULL;
	RygelSearchExpression* _tmp0_;
	RygelSearchExpression* _tmp2_;
	GValueArray* _tmp3_;
	gchar* _tmp4_ = NULL;
	gchar* filter;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (args != NULL, NULL);
	g_return_val_if_fail (prefix != NULL, NULL);
	_tmp0_ = expression;
	if (_tmp0_ == NULL) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("");
		result = _tmp1_;
		return result;
	}
	_tmp2_ = expression;
	_tmp3_ = args;
	_tmp4_ = rygel_media_export_media_cache_search_expression_to_sql (self, _tmp2_, _tmp3_, &_inner_error_);
	filter = _tmp4_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp5_ = prefix;
	_tmp6_ = filter;
	_tmp7_ = g_strdup_printf (" %s %s", _tmp5_, _tmp6_);
	result = _tmp7_;
	_g_free0 (filter);
	return result;
}


static gchar* rygel_media_export_media_cache_search_expression_to_sql (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, GValueArray* args, GError** error) {
	gchar* result = NULL;
	RygelSearchExpression* _tmp0_;
	RygelSearchExpression* _tmp2_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (args != NULL, NULL);
	_tmp0_ = expression;
	if (_tmp0_ == NULL) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("");
		result = _tmp1_;
		return result;
	}
	_tmp2_ = expression;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, RYGEL_TYPE_LOGICAL_EXPRESSION)) {
		RygelSearchExpression* _tmp3_;
		GValueArray* _tmp4_;
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_;
		_tmp3_ = expression;
		_tmp4_ = args;
		_tmp5_ = rygel_media_export_media_cache_logical_expression_to_sql (self, G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, RYGEL_TYPE_LOGICAL_EXPRESSION) ? ((RygelLogicalExpression*) _tmp3_) : NULL, _tmp4_, &_inner_error_);
		_tmp6_ = _tmp5_;
		if (_inner_error_ != NULL) {
			g_propagate_error (error, _inner_error_);
			return NULL;
		}
		result = _tmp6_;
		return result;
	} else {
		RygelSearchExpression* _tmp7_;
		GValueArray* _tmp8_;
		gchar* _tmp9_ = NULL;
		gchar* _tmp10_;
		_tmp7_ = expression;
		_tmp8_ = args;
		_tmp9_ = rygel_media_export_media_cache_relational_expression_to_sql (self, G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, RYGEL_TYPE_RELATIONAL_EXPRESSION) ? ((RygelRelationalExpression*) _tmp7_) : NULL, _tmp8_, &_inner_error_);
		_tmp10_ = _tmp9_;
		if (_inner_error_ != NULL) {
			g_propagate_error (error, _inner_error_);
			return NULL;
		}
		result = _tmp10_;
		return result;
	}
}


static gchar* rygel_media_export_media_cache_logical_expression_to_sql (RygelMediaExportMediaCache* self, RygelLogicalExpression* expression, GValueArray* args, GError** error) {
	gchar* result = NULL;
	RygelLogicalExpression* _tmp0_;
	gconstpointer _tmp1_;
	GValueArray* _tmp2_;
	gchar* _tmp3_ = NULL;
	gchar* left_sql_string;
	RygelLogicalExpression* _tmp4_;
	gconstpointer _tmp5_;
	GValueArray* _tmp6_;
	gchar* _tmp7_ = NULL;
	gchar* right_sql_string;
	gchar* _tmp8_;
	gchar* operator_sql_string;
	RygelLogicalExpression* _tmp9_;
	gconstpointer _tmp10_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (args != NULL, NULL);
	_tmp0_ = expression;
	_tmp1_ = ((RygelSearchExpression*) _tmp0_)->operand1;
	_tmp2_ = args;
	_tmp3_ = rygel_media_export_media_cache_search_expression_to_sql (self, (RygelSearchExpression*) _tmp1_, _tmp2_, &_inner_error_);
	left_sql_string = _tmp3_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		return NULL;
	}
	_tmp4_ = expression;
	_tmp5_ = ((RygelSearchExpression*) _tmp4_)->operand2;
	_tmp6_ = args;
	_tmp7_ = rygel_media_export_media_cache_search_expression_to_sql (self, (RygelSearchExpression*) _tmp5_, _tmp6_, &_inner_error_);
	right_sql_string = _tmp7_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (left_sql_string);
		return NULL;
	}
	_tmp8_ = g_strdup ("OR");
	operator_sql_string = _tmp8_;
	_tmp9_ = expression;
	_tmp10_ = ((RygelSearchExpression*) _tmp9_)->op;
	if (GPOINTER_TO_INT (_tmp10_) == RYGEL_LOGICAL_OPERATOR_AND) {
		gchar* _tmp11_;
		_tmp11_ = g_strdup ("AND");
		_g_free0 (operator_sql_string);
		operator_sql_string = _tmp11_;
	}
	_tmp12_ = left_sql_string;
	_tmp13_ = operator_sql_string;
	_tmp14_ = right_sql_string;
	_tmp15_ = g_strdup_printf ("(%s %s %s)", _tmp12_, _tmp13_, _tmp14_);
	result = _tmp15_;
	_g_free0 (operator_sql_string);
	_g_free0 (right_sql_string);
	_g_free0 (left_sql_string);
	return result;
}


static gchar* rygel_media_export_media_cache_map_operand_to_column (RygelMediaExportMediaCache* self, const gchar* operand, gchar** collate, GError** error) {
	gchar* _vala_collate = NULL;
	gchar* result = NULL;
	gchar* column;
	gboolean use_collation;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	GQuark _tmp3_ = 0U;
	static GQuark _tmp2_label0 = 0;
	static GQuark _tmp2_label1 = 0;
	static GQuark _tmp2_label2 = 0;
	static GQuark _tmp2_label3 = 0;
	static GQuark _tmp2_label4 = 0;
	static GQuark _tmp2_label5 = 0;
	static GQuark _tmp2_label6 = 0;
	static GQuark _tmp2_label7 = 0;
	static GQuark _tmp2_label8 = 0;
	static GQuark _tmp2_label9 = 0;
	static GQuark _tmp2_label10 = 0;
	static GQuark _tmp2_label11 = 0;
	static GQuark _tmp2_label12 = 0;
	gboolean _tmp19_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (operand != NULL, NULL);
	column = NULL;
	use_collation = FALSE;
	_tmp0_ = operand;
	_tmp1_ = _tmp0_;
	_tmp3_ = (NULL == _tmp1_) ? 0 : g_quark_from_string (_tmp1_);
	if (_tmp3_ == ((0 != _tmp2_label0) ? _tmp2_label0 : (_tmp2_label0 = g_quark_from_static_string ("res")))) {
		switch (0) {
			default:
			{
				gchar* _tmp4_;
				_tmp4_ = g_strdup ("o.uri");
				_g_free0 (column);
				column = _tmp4_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label1) ? _tmp2_label1 : (_tmp2_label1 = g_quark_from_static_string ("res@duration")))) {
		switch (0) {
			default:
			{
				gchar* _tmp5_;
				_tmp5_ = g_strdup ("m.duration");
				_g_free0 (column);
				column = _tmp5_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label2) ? _tmp2_label2 : (_tmp2_label2 = g_quark_from_static_string ("@refID")))) {
		switch (0) {
			default:
			{
				gchar* _tmp6_;
				_tmp6_ = g_strdup ("NULL");
				_g_free0 (column);
				column = _tmp6_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label3) ? _tmp2_label3 : (_tmp2_label3 = g_quark_from_static_string ("@id")))) {
		switch (0) {
			default:
			{
				gchar* _tmp7_;
				_tmp7_ = g_strdup ("o.upnp_id");
				_g_free0 (column);
				column = _tmp7_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label4) ? _tmp2_label4 : (_tmp2_label4 = g_quark_from_static_string ("@parentID")))) {
		switch (0) {
			default:
			{
				gchar* _tmp8_;
				_tmp8_ = g_strdup ("o.parent");
				_g_free0 (column);
				column = _tmp8_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label5) ? _tmp2_label5 : (_tmp2_label5 = g_quark_from_static_string ("upnp:class")))) {
		switch (0) {
			default:
			{
				gchar* _tmp9_;
				_tmp9_ = g_strdup ("m.class");
				_g_free0 (column);
				column = _tmp9_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label6) ? _tmp2_label6 : (_tmp2_label6 = g_quark_from_static_string ("dc:title")))) {
		switch (0) {
			default:
			{
				gchar* _tmp10_;
				_tmp10_ = g_strdup ("o.title");
				_g_free0 (column);
				column = _tmp10_;
				use_collation = TRUE;
				break;
			}
		}
	} else if ((_tmp3_ == ((0 != _tmp2_label7) ? _tmp2_label7 : (_tmp2_label7 = g_quark_from_static_string ("upnp:artist")))) || (_tmp3_ == ((0 != _tmp2_label8) ? _tmp2_label8 : (_tmp2_label8 = g_quark_from_static_string ("dc:creator"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp11_;
				_tmp11_ = g_strdup ("m.author");
				_g_free0 (column);
				column = _tmp11_;
				use_collation = TRUE;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label9) ? _tmp2_label9 : (_tmp2_label9 = g_quark_from_static_string ("dc:date")))) {
		switch (0) {
			default:
			{
				gchar* _tmp12_;
				_tmp12_ = g_strdup ("strftime(\"%Y\", m.date)");
				_g_free0 (column);
				column = _tmp12_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label10) ? _tmp2_label10 : (_tmp2_label10 = g_quark_from_static_string ("upnp:album")))) {
		switch (0) {
			default:
			{
				gchar* _tmp13_;
				_tmp13_ = g_strdup ("m.album");
				_g_free0 (column);
				column = _tmp13_;
				use_collation = TRUE;
				break;
			}
		}
	} else if ((_tmp3_ == ((0 != _tmp2_label11) ? _tmp2_label11 : (_tmp2_label11 = g_quark_from_static_string ("upnp:genre")))) || (_tmp3_ == ((0 != _tmp2_label12) ? _tmp2_label12 : (_tmp2_label12 = g_quark_from_static_string ("dc:genre"))))) {
		switch (0) {
			default:
			{
				gchar* _tmp14_;
				_tmp14_ = g_strdup ("m.genre");
				_g_free0 (column);
				column = _tmp14_;
				use_collation = TRUE;
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				const gchar* _tmp15_;
				gchar* _tmp16_ = NULL;
				gchar* message;
				const gchar* _tmp17_;
				GError* _tmp18_;
				_tmp15_ = operand;
				_tmp16_ = g_strdup_printf ("Unsupported column %s", _tmp15_);
				message = _tmp16_;
				_tmp17_ = message;
				_tmp18_ = g_error_new_literal (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH, _tmp17_);
				_inner_error_ = _tmp18_;
				g_propagate_error (error, _inner_error_);
				_g_free0 (message);
				_g_free0 (column);
				return NULL;
			}
		}
	}
	_tmp19_ = use_collation;
	if (_tmp19_) {
		gchar* _tmp20_;
		_tmp20_ = g_strdup ("COLLATE CASEFOLD");
		_g_free0 (_vala_collate);
		_vala_collate = _tmp20_;
	} else {
		gchar* _tmp21_;
		_tmp21_ = g_strdup ("");
		_g_free0 (_vala_collate);
		_vala_collate = _tmp21_;
	}
	result = column;
	if (collate) {
		*collate = _vala_collate;
	} else {
		_g_free0 (_vala_collate);
	}
	return result;
}


static void _vala_GValue_free (GValue* self) {
	g_value_unset (self);
	g_free (self);
}


static gchar* rygel_media_export_media_cache_relational_expression_to_sql (RygelMediaExportMediaCache* self, RygelRelationalExpression* exp, GValueArray* args, GError** error) {
	gchar* result = NULL;
	GValue* v;
	gchar* collate;
	RygelRelationalExpression* _tmp0_;
	gconstpointer _tmp1_;
	gchar* _tmp2_ = NULL;
	gchar* _tmp3_ = NULL;
	gchar* column;
	RygelMediaExportSqlOperator* operator = NULL;
	RygelRelationalExpression* _tmp4_;
	gconstpointer _tmp5_;
	GValue* _tmp40_;
	RygelMediaExportSqlOperator* _tmp44_;
	gchar* _tmp45_ = NULL;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (args != NULL, NULL);
	v = NULL;
	collate = NULL;
	_tmp0_ = exp;
	_tmp1_ = ((RygelSearchExpression*) _tmp0_)->operand1;
	_tmp3_ = rygel_media_export_media_cache_map_operand_to_column (self, (const gchar*) _tmp1_, &_tmp2_, &_inner_error_);
	_g_free0 (collate);
	collate = _tmp2_;
	column = _tmp3_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (collate);
		__vala_GValue_free0 (v);
		return NULL;
	}
	_tmp4_ = exp;
	_tmp5_ = ((RygelSearchExpression*) _tmp4_)->op;
	switch (GPOINTER_TO_INT (_tmp5_)) {
		case GUPNP_SEARCH_CRITERIA_OP_EXISTS:
		{
			gchar* sql_function = NULL;
			RygelRelationalExpression* _tmp6_;
			gconstpointer _tmp7_;
			const gchar* _tmp10_;
			const gchar* _tmp11_;
			const gchar* _tmp12_;
			gchar* _tmp13_ = NULL;
			_tmp6_ = exp;
			_tmp7_ = ((RygelSearchExpression*) _tmp6_)->operand2;
			if (g_strcmp0 ((const gchar*) _tmp7_, "true") == 0) {
				gchar* _tmp8_;
				_tmp8_ = g_strdup ("%s IS NOT NULL AND %s != ''");
				_g_free0 (sql_function);
				sql_function = _tmp8_;
			} else {
				gchar* _tmp9_;
				_tmp9_ = g_strdup ("%s IS NULL OR %s = ''");
				_g_free0 (sql_function);
				sql_function = _tmp9_;
			}
			_tmp10_ = sql_function;
			_tmp11_ = column;
			_tmp12_ = column;
			_tmp13_ = g_strdup_printf (_tmp10_, _tmp11_, _tmp12_);
			result = _tmp13_;
			_g_free0 (sql_function);
			_g_object_unref0 (operator);
			_g_free0 (column);
			_g_free0 (collate);
			__vala_GValue_free0 (v);
			return result;
		}
		case GUPNP_SEARCH_CRITERIA_OP_EQ:
		case GUPNP_SEARCH_CRITERIA_OP_NEQ:
		case GUPNP_SEARCH_CRITERIA_OP_LESS:
		case GUPNP_SEARCH_CRITERIA_OP_LEQ:
		case GUPNP_SEARCH_CRITERIA_OP_GREATER:
		case GUPNP_SEARCH_CRITERIA_OP_GEQ:
		{
			RygelRelationalExpression* _tmp14_;
			gconstpointer _tmp15_;
			GValue* _tmp16_ = NULL;
			RygelRelationalExpression* _tmp17_;
			gconstpointer _tmp18_;
			const gchar* _tmp19_;
			const gchar* _tmp20_;
			RygelMediaExportSqlOperator* _tmp21_;
			_tmp14_ = exp;
			_tmp15_ = ((RygelSearchExpression*) _tmp14_)->operand2;
			_tmp16_ = g_new0 (GValue, 1);
			g_value_init (_tmp16_, G_TYPE_STRING);
			g_value_set_string (_tmp16_, (const gchar*) _tmp15_);
			__vala_GValue_free0 (v);
			v = _tmp16_;
			_tmp17_ = exp;
			_tmp18_ = ((RygelSearchExpression*) _tmp17_)->op;
			_tmp19_ = column;
			_tmp20_ = collate;
			_tmp21_ = rygel_media_export_sql_operator_new_from_search_criteria_op (GPOINTER_TO_INT (_tmp18_), _tmp19_, _tmp20_);
			_g_object_unref0 (operator);
			operator = _tmp21_;
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_CONTAINS:
		{
			const gchar* _tmp22_;
			RygelMediaExportSqlFunction* _tmp23_;
			RygelRelationalExpression* _tmp24_;
			gconstpointer _tmp25_;
			GValue* _tmp26_ = NULL;
			_tmp22_ = column;
			_tmp23_ = rygel_media_export_sql_function_new ("contains", _tmp22_);
			_g_object_unref0 (operator);
			operator = (RygelMediaExportSqlOperator*) _tmp23_;
			_tmp24_ = exp;
			_tmp25_ = ((RygelSearchExpression*) _tmp24_)->operand2;
			_tmp26_ = g_new0 (GValue, 1);
			g_value_init (_tmp26_, G_TYPE_STRING);
			g_value_set_string (_tmp26_, (const gchar*) _tmp25_);
			__vala_GValue_free0 (v);
			v = _tmp26_;
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_DOES_NOT_CONTAIN:
		{
			const gchar* _tmp27_;
			RygelMediaExportSqlFunction* _tmp28_;
			RygelRelationalExpression* _tmp29_;
			gconstpointer _tmp30_;
			GValue* _tmp31_ = NULL;
			_tmp27_ = column;
			_tmp28_ = rygel_media_export_sql_function_new ("NOT contains", _tmp27_);
			_g_object_unref0 (operator);
			operator = (RygelMediaExportSqlOperator*) _tmp28_;
			_tmp29_ = exp;
			_tmp30_ = ((RygelSearchExpression*) _tmp29_)->operand2;
			_tmp31_ = g_new0 (GValue, 1);
			g_value_init (_tmp31_, G_TYPE_STRING);
			g_value_set_string (_tmp31_, (const gchar*) _tmp30_);
			__vala_GValue_free0 (v);
			v = _tmp31_;
			break;
		}
		case GUPNP_SEARCH_CRITERIA_OP_DERIVED_FROM:
		{
			const gchar* _tmp32_;
			RygelMediaExportSqlOperator* _tmp33_;
			RygelRelationalExpression* _tmp34_;
			gconstpointer _tmp35_;
			gchar* _tmp36_ = NULL;
			GValue* _tmp37_ = NULL;
			_tmp32_ = column;
			_tmp33_ = rygel_media_export_sql_operator_new ("LIKE", _tmp32_, "");
			_g_object_unref0 (operator);
			operator = _tmp33_;
			_tmp34_ = exp;
			_tmp35_ = ((RygelSearchExpression*) _tmp34_)->operand2;
			_tmp36_ = g_strdup_printf ("%s%%", (const gchar*) _tmp35_);
			_tmp37_ = g_new0 (GValue, 1);
			g_value_init (_tmp37_, G_TYPE_STRING);
			g_value_take_string (_tmp37_, _tmp36_);
			__vala_GValue_free0 (v);
			v = _tmp37_;
			break;
		}
		default:
		{
			RygelRelationalExpression* _tmp38_;
			gconstpointer _tmp39_;
			_tmp38_ = exp;
			_tmp39_ = ((RygelSearchExpression*) _tmp38_)->op;
			g_warning ("rygel-media-export-media-cache.vala:826: Unsupported op %d", (gint) GPOINTER_TO_INT (_tmp39_));
			result = NULL;
			_g_object_unref0 (operator);
			_g_free0 (column);
			_g_free0 (collate);
			__vala_GValue_free0 (v);
			return result;
		}
	}
	_tmp40_ = v;
	if (_tmp40_ != NULL) {
		GValueArray* _tmp41_;
		GValue* _tmp42_;
		GValue _tmp43_;
		_tmp41_ = args;
		_tmp42_ = v;
		_tmp43_ = *_tmp42_;
		g_value_array_append (_tmp41_, &_tmp43_);
	}
	_tmp44_ = operator;
	_tmp45_ = rygel_media_export_sql_operator_to_string (_tmp44_);
	result = _tmp45_;
	_g_object_unref0 (operator);
	_g_free0 (column);
	_g_free0 (collate);
	__vala_GValue_free0 (v);
	return result;
}


static RygelMediaExportDatabaseCursor* rygel_media_export_media_cache_exec_cursor (RygelMediaExportMediaCache* self, RygelMediaExportSQLString id, GValue* values, int values_length1, GError** error) {
	RygelMediaExportDatabaseCursor* result = NULL;
	RygelMediaExportDatabase* _tmp0_;
	RygelMediaExportSQLFactory* _tmp1_;
	RygelMediaExportSQLString _tmp2_;
	const gchar* _tmp3_ = NULL;
	GValue* _tmp4_;
	gint _tmp4__length1;
	RygelMediaExportDatabaseCursor* _tmp5_ = NULL;
	RygelMediaExportDatabaseCursor* _tmp6_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = self->priv->sql;
	_tmp2_ = id;
	_tmp3_ = rygel_media_export_sql_factory_make (_tmp1_, _tmp2_);
	_tmp4_ = values;
	_tmp4__length1 = values_length1;
	_tmp5_ = rygel_media_export_database_exec_cursor (_tmp0_, _tmp3_, _tmp4_, _tmp4__length1, &_inner_error_);
	_tmp6_ = _tmp5_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			return NULL;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return NULL;
		}
	}
	result = _tmp6_;
	return result;
}


static gint rygel_media_export_media_cache_query_value (RygelMediaExportMediaCache* self, RygelMediaExportSQLString id, GValue* values, int values_length1, GError** error) {
	gint result = 0;
	RygelMediaExportDatabase* _tmp0_;
	RygelMediaExportSQLFactory* _tmp1_;
	RygelMediaExportSQLString _tmp2_;
	const gchar* _tmp3_ = NULL;
	GValue* _tmp4_;
	gint _tmp4__length1;
	gint _tmp5_ = 0;
	gint _tmp6_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->db;
	_tmp1_ = self->priv->sql;
	_tmp2_ = id;
	_tmp3_ = rygel_media_export_sql_factory_make (_tmp1_, _tmp2_);
	_tmp4_ = values;
	_tmp4__length1 = values_length1;
	_tmp5_ = rygel_media_export_database_query_value (_tmp0_, _tmp3_, _tmp4_, _tmp4__length1, &_inner_error_);
	_tmp6_ = _tmp5_;
	if (_inner_error_ != NULL) {
		if (_inner_error_->domain == RYGEL_MEDIA_EXPORT_DATABASE_ERROR) {
			g_propagate_error (error, _inner_error_);
			return 0;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
			g_clear_error (&_inner_error_);
			return 0;
		}
	}
	result = _tmp6_;
	return result;
}


static void rygel_media_export_media_cache_class_init (RygelMediaExportMediaCacheClass * klass) {
	rygel_media_export_media_cache_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelMediaExportMediaCachePrivate));
	G_OBJECT_CLASS (klass)->finalize = rygel_media_export_media_cache_finalize;
}


static void rygel_media_export_media_cache_instance_init (RygelMediaExportMediaCache * self) {
	self->priv = RYGEL_MEDIA_EXPORT_MEDIA_CACHE_GET_PRIVATE (self);
}


static void rygel_media_export_media_cache_finalize (GObject* obj) {
	RygelMediaExportMediaCache * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_MEDIA_CACHE, RygelMediaExportMediaCache);
	_g_object_unref0 (self->priv->db);
	_g_object_unref0 (self->priv->factory);
	_g_object_unref0 (self->priv->sql);
	_g_object_unref0 (self->priv->exists_cache);
	G_OBJECT_CLASS (rygel_media_export_media_cache_parent_class)->finalize (obj);
}


/**
 * Persistent storage of media objects
 *
 *  MediaExportDB is a sqlite3 backed persistent storage of media objects
 */
GType rygel_media_export_media_cache_get_type (void) {
	static volatile gsize rygel_media_export_media_cache_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_media_cache_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportMediaCacheClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_media_cache_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportMediaCache), 0, (GInstanceInitFunc) rygel_media_export_media_cache_instance_init, NULL };
		GType rygel_media_export_media_cache_type_id;
		rygel_media_export_media_cache_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelMediaExportMediaCache", &g_define_type_info, 0);
		g_once_init_leave (&rygel_media_export_media_cache_type_id__volatile, rygel_media_export_media_cache_type_id);
	}
	return rygel_media_export_media_cache_type_id__volatile;
}



