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

/*
 * Copyright (C) 2012 Intel Corporation.
 *
 * Author: Jens Georg <jensg@openismus.com>
 *
 * This file is part of Rygel.
 *
 * Rygel is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * Rygel is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */


#include <glib.h>
#include <glib-object.h>
#include <rygel-server.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include <rygel-db.h>


#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;
typedef struct _RygelMediaExportDBContainerPrivate RygelMediaExportDBContainerPrivate;

#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;

#define RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER (rygel_media_export_trackable_db_container_get_type ())
#define RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, RygelMediaExportTrackableDbContainer))
#define RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, RygelMediaExportTrackableDbContainerClass))
#define RYGEL_MEDIA_EXPORT_IS_TRACKABLE_DB_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER))
#define RYGEL_MEDIA_EXPORT_IS_TRACKABLE_DB_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER))
#define RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, RygelMediaExportTrackableDbContainerClass))

typedef struct _RygelMediaExportTrackableDbContainer RygelMediaExportTrackableDbContainer;
typedef struct _RygelMediaExportTrackableDbContainerClass RygelMediaExportTrackableDbContainerClass;
typedef struct _RygelMediaExportTrackableDbContainerPrivate RygelMediaExportTrackableDbContainerPrivate;
enum  {
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_0_PROPERTY,
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_NUM_PROPERTIES
};
static GParamSpec* rygel_media_export_trackable_db_container_properties[RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _RygelMediaExportTrackableDbContainerAddChildData RygelMediaExportTrackableDbContainerAddChildData;
typedef struct _RygelMediaExportTrackableDbContainerRemoveChildData RygelMediaExportTrackableDbContainerRemoveChildData;

struct _RygelMediaExportDBContainer {
	RygelMediaContainer parent_instance;
	RygelMediaExportDBContainerPrivate * priv;
	RygelMediaExportMediaCache* media_db;
};

struct _RygelMediaExportDBContainerClass {
	RygelMediaContainerClass parent_class;
	gint (*count_children) (RygelMediaExportDBContainer* self);
	void (*search) (RygelMediaExportDBContainer* self, RygelSearchExpression* expression, guint offset, guint max_count, const gchar* sort_criteria, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	RygelMediaObjects* (*search_finish) (RygelMediaExportDBContainer* self, GAsyncResult* _res_, guint* total_matches, GError** error);
};

struct _RygelMediaExportTrackableDbContainer {
	RygelMediaExportDBContainer parent_instance;
	RygelMediaExportTrackableDbContainerPrivate * priv;
};

struct _RygelMediaExportTrackableDbContainerClass {
	RygelMediaExportDBContainerClass parent_class;
	void (*remove_child) (RygelMediaExportTrackableDbContainer* self, RygelMediaObject* object, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*remove_child_finish) (RygelMediaExportTrackableDbContainer* self, GAsyncResult* _res_);
	gchar* (*get_service_reset_token) (RygelMediaExportTrackableDbContainer* self);
	void (*set_service_reset_token) (RygelMediaExportTrackableDbContainer* self, const gchar* token);
	guint32 (*get_system_update_id) (RygelMediaExportTrackableDbContainer* self);
};

struct _RygelMediaExportTrackableDbContainerAddChildData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GAsyncReadyCallback _callback_;
	gboolean _task_complete_;
	RygelMediaExportTrackableDbContainer* self;
	RygelMediaObject* object;
	RygelMediaExportMediaCache* _tmp0_;
	RygelMediaExportMediaCache* _tmp1_;
	GError* _error_;
	GError* _tmp2_;
	const gchar* _tmp3_;
	GError * _inner_error_;
};

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 ()
struct _RygelMediaExportTrackableDbContainerRemoveChildData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GAsyncReadyCallback _callback_;
	gboolean _task_complete_;
	RygelMediaExportTrackableDbContainer* self;
	RygelMediaObject* object;
	RygelMediaExportMediaCache* _tmp0_;
	GError* _error_;
	GError* _tmp1_;
	const gchar* _tmp2_;
	GError * _inner_error_;
};


static gpointer rygel_media_export_trackable_db_container_parent_class = NULL;
static RygelTrackableContainerIface * rygel_media_export_trackable_db_container_rygel_trackable_container_parent_iface = NULL;

