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

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

#include "rygel-media-export.h"
#include "rygel-server.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib/gi18n-lib.h>

#define RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER (rygel_media_export_writable_db_container_get_type ())
#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer))
#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainerClass))
#define RYGEL_MEDIA_EXPORT_IS_WRITABLE_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER))
#define RYGEL_MEDIA_EXPORT_IS_WRITABLE_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER))
#define RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainerClass))

typedef struct _RygelMediaExportWritableDbContainer RygelMediaExportWritableDbContainer;
typedef struct _RygelMediaExportWritableDbContainerClass RygelMediaExportWritableDbContainerClass;
typedef struct _RygelMediaExportWritableDbContainerPrivate RygelMediaExportWritableDbContainerPrivate;
enum  {
	RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_0_PROPERTY,
	RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES_PROPERTY,
	RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_NUM_PROPERTIES
};
static GParamSpec* rygel_media_export_writable_db_container_properties[RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _RygelMediaExportWritableDbContainerAddItemData RygelMediaExportWritableDbContainerAddItemData;
typedef struct _RygelMediaExportWritableDbContainerAddReferenceData RygelMediaExportWritableDbContainerAddReferenceData;
typedef struct _RygelMediaExportWritableDbContainerAddContainerData RygelMediaExportWritableDbContainerAddContainerData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _RygelMediaExportWritableDbContainerRemoveChildData RygelMediaExportWritableDbContainerRemoveChildData;
typedef struct _RygelMediaExportWritableDbContainerRemoveItemData RygelMediaExportWritableDbContainerRemoveItemData;
typedef struct _RygelMediaExportWritableDbContainerRemoveContainerData RygelMediaExportWritableDbContainerRemoveContainerData;

struct _RygelMediaExportWritableDbContainer {
	RygelMediaExportTrackableDbContainer parent_instance;
	RygelMediaExportWritableDbContainerPrivate * priv;
};

struct _RygelMediaExportWritableDbContainerClass {
	RygelMediaExportTrackableDbContainerClass parent_class;
	void (*add_item) (RygelMediaExportWritableDbContainer* self, RygelMediaFileItem* item, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*add_item_finish) (RygelMediaExportWritableDbContainer* self, GAsyncResult* _res_, GError** error);
	void (*add_reference) (RygelMediaExportWritableDbContainer* self, RygelMediaObject* object, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	gchar* (*add_reference_finish) (RygelMediaExportWritableDbContainer* self, GAsyncResult* _res_, GError** error);
	void (*add_container) (RygelMediaExportWritableDbContainer* self, RygelMediaContainer* container, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*add_container_finish) (RygelMediaExportWritableDbContainer* self, GAsyncResult* _res_, GError** error);
	void (*remove_item) (RygelMediaExportWritableDbContainer* self, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*remove_item_finish) (RygelMediaExportWritableDbContainer* self, GAsyncResult* _res_, GError** error);
	void (*remove_container) (RygelMediaExportWritableDbContainer* self, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*remove_container_finish) (RygelMediaExportWritableDbContainer* self, GAsyncResult* _res_, GError** error);
};

struct _RygelMediaExportWritableDbContainerPrivate {
	GeeArrayList* _create_classes;
};

struct _RygelMediaExportWritableDbContainerAddItemData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportWritableDbContainer* self;
	RygelMediaFileItem* item;
	GCancellable* cancellable;
	GFile* file;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	GFile* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	RygelMediaExportMediaCache* _tmp8_;
};

struct _RygelMediaExportWritableDbContainerAddReferenceData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportWritableDbContainer* self;
	RygelMediaObject* object;
	GCancellable* cancellable;
	gchar* result;
	gchar* _tmp0_;
	RygelMediaExportMediaCache* _tmp1_;
	RygelMediaExportMediaCache* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GError* _inner_error0_;
};

struct _RygelMediaExportWritableDbContainerAddContainerData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportWritableDbContainer* self;
	RygelMediaContainer* container;
	GCancellable* cancellable;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GQuark _tmp4_;
	GFile* file;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GFile* _tmp7_;
	GFile* _tmp8_;
	GFile* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GFile* _tmp12_;
	GFile* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	GError* _tmp16_;
	RygelMediaExportMediaCache* _tmp17_;
	GError* _inner_error0_;
};

struct _RygelMediaExportWritableDbContainerRemoveChildData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportWritableDbContainer* self;
	RygelMediaObject* object;
	GFile* file;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GError* _error_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	GError* _tmp6_;
	const gchar* _tmp7_;
	GError* _inner_error0_;
};

struct _RygelMediaExportWritableDbContainerRemoveItemData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportWritableDbContainer* self;
	gchar* id;
	GCancellable* cancellable;
	RygelMediaObject* object;
	RygelMediaExportMediaCache* _tmp0_;
	RygelMediaObject* _tmp1_;
	GError* _inner_error0_;
};

struct _RygelMediaExportWritableDbContainerRemoveContainerData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	RygelMediaExportWritableDbContainer* self;
	gchar* id;
	GCancellable* cancellable;
	GError* _inner_error0_;
};

static gint RygelMediaExportWritableDbContainer_private_offset;
static gpointer rygel_media_export_writable_db_container_parent_class = NULL;
static RygelWritableContainerIface * rygel_media_export_writable_db_container_rygel_writable_container_parent_iface = NULL;

