/* app-terminate-operation.c generated by valac 0.56.3, the Vala compiler
 * generated from app-terminate-operation.vala, do not modify */

/* Copyright 2016 Software Freedom Conservancy Inc.
 *
 * This software is licensed under the GNU Lesser General Public License
 * (version 2.1 or later).  See the COPYING file in this distribution.
 */

#include "geary-engine.h"
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>

#define GEARY_APP_TYPE_CONVERSATION_OPERATION (geary_app_conversation_operation_get_type ())
#define GEARY_APP_CONVERSATION_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperation))
#define GEARY_APP_CONVERSATION_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperationClass))
#define GEARY_APP_IS_CONVERSATION_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION))
#define GEARY_APP_IS_CONVERSATION_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_CONVERSATION_OPERATION))
#define GEARY_APP_CONVERSATION_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_CONVERSATION_OPERATION, GearyAppConversationOperationClass))

typedef struct _GearyAppConversationOperation GearyAppConversationOperation;
typedef struct _GearyAppConversationOperationClass GearyAppConversationOperationClass;
typedef struct _GearyAppConversationOperationPrivate GearyAppConversationOperationPrivate;

#define GEARY_APP_TYPE_TERMINATE_OPERATION (geary_app_terminate_operation_get_type ())
#define GEARY_APP_TERMINATE_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_APP_TYPE_TERMINATE_OPERATION, GearyAppTerminateOperation))
#define GEARY_APP_TERMINATE_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_APP_TYPE_TERMINATE_OPERATION, GearyAppTerminateOperationClass))
#define GEARY_APP_IS_TERMINATE_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_APP_TYPE_TERMINATE_OPERATION))
#define GEARY_APP_IS_TERMINATE_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_APP_TYPE_TERMINATE_OPERATION))
#define GEARY_APP_TERMINATE_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_APP_TYPE_TERMINATE_OPERATION, GearyAppTerminateOperationClass))

typedef struct _GearyAppTerminateOperation GearyAppTerminateOperation;
typedef struct _GearyAppTerminateOperationClass GearyAppTerminateOperationClass;
typedef struct _GearyAppTerminateOperationPrivate GearyAppTerminateOperationPrivate;
enum  {
	GEARY_APP_TERMINATE_OPERATION_0_PROPERTY,
	GEARY_APP_TERMINATE_OPERATION_NUM_PROPERTIES
};
static GParamSpec* geary_app_terminate_operation_properties[GEARY_APP_TERMINATE_OPERATION_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _GearyAppTerminateOperationExecuteAsyncData GearyAppTerminateOperationExecuteAsyncData;

struct _GearyAppConversationOperation {
	GearyBaseObject parent_instance;
	GearyAppConversationMonitor* monitor;
	GearyAppConversationOperationPrivate * priv;
};

struct _GearyAppConversationOperationClass {
	GearyBaseObjectClass parent_class;
	void (*execute_async) (GearyAppConversationOperation* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*execute_finish) (GearyAppConversationOperation* self, GAsyncResult* _res_, GError** error);
};

struct _GearyAppTerminateOperation {
	GearyAppConversationOperation parent_instance;
	GearyAppTerminateOperationPrivate * priv;
};

struct _GearyAppTerminateOperationClass {
	GearyAppConversationOperationClass parent_class;
};

struct _GearyAppTerminateOperationExecuteAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyAppTerminateOperation* self;
};

static gpointer geary_app_terminate_operation_parent_class = NULL;