GType rygel_media_export_db_container_get_type (void) G_GNUC_CONST;
GType rygel_media_export_media_cache_get_type (void) G_GNUC_CONST;
GType rygel_media_export_trackable_db_container_get_type (void) G_GNUC_CONST;
RygelMediaExportTrackableDbContainer* rygel_media_export_trackable_db_container_new (const gchar* id,
                                                                                     const gchar* title);
RygelMediaExportTrackableDbContainer* rygel_media_export_trackable_db_container_construct (GType object_type,
                                                                                           const gchar* id,
                                                                                           const gchar* title);
static void rygel_media_export_trackable_db_container_real_constructed (GObject* base);
static void rygel_media_export_trackable_db_container_on_child_added (RygelMediaExportTrackableDbContainer* self,
                                                               RygelMediaObject* object);
static void _rygel_media_export_trackable_db_container_on_child_added_rygel_trackable_container_child_added (RygelTrackableContainer* _sender,
                                                                                                      RygelMediaObject* object,
                                                                                                      gpointer self);
static void rygel_media_export_trackable_db_container_on_child_removed (RygelMediaExportTrackableDbContainer* self,
                                                                 RygelMediaObject* object);
static void _rygel_media_export_trackable_db_container_on_child_removed_rygel_trackable_container_child_removed (RygelTrackableContainer* _sender,
                                                                                                          RygelMediaObject* object,
                                                                                                          gpointer self);
void rygel_media_export_media_cache_save_item (RygelMediaExportMediaCache* self,
                                               RygelMediaFileItem* item,
                                               gboolean override_guarded,
                                               GError** error);
void rygel_media_export_media_cache_save_container (RygelMediaExportMediaCache* self,
                                                    RygelMediaContainer* container,
                                                    GError** error);
static void rygel_media_export_trackable_db_container_real_add_child_data_free (gpointer _data);
static void rygel_media_export_trackable_db_container_real_add_child_async_ready_wrapper (GObject *source_object,
                                                                                   GAsyncResult *res,
                                                                                   void *user_data);
static void rygel_media_export_trackable_db_container_real_add_child (RygelTrackableContainer* base,
                                                               RygelMediaObject* object,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_);
static gboolean rygel_media_export_trackable_db_container_real_add_child_co (RygelMediaExportTrackableDbContainerAddChildData* _data_);
static void rygel_media_export_trackable_db_container_real_remove_child_data_free (gpointer _data);
static void rygel_media_export_trackable_db_container_real_remove_child_async_ready_wrapper (GObject *source_object,
                                                                                      GAsyncResult *res,
                                                                                      void *user_data);
static void rygel_media_export_trackable_db_container_real_remove_child (RygelMediaExportTrackableDbContainer* self,
                                                                  RygelMediaObject* object,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_);
