/* imap-engine-revokable-committed-move.c generated by valac 0.56.19, the Vala compiler
 * generated from imap-engine-revokable-committed-move.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 <gee.h>
#include <gio/gio.h>
#include <glib.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE (geary_imap_engine_revokable_committed_move_get_type ())
#define GEARY_IMAP_ENGINE_REVOKABLE_COMMITTED_MOVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE, GearyImapEngineRevokableCommittedMove))
#define GEARY_IMAP_ENGINE_REVOKABLE_COMMITTED_MOVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE, GearyImapEngineRevokableCommittedMoveClass))
#define GEARY_IMAP_ENGINE_IS_REVOKABLE_COMMITTED_MOVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE))
#define GEARY_IMAP_ENGINE_IS_REVOKABLE_COMMITTED_MOVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE))
#define GEARY_IMAP_ENGINE_REVOKABLE_COMMITTED_MOVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE, GearyImapEngineRevokableCommittedMoveClass))

typedef struct _GearyImapEngineRevokableCommittedMove GearyImapEngineRevokableCommittedMove;
typedef struct _GearyImapEngineRevokableCommittedMoveClass GearyImapEngineRevokableCommittedMoveClass;
typedef struct _GearyImapEngineRevokableCommittedMovePrivate GearyImapEngineRevokableCommittedMovePrivate;

#define GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT (geary_imap_engine_generic_account_get_type ())
#define GEARY_IMAP_ENGINE_GENERIC_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount))
#define GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccountClass))
#define GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT))
#define GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT))
#define GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccountClass))

typedef struct _GearyImapEngineGenericAccount GearyImapEngineGenericAccount;
typedef struct _GearyImapEngineGenericAccountClass GearyImapEngineGenericAccountClass;
enum  {
	GEARY_IMAP_ENGINE_REVOKABLE_COMMITTED_MOVE_0_PROPERTY,
	GEARY_IMAP_ENGINE_REVOKABLE_COMMITTED_MOVE_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_revokable_committed_move_properties[GEARY_IMAP_ENGINE_REVOKABLE_COMMITTED_MOVE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define GEARY_IMAP_TYPE_FOLDER_SESSION (geary_imap_folder_session_get_type ())
#define GEARY_IMAP_FOLDER_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_TYPE_FOLDER_SESSION, GearyImapFolderSession))
#define GEARY_IMAP_FOLDER_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_TYPE_FOLDER_SESSION, GearyImapFolderSessionClass))
#define GEARY_IMAP_IS_FOLDER_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_TYPE_FOLDER_SESSION))
#define GEARY_IMAP_IS_FOLDER_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_TYPE_FOLDER_SESSION))
#define GEARY_IMAP_FOLDER_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_TYPE_FOLDER_SESSION, GearyImapFolderSessionClass))

typedef struct _GearyImapFolderSession GearyImapFolderSession;
typedef struct _GearyImapFolderSessionClass GearyImapFolderSessionClass;
typedef struct _GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData;
typedef struct _GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData;

struct _GearyImapEngineRevokableCommittedMove {
	GearyRevokable parent_instance;
	GearyImapEngineRevokableCommittedMovePrivate * priv;
};

struct _GearyImapEngineRevokableCommittedMoveClass {
	GearyRevokableClass parent_class;
};

struct _GearyImapEngineRevokableCommittedMovePrivate {
	GearyImapEngineGenericAccount* account;
	GearyFolderPath* source;
	GearyFolderPath* destination;
	GeeSet* destination_uids;
};

struct _GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineRevokableCommittedMove* self;
	GCancellable* cancellable;
	GearyImapFolderSession* session;
	GearyImapFolderSession* _tmp0_;
	GearyImapEngineGenericAccount* _tmp1_;
	GearyFolderPath* _tmp2_;
	GearyImapFolderSession* _tmp3_;
	GearyImapFolderSession* _tmp4_;
	GeeList* _msg_set_list;
	GeeSet* _tmp5_;
	GeeList* _tmp6_;
	gint _msg_set_size;
	GeeList* _tmp7_;
	gint _tmp8_;
	gint _tmp9_;
	gint _msg_set_index;
	gint _tmp10_;
	gint _tmp11_;
	GearyImapMessageSet* msg_set;
	GeeList* _tmp12_;
	gpointer _tmp13_;
	GearyImapFolderSession* _tmp14_;
	GearyImapMessageSet* _tmp15_;
	GearyFolderPath* _tmp16_;
	GeeMap* _tmp17_;
	GeeMap* _tmp18_;
	GearyImapFolderSession* _tmp19_;
	GearyImapMessageSet* _tmp20_;
	GeeList* _tmp21_;
	GeeList* _tmp22_;
	gboolean _tmp23_;
	GError* _tmp24_;
	GearyFolder* target;
	GearyImapEngineGenericAccount* _tmp25_;
	GearyFolderPath* _tmp26_;
	GearyFolder* _tmp27_;
	GearyImapEngineGenericAccount* _tmp28_;
	GearyFolder* _tmp29_;
	GError* _inner_error1_;
	GearyImapFolderSession* _tmp30_;
	GearyImapEngineGenericAccount* _tmp31_;
	GearyImapFolderSession* _tmp32_;
	GError* _inner_error0_;
};

struct _GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineRevokableCommittedMove* self;
	GCancellable* cancellable;
};

static gint GearyImapEngineRevokableCommittedMove_private_offset;
static gpointer geary_imap_engine_revokable_committed_move_parent_class = NULL;

VALA_EXTERN GType geary_imap_engine_revokable_committed_move_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_generic_account_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineRevokableCommittedMove* geary_imap_engine_revokable_committed_move_new (GearyImapEngineGenericAccount* account,
                                                                                       GearyFolderPath* source,
                                                                                       GearyFolderPath* destination,
                                                                                       GeeSet* destination_uids);
VALA_EXTERN GearyImapEngineRevokableCommittedMove* geary_imap_engine_revokable_committed_move_construct (GType object_type,
                                                                                             GearyImapEngineGenericAccount* account,
                                                                                             GearyFolderPath* source,
                                                                                             GearyFolderPath* destination,
                                                                                             GeeSet* destination_uids);
static void geary_imap_engine_revokable_committed_move_real_internal_revoke_async_data_free (gpointer _data);
static void geary_imap_engine_revokable_committed_move_real_internal_revoke_async (GearyRevokable* base,
                                                                            GCancellable* cancellable,
                                                                            GAsyncReadyCallback _callback_,
                                                                            gpointer _user_data_);
static gboolean geary_imap_engine_revokable_committed_move_real_internal_revoke_async_co (GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData* _data_);
VALA_EXTERN GType geary_imap_folder_session_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_engine_generic_account_claim_folder_session (GearyImapEngineGenericAccount* self,
                                                             GearyFolderPath* path,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
VALA_EXTERN GearyImapFolderSession* geary_imap_engine_generic_account_claim_folder_session_finish (GearyImapEngineGenericAccount* self,
                                                                                       GAsyncResult* _res_,
                                                                                       GError** error);
static void geary_imap_engine_revokable_committed_move_internal_revoke_async_ready (GObject* source_object,
                                                                             GAsyncResult* _res_,
                                                                             gpointer _user_data_);
VALA_EXTERN void geary_imap_folder_session_copy_email_async (GearyImapFolderSession* self,
                                                 GearyImapMessageSet* msg_set,
                                                 GearyFolderPath* destination,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
VALA_EXTERN GeeMap* geary_imap_folder_session_copy_email_finish (GearyImapFolderSession* self,
                                                     GAsyncResult* _res_,
                                                     GError** error);
VALA_EXTERN void geary_imap_folder_session_remove_email_async (GearyImapFolderSession* self,
                                                   GeeList* msg_sets,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
VALA_EXTERN void geary_imap_folder_session_remove_email_finish (GearyImapFolderSession* self,
                                                    GAsyncResult* _res_,
                                                    GError** error);
VALA_EXTERN void geary_imap_engine_generic_account_update_folder (GearyImapEngineGenericAccount* self,
                                                      GearyFolder* folder);
VALA_EXTERN void geary_imap_engine_generic_account_release_folder_session (GearyImapEngineGenericAccount* self,
                                                               GearyImapFolderSession* session,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_generic_account_release_folder_session_finish (GearyImapEngineGenericAccount* self,
                                                                      GAsyncResult* _res_);
static void geary_imap_engine_revokable_committed_move_real_internal_commit_async_data_free (gpointer _data);
static void geary_imap_engine_revokable_committed_move_real_internal_commit_async (GearyRevokable* base,
                                                                            GCancellable* cancellable,
                                                                            GAsyncReadyCallback _callback_,
                                                                            gpointer _user_data_);
static gboolean geary_imap_engine_revokable_committed_move_real_internal_commit_async_co (GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData* _data_);
static void geary_imap_engine_revokable_committed_move_finalize (GObject * obj);
static GType geary_imap_engine_revokable_committed_move_get_type_once (void);

static inline gpointer
geary_imap_engine_revokable_committed_move_get_instance_private (GearyImapEngineRevokableCommittedMove* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEngineRevokableCommittedMove_private_offset);
}

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

GearyImapEngineRevokableCommittedMove*
geary_imap_engine_revokable_committed_move_construct (GType object_type,
                                                      GearyImapEngineGenericAccount* account,
                                                      GearyFolderPath* source,
                                                      GearyFolderPath* destination,
                                                      GeeSet* destination_uids)
{
	GearyImapEngineRevokableCommittedMove * self = NULL;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	GeeSet* _tmp3_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (account), NULL);
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (source), NULL);
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (destination), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (destination_uids, GEE_TYPE_SET), NULL);
	self = (GearyImapEngineRevokableCommittedMove*) geary_revokable_construct (object_type, 0);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (self->priv->account);
	self->priv->account = _tmp0_;
	_tmp1_ = _g_object_ref0 (source);
	_g_object_unref0 (self->priv->source);
	self->priv->source = _tmp1_;
	_tmp2_ = _g_object_ref0 (destination);
	_g_object_unref0 (self->priv->destination);
	self->priv->destination = _tmp2_;
	_tmp3_ = _g_object_ref0 (destination_uids);
	_g_object_unref0 (self->priv->destination_uids);
	self->priv->destination_uids = _tmp3_;
	return self;
}

GearyImapEngineRevokableCommittedMove*
geary_imap_engine_revokable_committed_move_new (GearyImapEngineGenericAccount* account,
                                                GearyFolderPath* source,
                                                GearyFolderPath* destination,
                                                GeeSet* destination_uids)
{
	return geary_imap_engine_revokable_committed_move_construct (GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE, account, source, destination, destination_uids);
}

static void
geary_imap_engine_revokable_committed_move_real_internal_revoke_async_data_free (gpointer _data)
{
	GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData, _data_);
}

static void
geary_imap_engine_revokable_committed_move_real_internal_revoke_async (GearyRevokable* base,
                                                                       GCancellable* cancellable,
                                                                       GAsyncReadyCallback _callback_,
                                                                       gpointer _user_data_)
{
	GearyImapEngineRevokableCommittedMove * self;
	GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData* _data_;
	GearyImapEngineRevokableCommittedMove* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE, GearyImapEngineRevokableCommittedMove);
	_data_ = g_slice_new0 (GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_imap_engine_revokable_committed_move_real_internal_revoke_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_imap_engine_revokable_committed_move_real_internal_revoke_async_co (_data_);
}

static void
geary_imap_engine_revokable_committed_move_internal_revoke_finish (GearyRevokable* base,
                                                                   GAsyncResult* _res_,
                                                                   GError** error)
{
	GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_revokable_committed_move_internal_revoke_async_ready (GObject* source_object,
                                                                        GAsyncResult* _res_,
                                                                        gpointer _user_data_)
{
	GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_revokable_committed_move_real_internal_revoke_async_co (_data_);
}

static gboolean
geary_imap_engine_revokable_committed_move_real_internal_revoke_async_co (GearyImapEngineRevokableCommittedMoveInternalRevokeAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->session = NULL;
	{
		_data_->_tmp1_ = _data_->self->priv->account;
		_data_->_tmp2_ = _data_->self->priv->destination;
		_data_->_state_ = 1;
		geary_imap_engine_generic_account_claim_folder_session (_data_->_tmp1_, _data_->_tmp2_, _data_->cancellable, geary_imap_engine_revokable_committed_move_internal_revoke_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp3_ = geary_imap_engine_generic_account_claim_folder_session_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp0_ = _data_->_tmp3_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_data_->_tmp4_ = _data_->_tmp0_;
		_data_->_tmp0_ = NULL;
		_g_object_unref0 (_data_->session);
		_data_->session = _data_->_tmp4_;
		{
			_data_->_tmp5_ = _data_->self->priv->destination_uids;
			_data_->_tmp6_ = geary_imap_message_set_uid_sparse (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_msg_set_list = _data_->_tmp6_;
			_data_->_tmp7_ = _data_->_msg_set_list;
			_data_->_tmp8_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp9_ = _data_->_tmp8_;
			_data_->_msg_set_size = _data_->_tmp9_;
			_data_->_msg_set_index = -1;
			while (TRUE) {
				_data_->_msg_set_index = _data_->_msg_set_index + 1;
				_data_->_tmp10_ = _data_->_msg_set_index;
				_data_->_tmp11_ = _data_->_msg_set_size;
				if (!(_data_->_tmp10_ < _data_->_tmp11_)) {
					break;
				}
				_data_->_tmp12_ = _data_->_msg_set_list;
				_data_->_tmp13_ = gee_list_get (_data_->_tmp12_, _data_->_msg_set_index);
				_data_->msg_set = (GearyImapMessageSet*) _data_->_tmp13_;
				_data_->_tmp14_ = _data_->session;
				_data_->_tmp15_ = _data_->msg_set;
				_data_->_tmp16_ = _data_->self->priv->source;
				_data_->_state_ = 2;
				geary_imap_folder_session_copy_email_async (_data_->_tmp14_, _data_->_tmp15_, _data_->_tmp16_, NULL, geary_imap_engine_revokable_committed_move_internal_revoke_async_ready, _data_);
				return FALSE;
				_state_2:
				_data_->_tmp17_ = geary_imap_folder_session_copy_email_finish (_data_->_tmp14_, _data_->_res_, &_data_->_inner_error0_);
				_data_->_tmp18_ = _data_->_tmp17_;
				_g_object_unref0 (_data_->_tmp18_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->msg_set);
					_g_object_unref0 (_data_->_msg_set_list);
					_g_object_unref0 (_data_->_tmp0_);
					goto __finally0;
				}
				_data_->_tmp19_ = _data_->session;
				_data_->_tmp20_ = _data_->msg_set;
				_data_->_tmp21_ = geary_imap_message_set_to_list (_data_->_tmp20_);
				_data_->_tmp22_ = _data_->_tmp21_;
				_data_->_state_ = 3;
				geary_imap_folder_session_remove_email_async (_data_->_tmp19_, _data_->_tmp22_, NULL, geary_imap_engine_revokable_committed_move_internal_revoke_async_ready, _data_);
				return FALSE;
				_state_3:
				geary_imap_folder_session_remove_email_finish (_data_->_tmp19_, _data_->_res_, &_data_->_inner_error0_);
				_g_object_unref0 (_data_->_tmp22_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->msg_set);
					_g_object_unref0 (_data_->_msg_set_list);
					_g_object_unref0 (_data_->_tmp0_);
					goto __finally0;
				}
				if (_data_->cancellable != NULL) {
					_data_->_tmp23_ = g_cancellable_is_cancelled (_data_->cancellable);
				} else {
					_data_->_tmp23_ = FALSE;
				}
				if (_data_->_tmp23_) {
					_data_->_tmp24_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CANCELLED, "Revoke cancelled");
					_data_->_inner_error0_ = _data_->_tmp24_;
					_g_object_unref0 (_data_->msg_set);
					_g_object_unref0 (_data_->_msg_set_list);
					_g_object_unref0 (_data_->_tmp0_);
					goto __finally0;
				}
				_g_object_unref0 (_data_->msg_set);
			}
			_g_object_unref0 (_data_->_msg_set_list);
		}
		geary_revokable_notify_revoked (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_REVOKABLE, GearyRevokable));
		_data_->_tmp25_ = _data_->self->priv->account;
		_data_->_tmp26_ = _data_->self->priv->destination;
		_data_->_tmp27_ = geary_account_get_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp25_, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->_tmp26_, &_data_->_inner_error0_);
		_data_->target = _data_->_tmp27_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->_tmp0_);
			goto __finally0;
		}
		_data_->_tmp28_ = _data_->self->priv->account;
		_data_->_tmp29_ = _data_->target;
		geary_imap_engine_generic_account_update_folder (_data_->_tmp28_, _data_->_tmp29_);
		_g_object_unref0 (_data_->target);
		_g_object_unref0 (_data_->_tmp0_);
	}
	__finally0:
	{
		_data_->_tmp30_ = _data_->session;
		if (_data_->_tmp30_ != NULL) {
			_data_->_tmp31_ = _data_->self->priv->account;
			_data_->_tmp32_ = _data_->session;
			_data_->_state_ = 4;
			geary_imap_engine_generic_account_release_folder_session (_data_->_tmp31_, _data_->_tmp32_, geary_imap_engine_revokable_committed_move_internal_revoke_async_ready, _data_);
			return FALSE;
			_state_4:
			geary_imap_engine_generic_account_release_folder_session_finish (_data_->_tmp31_, _data_->_res_);
		}
		geary_revokable_set_invalid (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_REVOKABLE, GearyRevokable));
	}
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->session);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->session);
	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_imap_engine_revokable_committed_move_real_internal_commit_async_data_free (gpointer _data)
{
	GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData, _data_);
}

static void
geary_imap_engine_revokable_committed_move_real_internal_commit_async (GearyRevokable* base,
                                                                       GCancellable* cancellable,
                                                                       GAsyncReadyCallback _callback_,
                                                                       gpointer _user_data_)
{
	GearyImapEngineRevokableCommittedMove * self;
	GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData* _data_;
	GearyImapEngineRevokableCommittedMove* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE, GearyImapEngineRevokableCommittedMove);
	_data_ = g_slice_new0 (GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_imap_engine_revokable_committed_move_real_internal_commit_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_imap_engine_revokable_committed_move_real_internal_commit_async_co (_data_);
}

static void
geary_imap_engine_revokable_committed_move_internal_commit_finish (GearyRevokable* base,
                                                                   GAsyncResult* _res_,
                                                                   GError** error)
{
	GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
geary_imap_engine_revokable_committed_move_real_internal_commit_async_co (GearyImapEngineRevokableCommittedMoveInternalCommitAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_revokable_notify_committed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_REVOKABLE, GearyRevokable), NULL);
	geary_revokable_set_invalid (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_REVOKABLE, GearyRevokable));
	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_imap_engine_revokable_committed_move_class_init (GearyImapEngineRevokableCommittedMoveClass * klass,
                                                       gpointer klass_data)
{
	geary_imap_engine_revokable_committed_move_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEngineRevokableCommittedMove_private_offset);
	((GearyRevokableClass *) klass)->internal_revoke_async = (void (*) (GearyRevokable*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_revokable_committed_move_real_internal_revoke_async;
	((GearyRevokableClass *) klass)->internal_revoke_finish = (void (*) (GearyRevokable*, GAsyncResult*, GError**)) geary_imap_engine_revokable_committed_move_internal_revoke_finish;
	((GearyRevokableClass *) klass)->internal_commit_async = (void (*) (GearyRevokable*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_revokable_committed_move_real_internal_commit_async;
	((GearyRevokableClass *) klass)->internal_commit_finish = (void (*) (GearyRevokable*, GAsyncResult*, GError**)) geary_imap_engine_revokable_committed_move_internal_commit_finish;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_engine_revokable_committed_move_finalize;
}

static void
geary_imap_engine_revokable_committed_move_instance_init (GearyImapEngineRevokableCommittedMove * self,
                                                          gpointer klass)
{
	self->priv = geary_imap_engine_revokable_committed_move_get_instance_private (self);
}

static void
geary_imap_engine_revokable_committed_move_finalize (GObject * obj)
{
	GearyImapEngineRevokableCommittedMove * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_ENGINE_TYPE_REVOKABLE_COMMITTED_MOVE, GearyImapEngineRevokableCommittedMove);
	_g_object_unref0 (self->priv->account);
	_g_object_unref0 (self->priv->source);
	_g_object_unref0 (self->priv->destination);
	_g_object_unref0 (self->priv->destination_uids);
	G_OBJECT_CLASS (geary_imap_engine_revokable_committed_move_parent_class)->finalize (obj);
}

/**
 * A {@link Geary.Revokable} for moving email back to its source after committed with
 * {@link RevokableMove}.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_engine_revokable_committed_move_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineRevokableCommittedMoveClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_revokable_committed_move_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineRevokableCommittedMove), 0, (GInstanceInitFunc) geary_imap_engine_revokable_committed_move_instance_init, NULL };
	GType geary_imap_engine_revokable_committed_move_type_id;
	geary_imap_engine_revokable_committed_move_type_id = g_type_register_static (GEARY_TYPE_REVOKABLE, "GearyImapEngineRevokableCommittedMove", &g_define_type_info, 0);
	GearyImapEngineRevokableCommittedMove_private_offset = g_type_add_instance_private (geary_imap_engine_revokable_committed_move_type_id, sizeof (GearyImapEngineRevokableCommittedMovePrivate));
	return geary_imap_engine_revokable_committed_move_type_id;
}

GType
geary_imap_engine_revokable_committed_move_get_type (void)
{
	static gsize geary_imap_engine_revokable_committed_move_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_revokable_committed_move_type_id__once)) {
		GType geary_imap_engine_revokable_committed_move_type_id;
		geary_imap_engine_revokable_committed_move_type_id = geary_imap_engine_revokable_committed_move_get_type_once ();
		g_once_init_leave (&geary_imap_engine_revokable_committed_move_type_id__once, geary_imap_engine_revokable_committed_move_type_id);
	}
	return geary_imap_engine_revokable_committed_move_type_id__once;
}

