/* rygel-object-removal-queue.c generated by valac 0.40.8, 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;
enum  {
	RYGEL_OBJECT_REMOVAL_QUEUE_0_PROPERTY,
	RYGEL_OBJECT_REMOVAL_QUEUE_NUM_PROPERTIES
};
static GParamSpec* rygel_object_removal_queue_properties[RYGEL_OBJECT_REMOVAL_QUEUE_NUM_PROPERTIES];
#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_;
	GTask* _async_result;
	GAsyncReadyCallback _callback_;
	gboolean _task_complete_;
	RygelObjectRemovalQueue* self;
	RygelMediaObject* object;
	GCancellable* cancellable;
	GeeHashMap* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	RygelWritableContainer* parent;
	RygelMediaContainer* _tmp3_;
	RygelMediaContainer* _tmp4_;
	RygelWritableContainer* _tmp5_;
	RygelWritableContainer* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	RygelWritableContainer* _tmp9_;
	const gchar* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	GError* err;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	GError* _tmp16_;
	const gchar* _tmp17_;
	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))
#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 __lambda7_ (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 ___lambda7__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 void rygel_object_removal_queue_remove_now_async_ready_wrapper (GObject *source_object,
                                                                GAsyncResult *res,
                                                                void *user_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_;
	RygelObjectRemovalQueue* _tmp2_;
	RygelObjectRemovalQueue* _tmp3_;
	_tmp0_ = rygel_object_removal_queue_removal_queue;
	if (G_UNLIKELY (_tmp0_ == NULL)) {
		RygelObjectRemovalQueue* _tmp1_;
		_tmp1_ = rygel_object_removal_queue_new ();
		_g_object_unref0 (rygel_object_removal_queue_removal_queue);
		rygel_object_removal_queue_removal_queue = _tmp1_;
	}
	_tmp2_ = rygel_object_removal_queue_removal_queue;
	_tmp3_ = _g_object_ref0 (_tmp2_);
	result = _tmp3_;
	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
__lambda7_ (Block10Data* _data10_)
{
	RygelObjectRemovalQueue* self;
	gboolean result = FALSE;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	self = _data10_->self;
	_tmp0_ = rygel_media_object_get_id (_data10_->object);
	_tmp1_ = _tmp0_;
	g_debug ("rygel-object-removal-queue.vala:51: Timeout on temporary object '%s'.", _tmp1_);
	rygel_object_removal_queue_remove_now (self, _data10_->object, _data10_->cancellable, NULL, NULL);
	result = FALSE;
	return result;
}


static gboolean
___lambda7__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda7_ (self);
	return result;
}


void
rygel_object_removal_queue_queue (RygelObjectRemovalQueue* self,
                                  RygelMediaObject* object,
                                  GCancellable* cancellable)
{
	Block10Data* _data10_;
	RygelMediaObject* _tmp0_;
	GCancellable* _tmp1_;
	RygelMediaContainer* _tmp2_;
	RygelMediaContainer* _tmp3_;
	guint timeout = 0U;
	GeeHashMap* _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	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_ = _g_object_ref0 (object);
	_g_object_unref0 (_data10_->object);
	_data10_->object = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data10_->cancellable);
	_data10_->cancellable = _tmp1_;
	_tmp2_ = rygel_media_object_get_parent_ref (_data10_->object);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == NULL) {
		RygelMediaContainer* _tmp4_;
		RygelMediaContainer* _tmp5_;
		_tmp4_ = rygel_media_object_get_parent (_data10_->object);
		_tmp5_ = _tmp4_;
		rygel_media_object_set_parent_ref (_data10_->object, _tmp5_);
	}
	timeout = g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, RYGEL_OBJECT_REMOVAL_QUEUE_TIMEOUT, ___lambda7__gsource_func, block10_data_ref (_data10_), block10_data_unref);
	_tmp6_ = self->priv->object_timeouts;
	_tmp7_ = rygel_media_object_get_id (_data10_->object);
	_tmp8_ = _tmp7_;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp6_, _tmp8_, (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_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gpointer _tmp3_ = NULL;
	gboolean _tmp4_;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (object != NULL, FALSE);
	_tmp0_ = self->priv->object_timeouts;
	_tmp1_ = rygel_media_object_get_id (object);
	_tmp2_ = _tmp1_;
	_tmp4_ = gee_abstract_map_unset ((GeeAbstractMap*) _tmp0_, _tmp2_, &_tmp3_);
	timeout = _tmp3_;
	if (_tmp4_) {
		guint _tmp5_;
		_tmp5_ = timeout;
		g_source_remove (_tmp5_);
		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_);
}


static void
rygel_object_removal_queue_remove_now_async_ready_wrapper (GObject *source_object,
                                                           GAsyncResult *res,
                                                           void *user_data)
{
	RygelObjectRemovalQueueRemoveNowData* _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;
}


void
rygel_object_removal_queue_remove_now (RygelObjectRemovalQueue* self,
                                       RygelMediaObject* object,
                                       GCancellable* cancellable,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	RygelObjectRemovalQueueRemoveNowData* _data_;
	RygelObjectRemovalQueue* _tmp0_;
	RygelMediaObject* _tmp1_;
	GCancellable* _tmp2_;
	_data_ = g_slice_new0 (RygelObjectRemovalQueueRemoveNowData);
	_data_->_callback_ = _callback_;
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, rygel_object_removal_queue_remove_now_async_ready_wrapper, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, rygel_object_removal_queue_remove_now_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (object);
	_g_object_unref0 (_data_->object);
	_data_->object = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	rygel_object_removal_queue_remove_now_co (_data_);
}


void
rygel_object_removal_queue_remove_now_finish (RygelObjectRemovalQueue* self,
                                              GAsyncResult* _res_)
{
	RygelObjectRemovalQueueRemoveNowData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	if (NULL == _data_) {
		return;
	}
}


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