void rygel_media_export_trackable_db_container_remove_child (RygelMediaExportTrackableDbContainer* self,
                                                             RygelMediaObject* object,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
void rygel_media_export_trackable_db_container_remove_child_finish (RygelMediaExportTrackableDbContainer* self,
                                                                    GAsyncResult* _res_);
static gboolean rygel_media_export_trackable_db_container_real_remove_child_co (RygelMediaExportTrackableDbContainerRemoveChildData* _data_);
GQuark rygel_media_export_media_cache_error_quark (void);
void rygel_media_export_media_cache_remove_object (RygelMediaExportMediaCache* self,
                                                   RygelMediaObject* object,
                                                   GError** error);
gchar* rygel_media_export_trackable_db_container_get_service_reset_token (RygelMediaExportTrackableDbContainer* self);
static gchar* rygel_media_export_trackable_db_container_real_get_service_reset_token (RygelMediaExportTrackableDbContainer* self);
gchar* rygel_media_export_media_cache_get_reset_token (RygelMediaExportMediaCache* self);
void rygel_media_export_trackable_db_container_set_service_reset_token (RygelMediaExportTrackableDbContainer* self,
                                                                        const gchar* token);
static void rygel_media_export_trackable_db_container_real_set_service_reset_token (RygelMediaExportTrackableDbContainer* self,
                                                                             const gchar* token);
void rygel_media_export_media_cache_save_reset_token (RygelMediaExportMediaCache* self,
                                                      const gchar* token);
guint32 rygel_media_export_trackable_db_container_get_system_update_id (RygelMediaExportTrackableDbContainer* self);
static guint32 rygel_media_export_trackable_db_container_real_get_system_update_id (RygelMediaExportTrackableDbContainer* self);
guint32 rygel_media_export_media_cache_get_update_id (RygelMediaExportMediaCache* self);


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


RygelMediaExportTrackableDbContainer*
rygel_media_export_trackable_db_container_new (const gchar* id,
                                               const gchar* title)
{
	return rygel_media_export_trackable_db_container_construct (RYGEL_MEDIA_EXPORT_TYPE_TRACKABLE_DB_CONTAINER, id, title);
}


static void
_rygel_media_export_trackable_db_container_on_child_added_rygel_trackable_container_child_added (RygelTrackableContainer* _sender,
                                                                                                 RygelMediaObject* object,
                                                                                                 gpointer self)
{
	rygel_media_export_trackable_db_container_on_child_added ((RygelMediaExportTrackableDbContainer*) self, object);
}


static void
_rygel_media_export_trackable_db_container_on_child_removed_rygel_trackable_container_child_removed (RygelTrackableContainer* _sender,
                                                                                                     RygelMediaObject* object,
                                                                                                     gpointer self)
{
	rygel_media_export_trackable_db_container_on_child_removed ((RygelMediaExportTrackableDbContainer*) self, object);
}


static void
rygel_media_export_trackable_db_container_real_constructed (GObject* base)
{
	RygelMediaExportTrackableDbContainer * self;
	self = (RygelMediaExportTrackableDbContainer*) base;
	G_OBJECT_CLASS (rygel_media_export_trackable_db_container_parent_class)->constructed ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, RygelMediaExportDBContainer));
	g_signal_connect_object ((RygelTrackableContainer*) self, "child-added", (GCallback) _rygel_media_export_trackable_db_container_on_child_added_rygel_trackable_container_child_added, self, 0);
	g_signal_connect_object ((RygelTrackableContainer*) self, "child-removed", (GCallback) _rygel_media_export_trackable_db_container_on_child_removed_rygel_trackable_container_child_removed, self, 0);
}


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


static void
rygel_media_export_trackable_db_container_on_child_added (RygelMediaExportTrackableDbContainer* self,
                                                          RygelMediaObject* object)
{
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	{
		RygelMediaExportMediaCache* cache = NULL;
		RygelMediaExportMediaCache* _tmp0_;
		RygelMediaExportMediaCache* _tmp1_;
		RygelMediaExportMediaCache* _tmp4_;
		_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		cache = _tmp1_;
		if (G_TYPE_CHECK_INSTANCE_TYPE (object, RYGEL_TYPE_MEDIA_ITEM)) {
			RygelMediaExportMediaCache* _tmp2_;
			_tmp2_ = cache;
			rygel_media_export_media_cache_save_item (_tmp2_, G_TYPE_CHECK_INSTANCE_TYPE (object, RYGEL_TYPE_MEDIA_FILE_ITEM) ? ((RygelMediaFileItem*) object) : NULL, FALSE, &_inner_error_);
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				_g_object_unref0 (cache);
				goto __catch64_g_error;
			}
		} else {
			if (G_TYPE_CHECK_INSTANCE_TYPE (object, RYGEL_TYPE_MEDIA_CONTAINER)) {
				RygelMediaExportMediaCache* _tmp3_;
				_tmp3_ = cache;
				rygel_media_export_media_cache_save_container (_tmp3_, G_TYPE_CHECK_INSTANCE_TYPE (object, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) object) : NULL, &_inner_error_);
				if (G_UNLIKELY (_inner_error_ != NULL)) {
					_g_object_unref0 (cache);
					goto __catch64_g_error;
				}
			} else {
				g_assert_not_reached ();
			}
		}
		_tmp4_ = cache;
		rygel_media_export_media_cache_save_container (_tmp4_, (RygelMediaContainer*) self, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (cache);
			goto __catch64_g_error;
		}
		_g_object_unref0 (cache);
	}
	goto __finally64;
	__catch64_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp5_;
		const gchar* _tmp6_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp5_ = _error_;
		_tmp6_ = _tmp5_->message;
		g_warning (_ ("Failed to save object: %s"), _tmp6_);
		_g_error_free0 (_error_);
	}
	__finally64:
	if (G_UNLIKELY (_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;
	}
}


