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

#include <glib.h>
#include <glib-object.h>
#include <rygel-server.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.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;
#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_;
	GSimpleAsyncResult* _async_result;
	RygelMediaExportTrackableDbContainer* self;
	RygelMediaObject* object;
	RygelMediaObject* _tmp0_;
	RygelMediaExportMediaCache* _tmp1_;
	RygelMediaObject* _tmp2_;
	RygelMediaObject* _tmp3_;
	RygelMediaExportMediaCache* _tmp4_;
	RygelMediaObject* _tmp5_;
	GError* _error_;
	GError* _tmp6_;
	const gchar* _tmp7_;
	GError * _inner_error_;
};

typedef enum  {
	RYGEL_MEDIA_EXPORT_DATABASE_ERROR_IO_ERROR,
	RYGEL_MEDIA_EXPORT_DATABASE_ERROR_SQLITE_ERROR
} RygelMediaExportDatabaseError;
#define RYGEL_MEDIA_EXPORT_DATABASE_ERROR rygel_media_export_database_error_quark ()
typedef enum  {
	RYGEL_MEDIA_EXPORT_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_;
	GSimpleAsyncResult* _async_result;
	RygelMediaExportTrackableDbContainer* self;
	RygelMediaObject* object;
	RygelMediaExportMediaCache* _tmp0_;
	RygelMediaObject* _tmp1_;
	GError* _error_;
	GError* _tmp2_;
	const gchar* _tmp3_;
	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;
enum  {
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_DUMMY_PROPERTY
};
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, RygelMediaItem* 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 (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 (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_database_error_quark (void);
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;
	const gchar* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_val_if_fail (id != NULL, NULL);
	g_return_val_if_fail (title != NULL, NULL);
	_tmp0_ = id;
	_tmp1_ = title;
	self = (RygelMediaExportTrackableDbContainer*) g_object_new (object_type, "id", _tmp0_, "title", _tmp1_, "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_ = NULL;
		RygelMediaExportMediaCache* _tmp1_ = NULL;
		RygelMediaObject* _tmp2_ = NULL;
		RygelMediaExportMediaCache* _tmp8_ = NULL;
		_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
		_tmp1_ = _g_object_ref0 (_tmp0_);
		cache = _tmp1_;
		_tmp2_ = object;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, RYGEL_TYPE_MEDIA_ITEM)) {
			RygelMediaExportMediaCache* _tmp3_ = NULL;
			RygelMediaObject* _tmp4_ = NULL;
			_tmp3_ = cache;
			_tmp4_ = object;
			rygel_media_export_media_cache_save_item (_tmp3_, G_TYPE_CHECK_INSTANCE_TYPE (_tmp4_, RYGEL_TYPE_MEDIA_ITEM) ? ((RygelMediaItem*) _tmp4_) : NULL, FALSE, &_inner_error_);
			if (G_UNLIKELY (_inner_error_ != NULL)) {
				_g_object_unref0 (cache);
				goto __catch70_g_error;
			}
		} else {
			RygelMediaObject* _tmp5_ = NULL;
			_tmp5_ = object;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp5_, RYGEL_TYPE_MEDIA_CONTAINER)) {
				RygelMediaExportMediaCache* _tmp6_ = NULL;
				RygelMediaObject* _tmp7_ = NULL;
				_tmp6_ = cache;
				_tmp7_ = object;
				rygel_media_export_media_cache_save_container (_tmp6_, G_TYPE_CHECK_INSTANCE_TYPE (_tmp7_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _tmp7_) : NULL, &_inner_error_);
				if (G_UNLIKELY (_inner_error_ != NULL)) {
					_g_object_unref0 (cache);
					goto __catch70_g_error;
				}
			} else {
				g_assert_not_reached ();
			}
		}
		_tmp8_ = cache;
		rygel_media_export_media_cache_save_container (_tmp8_, (RygelMediaContainer*) self, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (cache);
			goto __catch70_g_error;
		}
		_g_object_unref0 (cache);
	}
	goto __finally70;
	__catch70_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp9_ = NULL;
		const gchar* _tmp10_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp9_ = _error_;
		_tmp10_ = _tmp9_->message;
		g_warning ("rygel-media-export-trackable-db-container.vala:56: Failed to save obje" \
"ct: %s", _tmp10_);
		_g_error_free0 (_error_);
	}
	__finally70:
	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_ = NULL;
		_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
		rygel_media_export_media_cache_save_container (_tmp0_, (RygelMediaContainer*) self, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch71_g_error;
		}
	}
	goto __finally71;
	__catch71_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp1_ = NULL;
		const gchar* _tmp2_ = NULL;
		_error_ = _inner_error_;
		_inner_error_ = NULL;
		_tmp1_ = _error_;
		_tmp2_ = _tmp1_->message;
		g_warning ("rygel-media-export-trackable-db-container.vala:64: Failed to save obje" \
"ct: %s", _tmp2_);
		_g_error_free0 (_error_);
	}
	__finally71:
	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 (RygelTrackableContainer* base, RygelMediaObject* object, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	RygelMediaExportTrackableDbContainer * self;
	RygelMediaExportTrackableDbContainerAddChildData* _data_;
	RygelMediaExportTrackableDbContainer* _tmp0_ = NULL;
	RygelMediaObject* _tmp1_ = NULL;
	RygelMediaObject* _tmp2_ = NULL;
	self = (RygelMediaExportTrackableDbContainer*) base;
	_data_ = g_slice_new0 (RygelMediaExportTrackableDbContainerAddChildData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_trackable_db_container_real_add_child);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_trackable_db_container_real_add_child_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = object;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (_data_->object);
	_data_->object = _tmp2_;
	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_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


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:
	{
		_data_->_tmp0_ = NULL;
		_data_->_tmp0_ = _data_->object;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp0_, RYGEL_TYPE_MEDIA_ITEM)) {
			_data_->_tmp1_ = NULL;
			_data_->_tmp1_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
			_data_->_tmp2_ = NULL;
			_data_->_tmp2_ = _data_->object;
			rygel_media_export_media_cache_save_item (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp2_, RYGEL_TYPE_MEDIA_ITEM) ? ((RygelMediaItem*) _data_->_tmp2_) : NULL, FALSE, &_data_->_inner_error_);
			if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
				goto __catch72_g_error;
			}
		} else {
			_data_->_tmp3_ = NULL;
			_data_->_tmp3_ = _data_->object;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp3_, RYGEL_TYPE_MEDIA_CONTAINER)) {
				_data_->_tmp4_ = NULL;
				_data_->_tmp4_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
				_data_->_tmp5_ = NULL;
				_data_->_tmp5_ = _data_->object;
				rygel_media_export_media_cache_save_container (_data_->_tmp4_, G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp5_, RYGEL_TYPE_MEDIA_CONTAINER) ? ((RygelMediaContainer*) _data_->_tmp5_) : NULL, &_data_->_inner_error_);
				if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
					goto __catch72_g_error;
				}
			} else {
				g_assert_not_reached ();
			}
		}
	}
	goto __finally72;
	__catch72_g_error:
	{
		_data_->_error_ = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp6_ = NULL;
		_data_->_tmp6_ = _data_->_error_;
		_data_->_tmp7_ = NULL;
		_data_->_tmp7_ = _data_->_tmp6_->message;
		g_warning ("rygel-media-export-trackable-db-container.vala:79: Failed to add objec" \
"t: %s", _data_->_tmp7_);
		_g_error_free0 (_data_->_error_);
	}
	__finally72:
	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_);
		return FALSE;
	}
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	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 (RygelMediaExportTrackableDbContainer* self, RygelMediaObject* object, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	RygelMediaExportTrackableDbContainerRemoveChildData* _data_;
	RygelMediaExportTrackableDbContainer* _tmp0_ = NULL;
	RygelMediaObject* _tmp1_ = NULL;
	RygelMediaObject* _tmp2_ = NULL;
	_data_ = g_slice_new0 (RygelMediaExportTrackableDbContainerRemoveChildData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_media_export_trackable_db_container_real_remove_child);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_media_export_trackable_db_container_real_remove_child_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = object;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (_data_->object);
	_data_->object = _tmp2_;
	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_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


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_ = NULL;
		_data_->_tmp0_ = ((RygelMediaExportDBContainer*) _data_->self)->media_db;
		_data_->_tmp1_ = NULL;
		_data_->_tmp1_ = _data_->object;
		rygel_media_export_media_cache_remove_object (_data_->_tmp0_, _data_->_tmp1_, &_data_->_inner_error_);
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			goto __catch73_g_error;
		}
	}
	goto __finally73;
	__catch73_g_error:
	{
		_data_->_error_ = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp2_ = NULL;
		_data_->_tmp2_ = _data_->_error_;
		_data_->_tmp3_ = NULL;
		_data_->_tmp3_ = _data_->_tmp2_->message;
		g_warning ("rygel-media-export-trackable-db-container.vala:87: Failed to remove ob" \
"ject: %s", _data_->_tmp3_);
		_g_error_free0 (_data_->_error_);
	}
	__finally73:
	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_);
		return FALSE;
	}
	if (_data_->_state_ == 0) {
		g_simple_async_result_complete_in_idle (_data_->_async_result);
	} else {
		g_simple_async_result_complete (_data_->_async_result);
	}
	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_ = NULL;
	gchar* _tmp1_ = NULL;
	_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_ = NULL;
	const gchar* _tmp1_ = NULL;
	g_return_if_fail (token != NULL);
	_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
	_tmp1_ = token;
	rygel_media_export_media_cache_save_reset_token (_tmp0_, _tmp1_);
}


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_ = NULL;
	guint32 _tmp1_ = 0U;
	_tmp0_ = ((RygelMediaExportDBContainer*) self)->media_db;
	_tmp1_ = rygel_media_export_media_cache_get_update_id (_tmp0_);
	id = _tmp1_;
	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);
	G_OBJECT_CLASS (klass)->constructed = rygel_media_export_trackable_db_container_real_constructed;
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_CLASS (klass)->remove_child = rygel_media_export_trackable_db_container_real_remove_child;
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_CLASS (klass)->remove_child_finish = rygel_media_export_trackable_db_container_real_remove_child_finish;
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_CLASS (klass)->get_service_reset_token = rygel_media_export_trackable_db_container_real_get_service_reset_token;
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_CLASS (klass)->set_service_reset_token = rygel_media_export_trackable_db_container_real_set_service_reset_token;
	RYGEL_MEDIA_EXPORT_TRACKABLE_DB_CONTAINER_CLASS (klass)->get_system_update_id = 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*)) rygel_media_export_trackable_db_container_real_add_child;
	iface->add_child_finish = rygel_media_export_trackable_db_container_real_add_child_finish;
	iface->remove_child = (void (*)(RygelTrackableContainer*, RygelMediaObject*)) rygel_media_export_trackable_db_container_remove_child;
	iface->remove_child_finish = 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;
}



