/* rygel-media-export-updatable-object.c generated by valac 0.42.2, the Vala compiler
 * generated from rygel-media-export-updatable-object.vala, do not modify */

/*
 * Copyright (C) 2013 Intel Corporation.
 *
 * Author: Krzesimir Nowak <krnowak@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>


#define RYGEL_MEDIA_EXPORT_TYPE_UPDATABLE_OBJECT (rygel_media_export_updatable_object_get_type ())
#define RYGEL_MEDIA_EXPORT_UPDATABLE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), RYGEL_MEDIA_EXPORT_TYPE_UPDATABLE_OBJECT, RygelMediaExportUpdatableObject))
#define RYGEL_MEDIA_EXPORT_IS_UPDATABLE_OBJECT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), RYGEL_MEDIA_EXPORT_TYPE_UPDATABLE_OBJECT))
#define RYGEL_MEDIA_EXPORT_UPDATABLE_OBJECT_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), RYGEL_MEDIA_EXPORT_TYPE_UPDATABLE_OBJECT, RygelMediaExportUpdatableObjectIface))

typedef struct _RygelMediaExportUpdatableObject RygelMediaExportUpdatableObject;
typedef struct _RygelMediaExportUpdatableObjectIface RygelMediaExportUpdatableObjectIface;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _RygelMediaExportUpdatableObjectNonOverridingCommitData RygelMediaExportUpdatableObjectNonOverridingCommitData;

struct _RygelMediaExportUpdatableObjectIface {
	GTypeInterface parent_iface;
	void (*commit_custom) (RygelMediaExportUpdatableObject* self, gboolean override_guarded, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*commit_custom_finish) (RygelMediaExportUpdatableObject* self, GAsyncResult* _res_, GError** error);
};

struct _RygelMediaExportUpdatableObjectNonOverridingCommitData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GAsyncReadyCallback _callback_;
	gboolean _task_complete_;
	RygelMediaExportUpdatableObject* self;
	GError * _inner_error_;
};



GType rygel_media_export_updatable_object_get_type (void) G_GNUC_CONST;
static void rygel_media_export_updatable_object_non_overriding_commit_data_free (gpointer _data);
static void rygel_media_export_updatable_object_non_overriding_commit_async_ready_wrapper (GObject *source_object,
                                                                                    GAsyncResult *res,
                                                                                    void *user_data);
void rygel_media_export_updatable_object_non_overriding_commit (RygelMediaExportUpdatableObject* self,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
void rygel_media_export_updatable_object_non_overriding_commit_finish (RygelMediaExportUpdatableObject* self,
                                                                       GAsyncResult* _res_,
                                                                       GError** error);
static gboolean rygel_media_export_updatable_object_non_overriding_commit_co (RygelMediaExportUpdatableObjectNonOverridingCommitData* _data_);
void rygel_media_export_updatable_object_commit_custom (RygelMediaExportUpdatableObject* self,
                                                        gboolean override_guarded,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
void rygel_media_export_updatable_object_commit_custom_finish (RygelMediaExportUpdatableObject* self,
                                                               GAsyncResult* _res_,
                                                               GError** error);
static void rygel_media_export_updatable_object_non_overriding_commit_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_);


static void
rygel_media_export_updatable_object_non_overriding_commit_data_free (gpointer _data)
{
	RygelMediaExportUpdatableObjectNonOverridingCommitData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (RygelMediaExportUpdatableObjectNonOverridingCommitData, _data_);
}


static void
rygel_media_export_updatable_object_non_overriding_commit_async_ready_wrapper (GObject *source_object,
                                                                               GAsyncResult *res,
                                                                               void *user_data)
{
	RygelMediaExportUpdatableObjectNonOverridingCommitData* _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 gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}


void
rygel_media_export_updatable_object_non_overriding_commit (RygelMediaExportUpdatableObject* self,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	RygelMediaExportUpdatableObjectNonOverridingCommitData* _data_;
	RygelMediaExportUpdatableObject* _tmp0_;
	_data_ = g_slice_new0 (RygelMediaExportUpdatableObjectNonOverridingCommitData);
	_data_->_callback_ = _callback_;
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, rygel_media_export_updatable_object_non_overriding_commit_async_ready_wrapper, _user_data_);
	if (_callback_ == NULL) {
		_data_->_task_complete_ = TRUE;
	}
	g_task_set_task_data (_data_->_async_result, _data_, rygel_media_export_updatable_object_non_overriding_commit_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	rygel_media_export_updatable_object_non_overriding_commit_co (_data_);
}


void
rygel_media_export_updatable_object_non_overriding_commit_finish (RygelMediaExportUpdatableObject* self,
                                                                  GAsyncResult* _res_,
                                                                  GError** error)
{
	RygelMediaExportUpdatableObjectNonOverridingCommitData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}


static void
rygel_media_export_updatable_object_non_overriding_commit_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_)
{
	RygelMediaExportUpdatableObjectNonOverridingCommitData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	_data_->_task_complete_ = TRUE;
	rygel_media_export_updatable_object_non_overriding_commit_co (_data_);
}


static gboolean
rygel_media_export_updatable_object_non_overriding_commit_co (RygelMediaExportUpdatableObjectNonOverridingCommitData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	rygel_media_export_updatable_object_commit_custom (_data_->self, FALSE, rygel_media_export_updatable_object_non_overriding_commit_ready, _data_);
	return FALSE;
	_state_1:
	rygel_media_export_updatable_object_commit_custom_finish (_data_->self, _data_->_res_, &_data_->_inner_error_);
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		g_task_return_error (_data_->_async_result, _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_updatable_object_commit_custom (RygelMediaExportUpdatableObject* self,
                                                   gboolean override_guarded,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	RYGEL_MEDIA_EXPORT_UPDATABLE_OBJECT_GET_INTERFACE (self)->commit_custom (self, override_guarded, _callback_, _user_data_);
}


void
rygel_media_export_updatable_object_commit_custom_finish (RygelMediaExportUpdatableObject* self,
                                                          GAsyncResult* _res_,
                                                          GError** error)
{
	RYGEL_MEDIA_EXPORT_UPDATABLE_OBJECT_GET_INTERFACE (self)->commit_custom_finish (self, _res_, error);
}


static void
rygel_media_export_updatable_object_default_init (RygelMediaExportUpdatableObjectIface * iface)
{
}


GType
rygel_media_export_updatable_object_get_type (void)
{
	static volatile gsize rygel_media_export_updatable_object_type_id__volatile = 0;
	if (g_once_init_enter (&rygel_media_export_updatable_object_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (RygelMediaExportUpdatableObjectIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) rygel_media_export_updatable_object_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
		GType rygel_media_export_updatable_object_type_id;
		rygel_media_export_updatable_object_type_id = g_type_register_static (G_TYPE_INTERFACE, "RygelMediaExportUpdatableObject", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (rygel_media_export_updatable_object_type_id, RYGEL_TYPE_MEDIA_OBJECT);
		g_once_init_leave (&rygel_media_export_updatable_object_type_id__volatile, rygel_media_export_updatable_object_type_id);
	}
	return rygel_media_export_updatable_object_type_id__volatile;
}