static void
rygel_media_export_trackable_db_container_on_child_removed (RygelMediaExportTrackableDbContainer* self,
                                                            RygelMediaObject* object)
{
	GError * _inner_error_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	{
		RygelMediaExportMediaCache* _tmp0_;
		_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
		rygel_media_export_media_cache_save_container (_tmp0_, (RygelMediaContainer*) self, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch65_g_error;
		}
	}
	goto __finally65;
	__catch65_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp1_ = _error_;
		_tmp2_ = _tmp1_->message;
		g_warning (_ ("Failed to save object: %s"), _tmp2_);
		_g_error_free0 (_error_);
	}
	__finally65:
	if (G_UNLIKELY (_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;
	}
}


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


static void
rygel_media_export_trackable_db_container_real_add_child_async_ready_wrapper (GObject *source_object,
                                                                              GAsyncResult *res,
                                                                              void *user_data)
{
	RygelMediaExportTrackableDbContainerAddChildData* _task_data_;
	_task_data_ = g_task_get_task_data (G_TASK (res));
	if (_task_data_->_callback_ != NULL) {
		_task_data_->_callback_ (source_object, res, user_data);
	}
	_task_data_->_task_complete_ = TRUE;
}


static void
rygel_media_export_trackable_db_container_real_add_child (RygelTrackableContainer* base,
                                                          RygelMediaObject* object,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	RygelMediaExportTrackableDbContainer * self;
	RygelMediaExportTrackableDbContainerAddChildData* _data_;
	RygelMediaExportTrackableDbContainer* _tmp0_;
	RygelMediaObject* _tmp1_;
	self = (RygelMediaExportTrackableDbContainer*) base;
	_data_ = g_slice_new0 (RygelMediaExportTrackableDbContainerAddChildData);
	_data_->_callback_ = _callback_;
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, rygel_media_export_trackable_db_container_real_add_child_async_ready_wrapper, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_trackable_db_container_real_add_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_trackable_db_container_real_add_child_co (_data_);
}


static void
rygel_media_export_trackable_db_container_real_add_child_finish (RygelTrackableContainer* base,
                                                                 GAsyncResult* _res_)
{
	RygelMediaExportTrackableDbContainerAddChildData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}


static gboolean
rygel_media_export_trackable_db_container_real_add_child_co (RygelMediaExportTrackableDbContainerAddChildData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		if (G_TYPE_CHECK_INSTANCE_TYPE (_data_->object, RYGEL_TYPE_MEDIA_ITEM)) {
			_data_->_tmp0_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
			rygel_media_export_media_cache_save_item (_data_->_tmp0_, G_TYPE_CHECK_INSTANCE_TYPE (_data_->object, RYGEL_TYPE_MEDIA_FILE_ITEM) ? ((RygelMediaFileItem*) _data_->object) : NULL, FALSE, &_data_->_inner_error_);
			if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
				goto __catch66_g_error;
			}
		} else {
			if (G_TYPE_CHECK_INSTANCE_TYPE (_data_->object, RYGEL_TYPE_MEDIA_CONTAINER)) {
				_data_->_tmp1_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
				rygel_media_export_media_cache_save_container (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_TYPE (_data_->object, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _data_->object) : NULL, &_data_->_inner_error_);
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					goto __catch66_g_error;
				}
			} else {
				g_assert_not_reached ();
			}
		}
	}
	goto __finally66;
	__catch66_g_error:
	{
		_data_->_error_ = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp2_ = _data_->_error_;
		_data_->_tmp3_ = _data_->_tmp2_->message;
		g_warning (_ ("Failed to add object: %s"), _data_->_tmp3_);
		_g_error_free0 (_data_->_error_);
	}
	__finally66:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (_data_->_task_complete_ != TRUE) {
			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_trackable_db_container_real_remove_child_data_free (gpointer _data)
{
	RygelMediaExportTrackableDbContainerRemoveChildData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->object);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelMediaExportTrackableDbContainerRemoveChildData, _data_);
}


static void
rygel_media_export_trackable_db_container_real_remove_child_async_ready_wrapper (GObject *source_object,
                                                                                 GAsyncResult *res,
                                                                                 void *user_data)
{
	RygelMediaExportTrackableDbContainerRemoveChildData* _task_data_;
	_task_data_ = g_task_get_task_data (G_TASK (res));
	if (_task_data_->_callback_ != NULL) {
		_task_data_->_callback_ (source_object, res, user_data);
	}
	_task_data_->_task_complete_ = TRUE;
}


