/* rygel-object-removal-queue.c generated by valac 0.32.1, the Vala compiler
 * generated from rygel-object-removal-queue.vala, do not modify */

/*
 * Copyright (C) 2010 Nokia Corporation.
 *
 * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.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 <glib.h>
#include <glib-object.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>


#define RYGEL_TYPE_OBJECT_REMOVAL_QUEUE (rygel_object_removal_queue_get_type ())
#define RYGEL_OBJECT_REMOVAL_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_OBJECT_REMOVAL_QUEUE, RygelObjectRemovalQueue))
#define RYGEL_OBJECT_REMOVAL_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_OBJECT_REMOVAL_QUEUE, RygelObjectRemovalQueueClass))
#define RYGEL_IS_OBJECT_REMOVAL_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_OBJECT_REMOVAL_QUEUE))
#define RYGEL_IS_OBJECT_REMOVAL_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_OBJECT_REMOVAL_QUEUE))
#define RYGEL_OBJECT_REMOVAL_QUEUE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_OBJECT_REMOVAL_QUEUE, RygelObjectRemovalQueueClass))

typedef struct _RygelObjectRemovalQueue RygelObjectRemovalQueue;
typedef struct _RygelObjectRemovalQueueClass RygelObjectRemovalQueueClass;
typedef struct _RygelObjectRemovalQueuePrivate RygelObjectRemovalQueuePrivate;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define RYGEL_TYPE_MEDIA_OBJECT (rygel_media_object_get_type ())
#define RYGEL_MEDIA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObject))
#define RYGEL_MEDIA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObjectClass))
#define RYGEL_IS_MEDIA_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_OBJECT))
#define RYGEL_IS_MEDIA_OBJECT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_OBJECT))
#define RYGEL_MEDIA_OBJECT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_OBJECT, RygelMediaObjectClass))

typedef struct _RygelMediaObject RygelMediaObject;
typedef struct _RygelMediaObjectClass RygelMediaObjectClass;
typedef struct _Block10Data Block10Data;

#define RYGEL_TYPE_MEDIA_CONTAINER (rygel_media_container_get_type ())
#define RYGEL_MEDIA_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_CONTAINER, RygelMediaContainer))
#define RYGEL_MEDIA_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_CONTAINER, RygelMediaContainerClass))
#define RYGEL_IS_MEDIA_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_CONTAINER))
#define RYGEL_IS_MEDIA_CONTAINER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_CONTAINER))
#define RYGEL_MEDIA_CONTAINER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_CONTAINER, RygelMediaContainerClass))

typedef struct _RygelMediaContainer RygelMediaContainer;
typedef struct _RygelMediaContainerClass RygelMediaContainerClass;

#define RYGEL_TYPE_WRITABLE_CONTAINER (rygel_writable_container_get_type ())
#define RYGEL_WRITABLE_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_WRITABLE_CONTAINER, RygelWritableContainer))
#define RYGEL_IS_WRITABLE_CONTAINER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_WRITABLE_CONTAINER))
#define RYGEL_WRITABLE_CONTAINER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RYGEL_TYPE_WRITABLE_CONTAINER, RygelWritableContainerIface))

typedef struct _RygelWritableContainer RygelWritableContainer;
typedef struct _RygelWritableContainerIface RygelWritableContainerIface;

#define RYGEL_TYPE_MEDIA_ITEM (rygel_media_item_get_type ())
#define RYGEL_MEDIA_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_ITEM, RygelMediaItem))
#define RYGEL_MEDIA_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_ITEM, RygelMediaItemClass))
#define RYGEL_IS_MEDIA_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_ITEM))
#define RYGEL_IS_MEDIA_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_ITEM))
#define RYGEL_MEDIA_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_ITEM, RygelMediaItemClass))

typedef struct _RygelMediaItem RygelMediaItem;
typedef struct _RygelMediaItemClass RygelMediaItemClass;

#define RYGEL_TYPE_MEDIA_FILE_ITEM (rygel_media_file_item_get_type ())
#define RYGEL_MEDIA_FILE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_TYPE_MEDIA_FILE_ITEM, RygelMediaFileItem))
#define RYGEL_MEDIA_FILE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), RYGEL_TYPE_MEDIA_FILE_ITEM, RygelMediaFileItemClass))
#define RYGEL_IS_MEDIA_FILE_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_TYPE_MEDIA_FILE_ITEM))
#define RYGEL_IS_MEDIA_FILE_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), RYGEL_TYPE_MEDIA_FILE_ITEM))
#define RYGEL_MEDIA_FILE_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), RYGEL_TYPE_MEDIA_FILE_ITEM, RygelMediaFileItemClass))

typedef struct _RygelMediaFileItem RygelMediaFileItem;
typedef struct _RygelMediaFileItemClass RygelMediaFileItemClass;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _RygelObjectRemovalQueueRemoveNowData RygelObjectRemovalQueueRemoveNowData;

struct _RygelObjectRemovalQueue {
	GObject parent_instance;
	RygelObjectRemovalQueuePrivate * priv;
};

struct _RygelObjectRemovalQueueClass {
	GObjectClass parent_class;
};

struct _RygelObjectRemovalQueuePrivate {
	GeeHashMap* object_timeouts;
};

struct _Block10Data {
	int _ref_count_;
	RygelObjectRemovalQueue* self;
	RygelMediaObject* object;
	GCancellable* cancellable;
};

struct _RygelWritableContainerIface {
	GTypeInterface parent_iface;
	void (*add_item) (RygelWritableContainer* self, RygelMediaFileItem* item, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*add_item_finish) (RygelWritableContainer* self, GAsyncResult* _res_, GError** error);
	void (*add_container) (RygelWritableContainer* self, RygelMediaContainer* container, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*add_container_finish) (RygelWritableContainer* self, GAsyncResult* _res_, GError** error);
	void (*add_reference) (RygelWritableContainer* self, RygelMediaObject* object, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	gchar* (*add_reference_finish) (RygelWritableContainer* self, GAsyncResult* _res_, GError** error);
	void (*remove_item) (RygelWritableContainer* self, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*remove_item_finish) (RygelWritableContainer* self, GAsyncResult* _res_, GError** error);
	void (*remove_container) (RygelWritableContainer* self, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*remove_container_finish) (RygelWritableContainer* self, GAsyncResult* _res_, GError** error);
	GeeArrayList* (*get_create_classes) (RygelWritableContainer* self);
	void (*set_create_classes) (RygelWritableContainer* self, GeeArrayList* value);
};

struct _RygelObjectRemovalQueueRemoveNowData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GSimpleAsyncResult* _async_result;
	RygelObjectRemovalQueue* self;
	RygelMediaObject* object;
	GCancellable* cancellable;
	GeeHashMap* _tmp0_;
	RygelMediaObject* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	RygelWritableContainer* parent;
	RygelMediaObject* _tmp4_;
	RygelMediaContainer* _tmp5_;
	RygelMediaContainer* _tmp6_;
	RygelWritableContainer* _tmp7_;
	RygelMediaObject* _tmp8_;
	RygelWritableContainer* _tmp9_;
	RygelMediaObject* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	GCancellable* _tmp13_;
	RygelWritableContainer* _tmp14_;
	RygelMediaObject* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	GCancellable* _tmp18_;
	RygelMediaObject* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	GError* err;
	RygelMediaObject* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	GError* _tmp25_;
	const gchar* _tmp26_;
	GError * _inner_error_;
};


static gpointer rygel_object_removal_queue_parent_class = NULL;
static RygelObjectRemovalQueue* rygel_object_removal_queue_removal_queue;
static RygelObjectRemovalQueue* rygel_object_removal_queue_removal_queue = NULL;

GType rygel_object_removal_queue_get_type (void) G_GNUC_CONST;
#define RYGEL_OBJECT_REMOVAL_QUEUE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), RYGEL_TYPE_OBJECT_REMOVAL_QUEUE, RygelObjectRemovalQueuePrivate))
enum  {
	RYGEL_OBJECT_REMOVAL_QUEUE_DUMMY_PROPERTY
};
#define RYGEL_OBJECT_REMOVAL_QUEUE_TIMEOUT ((guint) 35)
RygelObjectRemovalQueue* rygel_object_removal_queue_get_default (void);
static RygelObjectRemovalQueue* rygel_object_removal_queue_new (void);
static RygelObjectRemovalQueue* rygel_object_removal_queue_construct (GType object_type);
GType rygel_media_object_get_type (void) G_GNUC_CONST;
void rygel_object_removal_queue_queue (RygelObjectRemovalQueue* self, RygelMediaObject* object, GCancellable* cancellable);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
GType rygel_media_container_get_type (void) G_GNUC_CONST;
RygelMediaContainer* rygel_media_object_get_parent_ref (RygelMediaObject* self);
RygelMediaContainer* rygel_media_object_get_parent (RygelMediaObject* self);
void rygel_media_object_set_parent_ref (RygelMediaObject* self, RygelMediaContainer* value);
static gboolean __lambda11_ (Block10Data* _data10_);
const gchar* rygel_media_object_get_id (RygelMediaObject* self);
void rygel_object_removal_queue_remove_now (RygelObjectRemovalQueue* self, RygelMediaObject* object, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
void rygel_object_removal_queue_remove_now_finish (RygelObjectRemovalQueue* self, GAsyncResult* _res_);
static gboolean ___lambda11__gsource_func (gpointer self);
gboolean rygel_object_removal_queue_dequeue (RygelObjectRemovalQueue* self, RygelMediaObject* object);
static void rygel_object_removal_queue_remove_now_data_free (gpointer _data);
static gboolean rygel_object_removal_queue_remove_now_co (RygelObjectRemovalQueueRemoveNowData* _data_);
GType rygel_media_item_get_type (void) G_GNUC_CONST;
GType rygel_media_file_item_get_type (void) G_GNUC_CONST;
GType rygel_writable_container_get_type (void) G_GNUC_CONST;
void rygel_writable_container_remove_item (RygelWritableContainer* self, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
void rygel_writable_container_remove_item_finish (RygelWritableContainer* self, GAsyncResult* _res_, GError** error);
static void rygel_object_removal_queue_remove_now_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
void rygel_writable_container_remove_container (RygelWritableContainer* self, const gchar* id, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
void rygel_writable_container_remove_container_finish (RygelWritableContainer* self, GAsyncResult* _res_, GError** error);
static void rygel_object_removal_queue_finalize (GObject* obj);


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


RygelObjectRemovalQueue* rygel_object_removal_queue_get_default (void) {
	RygelObjectRemovalQueue* result = NULL;
	RygelObjectRemovalQueue* _tmp0_ = NULL;
	gboolean _tmp1_ = FALSE;
	RygelObjectRemovalQueue* _tmp3_ = NULL;
	RygelObjectRemovalQueue* _tmp4_ = NULL;
	_tmp0_ = rygel_object_removal_queue_removal_queue;
	_tmp1_ = G_UNLIKELY (_tmp0_ == NULL);
	if (_tmp1_) {
		RygelObjectRemovalQueue* _tmp2_ = NULL;
		_tmp2_ = rygel_object_removal_queue_new ();
		_g_object_unref0 (rygel_object_removal_queue_removal_queue);
		rygel_object_removal_queue_removal_queue = _tmp2_;
	}
	_tmp3_ = rygel_object_removal_queue_removal_queue;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	result = _tmp4_;
	return result;
}


static Block10Data* block10_data_ref (Block10Data* _data10_) {
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}


static void block10_data_unref (void * _userdata_) {
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		RygelObjectRemovalQueue* self;
		self = _data10_->self;
		_g_object_unref0 (_data10_->object);
		_g_object_unref0 (_data10_->cancellable);
		_g_object_unref0 (self);
		g_slice_free (Block10Data, _data10_);
	}
}


static gboolean __lambda11_ (Block10Data* _data10_) {
	RygelObjectRemovalQueue* self;
	gboolean result = FALSE;
	RygelMediaObject* _tmp0_ = NULL;
	const gchar* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	RygelMediaObject* _tmp3_ = NULL;
	GCancellable* _tmp4_ = NULL;
	self = _data10_->self;
	_tmp0_ = _data10_->object;
	_tmp1_ = rygel_media_object_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	g_debug ("rygel-object-removal-queue.vala:51: Timeout on temporary object '%s'.", _tmp2_);
	_tmp3_ = _data10_->object;
	_tmp4_ = _data10_->cancellable;
	rygel_object_removal_queue_remove_now (self, _tmp3_, _tmp4_, NULL, NULL);
	result = FALSE;
	return result;
}


static gboolean ___lambda11__gsource_func (gpointer self) {
	gboolean result;
	result = __lambda11_ (self);
	return result;
}


void rygel_object_removal_queue_queue (RygelObjectRemovalQueue* self, RygelMediaObject* object, GCancellable* cancellable) {
	Block10Data* _data10_;
	RygelMediaObject* _tmp0_ = NULL;
	RygelMediaObject* _tmp1_ = NULL;
	GCancellable* _tmp2_ = NULL;
	GCancellable* _tmp3_ = NULL;
	RygelMediaObject* _tmp4_ = NULL;
	RygelMediaContainer* _tmp5_ = NULL;
	RygelMediaContainer* _tmp6_ = NULL;
	guint timeout = 0U;
	guint _tmp11_ = 0U;
	GeeHashMap* _tmp12_ = NULL;
	RygelMediaObject* _tmp13_ = NULL;
	const gchar* _tmp14_ = NULL;
	const gchar* _tmp15_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_data10_->self = g_object_ref (self);
	_tmp0_ = object;
	_tmp1_ = _g_object_ref0 (_tmp0_);
	_g_object_unref0 (_data10_->object);
	_data10_->object = _tmp1_;
	_tmp2_ = cancellable;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	_g_object_unref0 (_data10_->cancellable);
	_data10_->cancellable = _tmp3_;
	_tmp4_ = _data10_->object;
	_tmp5_ = rygel_media_object_get_parent_ref (_tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ == NULL) {
		RygelMediaObject* _tmp7_ = NULL;
		RygelMediaObject* _tmp8_ = NULL;
		RygelMediaContainer* _tmp9_ = NULL;
		RygelMediaContainer* _tmp10_ = NULL;
		_tmp7_ = _data10_->object;
		_tmp8_ = _data10_->object;
		_tmp9_ = rygel_media_object_get_parent (_tmp8_);
		_tmp10_ = _tmp9_;
		rygel_media_object_set_parent_ref (_tmp7_, _tmp10_);
	}
	_tmp11_ = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, RYGEL_OBJECT_REMOVAL_QUEUE_TIMEOUT, ___lambda11__gsource_func, block10_data_ref (_data10_), block10_data_unref);
	timeout = _tmp11_;
	_tmp12_ = self->priv->object_timeouts;
	_tmp13_ = _data10_->object;
	_tmp14_ = rygel_media_object_get_id (_tmp13_);
	_tmp15_ = _tmp14_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp12_, _tmp15_, (gpointer) ((guintptr) timeout));
	block10_data_unref (_data10_);
	_data10_ = NULL;
}


gboolean rygel_object_removal_queue_dequeue (RygelObjectRemovalQueue* self, RygelMediaObject* object) {
	gboolean result = FALSE;
	guint timeout = 0U;
	GeeHashMap* _tmp0_ = NULL;
	RygelMediaObject* _tmp1_ = NULL;
	const gchar* _tmp2_ = NULL;
	const gchar* _tmp3_ = NULL;
	gpointer _tmp4_ = NULL;
	gboolean _tmp5_ = FALSE;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (object != NULL, FALSE);
	_tmp0_ = self->priv->object_timeouts;
	_tmp1_ = object;
	_tmp2_ = rygel_media_object_get_id (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp5_ = gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, _tmp3_, &_tmp4_);
	timeout = _tmp4_;
	if (_tmp5_) {
		guint _tmp6_ = 0U;
		_tmp6_ = timeout;
		g_source_remove (_tmp6_);
		result = TRUE;
		return result;
	} else {
		result = FALSE;
		return result;
	}
}


static void rygel_object_removal_queue_remove_now_data_free (gpointer _data) {
	RygelObjectRemovalQueueRemoveNowData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->object);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelObjectRemovalQueueRemoveNowData, _data_);
}


void rygel_object_removal_queue_remove_now (RygelObjectRemovalQueue* self, RygelMediaObject* object, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	RygelObjectRemovalQueueRemoveNowData* _data_;
	RygelObjectRemovalQueue* _tmp0_ = NULL;
	RygelMediaObject* _tmp1_ = NULL;
	RygelMediaObject* _tmp2_ = NULL;
	GCancellable* _tmp3_ = NULL;
	GCancellable* _tmp4_ = NULL;
	_data_ = g_slice_new0 (RygelObjectRemovalQueueRemoveNowData);
	_data_->_async_result = g_simple_async_result_new (G_OBJECT (self), _callback_, _user_data_, rygel_object_removal_queue_remove_now);
	g_simple_async_result_set_op_res_gpointer (_data_->_async_result, _data_, rygel_object_removal_queue_remove_now_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_;
	_tmp3_ = cancellable;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp4_;
	rygel_object_removal_queue_remove_now_co (_data_);
}


void rygel_object_removal_queue_remove_now_finish (RygelObjectRemovalQueue* self, GAsyncResult* _res_) {
	RygelObjectRemovalQueueRemoveNowData* _data_;
	_data_ = g_simple_async_result_get_op_res_gpointer (G_SIMPLE_ASYNC_RESULT (_res_));
}


static void rygel_object_removal_queue_remove_now_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	RygelObjectRemovalQueueRemoveNowData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	rygel_object_removal_queue_remove_now_co (_data_);
}


static gboolean rygel_object_removal_queue_remove_now_co (RygelObjectRemovalQueueRemoveNowData* _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_->_tmp0_ = NULL;
	_data_->_tmp0_ = _data_->self->priv->object_timeouts;
	_data_->_tmp1_ = NULL;
	_data_->_tmp1_ = _data_->object;
	_data_->_tmp2_ = NULL;
	_data_->_tmp2_ = rygel_media_object_get_id (_data_->_tmp1_);
	_data_->_tmp3_ = NULL;
	_data_->_tmp3_ = _data_->_tmp2_;
	gee_abstract_map_unset ((GeeAbstractMap*) _data_->_tmp0_, _data_->_tmp3_, NULL);
	_data_->_tmp4_ = NULL;
	_data_->_tmp4_ = _data_->object;
	_data_->_tmp5_ = NULL;
	_data_->_tmp5_ = rygel_media_object_get_parent (_data_->_tmp4_);
	_data_->_tmp6_ = NULL;
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = NULL;
	_data_->_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp6_, RYGEL_TYPE_WRITABLE_CONTAINER) ? ((RygelWritableContainer*) _data_->_tmp6_) : NULL);
	_data_->parent = _data_->_tmp7_;
	{
		_data_->_tmp8_ = NULL;
		_data_->_tmp8_ = _data_->object;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp8_, RYGEL_TYPE_MEDIA_ITEM)) {
			_data_->_tmp9_ = NULL;
			_data_->_tmp9_ = _data_->parent;
			_data_->_tmp10_ = NULL;
			_data_->_tmp10_ = _data_->object;
			_data_->_tmp11_ = NULL;
			_data_->_tmp11_ = rygel_media_object_get_id (_data_->_tmp10_);
			_data_->_tmp12_ = NULL;
			_data_->_tmp12_ = _data_->_tmp11_;
			_data_->_tmp13_ = NULL;
			_data_->_tmp13_ = _data_->cancellable;
			_data_->_state_ = 1;
			rygel_writable_container_remove_item (_data_->_tmp9_, _data_->_tmp12_, _data_->_tmp13_, rygel_object_removal_queue_remove_now_ready, _data_);
			return FALSE;
			_state_1:
			rygel_writable_container_remove_item_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error_);
			if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
				goto __catch71_g_error;
			}
		} else {
			_data_->_tmp14_ = NULL;
			_data_->_tmp14_ = _data_->parent;
			_data_->_tmp15_ = NULL;
			_data_->_tmp15_ = _data_->object;
			_data_->_tmp16_ = NULL;
			_data_->_tmp16_ = rygel_media_object_get_id (_data_->_tmp15_);
			_data_->_tmp17_ = NULL;
			_data_->_tmp17_ = _data_->_tmp16_;
			_data_->_tmp18_ = NULL;
			_data_->_tmp18_ = _data_->cancellable;
			_data_->_state_ = 2;
			rygel_writable_container_remove_container (_data_->_tmp14_, _data_->_tmp17_, _data_->_tmp18_, rygel_object_removal_queue_remove_now_ready, _data_);
			return FALSE;
			_state_2:
			rygel_writable_container_remove_container_finish (_data_->_tmp14_, _data_->_res_, &_data_->_inner_error_);
			if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
				goto __catch71_g_error;
			}
		}
		_data_->_tmp19_ = NULL;
		_data_->_tmp19_ = _data_->object;
		_data_->_tmp20_ = NULL;
		_data_->_tmp20_ = rygel_media_object_get_id (_data_->_tmp19_);
		_data_->_tmp21_ = NULL;
		_data_->_tmp21_ = _data_->_tmp20_;
		g_debug ("rygel-object-removal-queue.vala:84: Auto-destroyed object '%s'!", _data_->_tmp21_);
	}
	goto __finally71;
	__catch71_g_error:
	{
		_data_->err = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp22_ = NULL;
		_data_->_tmp22_ = _data_->object;
		_data_->_tmp23_ = NULL;
		_data_->_tmp23_ = rygel_media_object_get_id (_data_->_tmp22_);
		_data_->_tmp24_ = NULL;
		_data_->_tmp24_ = _data_->_tmp23_;
		_data_->_tmp25_ = NULL;
		_data_->_tmp25_ = _data_->err;
		_data_->_tmp26_ = NULL;
		_data_->_tmp26_ = _data_->_tmp25_->message;
		g_warning ("rygel-object-removal-queue.vala:86: Failed to auto-destroy temporary o" \
"bject '%s': %s", _data_->_tmp24_, _data_->_tmp26_);
		_g_error_free0 (_data_->err);
	}
	__finally71:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		_g_object_unref0 (_data_->parent);
		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;
	}
	_g_object_unref0 (_data_->parent);
	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 RygelObjectRemovalQueue* rygel_object_removal_queue_construct (GType object_type) {
	RygelObjectRemovalQueue * self = NULL;
	GeeHashMap* _tmp0_ = NULL;
	self = (RygelObjectRemovalQueue*) g_object_new (object_type, NULL);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, g_free, G_TYPE_UINT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->object_timeouts);
	self->priv->object_timeouts = _tmp0_;
	return self;
}


static RygelObjectRemovalQueue* rygel_object_removal_queue_new (void) {
	return rygel_object_removal_queue_construct (RYGEL_TYPE_OBJECT_REMOVAL_QUEUE);
}


static void rygel_object_removal_queue_class_init (RygelObjectRemovalQueueClass * klass) {
	rygel_object_removal_queue_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (RygelObjectRemovalQueuePrivate));
	G_OBJECT_CLASS (klass)->finalize = rygel_object_removal_queue_finalize;
}


static void rygel_object_removal_queue_instance_init (RygelObjectRemovalQueue * self) {
	self->priv = RYGEL_OBJECT_REMOVAL_QUEUE_GET_PRIVATE (self);
}


static void rygel_object_removal_queue_finalize (GObject* obj) {
	RygelObjectRemovalQueue * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, RYGEL_TYPE_OBJECT_REMOVAL_QUEUE, RygelObjectRemovalQueue);
	_g_object_unref0 (self->priv->object_timeouts);
	G_OBJECT_CLASS (rygel_object_removal_queue_parent_class)->finalize (obj);
}


/**
 * Queues objects for removal after 35 seconds or immediately.
 *
 * The 35s timeout comes from the DLNA documentation.
 */
GType rygel_object_removal_queue_get_type (void) {
	static volatile gsize rygel_object_removal_queue_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_object_removal_queue_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelObjectRemovalQueueClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_object_removal_queue_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (RygelObjectRemovalQueue), 0, (GInstanceInitFunc) rygel_object_removal_queue_instance_init, NULL };
		GType rygel_object_removal_queue_type_id;
		rygel_object_removal_queue_type_id = g_type_register_static (G_TYPE_OBJECT, "RygelObjectRemovalQueue", &g_define_type_info, 0);
		g_once_init_leave (&rygel_object_removal_queue_type_id__volatile, rygel_object_removal_queue_type_id);
	}
	return rygel_object_removal_queue_type_id__volatile;
}