VALA_EXTERN GType rygel_media_export_writable_db_container_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void rygel_media_export_writable_db_container_add_item (RygelMediaExportWritableDbContainer* self,
                                                        RygelMediaFileItem* item,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
VALA_EXTERN void rygel_media_export_writable_db_container_add_item_finish (RygelMediaExportWritableDbContainer* self,
                                                               GAsyncResult* _res_,
                                                               GError** error);
VALA_EXTERN void rygel_media_export_writable_db_container_add_reference (RygelMediaExportWritableDbContainer* self,
                                                             RygelMediaObject* object,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
VALA_EXTERN gchar* rygel_media_export_writable_db_container_add_reference_finish (RygelMediaExportWritableDbContainer* self,
                                                                      GAsyncResult* _res_,
                                                                      GError** error);
VALA_EXTERN void rygel_media_export_writable_db_container_add_container (RygelMediaExportWritableDbContainer* self,
                                                             RygelMediaContainer* container,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
VALA_EXTERN void rygel_media_export_writable_db_container_add_container_finish (RygelMediaExportWritableDbContainer* self,
                                                                    GAsyncResult* _res_,
                                                                    GError** error);
VALA_EXTERN void rygel_media_export_writable_db_container_remove_item (RygelMediaExportWritableDbContainer* self,
                                                           const gchar* id,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
VALA_EXTERN void rygel_media_export_writable_db_container_remove_item_finish (RygelMediaExportWritableDbContainer* self,
                                                                  GAsyncResult* _res_,
                                                                  GError** error);
VALA_EXTERN void rygel_media_export_writable_db_container_remove_container (RygelMediaExportWritableDbContainer* self,
                                                                const gchar* id,
                                                                GCancellable* cancellable,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
VALA_EXTERN void rygel_media_export_writable_db_container_remove_container_finish (RygelMediaExportWritableDbContainer* self,
                                                                       GAsyncResult* _res_,
                                                                       GError** error);
VALA_EXTERN RygelMediaExportWritableDbContainer* rygel_media_export_writable_db_container_new (const gchar* id,
                                                                                   const gchar* title);
VALA_EXTERN RygelMediaExportWritableDbContainer* rygel_media_export_writable_db_container_construct (GType object_type,
                                                                                         const gchar* id,
                                                                                         const gchar* title);
static void rygel_media_export_writable_db_container_real_constructed (GObject* base);
static void rygel_media_export_writable_db_container_real_add_item_data_free (gpointer _data);
static void rygel_media_export_writable_db_container_real_add_item (RygelMediaExportWritableDbContainer* self,
                                                             RygelMediaFileItem* item,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static gboolean rygel_media_export_writable_db_container_real_add_item_co (RygelMediaExportWritableDbContainerAddItemData* _data_);
static void rygel_media_export_writable_db_container_add_item_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
static void rygel_media_export_writable_db_container_real_add_reference_data_free (gpointer _data);
static void rygel_media_export_writable_db_container_real_add_reference (RygelMediaExportWritableDbContainer* self,
                                                                  RygelMediaObject* object,
                                                                  GCancellable* cancellable,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_);
static gboolean rygel_media_export_writable_db_container_real_add_reference_co (RygelMediaExportWritableDbContainerAddReferenceData* _data_);
static void rygel_media_export_writable_db_container_real_add_container_data_free (gpointer _data);
static void rygel_media_export_writable_db_container_real_add_container (RygelMediaExportWritableDbContainer* self,
                                                                  RygelMediaContainer* container,
                                                                  GCancellable* cancellable,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_);
static gboolean rygel_media_export_writable_db_container_real_add_container_co (RygelMediaExportWritableDbContainerAddContainerData* _data_);
static void rygel_media_export_writable_db_container_add_container_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_);
static void rygel_media_export_writable_db_container_real_remove_child_data_free (gpointer _data);
static void rygel_media_export_writable_db_container_real_remove_child (RygelMediaExportTrackableDbContainer* base,
                                                                 RygelMediaObject* object,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_);
static gboolean rygel_media_export_writable_db_container_real_remove_child_co (RygelMediaExportWritableDbContainerRemoveChildData* _data_);
static void rygel_media_export_writable_db_container_remove_child_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static void rygel_media_export_writable_db_container_real_remove_item_data_free (gpointer _data);
static void rygel_media_export_writable_db_container_real_remove_item (RygelMediaExportWritableDbContainer* self,
                                                                const gchar* id,
                                                                GCancellable* cancellable,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
static gboolean rygel_media_export_writable_db_container_real_remove_item_co (RygelMediaExportWritableDbContainerRemoveItemData* _data_);
static void rygel_media_export_writable_db_container_remove_item_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_);
static void rygel_media_export_writable_db_container_real_remove_container_data_free (gpointer _data);
static void rygel_media_export_writable_db_container_real_remove_container (RygelMediaExportWritableDbContainer* self,
                                                                     const gchar* id,
                                                                     GCancellable* cancellable,
                                                                     GAsyncReadyCallback _callback_,
                                                                     gpointer _user_data_);
static gboolean rygel_media_export_writable_db_container_real_remove_container_co (RygelMediaExportWritableDbContainerRemoveContainerData* _data_);
static void rygel_media_export_writable_db_container_remove_container_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_);
VALA_EXTERN void rygel_media_export_writable_db_container_remove_tracked (RygelMediaExportWritableDbContainer* self,
                                                              RygelMediaObject* object,
                                                              GError** error);
static void rygel_media_export_writable_db_container_finalize (GObject * obj);
static GType rygel_media_export_writable_db_container_get_type_once (void);
static void _vala_rygel_media_export_writable_db_container_get_property (GObject * object,
                                                                  guint property_id,
                                                                  GValue * value,
                                                                  GParamSpec * pspec);
static void _vala_rygel_media_export_writable_db_container_set_property (GObject * object,
                                                                  guint property_id,
                                                                  const GValue * value,
                                                                  GParamSpec * pspec);

static inline gpointer
rygel_media_export_writable_db_container_get_instance_private (RygelMediaExportWritableDbContainer* self)
{
	return G_STRUCT_MEMBER_P (self, RygelMediaExportWritableDbContainer_private_offset);
}

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

RygelMediaExportWritableDbContainer*
rygel_media_export_writable_db_container_new (const gchar* id,
                                              const gchar* title)
{
	return rygel_media_export_writable_db_container_construct (RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, id, title);
}

static void
rygel_media_export_writable_db_container_real_constructed (GObject* base)
{
	RygelMediaExportWritableDbContainer * self;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeArrayList* _tmp4_;
	GeeArrayList* _tmp5_;
	GeeArrayList* _tmp6_;
	GeeArrayList* _tmp7_;
	GeeArrayList* _tmp8_;
	GeeArrayList* _tmp9_;
	GeeArrayList* _tmp10_;
	GeeArrayList* _tmp11_;
	GeeArrayList* _tmp12_;
	GeeArrayList* _tmp13_;
	GeeArrayList* _tmp14_;
	GeeArrayList* _tmp15_;
	self = (RygelMediaExportWritableDbContainer*) base;
	G_OBJECT_CLASS (rygel_media_export_writable_db_container_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, RygelMediaExportTrackableDbContainer));
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_tmp1_ = _tmp0_;
	rygel_writable_container_set_create_classes ((RygelWritableContainer*) self, _tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
	_tmp3_ = _tmp2_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp3_, RYGEL_IMAGE_ITEM_UPNP_CLASS);
	_tmp4_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
	_tmp5_ = _tmp4_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp5_, RYGEL_PHOTO_ITEM_UPNP_CLASS);
	_tmp6_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
	_tmp7_ = _tmp6_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp7_, RYGEL_VIDEO_ITEM_UPNP_CLASS);
	_tmp8_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
	_tmp9_ = _tmp8_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp9_, RYGEL_AUDIO_ITEM_UPNP_CLASS);
	_tmp10_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
	_tmp11_ = _tmp10_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, RYGEL_MUSIC_ITEM_UPNP_CLASS);
	_tmp12_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
	_tmp13_ = _tmp12_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp13_, RYGEL_PLAYLIST_ITEM_UPNP_CLASS);
	_tmp14_ = rygel_writable_container_get_create_classes ((RygelWritableContainer*) self);
	_tmp15_ = _tmp14_;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp15_, RYGEL_MEDIA_CONTAINER_UPNP_CLASS);
}