static void
rygel_media_export_trackable_db_container_real_remove_child (RygelMediaExportTrackableDbContainer* self,
                                                             RygelMediaObject* object,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	RygelMediaExportTrackableDbContainerRemoveChildData* _data_;
	RygelMediaExportTrackableDbContainer* _tmp0_;
	RygelMediaObject* _tmp1_;
	_data_ = g_slice_new0 (RygelMediaExportTrackableDbContainerRemoveChildData);
	_data_->_callback_ = _callback_;
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, rygel_media_export_trackable_db_container_real_remove_child_async_ready_wrapper, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_trackable_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_trackable_db_container_real_remove_child_co (_data_);
}


static void
rygel_media_export_trackable_db_container_real_remove_child_finish (RygelMediaExportTrackableDbContainer* self,
                                                                    GAsyncResult* _res_)
{
	RygelMediaExportTrackableDbContainerRemoveChildData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}


static gboolean
rygel_media_export_trackable_db_container_real_remove_child_co (RygelMediaExportTrackableDbContainerRemoveChildData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
		rygel_media_export_media_cache_remove_object (_data_->_tmp0_, _data_->object, &_data_->_inner_error_);
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			goto __catch67_g_error;
		}
	}
	goto __finally67;
	__catch67_g_error:
	{
		_data_->_error_ = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp1_ = _data_->_error_;
		_data_->_tmp2_ = _data_->_tmp1_->message;
		g_warning (_ ("Failed to remove object: %s"), _data_->_tmp2_);
		_g_error_free0 (_data_->_error_);
	}
	__finally67:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (_data_->_task_complete_ != TRUE) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


void
rygel_media_export_trackable_db_container_remove_child (RygelMediaExportTrackableDbContainer* self,
                                                        RygelMediaObject* object,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_GET_CLASS (self)->remove_child (self, object, _callback_, _user_data_);
}


void
rygel_media_export_trackable_db_container_remove_child_finish (RygelMediaExportTrackableDbContainer* self,
                                                               GAsyncResult* _res_)
{
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_GET_CLASS (self)->remove_child_finish (self, _res_);
}


static gchar*
rygel_media_export_trackable_db_container_real_get_service_reset_token (RygelMediaExportTrackableDbContainer* self)
{
	gchar* result = NULL;
	RygelMediaExportMediaCache* _tmp0_;
	gchar* _tmp1_;
	_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
	_tmp1_ = rygel_media_export_media_cache_get_reset_token (_tmp0_);
	result = _tmp1_;
	return result;
}


gchar*
rygel_media_export_trackable_db_container_get_service_reset_token (RygelMediaExportTrackableDbContainer* self)
{
	g_return_val_if_fail (self != NULL, NULL);
	return RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_GET_CLASS (self)->get_service_reset_token (self);
}


static void
rygel_media_export_trackable_db_container_real_set_service_reset_token (RygelMediaExportTrackableDbContainer* self,
                                                                        const gchar* token)
{
	RygelMediaExportMediaCache* _tmp0_;
	g_return_if_fail (token != NULL);
	_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
	rygel_media_export_media_cache_save_reset_token (_tmp0_, token);
}


void
rygel_media_export_trackable_db_container_set_service_reset_token (RygelMediaExportTrackableDbContainer* self,
                                                                   const gchar* token)
{
	g_return_if_fail (self != NULL);
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_GET_CLASS (self)->set_service_reset_token (self, token);
}


static guint32
rygel_media_export_trackable_db_container_real_get_system_update_id (RygelMediaExportTrackableDbContainer* self)
{
	guint32 result = 0U;
	guint32 id = 0U;
	RygelMediaExportMediaCache* _tmp0_;
	_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
	id = rygel_media_export_media_cache_get_update_id (_tmp0_);
	result = id;
	return result;
}


guint32
rygel_media_export_trackable_db_container_get_system_update_id (RygelMediaExportTrackableDbContainer* self)
{
	g_return_val_if_fail (self != NULL, 0U);
	return RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_GET_CLASS (self)->get_system_update_id (self);
}


