/* imap-engine-move-email-revoke.c generated by valac 0.56.3, the Vala compiler
 * generated from imap-engine-move-email-revoke.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 <gee.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>

#define GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION (geary_imap_engine_replay_operation_get_type ())
#define GEARY_IMAP_ENGINE_REPLAY_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation))
#define GEARY_IMAP_ENGINE_REPLAY_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperationClass))
#define GEARY_IMAP_ENGINE_IS_REPLAY_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION))
#define GEARY_IMAP_ENGINE_IS_REPLAY_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION))
#define GEARY_IMAP_ENGINE_REPLAY_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperationClass))

typedef struct _GearyImapEngineReplayOperation GearyImapEngineReplayOperation;
typedef struct _GearyImapEngineReplayOperationClass GearyImapEngineReplayOperationClass;
typedef struct _GearyImapEngineReplayOperationPrivate GearyImapEngineReplayOperationPrivate;

#define GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER (geary_imap_db_email_identifier_get_type ())
#define GEARY_IMAP_DB_EMAIL_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier))
#define GEARY_IMAP_DB_EMAIL_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifierClass))
#define GEARY_IMAP_DB_IS_EMAIL_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER))
#define GEARY_IMAP_DB_IS_EMAIL_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER))
#define GEARY_IMAP_DB_EMAIL_IDENTIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifierClass))

typedef struct _GearyImapDBEmailIdentifier GearyImapDBEmailIdentifier;
typedef struct _GearyImapDBEmailIdentifierClass GearyImapDBEmailIdentifierClass;
typedef enum  {
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_COMPLETED,
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_CONTINUE
} GearyImapEngineReplayOperationStatus;

#define GEARY_IMAP_ENGINE_REPLAY_OPERATION_TYPE_STATUS (geary_imap_engine_replay_operation_status_get_type ())

#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;

#define GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION (geary_imap_engine_send_replay_operation_get_type ())
#define GEARY_IMAP_ENGINE_SEND_REPLAY_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION, GearyImapEngineSendReplayOperation))
#define GEARY_IMAP_ENGINE_SEND_REPLAY_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION, GearyImapEngineSendReplayOperationClass))
#define GEARY_IMAP_ENGINE_IS_SEND_REPLAY_OPERATION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION))
#define GEARY_IMAP_ENGINE_IS_SEND_REPLAY_OPERATION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION))
#define GEARY_IMAP_ENGINE_SEND_REPLAY_OPERATION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION, GearyImapEngineSendReplayOperationClass))

typedef struct _GearyImapEngineSendReplayOperation GearyImapEngineSendReplayOperation;
typedef struct _GearyImapEngineSendReplayOperationClass GearyImapEngineSendReplayOperationClass;
typedef struct _GearyImapEngineSendReplayOperationPrivate GearyImapEngineSendReplayOperationPrivate;

#define GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE (geary_imap_engine_move_email_revoke_get_type ())
#define GEARY_IMAP_ENGINE_MOVE_EMAIL_REVOKE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE, GearyImapEngineMoveEmailRevoke))
#define GEARY_IMAP_ENGINE_MOVE_EMAIL_REVOKE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE, GearyImapEngineMoveEmailRevokeClass))
#define GEARY_IMAP_ENGINE_IS_MOVE_EMAIL_REVOKE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE))
#define GEARY_IMAP_ENGINE_IS_MOVE_EMAIL_REVOKE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE))
#define GEARY_IMAP_ENGINE_MOVE_EMAIL_REVOKE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE, GearyImapEngineMoveEmailRevokeClass))

typedef struct _GearyImapEngineMoveEmailRevoke GearyImapEngineMoveEmailRevoke;
typedef struct _GearyImapEngineMoveEmailRevokeClass GearyImapEngineMoveEmailRevokeClass;
typedef struct _GearyImapEngineMoveEmailRevokePrivate GearyImapEngineMoveEmailRevokePrivate;

#define GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER (geary_imap_engine_minimal_folder_get_type ())
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder))
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolderClass))
#define GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER))
#define GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER))
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolderClass))

typedef struct _GearyImapEngineMinimalFolder GearyImapEngineMinimalFolder;
typedef struct _GearyImapEngineMinimalFolderClass GearyImapEngineMinimalFolderClass;
enum  {
	GEARY_IMAP_ENGINE_MOVE_EMAIL_REVOKE_0_PROPERTY,
	GEARY_IMAP_ENGINE_MOVE_EMAIL_REVOKE_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_move_email_revoke_properties[GEARY_IMAP_ENGINE_MOVE_EMAIL_REVOKE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef enum  {
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_ON_ERROR_THROW,
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_ON_ERROR_RETRY,
	GEARY_IMAP_ENGINE_REPLAY_OPERATION_ON_ERROR_IGNORE_REMOTE
} GearyImapEngineReplayOperationOnError;

#define GEARY_IMAP_ENGINE_REPLAY_OPERATION_TYPE_ON_ERROR (geary_imap_engine_replay_operation_on_error_get_type ())

#define GEARY_IMAP_DB_TYPE_FOLDER (geary_imap_db_folder_get_type ())
#define GEARY_IMAP_DB_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_DB_TYPE_FOLDER, GearyImapDBFolder))
#define GEARY_IMAP_DB_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_DB_TYPE_FOLDER, GearyImapDBFolderClass))
#define GEARY_IMAP_DB_IS_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_DB_TYPE_FOLDER))
#define GEARY_IMAP_DB_IS_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_DB_TYPE_FOLDER))
#define GEARY_IMAP_DB_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_DB_TYPE_FOLDER, GearyImapDBFolderClass))

typedef struct _GearyImapDBFolder GearyImapDBFolder;
typedef struct _GearyImapDBFolderClass GearyImapDBFolderClass;
typedef struct _GearyImapEngineMoveEmailRevokeReplayLocalAsyncData GearyImapEngineMoveEmailRevokeReplayLocalAsyncData;

struct _GearyImapEngineReplayOperation {
	GearyBaseObject parent_instance;
	GearyImapEngineReplayOperationPrivate * priv;
};

struct _GearyImapEngineReplayOperationClass {
	GearyBaseObjectClass parent_class;
	void (*notify_remote_removed_position) (GearyImapEngineReplayOperation* self, GearyImapSequenceNumber* removed);
	void (*notify_remote_removed_ids) (GearyImapEngineReplayOperation* self, GeeCollection* ids);
	void (*get_ids_to_be_remote_removed) (GearyImapEngineReplayOperation* self, GeeCollection* ids);
	void (*replay_local_async) (GearyImapEngineReplayOperation* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GearyImapEngineReplayOperationStatus (*replay_local_finish) (GearyImapEngineReplayOperation* self, GAsyncResult* _res_, GError** error);
	void (*replay_remote_async) (GearyImapEngineReplayOperation* self, GearyImapFolderSession* remote, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*replay_remote_finish) (GearyImapEngineReplayOperation* self, GAsyncResult* _res_, GError** error);
	void (*backout_local_async) (GearyImapEngineReplayOperation* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*backout_local_finish) (GearyImapEngineReplayOperation* self, GAsyncResult* _res_, GError** error);
	gchar* (*describe_state) (GearyImapEngineReplayOperation* self);
};

struct _GearyImapEngineSendReplayOperation {
	GearyImapEngineReplayOperation parent_instance;
	GearyImapEngineSendReplayOperationPrivate * priv;
};

struct _GearyImapEngineSendReplayOperationClass {
	GearyImapEngineReplayOperationClass parent_class;
};

struct _GearyImapEngineMoveEmailRevoke {
	GearyImapEngineSendReplayOperation parent_instance;
	GearyImapEngineMoveEmailRevokePrivate * priv;
};

struct _GearyImapEngineMoveEmailRevokeClass {
	GearyImapEngineSendReplayOperationClass parent_class;
};

struct _GearyImapEngineMoveEmailRevokePrivate {
	GearyImapEngineMinimalFolder* engine;
	GeeList* to_revoke;
	GCancellable* cancellable;
};

struct _GearyImapEngineMoveEmailRevokeReplayLocalAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMoveEmailRevoke* self;
	GearyImapEngineReplayOperationStatus result;
	GeeList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GeeSet* revoked;
	GearyImapEngineMinimalFolder* _tmp3_;
	GearyImapDBFolder* _tmp4_;
	GearyImapDBFolder* _tmp5_;
	GeeList* _tmp6_;
	GCancellable* _tmp7_;
	GeeSet* _tmp8_;
	gboolean _tmp9_;
	GeeSet* _tmp10_;
	GeeSet* _tmp11_;
	gint _tmp12_;
	gint _tmp13_;
	gint count;
	GearyImapEngineMinimalFolder* _tmp14_;
	GearyFolderProperties* _tmp15_;
	GearyFolderProperties* _tmp16_;
	gint _tmp17_;
	gint _tmp18_;
	GearyImapEngineMinimalFolder* _tmp19_;
	GeeSet* _tmp20_;
	GearyImapEngineMinimalFolder* _tmp21_;
	GeeSet* _tmp22_;
	gint _tmp23_;
	gint _tmp24_;
	GError* _inner_error0_;
};

static gint GearyImapEngineMoveEmailRevoke_private_offset;
static gpointer geary_imap_engine_move_email_revoke_parent_class = NULL;

VALA_EXTERN GType geary_imap_engine_replay_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_db_email_identifier_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_replay_operation_status_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_folder_session_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_send_replay_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_move_email_revoke_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_minimal_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_engine_replay_operation_notify_remote_removed_ids (GearyImapEngineReplayOperation* self,
                                                                   GeeCollection* ids);
VALA_EXTERN void geary_imap_engine_replay_operation_replay_local_async (GearyImapEngineReplayOperation* self,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
VALA_EXTERN GearyImapEngineReplayOperationStatus geary_imap_engine_replay_operation_replay_local_finish (GearyImapEngineReplayOperation* self,
                                                                                             GAsyncResult* _res_,
                                                                                             GError** error);
VALA_EXTERN gchar* geary_imap_engine_replay_operation_describe_state (GearyImapEngineReplayOperation* self);
VALA_EXTERN GearyImapEngineMoveEmailRevoke* geary_imap_engine_move_email_revoke_new (GearyImapEngineMinimalFolder* engine,
                                                                         GeeCollection* to_revoke,
                                                                         GCancellable* cancellable);
VALA_EXTERN GearyImapEngineMoveEmailRevoke* geary_imap_engine_move_email_revoke_construct (GType object_type,
                                                                               GearyImapEngineMinimalFolder* engine,
                                                                               GeeCollection* to_revoke,
                                                                               GCancellable* cancellable);
VALA_EXTERN GType geary_imap_engine_replay_operation_on_error_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineSendReplayOperation* geary_imap_engine_send_replay_operation_construct_only_local (GType object_type,
                                                                                                  const gchar* name,
                                                                                                  GearyImapEngineReplayOperationOnError on_remote_error);
static void geary_imap_engine_move_email_revoke_real_notify_remote_removed_ids (GearyImapEngineReplayOperation* base,
                                                                         GeeCollection* ids);
static void geary_imap_engine_move_email_revoke_real_replay_local_async_data_free (gpointer _data);
static void geary_imap_engine_move_email_revoke_real_replay_local_async (GearyImapEngineReplayOperation* base,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_);
static gboolean geary_imap_engine_move_email_revoke_real_replay_local_async_co (GearyImapEngineMoveEmailRevokeReplayLocalAsyncData* _data_);
VALA_EXTERN GType geary_imap_db_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapDBFolder* geary_imap_engine_minimal_folder_get_local_folder (GearyImapEngineMinimalFolder* self);
VALA_EXTERN void geary_imap_db_folder_mark_removed_async (GearyImapDBFolder* self,
                                              GeeCollection* ids,
                                              gboolean mark_removed,
                                              GCancellable* cancellable,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
VALA_EXTERN GeeSet* geary_imap_db_folder_mark_removed_finish (GearyImapDBFolder* self,
                                                  GAsyncResult* _res_,
                                                  GError** error);
static void geary_imap_engine_move_email_revoke_replay_local_async_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_minimal_folder_replay_notify_email_inserted (GearyImapEngineMinimalFolder* self,
                                                                    GeeCollection* ids);
VALA_EXTERN void geary_imap_engine_minimal_folder_replay_notify_email_count_changed (GearyImapEngineMinimalFolder* self,
                                                                         gint new_count,
                                                                         GearyFolderCountChangeReason reason);
static gchar* geary_imap_engine_move_email_revoke_real_describe_state (GearyImapEngineReplayOperation* base);
static void geary_imap_engine_move_email_revoke_finalize (GObject * obj);
static GType geary_imap_engine_move_email_revoke_get_type_once (void);

static inline gpointer
geary_imap_engine_move_email_revoke_get_instance_private (GearyImapEngineMoveEmailRevoke* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEngineMoveEmailRevoke_private_offset);
}

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

GearyImapEngineMoveEmailRevoke*
geary_imap_engine_move_email_revoke_construct (GType object_type,
                                               GearyImapEngineMinimalFolder* engine,
                                               GeeCollection* to_revoke,
                                               GCancellable* cancellable)
{
	GearyImapEngineMoveEmailRevoke * self = NULL;
	GearyImapEngineMinimalFolder* _tmp0_;
	GeeList* _tmp1_;
	GCancellable* _tmp2_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (engine), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (to_revoke, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()), NULL);
	self = (GearyImapEngineMoveEmailRevoke*) geary_imap_engine_send_replay_operation_construct_only_local (object_type, "MoveEmailRevoke", GEARY_IMAP_ENGINE_REPLAY_OPERATION_ON_ERROR_RETRY);
	_tmp0_ = _g_object_ref0 (engine);
	_g_object_unref0 (self->priv->engine);
	self->priv->engine = _tmp0_;
	_tmp1_ = self->priv->to_revoke;
	gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection), to_revoke);
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (self->priv->cancellable);
	self->priv->cancellable = _tmp2_;
	return self;
}

GearyImapEngineMoveEmailRevoke*
geary_imap_engine_move_email_revoke_new (GearyImapEngineMinimalFolder* engine,
                                         GeeCollection* to_revoke,
                                         GCancellable* cancellable)
{
	return geary_imap_engine_move_email_revoke_construct (GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE, engine, to_revoke, cancellable);
}

static void
geary_imap_engine_move_email_revoke_real_notify_remote_removed_ids (GearyImapEngineReplayOperation* base,
                                                                    GeeCollection* ids)
{
	GearyImapEngineMoveEmailRevoke * self;
	GeeList* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE, GearyImapEngineMoveEmailRevoke);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	_tmp0_ = self->priv->to_revoke;
	gee_collection_remove_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection), ids);
}

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

static void
geary_imap_engine_move_email_revoke_real_replay_local_async (GearyImapEngineReplayOperation* base,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	GearyImapEngineMoveEmailRevoke * self;
	GearyImapEngineMoveEmailRevokeReplayLocalAsyncData* _data_;
	GearyImapEngineMoveEmailRevoke* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE, GearyImapEngineMoveEmailRevoke);
	_data_ = g_slice_new0 (GearyImapEngineMoveEmailRevokeReplayLocalAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, geary_imap_engine_move_email_revoke_real_replay_local_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	geary_imap_engine_move_email_revoke_real_replay_local_async_co (_data_);
}

static GearyImapEngineReplayOperationStatus
geary_imap_engine_move_email_revoke_replay_local_finish (GearyImapEngineReplayOperation* base,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	GearyImapEngineReplayOperationStatus result;
	GearyImapEngineMoveEmailRevokeReplayLocalAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return 0;
	}
	result = _data_->result;
	return result;
}

static void
geary_imap_engine_move_email_revoke_replay_local_async_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_)
{
	GearyImapEngineMoveEmailRevokeReplayLocalAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_move_email_revoke_real_replay_local_async_co (_data_);
}

static gboolean
geary_imap_engine_move_email_revoke_real_replay_local_async_co (GearyImapEngineMoveEmailRevokeReplayLocalAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->to_revoke;
	_data_->_tmp1_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp2_ = _data_->_tmp1_;
	if (_data_->_tmp2_ == 0) {
		_data_->result = GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_COMPLETED;
		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;
	}
	_data_->_tmp3_ = _data_->self->priv->engine;
	_data_->_tmp4_ = geary_imap_engine_minimal_folder_get_local_folder (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = _data_->self->priv->to_revoke;
	_data_->_tmp7_ = _data_->self->priv->cancellable;
	_data_->_state_ = 1;
	geary_imap_db_folder_mark_removed_async (_data_->_tmp5_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, GEE_TYPE_COLLECTION, GeeCollection), FALSE, _data_->_tmp7_, geary_imap_engine_move_email_revoke_replay_local_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp8_ = geary_imap_db_folder_mark_removed_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
	_data_->revoked = _data_->_tmp8_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp10_ = _data_->revoked;
	if (_data_->_tmp10_ == NULL) {
		_data_->_tmp9_ = TRUE;
	} else {
		_data_->_tmp11_ = _data_->revoked;
		_data_->_tmp12_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp9_ = _data_->_tmp13_ == 0;
	}
	if (_data_->_tmp9_) {
		_data_->result = GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_COMPLETED;
		_g_object_unref0 (_data_->revoked);
		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;
	}
	_data_->_tmp14_ = _data_->self->priv->engine;
	_data_->_tmp15_ = geary_folder_get_properties (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp14_, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = geary_folder_properties_get_email_total (_data_->_tmp16_);
	_data_->_tmp18_ = _data_->_tmp17_;
	_data_->count = _data_->_tmp18_;
	if (_data_->count < 0) {
		_data_->count = 0;
	}
	_data_->_tmp19_ = _data_->self->priv->engine;
	_data_->_tmp20_ = _data_->revoked;
	geary_imap_engine_minimal_folder_replay_notify_email_inserted (_data_->_tmp19_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp20_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp21_ = _data_->self->priv->engine;
	_data_->_tmp22_ = _data_->revoked;
	_data_->_tmp23_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp22_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp24_ = _data_->_tmp23_;
	geary_imap_engine_minimal_folder_replay_notify_email_count_changed (_data_->_tmp21_, _data_->count + _data_->_tmp24_, GEARY_FOLDER_COUNT_CHANGE_REASON_INSERTED);
	_data_->result = GEARY_IMAP_ENGINE_REPLAY_OPERATION_STATUS_COMPLETED;
	_g_object_unref0 (_data_->revoked);
	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 gchar*
geary_imap_engine_move_email_revoke_real_describe_state (GearyImapEngineReplayOperation* base)
{
	GearyImapEngineMoveEmailRevoke * self;
	GeeList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE, GearyImapEngineMoveEmailRevoke);
	_tmp0_ = self->priv->to_revoke;
	_tmp1_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup_printf ("%d email IDs", _tmp2_);
	result = _tmp3_;
	return result;
}

static void
geary_imap_engine_move_email_revoke_class_init (GearyImapEngineMoveEmailRevokeClass * klass,
                                                gpointer klass_data)
{
	geary_imap_engine_move_email_revoke_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEngineMoveEmailRevoke_private_offset);
	((GearyImapEngineReplayOperationClass *) klass)->notify_remote_removed_ids = (void (*) (GearyImapEngineReplayOperation*, GeeCollection*)) geary_imap_engine_move_email_revoke_real_notify_remote_removed_ids;
	((GearyImapEngineReplayOperationClass *) klass)->replay_local_async = (void (*) (GearyImapEngineReplayOperation*, GAsyncReadyCallback, gpointer)) geary_imap_engine_move_email_revoke_real_replay_local_async;
	((GearyImapEngineReplayOperationClass *) klass)->replay_local_finish = (GearyImapEngineReplayOperationStatus (*) (GearyImapEngineReplayOperation*, GAsyncResult*, GError**)) geary_imap_engine_move_email_revoke_replay_local_finish;
	((GearyImapEngineReplayOperationClass *) klass)->describe_state = (gchar* (*) (GearyImapEngineReplayOperation*)) geary_imap_engine_move_email_revoke_real_describe_state;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_engine_move_email_revoke_finalize;
}

static void
geary_imap_engine_move_email_revoke_instance_init (GearyImapEngineMoveEmailRevoke * self,
                                                   gpointer klass)
{
	GeeArrayList* _tmp0_;
	self->priv = geary_imap_engine_move_email_revoke_get_instance_private (self);
	_tmp0_ = gee_array_list_new (GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->to_revoke = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_LIST, GeeList);
}

static void
geary_imap_engine_move_email_revoke_finalize (GObject * obj)
{
	GearyImapEngineMoveEmailRevoke * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_REVOKE, GearyImapEngineMoveEmailRevoke);
	_g_object_unref0 (self->priv->engine);
	_g_object_unref0 (self->priv->to_revoke);
	_g_object_unref0 (self->priv->cancellable);
	G_OBJECT_CLASS (geary_imap_engine_move_email_revoke_parent_class)->finalize (obj);
}

/**
 * Revoked {@link RevokableMove}: Unmark emails as removed and update counts.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_engine_move_email_revoke_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineMoveEmailRevokeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_move_email_revoke_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineMoveEmailRevoke), 0, (GInstanceInitFunc) geary_imap_engine_move_email_revoke_instance_init, NULL };
	GType geary_imap_engine_move_email_revoke_type_id;
	geary_imap_engine_move_email_revoke_type_id = g_type_register_static (GEARY_IMAP_ENGINE_TYPE_SEND_REPLAY_OPERATION, "GearyImapEngineMoveEmailRevoke", &g_define_type_info, 0);
	GearyImapEngineMoveEmailRevoke_private_offset = g_type_add_instance_private (geary_imap_engine_move_email_revoke_type_id, sizeof (GearyImapEngineMoveEmailRevokePrivate));
	return geary_imap_engine_move_email_revoke_type_id;
}

GType
geary_imap_engine_move_email_revoke_get_type (void)
{
	static gsize geary_imap_engine_move_email_revoke_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_move_email_revoke_type_id__once)) {
		GType geary_imap_engine_move_email_revoke_type_id;
		geary_imap_engine_move_email_revoke_type_id = geary_imap_engine_move_email_revoke_get_type_once ();
		g_once_init_leave (&geary_imap_engine_move_email_revoke_type_id__once, geary_imap_engine_move_email_revoke_type_id);
	}
	return geary_imap_engine_move_email_revoke_type_id__once;
}

