/* rygel-media-export-media-cache.c generated by valac 0.16.1, 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 __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_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_MUSIC_ITEM (rygel_media_export_music_item_get_type ())
#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItem))
#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItemClass))
#define RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM))
#define RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM))
#define RYGEL_MEDIA_EXPORT_MUSIC_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_MUSIC_ITEM, RygelMediaExportMusicItemClass))

typedef struct _RygelMediaExportMusicItem RygelMediaExportMusicItem;
typedef struct _RygelMediaExportMusicItemClass RygelMediaExportMusicItemClass;
typedef struct _RygelMediaExportMusicItemPrivate RygelMediaExportMusicItemPrivate;

#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 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;
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

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,
	RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_DISC
} RygelMediaExportDetailColumn;

struct _RygelMediaExportMusicItem {
	RygelMusicItem parent_instance;
	RygelMediaExportMusicItemPrivate * priv;
	gint disc;
};

struct _RygelMediaExportMusicItemClass {
	RygelMusicItemClass parent_class;
};


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, const gchar* sort_criteria, glong offset, glong max_count, GError** error);
static gchar* rygel_media_export_media_cache_translate_sort_criteria (RygelMediaExportMediaCache* self, const gchar* sort_criteria);
RygelMediaExportDatabaseCursor* rygel_media_export_database_exec_cursor (RygelMediaExportDatabase* self, const gchar* sql, GValue* arguments, int arguments_length1, GError** error);
RygelMediaObjects* rygel_media_export_media_cache_get_objects_by_search_expression (RygelMediaExportMediaCache* self, RygelSearchExpression* expression, const gchar* container_id, const gchar* sort_criteria, 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, const gchar* sort_criteria, 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);
static GValue* _g_value_dup (GValue* self);
static void _vala_GValue_free (GValue* self);
gint rygel_media_export_database_query_value (RygelMediaExportDatabase* self, const gchar* sql, GValue* args, int args_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 "11"
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);
GType rygel_media_export_music_item_get_type (void) G_GNUC_CONST;
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);
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);
static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
static gint _vala_array_length (gpointer array);


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 (RYGEL_IS_MEDIA_CONTAINER (_tmp11_) ? ((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_ = !RYGEL_IS_MEDIA_CONTAINER (_tmp4_);
	} 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 (RYGEL_IS_MEDIA_CONTAINER (_tmp8_) ? ((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;
	gint64 _tmp23_;
	gint64 _tmp24_;
	sqlite3_stmt* _tmp25_;
	gint64 _tmp26_ = 0LL;
	sqlite3_stmt* _tmp27_;
	gint _tmp28_ = 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_ = _vala_timestamp;
	_tmp24_ = G_MAXINT64;
	if (_tmp23_ == _tmp24_) {
		_vala_timestamp = (gint64) 0;
	}
	_tmp25_ = statement;
	_tmp26_ = sqlite3_column_int64 (_tmp25_, 2);
	_vala_size = _tmp26_;
	_tmp27_ = statement;
	_tmp28_ = sqlite3_column_int (_tmp27_, 0);
	result = _tmp28_ == 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, const gchar* sort_criteria, 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_;
	RygelMediaExportSQLFactory* _tmp9_;
	const gchar* _tmp10_ = NULL;
	gchar* _tmp11_;
	gchar* sql;
	const gchar* _tmp12_;
	gchar* _tmp13_ = NULL;
	gchar* sort_order;
	RygelMediaExportDatabase* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	gchar* _tmp17_ = NULL;
	gchar* _tmp18_;
	GValue* _tmp19_;
	gint _tmp19__length1;
	RygelMediaExportDatabaseCursor* _tmp20_ = NULL;
	RygelMediaExportDatabaseCursor* _tmp21_;
	RygelMediaExportDatabaseCursor* cursor;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (container != NULL, NULL);
	g_return_val_if_fail (sort_criteria != 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_ = self->priv->sql;
	_tmp10_ = rygel_media_export_sql_factory_make (_tmp9_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_CHILDREN);
	_tmp11_ = g_strdup (_tmp10_);
	sql = _tmp11_;
	_tmp12_ = sort_criteria;
	_tmp13_ = rygel_media_export_media_cache_translate_sort_criteria (self, _tmp12_);
	sort_order = _tmp13_;
	_tmp14_ = self->priv->db;
	_tmp15_ = sql;
	_tmp16_ = sort_order;
	_tmp17_ = g_strdup_printf (_tmp15_, _tmp16_);
	_tmp18_ = _tmp17_;
	_tmp19_ = values;
	_tmp19__length1 = values_length1;
	_tmp20_ = rygel_media_export_database_exec_cursor (_tmp14_, _tmp18_, _tmp19_, _tmp19__length1, &_inner_error_);
	_tmp21_ = _tmp20_;
	_g_free0 (_tmp18_);
	cursor = _tmp21_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (sort_order);
		_g_free0 (sql);
		values = (_vala_GValue_array_free (values, values_length1), NULL);
		_g_object_unref0 (children);
		return NULL;
	}
	{
		RygelMediaExportDatabaseCursor* _tmp22_;
		RygelMediaExportDatabaseCursorIterator* _tmp23_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp22_ = cursor;
		_tmp23_ = rygel_media_export_database_cursor_iterator (_tmp22_);
		_statement_it = _tmp23_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp24_;
			gboolean _tmp25_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp26_;
			sqlite3_stmt* _tmp27_ = NULL;
			sqlite3_stmt* statement;
			RygelMediaObjects* _tmp28_;
			RygelMediaContainer* _tmp29_;
			sqlite3_stmt* _tmp30_;
			RygelMediaObject* _tmp31_ = NULL;
			RygelMediaObject* _tmp32_;
			RygelMediaObjects* _tmp33_;
			gpointer _tmp34_ = NULL;
			RygelMediaObject* _tmp35_;
			RygelMediaContainer* _tmp36_;
			_tmp24_ = _statement_it;
			_tmp25_ = rygel_media_export_database_cursor_iterator_next (_tmp24_);
			if (!_tmp25_) {
				break;
			}
			_tmp26_ = _statement_it;
			_tmp27_ = rygel_media_export_database_cursor_iterator_get (_tmp26_, &_inner_error_);
			statement = _tmp27_;
			if (_inner_error_ != NULL) {
				g_propagate_error (error, _inner_error_);
				_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
				_g_object_unref0 (cursor);
				_g_free0 (sort_order);
				_g_free0 (sql);
				values = (_vala_GValue_array_free (values, values_length1), NULL);
				_g_object_unref0 (children);
				return NULL;
			}
			_tmp28_ = children;
			_tmp29_ = container;
			_tmp30_ = statement;
			_tmp31_ = rygel_media_export_media_cache_get_object_from_statement (self, _tmp29_, _tmp30_);
			_tmp32_ = _tmp31_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp28_, _tmp32_);
			_g_object_unref0 (_tmp32_);
			_tmp33_ = children;
			_tmp34_ = gee_abstract_list_last ((GeeAbstractList*) _tmp33_);
			_tmp35_ = (RygelMediaObject*) _tmp34_;
			_tmp36_ = container;
			rygel_media_object_set_parent_ref (_tmp35_, _tmp36_);
			_g_object_unref0 (_tmp35_);
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	result = children;
	_g_object_unref0 (cursor);
	_g_free0 (sort_order);
	_g_free0 (sql);
	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, const gchar* sort_criteria, 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 _tmp9_;
	guint _tmp10_ = 0U;
	guint max_objects;
	const gchar* _tmp11_;
	GValueArray* _tmp12_;
	const gchar* _tmp13_;
	glong _tmp14_ = 0L;
	glong _tmp15_;
	const gchar* _tmp16_;
	GValueArray* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	guint _tmp20_;
	guint _tmp21_;
	RygelMediaObjects* _tmp22_ = NULL;
	RygelMediaObjects* _tmp23_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (sort_criteria != 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:223: Original search: %s", _tmp7_);
		_g_free0 (_tmp7_);
		_tmp8_ = filter;
		g_debug ("rygel-media-export-media-cache.vala:224: Parsed search expression: %s", _tmp8_);
	}
	_tmp9_ = max_count;
	_tmp10_ = rygel_media_export_media_cache_modify_limit (self, _tmp9_);
	max_objects = _tmp10_;
	_tmp11_ = filter;
	_tmp12_ = args;
	_tmp13_ = container_id;
	_tmp14_ = rygel_media_export_media_cache_get_object_count_by_filter (self, _tmp11_, _tmp12_, _tmp13_, &_inner_error_);
	_tmp15_ = _tmp14_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (filter);
		_g_value_array_free0 (args);
		return NULL;
	}
	_vala_total_matches = (guint) _tmp15_;
	_tmp16_ = filter;
	_tmp17_ = args;
	_tmp18_ = container_id;
	_tmp19_ = sort_criteria;
	_tmp20_ = offset;
	_tmp21_ = max_objects;
	_tmp22_ = rygel_media_export_media_cache_get_objects_by_filter (self, _tmp16_, _tmp17_, _tmp18_, _tmp19_, (glong) _tmp20_, (glong) _tmp21_, &_inner_error_);
	_tmp23_ = _tmp22_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (filter);
		_g_value_array_free0 (args);
		return NULL;
	}
	result = _tmp23_;
	_g_free0 (filter);
	_g_value_array_free0 (args);
	if (total_matches) {
		*total_matches = _vala_total_matches;
	}
	return result;
}


static GValue* _g_value_dup (GValue* self) {
	return g_boxed_copy (G_TYPE_VALUE, self);
}


static gpointer __g_value_dup0 (gpointer self) {
	return self ? _g_value_dup (self) : NULL;
}


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


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* _tmp29_;
	GValueArray* _tmp30_;
	const gchar* _tmp31_;
	glong _tmp32_ = 0L;
	glong _tmp33_;
	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:248: Original search: %s", _tmp7_);
		_g_free0 (_tmp7_);
		_tmp8_ = filter;
		g_debug ("rygel-media-export-media-cache.vala:249: Parsed search expression: %s", _tmp8_);
	}
	{
		gint i;
		i = 0;
		{
			gboolean _tmp9_;
			_tmp9_ = TRUE;
			while (TRUE) {
				gboolean _tmp10_;
				gint _tmp12_;
				GValueArray* _tmp13_;
				guint _tmp14_;
				GValueArray* _tmp15_;
				gint _tmp16_;
				GValue* _tmp17_ = NULL;
				GValue* _tmp18_;
				GValue* arg;
				gchar* _tmp19_ = NULL;
				GValue* _tmp20_;
				gboolean _tmp21_ = FALSE;
				gint _tmp27_;
				const gchar* _tmp28_;
				_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_ = args;
				_tmp16_ = i;
				_tmp17_ = g_value_array_get_nth (_tmp15_, (guint) _tmp16_);
				_tmp18_ = __g_value_dup0 (_tmp17_);
				arg = _tmp18_;
				_tmp20_ = arg;
				_tmp21_ = G_VALUE_HOLDS (_tmp20_, G_TYPE_STRING);
				if (_tmp21_) {
					GValue* _tmp22_;
					const gchar* _tmp23_ = NULL;
					gchar* _tmp24_;
					_tmp22_ = arg;
					_tmp23_ = g_value_get_string (_tmp22_);
					_tmp24_ = g_strdup (_tmp23_);
					_g_free0 (_tmp19_);
					_tmp19_ = _tmp24_;
				} else {
					GValue* _tmp25_;
					gchar* _tmp26_ = NULL;
					_tmp25_ = arg;
					_tmp26_ = g_strdup_value_contents (_tmp25_);
					_g_free0 (_tmp19_);
					_tmp19_ = _tmp26_;
				}
				_tmp27_ = i;
				_tmp28_ = _tmp19_;
				g_debug ("rygel-media-export-media-cache.vala:254: Arg %d: %s", _tmp27_, _tmp28_);
				_g_free0 (_tmp19_);
				__vala_GValue_free0 (arg);
			}
		}
	}
	_tmp29_ = filter;
	_tmp30_ = args;
	_tmp31_ = container_id;
	_tmp32_ = rygel_media_export_media_cache_get_object_count_by_filter (self, _tmp29_, _tmp30_, _tmp31_, &_inner_error_);
	_tmp33_ = _tmp32_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (filter);
		_g_value_array_free0 (args);
		return 0L;
	}
	result = _tmp33_;
	_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:274: 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, const gchar* sort_criteria, 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* _tmp31_;
	const gchar* _tmp36_;
	gchar* _tmp37_ = NULL;
	gchar* sort_order;
	RygelMediaExportDatabase* _tmp38_;
	const gchar* _tmp39_;
	const gchar* _tmp40_;
	const gchar* _tmp41_;
	gchar* _tmp42_ = NULL;
	gchar* _tmp43_;
	GValueArray* _tmp44_;
	GValue* _tmp45_;
	gint _tmp45__length1;
	RygelMediaExportDatabaseCursor* _tmp46_ = NULL;
	RygelMediaExportDatabaseCursor* _tmp47_;
	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);
	g_return_val_if_fail (sort_criteria != 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:301: Parameters to bind: %u", _tmp10_);
	{
		gint i;
		i = 0;
		{
			gboolean _tmp11_;
			_tmp11_ = TRUE;
			while (TRUE) {
				gboolean _tmp12_;
				gint _tmp14_;
				GValueArray* _tmp15_;
				guint _tmp16_;
				GValueArray* _tmp17_;
				gint _tmp18_;
				GValue* _tmp19_ = NULL;
				GValue* _tmp20_;
				GValue* arg;
				gchar* _tmp21_ = NULL;
				GValue* _tmp22_;
				gboolean _tmp23_ = FALSE;
				gint _tmp29_;
				const gchar* _tmp30_;
				_tmp12_ = _tmp11_;
				if (!_tmp12_) {
					gint _tmp13_;
					_tmp13_ = i;
					i = _tmp13_ + 1;
				}
				_tmp11_ = FALSE;
				_tmp14_ = i;
				_tmp15_ = args;
				_tmp16_ = _tmp15_->n_values;
				if (!(((guint) _tmp14_) < _tmp16_)) {
					break;
				}
				_tmp17_ = args;
				_tmp18_ = i;
				_tmp19_ = g_value_array_get_nth (_tmp17_, (guint) _tmp18_);
				_tmp20_ = __g_value_dup0 (_tmp19_);
				arg = _tmp20_;
				_tmp22_ = arg;
				_tmp23_ = G_VALUE_HOLDS (_tmp22_, G_TYPE_STRING);
				if (_tmp23_) {
					GValue* _tmp24_;
					const gchar* _tmp25_ = NULL;
					gchar* _tmp26_;
					_tmp24_ = arg;
					_tmp25_ = g_value_get_string (_tmp24_);
					_tmp26_ = g_strdup (_tmp25_);
					_g_free0 (_tmp21_);
					_tmp21_ = _tmp26_;
				} else {
					GValue* _tmp27_;
					gchar* _tmp28_ = NULL;
					_tmp27_ = arg;
					_tmp28_ = g_strdup_value_contents (_tmp27_);
					_g_free0 (_tmp21_);
					_tmp21_ = _tmp28_;
				}
				_tmp29_ = i;
				_tmp30_ = _tmp21_;
				g_debug ("rygel-media-export-media-cache.vala:304: Arg %d: %s", _tmp29_, _tmp30_);
				_g_free0 (_tmp21_);
				__vala_GValue_free0 (arg);
			}
		}
	}
	_tmp31_ = container_id;
	if (_tmp31_ != NULL) {
		RygelMediaExportSQLFactory* _tmp32_;
		const gchar* _tmp33_ = NULL;
		_tmp32_ = self->priv->sql;
		_tmp33_ = rygel_media_export_sql_factory_make (_tmp32_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER_WITH_ANCESTOR);
		sql = _tmp33_;
	} else {
		RygelMediaExportSQLFactory* _tmp34_;
		const gchar* _tmp35_ = NULL;
		_tmp34_ = self->priv->sql;
		_tmp35_ = rygel_media_export_sql_factory_make (_tmp34_, RYGEL_MEDIA_EXPORT_SQL_STRING_GET_OBJECTS_BY_FILTER);
		sql = _tmp35_;
	}
	_tmp36_ = sort_criteria;
	_tmp37_ = rygel_media_export_media_cache_translate_sort_criteria (self, _tmp36_);
	sort_order = _tmp37_;
	_tmp38_ = self->priv->db;
	_tmp39_ = sql;
	_tmp40_ = filter;
	_tmp41_ = sort_order;
	_tmp42_ = g_strdup_printf (_tmp39_, _tmp40_, _tmp41_);
	_tmp43_ = _tmp42_;
	_tmp44_ = args;
	_tmp45_ = _tmp44_->values;
	_tmp45__length1 = (gint) _tmp44_->n_values;
	_tmp46_ = rygel_media_export_database_exec_cursor (_tmp38_, _tmp43_, _tmp45_, _tmp45__length1, &_inner_error_);
	_tmp47_ = _tmp46_;
	_g_free0 (_tmp43_);
	cursor = _tmp47_;
	if (_inner_error_ != NULL) {
		g_propagate_error (error, _inner_error_);
		_g_free0 (sort_order);
		_g_object_unref0 (parent);
		G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
		_g_object_unref0 (children);
		return NULL;
	}
	{
		RygelMediaExportDatabaseCursor* _tmp48_;
		RygelMediaExportDatabaseCursorIterator* _tmp49_ = NULL;
		RygelMediaExportDatabaseCursorIterator* _statement_it;
		_tmp48_ = cursor;
		_tmp49_ = rygel_media_export_database_cursor_iterator (_tmp48_);
		_statement_it = _tmp49_;
		while (TRUE) {
			RygelMediaExportDatabaseCursorIterator* _tmp50_;
			gboolean _tmp51_ = FALSE;
			RygelMediaExportDatabaseCursorIterator* _tmp52_;
			sqlite3_stmt* _tmp53_ = NULL;
			sqlite3_stmt* statement;
			sqlite3_stmt* _tmp54_;
			const gchar* _tmp55_ = NULL;
			const gchar* parent_id;
			gboolean _tmp56_ = FALSE;
			RygelMediaContainer* _tmp57_;
			gboolean _tmp61_;
			RygelMediaContainer* _tmp66_;
			_tmp50_ = _statement_it;
			_tmp51_ = rygel_media_export_database_cursor_iterator_next (_tmp50_);
			if (!_tmp51_) {
				break;
			}
			_tmp52_ = _statement_it;
			_tmp53_ = rygel_media_export_database_cursor_iterator_get (_tmp52_, &_inner_error_);
			statement = _tmp53_;
			if (_inner_error_ != NULL) {
				g_propagate_error (error, _inner_error_);
				_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
				_g_object_unref0 (cursor);
				_g_free0 (sort_order);
				_g_object_unref0 (parent);
				G_IS_VALUE (&v) ? (g_value_unset (&v), NULL) : NULL;
				_g_object_unref0 (children);
				return NULL;
			}
			_tmp54_ = statement;
			_tmp55_ = sqlite3_column_text (_tmp54_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_PARENT);
			parent_id = _tmp55_;
			_tmp57_ = parent;
			if (_tmp57_ == NULL) {
				_tmp56_ = TRUE;
			} else {
				const gchar* _tmp58_;
				RygelMediaContainer* _tmp59_;
				const gchar* _tmp60_;
				_tmp58_ = parent_id;
				_tmp59_ = parent;
				_tmp60_ = ((RygelMediaObject*) _tmp59_)->id;
				_tmp56_ = g_strcmp0 (_tmp58_, _tmp60_) != 0;
			}
			_tmp61_ = _tmp56_;
			if (_tmp61_) {
				RygelNullContainer* _tmp62_;
				RygelMediaContainer* _tmp63_;
				const gchar* _tmp64_;
				gchar* _tmp65_;
				_tmp62_ = rygel_null_container_new ();
				_g_object_unref0 (parent);
				parent = (RygelMediaContainer*) _tmp62_;
				_tmp63_ = parent;
				_tmp64_ = parent_id;
				_tmp65_ = g_strdup (_tmp64_);
				_g_free0 (((RygelMediaObject*) _tmp63_)->id);
				((RygelMediaObject*) _tmp63_)->id = _tmp65_;
			}
			_tmp66_ = parent;
			if (_tmp66_ != NULL) {
				RygelMediaObjects* _tmp67_;
				RygelMediaContainer* _tmp68_;
				sqlite3_stmt* _tmp69_;
				RygelMediaObject* _tmp70_ = NULL;
				RygelMediaObject* _tmp71_;
				RygelMediaObjects* _tmp72_;
				gpointer _tmp73_ = NULL;
				RygelMediaObject* _tmp74_;
				RygelMediaContainer* _tmp75_;
				_tmp67_ = children;
				_tmp68_ = parent;
				_tmp69_ = statement;
				_tmp70_ = rygel_media_export_media_cache_get_object_from_statement (self, _tmp68_, _tmp69_);
				_tmp71_ = _tmp70_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp67_, _tmp71_);
				_g_object_unref0 (_tmp71_);
				_tmp72_ = children;
				_tmp73_ = gee_abstract_list_last ((GeeAbstractList*) _tmp72_);
				_tmp74_ = (RygelMediaObject*) _tmp73_;
				_tmp75_ = parent;
				rygel_media_object_set_parent_ref (_tmp74_, _tmp75_);
				_g_object_unref0 (_tmp74_);
			} else {
				sqlite3_stmt* _tmp76_;
				const gchar* _tmp77_ = NULL;
				const gchar* _tmp78_;
				_tmp76_ = statement;
				_tmp77_ = sqlite3_column_text (_tmp76_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_ID);
				_tmp78_ = parent_id;
				g_warning ("Inconsistent database: item %s " "has no parent %s", _tmp77_, _tmp78_);
			}
		}
		_rygel_media_export_database_cursor_iterator_unref0 (_statement_it);
	}
	result = children;
	_g_object_unref0 (cursor);
	_g_free0 (sort_order);
	_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:344: 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:347: %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:402: 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:476: %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:482: 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:490: 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:496: 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_ = {0};
	GValue* _tmp32_ = NULL;
	GValue* values;
	gint values_length1;
	gint _values_size_;
	RygelMediaItem* _tmp33_;
	RygelMediaItem* _tmp89_;
	RygelMediaExportDatabase* _tmp118_;
	RygelMediaExportSQLFactory* _tmp119_;
	const gchar* _tmp120_ = NULL;
	GValue* _tmp121_;
	gint _tmp121__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_);
	g_value_init (&_tmp31_, G_TYPE_INT);
	g_value_set_int (&_tmp31_, -1);
	_tmp32_ = g_new0 (GValue, 19);
	_tmp32_[0] = _tmp3_;
	_tmp32_[1] = _tmp6_;
	_tmp32_[2] = _tmp7_;
	_tmp32_[3] = _tmp8_;
	_tmp32_[4] = _tmp11_;
	_tmp32_[5] = _tmp12_;
	_tmp32_[6] = _tmp13_;
	_tmp32_[7] = _tmp16_;
	_tmp32_[8] = _tmp17_;
	_tmp32_[9] = _tmp18_;
	_tmp32_[10] = _tmp19_;
	_tmp32_[11] = _tmp20_;
	_tmp32_[12] = _tmp21_;
	_tmp32_[13] = _tmp22_;
	_tmp32_[14] = _tmp23_;
	_tmp32_[15] = _tmp26_;
	_tmp32_[16] = _tmp29_;
	_tmp32_[17] = _tmp30_;
	_tmp32_[18] = _tmp31_;
	values = _tmp32_;
	values_length1 = 19;
	_values_size_ = values_length1;
	_tmp33_ = item;
	if (RYGEL_IS_AUDIO_ITEM (_tmp33_)) {
		RygelMediaItem* _tmp34_;
		RygelAudioItem* _tmp35_;
		RygelAudioItem* audio_item;
		GValue* _tmp36_;
		gint _tmp36__length1;
		RygelAudioItem* _tmp37_;
		glong _tmp38_;
		GValue _tmp39_ = {0};
		GValue _tmp40_;
		GValue* _tmp41_;
		gint _tmp41__length1;
		RygelAudioItem* _tmp42_;
		gint _tmp43_;
		GValue _tmp44_ = {0};
		GValue _tmp45_;
		GValue* _tmp46_;
		gint _tmp46__length1;
		RygelAudioItem* _tmp47_;
		gint _tmp48_;
		GValue _tmp49_ = {0};
		GValue _tmp50_;
		GValue* _tmp51_;
		gint _tmp51__length1;
		RygelAudioItem* _tmp52_;
		gint _tmp53_;
		GValue _tmp54_ = {0};
		GValue _tmp55_;
		GValue* _tmp56_;
		gint _tmp56__length1;
		RygelAudioItem* _tmp57_;
		gint _tmp58_;
		GValue _tmp59_ = {0};
		GValue _tmp60_;
		RygelMediaItem* _tmp61_;
		_tmp34_ = item;
		_tmp35_ = _g_object_ref0 (RYGEL_IS_AUDIO_ITEM (_tmp34_) ? ((RygelAudioItem*) _tmp34_) : NULL);
		audio_item = _tmp35_;
		_tmp36_ = values;
		_tmp36__length1 = values_length1;
		_tmp37_ = audio_item;
		_tmp38_ = _tmp37_->duration;
		g_value_init (&_tmp39_, G_TYPE_LONG);
		g_value_set_long (&_tmp39_, _tmp38_);
		G_IS_VALUE (&_tmp36_[14]) ? (g_value_unset (&_tmp36_[14]), NULL) : NULL;
		_tmp36_[14] = _tmp39_;
		_tmp40_ = _tmp36_[14];
		_tmp41_ = values;
		_tmp41__length1 = values_length1;
		_tmp42_ = audio_item;
		_tmp43_ = _tmp42_->bitrate;
		g_value_init (&_tmp44_, G_TYPE_INT);
		g_value_set_int (&_tmp44_, _tmp43_);
		G_IS_VALUE (&_tmp41_[8]) ? (g_value_unset (&_tmp41_[8]), NULL) : NULL;
		_tmp41_[8] = _tmp44_;
		_tmp45_ = _tmp41_[8];
		_tmp46_ = values;
		_tmp46__length1 = values_length1;
		_tmp47_ = audio_item;
		_tmp48_ = _tmp47_->sample_freq;
		g_value_init (&_tmp49_, G_TYPE_INT);
		g_value_set_int (&_tmp49_, _tmp48_);
		G_IS_VALUE (&_tmp46_[9]) ? (g_value_unset (&_tmp46_[9]), NULL) : NULL;
		_tmp46_[9] = _tmp49_;
		_tmp50_ = _tmp46_[9];
		_tmp51_ = values;
		_tmp51__length1 = values_length1;
		_tmp52_ = audio_item;
		_tmp53_ = _tmp52_->bits_per_sample;
		g_value_init (&_tmp54_, G_TYPE_INT);
		g_value_set_int (&_tmp54_, _tmp53_);
		G_IS_VALUE (&_tmp51_[10]) ? (g_value_unset (&_tmp51_[10]), NULL) : NULL;
		_tmp51_[10] = _tmp54_;
		_tmp55_ = _tmp51_[10];
		_tmp56_ = values;
		_tmp56__length1 = values_length1;
		_tmp57_ = audio_item;
		_tmp58_ = _tmp57_->channels;
		g_value_init (&_tmp59_, G_TYPE_INT);
		g_value_set_int (&_tmp59_, _tmp58_);
		G_IS_VALUE (&_tmp56_[11]) ? (g_value_unset (&_tmp56_[11]), NULL) : NULL;
		_tmp56_[11] = _tmp59_;
		_tmp60_ = _tmp56_[11];
		_tmp61_ = item;
		if (RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM (_tmp61_)) {
			RygelMediaItem* _tmp62_;
			RygelMediaExportMusicItem* _tmp63_;
			RygelMediaExportMusicItem* music_item;
			GValue* _tmp64_;
			gint _tmp64__length1;
			RygelMediaExportMusicItem* _tmp65_;
			const gchar* _tmp66_;
			GValue _tmp67_ = {0};
			GValue _tmp68_;
			GValue* _tmp69_;
			gint _tmp69__length1;
			RygelMediaExportMusicItem* _tmp70_;
			const gchar* _tmp71_;
			GValue _tmp72_ = {0};
			GValue _tmp73_;
			GValue* _tmp74_;
			gint _tmp74__length1;
			RygelMediaExportMusicItem* _tmp75_;
			const gchar* _tmp76_;
			GValue _tmp77_ = {0};
			GValue _tmp78_;
			GValue* _tmp79_;
			gint _tmp79__length1;
			RygelMediaExportMusicItem* _tmp80_;
			gint _tmp81_;
			GValue _tmp82_ = {0};
			GValue _tmp83_;
			GValue* _tmp84_;
			gint _tmp84__length1;
			RygelMediaExportMusicItem* _tmp85_;
			gint _tmp86_;
			GValue _tmp87_ = {0};
			GValue _tmp88_;
			_tmp62_ = item;
			_tmp63_ = _g_object_ref0 (RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM (_tmp62_) ? ((RygelMediaExportMusicItem*) _tmp62_) : NULL);
			music_item = _tmp63_;
			_tmp64_ = values;
			_tmp64__length1 = values_length1;
			_tmp65_ = music_item;
			_tmp66_ = ((RygelMusicItem*) _tmp65_)->artist;
			g_value_init (&_tmp67_, G_TYPE_STRING);
			g_value_set_string (&_tmp67_, _tmp66_);
			G_IS_VALUE (&_tmp64_[5]) ? (g_value_unset (&_tmp64_[5]), NULL) : NULL;
			_tmp64_[5] = _tmp67_;
			_tmp68_ = _tmp64_[5];
			_tmp69_ = values;
			_tmp69__length1 = values_length1;
			_tmp70_ = music_item;
			_tmp71_ = ((RygelMusicItem*) _tmp70_)->album;
			g_value_init (&_tmp72_, G_TYPE_STRING);
			g_value_set_string (&_tmp72_, _tmp71_);
			G_IS_VALUE (&_tmp69_[6]) ? (g_value_unset (&_tmp69_[6]), NULL) : NULL;
			_tmp69_[6] = _tmp72_;
			_tmp73_ = _tmp69_[6];
			_tmp74_ = values;
			_tmp74__length1 = values_length1;
			_tmp75_ = music_item;
			_tmp76_ = ((RygelMusicItem*) _tmp75_)->genre;
			g_value_init (&_tmp77_, G_TYPE_STRING);
			g_value_set_string (&_tmp77_, _tmp76_);
			G_IS_VALUE (&_tmp74_[17]) ? (g_value_unset (&_tmp74_[17]), NULL) : NULL;
			_tmp74_[17] = _tmp77_;
			_tmp78_ = _tmp74_[17];
			_tmp79_ = values;
			_tmp79__length1 = values_length1;
			_tmp80_ = music_item;
			_tmp81_ = ((RygelMusicItem*) _tmp80_)->track_number;
			g_value_init (&_tmp82_, G_TYPE_INT);
			g_value_set_int (&_tmp82_, _tmp81_);
			G_IS_VALUE (&_tmp79_[12]) ? (g_value_unset (&_tmp79_[12]), NULL) : NULL;
			_tmp79_[12] = _tmp82_;
			_tmp83_ = _tmp79_[12];
			_tmp84_ = values;
			_tmp84__length1 = values_length1;
			_tmp85_ = music_item;
			_tmp86_ = _tmp85_->disc;
			g_value_init (&_tmp87_, G_TYPE_INT);
			g_value_set_int (&_tmp87_, _tmp86_);
			G_IS_VALUE (&_tmp84_[18]) ? (g_value_unset (&_tmp84_[18]), NULL) : NULL;
			_tmp84_[18] = _tmp87_;
			_tmp88_ = _tmp84_[18];
			_g_object_unref0 (music_item);
		}
		_g_object_unref0 (audio_item);
	}
	_tmp89_ = item;
	if (RYGEL_IS_VISUAL_ITEM (_tmp89_)) {
		RygelMediaItem* _tmp90_;
		RygelVisualItem* _tmp91_;
		RygelVisualItem* visual_item;
		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_;
		GValue* _tmp104_;
		gint _tmp104__length1;
		RygelVisualItem* _tmp105_;
		gint _tmp106_;
		gint _tmp107_;
		GValue _tmp108_ = {0};
		GValue _tmp109_;
		RygelMediaItem* _tmp110_;
		_tmp90_ = item;
		_tmp91_ = _g_object_ref0 (RYGEL_IS_VISUAL_ITEM (_tmp90_) ? ((RygelVisualItem*) _tmp90_) : NULL);
		visual_item = _tmp91_;
		_tmp92_ = values;
		_tmp92__length1 = values_length1;
		_tmp93_ = visual_item;
		_tmp94_ = rygel_visual_item_get_width (_tmp93_);
		_tmp95_ = _tmp94_;
		g_value_init (&_tmp96_, G_TYPE_INT);
		g_value_set_int (&_tmp96_, _tmp95_);
		G_IS_VALUE (&_tmp92_[2]) ? (g_value_unset (&_tmp92_[2]), NULL) : NULL;
		_tmp92_[2] = _tmp96_;
		_tmp97_ = _tmp92_[2];
		_tmp98_ = values;
		_tmp98__length1 = values_length1;
		_tmp99_ = visual_item;
		_tmp100_ = rygel_visual_item_get_height (_tmp99_);
		_tmp101_ = _tmp100_;
		g_value_init (&_tmp102_, G_TYPE_INT);
		g_value_set_int (&_tmp102_, _tmp101_);
		G_IS_VALUE (&_tmp98_[3]) ? (g_value_unset (&_tmp98_[3]), NULL) : NULL;
		_tmp98_[3] = _tmp102_;
		_tmp103_ = _tmp98_[3];
		_tmp104_ = values;
		_tmp104__length1 = values_length1;
		_tmp105_ = visual_item;
		_tmp106_ = rygel_visual_item_get_color_depth (_tmp105_);
		_tmp107_ = _tmp106_;
		g_value_init (&_tmp108_, G_TYPE_INT);
		g_value_set_int (&_tmp108_, _tmp107_);
		G_IS_VALUE (&_tmp104_[13]) ? (g_value_unset (&_tmp104_[13]), NULL) : NULL;
		_tmp104_[13] = _tmp108_;
		_tmp109_ = _tmp104_[13];
		_tmp110_ = item;
		if (RYGEL_IS_VIDEO_ITEM (_tmp110_)) {
			RygelMediaItem* _tmp111_;
			RygelVideoItem* _tmp112_;
			RygelVideoItem* video_item;
			GValue* _tmp113_;
			gint _tmp113__length1;
			RygelVideoItem* _tmp114_;
			const gchar* _tmp115_;
			GValue _tmp116_ = {0};
			GValue _tmp117_;
			_tmp111_ = item;
			_tmp112_ = _g_object_ref0 (RYGEL_IS_VIDEO_ITEM (_tmp111_) ? ((RygelVideoItem*) _tmp111_) : NULL);
			video_item = _tmp112_;
			_tmp113_ = values;
			_tmp113__length1 = values_length1;
			_tmp114_ = video_item;
			_tmp115_ = _tmp114_->author;
			g_value_init (&_tmp116_, G_TYPE_STRING);
			g_value_set_string (&_tmp116_, _tmp115_);
			G_IS_VALUE (&_tmp113_[5]) ? (g_value_unset (&_tmp113_[5]), NULL) : NULL;
			_tmp113_[5] = _tmp116_;
			_tmp117_ = _tmp113_[5];
			_g_object_unref0 (video_item);
		}
		_g_object_unref0 (visual_item);
	}
	_tmp118_ = self->priv->db;
	_tmp119_ = self->priv->sql;
	_tmp120_ = rygel_media_export_sql_factory_make (_tmp119_, RYGEL_MEDIA_EXPORT_SQL_STRING_SAVE_METADATA);
	_tmp121_ = values;
	_tmp121__length1 = values_length1;
	rygel_media_export_database_exec (_tmp118_, _tmp120_, _tmp121_, _tmp121__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 (RYGEL_IS_MEDIA_ITEM (_tmp0_)) {
		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:602: 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 (RYGEL_IS_MEDIA_CONTAINER (_tmp13_) ? ((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_, RYGEL_IS_MEDIA_ITEM (_tmp28_) ? ((RygelMediaItem*) _tmp28_) : NULL);
			_tmp29_ = uri;
			if (_tmp29_ != NULL) {
				RygelMediaObject* _tmp30_;
				const gchar* _tmp31_;
				_tmp30_ = object;
				_tmp31_ = uri;
				rygel_media_item_add_uri (RYGEL_IS_MEDIA_ITEM (_tmp30_) ? ((RygelMediaItem*) _tmp30_) : NULL, _tmp31_);
			}
			break;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
	_tmp32_ = object;
	if (_tmp32_ != NULL) {
		RygelMediaObject* _tmp33_;
		sqlite3_stmt* _tmp34_;
		gint64 _tmp35_ = 0LL;
		gboolean _tmp36_ = FALSE;
		RygelMediaObject* _tmp37_;
		guint64 _tmp38_;
		gint64 _tmp39_;
		gboolean _tmp41_;
		_tmp33_ = object;
		_tmp34_ = statement;
		_tmp35_ = sqlite3_column_int64 (_tmp34_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TIMESTAMP);
		_tmp33_->modified = (guint64) _tmp35_;
		_tmp37_ = object;
		_tmp38_ = _tmp37_->modified;
		_tmp39_ = G_MAXINT64;
		if (_tmp38_ == ((guint64) _tmp39_)) {
			RygelMediaObject* _tmp40_;
			_tmp40_ = object;
			_tmp36_ = RYGEL_IS_MEDIA_ITEM (_tmp40_);
		} else {
			_tmp36_ = FALSE;
		}
		_tmp41_ = _tmp36_;
		if (_tmp41_) {
			RygelMediaObject* _tmp42_;
			RygelMediaObject* _tmp43_;
			_tmp42_ = object;
			_tmp42_->modified = (guint64) 0;
			_tmp43_ = object;
			rygel_media_item_set_place_holder (RYGEL_IS_MEDIA_ITEM (_tmp43_) ? ((RygelMediaItem*) _tmp43_) : NULL, TRUE);
		}
	}
	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 (RYGEL_IS_AUDIO_ITEM (_tmp15_)) {
		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 (RYGEL_IS_AUDIO_ITEM (_tmp16_) ? ((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 (RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM (_tmp33_)) {
			RygelMediaItem* _tmp34_;
			RygelMediaExportMusicItem* _tmp35_;
			RygelMediaExportMusicItem* music_item;
			RygelMediaExportMusicItem* _tmp36_;
			sqlite3_stmt* _tmp37_;
			const gchar* _tmp38_ = NULL;
			gchar* _tmp39_;
			RygelMediaExportMusicItem* _tmp40_;
			sqlite3_stmt* _tmp41_;
			const gchar* _tmp42_ = NULL;
			gchar* _tmp43_;
			RygelMediaExportMusicItem* _tmp44_;
			sqlite3_stmt* _tmp45_;
			const gchar* _tmp46_ = NULL;
			gchar* _tmp47_;
			RygelMediaExportMusicItem* _tmp48_;
			sqlite3_stmt* _tmp49_;
			gint _tmp50_ = 0;
			RygelMediaExportMusicItem* _tmp51_;
			_tmp34_ = item;
			_tmp35_ = _g_object_ref0 (RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM (_tmp34_) ? ((RygelMediaExportMusicItem*) _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 (((RygelMusicItem*) _tmp36_)->artist);
			((RygelMusicItem*) _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 (((RygelMusicItem*) _tmp40_)->album);
			((RygelMusicItem*) _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 (((RygelMusicItem*) _tmp44_)->genre);
			((RygelMusicItem*) _tmp44_)->genre = _tmp47_;
			_tmp48_ = music_item;
			_tmp49_ = statement;
			_tmp50_ = sqlite3_column_int (_tmp49_, (gint) RYGEL_MEDIA_EXPORT_DETAIL_COLUMN_TRACK);
			((RygelMusicItem*) _tmp48_)->track_number = _tmp50_;
			_tmp51_ = music_item;
			rygel_music_item_lookup_album_art ((RygelMusicItem*) _tmp51_);
			_g_object_unref0 (music_item);
		}
		_g_object_unref0 (audio_item);
	}
	_tmp52_ = item;
	if (RYGEL_IS_VISUAL_ITEM (_tmp52_)) {
		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 (RYGEL_IS_VISUAL_ITEM (_tmp53_) ? ((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 (RYGEL_IS_VIDEO_ITEM (_tmp64_)) {
			RygelMediaItem* _tmp65_;
			RygelVideoItem* _tmp66_;
			RygelVideoItem* video_item;
			RygelVideoItem* _tmp67_;
			sqlite3_stmt* _tmp68_;
			const gchar* _tmp69_ = NULL;
			gchar* _tmp70_;
			_tmp65_ = item;
			_tmp66_ = _g_object_ref0 (RYGEL_IS_VIDEO_ITEM (_tmp65_) ? ((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 (RYGEL_IS_LOGICAL_EXPRESSION (_tmp2_)) {
		RygelSearchExpression* _tmp3_;
		GValueArray* _tmp4_;
		gchar* _tmp5_ = NULL;
		gchar* _tmp6_;
		_tmp3_ = expression;
		_tmp4_ = args;
		_tmp5_ = rygel_media_export_media_cache_logical_expression_to_sql (self, RYGEL_IS_LOGICAL_EXPRESSION (_tmp3_) ? ((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, RYGEL_IS_RELATIONAL_EXPRESSION (_tmp7_) ? ((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;
	static GQuark _tmp2_label13 = 0;
	static GQuark _tmp2_label14 = 0;
	gboolean _tmp21_;
	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 if (_tmp3_ == ((0 != _tmp2_label13) ? _tmp2_label13 : (_tmp2_label13 = g_quark_from_static_string ("upnp:originalTrackNumber")))) {
		switch (0) {
			default:
			{
				gchar* _tmp15_;
				_tmp15_ = g_strdup ("m.track");
				_g_free0 (column);
				column = _tmp15_;
				break;
			}
		}
	} else if (_tmp3_ == ((0 != _tmp2_label14) ? _tmp2_label14 : (_tmp2_label14 = g_quark_from_static_string ("rygel:originalVolumeNumber")))) {
		switch (0) {
			default:
			{
				gchar* _tmp16_;
				_tmp16_ = g_strdup ("m.disc");
				_g_free0 (column);
				column = _tmp16_;
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				const gchar* _tmp17_;
				gchar* _tmp18_ = NULL;
				gchar* message;
				const gchar* _tmp19_;
				GError* _tmp20_;
				_tmp17_ = operand;
				_tmp18_ = g_strdup_printf ("Unsupported column %s", _tmp17_);
				message = _tmp18_;
				_tmp19_ = message;
				_tmp20_ = g_error_new_literal (RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR, RYGEL_MEDIA_EXPORT_MEDIA_CACHE_ERROR_UNSUPPORTED_SEARCH, _tmp19_);
				_inner_error_ = _tmp20_;
				g_propagate_error (error, _inner_error_);
				_g_free0 (message);
				_g_free0 (column);
				return NULL;
			}
		}
	}
	_tmp21_ = use_collation;
	if (_tmp21_) {
		gchar* _tmp22_;
		_tmp22_ = g_strdup ("COLLATE CASEFOLD");
		_g_free0 (_vala_collate);
		_vala_collate = _tmp22_;
	} else {
		gchar* _tmp23_;
		_tmp23_ = g_strdup ("");
		_g_free0 (_vala_collate);
		_vala_collate = _tmp23_;
	}
	result = column;
	if (collate) {
		*collate = _vala_collate;
	} else {
		_g_free0 (_vala_collate);
	}
	return result;
}


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:856: 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 gchar* string_slice (const gchar* self, glong start, glong end) {
	gchar* result = NULL;
	gint _tmp0_;
	gint _tmp1_;
	glong string_length;
	glong _tmp2_;
	glong _tmp5_;
	gboolean _tmp8_ = FALSE;
	glong _tmp9_;
	gboolean _tmp12_;
	gboolean _tmp13_ = FALSE;
	glong _tmp14_;
	gboolean _tmp17_;
	glong _tmp18_;
	glong _tmp19_;
	glong _tmp20_;
	glong _tmp21_;
	glong _tmp22_;
	gchar* _tmp23_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	string_length = (glong) _tmp1_;
	_tmp2_ = start;
	if (_tmp2_ < ((glong) 0)) {
		glong _tmp3_;
		glong _tmp4_;
		_tmp3_ = string_length;
		_tmp4_ = start;
		start = _tmp3_ + _tmp4_;
	}
	_tmp5_ = end;
	if (_tmp5_ < ((glong) 0)) {
		glong _tmp6_;
		glong _tmp7_;
		_tmp6_ = string_length;
		_tmp7_ = end;
		end = _tmp6_ + _tmp7_;
	}
	_tmp9_ = start;
	if (_tmp9_ >= ((glong) 0)) {
		glong _tmp10_;
		glong _tmp11_;
		_tmp10_ = start;
		_tmp11_ = string_length;
		_tmp8_ = _tmp10_ <= _tmp11_;
	} else {
		_tmp8_ = FALSE;
	}
	_tmp12_ = _tmp8_;
	g_return_val_if_fail (_tmp12_, NULL);
	_tmp14_ = end;
	if (_tmp14_ >= ((glong) 0)) {
		glong _tmp15_;
		glong _tmp16_;
		_tmp15_ = end;
		_tmp16_ = string_length;
		_tmp13_ = _tmp15_ <= _tmp16_;
	} else {
		_tmp13_ = FALSE;
	}
	_tmp17_ = _tmp13_;
	g_return_val_if_fail (_tmp17_, NULL);
	_tmp18_ = start;
	_tmp19_ = end;
	g_return_val_if_fail (_tmp18_ <= _tmp19_, NULL);
	_tmp20_ = start;
	_tmp21_ = end;
	_tmp22_ = start;
	_tmp23_ = g_strndup (((gchar*) self) + _tmp20_, (gsize) (_tmp21_ - _tmp22_));
	result = _tmp23_;
	return result;
}


static gchar string_get (const gchar* self, glong index) {
	gchar result = '\0';
	glong _tmp0_;
	gchar _tmp1_;
	g_return_val_if_fail (self != NULL, '\0');
	_tmp0_ = index;
	_tmp1_ = ((gchar*) self)[_tmp0_];
	result = _tmp1_;
	return result;
}


static gchar* rygel_media_export_media_cache_translate_sort_criteria (RygelMediaExportMediaCache* self, const gchar* sort_criteria) {
	gchar* result = NULL;
	gchar* collate = NULL;
	GString* _tmp0_;
	GString* builder;
	const gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_ = NULL;
	gchar** fields;
	gint fields_length1;
	gint _fields_size_;
	gchar** _tmp4_;
	gint _tmp4__length1;
	GString* _tmp27_;
	const gchar* _tmp28_;
	gchar* _tmp29_;
	GError * _inner_error_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (sort_criteria != NULL, NULL);
	_tmp0_ = g_string_new ("ORDER BY ");
	builder = _tmp0_;
	_tmp1_ = sort_criteria;
	_tmp3_ = _tmp2_ = g_strsplit (_tmp1_, ",", 0);
	fields = _tmp3_;
	fields_length1 = _vala_array_length (_tmp2_);
	_fields_size_ = fields_length1;
	_tmp4_ = fields;
	_tmp4__length1 = fields_length1;
	{
		gchar** field_collection = NULL;
		gint field_collection_length1 = 0;
		gint _field_collection_size_ = 0;
		gint field_it = 0;
		field_collection = _tmp4_;
		field_collection_length1 = _tmp4__length1;
		for (field_it = 0; field_it < _tmp4__length1; field_it = field_it + 1) {
			gchar* _tmp5_;
			gchar* field = NULL;
			_tmp5_ = g_strdup (field_collection[field_it]);
			field = _tmp5_;
			{
				{
					const gchar* _tmp6_;
					const gchar* _tmp7_;
					gint _tmp8_;
					gint _tmp9_;
					gchar* _tmp10_ = NULL;
					gchar* _tmp11_;
					gchar* _tmp12_ = NULL;
					gchar* _tmp13_ = NULL;
					gchar* _tmp14_;
					gchar* column;
					const gchar* _tmp15_;
					gchar** _tmp16_;
					gint _tmp16__length1;
					const gchar* _tmp17_;
					const gchar* _tmp19_ = NULL;
					const gchar* _tmp20_;
					gchar _tmp21_ = '\0';
					GString* _tmp22_;
					const gchar* _tmp23_;
					const gchar* _tmp24_;
					const gchar* _tmp25_;
					_tmp6_ = field;
					_tmp7_ = field;
					_tmp8_ = strlen (_tmp7_);
					_tmp9_ = _tmp8_;
					_tmp10_ = string_slice (_tmp6_, (glong) 1, (glong) _tmp9_);
					_tmp11_ = _tmp10_;
					_tmp13_ = rygel_media_export_media_cache_map_operand_to_column (self, _tmp11_, &_tmp12_, &_inner_error_);
					_g_free0 (collate);
					collate = _tmp12_;
					_tmp14_ = _tmp13_;
					_g_free0 (_tmp11_);
					column = _tmp14_;
					if (_inner_error_ != NULL) {
						goto __catch11_g_error;
					}
					_tmp15_ = field;
					_tmp16_ = fields;
					_tmp16__length1 = fields_length1;
					_tmp17_ = _tmp16_[0];
					if (g_strcmp0 (_tmp15_, _tmp17_) != 0) {
						GString* _tmp18_;
						_tmp18_ = builder;
						g_string_append (_tmp18_, ",");
					}
					_tmp20_ = field;
					_tmp21_ = string_get (_tmp20_, (glong) 0);
					if (_tmp21_ == '-') {
						_tmp19_ = "DESC";
					} else {
						_tmp19_ = "ASC";
					}
					_tmp22_ = builder;
					_tmp23_ = column;
					_tmp24_ = collate;
					_tmp25_ = _tmp19_;
					g_string_append_printf (_tmp22_, "%s %s %s ", _tmp23_, _tmp24_, _tmp25_);
					_g_free0 (column);
				}
				goto __finally11;
				__catch11_g_error:
				{
					GError* _error_ = NULL;
					const gchar* _tmp26_;
					_error_ = _inner_error_;
					_inner_error_ = NULL;
					_tmp26_ = field;
					g_warning ("rygel-media-export-media-cache.vala:895: Skipping nsupported field: %s", _tmp26_);
					_g_error_free0 (_error_);
				}
				__finally11:
				if (_inner_error_ != NULL) {
					_g_free0 (field);
					fields = (_vala_array_free (fields, fields_length1, (GDestroyNotify) g_free), NULL);
					_g_string_free0 (builder);
					_g_free0 (collate);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
					g_clear_error (&_inner_error_);
					return NULL;
				}
				_g_free0 (field);
			}
		}
	}
	_tmp27_ = builder;
	_tmp28_ = _tmp27_->str;
	_tmp29_ = g_strdup (_tmp28_);
	result = _tmp29_;
	fields = (_vala_array_free (fields, fields_length1, (GDestroyNotify) g_free), NULL);
	_g_string_free0 (builder);
	_g_free0 (collate);
	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 = RYGEL_MEDIA_EXPORT_MEDIA_CACHE (obj);
	_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;
}


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


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


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