static void
rygel_media_export_trackable_db_container_class_init (RygelMediaExportTrackableDbContainerClass * klass)
{
	rygel_media_export_trackable_db_container_parent_class = g_type_class_peek_parent (klass);
	((GObjectClass *) klass)->constructed = (void (*) (GObject *)) rygel_media_export_trackable_db_container_real_constructed;
	((RygelMediaExportTrackableDbContainerClass *) klass)->remove_child = (void (*) (RygelMediaExportTrackableDbContainer *, RygelMediaObject*, GAsyncReadyCallback, gpointer)) rygel_media_export_trackable_db_container_real_remove_child;
	((RygelMediaExportTrackableDbContainerClass *) klass)->remove_child_finish = (void (*) (RygelMediaExportTrackableDbContainer *, GAsyncResult*)) rygel_media_export_trackable_db_container_real_remove_child_finish;
	((RygelMediaExportTrackableDbContainerClass *) klass)->get_service_reset_token = (gchar* (*) (RygelMediaExportTrackableDbContainer *)) rygel_media_export_trackable_db_container_real_get_service_reset_token;
	((RygelMediaExportTrackableDbContainerClass *) klass)->set_service_reset_token = (void (*) (RygelMediaExportTrackableDbContainer *, const gchar*)) rygel_media_export_trackable_db_container_real_set_service_reset_token;
	((RygelMediaExportTrackableDbContainerClass *) klass)->get_system_update_id = (guint32 (*) (RygelMediaExportTrackableDbContainer *)) rygel_media_export_trackable_db_container_real_get_system_update_id;
}


static void
rygel_media_export_trackable_db_container_rygel_trackable_container_interface_init (RygelTrackableContainerIface * iface)
{
	rygel_media_export_trackable_db_container_rygel_trackable_container_parent_iface = g_type_interface_peek_parent (iface);
	iface->add_child = (void (*) (RygelTrackableContainer *, RygelMediaObject*, GAsyncReadyCallback, gpointer)) rygel_media_export_trackable_db_container_real_add_child;
	iface->add_child_finish = (void (*) (RygelTrackableContainer *, GAsyncResult*)) rygel_media_export_trackable_db_container_real_add_child_finish;
	iface->remove_child = (void (*) (RygelTrackableContainer *, RygelMediaObject*, GAsyncReadyCallback, gpointer)) rygel_media_export_trackable_db_container_remove_child;
	iface->remove_child_finish = (void (*) (RygelTrackableContainer *, GAsyncResult*)) rygel_media_export_trackable_db_container_remove_child_finish;
	iface->get_service_reset_token = (gchar* (*) (RygelTrackableContainer *)) rygel_media_export_trackable_db_container_get_service_reset_token;
	iface->set_service_reset_token = (void (*) (RygelTrackableContainer *, const gchar*)) rygel_media_export_trackable_db_container_set_service_reset_token;
	iface->get_system_update_id = (guint32 (*) (RygelTrackableContainer *)) rygel_media_export_trackable_db_container_get_system_update_id;
}


static void
rygel_media_export_trackable_db_container_instance_init (RygelMediaExportTrackableDbContainer * self)
{
}


/**
 * A DB container that is trackable.
 */
GType
rygel_media_export_trackable_db_container_get_type (void)
{
	static volatile gsize rygel_media_export_trackable_db_container_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_trackable_db_container_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportTrackableDbContainerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_trackable_db_container_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelMediaExportTrackableDbContainer), 0, (GInstanceInitFunc) rygel_media_export_trackable_db_container_instance_init, NULL };
		static const GInterfaceInfo rygel_trackable_container_info = { (GInterfaceInitFunc) rygel_media_export_trackable_db_container_rygel_trackable_container_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType rygel_media_export_trackable_db_container_type_id;
		rygel_media_export_trackable_db_container_type_id = g_type_register_static (RYGEL_MEDIA_EXPORT_TYPE_DB_CONTAINER, "RygelMediaExportTrackableDbContainer", &g_define_type_info, 0);
		g_type_add_interface_static (rygel_media_export_trackable_db_container_type_id, RYGEL_TYPE_TRACKABLE_CONTAINER, &rygel_trackable_container_info);
		g_once_init_leave (&rygel_media_export_trackable_db_container_type_id__volatile, rygel_media_export_trackable_db_container_type_id);
	}
	return rygel_media_export_trackable_db_container_type_id__volatile;
}