VALA_EXTERN GType geary_app_conversation_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_app_terminate_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_app_conversation_operation_execute_async (GearyAppConversationOperation* self,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
VALA_EXTERN void geary_app_conversation_operation_execute_finish (GearyAppConversationOperation* self,
                                                      GAsyncResult* _res_,
                                                      GError** error);
VALA_EXTERN GearyAppTerminateOperation* geary_app_terminate_operation_new (void);
VALA_EXTERN GearyAppTerminateOperation* geary_app_terminate_operation_construct (GType object_type);
VALA_EXTERN GearyAppConversationOperation* geary_app_conversation_operation_construct (GType object_type,
                                                                           GearyAppConversationMonitor* monitor,
                                                                           gboolean allow_duplicates);
static void geary_app_terminate_operation_real_execute_async_data_free (gpointer _data);
static void geary_app_terminate_operation_real_execute_async (GearyAppConversationOperation* base,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static gboolean geary_app_terminate_operation_real_execute_async_co (GearyAppTerminateOperationExecuteAsyncData* _data_);
static GType geary_app_terminate_operation_get_type_once (void);

GearyAppTerminateOperation*
geary_app_terminate_operation_construct (GType object_type)
{
	GearyAppTerminateOperation * self = NULL;
	self = (GearyAppTerminateOperation*) geary_app_conversation_operation_construct (object_type, NULL, TRUE);
	return self;
}

GearyAppTerminateOperation*
geary_app_terminate_operation_new (void)
{
	return geary_app_terminate_operation_construct (GEARY_APP_TYPE_TERMINATE_OPERATION);
}

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

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

static void
geary_app_terminate_operation_real_execute_async (GearyAppConversationOperation* base,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	GearyAppTerminateOperation * self;
	GearyAppTerminateOperationExecuteAsyncData* _data_;
	GearyAppTerminateOperation* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_APP_TYPE_TERMINATE_OPERATION, GearyAppTerminateOperation);
	_data_ = g_slice_new0 (GearyAppTerminateOperationExecuteAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_app_terminate_operation_real_execute_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	geary_app_terminate_operation_real_execute_async_co (_data_);
}

static void
geary_app_terminate_operation_execute_finish (GearyAppConversationOperation* base,
                                              GAsyncResult* _res_,
                                              GError** error)
{
	GearyAppTerminateOperationExecuteAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
geary_app_terminate_operation_real_execute_async_co (GearyAppTerminateOperationExecuteAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
geary_app_terminate_operation_class_init (GearyAppTerminateOperationClass * klass,
                                          gpointer klass_data)
{
	geary_app_terminate_operation_parent_class = g_type_class_peek_parent (klass);
	((GearyAppConversationOperationClass *) klass)->execute_async = (void (*) (GearyAppConversationOperation*, GAsyncReadyCallback, gpointer)) geary_app_terminate_operation_real_execute_async;
	((GearyAppConversationOperationClass *) klass)->execute_finish = (void (*) (GearyAppConversationOperation*, GAsyncResult*, GError**)) geary_app_terminate_operation_execute_finish;
}

static void
geary_app_terminate_operation_instance_init (GearyAppTerminateOperation * self,
                                             gpointer klass)
{
}

 G_GNUC_NO_INLINE static GType
geary_app_terminate_operation_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyAppTerminateOperationClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_app_terminate_operation_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyAppTerminateOperation), 0, (GInstanceInitFunc) geary_app_terminate_operation_instance_init, NULL };
	GType geary_app_terminate_operation_type_id;
	geary_app_terminate_operation_type_id = g_type_register_static (GEARY_APP_TYPE_CONVERSATION_OPERATION, "GearyAppTerminateOperation", &g_define_type_info, 0);
	return geary_app_terminate_operation_type_id;
}

GType
geary_app_terminate_operation_get_type (void)
{
	static gsize geary_app_terminate_operation_type_id__once = 0;
	if (g_once_init_enter (&geary_app_terminate_operation_type_id__once)) {
		GType geary_app_terminate_operation_type_id;
		geary_app_terminate_operation_type_id = geary_app_terminate_operation_get_type_once ();
		g_once_init_leave (&geary_app_terminate_operation_type_id__once, geary_app_terminate_operation_type_id);
	}
	return geary_app_terminate_operation_type_id__once;
}