static void
rygel_media_export_writable_db_container_real_add_item_data_free (gpointer _data)
{
	RygelMediaExportWritableDbContainerAddItemData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->item);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelMediaExportWritableDbContainerAddItemData, _data_);
}

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

static void
rygel_media_export_writable_db_container_real_add_item (RygelMediaExportWritableDbContainer* self,
                                                        RygelMediaFileItem* item,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerAddItemData* _data_;
	RygelMediaExportWritableDbContainer* _tmp0_;
	RygelMediaFileItem* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (item != NULL);
	_data_ = g_slice_new0 (RygelMediaExportWritableDbContainerAddItemData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_writable_db_container_real_add_item_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (item);
	_g_object_unref0 (_data_->item);
	_data_->item = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	rygel_media_export_writable_db_container_real_add_item_co (_data_);
}

static void
rygel_media_export_writable_db_container_real_add_item_finish (RygelMediaExportWritableDbContainer* self,
                                                               GAsyncResult* _res_,
                                                               GError** error)
{
	RygelMediaExportWritableDbContainerAddItemData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
rygel_media_export_writable_db_container_add_item_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerAddItemData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_media_export_writable_db_container_real_add_item_co (_data_);
}

static gboolean
rygel_media_export_writable_db_container_real_add_item_co (RygelMediaExportWritableDbContainerAddItemData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	rygel_media_object_set_parent ((RygelMediaObject*) _data_->item, (RygelMediaContainer*) _data_->self);
	_data_->_tmp0_ = rygel_media_object_get_primary_uri ((RygelMediaObject*) _data_->item);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = g_file_new_for_uri (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_g_free0 (_data_->_tmp1_);
	_data_->file = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->file;
	if (g_file_is_native (_data_->_tmp4_)) {
		rygel_media_object_set_modified ((RygelMediaObject*) _data_->item, (guint64) G_MAXINT64);
	}
	_data_->_tmp5_ = _data_->file;
	_data_->_tmp6_ = rygel_media_export_media_cache_get_id (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	rygel_media_object_set_id ((RygelMediaObject*) _data_->item, _data_->_tmp7_);
	_g_free0 (_data_->_tmp7_);
	_data_->_state_ = 1;
	rygel_trackable_container_add_child_tracked ((RygelTrackableContainer*) _data_->self, (RygelMediaObject*) _data_->item, rygel_media_export_writable_db_container_add_item_ready, _data_);
	return FALSE;
	_state_1:
	rygel_trackable_container_add_child_tracked_finish ((RygelTrackableContainer*) _data_->self, _data_->_res_);
	_data_->_tmp8_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
	rygel_media_export_media_cache_make_object_guarded (_data_->_tmp8_, (RygelMediaObject*) _data_->item, TRUE);
	_g_object_unref0 (_data_->file);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
rygel_media_export_writable_db_container_add_item (RygelMediaExportWritableDbContainer* self,
                                                   RygelMediaFileItem* item,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->add_item) {
		_klass_->add_item (self, item, cancellable, _callback_, _user_data_);
	}
}

void
rygel_media_export_writable_db_container_add_item_finish (RygelMediaExportWritableDbContainer* self,
                                                          GAsyncResult* _res_,
                                                          GError** error)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->add_item_finish) {
		_klass_->add_item_finish (self, _res_, error);
	}
}

static void
rygel_media_export_writable_db_container_real_add_reference_data_free (gpointer _data)
{
	RygelMediaExportWritableDbContainerAddReferenceData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->object);
	_g_object_unref0 (_data_->cancellable);
	_g_free0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelMediaExportWritableDbContainerAddReferenceData, _data_);
}

static void
rygel_media_export_writable_db_container_real_add_reference (RygelMediaExportWritableDbContainer* self,
                                                             RygelMediaObject* object,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerAddReferenceData* _data_;
	RygelMediaExportWritableDbContainer* _tmp0_;
	RygelMediaObject* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (object != NULL);
	_data_ = g_slice_new0 (RygelMediaExportWritableDbContainerAddReferenceData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_writable_db_container_real_add_reference_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (object);
	_g_object_unref0 (_data_->object);
	_data_->object = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	rygel_media_export_writable_db_container_real_add_reference_co (_data_);
}

static gchar*
rygel_media_export_writable_db_container_real_add_reference_finish (RygelMediaExportWritableDbContainer* self,
                                                                    GAsyncResult* _res_,
                                                                    GError** error)
{
	gchar* result;
	RygelMediaExportWritableDbContainerAddReferenceData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static gboolean
rygel_media_export_writable_db_container_real_add_reference_co (RygelMediaExportWritableDbContainerAddReferenceData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = rygel_media_export_media_cache_get_default ();
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = rygel_media_export_media_cache_create_reference (_data_->_tmp2_, _data_->object, (RygelMediaContainer*) _data_->self, &_data_->_inner_error0_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_g_object_unref0 (_data_->_tmp2_);
	_data_->_tmp0_ = _data_->_tmp4_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_data_->result = _data_->_tmp5_;
	_g_free0 (_data_->_tmp0_);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
rygel_media_export_writable_db_container_add_reference (RygelMediaExportWritableDbContainer* self,
                                                        RygelMediaObject* object,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->add_reference) {
		_klass_->add_reference (self, object, cancellable, _callback_, _user_data_);
	}
}

gchar*
rygel_media_export_writable_db_container_add_reference_finish (RygelMediaExportWritableDbContainer* self,
                                                               GAsyncResult* _res_,
                                                               GError** error)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->add_reference_finish) {
		return _klass_->add_reference_finish (self, _res_, error);
	}
	return NULL;
}

static void
rygel_media_export_writable_db_container_real_add_container_data_free (gpointer _data)
{
	RygelMediaExportWritableDbContainerAddContainerData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->container);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelMediaExportWritableDbContainerAddContainerData, _data_);
}

static void
rygel_media_export_writable_db_container_real_add_container (RygelMediaExportWritableDbContainer* self,
                                                             RygelMediaContainer* container,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerAddContainerData* _data_;
	RygelMediaExportWritableDbContainer* _tmp0_;
	RygelMediaContainer* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (container != NULL);
	_data_ = g_slice_new0 (RygelMediaExportWritableDbContainerAddContainerData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_writable_db_container_real_add_container_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (container);
	_g_object_unref0 (_data_->container);
	_data_->container = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	rygel_media_export_writable_db_container_real_add_container_co (_data_);
}

static void
rygel_media_export_writable_db_container_real_add_container_finish (RygelMediaExportWritableDbContainer* self,
                                                                    GAsyncResult* _res_,
                                                                    GError** error)
{
	RygelMediaExportWritableDbContainerAddContainerData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
rygel_media_export_writable_db_container_add_container_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerAddContainerData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_media_export_writable_db_container_real_add_container_co (_data_);
}

static gboolean
rygel_media_export_writable_db_container_real_add_container_co (RygelMediaExportWritableDbContainerAddContainerData* _data_)
{
	static GQuark _tmp3_label0 = 0;
	static GQuark _tmp3_label1 = 0;
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	rygel_media_object_set_parent ((RygelMediaObject*) _data_->container, (RygelMediaContainer*) _data_->self);
	_data_->_tmp0_ = rygel_media_object_get_upnp_class ((RygelMediaObject*) _data_->container);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp4_ = 0U;
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp4_ = (NULL == _data_->_tmp2_) ? 0 : g_quark_from_string (_data_->_tmp2_);
	if ((_data_->_tmp4_ == ((0 != _tmp3_label0) ? _tmp3_label0 : (_tmp3_label0 = g_quark_from_static_string (RYGEL_MEDIA_CONTAINER_STORAGE_FOLDER)))) || (_data_->_tmp4_ == ((0 != _tmp3_label1) ? _tmp3_label1 : (_tmp3_label1 = g_quark_from_static_string (RYGEL_MEDIA_CONTAINER_UPNP_CLASS))))) {
		switch (0) {
			default:
			{
				_data_->_tmp5_ = rygel_media_object_get_primary_uri ((RygelMediaObject*) _data_->container);
				_data_->_tmp6_ = _data_->_tmp5_;
				_data_->_tmp7_ = g_file_new_for_uri (_data_->_tmp6_);
				_data_->_tmp8_ = _data_->_tmp7_;
				_g_free0 (_data_->_tmp6_);
				_data_->file = _data_->_tmp8_;
				_data_->_tmp9_ = _data_->file;
				_data_->_tmp10_ = rygel_media_export_media_cache_get_id (_data_->_tmp9_);
				_data_->_tmp11_ = _data_->_tmp10_;
				rygel_media_object_set_id ((RygelMediaObject*) _data_->container, _data_->_tmp11_);
				_g_free0 (_data_->_tmp11_);
				_data_->_tmp12_ = _data_->file;
				if (g_file_is_native (_data_->_tmp12_)) {
					_data_->_tmp13_ = _data_->file;
					g_file_make_directory_with_parents (_data_->_tmp13_, _data_->cancellable, &_data_->_inner_error0_);
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
						_g_object_unref0 (_data_->file);
						g_object_unref (_data_->_async_result);
						return FALSE;
					}
				}
				_g_object_unref0 (_data_->file);
				break;
			}
		}
	} else {
		switch (0) {
			default:
			{
				_data_->_tmp14_ = rygel_media_object_get_upnp_class ((RygelMediaObject*) _data_->container);
				_data_->_tmp15_ = _data_->_tmp14_;
				_data_->_tmp16_ = g_error_new (RYGEL_WRITABLE_CONTAINER_ERROR, RYGEL_WRITABLE_CONTAINER_ERROR_NOT_IMPLEMENTED, "upnp:class %s not supported", _data_->_tmp15_);
				_data_->_inner_error0_ = _data_->_tmp16_;
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
	}
	_data_->_state_ = 1;
	rygel_trackable_container_add_child_tracked ((RygelTrackableContainer*) _data_->self, (RygelMediaObject*) _data_->container, rygel_media_export_writable_db_container_add_container_ready, _data_);
	return FALSE;
	_state_1:
	rygel_trackable_container_add_child_tracked_finish ((RygelTrackableContainer*) _data_->self, _data_->_res_);
	_data_->_tmp17_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
	rygel_media_export_media_cache_make_object_guarded (_data_->_tmp17_, (RygelMediaObject*) _data_->container, TRUE);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
rygel_media_export_writable_db_container_add_container (RygelMediaExportWritableDbContainer* self,
                                                        RygelMediaContainer* container,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->add_container) {
		_klass_->add_container (self, container, cancellable, _callback_, _user_data_);
	}
}

void
rygel_media_export_writable_db_container_add_container_finish (RygelMediaExportWritableDbContainer* self,
                                                               GAsyncResult* _res_,
                                                               GError** error)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->add_container_finish) {
		_klass_->add_container_finish (self, _res_, error);
	}
}

static void
rygel_media_export_writable_db_container_real_remove_child_data_free (gpointer _data)
{
	RygelMediaExportWritableDbContainerRemoveChildData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->object);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelMediaExportWritableDbContainerRemoveChildData, _data_);
}

static void
rygel_media_export_writable_db_container_real_remove_child (RygelMediaExportTrackableDbContainer* base,
                                                            RygelMediaObject* object,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_)
{
	RygelMediaExportWritableDbContainer * self;
	RygelMediaExportWritableDbContainerRemoveChildData* _data_;
	RygelMediaExportWritableDbContainer* _tmp0_;
	RygelMediaObject* _tmp1_;
	g_return_if_fail (object != NULL);
	self = (RygelMediaExportWritableDbContainer*) base;
	_data_ = g_slice_new0 (RygelMediaExportWritableDbContainerRemoveChildData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_writable_db_container_real_remove_child_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (object);
	_g_object_unref0 (_data_->object);
	_data_->object = _tmp1_;
	rygel_media_export_writable_db_container_real_remove_child_co (_data_);
}

static void
rygel_media_export_writable_db_container_remove_child_finish (RygelMediaExportTrackableDbContainer* base,
                                                              GAsyncResult* _res_)
{
	RygelMediaExportWritableDbContainerRemoveChildData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
rygel_media_export_writable_db_container_remove_child_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerRemoveChildData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_media_export_writable_db_container_real_remove_child_co (_data_);
}

static gboolean
rygel_media_export_writable_db_container_real_remove_child_co (RygelMediaExportWritableDbContainerRemoveChildData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_CLASS (rygel_media_export_writable_db_container_parent_class)->remove_child (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, RygelMediaExportTrackableDbContainer), _data_->object, rygel_media_export_writable_db_container_remove_child_ready, _data_);
	return FALSE;
	_state_1:
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_CLASS (rygel_media_export_writable_db_container_parent_class)->remove_child_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, RygelMediaExportTrackableDbContainer), _data_->_res_);
	_data_->_tmp0_ = rygel_media_object_get_primary_uri (_data_->object);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = g_file_new_for_uri (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_g_free0 (_data_->_tmp1_);
	_data_->file = _data_->_tmp3_;
	{
		_data_->_state_ = 2;
		g_file_delete_async (_data_->file, G_PRIORITY_DEFAULT, NULL, rygel_media_export_writable_db_container_remove_child_ready, _data_);
		return FALSE;
		_state_2:
		g_file_delete_finish (_data_->file, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp4_ = g_file_get_path (_data_->file);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_tmp6_ = _data_->_error_;
		_data_->_tmp7_ = _data_->_tmp6_->message;
		g_warning (_ ("Failed to remove file %s: %s"), _data_->_tmp5_, _data_->_tmp7_);
		_g_free0 (_data_->_tmp5_);
		_g_error_free0 (_data_->_error_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->file);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->file);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

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

static void
rygel_media_export_writable_db_container_real_remove_item (RygelMediaExportWritableDbContainer* self,
                                                           const gchar* id,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerRemoveItemData* _data_;
	RygelMediaExportWritableDbContainer* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (id != NULL);
	_data_ = g_slice_new0 (RygelMediaExportWritableDbContainerRemoveItemData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_writable_db_container_real_remove_item_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (id);
	_g_free0 (_data_->id);
	_data_->id = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	rygel_media_export_writable_db_container_real_remove_item_co (_data_);
}

static void
rygel_media_export_writable_db_container_real_remove_item_finish (RygelMediaExportWritableDbContainer* self,
                                                                  GAsyncResult* _res_,
                                                                  GError** error)
{
	RygelMediaExportWritableDbContainerRemoveItemData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
rygel_media_export_writable_db_container_remove_item_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerRemoveItemData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_media_export_writable_db_container_real_remove_item_co (_data_);
}

static gboolean
rygel_media_export_writable_db_container_real_remove_item_co (RygelMediaExportWritableDbContainerRemoveItemData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
	_data_->_tmp1_ = rygel_media_export_media_cache_get_object (_data_->_tmp0_, _data_->id, &_data_->_inner_error0_);
	_data_->object = _data_->_tmp1_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	if (_data_->object != NULL) {
		_data_->_state_ = 1;
		rygel_trackable_container_remove_child_tracked ((RygelTrackableContainer*) _data_->self, _data_->object, rygel_media_export_writable_db_container_remove_item_ready, _data_);
		return FALSE;
		_state_1:
		rygel_trackable_container_remove_child_tracked_finish ((RygelTrackableContainer*) _data_->self, _data_->_res_);
	} else {
		g_warning (_ ("Could not find object %d in cache"), _data_->id);
	}
	_g_object_unref0 (_data_->object);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
rygel_media_export_writable_db_container_remove_item (RygelMediaExportWritableDbContainer* self,
                                                      const gchar* id,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->remove_item) {
		_klass_->remove_item (self, id, cancellable, _callback_, _user_data_);
	}
}

void
rygel_media_export_writable_db_container_remove_item_finish (RygelMediaExportWritableDbContainer* self,
                                                             GAsyncResult* _res_,
                                                             GError** error)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->remove_item_finish) {
		_klass_->remove_item_finish (self, _res_, error);
	}
}

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

static void
rygel_media_export_writable_db_container_real_remove_container (RygelMediaExportWritableDbContainer* self,
                                                                const gchar* id,
                                                                GCancellable* cancellable,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerRemoveContainerData* _data_;
	RygelMediaExportWritableDbContainer* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (id != NULL);
	_data_ = g_slice_new0 (RygelMediaExportWritableDbContainerRemoveContainerData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_writable_db_container_real_remove_container_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (id);
	_g_free0 (_data_->id);
	_data_->id = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	rygel_media_export_writable_db_container_real_remove_container_co (_data_);
}

static void
rygel_media_export_writable_db_container_real_remove_container_finish (RygelMediaExportWritableDbContainer* self,
                                                                       GAsyncResult* _res_,
                                                                       GError** error)
{
	RygelMediaExportWritableDbContainerRemoveContainerData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
rygel_media_export_writable_db_container_remove_container_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerRemoveContainerData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_media_export_writable_db_container_real_remove_container_co (_data_);
}

static gboolean
rygel_media_export_writable_db_container_real_remove_container_co (RygelMediaExportWritableDbContainerRemoveContainerData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	rygel_media_export_writable_db_container_remove_item (_data_->self, _data_->id, _data_->cancellable, rygel_media_export_writable_db_container_remove_container_ready, _data_);
	return FALSE;
	_state_1:
	rygel_media_export_writable_db_container_remove_item_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
rygel_media_export_writable_db_container_remove_container (RygelMediaExportWritableDbContainer* self,
                                                           const gchar* id,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->remove_container) {
		_klass_->remove_container (self, id, cancellable, _callback_, _user_data_);
	}
}

void
rygel_media_export_writable_db_container_remove_container_finish (RygelMediaExportWritableDbContainer* self,
                                                                  GAsyncResult* _res_,
                                                                  GError** error)
{
	RygelMediaExportWritableDbContainerClass* _klass_;
	_klass_ = RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_GET_CLASS (self);
	if (_klass_->remove_container_finish) {
		_klass_->remove_container_finish (self, _res_, error);
	}
}

void
rygel_media_export_writable_db_container_remove_tracked (RygelMediaExportWritableDbContainer* self,
                                                         RygelMediaObject* object,
                                                         GError** error)
{
	gint64 _tmp0_;
	RygelMediaExportMediaCache* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	rygel_media_container_updated ((RygelMediaContainer*) self, object, RYGEL_OBJECT_EVENT_TYPE_DELETED, FALSE);
	_tmp0_ = ((RygelMediaContainer*) self)->total_deleted_child_count;
	((RygelMediaContainer*) self)->total_deleted_child_count = _tmp0_ + 1;
	_tmp1_ = ((RygelMediaExportDBContainer*) self)->media_db;
	_tmp2_ = rygel_media_object_get_id (object);
	_tmp3_ = _tmp2_;
	rygel_media_export_media_cache_remove_by_id (_tmp1_, _tmp3_, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	rygel_media_container_updated ((RygelMediaContainer*) self, NULL, RYGEL_OBJECT_EVENT_TYPE_MODIFIED, FALSE);
	g_signal_emit_by_name ((RygelTrackableContainer*) self, "child-removed", object);
}

static GeeArrayList*
rygel_media_export_writable_db_container_real_get_create_classes (RygelWritableContainer* base)
{
	GeeArrayList* result;
	RygelMediaExportWritableDbContainer* self;
	GeeArrayList* _tmp0_;
	self = (RygelMediaExportWritableDbContainer*) base;
	_tmp0_ = self->priv->_create_classes;
	result = _tmp0_;
	return result;
}

static void
rygel_media_export_writable_db_container_real_set_create_classes (RygelWritableContainer* base,
                                                                  GeeArrayList* value)
{
	RygelMediaExportWritableDbContainer* self;
	GeeArrayList* old_value;
	self = (RygelMediaExportWritableDbContainer*) base;
	old_value = rygel_media_export_writable_db_container_real_get_create_classes (base);
	if (old_value != value) {
		GeeArrayList* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_create_classes);
		self->priv->_create_classes = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, rygel_media_export_writable_db_container_properties[RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES_PROPERTY]);
	}
}

static void
rygel_media_export_writable_db_container_class_init (RygelMediaExportWritableDbContainerClass * klass,
                                                     gpointer klass_data)
{
	rygel_media_export_writable_db_container_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &RygelMediaExportWritableDbContainer_private_offset);
	((GObjectClass *) klass)->constructed = (void (*) (GObject*)) rygel_media_export_writable_db_container_real_constructed;
	((RygelMediaExportWritableDbContainerClass *) klass)->add_item = (void (*) (RygelMediaExportWritableDbContainer*, RygelMediaFileItem*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_real_add_item;
	((RygelMediaExportWritableDbContainerClass *) klass)->add_item_finish = (void (*) (RygelMediaExportWritableDbContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_real_add_item_finish;
	((RygelMediaExportWritableDbContainerClass *) klass)->add_reference = (void (*) (RygelMediaExportWritableDbContainer*, RygelMediaObject*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_real_add_reference;
	((RygelMediaExportWritableDbContainerClass *) klass)->add_reference_finish = (gchar* (*) (RygelMediaExportWritableDbContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_real_add_reference_finish;
	((RygelMediaExportWritableDbContainerClass *) klass)->add_container = (void (*) (RygelMediaExportWritableDbContainer*, RygelMediaContainer*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_real_add_container;
	((RygelMediaExportWritableDbContainerClass *) klass)->add_container_finish = (void (*) (RygelMediaExportWritableDbContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_real_add_container_finish;
	((RygelMediaExportTrackableDbContainerClass *) klass)->remove_child = (void (*) (RygelMediaExportTrackableDbContainer*, RygelMediaObject*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_real_remove_child;
	((RygelMediaExportTrackableDbContainerClass *) klass)->remove_child_finish = (void (*) (RygelMediaExportTrackableDbContainer*, GAsyncResult*)) rygel_media_export_writable_db_container_remove_child_finish;
	((RygelMediaExportWritableDbContainerClass *) klass)->remove_item = (void (*) (RygelMediaExportWritableDbContainer*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_real_remove_item;
	((RygelMediaExportWritableDbContainerClass *) klass)->remove_item_finish = (void (*) (RygelMediaExportWritableDbContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_real_remove_item_finish;
	((RygelMediaExportWritableDbContainerClass *) klass)->remove_container = (void (*) (RygelMediaExportWritableDbContainer*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_real_remove_container;
	((RygelMediaExportWritableDbContainerClass *) klass)->remove_container_finish = (void (*) (RygelMediaExportWritableDbContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_real_remove_container_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_rygel_media_export_writable_db_container_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_rygel_media_export_writable_db_container_set_property;
	G_OBJECT_CLASS (klass)->finalize = rygel_media_export_writable_db_container_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES_PROPERTY, rygel_media_export_writable_db_container_properties[RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES_PROPERTY] = g_param_spec_object ("create-classes", "create-classes", "create-classes", GEE_TYPE_ARRAY_LIST, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
rygel_media_export_writable_db_container_rygel_writable_container_interface_init (RygelWritableContainerIface * iface,
                                                                                  gpointer iface_data)
{
	rygel_media_export_writable_db_container_rygel_writable_container_parent_iface = g_type_interface_peek_parent (iface);
	iface->add_item = (void (*) (RygelWritableContainer*, RygelMediaFileItem*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_add_item;
	iface->add_item_finish = (void (*) (RygelWritableContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_add_item_finish;
	iface->add_reference = (void (*) (RygelWritableContainer*, RygelMediaObject*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_add_reference;
	iface->add_reference_finish = (gchar* (*) (RygelWritableContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_add_reference_finish;
	iface->add_container = (void (*) (RygelWritableContainer*, RygelMediaContainer*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_add_container;
	iface->add_container_finish = (void (*) (RygelWritableContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_add_container_finish;
	iface->remove_item = (void (*) (RygelWritableContainer*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_remove_item;
	iface->remove_item_finish = (void (*) (RygelWritableContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_remove_item_finish;
	iface->remove_container = (void (*) (RygelWritableContainer*, const gchar*, GCancellable*, GAsyncReadyCallback, gpointer)) rygel_media_export_writable_db_container_remove_container;
	iface->remove_container_finish = (void (*) (RygelWritableContainer*, GAsyncResult*, GError**)) rygel_media_export_writable_db_container_remove_container_finish;
	iface->get_create_classes = rygel_media_export_writable_db_container_real_get_create_classes;
	iface->set_create_classes = rygel_media_export_writable_db_container_real_set_create_classes;
}

static void
rygel_media_export_writable_db_container_instance_init (RygelMediaExportWritableDbContainer * self,
                                                        gpointer klass)
{
	self->priv = rygel_media_export_writable_db_container_get_instance_private (self);
}

static void
rygel_media_export_writable_db_container_finalize (GObject * obj)
{
	RygelMediaExportWritableDbContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer);
	_g_object_unref0 (self->priv->_create_classes);
	G_OBJECT_CLASS (rygel_media_export_writable_db_container_parent_class)->finalize (obj);
}

/**
 * A DB container that is both Trackable and Writable.
 *
 * Clients can upload items to this container, causing
 * the items to be saved to the filesystem to be
 * served again subsequently.
 */
static GType
rygel_media_export_writable_db_container_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportWritableDbContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_writable_db_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportWritableDbContainer), 0, (GInstanceInitFunc) rygel_media_export_writable_db_container_instance_init, NULL };
	static const GInterfaceInfo rygel_writable_container_info = { (GInterfaceInitFunc) rygel_media_export_writable_db_container_rygel_writable_container_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType rygel_media_export_writable_db_container_type_id;
	rygel_media_export_writable_db_container_type_id = g_type_register_static (RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, "RygelMediaExportWritableDbContainer", &g_define_type_info, 0);
	g_type_add_interface_static (rygel_media_export_writable_db_container_type_id, RYGEL_TYPE_WRITABLE_CONTAINER, &rygel_writable_container_info);
	RygelMediaExportWritableDbContainer_private_offset = g_type_add_instance_private (rygel_media_export_writable_db_container_type_id, sizeof (RygelMediaExportWritableDbContainerPrivate));
	return rygel_media_export_writable_db_container_type_id;
}

GType
rygel_media_export_writable_db_container_get_type (void)
{
	static volatile gsize rygel_media_export_writable_db_container_type_id__once = 0;
	if (g_once_init_enter (&rygel_media_export_writable_db_container_type_id__once)) {
		GType rygel_media_export_writable_db_container_type_id;
		rygel_media_export_writable_db_container_type_id = rygel_media_export_writable_db_container_get_type_once ();
		g_once_init_leave (&rygel_media_export_writable_db_container_type_id__once, rygel_media_export_writable_db_container_type_id);
	}
	return rygel_media_export_writable_db_container_type_id__once;
}

static void
_vala_rygel_media_export_writable_db_container_get_property (GObject * object,
                                                             guint property_id,
                                                             GValue * value,
                                                             GParamSpec * pspec)
{
	RygelMediaExportWritableDbContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer);
	switch (property_id) {
		case RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES_PROPERTY:
		g_value_set_object (value, rygel_writable_container_get_create_classes ((RygelWritableContainer*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_rygel_media_export_writable_db_container_set_property (GObject * object,
                                                             guint property_id,
                                                             const GValue * value,
                                                             GParamSpec * pspec)
{
	RygelMediaExportWritableDbContainer * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, RYGEL_MEDIA_EXPORT_TYPE_WRITABLE_DB_CONTAINER, RygelMediaExportWritableDbContainer);
	switch (property_id) {
		case RYGEL_MEDIA_EXPORT_WRITABLE_DB_CONTAINER_CREATE_CLASSES_PROPERTY:
		rygel_writable_container_set_create_classes ((RygelWritableContainer*) self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

