/* imap-engine-minimal-folder.c generated by valac 0.56.19, the Vala compiler
 * generated from imap-engine-minimal-folder.vala, do not modify */

/*
 * Copyright 2016 Software Freedom Conservancy Inc.
 * Copyright 2018 Michael Gratton <mike@vee.net>
 *
 * 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>
#include <stdlib.h>
#include <string.h>

#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FLAG_UPDATE_TIMEOUT_SEC 2
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FLAG_UPDATE_START_CHUNK 20
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FLAG_UPDATE_MAX_CHUNK 100
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FORCE_OPEN_REMOTE_TIMEOUT_SEC 10
#define GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REFRESH_UNSEEN_TIMEOUT_SEC 1
#define GEARY_IMAP_ENGINE_EMAIL_PREFETCHER_PREFETCH_DELAY_SEC 1
#define GEARY_IMAP_DB_FOLDER_REQUIRED_FIELDS ((GEARY_EMAIL_FIELD_PROPERTIES | GEARY_EMAIL_FIELD_REFERENCES) | GEARY_EMAIL_FIELD_FLAGS)
#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_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;
typedef struct _GearyImapEngineMinimalFolderPrivate GearyImapEngineMinimalFolderPrivate;

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

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

#define GEARY_IMAP_ENGINE_TYPE_REPLAY_QUEUE (geary_imap_engine_replay_queue_get_type ())
#define GEARY_IMAP_ENGINE_REPLAY_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_QUEUE, GearyImapEngineReplayQueue))
#define GEARY_IMAP_ENGINE_REPLAY_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_QUEUE, GearyImapEngineReplayQueueClass))
#define GEARY_IMAP_ENGINE_IS_REPLAY_QUEUE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_QUEUE))
#define GEARY_IMAP_ENGINE_IS_REPLAY_QUEUE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_QUEUE))
#define GEARY_IMAP_ENGINE_REPLAY_QUEUE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_QUEUE, GearyImapEngineReplayQueueClass))

typedef struct _GearyImapEngineReplayQueue GearyImapEngineReplayQueue;
typedef struct _GearyImapEngineReplayQueueClass GearyImapEngineReplayQueueClass;

#define GEARY_TYPE_CONTACT_HARVESTER (geary_contact_harvester_get_type ())
#define GEARY_CONTACT_HARVESTER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_TYPE_CONTACT_HARVESTER, GearyContactHarvester))
#define GEARY_IS_CONTACT_HARVESTER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_TYPE_CONTACT_HARVESTER))
#define GEARY_CONTACT_HARVESTER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEARY_TYPE_CONTACT_HARVESTER, GearyContactHarvesterIface))

typedef struct _GearyContactHarvester GearyContactHarvester;
typedef struct _GearyContactHarvesterIface GearyContactHarvesterIface;

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

#define GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES (geary_aggregated_folder_properties_get_type ())
#define GEARY_AGGREGATED_FOLDER_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES, GearyAggregatedFolderProperties))
#define GEARY_AGGREGATED_FOLDER_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES, GearyAggregatedFolderPropertiesClass))
#define GEARY_IS_AGGREGATED_FOLDER_PROPERTIES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES))
#define GEARY_IS_AGGREGATED_FOLDER_PROPERTIES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES))
#define GEARY_AGGREGATED_FOLDER_PROPERTIES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_TYPE_AGGREGATED_FOLDER_PROPERTIES, GearyAggregatedFolderPropertiesClass))

typedef struct _GearyAggregatedFolderProperties GearyAggregatedFolderProperties;
typedef struct _GearyAggregatedFolderPropertiesClass GearyAggregatedFolderPropertiesClass;

#define GEARY_IMAP_ENGINE_TYPE_EMAIL_PREFETCHER (geary_imap_engine_email_prefetcher_get_type ())
#define GEARY_IMAP_ENGINE_EMAIL_PREFETCHER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_EMAIL_PREFETCHER, GearyImapEngineEmailPrefetcher))
#define GEARY_IMAP_ENGINE_EMAIL_PREFETCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_EMAIL_PREFETCHER, GearyImapEngineEmailPrefetcherClass))
#define GEARY_IMAP_ENGINE_IS_EMAIL_PREFETCHER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_EMAIL_PREFETCHER))
#define GEARY_IMAP_ENGINE_IS_EMAIL_PREFETCHER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_EMAIL_PREFETCHER))
#define GEARY_IMAP_ENGINE_EMAIL_PREFETCHER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_EMAIL_PREFETCHER, GearyImapEngineEmailPrefetcherClass))

typedef struct _GearyImapEngineEmailPrefetcher GearyImapEngineEmailPrefetcher;
typedef struct _GearyImapEngineEmailPrefetcherClass GearyImapEngineEmailPrefetcherClass;

#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;
enum  {
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_0_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_ACCOUNT_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_PROPERTIES_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_PATH_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_USED_AS_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_OPENING_MONITOR_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_LOCAL_FOLDER_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REPLAY_QUEUE_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_HARVESTER_PROPERTY,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _GearyImapEngineMinimalFolderOpenAsyncData GearyImapEngineMinimalFolderOpenAsyncData;
typedef struct _GearyImapEngineMinimalFolderClaimRemoteSessionData GearyImapEngineMinimalFolderClaimRemoteSessionData;

#define GEARY_IMAP_ENGINE_TYPE_USER_CLOSE (geary_imap_engine_user_close_get_type ())
#define GEARY_IMAP_ENGINE_USER_CLOSE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_USER_CLOSE, GearyImapEngineUserClose))
#define GEARY_IMAP_ENGINE_USER_CLOSE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_USER_CLOSE, GearyImapEngineUserCloseClass))
#define GEARY_IMAP_ENGINE_IS_USER_CLOSE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_USER_CLOSE))
#define GEARY_IMAP_ENGINE_IS_USER_CLOSE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_USER_CLOSE))
#define GEARY_IMAP_ENGINE_USER_CLOSE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_USER_CLOSE, GearyImapEngineUserCloseClass))

typedef struct _GearyImapEngineUserClose GearyImapEngineUserClose;
typedef struct _GearyImapEngineUserCloseClass GearyImapEngineUserCloseClass;
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 ())
typedef struct _GearyImapEngineUserClosePrivate GearyImapEngineUserClosePrivate;
typedef struct _GearyImapEngineMinimalFolderCloseAsyncData GearyImapEngineMinimalFolderCloseAsyncData;
typedef struct _GearyImapEngineMinimalFolderWaitForCloseAsyncData GearyImapEngineMinimalFolderWaitForCloseAsyncData;
typedef struct _GearyImapEngineMinimalFolderSynchroniseRemoteData GearyImapEngineMinimalFolderSynchroniseRemoteData;
typedef enum  {
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_NONE = 0,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_PARTIAL_OK = 1 << 0,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_INCLUDE_MARKED_FOR_REMOVE = 1 << 1,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_INCLUDING_ID = 1 << 2,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_OLDEST_TO_NEWEST = 1 << 3,
	GEARY_IMAP_DB_FOLDER_LIST_FLAGS_ONLY_INCOMPLETE = 1 << 4
} GearyImapDBFolderListFlags;

#define GEARY_IMAP_DB_FOLDER_TYPE_LIST_FLAGS (geary_imap_db_folder_list_flags_get_type ())
typedef struct _GearyImapEngineMinimalFolderDetachAllEmailsAsyncData GearyImapEngineMinimalFolderDetachAllEmailsAsyncData;
typedef struct _Block98Data Block98Data;

#define GEARY_IMAP_TYPE_FOLDER (geary_imap_folder_get_type ())
#define GEARY_IMAP_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_TYPE_FOLDER, GearyImapFolder))
#define GEARY_IMAP_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_TYPE_FOLDER, GearyImapFolderClass))
#define GEARY_IMAP_IS_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_TYPE_FOLDER))
#define GEARY_IMAP_IS_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_TYPE_FOLDER))
#define GEARY_IMAP_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_TYPE_FOLDER, GearyImapFolderClass))

typedef struct _GearyImapFolder GearyImapFolder;
typedef struct _GearyImapFolderClass GearyImapFolderClass;
typedef struct _Block99Data Block99Data;
typedef struct _GearyImapEngineMinimalFolderNormalizeFoldersData GearyImapEngineMinimalFolderNormalizeFoldersData;
typedef struct _Block100Data Block100Data;
typedef struct _GearyImapEngineMinimalFolderCloseInternalData GearyImapEngineMinimalFolderCloseInternalData;
typedef struct _GearyImapEngineMinimalFolderCloseRemoteSessionData GearyImapEngineMinimalFolderCloseRemoteSessionData;
typedef struct _GearyImapEngineMinimalFolderOpenLockedData GearyImapEngineMinimalFolderOpenLockedData;
typedef struct _GearyImapEngineMinimalFolderForceCloseData GearyImapEngineMinimalFolderForceCloseData;
typedef struct _GearyImapEngineMinimalFolderCloseInternalLockedData GearyImapEngineMinimalFolderCloseInternalLockedData;
typedef struct _GearyImapEngineMinimalFolderOpenRemoteSessionData GearyImapEngineMinimalFolderOpenRemoteSessionData;
typedef struct _GearyImapEngineMinimalFolderOpenRemoteSessionLockedData GearyImapEngineMinimalFolderOpenRemoteSessionLockedData;

#define GEARY_IMAP_ENGINE_TYPE_REPLAY_APPEND (geary_imap_engine_replay_append_get_type ())
#define GEARY_IMAP_ENGINE_REPLAY_APPEND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_APPEND, GearyImapEngineReplayAppend))
#define GEARY_IMAP_ENGINE_REPLAY_APPEND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_APPEND, GearyImapEngineReplayAppendClass))
#define GEARY_IMAP_ENGINE_IS_REPLAY_APPEND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_APPEND))
#define GEARY_IMAP_ENGINE_IS_REPLAY_APPEND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_APPEND))
#define GEARY_IMAP_ENGINE_REPLAY_APPEND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_APPEND, GearyImapEngineReplayAppendClass))

typedef struct _GearyImapEngineReplayAppend GearyImapEngineReplayAppend;
typedef struct _GearyImapEngineReplayAppendClass GearyImapEngineReplayAppendClass;

#define GEARY_IMAP_ENGINE_TYPE_REPLAY_UPDATE (geary_imap_engine_replay_update_get_type ())
#define GEARY_IMAP_ENGINE_REPLAY_UPDATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_UPDATE, GearyImapEngineReplayUpdate))
#define GEARY_IMAP_ENGINE_REPLAY_UPDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_UPDATE, GearyImapEngineReplayUpdateClass))
#define GEARY_IMAP_ENGINE_IS_REPLAY_UPDATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_UPDATE))
#define GEARY_IMAP_ENGINE_IS_REPLAY_UPDATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_UPDATE))
#define GEARY_IMAP_ENGINE_REPLAY_UPDATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_UPDATE, GearyImapEngineReplayUpdateClass))

typedef struct _GearyImapEngineReplayUpdate GearyImapEngineReplayUpdate;
typedef struct _GearyImapEngineReplayUpdateClass GearyImapEngineReplayUpdateClass;

#define GEARY_IMAP_ENGINE_TYPE_REPLAY_REMOVAL (geary_imap_engine_replay_removal_get_type ())
#define GEARY_IMAP_ENGINE_REPLAY_REMOVAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_REMOVAL, GearyImapEngineReplayRemoval))
#define GEARY_IMAP_ENGINE_REPLAY_REMOVAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_REMOVAL, GearyImapEngineReplayRemovalClass))
#define GEARY_IMAP_ENGINE_IS_REPLAY_REMOVAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_REMOVAL))
#define GEARY_IMAP_ENGINE_IS_REPLAY_REMOVAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REPLAY_REMOVAL))
#define GEARY_IMAP_ENGINE_REPLAY_REMOVAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REPLAY_REMOVAL, GearyImapEngineReplayRemovalClass))

typedef struct _GearyImapEngineReplayRemoval GearyImapEngineReplayRemoval;
typedef struct _GearyImapEngineReplayRemovalClass GearyImapEngineReplayRemovalClass;
typedef struct _GearyImapEngineMinimalFolderContainsIdentifiersData GearyImapEngineMinimalFolderContainsIdentifiersData;

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

#define GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL (geary_imap_engine_abstract_list_email_get_type ())
#define GEARY_IMAP_ENGINE_ABSTRACT_LIST_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail))
#define GEARY_IMAP_ENGINE_ABSTRACT_LIST_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmailClass))
#define GEARY_IMAP_ENGINE_IS_ABSTRACT_LIST_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL))
#define GEARY_IMAP_ENGINE_IS_ABSTRACT_LIST_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL))
#define GEARY_IMAP_ENGINE_ABSTRACT_LIST_EMAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmailClass))

typedef struct _GearyImapEngineAbstractListEmail GearyImapEngineAbstractListEmail;
typedef struct _GearyImapEngineAbstractListEmailClass GearyImapEngineAbstractListEmailClass;

#define GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID (geary_imap_engine_list_email_by_id_get_type ())
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByID))
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByIDClass))
#define GEARY_IMAP_ENGINE_IS_LIST_EMAIL_BY_ID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID))
#define GEARY_IMAP_ENGINE_IS_LIST_EMAIL_BY_ID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID))
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_ID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_ID, GearyImapEngineListEmailByIDClass))

typedef struct _GearyImapEngineListEmailByID GearyImapEngineListEmailByID;
typedef struct _GearyImapEngineListEmailByIDClass GearyImapEngineListEmailByIDClass;
typedef struct _GearyImapEngineSendReplayOperationPrivate GearyImapEngineSendReplayOperationPrivate;
typedef struct _GearyImapEngineAbstractListEmailPrivate GearyImapEngineAbstractListEmailPrivate;
typedef struct _GearyImapEngineMinimalFolderListEmailByIdAsyncData GearyImapEngineMinimalFolderListEmailByIdAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_SPARSE_ID (geary_imap_engine_list_email_by_sparse_id_get_type ())
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_SPARSE_ID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_SPARSE_ID, GearyImapEngineListEmailBySparseID))
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_SPARSE_ID_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_SPARSE_ID, GearyImapEngineListEmailBySparseIDClass))
#define GEARY_IMAP_ENGINE_IS_LIST_EMAIL_BY_SPARSE_ID(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_SPARSE_ID))
#define GEARY_IMAP_ENGINE_IS_LIST_EMAIL_BY_SPARSE_ID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_SPARSE_ID))
#define GEARY_IMAP_ENGINE_LIST_EMAIL_BY_SPARSE_ID_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_LIST_EMAIL_BY_SPARSE_ID, GearyImapEngineListEmailBySparseIDClass))

typedef struct _GearyImapEngineListEmailBySparseID GearyImapEngineListEmailBySparseID;
typedef struct _GearyImapEngineListEmailBySparseIDClass GearyImapEngineListEmailBySparseIDClass;
typedef struct _GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_FETCH_EMAIL (geary_imap_engine_fetch_email_get_type ())
#define GEARY_IMAP_ENGINE_FETCH_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_FETCH_EMAIL, GearyImapEngineFetchEmail))
#define GEARY_IMAP_ENGINE_FETCH_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_FETCH_EMAIL, GearyImapEngineFetchEmailClass))
#define GEARY_IMAP_ENGINE_IS_FETCH_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_FETCH_EMAIL))
#define GEARY_IMAP_ENGINE_IS_FETCH_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_FETCH_EMAIL))
#define GEARY_IMAP_ENGINE_FETCH_EMAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_FETCH_EMAIL, GearyImapEngineFetchEmailClass))

typedef struct _GearyImapEngineFetchEmail GearyImapEngineFetchEmail;
typedef struct _GearyImapEngineFetchEmailClass GearyImapEngineFetchEmailClass;
typedef struct _GearyImapEngineFetchEmailPrivate GearyImapEngineFetchEmailPrivate;
typedef struct _GearyImapEngineMinimalFolderFetchEmailAsyncData GearyImapEngineMinimalFolderFetchEmailAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_REMOVE_EMAIL (geary_imap_engine_remove_email_get_type ())
#define GEARY_IMAP_ENGINE_REMOVE_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REMOVE_EMAIL, GearyImapEngineRemoveEmail))
#define GEARY_IMAP_ENGINE_REMOVE_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REMOVE_EMAIL, GearyImapEngineRemoveEmailClass))
#define GEARY_IMAP_ENGINE_IS_REMOVE_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REMOVE_EMAIL))
#define GEARY_IMAP_ENGINE_IS_REMOVE_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REMOVE_EMAIL))
#define GEARY_IMAP_ENGINE_REMOVE_EMAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REMOVE_EMAIL, GearyImapEngineRemoveEmailClass))

typedef struct _GearyImapEngineRemoveEmail GearyImapEngineRemoveEmail;
typedef struct _GearyImapEngineRemoveEmailClass GearyImapEngineRemoveEmailClass;
typedef struct _GearyImapEngineMinimalFolderExpungeEmailAsyncData GearyImapEngineMinimalFolderExpungeEmailAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_EMPTY_FOLDER (geary_imap_engine_empty_folder_get_type ())
#define GEARY_IMAP_ENGINE_EMPTY_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_EMPTY_FOLDER, GearyImapEngineEmptyFolder))
#define GEARY_IMAP_ENGINE_EMPTY_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_EMPTY_FOLDER, GearyImapEngineEmptyFolderClass))
#define GEARY_IMAP_ENGINE_IS_EMPTY_FOLDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_EMPTY_FOLDER))
#define GEARY_IMAP_ENGINE_IS_EMPTY_FOLDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_EMPTY_FOLDER))
#define GEARY_IMAP_ENGINE_EMPTY_FOLDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_EMPTY_FOLDER, GearyImapEngineEmptyFolderClass))

typedef struct _GearyImapEngineEmptyFolder GearyImapEngineEmptyFolder;
typedef struct _GearyImapEngineEmptyFolderClass GearyImapEngineEmptyFolderClass;

#define GEARY_IMAP_DB_TYPE_ACCOUNT (geary_imap_db_account_get_type ())
#define GEARY_IMAP_DB_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_DB_TYPE_ACCOUNT, GearyImapDBAccount))
#define GEARY_IMAP_DB_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_DB_TYPE_ACCOUNT, GearyImapDBAccountClass))
#define GEARY_IMAP_DB_IS_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_DB_TYPE_ACCOUNT))
#define GEARY_IMAP_DB_IS_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_DB_TYPE_ACCOUNT))
#define GEARY_IMAP_DB_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_DB_TYPE_ACCOUNT, GearyImapDBAccountClass))

typedef struct _GearyImapDBAccount GearyImapDBAccount;
typedef struct _GearyImapDBAccountClass GearyImapDBAccountClass;

#define GEARY_IMAP_DB_TYPE_DATABASE (geary_imap_db_database_get_type ())
#define GEARY_IMAP_DB_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_DB_TYPE_DATABASE, GearyImapDBDatabase))
#define GEARY_IMAP_DB_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_DB_TYPE_DATABASE, GearyImapDBDatabaseClass))
#define GEARY_IMAP_DB_IS_DATABASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_DB_TYPE_DATABASE))
#define GEARY_IMAP_DB_IS_DATABASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_DB_TYPE_DATABASE))
#define GEARY_IMAP_DB_DATABASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_DB_TYPE_DATABASE, GearyImapDBDatabaseClass))

typedef struct _GearyImapDBDatabase GearyImapDBDatabase;
typedef struct _GearyImapDBDatabaseClass GearyImapDBDatabaseClass;
typedef enum  {
	GEARY_IMAP_DB_DATABASE_GARBAGE_COLLECTION_OPTIONS_NONE = 1 << 0,
	GEARY_IMAP_DB_DATABASE_GARBAGE_COLLECTION_OPTIONS_FORCE_REAP = 1 << 1,
	GEARY_IMAP_DB_DATABASE_GARBAGE_COLLECTION_OPTIONS_ALLOW_VACUUM = 1 << 2
} GearyImapDBDatabaseGarbageCollectionOptions;

#define GEARY_IMAP_DB_DATABASE_TYPE_GARBAGE_COLLECTION_OPTIONS (geary_imap_db_database_garbage_collection_options_get_type ())
typedef struct _GearyImapEngineMinimalFolderExpungeAllAsyncData GearyImapEngineMinimalFolderExpungeAllAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_MARK_EMAIL (geary_imap_engine_mark_email_get_type ())
#define GEARY_IMAP_ENGINE_MARK_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_MARK_EMAIL, GearyImapEngineMarkEmail))
#define GEARY_IMAP_ENGINE_MARK_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_MARK_EMAIL, GearyImapEngineMarkEmailClass))
#define GEARY_IMAP_ENGINE_IS_MARK_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_MARK_EMAIL))
#define GEARY_IMAP_ENGINE_IS_MARK_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_MARK_EMAIL))
#define GEARY_IMAP_ENGINE_MARK_EMAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_MARK_EMAIL, GearyImapEngineMarkEmailClass))

typedef struct _GearyImapEngineMarkEmail GearyImapEngineMarkEmail;
typedef struct _GearyImapEngineMarkEmailClass GearyImapEngineMarkEmailClass;
typedef struct _GearyImapEngineMinimalFolderMarkEmailAsyncData GearyImapEngineMinimalFolderMarkEmailAsyncData;
typedef struct _GearyImapEngineMinimalFolderCopyEmailAsyncData GearyImapEngineMinimalFolderCopyEmailAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_COPY_EMAIL (geary_imap_engine_copy_email_get_type ())
#define GEARY_IMAP_ENGINE_COPY_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_COPY_EMAIL, GearyImapEngineCopyEmail))
#define GEARY_IMAP_ENGINE_COPY_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_COPY_EMAIL, GearyImapEngineCopyEmailClass))
#define GEARY_IMAP_ENGINE_IS_COPY_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_COPY_EMAIL))
#define GEARY_IMAP_ENGINE_IS_COPY_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_COPY_EMAIL))
#define GEARY_IMAP_ENGINE_COPY_EMAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_COPY_EMAIL, GearyImapEngineCopyEmailClass))

typedef struct _GearyImapEngineCopyEmail GearyImapEngineCopyEmail;
typedef struct _GearyImapEngineCopyEmailClass GearyImapEngineCopyEmailClass;
typedef struct _GearyImapEngineCopyEmailPrivate GearyImapEngineCopyEmailPrivate;
typedef struct _GearyImapEngineMinimalFolderCopyEmailUidsAsyncData GearyImapEngineMinimalFolderCopyEmailUidsAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_PREPARE (geary_imap_engine_move_email_prepare_get_type ())
#define GEARY_IMAP_ENGINE_MOVE_EMAIL_PREPARE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_PREPARE, GearyImapEngineMoveEmailPrepare))
#define GEARY_IMAP_ENGINE_MOVE_EMAIL_PREPARE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_PREPARE, GearyImapEngineMoveEmailPrepareClass))
#define GEARY_IMAP_ENGINE_IS_MOVE_EMAIL_PREPARE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_PREPARE))
#define GEARY_IMAP_ENGINE_IS_MOVE_EMAIL_PREPARE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_PREPARE))
#define GEARY_IMAP_ENGINE_MOVE_EMAIL_PREPARE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_MOVE_EMAIL_PREPARE, GearyImapEngineMoveEmailPrepareClass))

typedef struct _GearyImapEngineMoveEmailPrepare GearyImapEngineMoveEmailPrepare;
typedef struct _GearyImapEngineMoveEmailPrepareClass GearyImapEngineMoveEmailPrepareClass;
typedef struct _GearyImapEngineMoveEmailPreparePrivate GearyImapEngineMoveEmailPreparePrivate;

#define GEARY_IMAP_ENGINE_TYPE_REVOKABLE_MOVE (geary_imap_engine_revokable_move_get_type ())
#define GEARY_IMAP_ENGINE_REVOKABLE_MOVE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_MOVE, GearyImapEngineRevokableMove))
#define GEARY_IMAP_ENGINE_REVOKABLE_MOVE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_MOVE, GearyImapEngineRevokableMoveClass))
#define GEARY_IMAP_ENGINE_IS_REVOKABLE_MOVE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_MOVE))
#define GEARY_IMAP_ENGINE_IS_REVOKABLE_MOVE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_MOVE))
#define GEARY_IMAP_ENGINE_REVOKABLE_MOVE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REVOKABLE_MOVE, GearyImapEngineRevokableMoveClass))

typedef struct _GearyImapEngineRevokableMove GearyImapEngineRevokableMove;
typedef struct _GearyImapEngineRevokableMoveClass GearyImapEngineRevokableMoveClass;
typedef struct _GearyImapEngineMinimalFolderMoveEmailAsyncData GearyImapEngineMinimalFolderMoveEmailAsyncData;
typedef struct _GearyImapEngineMinimalFolderExecOpAsyncData GearyImapEngineMinimalFolderExecOpAsyncData;
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

#define GEARY_IMAP_ENGINE_TYPE_SERVER_SEARCH_EMAIL (geary_imap_engine_server_search_email_get_type ())
#define GEARY_IMAP_ENGINE_SERVER_SEARCH_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_SERVER_SEARCH_EMAIL, GearyImapEngineServerSearchEmail))
#define GEARY_IMAP_ENGINE_SERVER_SEARCH_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_SERVER_SEARCH_EMAIL, GearyImapEngineServerSearchEmailClass))
#define GEARY_IMAP_ENGINE_IS_SERVER_SEARCH_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_SERVER_SEARCH_EMAIL))
#define GEARY_IMAP_ENGINE_IS_SERVER_SEARCH_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_SERVER_SEARCH_EMAIL))
#define GEARY_IMAP_ENGINE_SERVER_SEARCH_EMAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_SERVER_SEARCH_EMAIL, GearyImapEngineServerSearchEmailClass))

typedef struct _GearyImapEngineServerSearchEmail GearyImapEngineServerSearchEmail;
typedef struct _GearyImapEngineServerSearchEmailClass GearyImapEngineServerSearchEmailClass;
typedef struct _GearyImapEngineMinimalFolderFindEarliestEmailAsyncData GearyImapEngineMinimalFolderFindEarliestEmailAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_CREATE_EMAIL (geary_imap_engine_create_email_get_type ())
#define GEARY_IMAP_ENGINE_CREATE_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_CREATE_EMAIL, GearyImapEngineCreateEmail))
#define GEARY_IMAP_ENGINE_CREATE_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_CREATE_EMAIL, GearyImapEngineCreateEmailClass))
#define GEARY_IMAP_ENGINE_IS_CREATE_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_CREATE_EMAIL))
#define GEARY_IMAP_ENGINE_IS_CREATE_EMAIL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_CREATE_EMAIL))
#define GEARY_IMAP_ENGINE_CREATE_EMAIL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_CREATE_EMAIL, GearyImapEngineCreateEmailClass))

typedef struct _GearyImapEngineCreateEmail GearyImapEngineCreateEmail;
typedef struct _GearyImapEngineCreateEmailClass GearyImapEngineCreateEmailClass;
typedef struct _GearyImapEngineMinimalFolderCreateEmailAsyncData GearyImapEngineMinimalFolderCreateEmailAsyncData;
typedef struct _GearyImapEngineMinimalFolderUpdateFlagsData GearyImapEngineMinimalFolderUpdateFlagsData;

#define GEARY_TYPE_CONTACT_HARVESTER_IMPL (geary_contact_harvester_impl_get_type ())
#define GEARY_CONTACT_HARVESTER_IMPL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_TYPE_CONTACT_HARVESTER_IMPL, GearyContactHarvesterImpl))
#define GEARY_CONTACT_HARVESTER_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_TYPE_CONTACT_HARVESTER_IMPL, GearyContactHarvesterImplClass))
#define GEARY_IS_CONTACT_HARVESTER_IMPL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_TYPE_CONTACT_HARVESTER_IMPL))
#define GEARY_IS_CONTACT_HARVESTER_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_TYPE_CONTACT_HARVESTER_IMPL))
#define GEARY_CONTACT_HARVESTER_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_TYPE_CONTACT_HARVESTER_IMPL, GearyContactHarvesterImplClass))

typedef struct _GearyContactHarvesterImpl GearyContactHarvesterImpl;
typedef struct _GearyContactHarvesterImplClass GearyContactHarvesterImplClass;

#define GEARY_IMAP_ENGINE_TYPE_REFRESH_FOLDER_UNSEEN (geary_imap_engine_refresh_folder_unseen_get_type ())
#define GEARY_IMAP_ENGINE_REFRESH_FOLDER_UNSEEN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_REFRESH_FOLDER_UNSEEN, GearyImapEngineRefreshFolderUnseen))
#define GEARY_IMAP_ENGINE_REFRESH_FOLDER_UNSEEN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_REFRESH_FOLDER_UNSEEN, GearyImapEngineRefreshFolderUnseenClass))
#define GEARY_IMAP_ENGINE_IS_REFRESH_FOLDER_UNSEEN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_REFRESH_FOLDER_UNSEEN))
#define GEARY_IMAP_ENGINE_IS_REFRESH_FOLDER_UNSEEN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_REFRESH_FOLDER_UNSEEN))
#define GEARY_IMAP_ENGINE_REFRESH_FOLDER_UNSEEN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_REFRESH_FOLDER_UNSEEN, GearyImapEngineRefreshFolderUnseenClass))

typedef struct _GearyImapEngineRefreshFolderUnseen GearyImapEngineRefreshFolderUnseen;
typedef struct _GearyImapEngineRefreshFolderUnseenClass GearyImapEngineRefreshFolderUnseenClass;
typedef struct _Block101Data Block101Data;
enum  {
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_CLOSING_SIGNAL,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_MARKED_EMAIL_REMOVED_SIGNAL,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REPORT_PROBLEM_SIGNAL,
	GEARY_IMAP_ENGINE_MINIMAL_FOLDER_NUM_SIGNALS
};
static guint geary_imap_engine_minimal_folder_signals[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_NUM_SIGNALS] = {0};
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _GearyImapEngineMinimalFolder {
	GearyFolder parent_instance;
	GearyImapEngineMinimalFolderPrivate * priv;
};

struct _GearyImapEngineMinimalFolderClass {
	GearyFolderClass parent_class;
	void (*notify_closing) (GearyImapEngineMinimalFolder* self, GeeList* final_ops);
	void (*mark_email_async) (GearyImapEngineMinimalFolder* self, GeeCollection* to_mark, GearyEmailFlags* flags_to_add, GearyEmailFlags* flags_to_remove, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*mark_email_finish) (GearyImapEngineMinimalFolder* self, GAsyncResult* _res_, GError** error);
	void (*copy_email_async) (GearyImapEngineMinimalFolder* self, GeeCollection* to_copy, GearyFolderPath* destination, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*copy_email_finish) (GearyImapEngineMinimalFolder* self, GAsyncResult* _res_, GError** error);
	void (*move_email_async) (GearyImapEngineMinimalFolder* self, GeeCollection* to_move, GearyFolderPath* destination, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GearyRevokable* (*move_email_finish) (GearyImapEngineMinimalFolder* self, GAsyncResult* _res_, GError** error);
	void (*notify_marked_email_removed) (GearyImapEngineMinimalFolder* self, GeeCollection* removed);
};

struct _GearyContactHarvesterIface {
	GTypeInterface parent_iface;
	void (*harvest_from_email) (GearyContactHarvester* self, GeeCollection* messages, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*harvest_from_email_finish) (GearyContactHarvester* self, GAsyncResult* _res_, GError** error);
};

struct _GearyImapEngineMinimalFolderPrivate {
	GearyFolderSpecialUse _used_as;
	GearyProgressMonitor* _opening_monitor;
	GearyImapDBFolder* _local_folder;
	GearyImapEngineReplayQueue* _replay_queue;
	GearyContactHarvester* _harvester;
	GearyImapEngineGenericAccount* _account;
	GearyAggregatedFolderProperties* _properties;
	GearyImapEngineEmailPrefetcher* email_prefetcher;
	gint open_count;
	GearyFolderOpenFlags open_flags;
	GCancellable* open_cancellable;
	GearyNonblockingMutex* lifecycle_mutex;
	GearyNonblockingSemaphore* closed_semaphore;
	GearyImapFolderSession* remote_session;
	GearyNonblockingMutex* remote_mutex;
	GearyNonblockingReportingSemaphore* remote_wait_semaphore;
	GearyTimeoutManager* remote_open_timer;
	GearyTimeoutManager* update_flags_timer;
	GearyTimeoutManager* refresh_unseen_timer;
};

struct _GearyImapEngineMinimalFolderOpenAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyFolderOpenFlags open_flags;
	GCancellable* cancellable;
	gboolean result;
	gboolean opening;
	GError* open_err;
	gint token;
	GearyNonblockingMutex* _tmp0_;
	gboolean _tmp1_;
	GError* err;
	GError* _tmp2_;
	GError* _tmp3_;
	GearyNonblockingMutex* _tmp4_;
	GError* _tmp5_;
	GError* _tmp6_;
	GError* _tmp7_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderClaimRemoteSessionData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GCancellable* cancellable;
	GearyImapFolderSession* result;
	gboolean _tmp0_;
	GearyImapFolderSession* _tmp1_;
	GCancellable* _tmp2_;
	gboolean _tmp3_;
	GearyNonblockingReportingSemaphore* _tmp4_;
	gpointer _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GError* _tmp8_;
	GError* _tmp9_;
	GearyImapFolderSession* _tmp10_;
	GearyImapFolderSession* _tmp11_;
	GError* _inner_error0_;
};

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 _GearyImapEngineUserClose {
	GearyImapEngineReplayOperation parent_instance;
	GearyTrillian is_closing;
	GearyImapEngineUserClosePrivate * priv;
};

struct _GearyImapEngineUserCloseClass {
	GearyImapEngineReplayOperationClass parent_class;
};

struct _GearyImapEngineMinimalFolderCloseAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GCancellable* cancellable;
	gboolean result;
	GearyImapEngineUserClose* op;
	GearyImapEngineUserClose* _tmp0_;
	GearyImapEngineReplayQueue* _tmp1_;
	GearyImapEngineUserClose* _tmp2_;
	GearyImapEngineUserClose* _tmp3_;
	GearyImapEngineUserClose* _tmp4_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderWaitForCloseAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GCancellable* cancellable;
	GearyNonblockingSemaphore* _tmp0_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderSynchroniseRemoteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GCancellable* cancellable;
	gboolean have_nooped;
	gint retries;
	gboolean _tmp0_;
	GearyImapFolderSession* remote;
	GearyImapFolderSession* _tmp1_;
	GearyImapFolderSession* _tmp2_;
	GError* err;
	gboolean _tmp3_;
	GError* _tmp4_;
	GError* _tmp5_;
	const gchar* _tmp6_;
	GError* _tmp7_;
	GError* _tmp8_;
	GearyImapEngineReplayQueue* _tmp9_;
	GearyImapEngineReplayQueue* _tmp10_;
	GearyImapEngineEmailPrefetcher* _tmp11_;
	GearyNonblockingCountingSemaphore* _tmp12_;
	GearyNonblockingCountingSemaphore* _tmp13_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderDetachAllEmailsAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GCancellable* cancellable;
	GeeList* all;
	GearyImapDBFolder* _tmp0_;
	GeeList* _tmp1_;
	GearyImapDBFolder* _tmp2_;
	gboolean _tmp3_;
	GeeList* _tmp4_;
	GeeList* _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	GeeList* ids;
	GeeList* _tmp8_;
	GearyIterable* _tmp9_;
	GearyIterable* _tmp10_;
	GearyIterable* _tmp11_;
	GearyIterable* _tmp12_;
	GeeArrayList* _tmp13_;
	GeeList* _tmp14_;
	GeeList* _tmp15_;
	GError* _inner_error0_;
};

struct _Block98Data {
	int _ref_count_;
	GearyImapEngineMinimalFolder* self;
	GearyImapDBEmailIdentifier* local_latest_id;
	GeeSet* already_marked_ids;
	GeeSet* local_uids;
	GeeSet* remote_uids;
	GeeHashSet* removed_uids;
	GeeHashSet* appended_uids;
	GeeHashSet* inserted_uids;
	GeeSet* appended_ids;
	GeeSet* locally_appended_ids;
	GeeSet* inserted_ids;
	GeeSet* locally_inserted_ids;
	gpointer _async_data_;
};

struct _Block99Data {
	int _ref_count_;
	Block98Data * _data98_;
	GeeMap* created_or_merged;
};

struct _GearyImapEngineMinimalFolderNormalizeFoldersData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyImapFolderSession* session;
	GCancellable* cancellable;
	Block98Data* _data98_;
	GearyImapFolderProperties* local_properties;
	GearyImapDBFolder* _tmp0_;
	GearyImapFolderProperties* _tmp1_;
	GearyImapFolderProperties* remote_properties;
	GearyImapFolder* _tmp2_;
	GearyImapFolder* _tmp3_;
	GearyImapFolderProperties* _tmp4_;
	GearyImapFolderProperties* _tmp5_;
	GearyImapFolderProperties* _tmp6_;
	gboolean _tmp7_;
	GearyImapFolderProperties* _tmp8_;
	GearyImapUID* _tmp9_;
	GearyImapUID* _tmp10_;
	GearyImapFolderProperties* _tmp11_;
	GearyImapUIDValidity* _tmp12_;
	GearyImapUIDValidity* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	GearyImapFolderProperties* _tmp16_;
	GearyImapUID* _tmp17_;
	GearyImapUID* _tmp18_;
	gchar* _tmp19_;
	gchar* _tmp20_;
	GearyImapFolderProperties* _tmp21_;
	GearyImapUIDValidity* _tmp22_;
	GearyImapUIDValidity* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	GError* _tmp26_;
	GError* _tmp27_;
	gboolean _tmp28_;
	GearyImapFolderProperties* _tmp29_;
	GearyImapUID* _tmp30_;
	GearyImapUID* _tmp31_;
	GearyImapFolderProperties* _tmp32_;
	GearyImapUIDValidity* _tmp33_;
	GearyImapUIDValidity* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	GearyImapFolderProperties* _tmp37_;
	GearyImapUID* _tmp38_;
	GearyImapUID* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	GearyImapFolderProperties* _tmp42_;
	GearyImapUIDValidity* _tmp43_;
	GearyImapUIDValidity* _tmp44_;
	gchar* _tmp45_;
	gchar* _tmp46_;
	GError* _tmp47_;
	GError* _tmp48_;
	GearyImapFolderProperties* _tmp49_;
	GearyImapUIDValidity* _tmp50_;
	GearyImapUIDValidity* _tmp51_;
	gint64 _tmp52_;
	gint64 _tmp53_;
	GearyImapFolderProperties* _tmp54_;
	GearyImapUIDValidity* _tmp55_;
	GearyImapUIDValidity* _tmp56_;
	gint64 _tmp57_;
	gint64 _tmp58_;
	GearyImapFolderProperties* _tmp59_;
	GearyImapUIDValidity* _tmp60_;
	GearyImapUIDValidity* _tmp61_;
	gint64 _tmp62_;
	gint64 _tmp63_;
	gchar* _tmp64_;
	gchar* _tmp65_;
	GearyImapFolderProperties* _tmp66_;
	GearyImapUIDValidity* _tmp67_;
	GearyImapUIDValidity* _tmp68_;
	gint64 _tmp69_;
	gint64 _tmp70_;
	gchar* _tmp71_;
	gchar* _tmp72_;
	GearyImapDBEmailIdentifier* local_earliest_id;
	GearyImapDBFolder* _tmp73_;
	GearyImapDBEmailIdentifier* _tmp74_;
	GearyImapDBFolder* _tmp75_;
	GearyImapDBEmailIdentifier* _tmp76_;
	gboolean _tmp77_;
	GearyImapDBEmailIdentifier* _tmp78_;
	GearyImapDBEmailIdentifier* _tmp79_;
	GearyImapDBFolder* _tmp80_;
	GeeSet* _tmp81_;
	GeeHashSet* to_be_removed;
	GeeHashSet* _tmp82_;
	GearyImapEngineReplayQueue* _tmp83_;
	GeeHashSet* _tmp84_;
	GeeSet* _tmp85_;
	GeeSet* _tmp86_;
	GeeHashSet* _tmp87_;
	gboolean _tmp88_;
	GeeSet* _tmp89_;
	GeeSet* _tmp90_;
	gint _tmp91_;
	gint _tmp92_;
	gboolean is_dirty;
	GeeSet* _tmp93_;
	gint _tmp94_;
	gint _tmp95_;
	GearyImapUID* last_uid;
	GearyImapFolderProperties* _tmp96_;
	GearyImapUID* _tmp97_;
	GearyImapUID* _tmp98_;
	GearyImapUID* _tmp99_;
	gboolean _tmp100_;
	GearyImapDBEmailIdentifier* _tmp101_;
	GearyImapUID* _tmp102_;
	GearyImapUID* _tmp103_;
	GearyImapUID* _tmp104_;
	GearyImapDBEmailIdentifier* _tmp105_;
	GearyImapUID* _tmp106_;
	GearyImapUID* _tmp107_;
	GearyImapUID* _tmp108_;
	GearyImapDBEmailIdentifier* _tmp109_;
	GearyImapUID* _tmp110_;
	GearyImapUID* _tmp111_;
	gchar* _tmp112_;
	gchar* _tmp113_;
	GearyImapDBEmailIdentifier* _tmp114_;
	GearyImapUID* _tmp115_;
	GearyImapUID* _tmp116_;
	gchar* _tmp117_;
	gchar* _tmp118_;
	GearyImapUID* _tmp119_;
	gchar* _tmp120_;
	gchar* _tmp121_;
	gint64 uidnext_diff;
	GearyImapFolderProperties* _tmp122_;
	GearyImapUID* _tmp123_;
	GearyImapUID* _tmp124_;
	gint64 _tmp125_;
	gint64 _tmp126_;
	GearyImapFolderProperties* _tmp127_;
	GearyImapUID* _tmp128_;
	GearyImapUID* _tmp129_;
	gint64 _tmp130_;
	gint64 _tmp131_;
	gint _tmp132_;
	GearyImapFolderProperties* _tmp133_;
	gint _tmp134_;
	gint _tmp135_;
	GearyImapFolderProperties* _tmp136_;
	gint _tmp137_;
	gint _tmp138_;
	gint local_message_count;
	gint _tmp139_;
	GearyImapFolderProperties* _tmp140_;
	gint _tmp141_;
	gint _tmp142_;
	GearyImapFolderProperties* _tmp143_;
	gint _tmp144_;
	gint _tmp145_;
	gint remote_message_count;
	gboolean _tmp146_;
	gboolean _tmp147_;
	GearyImapUID* first_uid;
	gboolean _tmp148_;
	GearyImapDBEmailIdentifier* _tmp149_;
	GearyImapUID* _tmp150_;
	GearyImapUID* _tmp151_;
	GearyImapUID* _tmp152_;
	GearyImapFolderProperties* _tmp153_;
	GearyImapUID* _tmp154_;
	GearyImapUID* _tmp155_;
	gchar* _tmp156_;
	gchar* _tmp157_;
	GearyImapFolderProperties* _tmp158_;
	GearyImapUID* _tmp159_;
	GearyImapUID* _tmp160_;
	gchar* _tmp161_;
	gchar* _tmp162_;
	GearyImapFolderProperties* _tmp163_;
	gint _tmp164_;
	gint _tmp165_;
	GearyImapFolderProperties* _tmp166_;
	gint _tmp167_;
	gint _tmp168_;
	gchar* _tmp169_;
	gchar* _tmp170_;
	GearyImapUID* _tmp171_;
	gchar* _tmp172_;
	gchar* _tmp173_;
	GearyImapUID* _tmp174_;
	gchar* _tmp175_;
	gchar* _tmp176_;
	GearyImapDBEmailIdentifier* _tmp177_;
	GearyImapUID* _tmp178_;
	GearyImapUID* _tmp179_;
	GearyImapUID* _tmp180_;
	GearyImapFolderProperties* _tmp181_;
	GearyImapUID* _tmp182_;
	GearyImapUID* _tmp183_;
	gchar* _tmp184_;
	gchar* _tmp185_;
	GearyImapFolderProperties* _tmp186_;
	GearyImapUID* _tmp187_;
	GearyImapUID* _tmp188_;
	gchar* _tmp189_;
	gchar* _tmp190_;
	GearyImapFolderProperties* _tmp191_;
	gint _tmp192_;
	gint _tmp193_;
	GearyImapFolderProperties* _tmp194_;
	gint _tmp195_;
	gint _tmp196_;
	gchar* _tmp197_;
	gchar* _tmp198_;
	GearyImapUID* _tmp199_;
	gchar* _tmp200_;
	gchar* _tmp201_;
	GearyImapUID* _tmp202_;
	gchar* _tmp203_;
	gchar* _tmp204_;
	GearyImapDBFolder* _tmp205_;
	GearyImapUID* _tmp206_;
	GearyImapUID* _tmp207_;
	GeeSet* _tmp208_;
	GeeSet* _tmp209_;
	GeeHashSet* _tmp210_;
	GearyImapUID* _tmp211_;
	GearyImapUID* _tmp212_;
	GearyImapMessageSet* _tmp213_;
	GearyImapMessageSet* _tmp214_;
	GeeSet* _tmp215_;
	GeeSet* _tmp216_;
	GeeSet* _tmp217_;
	GeeHashSet* _tmp218_;
	GeeSet* _tmp219_;
	gint _tmp220_;
	gint _tmp221_;
	GeeSet* _tmp222_;
	gint _tmp223_;
	gint _tmp224_;
	GeeHashSet* _tmp225_;
	GeeHashSet* _tmp226_;
	GeeHashSet* _tmp227_;
	GearyNonblockingConcurrent* _tmp228_;
	GearyNonblockingConcurrent* _tmp229_;
	GeeHashSet* _tmp230_;
	gint _tmp231_;
	gint _tmp232_;
	GeeHashSet* _tmp233_;
	gint _tmp234_;
	gint _tmp235_;
	GeeHashSet* _tmp236_;
	gint _tmp237_;
	gint _tmp238_;
	GeeList* to_create;
	GeeArrayList* _tmp239_;
	GeeSet* _tmp240_;
	gint _tmp241_;
	gint _tmp242_;
	GeeList* msg_sets;
	GeeSet* _tmp243_;
	GeeList* _tmp244_;
	GeeList* _msg_set_list;
	GeeList* _tmp245_;
	gint _msg_set_size;
	GeeList* _tmp246_;
	gint _tmp247_;
	gint _tmp248_;
	gint _msg_set_index;
	gint _tmp249_;
	gint _tmp250_;
	GearyImapMessageSet* msg_set;
	GeeList* _tmp251_;
	gpointer _tmp252_;
	GeeList* list;
	GearyImapMessageSet* _tmp253_;
	GeeList* _tmp254_;
	gboolean _tmp255_;
	GeeList* _tmp256_;
	GeeList* _tmp257_;
	gint _tmp258_;
	gint _tmp259_;
	GeeList* _tmp260_;
	GeeList* _tmp261_;
	GeeHashSet* _tmp262_;
	GeeHashSet* _tmp263_;
	GeeHashSet* _tmp264_;
	GeeHashSet* _tmp265_;
	GeeList* _tmp266_;
	gint _tmp267_;
	gint _tmp268_;
	Block99Data* _data99_;
	GearyImapDBFolder* _tmp269_;
	GeeList* _tmp270_;
	GearyContactHarvester* _tmp271_;
	GeeMap* _tmp272_;
	GeeMap* _tmp273_;
	GearyNonblockingConcurrent* _tmp274_;
	GearyNonblockingConcurrent* _tmp275_;
	GeeMap* _tmp276_;
	gint _tmp277_;
	gint _tmp278_;
	GeeSet* removed_ids;
	GeeHashSet* _tmp279_;
	gint _tmp280_;
	gint _tmp281_;
	GeeSet* _tmp282_;
	GearyImapDBFolder* _tmp283_;
	GeeHashSet* _tmp284_;
	GeeSet* _tmp285_;
	GeeSet* _tmp286_;
	gboolean _tmp287_;
	GeeSet* _tmp288_;
	GeeSet* _tmp289_;
	gint _tmp290_;
	gint _tmp291_;
	GearyImapDBFolder* _tmp292_;
	GeeSet* _tmp293_;
	GearyImapDBFolder* _tmp294_;
	GeeHashSet* _tmp295_;
	GearyFolderCountChangeReason count_change_reason;
	gboolean _tmp296_;
	GeeSet* _tmp297_;
	GeeSet* _tmp298_;
	gint _tmp299_;
	gint _tmp300_;
	GearyImapEngineReplayQueue* _tmp301_;
	GeeSet* _tmp302_;
	GeeSet* _tmp303_;
	gint _tmp304_;
	gint _tmp305_;
	GeeSet* _tmp306_;
	GeeSet* _tmp307_;
	gint _tmp308_;
	gint _tmp309_;
	GeeSet* _tmp310_;
	gint _tmp311_;
	gint _tmp312_;
	GeeSet* _tmp313_;
	GeeSet* _tmp314_;
	gint _tmp315_;
	gint _tmp316_;
	GeeSet* _tmp317_;
	gint _tmp318_;
	gint _tmp319_;
	GeeSet* _tmp320_;
	GeeSet* _tmp321_;
	gint _tmp322_;
	gint _tmp323_;
	GeeSet* _tmp324_;
	gint _tmp325_;
	gint _tmp326_;
	GeeSet* _tmp327_;
	GeeSet* _tmp328_;
	gint _tmp329_;
	gint _tmp330_;
	GeeSet* _tmp331_;
	gint _tmp332_;
	gint _tmp333_;
	GeeSet* _tmp334_;
	GError* _inner_error0_;
};

struct _Block100Data {
	int _ref_count_;
	GearyImapEngineMinimalFolder* self;
	gint token;
};

struct _GearyImapEngineMinimalFolderCloseInternalData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyFolderCloseReason local_reason;
	GearyFolderCloseReason remote_reason;
	GCancellable* cancellable;
	gboolean result;
	gboolean is_closing;
	Block100Data* _data100_;
	GearyNonblockingMutex* _tmp0_;
	GearyNonblockingMutex* _tmp1_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderCloseRemoteSessionData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyFolderCloseReason remote_reason;
	GCancellable* _tmp0_;
	GearyNonblockingReportingSemaphore* _tmp1_;
	GearyImapFolderSession* session;
	GearyImapFolderSession* _tmp2_;
	GearyImapFolderSession* _tmp3_;
	GearyImapFolderSession* _tmp4_;
	GearyImapFolderSession* _tmp5_;
	guint _tmp6_;
	GearyImapFolderSession* _tmp7_;
	guint _tmp8_;
	GearyImapFolderSession* _tmp9_;
	guint _tmp10_;
	GearyImapFolderSession* _tmp11_;
	guint _tmp12_;
	GearyAggregatedFolderProperties* _tmp13_;
	GearyImapFolderSession* _tmp14_;
	GearyImapFolder* _tmp15_;
	GearyImapFolder* _tmp16_;
	GearyImapFolderProperties* _tmp17_;
	GearyImapFolderProperties* _tmp18_;
	GearyImapEngineGenericAccount* _tmp19_;
	GearyImapFolderSession* _tmp20_;
};

struct _GearyImapEngineMinimalFolderOpenLockedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyFolderOpenFlags open_flags;
	GCancellable* cancellable;
	gboolean result;
	gint _tmp0_;
	GearyImapFolderSession* _tmp1_;
	GearyNonblockingSemaphore* _tmp2_;
	GearyTimeoutManager* _tmp3_;
	GCancellable* _tmp4_;
	GearyImapEngineReplayQueue* _tmp5_;
	GearyImapEngineReplayQueue* _tmp6_;
	GearyImapEngineEmailPrefetcher* _tmp7_;
	GearyImapDBFolder* _tmp8_;
	GearyImapFolderProperties* _tmp9_;
	GearyImapFolderProperties* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	GearyImapEngineGenericAccount* _tmp13_;
	GearyImapClientService* _tmp14_;
	GearyImapClientService* _tmp15_;
	GearyTimeoutManager* _tmp16_;
};

struct _GearyImapEngineMinimalFolderForceCloseData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyFolderCloseReason local_reason;
	GearyFolderCloseReason remote_reason;
	gint token;
	GearyNonblockingMutex* _tmp0_;
	GearyNonblockingMutex* _tmp1_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderCloseInternalLockedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyFolderCloseReason local_reason;
	GearyFolderCloseReason remote_reason;
	GCancellable* cancellable;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyImapClientService* _tmp1_;
	GearyImapClientService* _tmp2_;
	guint _tmp3_;
	GQuark _tmp4_;
	GearyTimeoutManager* _tmp5_;
	GCancellable* _tmp6_;
	GearyImapEngineEmailPrefetcher* _tmp7_;
	GearyTimeoutManager* _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	GearyImapFolderSession* _tmp11_;
	gboolean flush_pending;
	GeeList* final_ops;
	GeeArrayList* _tmp12_;
	GeeList* _tmp13_;
	GeeList* _op_list;
	GeeList* _tmp14_;
	gint _op_size;
	GeeList* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	gint _op_index;
	gint _tmp18_;
	gint _tmp19_;
	GearyImapEngineReplayOperation* op;
	GeeList* _tmp20_;
	gpointer _tmp21_;
	GearyImapEngineReplayQueue* _tmp22_;
	GearyImapEngineReplayOperation* _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	GearyImapEngineReplayQueue* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	GearyImapEngineReplayQueue* _tmp29_;
	GearyImapEngineReplayQueue* _tmp30_;
	gchar* _tmp31_;
	gchar* _tmp32_;
	GError* err;
	GError* _tmp33_;
	const gchar* _tmp34_;
	GearyNonblockingReportingSemaphore* _tmp35_;
	GearyNonblockingSemaphore* _tmp36_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderOpenRemoteSessionData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	gint token;
	GearyNonblockingMutex* _tmp0_;
	GCancellable* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	GearyImapEngineGenericAccount* _tmp4_;
	GearyImapClientService* _tmp5_;
	GearyImapClientService* _tmp6_;
	GearyClientServiceStatus _tmp7_;
	GearyClientServiceStatus _tmp8_;
	GearyImapFolderSession* _tmp9_;
	GearyProgressMonitor* _tmp10_;
	GearyProgressMonitor* _tmp11_;
	GCancellable* _tmp12_;
	GearyProgressMonitor* _tmp13_;
	GearyProgressMonitor* _tmp14_;
	GearyNonblockingMutex* _tmp15_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderOpenRemoteSessionLockedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GCancellable* cancellable;
	GearyTimeoutManager* _tmp0_;
	GearyImapFolderSession* session;
	GearyImapFolderSession* _tmp1_;
	GearyImapEngineGenericAccount* _tmp2_;
	GearyFolderPath* _tmp3_;
	GearyFolderPath* _tmp4_;
	GearyImapFolderSession* _tmp5_;
	GearyImapFolderSession* _tmp6_;
	GError* err;
	GearyErrorContext* context;
	GError* _tmp7_;
	GearyErrorContext* _tmp8_;
	GError* _tmp9_;
	GearyErrorContext* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	GearyErrorContext* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	GError* _tmp16_;
	GearyImapFolderSession* _tmp17_;
	GearyImapFolderSession* _tmp18_;
	GearyImapFolderSession* _tmp19_;
	GearyImapFolderSession* _tmp20_;
	GError* _vala1_err;
	GearyImapEngineGenericAccount* _tmp21_;
	GearyImapFolderSession* _tmp22_;
	GError* _tmp23_;
	GearyFolderCloseReason local_reason;
	GearyFolderCloseReason remote_reason;
	GError* _tmp24_;
	GError* _tmp25_;
	GError* _tmp26_;
	GearyImapFolderSession* _tmp27_;
	GearyImapFolder* _tmp28_;
	GearyImapFolder* _tmp29_;
	GearyImapFolderProperties* _tmp30_;
	GearyImapFolderProperties* _tmp31_;
	GearyImapFolderSession* _tmp32_;
	GearyImapFolder* _tmp33_;
	GearyImapFolder* _tmp34_;
	GearyImapFolderProperties* _tmp35_;
	GearyImapFolderProperties* _tmp36_;
	gint _tmp37_;
	gint _tmp38_;
	GearyImapEngineReplayQueue* _tmp39_;
	GearyImapDBFolder* _tmp40_;
	GearyImapFolderSession* _tmp41_;
	GearyImapFolder* _tmp42_;
	GearyImapFolder* _tmp43_;
	GearyImapFolderProperties* _tmp44_;
	GearyImapFolderProperties* _tmp45_;
	GError* _vala2_err;
	GearyImapEngineGenericAccount* _tmp46_;
	GearyImapFolderSession* _tmp47_;
	GError* _tmp48_;
	GError* _tmp49_;
	GearyImapFolderSession* _tmp50_;
	GearyImapFolderSession* _tmp51_;
	GearyAggregatedFolderProperties* _tmp52_;
	GearyImapFolderSession* _tmp53_;
	GearyImapFolder* _tmp54_;
	GearyImapFolder* _tmp55_;
	GearyImapFolderProperties* _tmp56_;
	GearyImapFolderProperties* _tmp57_;
	GearyImapFolderSession* _tmp58_;
	GearyImapFolderSession* _tmp59_;
	GearyImapFolderSession* _tmp60_;
	GearyImapFolder* _tmp61_;
	GearyImapFolder* _tmp62_;
	GearyImapFolderProperties* _tmp63_;
	GearyImapFolderProperties* _tmp64_;
	gint _tmp65_;
	gint _tmp66_;
	GearyTimeoutManager* _tmp67_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderContainsIdentifiersData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GeeCollection* ids;
	GCancellable* cancellable;
	GeeCollection* result;
	GeeCollection* _tmp0_;
	GearyImapDBFolder* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GError* _inner_error0_;
};

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

struct _GearyImapEngineSendReplayOperationClass {
	GearyImapEngineReplayOperationClass parent_class;
};

struct _GearyImapEngineAbstractListEmail {
	GearyImapEngineSendReplayOperation parent_instance;
	GeeList* accumulator;
	GearyImapEngineMinimalFolder* owner;
	GearyEmailField required_fields;
	GCancellable* cancellable;
	GearyFolderListFlags flags;
	GearyImapEngineAbstractListEmailPrivate * priv;
};

struct _GearyImapEngineAbstractListEmailClass {
	GearyImapEngineSendReplayOperationClass parent_class;
};

struct _GearyImapEngineMinimalFolderListEmailByIdAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyEmailIdentifier* initial_id;
	gint count;
	GearyEmailField required_fields;
	GearyFolderListFlags flags;
	GCancellable* cancellable;
	GeeList* result;
	GearyImapEngineListEmailByID* op;
	GearyImapEngineListEmailByID* _tmp0_;
	GearyImapEngineReplayQueue* _tmp1_;
	GearyImapEngineListEmailByID* _tmp2_;
	GearyImapEngineListEmailByID* _tmp3_;
	GeeList* _tmp4_;
	GearyImapEngineListEmailByID* _tmp5_;
	GeeList* _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	GearyImapEngineListEmailByID* _tmp9_;
	GeeList* _tmp10_;
	GeeList* _tmp11_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GeeCollection* ids;
	GearyEmailField required_fields;
	GearyFolderListFlags flags;
	GCancellable* cancellable;
	GeeList* result;
	gint _tmp0_;
	gint _tmp1_;
	GearyImapEngineListEmailBySparseID* op;
	GearyImapEngineListEmailBySparseID* _tmp2_;
	GearyImapEngineReplayQueue* _tmp3_;
	GearyImapEngineListEmailBySparseID* _tmp4_;
	GearyImapEngineListEmailBySparseID* _tmp5_;
	GeeList* _tmp6_;
	GearyImapEngineListEmailBySparseID* _tmp7_;
	GeeList* _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	GearyImapEngineListEmailBySparseID* _tmp11_;
	GeeList* _tmp12_;
	GeeList* _tmp13_;
	GError* _inner_error0_;
};

struct _GearyImapEngineFetchEmail {
	GearyImapEngineSendReplayOperation parent_instance;
	GearyEmail* email;
	GearyImapEngineFetchEmailPrivate * priv;
};

struct _GearyImapEngineFetchEmailClass {
	GearyImapEngineSendReplayOperationClass parent_class;
};

struct _GearyImapEngineMinimalFolderFetchEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyEmailIdentifier* id;
	GearyEmailField required_fields;
	GearyFolderListFlags flags;
	GCancellable* cancellable;
	GearyEmail* result;
	GearyImapEngineFetchEmail* op;
	GearyImapEngineFetchEmail* _tmp0_;
	GearyImapEngineReplayQueue* _tmp1_;
	GearyImapEngineFetchEmail* _tmp2_;
	GearyImapEngineFetchEmail* _tmp3_;
	GearyImapEngineFetchEmail* _tmp4_;
	GearyEmail* _tmp5_;
	GearyEmail* _tmp6_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderExpungeEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GeeCollection* to_expunge;
	GCancellable* cancellable;
	GearyImapEngineRemoveEmail* remove;
	GearyImapEngineRemoveEmail* _tmp0_;
	GearyImapEngineReplayQueue* _tmp1_;
	GearyImapEngineRemoveEmail* _tmp2_;
	GearyImapEngineRemoveEmail* _tmp3_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderExpungeAllAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GCancellable* cancellable;
	GearyImapEngineEmptyFolder* op;
	GearyImapEngineEmptyFolder* _tmp0_;
	GearyImapEngineReplayQueue* _tmp1_;
	GearyImapEngineEmptyFolder* _tmp2_;
	GearyImapEngineEmptyFolder* _tmp3_;
	GearyImapEngineReplayQueue* _tmp4_;
	GearyImapEngineGenericAccount* _tmp5_;
	GearyImapDBAccount* _tmp6_;
	GearyImapDBAccount* _tmp7_;
	GearyImapDBDatabase* _tmp8_;
	GearyImapDBDatabase* _tmp9_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderMarkEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GeeCollection* to_mark;
	GearyEmailFlags* flags_to_add;
	GearyEmailFlags* flags_to_remove;
	GCancellable* cancellable;
	GearyImapEngineMarkEmail* mark;
	GearyImapEngineMarkEmail* _tmp0_;
	GearyImapEngineReplayQueue* _tmp1_;
	GearyImapEngineMarkEmail* _tmp2_;
	GearyImapEngineMarkEmail* _tmp3_;
	GearyAccount* _tmp4_;
	GearyAccount* _tmp5_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderCopyEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GeeCollection* to_copy;
	GearyFolderPath* destination;
	GCancellable* cancellable;
	GearyFolder* target;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyFolder* _tmp1_;
	GeeSet* _tmp2_;
	GeeSet* _tmp3_;
	GearyImapEngineGenericAccount* _tmp4_;
	GearyFolder* _tmp5_;
	GError* _inner_error0_;
};

struct _GearyImapEngineCopyEmail {
	GearyImapEngineSendReplayOperation parent_instance;
	GeeSet* destination_uids;
	GearyImapEngineCopyEmailPrivate * priv;
};

struct _GearyImapEngineCopyEmailClass {
	GearyImapEngineSendReplayOperationClass parent_class;
};

struct _GearyImapEngineMinimalFolderCopyEmailUidsAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GeeCollection* to_copy;
	GearyFolderPath* destination;
	GCancellable* cancellable;
	GeeSet* result;
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyImapEngineCopyEmail* copy;
	GearyIterable* _tmp2_;
	GearyIterable* _tmp3_;
	GeeArrayList* _tmp4_;
	GeeList* _tmp5_;
	GearyImapEngineCopyEmail* _tmp6_;
	GearyImapEngineCopyEmail* _tmp7_;
	GearyImapEngineReplayQueue* _tmp8_;
	GearyImapEngineCopyEmail* _tmp9_;
	GearyImapEngineCopyEmail* _tmp10_;
	GeeSet* _tmp11_;
	GearyImapEngineCopyEmail* _tmp12_;
	GeeSet* _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	GearyImapEngineCopyEmail* _tmp16_;
	GeeSet* _tmp17_;
	GeeSet* _tmp18_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMoveEmailPrepare {
	GearyImapEngineSendReplayOperation parent_instance;
	GeeSet* prepared_for_move;
	GearyImapEngineMoveEmailPreparePrivate * priv;
};

struct _GearyImapEngineMoveEmailPrepareClass {
	GearyImapEngineSendReplayOperationClass parent_class;
};

struct _GearyImapEngineMinimalFolderMoveEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GeeCollection* to_move;
	GearyFolderPath* destination;
	GCancellable* cancellable;
	GearyRevokable* result;
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyImapEngineMoveEmailPrepare* prepare;
	GearyImapEngineMoveEmailPrepare* _tmp2_;
	GearyImapEngineReplayQueue* _tmp3_;
	GearyImapEngineMoveEmailPrepare* _tmp4_;
	GearyImapEngineMoveEmailPrepare* _tmp5_;
	gboolean _tmp6_;
	GearyImapEngineMoveEmailPrepare* _tmp7_;
	GeeSet* _tmp8_;
	GearyImapEngineMoveEmailPrepare* _tmp9_;
	GeeSet* _tmp10_;
	gint _tmp11_;
	gint _tmp12_;
	GearyFolder* target;
	GearyImapEngineGenericAccount* _tmp13_;
	GearyFolder* _tmp14_;
	GearyImapEngineGenericAccount* _tmp15_;
	GearyFolder* _tmp16_;
	GearyImapEngineMoveEmailPrepare* _tmp17_;
	GeeSet* _tmp18_;
	GearyImapEngineRevokableMove* _tmp19_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderExecOpAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyImapEngineReplayOperation* op;
	GCancellable* cancellable;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderFindEarliestEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GDateTime* datetime;
	GearyEmailIdentifier* before_id;
	GCancellable* cancellable;
	GearyEmail* result;
	GearyImapSearchCriteria* criteria;
	GearyImapSearchCriteria* _tmp0_;
	GearyImapInternalDate* _tmp1_;
	GearyImapInternalDate* _tmp2_;
	GearyImapSearchCriteria* _tmp3_;
	GearyImapSearchCriterion* _tmp4_;
	GearyImapSearchCriterion* _tmp5_;
	GearyImapUID* before_uid;
	GearyImapDBFolder* _tmp6_;
	GearyImapUID* _tmp7_;
	GearyImapUID* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	GError* _tmp13_;
	GError* _tmp14_;
	GearyImapSearchCriteria* _tmp15_;
	GearyImapUID* _tmp16_;
	GearyImapUID* _tmp17_;
	GearyImapUID* _tmp18_;
	GearyImapUID* _tmp19_;
	GearyImapUID* _tmp20_;
	GearyImapMessageSet* _tmp21_;
	GearyImapMessageSet* _tmp22_;
	GearyImapSearchCriterion* _tmp23_;
	GearyImapSearchCriterion* _tmp24_;
	GearyImapEngineServerSearchEmail* op;
	GearyImapSearchCriteria* _tmp25_;
	GearyImapEngineServerSearchEmail* _tmp26_;
	GearyImapEngineReplayQueue* _tmp27_;
	GearyImapEngineServerSearchEmail* _tmp28_;
	GearyImapEngineServerSearchEmail* _tmp29_;
	GearyEmail* earliest;
	GearyImapDBEmailIdentifier* earliest_id;
	GeeList* _email_list;
	GearyImapEngineServerSearchEmail* _tmp30_;
	GeeList* _tmp31_;
	gint _email_size;
	GeeList* _tmp32_;
	gint _tmp33_;
	gint _tmp34_;
	gint _email_index;
	gint _tmp35_;
	gint _tmp36_;
	GearyEmail* email;
	GeeList* _tmp37_;
	gpointer _tmp38_;
	GearyImapDBEmailIdentifier* email_id;
	GearyEmail* _tmp39_;
	GearyEmailIdentifier* _tmp40_;
	GearyEmailIdentifier* _tmp41_;
	GearyImapDBEmailIdentifier* _tmp42_;
	gboolean _tmp43_;
	GearyImapDBEmailIdentifier* _tmp44_;
	GearyImapDBEmailIdentifier* _tmp45_;
	GearyImapUID* _tmp46_;
	GearyImapUID* _tmp47_;
	GearyImapDBEmailIdentifier* _tmp48_;
	GearyImapUID* _tmp49_;
	GearyImapUID* _tmp50_;
	GearyEmail* _tmp51_;
	GearyEmail* _tmp52_;
	GearyImapDBEmailIdentifier* _tmp53_;
	GearyImapDBEmailIdentifier* _tmp54_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderCreateEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GearyRFC822Message* rfc822;
	GearyEmailFlags* flags;
	GDateTime* date_received;
	GCancellable* cancellable;
	GearyEmailIdentifier* result;
	GearyImapEngineCreateEmail* op;
	GearyImapEngineCreateEmail* _tmp0_;
	GearyImapEngineReplayQueue* _tmp1_;
	GearyImapEngineCreateEmail* _tmp2_;
	GearyImapEngineCreateEmail* _tmp3_;
	GearyImapEngineGenericAccount* _tmp4_;
	GearyImapEngineCreateEmail* _tmp5_;
	GearyEmailIdentifier* _tmp6_;
	GearyEmailIdentifier* _tmp7_;
	GearyImapEngineCreateEmail* _tmp8_;
	GearyEmailIdentifier* _tmp9_;
	GearyEmailIdentifier* _tmp10_;
	GeeList* _tmp11_;
	GeeList* _tmp12_;
	GearyImapEngineCreateEmail* _tmp13_;
	GearyEmailIdentifier* _tmp14_;
	GearyEmailIdentifier* _tmp15_;
	GearyEmailIdentifier* _tmp16_;
	GError* _inner_error0_;
};

struct _GearyImapEngineMinimalFolderUpdateFlagsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineMinimalFolder* self;
	GCancellable* cancellable;
	gint chunk_size;
	GearyEmailIdentifier* lowest;
	GeeList* list_local;
	GearyEmailIdentifier* _tmp0_;
	GeeList* _tmp1_;
	gboolean _tmp2_;
	GeeList* _tmp3_;
	GeeList* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	GeeList* _tmp7_;
	GeeSortedSet* _tmp8_;
	GeeSortedSet* _tmp9_;
	gpointer _tmp10_;
	GearyEmail* _tmp11_;
	GearyEmailIdentifier* _tmp12_;
	GearyEmailIdentifier* _tmp13_;
	GearyEmailIdentifier* _tmp14_;
	GeeHashMap* local_map;
	GeeHashMap* _tmp15_;
	GeeList* _e_list;
	GeeList* _tmp16_;
	gint _e_size;
	GeeList* _tmp17_;
	gint _tmp18_;
	gint _tmp19_;
	gint _e_index;
	gint _tmp20_;
	gint _tmp21_;
	GearyEmail* e;
	GeeList* _tmp22_;
	gpointer _tmp23_;
	GeeHashMap* _tmp24_;
	GearyEmail* _tmp25_;
	GearyEmailIdentifier* _tmp26_;
	GearyEmailIdentifier* _tmp27_;
	GearyEmail* _tmp28_;
	GearyEmailFlags* _tmp29_;
	GearyEmailFlags* _tmp30_;
	GeeHashMap* _tmp31_;
	GeeSet* _tmp32_;
	GeeSet* _tmp33_;
	GeeSet* _tmp34_;
	gint _tmp35_;
	gint _tmp36_;
	GeeList* list_remote;
	GeeHashMap* _tmp37_;
	GeeSet* _tmp38_;
	GeeSet* _tmp39_;
	GeeSet* _tmp40_;
	GeeList* _tmp41_;
	GeeList* _tmp42_;
	gboolean _tmp43_;
	GeeList* _tmp44_;
	GeeList* _tmp45_;
	gboolean _tmp46_;
	gboolean _tmp47_;
	GeeHashMap* changed_map;
	GeeHashMap* _tmp48_;
	GeeList* _vala1__e_list;
	GeeList* _tmp49_;
	gint _vala1__e_size;
	GeeList* _tmp50_;
	gint _tmp51_;
	gint _tmp52_;
	gint _vala1__e_index;
	gint _tmp53_;
	gint _tmp54_;
	GearyEmail* _vala1_e;
	GeeList* _tmp55_;
	gpointer _tmp56_;
	GeeHashMap* _tmp57_;
	GearyEmail* _tmp58_;
	GearyEmailIdentifier* _tmp59_;
	GearyEmailIdentifier* _tmp60_;
	GeeHashMap* _tmp61_;
	GearyEmail* _tmp62_;
	GearyEmailIdentifier* _tmp63_;
	GearyEmailIdentifier* _tmp64_;
	gpointer _tmp65_;
	GearyEmailFlags* _tmp66_;
	GearyEmail* _tmp67_;
	GearyEmailFlags* _tmp68_;
	GearyEmailFlags* _tmp69_;
	gboolean _tmp70_;
	GeeHashMap* _tmp71_;
	GearyEmail* _tmp72_;
	GearyEmailIdentifier* _tmp73_;
	GearyEmailIdentifier* _tmp74_;
	GearyEmail* _tmp75_;
	GearyEmailFlags* _tmp76_;
	GearyEmailFlags* _tmp77_;
	gboolean _tmp78_;
	GeeHashMap* _tmp79_;
	gint _tmp80_;
	gint _tmp81_;
	GeeHashMap* _tmp82_;
	GError* _inner_error0_;
};

struct _Block101Data {
	int _ref_count_;
	GearyImapEngineMinimalFolder* self;
	gboolean is_error;
};

static gint GearyImapEngineMinimalFolder_private_offset;
static gpointer geary_imap_engine_minimal_folder_parent_class = NULL;
static GearyFolderSupportCopyIface * geary_imap_engine_minimal_folder_geary_folder_support_copy_parent_iface = NULL;
static GearyFolderSupportMarkIface * geary_imap_engine_minimal_folder_geary_folder_support_mark_parent_iface = NULL;
static GearyFolderSupportMoveIface * geary_imap_engine_minimal_folder_geary_folder_support_move_parent_iface = NULL;

VALA_EXTERN GType geary_imap_engine_minimal_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_replay_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_db_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_replay_queue_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_contact_harvester_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_generic_account_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_aggregated_folder_properties_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_email_prefetcher_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_folder_session_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_engine_minimal_folder_notify_closing (GearyImapEngineMinimalFolder* self,
                                                      GeeList* final_ops);
VALA_EXTERN void geary_imap_engine_minimal_folder_mark_email_async (GearyImapEngineMinimalFolder* self,
                                                        GeeCollection* to_mark,
                                                        GearyEmailFlags* flags_to_add,
                                                        GearyEmailFlags* flags_to_remove,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_minimal_folder_mark_email_finish (GearyImapEngineMinimalFolder* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
VALA_EXTERN void geary_imap_engine_minimal_folder_copy_email_async (GearyImapEngineMinimalFolder* self,
                                                        GeeCollection* to_copy,
                                                        GearyFolderPath* destination,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_minimal_folder_copy_email_finish (GearyImapEngineMinimalFolder* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
VALA_EXTERN void geary_imap_engine_minimal_folder_move_email_async (GearyImapEngineMinimalFolder* self,
                                                        GeeCollection* to_move,
                                                        GearyFolderPath* destination,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
VALA_EXTERN GearyRevokable* geary_imap_engine_minimal_folder_move_email_finish (GearyImapEngineMinimalFolder* self,
                                                                    GAsyncResult* _res_,
                                                                    GError** error);
VALA_EXTERN void geary_imap_engine_minimal_folder_notify_marked_email_removed (GearyImapEngineMinimalFolder* self,
                                                                   GeeCollection* removed);
VALA_EXTERN GearyImapDBFolder* geary_imap_engine_minimal_folder_get_local_folder (GearyImapEngineMinimalFolder* self);
VALA_EXTERN GearyFolderPath* geary_imap_db_folder_get_path (GearyImapDBFolder* self);
static void geary_imap_engine_minimal_folder_set_local_folder (GearyImapEngineMinimalFolder* self,
                                                        GearyImapDBFolder* value);
VALA_EXTERN GearyImapEngineReplayQueue* geary_imap_engine_minimal_folder_get_replay_queue (GearyImapEngineMinimalFolder* self);
static void geary_imap_engine_minimal_folder_set_replay_queue (GearyImapEngineMinimalFolder* self,
                                                        GearyImapEngineReplayQueue* value);
VALA_EXTERN GearyContactHarvester* geary_imap_engine_minimal_folder_get_harvester (GearyImapEngineMinimalFolder* self);
static void geary_imap_engine_minimal_folder_set_harvester (GearyImapEngineMinimalFolder* self,
                                                     GearyContactHarvester* value);
VALA_EXTERN GearyAggregatedFolderProperties* geary_aggregated_folder_properties_new (gboolean is_local_only,
                                                                         gboolean is_virtual);
VALA_EXTERN GearyAggregatedFolderProperties* geary_aggregated_folder_properties_construct (GType object_type,
                                                                               gboolean is_local_only,
                                                                               gboolean is_virtual);
VALA_EXTERN GearyImapEngineMinimalFolder* geary_imap_engine_minimal_folder_new (GearyImapEngineGenericAccount* account,
                                                                    GearyImapDBFolder* local_folder,
                                                                    GearyFolderSpecialUse use);
VALA_EXTERN GearyImapEngineMinimalFolder* geary_imap_engine_minimal_folder_construct (GType object_type,
                                                                          GearyImapEngineGenericAccount* account,
                                                                          GearyImapDBFolder* local_folder,
                                                                          GearyFolderSpecialUse use);
static void geary_imap_engine_minimal_folder_on_email_complete (GearyImapEngineMinimalFolder* self,
                                                         GeeCollection* email_ids);
static void _geary_imap_engine_minimal_folder_on_email_complete_geary_imap_db_folder_email_complete (GearyImapDBFolder* _sender,
                                                                                              GeeCollection* email_ids,
                                                                                              gpointer self);
VALA_EXTERN void geary_aggregated_folder_properties_add (GearyAggregatedFolderProperties* self,
                                             GearyFolderProperties* child);
VALA_EXTERN GearyImapFolderProperties* geary_imap_db_folder_get_properties (GearyImapDBFolder* self);
VALA_EXTERN GearyImapEngineEmailPrefetcher* geary_imap_engine_email_prefetcher_new (GearyImapEngineMinimalFolder* folder,
                                                                        gint start_delay_sec);
VALA_EXTERN GearyImapEngineEmailPrefetcher* geary_imap_engine_email_prefetcher_construct (GType object_type,
                                                                              GearyImapEngineMinimalFolder* folder,
                                                                              gint start_delay_sec);
static void geary_imap_engine_minimal_folder_update_harvester (GearyImapEngineMinimalFolder* self);
static void __lambda115_ (GearyImapEngineMinimalFolder* self);
static void geary_imap_engine_minimal_folder_open_remote_session (GearyImapEngineMinimalFolder* self,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
static void geary_imap_engine_minimal_folder_open_remote_session_finish (GearyImapEngineMinimalFolder* self,
                                                                  GAsyncResult* _res_);
static void ___lambda115__geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                       gpointer self);
static void geary_imap_engine_minimal_folder_on_update_flags (GearyImapEngineMinimalFolder* self);
static void _geary_imap_engine_minimal_folder_on_update_flags_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                           gpointer self);
static void geary_imap_engine_minimal_folder_on_refresh_unseen (GearyImapEngineMinimalFolder* self);
static void _geary_imap_engine_minimal_folder_on_refresh_unseen_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                             gpointer self);
static void geary_imap_engine_minimal_folder_real_notify_closing (GearyImapEngineMinimalFolder* self,
                                                           GeeList* final_ops);
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_locally_inserted (GearyImapEngineMinimalFolder* self,
                                                                            GeeCollection* ids);
VALA_EXTERN void geary_imap_engine_minimal_folder_replay_notify_email_removed (GearyImapEngineMinimalFolder* self,
                                                                   GeeCollection* ids);
VALA_EXTERN void geary_imap_engine_minimal_folder_replay_notify_email_count_changed (GearyImapEngineMinimalFolder* self,
                                                                         gint new_count,
                                                                         GearyFolderCountChangeReason reason);
VALA_EXTERN void geary_imap_engine_minimal_folder_replay_notify_email_flags_changed (GearyImapEngineMinimalFolder* self,
                                                                         GeeMap* flag_map);
static void geary_imap_engine_minimal_folder_real_set_used_as_custom (GearyFolder* base,
                                                               gboolean enabled,
                                                               GError** error);
VALA_EXTERN void geary_imap_engine_minimal_folder_set_use (GearyImapEngineMinimalFolder* self,
                                               GearyFolderSpecialUse new_use);
static GearyFolderOpenState geary_imap_engine_minimal_folder_real_get_open_state (GearyFolder* base);
static void geary_imap_engine_minimal_folder_real_open_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_open_async (GearyFolder* base,
                                                       GearyFolderOpenFlags open_flags,
                                                       GCancellable* cancellable,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_open_async_co (GearyImapEngineMinimalFolderOpenAsyncData* _data_);
static void geary_imap_engine_minimal_folder_open_async_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_);
static void geary_imap_engine_minimal_folder_open_locked (GearyImapEngineMinimalFolder* self,
                                                   GearyFolderOpenFlags open_flags,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_open_locked_finish (GearyImapEngineMinimalFolder* self,
                                                              GAsyncResult* _res_,
                                                              GError** error);
static void geary_imap_engine_minimal_folder_claim_remote_session_data_free (gpointer _data);
VALA_EXTERN void geary_imap_engine_minimal_folder_claim_remote_session (GearyImapEngineMinimalFolder* self,
                                                            GCancellable* cancellable,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
VALA_EXTERN GearyImapFolderSession* geary_imap_engine_minimal_folder_claim_remote_session_finish (GearyImapEngineMinimalFolder* self,
                                                                                      GAsyncResult* _res_,
                                                                                      GError** error);
static gboolean geary_imap_engine_minimal_folder_claim_remote_session_co (GearyImapEngineMinimalFolderClaimRemoteSessionData* _data_);
static void geary_imap_engine_minimal_folder_check_open (GearyImapEngineMinimalFolder* self,
                                                  const gchar* method,
                                                  GError** error);
static void geary_imap_engine_minimal_folder_claim_remote_session_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static void geary_imap_engine_minimal_folder_real_close_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_close_async (GearyFolder* base,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_close_async_co (GearyImapEngineMinimalFolderCloseAsyncData* _data_);
VALA_EXTERN GType geary_imap_engine_user_close_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineUserClose* geary_imap_engine_user_close_new (GearyImapEngineMinimalFolder* owner,
                                                            GCancellable* cancellable);
VALA_EXTERN GearyImapEngineUserClose* geary_imap_engine_user_close_construct (GType object_type,
                                                                  GearyImapEngineMinimalFolder* owner,
                                                                  GCancellable* cancellable);
VALA_EXTERN gboolean geary_imap_engine_replay_queue_schedule (GearyImapEngineReplayQueue* self,
                                                  GearyImapEngineReplayOperation* op);
VALA_EXTERN void geary_imap_engine_replay_operation_wait_for_ready_async (GearyImapEngineReplayOperation* self,
                                                              GCancellable* cancellable,
                                                              GAsyncReadyCallback _callback_,
                                                              gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_replay_operation_wait_for_ready_finish (GearyImapEngineReplayOperation* self,
                                                               GAsyncResult* _res_,
                                                               GError** error);
static void geary_imap_engine_minimal_folder_close_async_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
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 ;
static void geary_imap_engine_minimal_folder_real_wait_for_close_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_wait_for_close_async (GearyFolder* base,
                                                                 GCancellable* cancellable,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_wait_for_close_async_co (GearyImapEngineMinimalFolderWaitForCloseAsyncData* _data_);
static void geary_imap_engine_minimal_folder_wait_for_close_async_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static void geary_imap_engine_minimal_folder_real_synchronise_remote_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_synchronise_remote (GearyFolder* base,
                                                               GCancellable* cancellable,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_synchronise_remote_co (GearyImapEngineMinimalFolderSynchroniseRemoteData* _data_);
static void geary_imap_engine_minimal_folder_synchronise_remote_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_);
VALA_EXTERN void geary_imap_folder_session_send_noop (GearyImapFolderSession* self,
                                          GCancellable* cancellable,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN void geary_imap_folder_session_send_noop_finish (GearyImapFolderSession* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
VALA_EXTERN gboolean geary_imap_engine_is_recoverable_failure (GError* err);
static gboolean _geary_imap_engine_minimal_folder_real_synchronise_remote_co_gsource_func (gpointer self);
VALA_EXTERN void geary_imap_engine_replay_queue_flush_notifications (GearyImapEngineReplayQueue* self);
VALA_EXTERN void geary_imap_engine_replay_queue_checkpoint (GearyImapEngineReplayQueue* self,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_replay_queue_checkpoint_finish (GearyImapEngineReplayQueue* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
VALA_EXTERN GearyNonblockingCountingSemaphore* geary_imap_engine_email_prefetcher_get_active_sem (GearyImapEngineEmailPrefetcher* self);
static void geary_imap_engine_minimal_folder_detach_all_emails_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_detach_all_emails_async (GearyImapEngineMinimalFolder* self,
                                                               GCancellable* cancellable,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_);
static void geary_imap_engine_minimal_folder_detach_all_emails_finish (GearyImapEngineMinimalFolder* self,
                                                                GAsyncResult* _res_,
                                                                GError** error);
static gboolean geary_imap_engine_minimal_folder_detach_all_emails_async_co (GearyImapEngineMinimalFolderDetachAllEmailsAsyncData* _data_);
VALA_EXTERN GType geary_imap_db_folder_list_flags_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_db_folder_list_email_by_id_async (GearyImapDBFolder* self,
                                                  GearyImapDBEmailIdentifier* initial_id,
                                                  gint count,
                                                  GearyEmailField required_fields,
                                                  GearyImapDBFolderListFlags flags,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN GeeList* geary_imap_db_folder_list_email_by_id_finish (GearyImapDBFolder* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
static void geary_imap_engine_minimal_folder_detach_all_emails_async_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_);
VALA_EXTERN void geary_imap_db_folder_detach_all_emails_async (GearyImapDBFolder* self,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
VALA_EXTERN void geary_imap_db_folder_detach_all_emails_finish (GearyImapDBFolder* self,
                                                    GAsyncResult* _res_,
                                                    GError** error);
static GearyEmailIdentifier* ___lambda112_ (GearyImapEngineMinimalFolder* self,
                                     GearyEmail* email);
static gpointer ____lambda112__gee_map_func (gpointer g,
                                      gpointer self);
static void geary_imap_engine_minimal_folder_normalize_folders_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_normalize_folders (GearyImapEngineMinimalFolder* self,
                                                         GearyImapFolderSession* session,
                                                         GCancellable* cancellable,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
static void geary_imap_engine_minimal_folder_normalize_folders_finish (GearyImapEngineMinimalFolder* self,
                                                                GAsyncResult* _res_,
                                                                GError** error);
static gboolean geary_imap_engine_minimal_folder_normalize_folders_co (GearyImapEngineMinimalFolderNormalizeFoldersData* _data_);
static Block98Data* block98_data_ref (Block98Data* _data98_);
static void block98_data_unref (void * _userdata_);
VALA_EXTERN GType geary_imap_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapFolder* geary_imap_folder_session_get_folder (GearyImapFolderSession* self);
VALA_EXTERN GearyImapFolderProperties* geary_imap_folder_get_properties (GearyImapFolder* self);
static void geary_imap_engine_minimal_folder_normalize_folders_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_);
VALA_EXTERN void geary_imap_db_folder_get_earliest_id_async (GearyImapDBFolder* self,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
VALA_EXTERN GearyImapDBEmailIdentifier* geary_imap_db_folder_get_earliest_id_finish (GearyImapDBFolder* self,
                                                                         GAsyncResult* _res_,
                                                                         GError** error);
VALA_EXTERN void geary_imap_db_folder_get_latest_id_async (GearyImapDBFolder* self,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
VALA_EXTERN GearyImapDBEmailIdentifier* geary_imap_db_folder_get_latest_id_finish (GearyImapDBFolder* self,
                                                                       GAsyncResult* _res_,
                                                                       GError** error);
VALA_EXTERN void geary_imap_db_folder_get_marked_ids_async (GearyImapDBFolder* self,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN GeeSet* geary_imap_db_folder_get_marked_ids_finish (GearyImapDBFolder* self,
                                                    GAsyncResult* _res_,
                                                    GError** error);
VALA_EXTERN void geary_imap_engine_replay_queue_get_ids_to_be_remote_removed (GearyImapEngineReplayQueue* self,
                                                                  GeeCollection* ids);
VALA_EXTERN GearyImapUID* geary_imap_db_email_identifier_get_uid (GearyImapDBEmailIdentifier* self);
VALA_EXTERN void geary_imap_db_folder_list_uids_by_range_async (GearyImapDBFolder* self,
                                                    GearyImapUID* first_uid,
                                                    GearyImapUID* last_uid,
                                                    gboolean include_marked_for_removal,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
VALA_EXTERN GeeSet* geary_imap_db_folder_list_uids_by_range_finish (GearyImapDBFolder* self,
                                                        GAsyncResult* _res_,
                                                        GError** error);
VALA_EXTERN void geary_imap_folder_session_list_uids_async (GearyImapFolderSession* self,
                                                GearyImapMessageSet* msg_set,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN GeeSet* geary_imap_folder_session_list_uids_finish (GearyImapFolderSession* self,
                                                    GAsyncResult* _res_,
                                                    GError** error);
static void __lambda113_ (Block98Data* _data98_,
                   GError** error);
VALA_EXTERN gboolean geary_imap_db_email_identifier_has_uid (GearyImapDBEmailIdentifier* self);
static void ___lambda113__geary_nonblocking_concurrent_concurrent_callback (GCancellable* cancellable,
                                                                     gpointer self,
                                                                     GError** error);
VALA_EXTERN void geary_imap_folder_session_list_email_async (GearyImapFolderSession* self,
                                                 GearyImapMessageSet* msg_set,
                                                 GearyEmailField fields,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
VALA_EXTERN GeeList* geary_imap_folder_session_list_email_finish (GearyImapFolderSession* self,
                                                      GAsyncResult* _res_,
                                                      GError** error);
static Block99Data* block99_data_ref (Block99Data* _data99_);
static void block99_data_unref (void * _userdata_);
VALA_EXTERN void geary_imap_db_folder_create_or_merge_email_async (GearyImapDBFolder* self,
                                                       GeeCollection* emails,
                                                       gboolean update_totals,
                                                       GearyContactHarvester* harvester,
                                                       GCancellable* cancellable,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
VALA_EXTERN GeeMap* geary_imap_db_folder_create_or_merge_email_finish (GearyImapDBFolder* self,
                                                           GAsyncResult* _res_,
                                                           GError** error);
static void ___lambda114_ (Block99Data* _data99_,
                    GError** error);
static void ____lambda114__geary_nonblocking_concurrent_concurrent_callback (GCancellable* cancellable,
                                                                      gpointer self,
                                                                      GError** error);
VALA_EXTERN void geary_imap_db_folder_get_ids_async (GearyImapDBFolder* self,
                                         GeeCollection* uids,
                                         GearyImapDBFolderListFlags flags,
                                         GCancellable* cancellable,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN GeeSet* geary_imap_db_folder_get_ids_finish (GearyImapDBFolder* self,
                                             GAsyncResult* _res_,
                                             GError** error);
VALA_EXTERN void geary_imap_db_folder_detach_multiple_emails_async (GearyImapDBFolder* self,
                                                        GeeCollection* ids,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
VALA_EXTERN void geary_imap_db_folder_detach_multiple_emails_finish (GearyImapDBFolder* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
VALA_EXTERN void geary_imap_db_folder_clear_remove_markers_async (GearyImapDBFolder* self,
                                                      GeeCollection* exceptions,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_);
VALA_EXTERN void geary_imap_db_folder_clear_remove_markers_finish (GearyImapDBFolder* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
VALA_EXTERN void geary_imap_engine_replay_queue_notify_remote_removed_ids (GearyImapEngineReplayQueue* self,
                                                               GeeCollection* ids);
static void geary_imap_engine_minimal_folder_close_internal_data_free (gpointer _data);
VALA_EXTERN void geary_imap_engine_minimal_folder_close_internal (GearyImapEngineMinimalFolder* self,
                                                      GearyFolderCloseReason local_reason,
                                                      GearyFolderCloseReason remote_reason,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_);
VALA_EXTERN gboolean geary_imap_engine_minimal_folder_close_internal_finish (GearyImapEngineMinimalFolder* self,
                                                                 GAsyncResult* _res_);
static gboolean geary_imap_engine_minimal_folder_close_internal_co (GearyImapEngineMinimalFolderCloseInternalData* _data_);
static Block100Data* block100_data_ref (Block100Data* _data100_);
static void block100_data_unref (void * _userdata_);
static void geary_imap_engine_minimal_folder_close_internal_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static void geary_imap_engine_minimal_folder_close_internal_locked (GearyImapEngineMinimalFolder* self,
                                                             GearyFolderCloseReason local_reason,
                                                             GearyFolderCloseReason remote_reason,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static void geary_imap_engine_minimal_folder_close_internal_locked_finish (GearyImapEngineMinimalFolder* self,
                                                                    GAsyncResult* _res_);
static void ____lambda129_ (Block100Data* _data100_,
                     GObject* obj,
                     GAsyncResult* res);
static void _____lambda129__gasync_ready_callback (GObject* source_object,
                                            GAsyncResult* res,
                                            gpointer self);
static void geary_imap_engine_minimal_folder_close_remote_session_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_close_remote_session (GearyImapEngineMinimalFolder* self,
                                                            GearyFolderCloseReason remote_reason,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
static void geary_imap_engine_minimal_folder_close_remote_session_finish (GearyImapEngineMinimalFolder* self,
                                                                   GAsyncResult* _res_);
static gboolean geary_imap_engine_minimal_folder_close_remote_session_co (GearyImapEngineMinimalFolderCloseRemoteSessionData* _data_);
static inline void geary_imap_engine_minimal_folder_notify_remote_waiters (GearyImapEngineMinimalFolder* self,
                                                             gboolean successful);
static void geary_imap_engine_minimal_folder_on_remote_appended (GearyImapEngineMinimalFolder* self,
                                                          GearyImapFolderSession* session,
                                                          gint appended);
static void _geary_imap_engine_minimal_folder_on_remote_appended_geary_imap_folder_session_appended (GearyImapFolderSession* _sender,
                                                                                              gint count,
                                                                                              gpointer self);
static void geary_imap_engine_minimal_folder_on_remote_updated (GearyImapEngineMinimalFolder* self,
                                                         GearyImapFolderSession* session,
                                                         GearyImapSequenceNumber* position,
                                                         GearyImapFetchedData* data);
static void _geary_imap_engine_minimal_folder_on_remote_updated_geary_imap_folder_session_updated (GearyImapFolderSession* _sender,
                                                                                            GearyImapSequenceNumber* pos,
                                                                                            GearyImapFetchedData* data,
                                                                                            gpointer self);
static void geary_imap_engine_minimal_folder_on_remote_removed (GearyImapEngineMinimalFolder* self,
                                                         GearyImapFolderSession* session,
                                                         GearyImapSequenceNumber* position);
static void _geary_imap_engine_minimal_folder_on_remote_removed_geary_imap_folder_session_removed (GearyImapFolderSession* _sender,
                                                                                            GearyImapSequenceNumber* pos,
                                                                                            gpointer self);
static void geary_imap_engine_minimal_folder_on_remote_disconnected (GearyImapEngineMinimalFolder* self,
                                                              GearyImapClientSessionDisconnectReason reason);
static void _geary_imap_engine_minimal_folder_on_remote_disconnected_geary_imap_session_object_disconnected (GearyImapSessionObject* _sender,
                                                                                                      GearyImapClientSessionDisconnectReason reason,
                                                                                                      gpointer self);
VALA_EXTERN gboolean geary_aggregated_folder_properties_remove (GearyAggregatedFolderProperties* self,
                                                    GearyFolderProperties* child);
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_minimal_folder_close_remote_session_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static void geary_imap_engine_minimal_folder_open_locked_data_free (gpointer _data);
static gboolean geary_imap_engine_minimal_folder_open_locked_co (GearyImapEngineMinimalFolderOpenLockedData* _data_);
VALA_EXTERN GearyImapEngineReplayQueue* geary_imap_engine_replay_queue_new (GearyImapEngineMinimalFolder* owner);
VALA_EXTERN GearyImapEngineReplayQueue* geary_imap_engine_replay_queue_construct (GType object_type,
                                                                      GearyImapEngineMinimalFolder* owner);
VALA_EXTERN void geary_imap_engine_email_prefetcher_open (GearyImapEngineEmailPrefetcher* self);
VALA_EXTERN GearyImapClientService* geary_imap_engine_generic_account_get_imap (GearyImapEngineGenericAccount* self);
static void geary_imap_engine_minimal_folder_on_remote_status_notify (GearyImapEngineMinimalFolder* self);
static void _geary_imap_engine_minimal_folder_on_remote_status_notify_g_object_notify (GObject* _sender,
                                                                                GParamSpec* pspec,
                                                                                gpointer self);
static void geary_imap_engine_minimal_folder_force_close_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_force_close (GearyImapEngineMinimalFolder* self,
                                                   GearyFolderCloseReason local_reason,
                                                   GearyFolderCloseReason remote_reason,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static void geary_imap_engine_minimal_folder_force_close_finish (GearyImapEngineMinimalFolder* self,
                                                          GAsyncResult* _res_);
static gboolean geary_imap_engine_minimal_folder_force_close_co (GearyImapEngineMinimalFolderForceCloseData* _data_);
static void geary_imap_engine_minimal_folder_force_close_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void geary_imap_engine_minimal_folder_close_internal_locked_data_free (gpointer _data);
static gboolean geary_imap_engine_minimal_folder_close_internal_locked_co (GearyImapEngineMinimalFolderCloseInternalLockedData* _data_);
VALA_EXTERN void geary_imap_engine_email_prefetcher_close (GearyImapEngineEmailPrefetcher* self);
VALA_EXTERN void geary_imap_engine_replay_queue_close_async (GearyImapEngineReplayQueue* self,
                                                 gboolean flush_pending,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_replay_queue_close_finish (GearyImapEngineReplayQueue* self,
                                                  GAsyncResult* _res_,
                                                  GError** error);
static void geary_imap_engine_minimal_folder_close_internal_locked_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_);
static void geary_imap_engine_minimal_folder_open_remote_session_data_free (gpointer _data);
static gboolean geary_imap_engine_minimal_folder_open_remote_session_co (GearyImapEngineMinimalFolderOpenRemoteSessionData* _data_);
static void geary_imap_engine_minimal_folder_open_remote_session_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_);
static void geary_imap_engine_minimal_folder_open_remote_session_locked (GearyImapEngineMinimalFolder* self,
                                                                  GCancellable* cancellable,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_);
static void geary_imap_engine_minimal_folder_open_remote_session_locked_finish (GearyImapEngineMinimalFolder* self,
                                                                         GAsyncResult* _res_);
static void geary_imap_engine_minimal_folder_open_remote_session_locked_data_free (gpointer _data);
static gboolean geary_imap_engine_minimal_folder_open_remote_session_locked_co (GearyImapEngineMinimalFolderOpenRemoteSessionLockedData* _data_);
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_minimal_folder_open_remote_session_locked_ready (GObject* source_object,
                                                                        GAsyncResult* _res_,
                                                                        gpointer _user_data_);
VALA_EXTERN gboolean geary_imap_engine_is_remote_error (GError* err);
VALA_EXTERN gint geary_imap_engine_replay_queue_pending_unread_change (GearyImapEngineReplayQueue* self);
VALA_EXTERN void geary_imap_db_folder_update_folder_select_examine (GearyImapDBFolder* self,
                                                        GearyImapFolderProperties* remote_properties,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
VALA_EXTERN void geary_imap_db_folder_update_folder_select_examine_finish (GearyImapDBFolder* self,
                                                               GAsyncResult* _res_,
                                                               GError** error);
VALA_EXTERN void geary_imap_folder_session_enable_idle (GearyImapFolderSession* self,
                                            GCancellable* cancellable,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
VALA_EXTERN void geary_imap_folder_session_enable_idle_finish (GearyImapFolderSession* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
VALA_EXTERN GType geary_imap_engine_replay_append_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineReplayAppend* geary_imap_engine_replay_append_new (GearyImapEngineMinimalFolder* owner,
                                                                  gint remote_count,
                                                                  GeeList* positions,
                                                                  GCancellable* cancellable);
VALA_EXTERN GearyImapEngineReplayAppend* geary_imap_engine_replay_append_construct (GType object_type,
                                                                        GearyImapEngineMinimalFolder* owner,
                                                                        gint remote_count,
                                                                        GeeList* positions,
                                                                        GCancellable* cancellable);
static void _geary_folder_notify_email_appended_geary_imap_engine_replay_append_email_appended (GearyImapEngineReplayAppend* _sender,
                                                                                         GeeCollection* ids,
                                                                                         gpointer self);
static void _geary_folder_notify_email_locally_appended_geary_imap_engine_replay_append_email_locally_appended (GearyImapEngineReplayAppend* _sender,
                                                                                                         GeeCollection* ids,
                                                                                                         gpointer self);
static void _geary_folder_notify_email_count_changed_geary_imap_engine_replay_append_email_count_changed (GearyImapEngineReplayAppend* _sender,
                                                                                                   gint count,
                                                                                                   GearyFolderCountChangeReason reason,
                                                                                                   gpointer self);
VALA_EXTERN gboolean geary_imap_engine_replay_queue_schedule_server_notification (GearyImapEngineReplayQueue* self,
                                                                      GearyImapEngineReplayOperation* op);
VALA_EXTERN GearyImapEngineReplayUpdate* geary_imap_engine_replay_update_new (GearyImapEngineMinimalFolder* owner,
                                                                  gint remote_count,
                                                                  GearyImapSequenceNumber* position,
                                                                  GearyImapFetchedData* data);
VALA_EXTERN GearyImapEngineReplayUpdate* geary_imap_engine_replay_update_construct (GType object_type,
                                                                        GearyImapEngineMinimalFolder* owner,
                                                                        gint remote_count,
                                                                        GearyImapSequenceNumber* position,
                                                                        GearyImapFetchedData* data);
VALA_EXTERN GType geary_imap_engine_replay_update_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_engine_replay_queue_notify_remote_removed_position (GearyImapEngineReplayQueue* self,
                                                                    GearyImapSequenceNumber* pos);
VALA_EXTERN GType geary_imap_engine_replay_removal_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineReplayRemoval* geary_imap_engine_replay_removal_new (GearyImapEngineMinimalFolder* owner,
                                                                    gint remote_count,
                                                                    GearyImapSequenceNumber* position);
VALA_EXTERN GearyImapEngineReplayRemoval* geary_imap_engine_replay_removal_construct (GType object_type,
                                                                          GearyImapEngineMinimalFolder* owner,
                                                                          gint remote_count,
                                                                          GearyImapSequenceNumber* position);
static void _geary_folder_notify_email_removed_geary_imap_engine_replay_removal_email_removed (GearyImapEngineReplayRemoval* _sender,
                                                                                        GeeCollection* ids,
                                                                                        gpointer self);
static void _geary_imap_engine_minimal_folder_notify_marked_email_removed_geary_imap_engine_replay_removal_marked_email_removed (GearyImapEngineReplayRemoval* _sender,
                                                                                                                          GeeCollection* ids,
                                                                                                                          gpointer self);
static void _geary_folder_notify_email_count_changed_geary_imap_engine_replay_removal_email_count_changed (GearyImapEngineReplayRemoval* _sender,
                                                                                                    gint count,
                                                                                                    GearyFolderCountChangeReason reason,
                                                                                                    gpointer self);
static void geary_imap_engine_minimal_folder_real_contains_identifiers_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_contains_identifiers (GearyFolder* base,
                                                                 GeeCollection* ids,
                                                                 GCancellable* cancellable,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_contains_identifiers_co (GearyImapEngineMinimalFolderContainsIdentifiersData* _data_);
VALA_EXTERN void geary_imap_db_folder_contains_identifiers (GearyImapDBFolder* self,
                                                GeeCollection* ids,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN GeeCollection* geary_imap_db_folder_contains_identifiers_finish (GearyImapDBFolder* self,
                                                                 GAsyncResult* _res_,
                                                                 GError** error);
static void geary_imap_engine_minimal_folder_contains_identifiers_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static void geary_imap_engine_minimal_folder_real_list_email_by_id_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_list_email_by_id_async (GearyFolder* base,
                                                                   GearyEmailIdentifier* initial_id,
                                                                   gint count,
                                                                   GearyEmailField required_fields,
                                                                   GearyFolderListFlags flags,
                                                                   GCancellable* cancellable,
                                                                   GAsyncReadyCallback _callback_,
                                                                   gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_list_email_by_id_async_co (GearyImapEngineMinimalFolderListEmailByIdAsyncData* _data_);
static void geary_imap_engine_minimal_folder_check_flags (GearyImapEngineMinimalFolder* self,
                                                   const gchar* method,
                                                   GearyFolderListFlags flags,
                                                   GError** error);
static void geary_imap_engine_minimal_folder_check_id (GearyImapEngineMinimalFolder* self,
                                                const gchar* method,
                                                GearyEmailIdentifier* id,
                                                GError** error);
VALA_EXTERN GType geary_imap_engine_send_replay_operation_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_abstract_list_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_list_email_by_id_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineListEmailByID* geary_imap_engine_list_email_by_id_new (GearyImapEngineMinimalFolder* owner,
                                                                      GearyImapDBEmailIdentifier* initial_id,
                                                                      gint count,
                                                                      GearyEmailField required_fields,
                                                                      GearyFolderListFlags flags,
                                                                      GCancellable* cancellable);
VALA_EXTERN GearyImapEngineListEmailByID* geary_imap_engine_list_email_by_id_construct (GType object_type,
                                                                            GearyImapEngineMinimalFolder* owner,
                                                                            GearyImapDBEmailIdentifier* initial_id,
                                                                            gint count,
                                                                            GearyEmailField required_fields,
                                                                            GearyFolderListFlags flags,
                                                                            GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_list_email_by_id_async_ready (GObject* source_object,
                                                                    GAsyncResult* _res_,
                                                                    gpointer _user_data_);
static void geary_imap_engine_minimal_folder_real_list_email_by_sparse_id_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_list_email_by_sparse_id_async (GearyFolder* base,
                                                                          GeeCollection* ids,
                                                                          GearyEmailField required_fields,
                                                                          GearyFolderListFlags flags,
                                                                          GCancellable* cancellable,
                                                                          GAsyncReadyCallback _callback_,
                                                                          gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_list_email_by_sparse_id_async_co (GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData* _data_);
static void geary_imap_engine_minimal_folder_check_ids (GearyImapEngineMinimalFolder* self,
                                                 const gchar* method,
                                                 GeeCollection* ids,
                                                 GError** error);
VALA_EXTERN GType geary_imap_engine_list_email_by_sparse_id_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineListEmailBySparseID* geary_imap_engine_list_email_by_sparse_id_new (GearyImapEngineMinimalFolder* owner,
                                                                                   GeeCollection* ids,
                                                                                   GearyEmailField required_fields,
                                                                                   GearyFolderListFlags flags,
                                                                                   GCancellable* cancellable);
VALA_EXTERN GearyImapEngineListEmailBySparseID* geary_imap_engine_list_email_by_sparse_id_construct (GType object_type,
                                                                                         GearyImapEngineMinimalFolder* owner,
                                                                                         GeeCollection* ids,
                                                                                         GearyEmailField required_fields,
                                                                                         GearyFolderListFlags flags,
                                                                                         GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_list_email_by_sparse_id_async_ready (GObject* source_object,
                                                                           GAsyncResult* _res_,
                                                                           gpointer _user_data_);
static void geary_imap_engine_minimal_folder_real_fetch_email_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_fetch_email_async (GearyFolder* base,
                                                              GearyEmailIdentifier* id,
                                                              GearyEmailField required_fields,
                                                              GearyFolderListFlags flags,
                                                              GCancellable* cancellable,
                                                              GAsyncReadyCallback _callback_,
                                                              gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_fetch_email_async_co (GearyImapEngineMinimalFolderFetchEmailAsyncData* _data_);
VALA_EXTERN GType geary_imap_engine_fetch_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineFetchEmail* geary_imap_engine_fetch_email_new (GearyImapEngineMinimalFolder* engine,
                                                              GearyImapDBEmailIdentifier* id,
                                                              GearyEmailField required_fields,
                                                              GearyFolderListFlags flags,
                                                              GCancellable* cancellable);
VALA_EXTERN GearyImapEngineFetchEmail* geary_imap_engine_fetch_email_construct (GType object_type,
                                                                    GearyImapEngineMinimalFolder* engine,
                                                                    GearyImapDBEmailIdentifier* id,
                                                                    GearyEmailField required_fields,
                                                                    GearyFolderListFlags flags,
                                                                    GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_fetch_email_async_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_);
static void geary_imap_engine_minimal_folder_expunge_email_async_data_free (gpointer _data);
VALA_EXTERN void geary_imap_engine_minimal_folder_expunge_email_async (GearyImapEngineMinimalFolder* self,
                                                           GeeCollection* to_expunge,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_minimal_folder_expunge_email_finish (GearyImapEngineMinimalFolder* self,
                                                            GAsyncResult* _res_,
                                                            GError** error);
static gboolean geary_imap_engine_minimal_folder_expunge_email_async_co (GearyImapEngineMinimalFolderExpungeEmailAsyncData* _data_);
VALA_EXTERN GType geary_imap_engine_remove_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineRemoveEmail* geary_imap_engine_remove_email_new (GearyImapEngineMinimalFolder* engine,
                                                                GeeCollection* to_remove,
                                                                GCancellable* cancellable);
VALA_EXTERN GearyImapEngineRemoveEmail* geary_imap_engine_remove_email_construct (GType object_type,
                                                                      GearyImapEngineMinimalFolder* engine,
                                                                      GeeCollection* to_remove,
                                                                      GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_expunge_email_async_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_);
static void geary_imap_engine_minimal_folder_expunge_all_async_data_free (gpointer _data);
VALA_EXTERN void geary_imap_engine_minimal_folder_expunge_all_async (GearyImapEngineMinimalFolder* self,
                                                         GCancellable* cancellable,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_minimal_folder_expunge_all_finish (GearyImapEngineMinimalFolder* self,
                                                          GAsyncResult* _res_,
                                                          GError** error);
static gboolean geary_imap_engine_minimal_folder_expunge_all_async_co (GearyImapEngineMinimalFolderExpungeAllAsyncData* _data_);
VALA_EXTERN GType geary_imap_engine_empty_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineEmptyFolder* geary_imap_engine_empty_folder_new (GearyImapEngineMinimalFolder* engine,
                                                                GCancellable* cancellable);
VALA_EXTERN GearyImapEngineEmptyFolder* geary_imap_engine_empty_folder_construct (GType object_type,
                                                                      GearyImapEngineMinimalFolder* engine,
                                                                      GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_expunge_all_async_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_);
VALA_EXTERN GType geary_imap_db_account_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapDBAccount* geary_imap_engine_generic_account_get_local (GearyImapEngineGenericAccount* self);
VALA_EXTERN GType geary_imap_db_database_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapDBDatabase* geary_imap_db_account_get_db (GearyImapDBAccount* self);
VALA_EXTERN GType geary_imap_db_database_garbage_collection_options_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_db_database_run_gc (GearyImapDBDatabase* self,
                                    GearyImapDBDatabaseGarbageCollectionOptions options,
                                    GeeCollection* to_pause,
                                    GCancellable* cancellable,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
VALA_EXTERN void geary_imap_db_database_run_gc_finish (GearyImapDBDatabase* self,
                                           GAsyncResult* _res_,
                                           GError** error);
static void geary_imap_engine_minimal_folder_real_mark_email_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_mark_email_async (GearyImapEngineMinimalFolder* self,
                                                             GeeCollection* to_mark,
                                                             GearyEmailFlags* flags_to_add,
                                                             GearyEmailFlags* flags_to_remove,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_mark_email_async_co (GearyImapEngineMinimalFolderMarkEmailAsyncData* _data_);
VALA_EXTERN GType geary_imap_engine_mark_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineMarkEmail* geary_imap_engine_mark_email_new (GearyImapEngineMinimalFolder* engine,
                                                            GeeCollection* to_mark,
                                                            GearyEmailFlags* flags_to_add,
                                                            GearyEmailFlags* flags_to_remove,
                                                            GCancellable* cancellable);
VALA_EXTERN GearyImapEngineMarkEmail* geary_imap_engine_mark_email_construct (GType object_type,
                                                                  GearyImapEngineMinimalFolder* engine,
                                                                  GeeCollection* to_mark,
                                                                  GearyEmailFlags* flags_to_add,
                                                                  GearyEmailFlags* flags_to_remove,
                                                                  GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_mark_email_async_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
static void geary_imap_engine_minimal_folder_real_copy_email_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_copy_email_async (GearyImapEngineMinimalFolder* self,
                                                             GeeCollection* to_copy,
                                                             GearyFolderPath* destination,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_copy_email_async_co (GearyImapEngineMinimalFolderCopyEmailAsyncData* _data_);
VALA_EXTERN void geary_imap_engine_minimal_folder_copy_email_uids_async (GearyImapEngineMinimalFolder* self,
                                                             GeeCollection* to_copy,
                                                             GearyFolderPath* destination,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
VALA_EXTERN GeeSet* geary_imap_engine_minimal_folder_copy_email_uids_finish (GearyImapEngineMinimalFolder* self,
                                                                 GAsyncResult* _res_,
                                                                 GError** error);
static void geary_imap_engine_minimal_folder_copy_email_async_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_generic_account_update_folder (GearyImapEngineGenericAccount* self,
                                                      GearyFolder* folder);
static void geary_imap_engine_minimal_folder_copy_email_uids_async_data_free (gpointer _data);
static gboolean geary_imap_engine_minimal_folder_copy_email_uids_async_co (GearyImapEngineMinimalFolderCopyEmailUidsAsyncData* _data_);
VALA_EXTERN GType geary_imap_engine_copy_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineCopyEmail* geary_imap_engine_copy_email_new (GearyImapEngineMinimalFolder* engine,
                                                            GeeList* to_copy,
                                                            GearyFolderPath* destination,
                                                            GCancellable* cancellable);
VALA_EXTERN GearyImapEngineCopyEmail* geary_imap_engine_copy_email_construct (GType object_type,
                                                                  GearyImapEngineMinimalFolder* engine,
                                                                  GeeList* to_copy,
                                                                  GearyFolderPath* destination,
                                                                  GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_copy_email_uids_async_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_);
static void geary_imap_engine_minimal_folder_real_move_email_async_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_real_move_email_async (GearyImapEngineMinimalFolder* self,
                                                             GeeCollection* to_move,
                                                             GearyFolderPath* destination,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static gboolean geary_imap_engine_minimal_folder_real_move_email_async_co (GearyImapEngineMinimalFolderMoveEmailAsyncData* _data_);
VALA_EXTERN GType geary_imap_engine_move_email_prepare_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineMoveEmailPrepare* geary_imap_engine_move_email_prepare_new (GearyImapEngineMinimalFolder* engine,
                                                                           GeeCollection* to_move,
                                                                           GCancellable* cancellable);
VALA_EXTERN GearyImapEngineMoveEmailPrepare* geary_imap_engine_move_email_prepare_construct (GType object_type,
                                                                                 GearyImapEngineMinimalFolder* engine,
                                                                                 GeeCollection* to_move,
                                                                                 GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_move_email_async_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
VALA_EXTERN GearyImapEngineRevokableMove* geary_imap_engine_revokable_move_new (GearyImapEngineGenericAccount* account,
                                                                    GearyImapEngineMinimalFolder* source,
                                                                    GearyFolder* destination,
                                                                    GeeSet* move_ids);
VALA_EXTERN GearyImapEngineRevokableMove* geary_imap_engine_revokable_move_construct (GType object_type,
                                                                          GearyImapEngineGenericAccount* account,
                                                                          GearyImapEngineMinimalFolder* source,
                                                                          GearyFolder* destination,
                                                                          GeeSet* move_ids);
VALA_EXTERN GType geary_imap_engine_revokable_move_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_engine_minimal_folder_schedule_op (GearyImapEngineMinimalFolder* self,
                                                   GearyImapEngineReplayOperation* op,
                                                   GError** error);
static void geary_imap_engine_minimal_folder_exec_op_async_data_free (gpointer _data);
VALA_EXTERN void geary_imap_engine_minimal_folder_exec_op_async (GearyImapEngineMinimalFolder* self,
                                                     GearyImapEngineReplayOperation* op,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_minimal_folder_exec_op_finish (GearyImapEngineMinimalFolder* self,
                                                      GAsyncResult* _res_,
                                                      GError** error);
static gboolean geary_imap_engine_minimal_folder_exec_op_async_co (GearyImapEngineMinimalFolderExecOpAsyncData* _data_);
static void geary_imap_engine_minimal_folder_exec_op_async_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_);
static GearyLoggingState* geary_imap_engine_minimal_folder_real_to_logging_state (GearyFolder* base);
VALA_EXTERN void geary_imap_engine_minimal_folder_refresh_unseen (GearyImapEngineMinimalFolder* self);
static void geary_imap_engine_minimal_folder_find_earliest_email_async_data_free (gpointer _data);
VALA_EXTERN void geary_imap_engine_minimal_folder_find_earliest_email_async (GearyImapEngineMinimalFolder* self,
                                                                 GDateTime* datetime,
                                                                 GearyEmailIdentifier* before_id,
                                                                 GCancellable* cancellable,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_);
VALA_EXTERN GearyEmail* geary_imap_engine_minimal_folder_find_earliest_email_finish (GearyImapEngineMinimalFolder* self,
                                                                         GAsyncResult* _res_,
                                                                         GError** error);
static gboolean geary_imap_engine_minimal_folder_find_earliest_email_async_co (GearyImapEngineMinimalFolderFindEarliestEmailAsyncData* _data_);
VALA_EXTERN void geary_imap_db_folder_get_uid_async (GearyImapDBFolder* self,
                                         GearyImapDBEmailIdentifier* id,
                                         GearyImapDBFolderListFlags flags,
                                         GCancellable* cancellable,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN GearyImapUID* geary_imap_db_folder_get_uid_finish (GearyImapDBFolder* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
static void geary_imap_engine_minimal_folder_find_earliest_email_async_ready (GObject* source_object,
                                                                       GAsyncResult* _res_,
                                                                       gpointer _user_data_);
VALA_EXTERN GType geary_imap_engine_server_search_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineServerSearchEmail* geary_imap_engine_server_search_email_new (GearyImapEngineMinimalFolder* owner,
                                                                             GearyImapSearchCriteria* criteria,
                                                                             GearyEmailField required_fields,
                                                                             GCancellable* cancellable);
VALA_EXTERN GearyImapEngineServerSearchEmail* geary_imap_engine_server_search_email_construct (GType object_type,
                                                                                   GearyImapEngineMinimalFolder* owner,
                                                                                   GearyImapSearchCriteria* criteria,
                                                                                   GearyEmailField required_fields,
                                                                                   GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_create_email_async_data_free (gpointer _data);
VALA_EXTERN void geary_imap_engine_minimal_folder_create_email_async (GearyImapEngineMinimalFolder* self,
                                                          GearyRFC822Message* rfc822,
                                                          GearyEmailFlags* flags,
                                                          GDateTime* date_received,
                                                          GCancellable* cancellable,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_);
VALA_EXTERN GearyEmailIdentifier* geary_imap_engine_minimal_folder_create_email_finish (GearyImapEngineMinimalFolder* self,
                                                                            GAsyncResult* _res_,
                                                                            GError** error);
static gboolean geary_imap_engine_minimal_folder_create_email_async_co (GearyImapEngineMinimalFolderCreateEmailAsyncData* _data_);
VALA_EXTERN GType geary_imap_engine_create_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineCreateEmail* geary_imap_engine_create_email_new (GearyImapEngineMinimalFolder* engine,
                                                                GearyRFC822Message* rfc822,
                                                                GearyEmailFlags* flags,
                                                                GDateTime* date_received,
                                                                GCancellable* cancellable);
VALA_EXTERN GearyImapEngineCreateEmail* geary_imap_engine_create_email_construct (GType object_type,
                                                                      GearyImapEngineMinimalFolder* engine,
                                                                      GearyRFC822Message* rfc822,
                                                                      GearyEmailFlags* flags,
                                                                      GDateTime* date_received,
                                                                      GCancellable* cancellable);
static void geary_imap_engine_minimal_folder_create_email_async_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_);
VALA_EXTERN GearyEmailIdentifier* geary_imap_engine_create_email_get_created_id (GearyImapEngineCreateEmail* self);
static void geary_imap_engine_minimal_folder_real_notify_marked_email_removed (GearyImapEngineMinimalFolder* self,
                                                                        GeeCollection* removed);
static void geary_imap_engine_minimal_folder_update_flags_data_free (gpointer _data);
static void geary_imap_engine_minimal_folder_update_flags (GearyImapEngineMinimalFolder* self,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
static void geary_imap_engine_minimal_folder_update_flags_finish (GearyImapEngineMinimalFolder* self,
                                                           GAsyncResult* _res_,
                                                           GError** error);
static gboolean geary_imap_engine_minimal_folder_update_flags_co (GearyImapEngineMinimalFolderUpdateFlagsData* _data_);
static void geary_imap_engine_minimal_folder_update_flags_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_);
VALA_EXTERN GearyContactHarvesterImpl* geary_contact_harvester_impl_new (GearyContactStore* store,
                                                             GearyFolderSpecialUse location,
                                                             GeeCollection* owners);
VALA_EXTERN GearyContactHarvesterImpl* geary_contact_harvester_impl_construct (GType object_type,
                                                                   GearyContactStore* store,
                                                                   GearyFolderSpecialUse location,
                                                                   GeeCollection* owners);
VALA_EXTERN GType geary_contact_harvester_impl_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_refresh_folder_unseen_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineRefreshFolderUnseen* geary_imap_engine_refresh_folder_unseen_new (GearyImapEngineMinimalFolder* folder,
                                                                                 GearyImapEngineGenericAccount* account);
VALA_EXTERN GearyImapEngineRefreshFolderUnseen* geary_imap_engine_refresh_folder_unseen_construct (GType object_type,
                                                                                       GearyImapEngineMinimalFolder* folder,
                                                                                       GearyImapEngineGenericAccount* account);
VALA_EXTERN void geary_imap_engine_generic_account_queue_operation (GearyImapEngineGenericAccount* self,
                                                        GearyImapEngineAccountOperation* op,
                                                        GError** error);
static void __lambda116_ (GearyImapEngineMinimalFolder* self,
                   GObject* obj,
                   GAsyncResult* res);
static void ___lambda116__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static Block101Data* block101_data_ref (Block101Data* _data101_);
static void block101_data_unref (void * _userdata_);
static void __lambda111_ (Block101Data* _data101_,
                   GObject* obj,
                   GAsyncResult* res);
static void ___lambda111__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static void geary_imap_engine_minimal_folder_finalize (GObject * obj);
static GType geary_imap_engine_minimal_folder_get_type_once (void);
static void _vala_geary_imap_engine_minimal_folder_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static void _vala_geary_imap_engine_minimal_folder_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec);

static inline gpointer
geary_imap_engine_minimal_folder_get_instance_private (GearyImapEngineMinimalFolder* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEngineMinimalFolder_private_offset);
}

static GearyAccount*
geary_imap_engine_minimal_folder_real_get_account (GearyFolder* base)
{
	GearyAccount* result;
	GearyImapEngineMinimalFolder* self;
	GearyImapEngineGenericAccount* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_tmp0_ = self->priv->_account;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEARY_TYPE_ACCOUNT, GearyAccount);
	return result;
}

static GearyFolderProperties*
geary_imap_engine_minimal_folder_real_get_properties (GearyFolder* base)
{
	GearyFolderProperties* result;
	GearyImapEngineMinimalFolder* self;
	GearyAggregatedFolderProperties* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_tmp0_ = self->priv->_properties;
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties);
	return result;
}

static GearyFolderPath*
geary_imap_engine_minimal_folder_real_get_path (GearyFolder* base)
{
	GearyFolderPath* result;
	GearyImapEngineMinimalFolder* self;
	GearyImapDBFolder* _tmp0_;
	GearyFolderPath* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_tmp0_ = self->priv->_local_folder;
	_tmp1_ = geary_imap_db_folder_get_path (_tmp0_);
	result = _tmp1_;
	return result;
}

static GearyFolderSpecialUse
geary_imap_engine_minimal_folder_real_get_used_as (GearyFolder* base)
{
	GearyFolderSpecialUse result;
	GearyImapEngineMinimalFolder* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	result = self->priv->_used_as;
	return result;
}

static GearyProgressMonitor*
geary_imap_engine_minimal_folder_real_get_opening_monitor (GearyFolder* base)
{
	GearyProgressMonitor* result;
	GearyImapEngineMinimalFolder* self;
	GearyProgressMonitor* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_tmp0_ = self->priv->_opening_monitor;
	result = _tmp0_;
	return result;
}

GearyImapDBFolder*
geary_imap_engine_minimal_folder_get_local_folder (GearyImapEngineMinimalFolder* self)
{
	GearyImapDBFolder* result;
	GearyImapDBFolder* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self), NULL);
	_tmp0_ = self->priv->_local_folder;
	result = _tmp0_;
	return result;
}

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

static void
geary_imap_engine_minimal_folder_set_local_folder (GearyImapEngineMinimalFolder* self,
                                                   GearyImapDBFolder* value)
{
	GearyImapDBFolder* old_value;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	old_value = geary_imap_engine_minimal_folder_get_local_folder (self);
	if (old_value != value) {
		GearyImapDBFolder* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_local_folder);
		self->priv->_local_folder = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_LOCAL_FOLDER_PROPERTY]);
	}
}

GearyImapEngineReplayQueue*
geary_imap_engine_minimal_folder_get_replay_queue (GearyImapEngineMinimalFolder* self)
{
	GearyImapEngineReplayQueue* result;
	GearyImapEngineReplayQueue* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self), NULL);
	_tmp0_ = self->priv->_replay_queue;
	result = _tmp0_;
	return result;
}

static void
geary_imap_engine_minimal_folder_set_replay_queue (GearyImapEngineMinimalFolder* self,
                                                   GearyImapEngineReplayQueue* value)
{
	GearyImapEngineReplayQueue* old_value;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	old_value = geary_imap_engine_minimal_folder_get_replay_queue (self);
	if (old_value != value) {
		GearyImapEngineReplayQueue* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_replay_queue);
		self->priv->_replay_queue = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REPLAY_QUEUE_PROPERTY]);
	}
}

GearyContactHarvester*
geary_imap_engine_minimal_folder_get_harvester (GearyImapEngineMinimalFolder* self)
{
	GearyContactHarvester* result;
	GearyContactHarvester* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self), NULL);
	_tmp0_ = self->priv->_harvester;
	result = _tmp0_;
	return result;
}

static void
geary_imap_engine_minimal_folder_set_harvester (GearyImapEngineMinimalFolder* self,
                                                GearyContactHarvester* value)
{
	GearyContactHarvester* old_value;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	old_value = geary_imap_engine_minimal_folder_get_harvester (self);
	if (old_value != value) {
		GearyContactHarvester* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_harvester);
		self->priv->_harvester = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_HARVESTER_PROPERTY]);
	}
}

static void
_geary_imap_engine_minimal_folder_on_email_complete_geary_imap_db_folder_email_complete (GearyImapDBFolder* _sender,
                                                                                         GeeCollection* email_ids,
                                                                                         gpointer self)
{
	geary_imap_engine_minimal_folder_on_email_complete ((GearyImapEngineMinimalFolder*) self, email_ids);
}

static void
__lambda115_ (GearyImapEngineMinimalFolder* self)
{
	geary_imap_engine_minimal_folder_open_remote_session (self, NULL, NULL);
}

static void
___lambda115__geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                  gpointer self)
{
	__lambda115_ ((GearyImapEngineMinimalFolder*) self);
}

static void
_geary_imap_engine_minimal_folder_on_update_flags_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                      gpointer self)
{
	geary_imap_engine_minimal_folder_on_update_flags ((GearyImapEngineMinimalFolder*) self);
}

static void
_geary_imap_engine_minimal_folder_on_refresh_unseen_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                        gpointer self)
{
	geary_imap_engine_minimal_folder_on_refresh_unseen ((GearyImapEngineMinimalFolder*) self);
}

GearyImapEngineMinimalFolder*
geary_imap_engine_minimal_folder_construct (GType object_type,
                                            GearyImapEngineGenericAccount* account,
                                            GearyImapDBFolder* local_folder,
                                            GearyFolderSpecialUse use)
{
	GearyImapEngineMinimalFolder * self = NULL;
	GearyImapDBFolder* _tmp0_;
	GearyAggregatedFolderProperties* _tmp1_;
	GearyImapFolderProperties* _tmp2_;
	GearyImapFolderProperties* _tmp3_;
	GearyImapEngineEmailPrefetcher* _tmp4_;
	GearyTimeoutManager* _tmp5_;
	GearyTimeoutManager* _tmp6_;
	GearyTimeoutManager* _tmp7_;
	GearyNonblockingSemaphore* _tmp8_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (account), NULL);
	g_return_val_if_fail (GEARY_IMAP_DB_IS_FOLDER (local_folder), NULL);
	self = (GearyImapEngineMinimalFolder*) geary_folder_construct (object_type);
	self->priv->_account = account;
	geary_imap_engine_minimal_folder_set_local_folder (self, local_folder);
	_tmp0_ = self->priv->_local_folder;
	g_signal_connect_object (_tmp0_, "email-complete", (GCallback) _geary_imap_engine_minimal_folder_on_email_complete_geary_imap_db_folder_email_complete, self, 0);
	self->priv->_used_as = use;
	_tmp1_ = self->priv->_properties;
	_tmp2_ = geary_imap_db_folder_get_properties (local_folder);
	_tmp3_ = _tmp2_;
	geary_aggregated_folder_properties_add (_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
	_g_object_unref0 (_tmp3_);
	_tmp4_ = geary_imap_engine_email_prefetcher_new (self, GEARY_IMAP_ENGINE_EMAIL_PREFETCHER_PREFETCH_DELAY_SEC);
	_g_object_unref0 (self->priv->email_prefetcher);
	self->priv->email_prefetcher = _tmp4_;
	geary_imap_engine_minimal_folder_update_harvester (self);
	_tmp5_ = geary_timeout_manager_new_seconds ((guint) GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FORCE_OPEN_REMOTE_TIMEOUT_SEC, ___lambda115__geary_timeout_manager_timeout_func, self);
	_g_object_unref0 (self->priv->remote_open_timer);
	self->priv->remote_open_timer = _tmp5_;
	_tmp6_ = geary_timeout_manager_new_seconds ((guint) GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FLAG_UPDATE_TIMEOUT_SEC, _geary_imap_engine_minimal_folder_on_update_flags_geary_timeout_manager_timeout_func, self);
	_g_object_unref0 (self->priv->update_flags_timer);
	self->priv->update_flags_timer = _tmp6_;
	_tmp7_ = geary_timeout_manager_new_seconds ((guint) GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REFRESH_UNSEEN_TIMEOUT_SEC, _geary_imap_engine_minimal_folder_on_refresh_unseen_geary_timeout_manager_timeout_func, self);
	_g_object_unref0 (self->priv->refresh_unseen_timer);
	self->priv->refresh_unseen_timer = _tmp7_;
	_tmp8_ = self->priv->closed_semaphore;
	geary_nonblocking_lock_blind_notify (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
	return self;
}

GearyImapEngineMinimalFolder*
geary_imap_engine_minimal_folder_new (GearyImapEngineGenericAccount* account,
                                      GearyImapDBFolder* local_folder,
                                      GearyFolderSpecialUse use)
{
	return geary_imap_engine_minimal_folder_construct (GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, account, local_folder, use);
}

static void
geary_imap_engine_minimal_folder_real_notify_closing (GearyImapEngineMinimalFolder* self,
                                                      GeeList* final_ops)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (final_ops, GEE_TYPE_LIST));
	g_signal_emit (self, geary_imap_engine_minimal_folder_signals[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_CLOSING_SIGNAL], 0, final_ops);
}

void
geary_imap_engine_minimal_folder_notify_closing (GearyImapEngineMinimalFolder* self,
                                                 GeeList* final_ops)
{
	GearyImapEngineMinimalFolderClass* _klass_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_klass_ = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS (self);
	if (_klass_->notify_closing) {
		_klass_->notify_closing (self, final_ops);
	}
}

void
geary_imap_engine_minimal_folder_replay_notify_email_inserted (GearyImapEngineMinimalFolder* self,
                                                               GeeCollection* ids)
{
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	geary_folder_notify_email_inserted (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), ids);
}

void
geary_imap_engine_minimal_folder_replay_notify_email_locally_inserted (GearyImapEngineMinimalFolder* self,
                                                                       GeeCollection* ids)
{
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	geary_folder_notify_email_locally_inserted (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), ids);
}

void
geary_imap_engine_minimal_folder_replay_notify_email_removed (GearyImapEngineMinimalFolder* self,
                                                              GeeCollection* ids)
{
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	geary_folder_notify_email_removed (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), ids);
}

void
geary_imap_engine_minimal_folder_replay_notify_email_count_changed (GearyImapEngineMinimalFolder* self,
                                                                    gint new_count,
                                                                    GearyFolderCountChangeReason reason)
{
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	geary_folder_notify_email_count_changed (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), new_count, reason);
}

void
geary_imap_engine_minimal_folder_replay_notify_email_flags_changed (GearyImapEngineMinimalFolder* self,
                                                                    GeeMap* flag_map)
{
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (flag_map, GEE_TYPE_MAP));
	geary_folder_notify_email_flags_changed (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), flag_map);
}

static void
geary_imap_engine_minimal_folder_real_set_used_as_custom (GearyFolder* base,
                                                          gboolean enabled,
                                                          GError** error)
{
	GearyImapEngineMinimalFolder * self;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	if (enabled) {
		if (self->priv->_used_as != GEARY_FOLDER_SPECIAL_USE_NONE) {
			GError* _tmp0_;
			_tmp0_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Folder already has special use");
			_inner_error0_ = _tmp0_;
			if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
				g_propagate_error (error, _inner_error0_);
				return;
			} else {
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
		}
		geary_imap_engine_minimal_folder_set_use (self, GEARY_FOLDER_SPECIAL_USE_CUSTOM);
	} else {
		gboolean _tmp1_ = FALSE;
		if (self->priv->_used_as != GEARY_FOLDER_SPECIAL_USE_CUSTOM) {
			_tmp1_ = self->priv->_used_as != GEARY_FOLDER_SPECIAL_USE_NONE;
		} else {
			_tmp1_ = FALSE;
		}
		if (_tmp1_) {
			GError* _tmp2_;
			_tmp2_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Folder already has special use");
			_inner_error0_ = _tmp2_;
			if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
				g_propagate_error (error, _inner_error0_);
				return;
			} else {
				g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
				g_clear_error (&_inner_error0_);
				return;
			}
		}
		geary_imap_engine_minimal_folder_set_use (self, GEARY_FOLDER_SPECIAL_USE_NONE);
	}
}

void
geary_imap_engine_minimal_folder_set_use (GearyImapEngineMinimalFolder* self,
                                          GearyFolderSpecialUse new_use)
{
	GearyFolderSpecialUse old_use = 0;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	old_use = self->priv->_used_as;
	self->priv->_used_as = new_use;
	if (old_use != new_use) {
		geary_folder_notify_use_changed (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), old_use, new_use);
		geary_imap_engine_minimal_folder_update_harvester (self);
	}
}

/** {@inheritDoc} */
static GearyFolderOpenState
geary_imap_engine_minimal_folder_real_get_open_state (GearyFolder* base)
{
	GearyImapEngineMinimalFolder * self;
	GearyFolderOpenState _tmp0_ = 0;
	GearyImapFolderSession* _tmp1_;
	GearyFolderOpenState result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	if (self->priv->open_count == 0) {
		result = GEARY_FOLDER_OPEN_STATE_CLOSED;
		return result;
	}
	_tmp1_ = self->priv->remote_session;
	if (_tmp1_ != NULL) {
		_tmp0_ = GEARY_FOLDER_OPEN_STATE_REMOTE;
	} else {
		_tmp0_ = GEARY_FOLDER_OPEN_STATE_LOCAL;
	}
	result = _tmp0_;
	return result;
}

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

static void
geary_imap_engine_minimal_folder_real_open_async (GearyFolder* base,
                                                  GearyFolderOpenFlags open_flags,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	GearyImapEngineMinimalFolder * self;
	GearyImapEngineMinimalFolderOpenAsyncData* _data_;
	GearyImapEngineMinimalFolder* _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_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderOpenAsyncData);
	_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_minimal_folder_real_open_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->open_flags = open_flags;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_imap_engine_minimal_folder_real_open_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_open_finish (GearyFolder* base,
                                              GAsyncResult* _res_,
                                              GError** error)
{
	gboolean result;
	GearyImapEngineMinimalFolderOpenAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

/** {@inheritDoc} */
static void
geary_imap_engine_minimal_folder_open_async_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_)
{
	GearyImapEngineMinimalFolderOpenAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_open_async_co (_data_);
}

static gpointer
_g_error_copy0 (gpointer self)
{
	return self ? g_error_copy (self) : NULL;
}

static gboolean
geary_imap_engine_minimal_folder_real_open_async_co (GearyImapEngineMinimalFolderOpenAsyncData* _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_->opening = FALSE;
	_data_->open_err = NULL;
	{
		_data_->_tmp0_ = _data_->self->priv->lifecycle_mutex;
		_data_->_state_ = 1;
		geary_nonblocking_mutex_claim_async (_data_->_tmp0_, _data_->cancellable, geary_imap_engine_minimal_folder_open_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->token = geary_nonblocking_mutex_claim_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		{
			_data_->_state_ = 2;
			geary_imap_engine_minimal_folder_open_locked (_data_->self, _data_->open_flags, _data_->cancellable, geary_imap_engine_minimal_folder_open_async_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp1_ = geary_imap_engine_minimal_folder_open_locked_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
			_data_->opening = _data_->_tmp1_;
		}
		goto __finally1;
		__catch1_g_error:
		{
			_data_->err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp2_ = _data_->err;
			_data_->_tmp3_ = _g_error_copy0 (_data_->_tmp2_);
			_g_error_free0 (_data_->open_err);
			_data_->open_err = _data_->_tmp3_;
			_g_error_free0 (_data_->err);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp4_ = _data_->self->priv->lifecycle_mutex;
		geary_nonblocking_mutex_release (_data_->_tmp4_, &_data_->token, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->open_err);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->open_err;
	if (_data_->_tmp5_ != NULL) {
		_data_->_tmp6_ = _data_->open_err;
		_data_->_tmp7_ = _g_error_copy0 (_data_->_tmp6_);
		_data_->_inner_error0_ = _data_->_tmp7_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->open_err);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->opening;
	_g_error_free0 (_data_->open_err);
	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_minimal_folder_claim_remote_session_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderClaimRemoteSessionData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderClaimRemoteSessionData, _data_);
}

void
geary_imap_engine_minimal_folder_claim_remote_session (GearyImapEngineMinimalFolder* self,
                                                       GCancellable* cancellable,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	GearyImapEngineMinimalFolderClaimRemoteSessionData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderClaimRemoteSessionData);
	_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_minimal_folder_claim_remote_session_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_minimal_folder_claim_remote_session_co (_data_);
}

GearyImapFolderSession*
geary_imap_engine_minimal_folder_claim_remote_session_finish (GearyImapEngineMinimalFolder* self,
                                                              GAsyncResult* _res_,
                                                              GError** error)
{
	GearyImapFolderSession* result;
	GearyImapEngineMinimalFolderClaimRemoteSessionData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

/**
     * Returns a valid IMAP folder session when one is available.
     *
     * Implementations may use this to acquire an IMAP session for
     * performing folder-related work. The call will wait until a
     * connection is established then return the session.
     *
     * The session returned is guaranteed to be open upon return,
     * however may close afterwards due to this folder closing, or the
     * network connection going away.
     *
     * The folder must have been opened before calling this method.
     */
static void
geary_imap_engine_minimal_folder_claim_remote_session_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	GearyImapEngineMinimalFolderClaimRemoteSessionData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_claim_remote_session_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_claim_remote_session_co (GearyImapEngineMinimalFolderClaimRemoteSessionData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "claim_remote_session", &_data_->_inner_error0_);
	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;
	}
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Claiming folder session");
	_data_->_tmp1_ = _data_->self->priv->remote_session;
	if (_data_->_tmp1_ == NULL) {
		_data_->_tmp2_ = _data_->self->priv->open_cancellable;
		_data_->_tmp0_ = !g_cancellable_is_cancelled (_data_->_tmp2_);
	} else {
		_data_->_tmp0_ = FALSE;
	}
	if (_data_->_tmp0_) {
		geary_imap_engine_minimal_folder_open_remote_session (_data_->self, NULL, NULL);
	}
	_data_->_tmp4_ = _data_->self->priv->remote_wait_semaphore;
	_data_->_state_ = 1;
	geary_nonblocking_reporting_semaphore_wait_for_result_async (_data_->_tmp4_, _data_->cancellable, geary_imap_engine_minimal_folder_claim_remote_session_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp5_ = geary_nonblocking_reporting_semaphore_wait_for_result_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp3_ = (gboolean) ((gintptr) _data_->_tmp5_);
	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;
	}
	if (!_data_->_tmp3_) {
		_data_->_tmp6_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_ALREADY_CLOSED, "%s failed to open", _data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_g_free0 (_data_->_tmp7_);
		_data_->_inner_error0_ = _data_->_tmp9_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp10_ = _data_->self->priv->remote_session;
	_data_->_tmp11_ = _g_object_ref0 (_data_->_tmp10_);
	_data_->result = _data_->_tmp11_;
	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_minimal_folder_real_close_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderCloseAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderCloseAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_close_async (GearyFolder* base,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	GearyImapEngineMinimalFolder * self;
	GearyImapEngineMinimalFolderCloseAsyncData* _data_;
	GearyImapEngineMinimalFolder* _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_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderCloseAsyncData);
	_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_minimal_folder_real_close_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_minimal_folder_real_close_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_close_finish (GearyFolder* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	gboolean result;
	GearyImapEngineMinimalFolderCloseAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

/** {@inheritDoc} */
static void
geary_imap_engine_minimal_folder_close_async_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCloseAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_close_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_close_async_co (GearyImapEngineMinimalFolderCloseAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "close_async", &_data_->_inner_error0_);
	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;
	}
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Scheduling folder close");
	_data_->_tmp0_ = geary_imap_engine_user_close_new (_data_->self, _data_->cancellable);
	_data_->op = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->_replay_queue;
	_data_->_tmp2_ = _data_->op;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp3_ = _data_->op;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_close_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->op;
	_data_->result = geary_trillian_is_certain (_data_->_tmp4_->is_closing);
	_g_object_unref0 (_data_->op);
	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_minimal_folder_real_wait_for_close_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderWaitForCloseAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderWaitForCloseAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_wait_for_close_async (GearyFolder* base,
                                                            GCancellable* cancellable,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_)
{
	GearyImapEngineMinimalFolder * self;
	GearyImapEngineMinimalFolderWaitForCloseAsyncData* _data_;
	GearyImapEngineMinimalFolder* _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_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderWaitForCloseAsyncData);
	_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_minimal_folder_real_wait_for_close_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_minimal_folder_real_wait_for_close_async_co (_data_);
}

static void
geary_imap_engine_minimal_folder_wait_for_close_finish (GearyFolder* base,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	GearyImapEngineMinimalFolderWaitForCloseAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** {@inheritDoc} */
static void
geary_imap_engine_minimal_folder_wait_for_close_async_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	GearyImapEngineMinimalFolderWaitForCloseAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_wait_for_close_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_wait_for_close_async_co (GearyImapEngineMinimalFolderWaitForCloseAsyncData* _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->closed_semaphore;
	_data_->_state_ = 1;
	geary_nonblocking_lock_wait_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), _data_->cancellable, geary_imap_engine_minimal_folder_wait_for_close_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_nonblocking_lock_wait_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), _data_->_res_, &_data_->_inner_error0_);
	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;
	}
	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_minimal_folder_real_synchronise_remote_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderSynchroniseRemoteData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderSynchroniseRemoteData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_synchronise_remote (GearyFolder* base,
                                                          GCancellable* cancellable,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	GearyImapEngineMinimalFolder * self;
	GearyImapEngineMinimalFolderSynchroniseRemoteData* _data_;
	GearyImapEngineMinimalFolder* _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_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderSynchroniseRemoteData);
	_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_minimal_folder_real_synchronise_remote_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_minimal_folder_real_synchronise_remote_co (_data_);
}

static void
geary_imap_engine_minimal_folder_synchronise_remote_finish (GearyFolder* base,
                                                            GAsyncResult* _res_,
                                                            GError** error)
{
	GearyImapEngineMinimalFolderSynchroniseRemoteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** {@inheritDoc} */
static void
geary_imap_engine_minimal_folder_synchronise_remote_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_)
{
	GearyImapEngineMinimalFolderSynchroniseRemoteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_synchronise_remote_co (_data_);
}

static gboolean
_geary_imap_engine_minimal_folder_real_synchronise_remote_co_gsource_func (gpointer self)
{
	gboolean result;
	result = geary_imap_engine_minimal_folder_real_synchronise_remote_co (self);
	return result;
}

static gboolean
geary_imap_engine_minimal_folder_real_synchronise_remote_co (GearyImapEngineMinimalFolderSynchroniseRemoteData* _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;
		case 5:
		goto _state_5;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "synchronise_remote", &_data_->_inner_error0_);
	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_->have_nooped = FALSE;
	_data_->retries = 3;
	while (TRUE) {
		if (!_data_->have_nooped) {
			_data_->_tmp0_ = !g_cancellable_is_cancelled (_data_->cancellable);
		} else {
			_data_->_tmp0_ = FALSE;
		}
		if (!_data_->_tmp0_) {
			break;
		}
		_data_->_state_ = 1;
		geary_imap_engine_minimal_folder_claim_remote_session (_data_->self, _data_->cancellable, geary_imap_engine_minimal_folder_synchronise_remote_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = geary_imap_engine_minimal_folder_claim_remote_session_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		_data_->remote = _data_->_tmp1_;
		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_->_tmp2_ = _data_->remote;
			_data_->_state_ = 2;
			geary_imap_folder_session_send_noop (_data_->_tmp2_, _data_->cancellable, geary_imap_engine_minimal_folder_synchronise_remote_ready, _data_);
			return FALSE;
			_state_2:
			geary_imap_folder_session_send_noop_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->have_nooped = TRUE;
		}
		goto __finally0;
		__catch0_g_error:
		{
			_data_->err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->retries = -1;
			_data_->_tmp4_ = _data_->err;
			if (geary_imap_engine_is_recoverable_failure (_data_->_tmp4_)) {
				_data_->_tmp3_ = _data_->retries > 0;
			} else {
				_data_->_tmp3_ = FALSE;
			}
			if (_data_->_tmp3_) {
				_data_->_tmp5_ = _data_->err;
				_data_->_tmp6_ = _data_->_tmp5_->message;
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Recoverable error during remote sync: %s", _data_->_tmp6_);
				g_timeout_add_seconds_full (G_PRIORITY_DEFAULT, (guint) 1, _geary_imap_engine_minimal_folder_real_synchronise_remote_co_gsource_func, _data_, NULL);
				_data_->_state_ = 3;
				return FALSE;
				_state_3:
				;
			} else {
				_data_->_tmp7_ = _data_->err;
				_data_->_tmp8_ = _g_error_copy0 (_data_->_tmp7_);
				_data_->_inner_error0_ = _data_->_tmp8_;
				_g_error_free0 (_data_->err);
				goto __finally0;
			}
			_g_error_free0 (_data_->err);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->remote);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->remote);
	}
	_data_->_tmp9_ = _data_->self->priv->_replay_queue;
	geary_imap_engine_replay_queue_flush_notifications (_data_->_tmp9_);
	_data_->_tmp10_ = _data_->self->priv->_replay_queue;
	_data_->_state_ = 4;
	geary_imap_engine_replay_queue_checkpoint (_data_->_tmp10_, _data_->cancellable, geary_imap_engine_minimal_folder_synchronise_remote_ready, _data_);
	return FALSE;
	_state_4:
	geary_imap_engine_replay_queue_checkpoint_finish (_data_->_tmp10_, _data_->_res_, &_data_->_inner_error0_);
	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_->_tmp11_ = _data_->self->priv->email_prefetcher;
	_data_->_tmp12_ = geary_imap_engine_email_prefetcher_get_active_sem (_data_->_tmp11_);
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_state_ = 5;
	geary_nonblocking_lock_wait_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp13_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), _data_->cancellable, geary_imap_engine_minimal_folder_synchronise_remote_ready, _data_);
	return FALSE;
	_state_5:
	geary_nonblocking_lock_wait_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp13_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), _data_->_res_, &_data_->_inner_error0_);
	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;
	}
	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_minimal_folder_detach_all_emails_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderDetachAllEmailsAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderDetachAllEmailsAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_detach_all_emails_async (GearyImapEngineMinimalFolder* self,
                                                          GCancellable* cancellable,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	GearyImapEngineMinimalFolderDetachAllEmailsAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderDetachAllEmailsAsyncData);
	_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_minimal_folder_detach_all_emails_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_minimal_folder_detach_all_emails_async_co (_data_);
}

static void
geary_imap_engine_minimal_folder_detach_all_emails_finish (GearyImapEngineMinimalFolder* self,
                                                           GAsyncResult* _res_,
                                                           GError** error)
{
	GearyImapEngineMinimalFolderDetachAllEmailsAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_minimal_folder_detach_all_emails_async_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_)
{
	GearyImapEngineMinimalFolderDetachAllEmailsAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_detach_all_emails_async_co (_data_);
}

static GearyEmailIdentifier*
___lambda112_ (GearyImapEngineMinimalFolder* self,
               GearyEmail* email)
{
	GearyEmailIdentifier* _tmp0_;
	GearyEmailIdentifier* _tmp1_;
	GearyEmailIdentifier* _tmp2_;
	GearyEmailIdentifier* result;
	g_return_val_if_fail (GEARY_IS_EMAIL (email), NULL);
	_tmp0_ = geary_email_get_id (email);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	result = _tmp2_;
	_g_object_unref0 (email);
	return result;
}

static gpointer
____lambda112__gee_map_func (gpointer g,
                             gpointer self)
{
	gpointer result;
	result = ___lambda112_ ((GearyImapEngineMinimalFolder*) self, (GearyEmail*) g);
	return result;
}

static gboolean
geary_imap_engine_minimal_folder_detach_all_emails_async_co (GearyImapEngineMinimalFolderDetachAllEmailsAsyncData* _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->_local_folder;
	_data_->_state_ = 1;
	geary_imap_db_folder_list_email_by_id_async (_data_->_tmp0_, NULL, -1, GEARY_EMAIL_FIELD_NONE, GEARY_IMAP_DB_FOLDER_LIST_FLAGS_NONE, _data_->cancellable, geary_imap_engine_minimal_folder_detach_all_emails_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = geary_imap_db_folder_list_email_by_id_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
	_data_->all = _data_->_tmp1_;
	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_->_tmp2_ = _data_->self->priv->_local_folder;
	_data_->_state_ = 2;
	geary_imap_db_folder_detach_all_emails_async (_data_->_tmp2_, _data_->cancellable, geary_imap_engine_minimal_folder_detach_all_emails_async_ready, _data_);
	return FALSE;
	_state_2:
	geary_imap_db_folder_detach_all_emails_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->all);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->all;
	if (_data_->_tmp4_ != NULL) {
		_data_->_tmp5_ = _data_->all;
		_data_->_tmp6_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp3_ = _data_->_tmp7_ > 0;
	} else {
		_data_->_tmp3_ = FALSE;
	}
	if (_data_->_tmp3_) {
		_data_->_tmp8_ = _data_->all;
		_data_->_tmp9_ = geary_traverse (GEARY_TYPE_EMAIL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = geary_iterable_map (_data_->_tmp10_, GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, ____lambda112__gee_map_func, _data_->self);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp13_ = geary_iterable_to_array_list (_data_->_tmp12_, NULL, NULL, NULL);
		_data_->_tmp14_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp13_, GEE_TYPE_LIST, GeeList);
		_g_object_unref0 (_data_->_tmp12_);
		_g_object_unref0 (_data_->_tmp10_);
		_data_->ids = _data_->_tmp14_;
		_data_->_tmp15_ = _data_->ids;
		geary_folder_notify_email_removed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp15_, GEE_TYPE_COLLECTION, GeeCollection));
		geary_folder_notify_email_count_changed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), 0, GEARY_FOLDER_COUNT_CHANGE_REASON_REMOVED);
		_g_object_unref0 (_data_->ids);
	}
	_g_object_unref0 (_data_->all);
	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_minimal_folder_normalize_folders_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderNormalizeFoldersData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->session);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderNormalizeFoldersData, _data_);
}

static void
geary_imap_engine_minimal_folder_normalize_folders (GearyImapEngineMinimalFolder* self,
                                                    GearyImapFolderSession* session,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	GearyImapEngineMinimalFolderNormalizeFoldersData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GearyImapFolderSession* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (GEARY_IMAP_IS_FOLDER_SESSION (session));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderNormalizeFoldersData);
	_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_minimal_folder_normalize_folders_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (session);
	_g_object_unref0 (_data_->session);
	_data_->session = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_minimal_folder_normalize_folders_co (_data_);
}

static void
geary_imap_engine_minimal_folder_normalize_folders_finish (GearyImapEngineMinimalFolder* self,
                                                           GAsyncResult* _res_,
                                                           GError** error)
{
	GearyImapEngineMinimalFolderNormalizeFoldersData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/**
     * Synchronises the remote and local folders on session established.
     *
     * See [[https://tools.ietf.org/html/rfc4549|RFC 4549]] for an
     * overview of the process
     */
static Block98Data*
block98_data_ref (Block98Data* _data98_)
{
	g_atomic_int_inc (&_data98_->_ref_count_);
	return _data98_;
}

static void
block98_data_unref (void * _userdata_)
{
	Block98Data* _data98_;
	_data98_ = (Block98Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data98_->_ref_count_)) {
		GearyImapEngineMinimalFolder* self;
		self = _data98_->self;
		_g_object_unref0 (_data98_->locally_inserted_ids);
		_g_object_unref0 (_data98_->inserted_ids);
		_g_object_unref0 (_data98_->locally_appended_ids);
		_g_object_unref0 (_data98_->appended_ids);
		_g_object_unref0 (_data98_->inserted_uids);
		_g_object_unref0 (_data98_->appended_uids);
		_g_object_unref0 (_data98_->removed_uids);
		_g_object_unref0 (_data98_->remote_uids);
		_g_object_unref0 (_data98_->local_uids);
		_g_object_unref0 (_data98_->already_marked_ids);
		_g_object_unref0 (_data98_->local_latest_id);
		_g_object_unref0 (self);
		g_slice_free (Block98Data, _data98_);
	}
}

static gchar*
bool_to_string (gboolean self)
{
	gchar* result;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}

static void
geary_imap_engine_minimal_folder_normalize_folders_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_)
{
	GearyImapEngineMinimalFolderNormalizeFoldersData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_normalize_folders_co (_data_);
}

static void
__lambda113_ (Block98Data* _data98_,
              GError** error)
{
	GearyImapEngineMinimalFolder* self;
	GeeSet* _tmp22_;
	self = _data98_->self;
	{
		GeeIterator* _local_uid_it = NULL;
		GeeSet* _tmp0_;
		GeeIterator* _tmp1_;
		_tmp0_ = _data98_->local_uids;
		_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ITERABLE, GeeIterable));
		_local_uid_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			GearyImapUID* local_uid = NULL;
			GeeIterator* _tmp3_;
			gpointer _tmp4_;
			GeeSet* _tmp5_;
			GearyImapUID* _tmp6_;
			_tmp2_ = _local_uid_it;
			if (!gee_iterator_next (_tmp2_)) {
				break;
			}
			_tmp3_ = _local_uid_it;
			_tmp4_ = gee_iterator_get (_tmp3_);
			local_uid = (GearyImapUID*) _tmp4_;
			_tmp5_ = _data98_->remote_uids;
			_tmp6_ = local_uid;
			if (!gee_collection_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEE_TYPE_COLLECTION, GeeCollection), _tmp6_)) {
				GeeHashSet* _tmp7_;
				GearyImapUID* _tmp8_;
				_tmp7_ = _data98_->removed_uids;
				_tmp8_ = local_uid;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp8_);
			}
			_g_object_unref0 (local_uid);
		}
		_g_object_unref0 (_local_uid_it);
	}
	{
		GeeIterator* _remote_uid_it = NULL;
		GeeSet* _tmp9_;
		GeeIterator* _tmp10_;
		_tmp9_ = _data98_->remote_uids;
		_tmp10_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEE_TYPE_ITERABLE, GeeIterable));
		_remote_uid_it = _tmp10_;
		while (TRUE) {
			GeeIterator* _tmp11_;
			GearyImapUID* remote_uid = NULL;
			GeeIterator* _tmp12_;
			gpointer _tmp13_;
			GearyImapUID* _tmp14_;
			GearyImapDBEmailIdentifier* _tmp15_;
			GearyImapUID* _tmp16_;
			GearyImapUID* _tmp17_;
			_tmp11_ = _remote_uid_it;
			if (!gee_iterator_next (_tmp11_)) {
				break;
			}
			_tmp12_ = _remote_uid_it;
			_tmp13_ = gee_iterator_get (_tmp12_);
			remote_uid = (GearyImapUID*) _tmp13_;
			_tmp14_ = remote_uid;
			_tmp15_ = _data98_->local_latest_id;
			_tmp16_ = geary_imap_db_email_identifier_get_uid (_tmp15_);
			_tmp17_ = _tmp16_;
			if (geary_imap_uid_compare_to (_tmp14_, _tmp17_) > 0) {
				GeeHashSet* _tmp18_;
				GearyImapUID* _tmp19_;
				_tmp18_ = _data98_->appended_uids;
				_tmp19_ = remote_uid;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp19_);
			} else {
				GeeHashSet* _tmp20_;
				GearyImapUID* _tmp21_;
				_tmp20_ = _data98_->inserted_uids;
				_tmp21_ = remote_uid;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp21_);
			}
			_g_object_unref0 (remote_uid);
		}
		_g_object_unref0 (_remote_uid_it);
	}
	_tmp22_ = _data98_->already_marked_ids;
	if (_tmp22_ != NULL) {
		{
			GeeIterator* _id_it = NULL;
			GeeSet* _tmp23_;
			GeeIterator* _tmp24_;
			_tmp23_ = _data98_->already_marked_ids;
			_tmp24_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, GEE_TYPE_ITERABLE, GeeIterable));
			_id_it = _tmp24_;
			while (TRUE) {
				GeeIterator* _tmp25_;
				GearyImapDBEmailIdentifier* id = NULL;
				GeeIterator* _tmp26_;
				gpointer _tmp27_;
				GearyImapDBEmailIdentifier* _tmp28_;
				GeeHashSet* _tmp29_;
				GearyImapDBEmailIdentifier* _tmp30_;
				GearyImapUID* _tmp31_;
				GearyImapUID* _tmp32_;
				_tmp25_ = _id_it;
				if (!gee_iterator_next (_tmp25_)) {
					break;
				}
				_tmp26_ = _id_it;
				_tmp27_ = gee_iterator_get (_tmp26_);
				id = (GearyImapDBEmailIdentifier*) _tmp27_;
				_tmp28_ = id;
				_vala_assert (geary_imap_db_email_identifier_has_uid (_tmp28_), "id.has_uid()");
				_tmp29_ = _data98_->appended_uids;
				_tmp30_ = id;
				_tmp31_ = geary_imap_db_email_identifier_get_uid (_tmp30_);
				_tmp32_ = _tmp31_;
				if (!gee_abstract_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp32_)) {
					GeeHashSet* _tmp33_;
					GearyImapDBEmailIdentifier* _tmp34_;
					GearyImapUID* _tmp35_;
					GearyImapUID* _tmp36_;
					_tmp33_ = _data98_->inserted_uids;
					_tmp34_ = id;
					_tmp35_ = geary_imap_db_email_identifier_get_uid (_tmp34_);
					_tmp36_ = _tmp35_;
					gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp33_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp36_);
				}
				_g_object_unref0 (id);
			}
			_g_object_unref0 (_id_it);
		}
	}
}

static void
___lambda113__geary_nonblocking_concurrent_concurrent_callback (GCancellable* cancellable,
                                                                gpointer self,
                                                                GError** error)
{
	__lambda113_ (self, error);
}

static Block99Data*
block99_data_ref (Block99Data* _data99_)
{
	g_atomic_int_inc (&_data99_->_ref_count_);
	return _data99_;
}

static void
block99_data_unref (void * _userdata_)
{
	Block99Data* _data99_;
	_data99_ = (Block99Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data99_->_ref_count_)) {
		GearyImapEngineMinimalFolder* self;
		self = _data99_->_data98_->self;
		_g_object_unref0 (_data99_->created_or_merged);
		block98_data_unref (_data99_->_data98_);
		_data99_->_data98_ = NULL;
		g_slice_free (Block99Data, _data99_);
	}
}

static void
___lambda114_ (Block99Data* _data99_,
               GError** error)
{
	Block98Data* _data98_;
	GearyImapEngineMinimalFolder* self;
	_data98_ = _data99_->_data98_;
	self = _data98_->self;
	{
		GeeIterator* _email_it = NULL;
		GeeMap* _tmp0_;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = _data99_->created_or_merged;
		_tmp1_ = gee_map_get_keys (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_email_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			GearyEmail* email = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GearyImapDBEmailIdentifier* id = NULL;
			GearyEmail* _tmp9_;
			GearyEmailIdentifier* _tmp10_;
			GearyEmailIdentifier* _tmp11_;
			GearyImapDBEmailIdentifier* _tmp12_;
			gboolean created = FALSE;
			GeeMap* _tmp13_;
			GearyEmail* _tmp14_;
			gpointer _tmp15_;
			GeeHashSet* _tmp16_;
			GearyImapDBEmailIdentifier* _tmp17_;
			GearyImapUID* _tmp18_;
			GearyImapUID* _tmp19_;
			_tmp6_ = _email_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _email_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			email = (GearyEmail*) _tmp8_;
			_tmp9_ = email;
			_tmp10_ = geary_email_get_id (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier));
			id = _tmp12_;
			_tmp13_ = _data99_->created_or_merged;
			_tmp14_ = email;
			_tmp15_ = gee_map_get (_tmp13_, _tmp14_);
			created = (gboolean) ((gintptr) _tmp15_);
			_tmp16_ = _data98_->appended_uids;
			_tmp17_ = id;
			_tmp18_ = geary_imap_db_email_identifier_get_uid (_tmp17_);
			_tmp19_ = _tmp18_;
			if (gee_abstract_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp19_)) {
				GeeSet* _tmp20_;
				GearyImapDBEmailIdentifier* _tmp21_;
				_tmp20_ = _data98_->appended_ids;
				_tmp21_ = id;
				gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, GEE_TYPE_COLLECTION, GeeCollection), _tmp21_);
				if (created) {
					GeeSet* _tmp22_;
					GearyImapDBEmailIdentifier* _tmp23_;
					_tmp22_ = _data98_->locally_appended_ids;
					_tmp23_ = id;
					gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, GEE_TYPE_COLLECTION, GeeCollection), _tmp23_);
				}
			} else {
				GeeHashSet* _tmp24_;
				GearyImapDBEmailIdentifier* _tmp25_;
				GearyImapUID* _tmp26_;
				GearyImapUID* _tmp27_;
				_tmp24_ = _data98_->inserted_uids;
				_tmp25_ = id;
				_tmp26_ = geary_imap_db_email_identifier_get_uid (_tmp25_);
				_tmp27_ = _tmp26_;
				if (gee_abstract_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp24_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp27_)) {
					GeeSet* _tmp28_;
					GearyImapDBEmailIdentifier* _tmp29_;
					_tmp28_ = _data98_->inserted_ids;
					_tmp29_ = id;
					gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, GEE_TYPE_COLLECTION, GeeCollection), _tmp29_);
					if (created) {
						GeeSet* _tmp30_;
						GearyImapDBEmailIdentifier* _tmp31_;
						_tmp30_ = _data98_->locally_inserted_ids;
						_tmp31_ = id;
						gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, GEE_TYPE_COLLECTION, GeeCollection), _tmp31_);
					}
				}
			}
			_g_object_unref0 (id);
			_g_object_unref0 (email);
		}
		_g_object_unref0 (_email_it);
	}
}

static void
____lambda114__geary_nonblocking_concurrent_concurrent_callback (GCancellable* cancellable,
                                                                 gpointer self,
                                                                 GError** error)
{
	___lambda114_ (self, error);
}

static gboolean
geary_imap_engine_minimal_folder_normalize_folders_co (GearyImapEngineMinimalFolderNormalizeFoldersData* _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;
		case 5:
		goto _state_5;
		case 6:
		goto _state_6;
		case 7:
		goto _state_7;
		case 8:
		goto _state_8;
		case 9:
		goto _state_9;
		case 10:
		goto _state_10;
		case 11:
		goto _state_11;
		case 12:
		goto _state_12;
		case 13:
		goto _state_13;
		case 14:
		goto _state_14;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data98_ = g_slice_new0 (Block98Data);
	_data_->_data98_->_ref_count_ = 1;
	_data_->_data98_->self = g_object_ref (_data_->self);
	_data_->_data98_->_async_data_ = _data_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Begin normalizing remote and local folders");
	_data_->_tmp0_ = _data_->self->priv->_local_folder;
	_data_->_tmp1_ = geary_imap_db_folder_get_properties (_data_->_tmp0_);
	_data_->local_properties = _data_->_tmp1_;
	_data_->_tmp2_ = geary_imap_folder_session_get_folder (_data_->session);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = geary_imap_folder_get_properties (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = _g_object_ref0 (_data_->_tmp5_);
	_data_->remote_properties = _data_->_tmp6_;
	_data_->_tmp8_ = _data_->local_properties;
	_data_->_tmp9_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	if (_data_->_tmp10_ == NULL) {
		_data_->_tmp7_ = TRUE;
	} else {
		_data_->_tmp11_ = _data_->local_properties;
		_data_->_tmp12_ = geary_imap_folder_properties_get_uid_validity (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp7_ = _data_->_tmp13_ == NULL;
	}
	if (_data_->_tmp7_) {
		_data_->_tmp14_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_tmp16_ = _data_->local_properties;
		_data_->_tmp17_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp16_);
		_data_->_tmp18_ = _data_->_tmp17_;
		_data_->_tmp19_ = bool_to_string (_data_->_tmp18_ == NULL);
		_data_->_tmp20_ = _data_->_tmp19_;
		_data_->_tmp21_ = _data_->local_properties;
		_data_->_tmp22_ = geary_imap_folder_properties_get_uid_validity (_data_->_tmp21_);
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_tmp24_ = bool_to_string (_data_->_tmp23_ == NULL);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_tmp26_ = g_error_new (GEARY_IMAP_ERROR, GEARY_IMAP_ERROR_NOT_SUPPORTED, "%s: Unable to verify UIDs: missing local UIDNEXT (%s) and/or UIDVALIDI" \
"TY (%s)", _data_->_tmp15_, _data_->_tmp20_, _data_->_tmp25_);
		_data_->_tmp27_ = _data_->_tmp26_;
		_g_free0 (_data_->_tmp25_);
		_g_free0 (_data_->_tmp20_);
		_g_free0 (_data_->_tmp15_);
		_data_->_inner_error0_ = _data_->_tmp27_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp29_ = _data_->remote_properties;
	_data_->_tmp30_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp29_);
	_data_->_tmp31_ = _data_->_tmp30_;
	if (_data_->_tmp31_ == NULL) {
		_data_->_tmp28_ = TRUE;
	} else {
		_data_->_tmp32_ = _data_->remote_properties;
		_data_->_tmp33_ = geary_imap_folder_properties_get_uid_validity (_data_->_tmp32_);
		_data_->_tmp34_ = _data_->_tmp33_;
		_data_->_tmp28_ = _data_->_tmp34_ == NULL;
	}
	if (_data_->_tmp28_) {
		_data_->_tmp35_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_data_->_tmp36_ = _data_->_tmp35_;
		_data_->_tmp37_ = _data_->remote_properties;
		_data_->_tmp38_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp37_);
		_data_->_tmp39_ = _data_->_tmp38_;
		_data_->_tmp40_ = bool_to_string (_data_->_tmp39_ == NULL);
		_data_->_tmp41_ = _data_->_tmp40_;
		_data_->_tmp42_ = _data_->remote_properties;
		_data_->_tmp43_ = geary_imap_folder_properties_get_uid_validity (_data_->_tmp42_);
		_data_->_tmp44_ = _data_->_tmp43_;
		_data_->_tmp45_ = bool_to_string (_data_->_tmp44_ == NULL);
		_data_->_tmp46_ = _data_->_tmp45_;
		_data_->_tmp47_ = g_error_new (GEARY_IMAP_ERROR, GEARY_IMAP_ERROR_NOT_SUPPORTED, "%s: Unable to verify UIDs: missing remote UIDNEXT (%s) and/or UIDVALID" \
"ITY (%s)", _data_->_tmp36_, _data_->_tmp41_, _data_->_tmp46_);
		_data_->_tmp48_ = _data_->_tmp47_;
		_g_free0 (_data_->_tmp46_);
		_g_free0 (_data_->_tmp41_);
		_g_free0 (_data_->_tmp36_);
		_data_->_inner_error0_ = _data_->_tmp48_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp49_ = _data_->local_properties;
	_data_->_tmp50_ = geary_imap_folder_properties_get_uid_validity (_data_->_tmp49_);
	_data_->_tmp51_ = _data_->_tmp50_;
	_data_->_tmp52_ = geary_message_data_int64_message_data_get_value (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp51_, GEARY_MESSAGE_DATA_TYPE_INT64_MESSAGE_DATA, GearyMessageDataInt64MessageData));
	_data_->_tmp53_ = _data_->_tmp52_;
	_data_->_tmp54_ = _data_->remote_properties;
	_data_->_tmp55_ = geary_imap_folder_properties_get_uid_validity (_data_->_tmp54_);
	_data_->_tmp56_ = _data_->_tmp55_;
	_data_->_tmp57_ = geary_message_data_int64_message_data_get_value (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp56_, GEARY_MESSAGE_DATA_TYPE_INT64_MESSAGE_DATA, GearyMessageDataInt64MessageData));
	_data_->_tmp58_ = _data_->_tmp57_;
	if (_data_->_tmp53_ != _data_->_tmp58_) {
		_data_->_tmp59_ = _data_->local_properties;
		_data_->_tmp60_ = geary_imap_folder_properties_get_uid_validity (_data_->_tmp59_);
		_data_->_tmp61_ = _data_->_tmp60_;
		_data_->_tmp62_ = geary_message_data_int64_message_data_get_value (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp61_, GEARY_MESSAGE_DATA_TYPE_INT64_MESSAGE_DATA, GearyMessageDataInt64MessageData));
		_data_->_tmp63_ = _data_->_tmp62_;
		_data_->_tmp64_ = g_strdup_printf ("%" G_GINT64_FORMAT, _data_->_tmp63_);
		_data_->_tmp65_ = _data_->_tmp64_;
		_data_->_tmp66_ = _data_->remote_properties;
		_data_->_tmp67_ = geary_imap_folder_properties_get_uid_validity (_data_->_tmp66_);
		_data_->_tmp68_ = _data_->_tmp67_;
		_data_->_tmp69_ = geary_message_data_int64_message_data_get_value (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp68_, GEARY_MESSAGE_DATA_TYPE_INT64_MESSAGE_DATA, GearyMessageDataInt64MessageData));
		_data_->_tmp70_ = _data_->_tmp69_;
		_data_->_tmp71_ = g_strdup_printf ("%" G_GINT64_FORMAT, _data_->_tmp70_);
		_data_->_tmp72_ = _data_->_tmp71_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "UID validity changed, detaching all email: %s -> %s", _data_->_tmp65_, _data_->_tmp72_);
		_g_free0 (_data_->_tmp72_);
		_g_free0 (_data_->_tmp65_);
		_data_->_state_ = 1;
		geary_imap_engine_minimal_folder_detach_all_emails_async (_data_->self, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
		return FALSE;
		_state_1:
		geary_imap_engine_minimal_folder_detach_all_emails_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->remote_properties);
			_g_object_unref0 (_data_->local_properties);
			block98_data_unref (_data_->_data98_);
			_data_->_data98_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		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_->_tmp73_ = _data_->self->priv->_local_folder;
	_data_->_state_ = 2;
	geary_imap_db_folder_get_earliest_id_async (_data_->_tmp73_, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp74_ = geary_imap_db_folder_get_earliest_id_finish (_data_->_tmp73_, _data_->_res_, &_data_->_inner_error0_);
	_data_->local_earliest_id = _data_->_tmp74_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp75_ = _data_->self->priv->_local_folder;
	_data_->_state_ = 3;
	geary_imap_db_folder_get_latest_id_async (_data_->_tmp75_, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
	return FALSE;
	_state_3:
	_data_->_tmp76_ = geary_imap_db_folder_get_latest_id_finish (_data_->_tmp75_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_data98_->local_latest_id = _data_->_tmp76_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	geary_imap_engine_minimal_folder_check_open (_data_->self, "normalize_folders (local earliest/latest UID)", &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp78_ = _data_->local_earliest_id;
	if (_data_->_tmp78_ == NULL) {
		_data_->_tmp77_ = TRUE;
	} else {
		_data_->_tmp79_ = _data_->_data98_->local_latest_id;
		_data_->_tmp77_ = _data_->_tmp79_ == NULL;
	}
	if (_data_->_tmp77_) {
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "local store empty, nothing to normalize");
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		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_->_tmp80_ = _data_->self->priv->_local_folder;
	_data_->_state_ = 4;
	geary_imap_db_folder_get_marked_ids_async (_data_->_tmp80_, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
	return FALSE;
	_state_4:
	_data_->_tmp81_ = geary_imap_db_folder_get_marked_ids_finish (_data_->_tmp80_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_data98_->already_marked_ids = _data_->_tmp81_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp82_ = gee_hash_set_new (GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->to_be_removed = _data_->_tmp82_;
	_data_->_tmp83_ = _data_->self->priv->_replay_queue;
	_data_->_tmp84_ = _data_->to_be_removed;
	geary_imap_engine_replay_queue_get_ids_to_be_remote_removed (_data_->_tmp83_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp84_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp85_ = _data_->_data98_->already_marked_ids;
	if (_data_->_tmp85_ != NULL) {
		_data_->_tmp86_ = _data_->_data98_->already_marked_ids;
		_data_->_tmp87_ = _data_->to_be_removed;
		gee_collection_remove_all (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp86_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp87_, GEE_TYPE_COLLECTION, GeeCollection));
	}
	_data_->_tmp89_ = _data_->_data98_->already_marked_ids;
	if (_data_->_tmp89_ != NULL) {
		_data_->_tmp90_ = _data_->_data98_->already_marked_ids;
		_data_->_tmp91_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp90_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp92_ = _data_->_tmp91_;
		_data_->_tmp88_ = _data_->_tmp92_ > 0;
	} else {
		_data_->_tmp88_ = FALSE;
	}
	_data_->is_dirty = _data_->_tmp88_;
	if (_data_->is_dirty) {
		_data_->_tmp93_ = _data_->_data98_->already_marked_ids;
		_data_->_tmp94_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp93_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp95_ = _data_->_tmp94_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "%d remove markers found, folder is dirty", _data_->_tmp95_);
	}
	_data_->_tmp96_ = _data_->remote_properties;
	_data_->_tmp97_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp96_);
	_data_->_tmp98_ = _data_->_tmp97_;
	_data_->_tmp99_ = geary_imap_uid_previous (_data_->_tmp98_, TRUE);
	_data_->last_uid = _data_->_tmp99_;
	_data_->_tmp101_ = _data_->local_earliest_id;
	_data_->_tmp102_ = geary_imap_db_email_identifier_get_uid (_data_->_tmp101_);
	_data_->_tmp103_ = _data_->_tmp102_;
	_data_->_tmp104_ = _data_->last_uid;
	if (geary_imap_uid_compare_to (_data_->_tmp103_, _data_->_tmp104_) > 0) {
		_data_->_tmp100_ = TRUE;
	} else {
		_data_->_tmp105_ = _data_->_data98_->local_latest_id;
		_data_->_tmp106_ = geary_imap_db_email_identifier_get_uid (_data_->_tmp105_);
		_data_->_tmp107_ = _data_->_tmp106_;
		_data_->_tmp108_ = _data_->last_uid;
		_data_->_tmp100_ = geary_imap_uid_compare_to (_data_->_tmp107_, _data_->_tmp108_) > 0;
	}
	if (_data_->_tmp100_) {
		_data_->_tmp109_ = _data_->local_earliest_id;
		_data_->_tmp110_ = geary_imap_db_email_identifier_get_uid (_data_->_tmp109_);
		_data_->_tmp111_ = _data_->_tmp110_;
		_data_->_tmp112_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp111_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp113_ = _data_->_tmp112_;
		_data_->_tmp114_ = _data_->_data98_->local_latest_id;
		_data_->_tmp115_ = geary_imap_db_email_identifier_get_uid (_data_->_tmp114_);
		_data_->_tmp116_ = _data_->_tmp115_;
		_data_->_tmp117_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp116_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp118_ = _data_->_tmp117_;
		_data_->_tmp119_ = _data_->last_uid;
		_data_->_tmp120_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp119_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp121_ = _data_->_tmp120_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Local UID(s) higher than remote UIDNEXT, detaching all email: %s/%s re" \
"mote=%s", _data_->_tmp113_, _data_->_tmp118_, _data_->_tmp121_);
		_g_free0 (_data_->_tmp121_);
		_g_free0 (_data_->_tmp118_);
		_g_free0 (_data_->_tmp113_);
		_data_->_state_ = 5;
		geary_imap_engine_minimal_folder_detach_all_emails_async (_data_->self, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
		return FALSE;
		_state_5:
		geary_imap_engine_minimal_folder_detach_all_emails_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->last_uid);
			_g_object_unref0 (_data_->to_be_removed);
			_g_object_unref0 (_data_->local_earliest_id);
			_g_object_unref0 (_data_->remote_properties);
			_g_object_unref0 (_data_->local_properties);
			block98_data_unref (_data_->_data98_);
			_data_->_data98_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		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_->_tmp122_ = _data_->remote_properties;
	_data_->_tmp123_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp122_);
	_data_->_tmp124_ = _data_->_tmp123_;
	_data_->_tmp125_ = geary_message_data_int64_message_data_get_value (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp124_, GEARY_MESSAGE_DATA_TYPE_INT64_MESSAGE_DATA, GearyMessageDataInt64MessageData));
	_data_->_tmp126_ = _data_->_tmp125_;
	_data_->_tmp127_ = _data_->local_properties;
	_data_->_tmp128_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp127_);
	_data_->_tmp129_ = _data_->_tmp128_;
	_data_->_tmp130_ = geary_message_data_int64_message_data_get_value (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp129_, GEARY_MESSAGE_DATA_TYPE_INT64_MESSAGE_DATA, GearyMessageDataInt64MessageData));
	_data_->_tmp131_ = _data_->_tmp130_;
	_data_->uidnext_diff = _data_->_tmp126_ - _data_->_tmp131_;
	_data_->_tmp133_ = _data_->local_properties;
	_data_->_tmp134_ = geary_imap_folder_properties_get_select_examine_messages (_data_->_tmp133_);
	_data_->_tmp135_ = _data_->_tmp134_;
	if (_data_->_tmp135_ >= 0) {
		_data_->_tmp136_ = _data_->local_properties;
		_data_->_tmp137_ = geary_imap_folder_properties_get_select_examine_messages (_data_->_tmp136_);
		_data_->_tmp138_ = _data_->_tmp137_;
		_data_->_tmp132_ = _data_->_tmp138_;
	} else {
		_data_->_tmp132_ = 0;
	}
	_data_->local_message_count = _data_->_tmp132_;
	_data_->_tmp140_ = _data_->remote_properties;
	_data_->_tmp141_ = geary_imap_folder_properties_get_select_examine_messages (_data_->_tmp140_);
	_data_->_tmp142_ = _data_->_tmp141_;
	if (_data_->_tmp142_ >= 0) {
		_data_->_tmp143_ = _data_->remote_properties;
		_data_->_tmp144_ = geary_imap_folder_properties_get_select_examine_messages (_data_->_tmp143_);
		_data_->_tmp145_ = _data_->_tmp144_;
		_data_->_tmp139_ = _data_->_tmp145_;
	} else {
		_data_->_tmp139_ = 0;
	}
	_data_->remote_message_count = _data_->_tmp139_;
	if (!_data_->is_dirty) {
		_data_->_tmp147_ = _data_->uidnext_diff == ((gint64) 0);
	} else {
		_data_->_tmp147_ = FALSE;
	}
	if (_data_->_tmp147_) {
		_data_->_tmp146_ = _data_->local_message_count == _data_->remote_message_count;
	} else {
		_data_->_tmp146_ = FALSE;
	}
	if (_data_->_tmp146_) {
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "No messages added/removed since last opened, normalization completed");
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		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;
	}
	if (!_data_->is_dirty) {
		_data_->_tmp148_ = _data_->uidnext_diff == ((gint64) (_data_->remote_message_count - _data_->local_message_count));
	} else {
		_data_->_tmp148_ = FALSE;
	}
	if (_data_->_tmp148_) {
		_data_->_tmp149_ = _data_->_data98_->local_latest_id;
		_data_->_tmp150_ = geary_imap_db_email_identifier_get_uid (_data_->_tmp149_);
		_data_->_tmp151_ = _data_->_tmp150_;
		_data_->_tmp152_ = geary_imap_uid_next (_data_->_tmp151_, TRUE);
		_g_object_unref0 (_data_->first_uid);
		_data_->first_uid = _data_->_tmp152_;
		_data_->_tmp153_ = _data_->local_properties;
		_data_->_tmp154_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp153_);
		_data_->_tmp155_ = _data_->_tmp154_;
		_data_->_tmp156_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp155_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp157_ = _data_->_tmp156_;
		_data_->_tmp158_ = _data_->remote_properties;
		_data_->_tmp159_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp158_);
		_data_->_tmp160_ = _data_->_tmp159_;
		_data_->_tmp161_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp160_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp162_ = _data_->_tmp161_;
		_data_->_tmp163_ = _data_->local_properties;
		_data_->_tmp164_ = geary_imap_folder_properties_get_select_examine_messages (_data_->_tmp163_);
		_data_->_tmp165_ = _data_->_tmp164_;
		_data_->_tmp166_ = _data_->remote_properties;
		_data_->_tmp167_ = geary_imap_folder_properties_get_select_examine_messages (_data_->_tmp166_);
		_data_->_tmp168_ = _data_->_tmp167_;
		_data_->_tmp169_ = g_strdup_printf ("%" G_GINT64_FORMAT, _data_->uidnext_diff);
		_data_->_tmp170_ = _data_->_tmp169_;
		_data_->_tmp171_ = _data_->first_uid;
		_data_->_tmp172_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp171_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp173_ = _data_->_tmp172_;
		_data_->_tmp174_ = _data_->last_uid;
		_data_->_tmp175_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp174_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp176_ = _data_->_tmp175_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Messages only appended (local/remote UIDNEXT=%s/%s total=%d/%d diff=%s" \
"), gathering mail UIDs %s:%s", _data_->_tmp157_, _data_->_tmp162_, _data_->_tmp165_, _data_->_tmp168_, _data_->_tmp170_, _data_->_tmp173_, _data_->_tmp176_);
		_g_free0 (_data_->_tmp176_);
		_g_free0 (_data_->_tmp173_);
		_g_free0 (_data_->_tmp170_);
		_g_free0 (_data_->_tmp162_);
		_g_free0 (_data_->_tmp157_);
	} else {
		_data_->_tmp177_ = _data_->local_earliest_id;
		_data_->_tmp178_ = geary_imap_db_email_identifier_get_uid (_data_->_tmp177_);
		_data_->_tmp179_ = _data_->_tmp178_;
		_data_->_tmp180_ = _g_object_ref0 (_data_->_tmp179_);
		_g_object_unref0 (_data_->first_uid);
		_data_->first_uid = _data_->_tmp180_;
		_data_->_tmp181_ = _data_->local_properties;
		_data_->_tmp182_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp181_);
		_data_->_tmp183_ = _data_->_tmp182_;
		_data_->_tmp184_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp183_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp185_ = _data_->_tmp184_;
		_data_->_tmp186_ = _data_->remote_properties;
		_data_->_tmp187_ = geary_imap_folder_properties_get_uid_next (_data_->_tmp186_);
		_data_->_tmp188_ = _data_->_tmp187_;
		_data_->_tmp189_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp188_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp190_ = _data_->_tmp189_;
		_data_->_tmp191_ = _data_->local_properties;
		_data_->_tmp192_ = geary_imap_folder_properties_get_select_examine_messages (_data_->_tmp191_);
		_data_->_tmp193_ = _data_->_tmp192_;
		_data_->_tmp194_ = _data_->remote_properties;
		_data_->_tmp195_ = geary_imap_folder_properties_get_select_examine_messages (_data_->_tmp194_);
		_data_->_tmp196_ = _data_->_tmp195_;
		_data_->_tmp197_ = g_strdup_printf ("%" G_GINT64_FORMAT, _data_->uidnext_diff);
		_data_->_tmp198_ = _data_->_tmp197_;
		_data_->_tmp199_ = _data_->first_uid;
		_data_->_tmp200_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp199_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp201_ = _data_->_tmp200_;
		_data_->_tmp202_ = _data_->last_uid;
		_data_->_tmp203_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp202_, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
		_data_->_tmp204_ = _data_->_tmp203_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Messages appended/removed (local/remote UIDNEXT=%s/%s total=%d/%d diff" \
"=%s), gathering mail UIDs %s:%s", _data_->_tmp185_, _data_->_tmp190_, _data_->_tmp193_, _data_->_tmp196_, _data_->_tmp198_, _data_->_tmp201_, _data_->_tmp204_);
		_g_free0 (_data_->_tmp204_);
		_g_free0 (_data_->_tmp201_);
		_g_free0 (_data_->_tmp198_);
		_g_free0 (_data_->_tmp190_);
		_g_free0 (_data_->_tmp185_);
	}
	_data_->_tmp205_ = _data_->self->priv->_local_folder;
	_data_->_tmp206_ = _data_->first_uid;
	_data_->_tmp207_ = _data_->last_uid;
	_data_->_state_ = 6;
	geary_imap_db_folder_list_uids_by_range_async (_data_->_tmp205_, _data_->_tmp206_, _data_->_tmp207_, TRUE, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
	return FALSE;
	_state_6:
	_data_->_tmp208_ = geary_imap_db_folder_list_uids_by_range_finish (_data_->_tmp205_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_data98_->local_uids = _data_->_tmp208_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp209_ = _data_->_data98_->local_uids;
	if (_data_->_tmp209_ == NULL) {
		_data_->_tmp210_ = gee_hash_set_new (GEARY_IMAP_TYPE_UID, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
		_g_object_unref0 (_data_->_data98_->local_uids);
		_data_->_data98_->local_uids = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp210_, GEE_TYPE_SET, GeeSet);
	}
	geary_imap_engine_minimal_folder_check_open (_data_->self, "normalize_folders (list local)", &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp211_ = _data_->first_uid;
	_data_->_tmp212_ = _data_->last_uid;
	_data_->_tmp213_ = geary_imap_message_set_new_uid_range (_data_->_tmp211_, _data_->_tmp212_);
	_data_->_tmp214_ = _data_->_tmp213_;
	_data_->_state_ = 7;
	geary_imap_folder_session_list_uids_async (_data_->session, _data_->_tmp214_, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
	return FALSE;
	_state_7:
	_data_->_tmp215_ = geary_imap_folder_session_list_uids_finish (_data_->session, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp216_ = _data_->_tmp215_;
	_g_object_unref0 (_data_->_tmp214_);
	_data_->_data98_->remote_uids = _data_->_tmp216_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp217_ = _data_->_data98_->remote_uids;
	if (_data_->_tmp217_ == NULL) {
		_data_->_tmp218_ = gee_hash_set_new (GEARY_IMAP_TYPE_UID, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
		_g_object_unref0 (_data_->_data98_->remote_uids);
		_data_->_data98_->remote_uids = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp218_, GEE_TYPE_SET, GeeSet);
	}
	geary_imap_engine_minimal_folder_check_open (_data_->self, "normalize_folders (list remote)", &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp219_ = _data_->_data98_->local_uids;
	_data_->_tmp220_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp219_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp221_ = _data_->_tmp220_;
	_data_->_tmp222_ = _data_->_data98_->remote_uids;
	_data_->_tmp223_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp222_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp224_ = _data_->_tmp223_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Loaded local (%d) and remote (%d) UIDs, normalizing...", _data_->_tmp221_, _data_->_tmp224_);
	_data_->_tmp225_ = gee_hash_set_new (GEARY_IMAP_TYPE_UID, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data98_->removed_uids = _data_->_tmp225_;
	_data_->_tmp226_ = gee_hash_set_new (GEARY_IMAP_TYPE_UID, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data98_->appended_uids = _data_->_tmp226_;
	_data_->_tmp227_ = gee_hash_set_new (GEARY_IMAP_TYPE_UID, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data98_->inserted_uids = _data_->_tmp227_;
	_data_->_tmp228_ = geary_nonblocking_concurrent_get_global ();
	_data_->_tmp229_ = _data_->_tmp228_;
	_data_->_state_ = 8;
	geary_nonblocking_concurrent_schedule_async (_data_->_tmp229_, ___lambda113__geary_nonblocking_concurrent_concurrent_callback, _data_->_data98_, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
	return FALSE;
	_state_8:
	geary_nonblocking_concurrent_schedule_finish (_data_->_tmp229_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp230_ = _data_->_data98_->removed_uids;
	_data_->_tmp231_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp230_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
	_data_->_tmp232_ = _data_->_tmp231_;
	_data_->_tmp233_ = _data_->_data98_->appended_uids;
	_data_->_tmp234_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp233_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
	_data_->_tmp235_ = _data_->_tmp234_;
	_data_->_tmp236_ = _data_->_data98_->inserted_uids;
	_data_->_tmp237_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp236_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
	_data_->_tmp238_ = _data_->_tmp237_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Changes since last seen: removed=%d appended=%d inserted=%d", _data_->_tmp232_, _data_->_tmp235_, _data_->_tmp238_);
	_data_->_tmp239_ = gee_array_list_new (GEARY_TYPE_EMAIL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data_->to_create = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp239_, GEE_TYPE_LIST, GeeList);
	_data_->_tmp240_ = _data_->_data98_->remote_uids;
	_data_->_tmp241_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp240_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp242_ = _data_->_tmp241_;
	if (_data_->_tmp242_ > 0) {
		_data_->_tmp243_ = _data_->_data98_->remote_uids;
		_data_->_tmp244_ = geary_imap_message_set_uid_sparse (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp243_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->msg_sets = _data_->_tmp244_;
		{
			_data_->_tmp245_ = _data_->msg_sets;
			_data_->_msg_set_list = _data_->_tmp245_;
			_data_->_tmp246_ = _data_->_msg_set_list;
			_data_->_tmp247_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp246_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp248_ = _data_->_tmp247_;
			_data_->_msg_set_size = _data_->_tmp248_;
			_data_->_msg_set_index = -1;
			while (TRUE) {
				_data_->_msg_set_index = _data_->_msg_set_index + 1;
				_data_->_tmp249_ = _data_->_msg_set_index;
				_data_->_tmp250_ = _data_->_msg_set_size;
				if (!(_data_->_tmp249_ < _data_->_tmp250_)) {
					break;
				}
				_data_->_tmp251_ = _data_->_msg_set_list;
				_data_->_tmp252_ = gee_list_get (_data_->_tmp251_, _data_->_msg_set_index);
				_data_->msg_set = (GearyImapMessageSet*) _data_->_tmp252_;
				_data_->_tmp253_ = _data_->msg_set;
				_data_->_state_ = 9;
				geary_imap_folder_session_list_email_async (_data_->session, _data_->_tmp253_, GEARY_IMAP_DB_FOLDER_REQUIRED_FIELDS, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
				return FALSE;
				_state_9:
				_data_->_tmp254_ = geary_imap_folder_session_list_email_finish (_data_->session, _data_->_res_, &_data_->_inner_error0_);
				_data_->list = _data_->_tmp254_;
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
					_g_object_unref0 (_data_->msg_set);
					_g_object_unref0 (_data_->msg_sets);
					_g_object_unref0 (_data_->to_create);
					_g_object_unref0 (_data_->first_uid);
					_g_object_unref0 (_data_->last_uid);
					_g_object_unref0 (_data_->to_be_removed);
					_g_object_unref0 (_data_->local_earliest_id);
					_g_object_unref0 (_data_->remote_properties);
					_g_object_unref0 (_data_->local_properties);
					block98_data_unref (_data_->_data98_);
					_data_->_data98_ = NULL;
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_data_->_tmp256_ = _data_->list;
				if (_data_->_tmp256_ != NULL) {
					_data_->_tmp257_ = _data_->list;
					_data_->_tmp258_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp257_, GEE_TYPE_COLLECTION, GeeCollection));
					_data_->_tmp259_ = _data_->_tmp258_;
					_data_->_tmp255_ = _data_->_tmp259_ > 0;
				} else {
					_data_->_tmp255_ = FALSE;
				}
				if (_data_->_tmp255_) {
					_data_->_tmp260_ = _data_->to_create;
					_data_->_tmp261_ = _data_->list;
					gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp260_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp261_, GEE_TYPE_COLLECTION, GeeCollection));
				}
				_g_object_unref0 (_data_->list);
				_g_object_unref0 (_data_->msg_set);
			}
		}
		_g_object_unref0 (_data_->msg_sets);
	}
	geary_imap_engine_minimal_folder_check_open (_data_->self, "normalize_folders (list remote appended/inserted required fields)", &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->to_create);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp262_ = gee_hash_set_new (GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data98_->appended_ids = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp262_, GEE_TYPE_SET, GeeSet);
	_data_->_tmp263_ = gee_hash_set_new (GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data98_->locally_appended_ids = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp263_, GEE_TYPE_SET, GeeSet);
	_data_->_tmp264_ = gee_hash_set_new (GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data98_->inserted_ids = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp264_, GEE_TYPE_SET, GeeSet);
	_data_->_tmp265_ = gee_hash_set_new (GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->_data98_->locally_inserted_ids = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp265_, GEE_TYPE_SET, GeeSet);
	_data_->_tmp266_ = _data_->to_create;
	_data_->_tmp267_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp266_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp268_ = _data_->_tmp267_;
	if (_data_->_tmp268_ > 0) {
		_data_->_data99_ = g_slice_new0 (Block99Data);
		_data_->_data99_->_ref_count_ = 1;
		_data_->_data99_->_data98_ = block98_data_ref (_data_->_data98_);
		_data_->_tmp269_ = _data_->self->priv->_local_folder;
		_data_->_tmp270_ = _data_->to_create;
		_data_->_tmp271_ = _data_->self->priv->_harvester;
		_data_->_state_ = 10;
		geary_imap_db_folder_create_or_merge_email_async (_data_->_tmp269_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp270_, GEE_TYPE_COLLECTION, GeeCollection), FALSE, _data_->_tmp271_, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
		return FALSE;
		_state_10:
		_data_->_tmp272_ = geary_imap_db_folder_create_or_merge_email_finish (_data_->_tmp269_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_data99_->created_or_merged = _data_->_tmp272_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			block99_data_unref (_data_->_data99_);
			_data_->_data99_ = NULL;
			_g_object_unref0 (_data_->to_create);
			_g_object_unref0 (_data_->first_uid);
			_g_object_unref0 (_data_->last_uid);
			_g_object_unref0 (_data_->to_be_removed);
			_g_object_unref0 (_data_->local_earliest_id);
			_g_object_unref0 (_data_->remote_properties);
			_g_object_unref0 (_data_->local_properties);
			block98_data_unref (_data_->_data98_);
			_data_->_data98_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp273_ = _data_->_data99_->created_or_merged;
		_vala_assert (_data_->_tmp273_ != NULL, "created_or_merged != null");
		_data_->_tmp274_ = geary_nonblocking_concurrent_get_global ();
		_data_->_tmp275_ = _data_->_tmp274_;
		_data_->_state_ = 11;
		geary_nonblocking_concurrent_schedule_async (_data_->_tmp275_, ____lambda114__geary_nonblocking_concurrent_concurrent_callback, _data_->_data99_, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
		return FALSE;
		_state_11:
		geary_nonblocking_concurrent_schedule_finish (_data_->_tmp275_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			block99_data_unref (_data_->_data99_);
			_data_->_data99_ = NULL;
			_g_object_unref0 (_data_->to_create);
			_g_object_unref0 (_data_->first_uid);
			_g_object_unref0 (_data_->last_uid);
			_g_object_unref0 (_data_->to_be_removed);
			_g_object_unref0 (_data_->local_earliest_id);
			_g_object_unref0 (_data_->remote_properties);
			_g_object_unref0 (_data_->local_properties);
			block98_data_unref (_data_->_data98_);
			_data_->_data98_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp276_ = _data_->_data99_->created_or_merged;
		_data_->_tmp277_ = gee_map_get_size (_data_->_tmp276_);
		_data_->_tmp278_ = _data_->_tmp277_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Finished creating/merging %d emails", _data_->_tmp278_);
		block99_data_unref (_data_->_data99_);
		_data_->_data99_ = NULL;
	}
	geary_imap_engine_minimal_folder_check_open (_data_->self, "normalize_folders (created/merged appended/inserted emails)", &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->to_create);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->removed_ids = NULL;
	_data_->_tmp279_ = _data_->_data98_->removed_uids;
	_data_->_tmp280_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp279_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
	_data_->_tmp281_ = _data_->_tmp280_;
	if (_data_->_tmp281_ > 0) {
		_data_->_tmp283_ = _data_->self->priv->_local_folder;
		_data_->_tmp284_ = _data_->_data98_->removed_uids;
		_data_->_state_ = 12;
		geary_imap_db_folder_get_ids_async (_data_->_tmp283_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp284_, GEE_TYPE_COLLECTION, GeeCollection), GEARY_IMAP_DB_FOLDER_LIST_FLAGS_INCLUDE_MARKED_FOR_REMOVE, _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
		return FALSE;
		_state_12:
		_data_->_tmp285_ = geary_imap_db_folder_get_ids_finish (_data_->_tmp283_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp282_ = _data_->_tmp285_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->removed_ids);
			_g_object_unref0 (_data_->to_create);
			_g_object_unref0 (_data_->first_uid);
			_g_object_unref0 (_data_->last_uid);
			_g_object_unref0 (_data_->to_be_removed);
			_g_object_unref0 (_data_->local_earliest_id);
			_g_object_unref0 (_data_->remote_properties);
			_g_object_unref0 (_data_->local_properties);
			block98_data_unref (_data_->_data98_);
			_data_->_data98_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp286_ = _data_->_tmp282_;
		_data_->_tmp282_ = NULL;
		_g_object_unref0 (_data_->removed_ids);
		_data_->removed_ids = _data_->_tmp286_;
		_data_->_tmp288_ = _data_->removed_ids;
		if (_data_->_tmp288_ != NULL) {
			_data_->_tmp289_ = _data_->removed_ids;
			_data_->_tmp290_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp289_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp291_ = _data_->_tmp290_;
			_data_->_tmp287_ = _data_->_tmp291_ > 0;
		} else {
			_data_->_tmp287_ = FALSE;
		}
		if (_data_->_tmp287_) {
			_data_->_tmp292_ = _data_->self->priv->_local_folder;
			_data_->_tmp293_ = _data_->removed_ids;
			_data_->_state_ = 13;
			geary_imap_db_folder_detach_multiple_emails_async (_data_->_tmp292_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp293_, GEE_TYPE_COLLECTION, GeeCollection), _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
			return FALSE;
			_state_13:
			geary_imap_db_folder_detach_multiple_emails_finish (_data_->_tmp292_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->_tmp282_);
				_g_object_unref0 (_data_->removed_ids);
				_g_object_unref0 (_data_->to_create);
				_g_object_unref0 (_data_->first_uid);
				_g_object_unref0 (_data_->last_uid);
				_g_object_unref0 (_data_->to_be_removed);
				_g_object_unref0 (_data_->local_earliest_id);
				_g_object_unref0 (_data_->remote_properties);
				_g_object_unref0 (_data_->local_properties);
				block98_data_unref (_data_->_data98_);
				_data_->_data98_ = NULL;
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
		_g_object_unref0 (_data_->_tmp282_);
	}
	geary_imap_engine_minimal_folder_check_open (_data_->self, "normalize_folders (removed emails)", &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->removed_ids);
		_g_object_unref0 (_data_->to_create);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp294_ = _data_->self->priv->_local_folder;
	_data_->_tmp295_ = _data_->to_be_removed;
	_data_->_state_ = 14;
	geary_imap_db_folder_clear_remove_markers_async (_data_->_tmp294_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp295_, GEE_TYPE_COLLECTION, GeeCollection), _data_->cancellable, geary_imap_engine_minimal_folder_normalize_folders_ready, _data_);
	return FALSE;
	_state_14:
	geary_imap_db_folder_clear_remove_markers_finish (_data_->_tmp294_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->removed_ids);
		_g_object_unref0 (_data_->to_create);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	if (g_cancellable_is_cancelled (_data_->cancellable)) {
		_g_object_unref0 (_data_->removed_ids);
		_g_object_unref0 (_data_->to_create);
		_g_object_unref0 (_data_->first_uid);
		_g_object_unref0 (_data_->last_uid);
		_g_object_unref0 (_data_->to_be_removed);
		_g_object_unref0 (_data_->local_earliest_id);
		_g_object_unref0 (_data_->remote_properties);
		_g_object_unref0 (_data_->local_properties);
		block98_data_unref (_data_->_data98_);
		_data_->_data98_ = NULL;
		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_->count_change_reason = GEARY_FOLDER_COUNT_CHANGE_REASON_NONE;
	_data_->_tmp297_ = _data_->removed_ids;
	if (_data_->_tmp297_ != NULL) {
		_data_->_tmp298_ = _data_->removed_ids;
		_data_->_tmp299_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp298_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp300_ = _data_->_tmp299_;
		_data_->_tmp296_ = _data_->_tmp300_ > 0;
	} else {
		_data_->_tmp296_ = FALSE;
	}
	if (_data_->_tmp296_) {
		_data_->_tmp301_ = _data_->self->priv->_replay_queue;
		_data_->_tmp302_ = _data_->removed_ids;
		geary_imap_engine_replay_queue_notify_remote_removed_ids (_data_->_tmp301_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp302_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp303_ = _data_->removed_ids;
		_data_->_tmp304_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp303_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp305_ = _data_->_tmp304_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Notifying of %d removed emails since last opened", _data_->_tmp305_);
		_data_->_tmp306_ = _data_->removed_ids;
		geary_folder_notify_email_removed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp306_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->count_change_reason |= GEARY_FOLDER_COUNT_CHANGE_REASON_REMOVED;
	}
	_data_->_tmp307_ = _data_->_data98_->inserted_ids;
	_data_->_tmp308_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp307_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp309_ = _data_->_tmp308_;
	if (_data_->_tmp309_ > 0) {
		_data_->_tmp310_ = _data_->_data98_->inserted_ids;
		_data_->_tmp311_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp310_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp312_ = _data_->_tmp311_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Notifying of %d inserted emails since last opened", _data_->_tmp312_);
		_data_->_tmp313_ = _data_->_data98_->inserted_ids;
		geary_folder_notify_email_inserted (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp313_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->count_change_reason |= GEARY_FOLDER_COUNT_CHANGE_REASON_INSERTED;
	}
	_data_->_tmp314_ = _data_->_data98_->locally_inserted_ids;
	_data_->_tmp315_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp314_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp316_ = _data_->_tmp315_;
	if (_data_->_tmp316_ > 0) {
		_data_->_tmp317_ = _data_->_data98_->locally_inserted_ids;
		_data_->_tmp318_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp317_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp319_ = _data_->_tmp318_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Notifying of %d locally inserted emails since last opened", _data_->_tmp319_);
		_data_->_tmp320_ = _data_->_data98_->locally_inserted_ids;
		geary_folder_notify_email_locally_inserted (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp320_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->count_change_reason |= GEARY_FOLDER_COUNT_CHANGE_REASON_INSERTED;
	}
	_data_->_tmp321_ = _data_->_data98_->appended_ids;
	_data_->_tmp322_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp321_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp323_ = _data_->_tmp322_;
	if (_data_->_tmp323_ > 0) {
		_data_->_tmp324_ = _data_->_data98_->appended_ids;
		_data_->_tmp325_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp324_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp326_ = _data_->_tmp325_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Notifying of %d appended emails since last opened", _data_->_tmp326_);
		_data_->_tmp327_ = _data_->_data98_->appended_ids;
		geary_folder_notify_email_appended (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp327_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->count_change_reason |= GEARY_FOLDER_COUNT_CHANGE_REASON_APPENDED;
	}
	_data_->_tmp328_ = _data_->_data98_->locally_appended_ids;
	_data_->_tmp329_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp328_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp330_ = _data_->_tmp329_;
	if (_data_->_tmp330_ > 0) {
		_data_->_tmp331_ = _data_->_data98_->locally_appended_ids;
		_data_->_tmp332_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp331_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp333_ = _data_->_tmp332_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Notifying of %d locally appended emails since last opened", _data_->_tmp333_);
		_data_->_tmp334_ = _data_->_data98_->locally_appended_ids;
		geary_folder_notify_email_locally_appended (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp334_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->count_change_reason |= GEARY_FOLDER_COUNT_CHANGE_REASON_APPENDED;
	}
	if (_data_->count_change_reason != GEARY_FOLDER_COUNT_CHANGE_REASON_NONE) {
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Notifying of %Xh count change reason (%d remote messages)", (guint) _data_->count_change_reason, _data_->remote_message_count);
		geary_folder_notify_email_count_changed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->remote_message_count, _data_->count_change_reason);
	}
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Completed normalize_folder");
	_g_object_unref0 (_data_->removed_ids);
	_g_object_unref0 (_data_->to_create);
	_g_object_unref0 (_data_->first_uid);
	_g_object_unref0 (_data_->last_uid);
	_g_object_unref0 (_data_->to_be_removed);
	_g_object_unref0 (_data_->local_earliest_id);
	_g_object_unref0 (_data_->remote_properties);
	_g_object_unref0 (_data_->local_properties);
	block98_data_unref (_data_->_data98_);
	_data_->_data98_ = NULL;
	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_minimal_folder_close_internal_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderCloseInternalData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderCloseInternalData, _data_);
}

void
geary_imap_engine_minimal_folder_close_internal (GearyImapEngineMinimalFolder* self,
                                                 GearyFolderCloseReason local_reason,
                                                 GearyFolderCloseReason remote_reason,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCloseInternalData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderCloseInternalData);
	_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_minimal_folder_close_internal_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->local_reason = local_reason;
	_data_->remote_reason = remote_reason;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_imap_engine_minimal_folder_close_internal_co (_data_);
}

gboolean
geary_imap_engine_minimal_folder_close_internal_finish (GearyImapEngineMinimalFolder* self,
                                                        GAsyncResult* _res_)
{
	gboolean result;
	GearyImapEngineMinimalFolderCloseInternalData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

/**
     * Closes the folder and the remote session.
     *
     * This should only be called from the replay queue.
     */
static Block100Data*
block100_data_ref (Block100Data* _data100_)
{
	g_atomic_int_inc (&_data100_->_ref_count_);
	return _data100_;
}

static void
block100_data_unref (void * _userdata_)
{
	Block100Data* _data100_;
	_data100_ = (Block100Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data100_->_ref_count_)) {
		GearyImapEngineMinimalFolder* self;
		self = _data100_->self;
		_g_object_unref0 (self);
		g_slice_free (Block100Data, _data100_);
	}
}

static void
geary_imap_engine_minimal_folder_close_internal_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCloseInternalData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_close_internal_co (_data_);
}

static void
____lambda129_ (Block100Data* _data100_,
                GObject* obj,
                GAsyncResult* res)
{
	GearyImapEngineMinimalFolder* self;
	GError* _inner_error0_ = NULL;
	self = _data100_->self;
	g_return_if_fail ((obj == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_OBJECT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (res, g_async_result_get_type ()));
	geary_imap_engine_minimal_folder_close_internal_locked_finish (self, res);
	{
		GearyNonblockingMutex* _tmp0_;
		_tmp0_ = self->priv->lifecycle_mutex;
		geary_nonblocking_mutex_release (_tmp0_, &_data100_->token, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
_____lambda129__gasync_ready_callback (GObject* source_object,
                                       GAsyncResult* res,
                                       gpointer self)
{
	____lambda129_ (self, source_object, res);
	block100_data_unref (self);
}

static gboolean
geary_imap_engine_minimal_folder_close_internal_co (GearyImapEngineMinimalFolderCloseInternalData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->is_closing = FALSE;
	{
		_data_->_data100_ = g_slice_new0 (Block100Data);
		_data_->_data100_->_ref_count_ = 1;
		_data_->_data100_->self = g_object_ref (_data_->self);
		_data_->_tmp0_ = _data_->self->priv->lifecycle_mutex;
		_data_->_state_ = 1;
		geary_nonblocking_mutex_claim_async (_data_->_tmp0_, _data_->cancellable, geary_imap_engine_minimal_folder_close_internal_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_data100_->token = geary_nonblocking_mutex_claim_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			block100_data_unref (_data_->_data100_);
			_data_->_data100_ = NULL;
			goto __catch0_g_error;
		}
		if (_data_->self->priv->open_count == 1) {
			_data_->is_closing = TRUE;
			geary_imap_engine_minimal_folder_close_internal_locked (_data_->self, _data_->local_reason, _data_->remote_reason, _data_->cancellable, _____lambda129__gasync_ready_callback, block100_data_ref (_data_->_data100_));
		} else {
			if (_data_->self->priv->open_count > 1) {
				_data_->self->priv->open_count = _data_->self->priv->open_count - 1;
			} else {
				_data_->is_closing = TRUE;
			}
			_data_->_tmp1_ = _data_->self->priv->lifecycle_mutex;
			geary_nonblocking_mutex_release (_data_->_tmp1_, &_data_->_data100_->token, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				block100_data_unref (_data_->_data100_);
				_data_->_data100_ = NULL;
				goto __catch0_g_error;
			}
		}
		block100_data_unref (_data_->_data100_);
		_data_->_data100_ = NULL;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->is_closing;
	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_minimal_folder_close_remote_session_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderCloseRemoteSessionData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderCloseRemoteSessionData, _data_);
}

static void
geary_imap_engine_minimal_folder_close_remote_session (GearyImapEngineMinimalFolder* self,
                                                       GearyFolderCloseReason remote_reason,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCloseRemoteSessionData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderCloseRemoteSessionData);
	_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_minimal_folder_close_remote_session_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->remote_reason = remote_reason;
	geary_imap_engine_minimal_folder_close_remote_session_co (_data_);
}

static void
geary_imap_engine_minimal_folder_close_remote_session_finish (GearyImapEngineMinimalFolder* self,
                                                              GAsyncResult* _res_)
{
	GearyImapEngineMinimalFolderCloseRemoteSessionData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/**
     * Unhooks the IMAP folder session and returns it to the account.
     */
static void
_geary_imap_engine_minimal_folder_on_remote_appended_geary_imap_folder_session_appended (GearyImapFolderSession* _sender,
                                                                                         gint count,
                                                                                         gpointer self)
{
	geary_imap_engine_minimal_folder_on_remote_appended ((GearyImapEngineMinimalFolder*) self, _sender, count);
}

static void
_geary_imap_engine_minimal_folder_on_remote_updated_geary_imap_folder_session_updated (GearyImapFolderSession* _sender,
                                                                                       GearyImapSequenceNumber* pos,
                                                                                       GearyImapFetchedData* data,
                                                                                       gpointer self)
{
	geary_imap_engine_minimal_folder_on_remote_updated ((GearyImapEngineMinimalFolder*) self, _sender, pos, data);
}

static void
_geary_imap_engine_minimal_folder_on_remote_removed_geary_imap_folder_session_removed (GearyImapFolderSession* _sender,
                                                                                       GearyImapSequenceNumber* pos,
                                                                                       gpointer self)
{
	geary_imap_engine_minimal_folder_on_remote_removed ((GearyImapEngineMinimalFolder*) self, _sender, pos);
}

static void
_geary_imap_engine_minimal_folder_on_remote_disconnected_geary_imap_session_object_disconnected (GearyImapSessionObject* _sender,
                                                                                                 GearyImapClientSessionDisconnectReason reason,
                                                                                                 gpointer self)
{
	geary_imap_engine_minimal_folder_on_remote_disconnected ((GearyImapEngineMinimalFolder*) self, reason);
}

static void
geary_imap_engine_minimal_folder_close_remote_session_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCloseRemoteSessionData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_close_remote_session_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_close_remote_session_co (GearyImapEngineMinimalFolderCloseRemoteSessionData* _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->open_cancellable;
	if (g_cancellable_is_cancelled (_data_->_tmp0_)) {
		geary_imap_engine_minimal_folder_notify_remote_waiters (_data_->self, FALSE);
	} else {
		_data_->_tmp1_ = _data_->self->priv->remote_wait_semaphore;
		geary_nonblocking_lock_reset (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp1_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
	}
	_data_->_tmp2_ = _data_->self->priv->remote_session;
	_data_->_tmp3_ = _g_object_ref0 (_data_->_tmp2_);
	_data_->session = _data_->_tmp3_;
	_g_object_unref0 (_data_->self->priv->remote_session);
	_data_->self->priv->remote_session = NULL;
	_data_->_tmp4_ = _data_->session;
	if (_data_->_tmp4_ != NULL) {
		_data_->_tmp5_ = _data_->session;
		g_signal_parse_name ("appended", GEARY_IMAP_TYPE_FOLDER_SESSION, &_data_->_tmp6_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_data_->_tmp5_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp6_, 0, NULL, (GCallback) _geary_imap_engine_minimal_folder_on_remote_appended_geary_imap_folder_session_appended, _data_->self);
		_data_->_tmp7_ = _data_->session;
		g_signal_parse_name ("updated", GEARY_IMAP_TYPE_FOLDER_SESSION, &_data_->_tmp8_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_data_->_tmp7_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp8_, 0, NULL, (GCallback) _geary_imap_engine_minimal_folder_on_remote_updated_geary_imap_folder_session_updated, _data_->self);
		_data_->_tmp9_ = _data_->session;
		g_signal_parse_name ("removed", GEARY_IMAP_TYPE_FOLDER_SESSION, &_data_->_tmp10_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_data_->_tmp9_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp10_, 0, NULL, (GCallback) _geary_imap_engine_minimal_folder_on_remote_removed_geary_imap_folder_session_removed, _data_->self);
		_data_->_tmp11_ = _data_->session;
		g_signal_parse_name ("disconnected", GEARY_IMAP_TYPE_SESSION_OBJECT, &_data_->_tmp12_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GEARY_IMAP_TYPE_SESSION_OBJECT, GearyImapSessionObject), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp12_, 0, NULL, (GCallback) _geary_imap_engine_minimal_folder_on_remote_disconnected_geary_imap_session_object_disconnected, _data_->self);
		_data_->_tmp13_ = _data_->self->priv->_properties;
		_data_->_tmp14_ = _data_->session;
		_data_->_tmp15_ = geary_imap_folder_session_get_folder (_data_->_tmp14_);
		_data_->_tmp16_ = _data_->_tmp15_;
		_data_->_tmp17_ = geary_imap_folder_get_properties (_data_->_tmp16_);
		_data_->_tmp18_ = _data_->_tmp17_;
		geary_aggregated_folder_properties_remove (_data_->_tmp13_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
		_data_->_tmp19_ = _data_->self->priv->_account;
		_data_->_tmp20_ = _data_->session;
		_data_->_state_ = 1;
		geary_imap_engine_generic_account_release_folder_session (_data_->_tmp19_, _data_->_tmp20_, geary_imap_engine_minimal_folder_close_remote_session_ready, _data_);
		return FALSE;
		_state_1:
		geary_imap_engine_generic_account_release_folder_session_finish (_data_->_tmp19_, _data_->_res_);
		geary_folder_notify_closed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->remote_reason);
	}
	_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_minimal_folder_open_locked_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderOpenLockedData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderOpenLockedData, _data_);
}

static void
geary_imap_engine_minimal_folder_open_locked (GearyImapEngineMinimalFolder* self,
                                              GearyFolderOpenFlags open_flags,
                                              GCancellable* cancellable,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	GearyImapEngineMinimalFolderOpenLockedData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderOpenLockedData);
	_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_minimal_folder_open_locked_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->open_flags = open_flags;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_imap_engine_minimal_folder_open_locked_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_open_locked_finish (GearyImapEngineMinimalFolder* self,
                                                     GAsyncResult* _res_,
                                                     GError** error)
{
	gboolean result;
	GearyImapEngineMinimalFolderOpenLockedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		gboolean _tmp0_ = FALSE;
		return _tmp0_;
	}
	result = _data_->result;
	return result;
}

static void
_geary_imap_engine_minimal_folder_on_remote_status_notify_g_object_notify (GObject* _sender,
                                                                           GParamSpec* pspec,
                                                                           gpointer self)
{
	geary_imap_engine_minimal_folder_on_remote_status_notify ((GearyImapEngineMinimalFolder*) self);
}

static gboolean
geary_imap_engine_minimal_folder_open_locked_co (GearyImapEngineMinimalFolderOpenLockedData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->open_count;
	_data_->self->priv->open_count = _data_->_tmp0_ + 1;
	if (_data_->_tmp0_ > 0) {
		if (geary_folder_open_flags_is_all_set (_data_->open_flags, GEARY_FOLDER_OPEN_FLAGS_NO_DELAY)) {
			_data_->_tmp1_ = _data_->self->priv->remote_session;
			if (_data_->_tmp1_ == NULL) {
				_data_->self->priv->open_flags = _data_->self->priv->open_flags | GEARY_FOLDER_OPEN_FLAGS_NO_DELAY;
			}
			geary_imap_engine_minimal_folder_open_remote_session (_data_->self, NULL, NULL);
		}
		_data_->result = FALSE;
		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_->self->priv->open_flags = _data_->open_flags;
	_data_->_tmp2_ = _data_->self->priv->closed_semaphore;
	geary_nonblocking_lock_reset (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
	_data_->_tmp3_ = _data_->self->priv->refresh_unseen_timer;
	geary_timeout_manager_reset (_data_->_tmp3_);
	_data_->_tmp4_ = g_cancellable_new ();
	_g_object_unref0 (_data_->self->priv->open_cancellable);
	_data_->self->priv->open_cancellable = _data_->_tmp4_;
	_data_->_tmp5_ = geary_imap_engine_replay_queue_new (_data_->self);
	_data_->_tmp6_ = _data_->_tmp5_;
	geary_imap_engine_minimal_folder_set_replay_queue (_data_->self, _data_->_tmp6_);
	_g_object_unref0 (_data_->_tmp6_);
	_data_->_tmp7_ = _data_->self->priv->email_prefetcher;
	geary_imap_engine_email_prefetcher_open (_data_->_tmp7_);
	_data_->_tmp8_ = _data_->self->priv->_local_folder;
	_data_->_tmp9_ = geary_imap_db_folder_get_properties (_data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_tmp11_ = geary_folder_properties_get_email_total (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp10_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
	_data_->_tmp12_ = _data_->_tmp11_;
	geary_folder_notify_opened (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_STATE_LOCAL, _data_->_tmp12_);
	_g_object_unref0 (_data_->_tmp10_);
	_data_->_tmp13_ = _data_->self->priv->_account;
	_data_->_tmp14_ = geary_imap_engine_generic_account_get_imap (_data_->_tmp13_);
	_data_->_tmp15_ = _data_->_tmp14_;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp15_, G_TYPE_OBJECT, GObject), "notify::current-status", (GCallback) _geary_imap_engine_minimal_folder_on_remote_status_notify_g_object_notify, _data_->self, 0);
	if (geary_folder_open_flags_is_all_set (_data_->open_flags, GEARY_FOLDER_OPEN_FLAGS_NO_DELAY)) {
		geary_imap_engine_minimal_folder_open_remote_session (_data_->self, NULL, NULL);
	} else {
		_data_->_tmp16_ = _data_->self->priv->remote_open_timer;
		geary_timeout_manager_start (_data_->_tmp16_);
	}
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Folder opened");
	_data_->result = TRUE;
	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_minimal_folder_force_close_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderForceCloseData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderForceCloseData, _data_);
}

static void
geary_imap_engine_minimal_folder_force_close (GearyImapEngineMinimalFolder* self,
                                              GearyFolderCloseReason local_reason,
                                              GearyFolderCloseReason remote_reason,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	GearyImapEngineMinimalFolderForceCloseData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderForceCloseData);
	_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_minimal_folder_force_close_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->local_reason = local_reason;
	_data_->remote_reason = remote_reason;
	geary_imap_engine_minimal_folder_force_close_co (_data_);
}

static void
geary_imap_engine_minimal_folder_force_close_finish (GearyImapEngineMinimalFolder* self,
                                                     GAsyncResult* _res_)
{
	GearyImapEngineMinimalFolderForceCloseData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/**
     * Closes the folder regardless of the open count.
     *
     * This only useful when an unrecoverable error has occurred. No
     * cancellable argument is provided since the close must complete.
     */
static void
geary_imap_engine_minimal_folder_force_close_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	GearyImapEngineMinimalFolderForceCloseData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_force_close_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_force_close_co (GearyImapEngineMinimalFolderForceCloseData* _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->lifecycle_mutex;
		_data_->_state_ = 1;
		geary_nonblocking_mutex_claim_async (_data_->_tmp0_, NULL, geary_imap_engine_minimal_folder_force_close_ready, _data_);
		return FALSE;
		_state_1:
		_data_->token = geary_nonblocking_mutex_claim_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (_data_->self->priv->open_count > 0) {
			_data_->_state_ = 2;
			geary_imap_engine_minimal_folder_close_internal_locked (_data_->self, _data_->local_reason, _data_->remote_reason, NULL, geary_imap_engine_minimal_folder_force_close_ready, _data_);
			return FALSE;
			_state_2:
			geary_imap_engine_minimal_folder_close_internal_locked_finish (_data_->self, _data_->_res_);
		}
		_data_->_tmp1_ = _data_->self->priv->lifecycle_mutex;
		geary_nonblocking_mutex_release (_data_->_tmp1_, &_data_->token, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	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_minimal_folder_close_internal_locked_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderCloseInternalLockedData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderCloseInternalLockedData, _data_);
}

static void
geary_imap_engine_minimal_folder_close_internal_locked (GearyImapEngineMinimalFolder* self,
                                                        GearyFolderCloseReason local_reason,
                                                        GearyFolderCloseReason remote_reason,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCloseInternalLockedData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderCloseInternalLockedData);
	_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_minimal_folder_close_internal_locked_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->local_reason = local_reason;
	_data_->remote_reason = remote_reason;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_imap_engine_minimal_folder_close_internal_locked_co (_data_);
}

static void
geary_imap_engine_minimal_folder_close_internal_locked_finish (GearyImapEngineMinimalFolder* self,
                                                               GAsyncResult* _res_)
{
	GearyImapEngineMinimalFolderCloseInternalLockedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_minimal_folder_close_internal_locked_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCloseInternalLockedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_close_internal_locked_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_close_internal_locked_co (GearyImapEngineMinimalFolderCloseInternalLockedData* _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:
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Folder closing");
	_data_->_tmp0_ = _data_->self->priv->_account;
	_data_->_tmp1_ = geary_imap_engine_generic_account_get_imap (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	g_signal_parse_name ("notify::current-status", G_TYPE_OBJECT, &_data_->_tmp3_, &_data_->_tmp4_, TRUE);
	g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, G_TYPE_OBJECT, GObject), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp3_, _data_->_tmp4_, NULL, (GCallback) _geary_imap_engine_minimal_folder_on_remote_status_notify_g_object_notify, _data_->self);
	_data_->_tmp5_ = _data_->self->priv->remote_open_timer;
	geary_timeout_manager_reset (_data_->_tmp5_);
	_data_->_tmp6_ = _data_->self->priv->open_cancellable;
	g_cancellable_cancel (_data_->_tmp6_);
	_data_->_tmp7_ = _data_->self->priv->email_prefetcher;
	geary_imap_engine_email_prefetcher_close (_data_->_tmp7_);
	_data_->_tmp8_ = _data_->self->priv->update_flags_timer;
	geary_timeout_manager_reset (_data_->_tmp8_);
	_data_->_tmp11_ = _data_->self->priv->remote_session;
	if (_data_->_tmp11_ != NULL) {
		_data_->_tmp10_ = !geary_folder_close_reason_is_error (_data_->local_reason);
	} else {
		_data_->_tmp10_ = FALSE;
	}
	if (_data_->_tmp10_) {
		_data_->_tmp9_ = !geary_folder_close_reason_is_error (_data_->remote_reason);
	} else {
		_data_->_tmp9_ = FALSE;
	}
	_data_->flush_pending = _data_->_tmp9_;
	if (_data_->flush_pending) {
		_data_->_tmp12_ = gee_array_list_new (GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_data_->final_ops = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp12_, GEE_TYPE_LIST, GeeList);
		_data_->_tmp13_ = _data_->final_ops;
		geary_imap_engine_minimal_folder_notify_closing (_data_->self, _data_->_tmp13_);
		{
			_data_->_tmp14_ = _data_->final_ops;
			_data_->_op_list = _data_->_tmp14_;
			_data_->_tmp15_ = _data_->_op_list;
			_data_->_tmp16_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp15_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp17_ = _data_->_tmp16_;
			_data_->_op_size = _data_->_tmp17_;
			_data_->_op_index = -1;
			while (TRUE) {
				_data_->_op_index = _data_->_op_index + 1;
				_data_->_tmp18_ = _data_->_op_index;
				_data_->_tmp19_ = _data_->_op_size;
				if (!(_data_->_tmp18_ < _data_->_tmp19_)) {
					break;
				}
				_data_->_tmp20_ = _data_->_op_list;
				_data_->_tmp21_ = gee_list_get (_data_->_tmp20_, _data_->_op_index);
				_data_->op = (GearyImapEngineReplayOperation*) _data_->_tmp21_;
				_data_->_tmp22_ = _data_->self->priv->_replay_queue;
				_data_->_tmp23_ = _data_->op;
				geary_imap_engine_replay_queue_schedule (_data_->_tmp22_, _data_->_tmp23_);
				_g_object_unref0 (_data_->op);
			}
		}
		_g_object_unref0 (_data_->final_ops);
	}
	_data_->_tmp24_ = bool_to_string (_data_->flush_pending);
	_data_->_tmp25_ = _data_->_tmp24_;
	_data_->_tmp26_ = _data_->self->priv->_replay_queue;
	_data_->_tmp27_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp26_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
	_data_->_tmp28_ = _data_->_tmp27_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Closing replay queue for (flush_pending=%s): %s", _data_->_tmp25_, _data_->_tmp28_);
	_g_free0 (_data_->_tmp28_);
	_g_free0 (_data_->_tmp25_);
	{
		_data_->_tmp29_ = _data_->self->priv->_replay_queue;
		_data_->_state_ = 1;
		geary_imap_engine_replay_queue_close_async (_data_->_tmp29_, _data_->flush_pending, NULL, geary_imap_engine_minimal_folder_close_internal_locked_ready, _data_);
		return FALSE;
		_state_1:
		geary_imap_engine_replay_queue_close_finish (_data_->_tmp29_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp30_ = _data_->self->priv->_replay_queue;
		_data_->_tmp31_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp30_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_data_->_tmp32_ = _data_->_tmp31_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Closed replay queue: %s", _data_->_tmp32_);
		_g_free0 (_data_->_tmp32_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp33_ = _data_->err;
		_data_->_tmp34_ = _data_->_tmp33_->message;
		geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error closing replay queue: %s", _data_->_tmp34_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_state_ = 2;
	geary_imap_engine_minimal_folder_close_remote_session (_data_->self, _data_->remote_reason, geary_imap_engine_minimal_folder_close_internal_locked_ready, _data_);
	return FALSE;
	_state_2:
	geary_imap_engine_minimal_folder_close_remote_session_finish (_data_->self, _data_->_res_);
	_data_->_tmp35_ = _data_->self->priv->remote_wait_semaphore;
	geary_nonblocking_lock_reset (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp35_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
	geary_imap_engine_minimal_folder_set_replay_queue (_data_->self, NULL);
	_g_object_unref0 (_data_->self->priv->open_cancellable);
	_data_->self->priv->open_cancellable = NULL;
	_data_->self->priv->open_flags = GEARY_FOLDER_OPEN_FLAGS_NONE;
	_data_->self->priv->open_count = 0;
	geary_folder_notify_closed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->local_reason);
	geary_folder_notify_closed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_CLOSE_REASON_FOLDER_CLOSED);
	_data_->_tmp36_ = _data_->self->priv->closed_semaphore;
	geary_nonblocking_lock_blind_notify (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp36_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Folder closed");
	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_minimal_folder_open_remote_session_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderOpenRemoteSessionData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderOpenRemoteSessionData, _data_);
}

static void
geary_imap_engine_minimal_folder_open_remote_session (GearyImapEngineMinimalFolder* self,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	GearyImapEngineMinimalFolderOpenRemoteSessionData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderOpenRemoteSessionData);
	_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_minimal_folder_open_remote_session_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	geary_imap_engine_minimal_folder_open_remote_session_co (_data_);
}

static void
geary_imap_engine_minimal_folder_open_remote_session_finish (GearyImapEngineMinimalFolder* self,
                                                             GAsyncResult* _res_)
{
	GearyImapEngineMinimalFolderOpenRemoteSessionData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/**
     * Establishes a new IMAP session, normalising local and remote folders.
     */
static void
geary_imap_engine_minimal_folder_open_remote_session_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_)
{
	GearyImapEngineMinimalFolderOpenRemoteSessionData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_open_remote_session_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_open_remote_session_co (GearyImapEngineMinimalFolderOpenRemoteSessionData* _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->remote_mutex;
		_data_->_tmp1_ = _data_->self->priv->open_cancellable;
		_data_->_state_ = 1;
		geary_nonblocking_mutex_claim_async (_data_->_tmp0_, _data_->_tmp1_, geary_imap_engine_minimal_folder_open_remote_session_ready, _data_);
		return FALSE;
		_state_1:
		_data_->token = geary_nonblocking_mutex_claim_finish (_data_->_tmp0_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (_data_->self->priv->open_count > 0) {
			_data_->_tmp4_ = _data_->self->priv->_account;
			_data_->_tmp5_ = geary_imap_engine_generic_account_get_imap (_data_->_tmp4_);
			_data_->_tmp6_ = _data_->_tmp5_;
			_data_->_tmp7_ = geary_client_service_get_current_status (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
			_data_->_tmp8_ = _data_->_tmp7_;
			_data_->_tmp3_ = _data_->_tmp8_ == GEARY_CLIENT_SERVICE_STATUS_CONNECTED;
		} else {
			_data_->_tmp3_ = FALSE;
		}
		if (_data_->_tmp3_) {
			_data_->_tmp9_ = _data_->self->priv->remote_session;
			_data_->_tmp2_ = _data_->_tmp9_ == NULL;
		} else {
			_data_->_tmp2_ = FALSE;
		}
		if (_data_->_tmp2_) {
			_data_->_tmp10_ = geary_folder_get_opening_monitor (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder));
			_data_->_tmp11_ = _data_->_tmp10_;
			geary_progress_monitor_notify_start (_data_->_tmp11_);
			_data_->_tmp12_ = _data_->self->priv->open_cancellable;
			_data_->_state_ = 2;
			geary_imap_engine_minimal_folder_open_remote_session_locked (_data_->self, _data_->_tmp12_, geary_imap_engine_minimal_folder_open_remote_session_ready, _data_);
			return FALSE;
			_state_2:
			geary_imap_engine_minimal_folder_open_remote_session_locked_finish (_data_->self, _data_->_res_);
			_data_->_tmp13_ = geary_folder_get_opening_monitor (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder));
			_data_->_tmp14_ = _data_->_tmp13_;
			geary_progress_monitor_notify_finish (_data_->_tmp14_);
		}
		_data_->_tmp15_ = _data_->self->priv->remote_mutex;
		geary_nonblocking_mutex_release (_data_->_tmp15_, &_data_->token, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	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_minimal_folder_open_remote_session_locked_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderOpenRemoteSessionLockedData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderOpenRemoteSessionLockedData, _data_);
}

static void
geary_imap_engine_minimal_folder_open_remote_session_locked (GearyImapEngineMinimalFolder* self,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	GearyImapEngineMinimalFolderOpenRemoteSessionLockedData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderOpenRemoteSessionLockedData);
	_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_minimal_folder_open_remote_session_locked_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_minimal_folder_open_remote_session_locked_co (_data_);
}

static void
geary_imap_engine_minimal_folder_open_remote_session_locked_finish (GearyImapEngineMinimalFolder* self,
                                                                    GAsyncResult* _res_)
{
	GearyImapEngineMinimalFolderOpenRemoteSessionLockedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_minimal_folder_open_remote_session_locked_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_)
{
	GearyImapEngineMinimalFolderOpenRemoteSessionLockedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_open_remote_session_locked_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_open_remote_session_locked_co (GearyImapEngineMinimalFolderOpenRemoteSessionLockedData* _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;
		case 5:
		goto _state_5;
		case 6:
		goto _state_6;
		case 7:
		goto _state_7;
		case 8:
		goto _state_8;
		case 9:
		goto _state_9;
		case 10:
		goto _state_10;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Opening remote session");
	_data_->_tmp0_ = _data_->self->priv->remote_open_timer;
	geary_timeout_manager_reset (_data_->_tmp0_);
	_data_->session = NULL;
	{
		_data_->_tmp2_ = _data_->self->priv->_account;
		_data_->_tmp3_ = geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder));
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_state_ = 1;
		geary_imap_engine_generic_account_claim_folder_session (_data_->_tmp2_, _data_->_tmp4_, _data_->cancellable, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp5_ = geary_imap_engine_generic_account_claim_folder_session_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp5_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
				goto __catch0_g_io_error_cancelled;
			}
			if (g_error_matches (_data_->_inner_error0_, GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND)) {
				goto __catch0_geary_engine_error_not_found;
			}
			if (g_error_matches (_data_->_inner_error0_, GEARY_IMAP_ERROR, GEARY_IMAP_ERROR_NOT_SUPPORTED)) {
				goto __catch0_geary_imap_error_not_supported;
			}
			goto __catch0_g_error;
		}
		_data_->_tmp6_ = _data_->_tmp1_;
		_data_->_tmp1_ = NULL;
		_g_object_unref0 (_data_->session);
		_data_->session = _data_->_tmp6_;
		_g_object_unref0 (_data_->_tmp1_);
	}
	goto __finally0;
	__catch0_g_io_error_cancelled:
	{
		g_clear_error (&_data_->_inner_error0_);
		_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;
	}
	goto __finally0;
	__catch0_geary_engine_error_not_found:
	{
		g_clear_error (&_data_->_inner_error0_);
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Remote folder not found, forcing closed");
		_data_->_state_ = 2;
		geary_imap_engine_minimal_folder_force_close (_data_->self, GEARY_FOLDER_CLOSE_REASON_LOCAL_CLOSE, GEARY_FOLDER_CLOSE_REASON_REMOTE_ERROR, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
		return FALSE;
		_state_2:
		geary_imap_engine_minimal_folder_force_close_finish (_data_->self, _data_->_res_);
		_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;
	}
	goto __finally0;
	__catch0_geary_imap_error_not_supported:
	{
		g_clear_error (&_data_->_inner_error0_);
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Remote folder not selectable, forcing closed");
		_data_->_state_ = 3;
		geary_imap_engine_minimal_folder_force_close (_data_->self, GEARY_FOLDER_CLOSE_REASON_LOCAL_CLOSE, GEARY_FOLDER_CLOSE_REASON_REMOTE_ERROR, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
		return FALSE;
		_state_3:
		geary_imap_engine_minimal_folder_force_close_finish (_data_->self, _data_->_res_);
		_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;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp7_ = _data_->err;
		_data_->_tmp8_ = geary_error_context_new (_data_->_tmp7_);
		_data_->context = _data_->_tmp8_;
		_data_->_tmp9_ = _data_->err;
		if (!geary_imap_engine_is_recoverable_failure (_data_->_tmp9_)) {
			_data_->_tmp10_ = _data_->context;
			_data_->_tmp11_ = geary_error_context_format_full_error (_data_->_tmp10_);
			_data_->_tmp12_ = _data_->_tmp11_;
			geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unrecoverable failure opening remote, forcing closed: %s", _data_->_tmp12_);
			_g_free0 (_data_->_tmp12_);
			_data_->_state_ = 4;
			geary_imap_engine_minimal_folder_force_close (_data_->self, GEARY_FOLDER_CLOSE_REASON_LOCAL_CLOSE, GEARY_FOLDER_CLOSE_REASON_REMOTE_ERROR, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
			return FALSE;
			_state_4:
			geary_imap_engine_minimal_folder_force_close_finish (_data_->self, _data_->_res_);
		} else {
			_data_->_tmp13_ = _data_->context;
			_data_->_tmp14_ = geary_error_context_format_full_error (_data_->_tmp13_);
			_data_->_tmp15_ = _data_->_tmp14_;
			geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Recoverable error opening remote: %s", _data_->_tmp15_);
			_g_free0 (_data_->_tmp15_);
			_data_->_tmp16_ = _data_->err;
			geary_folder_notify_open_failed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FAILED_REMOTE_ERROR, _data_->_tmp16_);
		}
		_g_object_unref0 (_data_->context);
		_g_error_free0 (_data_->err);
		_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;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->session);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp17_ = _data_->session;
	g_signal_connect_object (_data_->_tmp17_, "appended", (GCallback) _geary_imap_engine_minimal_folder_on_remote_appended_geary_imap_folder_session_appended, _data_->self, 0);
	_data_->_tmp18_ = _data_->session;
	g_signal_connect_object (_data_->_tmp18_, "updated", (GCallback) _geary_imap_engine_minimal_folder_on_remote_updated_geary_imap_folder_session_updated, _data_->self, 0);
	_data_->_tmp19_ = _data_->session;
	g_signal_connect_object (_data_->_tmp19_, "removed", (GCallback) _geary_imap_engine_minimal_folder_on_remote_removed_geary_imap_folder_session_removed, _data_->self, 0);
	{
		_data_->_tmp20_ = _data_->session;
		_data_->_state_ = 5;
		geary_imap_engine_minimal_folder_normalize_folders (_data_->self, _data_->_tmp20_, _data_->cancellable, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
		return FALSE;
		_state_5:
		geary_imap_engine_minimal_folder_normalize_folders_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
	}
	goto __finally1;
	__catch1_g_error:
	{
		_data_->_vala1_err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp21_ = _data_->self->priv->_account;
		_data_->_tmp22_ = _data_->session;
		_data_->_state_ = 6;
		geary_imap_engine_generic_account_release_folder_session (_data_->_tmp21_, _data_->_tmp22_, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
		return FALSE;
		_state_6:
		geary_imap_engine_generic_account_release_folder_session_finish (_data_->_tmp21_, _data_->_res_);
		_data_->_tmp23_ = _data_->_vala1_err;
		if (!g_error_matches (_data_->_tmp23_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
			_data_->local_reason = GEARY_FOLDER_CLOSE_REASON_LOCAL_ERROR;
			_data_->remote_reason = GEARY_FOLDER_CLOSE_REASON_REMOTE_CLOSE;
			_data_->_tmp24_ = _data_->_vala1_err;
			if (!geary_imap_engine_is_remote_error (_data_->_tmp24_)) {
				_data_->_tmp25_ = _data_->_vala1_err;
				geary_folder_notify_open_failed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FAILED_LOCAL_ERROR, _data_->_tmp25_);
			} else {
				_data_->_tmp26_ = _data_->_vala1_err;
				geary_folder_notify_open_failed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FAILED_REMOTE_ERROR, _data_->_tmp26_);
				_data_->local_reason = GEARY_FOLDER_CLOSE_REASON_LOCAL_CLOSE;
				_data_->remote_reason = GEARY_FOLDER_CLOSE_REASON_REMOTE_ERROR;
			}
			_data_->_state_ = 7;
			geary_imap_engine_minimal_folder_force_close (_data_->self, _data_->local_reason, _data_->remote_reason, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
			return FALSE;
			_state_7:
			geary_imap_engine_minimal_folder_force_close_finish (_data_->self, _data_->_res_);
		}
		_g_error_free0 (_data_->_vala1_err);
		_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;
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->session);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp27_ = _data_->session;
	_data_->_tmp28_ = geary_imap_folder_session_get_folder (_data_->_tmp27_);
	_data_->_tmp29_ = _data_->_tmp28_;
	_data_->_tmp30_ = geary_imap_folder_get_properties (_data_->_tmp29_);
	_data_->_tmp31_ = _data_->_tmp30_;
	_data_->_tmp32_ = _data_->session;
	_data_->_tmp33_ = geary_imap_folder_session_get_folder (_data_->_tmp32_);
	_data_->_tmp34_ = _data_->_tmp33_;
	_data_->_tmp35_ = geary_imap_folder_get_properties (_data_->_tmp34_);
	_data_->_tmp36_ = _data_->_tmp35_;
	_data_->_tmp37_ = geary_imap_folder_properties_get_unseen (_data_->_tmp36_);
	_data_->_tmp38_ = _data_->_tmp37_;
	_data_->_tmp39_ = _data_->self->priv->_replay_queue;
	geary_imap_folder_properties_set_status_unseen (_data_->_tmp31_, _data_->_tmp38_ + geary_imap_engine_replay_queue_pending_unread_change (_data_->_tmp39_));
	{
		_data_->_tmp40_ = _data_->self->priv->_local_folder;
		_data_->_tmp41_ = _data_->session;
		_data_->_tmp42_ = geary_imap_folder_session_get_folder (_data_->_tmp41_);
		_data_->_tmp43_ = _data_->_tmp42_;
		_data_->_tmp44_ = geary_imap_folder_get_properties (_data_->_tmp43_);
		_data_->_tmp45_ = _data_->_tmp44_;
		_data_->_state_ = 8;
		geary_imap_db_folder_update_folder_select_examine (_data_->_tmp40_, _data_->_tmp45_, _data_->cancellable, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
		return FALSE;
		_state_8:
		geary_imap_db_folder_update_folder_select_examine_finish (_data_->_tmp40_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch2_g_error;
		}
	}
	goto __finally2;
	__catch2_g_error:
	{
		_data_->_vala2_err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp46_ = _data_->self->priv->_account;
		_data_->_tmp47_ = _data_->session;
		_data_->_state_ = 9;
		geary_imap_engine_generic_account_release_folder_session (_data_->_tmp46_, _data_->_tmp47_, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
		return FALSE;
		_state_9:
		geary_imap_engine_generic_account_release_folder_session_finish (_data_->_tmp46_, _data_->_res_);
		_data_->_tmp48_ = _data_->_vala2_err;
		if (!g_error_matches (_data_->_tmp48_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
			_data_->_tmp49_ = _data_->_vala2_err;
			geary_folder_notify_open_failed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FAILED_LOCAL_ERROR, _data_->_tmp49_);
			_data_->_state_ = 10;
			geary_imap_engine_minimal_folder_force_close (_data_->self, GEARY_FOLDER_CLOSE_REASON_LOCAL_ERROR, GEARY_FOLDER_CLOSE_REASON_REMOTE_CLOSE, geary_imap_engine_minimal_folder_open_remote_session_locked_ready, _data_);
			return FALSE;
			_state_10:
			geary_imap_engine_minimal_folder_force_close_finish (_data_->self, _data_->_res_);
		}
		_g_error_free0 (_data_->_vala2_err);
		_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;
	}
	__finally2:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->session);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp50_ = _data_->session;
	_data_->_tmp51_ = _g_object_ref0 (_data_->_tmp50_);
	_g_object_unref0 (_data_->self->priv->remote_session);
	_data_->self->priv->remote_session = _data_->_tmp51_;
	_data_->_tmp52_ = _data_->self->priv->_properties;
	_data_->_tmp53_ = _data_->session;
	_data_->_tmp54_ = geary_imap_folder_session_get_folder (_data_->_tmp53_);
	_data_->_tmp55_ = _data_->_tmp54_;
	_data_->_tmp56_ = geary_imap_folder_get_properties (_data_->_tmp55_);
	_data_->_tmp57_ = _data_->_tmp56_;
	geary_aggregated_folder_properties_add (_data_->_tmp52_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp57_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
	_data_->_tmp58_ = _data_->session;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp58_, GEARY_IMAP_TYPE_SESSION_OBJECT, GearyImapSessionObject), "disconnected", (GCallback) _geary_imap_engine_minimal_folder_on_remote_disconnected_geary_imap_session_object_disconnected, _data_->self, 0);
	_data_->_tmp59_ = _data_->session;
	geary_imap_folder_session_enable_idle (_data_->_tmp59_, _data_->cancellable, NULL, NULL);
	_data_->_tmp60_ = _data_->session;
	_data_->_tmp61_ = geary_imap_folder_session_get_folder (_data_->_tmp60_);
	_data_->_tmp62_ = _data_->_tmp61_;
	_data_->_tmp63_ = geary_imap_folder_get_properties (_data_->_tmp62_);
	_data_->_tmp64_ = _data_->_tmp63_;
	_data_->_tmp65_ = geary_folder_properties_get_email_total (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp64_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
	_data_->_tmp66_ = _data_->_tmp65_;
	geary_folder_notify_opened (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_STATE_REMOTE, _data_->_tmp66_);
	geary_imap_engine_minimal_folder_notify_remote_waiters (_data_->self, TRUE);
	_data_->_tmp67_ = _data_->self->priv->update_flags_timer;
	geary_timeout_manager_start (_data_->_tmp67_);
	_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_minimal_folder_on_email_complete (GearyImapEngineMinimalFolder* self,
                                                    GeeCollection* email_ids)
{
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email_ids, GEE_TYPE_COLLECTION));
	geary_folder_notify_email_locally_complete (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), email_ids);
}

static void
_geary_folder_notify_email_appended_geary_imap_engine_replay_append_email_appended (GearyImapEngineReplayAppend* _sender,
                                                                                    GeeCollection* ids,
                                                                                    gpointer self)
{
	geary_folder_notify_email_appended ((GearyFolder*) self, ids);
}

static void
_geary_folder_notify_email_locally_appended_geary_imap_engine_replay_append_email_locally_appended (GearyImapEngineReplayAppend* _sender,
                                                                                                    GeeCollection* ids,
                                                                                                    gpointer self)
{
	geary_folder_notify_email_locally_appended ((GearyFolder*) self, ids);
}

static void
_geary_folder_notify_email_count_changed_geary_imap_engine_replay_append_email_count_changed (GearyImapEngineReplayAppend* _sender,
                                                                                              gint count,
                                                                                              GearyFolderCountChangeReason reason,
                                                                                              gpointer self)
{
	geary_folder_notify_email_count_changed ((GearyFolder*) self, count, reason);
}

static void
geary_imap_engine_minimal_folder_on_remote_appended (GearyImapEngineMinimalFolder* self,
                                                     GearyImapFolderSession* session,
                                                     gint appended)
{
	gint remote_count = 0;
	GearyImapFolder* _tmp0_;
	GearyImapFolder* _tmp1_;
	GearyImapFolderProperties* _tmp2_;
	GearyImapFolderProperties* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GeeList* positions = NULL;
	GeeArrayList* _tmp6_;
	GeeList* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (GEARY_IMAP_IS_FOLDER_SESSION (session));
	_tmp0_ = geary_imap_folder_session_get_folder (session);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_imap_folder_get_properties (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_folder_properties_get_email_total (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
	_tmp5_ = _tmp4_;
	remote_count = _tmp5_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "on_remote_appended: remote_count=%d appended=%d", remote_count, appended);
	_tmp6_ = gee_array_list_new (GEARY_IMAP_TYPE_SEQUENCE_NUMBER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	positions = G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_LIST, GeeList);
	{
		gint pos = 0;
		pos = (remote_count - appended) + 1;
		{
			gboolean _tmp7_ = FALSE;
			_tmp7_ = TRUE;
			while (TRUE) {
				GeeList* _tmp9_;
				GearyImapSequenceNumber* _tmp10_;
				GearyImapSequenceNumber* _tmp11_;
				if (!_tmp7_) {
					gint _tmp8_;
					_tmp8_ = pos;
					pos = _tmp8_ + 1;
				}
				_tmp7_ = FALSE;
				if (!(pos <= remote_count)) {
					break;
				}
				_tmp9_ = positions;
				_tmp10_ = geary_imap_sequence_number_new ((gint64) pos);
				_tmp11_ = _tmp10_;
				gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEE_TYPE_COLLECTION, GeeCollection), _tmp11_);
				_g_object_unref0 (_tmp11_);
			}
		}
	}
	_tmp12_ = positions;
	_tmp13_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp14_ = _tmp13_;
	if (_tmp14_ > 0) {
		GearyImapEngineReplayAppend* op = NULL;
		GeeList* _tmp15_;
		GearyImapEngineReplayAppend* _tmp16_;
		GearyImapEngineReplayAppend* _tmp17_;
		GearyImapEngineReplayAppend* _tmp18_;
		GearyImapEngineReplayAppend* _tmp19_;
		GearyImapEngineReplayQueue* _tmp20_;
		GearyImapEngineReplayAppend* _tmp21_;
		_tmp15_ = positions;
		_tmp16_ = geary_imap_engine_replay_append_new (self, remote_count, _tmp15_, NULL);
		op = _tmp16_;
		_tmp17_ = op;
		g_signal_connect_object (_tmp17_, "email-appended", (GCallback) _geary_folder_notify_email_appended_geary_imap_engine_replay_append_email_appended, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), 0);
		_tmp18_ = op;
		g_signal_connect_object (_tmp18_, "email-locally-appended", (GCallback) _geary_folder_notify_email_locally_appended_geary_imap_engine_replay_append_email_locally_appended, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), 0);
		_tmp19_ = op;
		g_signal_connect_object (_tmp19_, "email-count-changed", (GCallback) _geary_folder_notify_email_count_changed_geary_imap_engine_replay_append_email_count_changed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), 0);
		_tmp20_ = self->priv->_replay_queue;
		_tmp21_ = op;
		geary_imap_engine_replay_queue_schedule_server_notification (_tmp20_, G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
		_g_object_unref0 (op);
	}
	_g_object_unref0 (positions);
}

static void
geary_imap_engine_minimal_folder_on_remote_updated (GearyImapEngineMinimalFolder* self,
                                                    GearyImapFolderSession* session,
                                                    GearyImapSequenceNumber* position,
                                                    GearyImapFetchedData* data)
{
	gint remote_count = 0;
	GearyImapFolder* _tmp0_;
	GearyImapFolder* _tmp1_;
	GearyImapFolderProperties* _tmp2_;
	GearyImapFolderProperties* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GearyImapEngineReplayQueue* _tmp8_;
	GearyImapEngineReplayUpdate* _tmp9_;
	GearyImapEngineReplayUpdate* _tmp10_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (GEARY_IMAP_IS_FOLDER_SESSION (session));
	g_return_if_fail (GEARY_IMAP_IS_SEQUENCE_NUMBER (position));
	g_return_if_fail (GEARY_IMAP_IS_FETCHED_DATA (data));
	_tmp0_ = geary_imap_folder_session_get_folder (session);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_imap_folder_get_properties (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_folder_properties_get_email_total (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
	_tmp5_ = _tmp4_;
	remote_count = _tmp5_;
	_tmp6_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (position, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
	_tmp7_ = _tmp6_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "on_remote_updated: remote_count=%d position=%s", remote_count, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp8_ = self->priv->_replay_queue;
	_tmp9_ = geary_imap_engine_replay_update_new (self, remote_count, position, data);
	_tmp10_ = _tmp9_;
	geary_imap_engine_replay_queue_schedule_server_notification (_tmp8_, G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_g_object_unref0 (_tmp10_);
}

static void
_geary_folder_notify_email_removed_geary_imap_engine_replay_removal_email_removed (GearyImapEngineReplayRemoval* _sender,
                                                                                   GeeCollection* ids,
                                                                                   gpointer self)
{
	geary_folder_notify_email_removed ((GearyFolder*) self, ids);
}

static void
_geary_imap_engine_minimal_folder_notify_marked_email_removed_geary_imap_engine_replay_removal_marked_email_removed (GearyImapEngineReplayRemoval* _sender,
                                                                                                                     GeeCollection* ids,
                                                                                                                     gpointer self)
{
	geary_imap_engine_minimal_folder_notify_marked_email_removed ((GearyImapEngineMinimalFolder*) self, ids);
}

static void
_geary_folder_notify_email_count_changed_geary_imap_engine_replay_removal_email_count_changed (GearyImapEngineReplayRemoval* _sender,
                                                                                               gint count,
                                                                                               GearyFolderCountChangeReason reason,
                                                                                               gpointer self)
{
	geary_folder_notify_email_count_changed ((GearyFolder*) self, count, reason);
}

static void
geary_imap_engine_minimal_folder_on_remote_removed (GearyImapEngineMinimalFolder* self,
                                                    GearyImapFolderSession* session,
                                                    GearyImapSequenceNumber* position)
{
	gint remote_count = 0;
	GearyImapFolder* _tmp0_;
	GearyImapFolder* _tmp1_;
	GearyImapFolderProperties* _tmp2_;
	GearyImapFolderProperties* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	GearyImapEngineReplayQueue* _tmp8_;
	GearyImapEngineReplayRemoval* op = NULL;
	GearyImapEngineReplayRemoval* _tmp9_;
	GearyImapEngineReplayQueue* _tmp10_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (GEARY_IMAP_IS_FOLDER_SESSION (session));
	g_return_if_fail (GEARY_IMAP_IS_SEQUENCE_NUMBER (position));
	_tmp0_ = geary_imap_folder_session_get_folder (session);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_imap_folder_get_properties (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_folder_properties_get_email_total (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
	_tmp5_ = _tmp4_;
	remote_count = _tmp5_;
	_tmp6_ = geary_message_data_abstract_message_data_to_string (G_TYPE_CHECK_INSTANCE_CAST (position, GEARY_MESSAGE_DATA_TYPE_ABSTRACT_MESSAGE_DATA, GearyMessageDataAbstractMessageData));
	_tmp7_ = _tmp6_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "on_remote_removed: remote_count=%d position=%s", remote_count, _tmp7_);
	_g_free0 (_tmp7_);
	_tmp8_ = self->priv->_replay_queue;
	geary_imap_engine_replay_queue_notify_remote_removed_position (_tmp8_, position);
	_tmp9_ = geary_imap_engine_replay_removal_new (self, remote_count, position);
	op = _tmp9_;
	g_signal_connect_object (op, "email-removed", (GCallback) _geary_folder_notify_email_removed_geary_imap_engine_replay_removal_email_removed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), 0);
	g_signal_connect_object (op, "marked-email-removed", (GCallback) _geary_imap_engine_minimal_folder_notify_marked_email_removed_geary_imap_engine_replay_removal_marked_email_removed, self, 0);
	g_signal_connect_object (op, "email-count-changed", (GCallback) _geary_folder_notify_email_count_changed_geary_imap_engine_replay_removal_email_count_changed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder), 0);
	_tmp10_ = self->priv->_replay_queue;
	geary_imap_engine_replay_queue_schedule_server_notification (_tmp10_, G_TYPE_CHECK_INSTANCE_CAST (op, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_g_object_unref0 (op);
}

static void
geary_imap_engine_minimal_folder_real_contains_identifiers_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderContainsIdentifiersData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->ids);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderContainsIdentifiersData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_contains_identifiers (GearyFolder* base,
                                                            GeeCollection* ids,
                                                            GCancellable* cancellable,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_)
{
	GearyImapEngineMinimalFolder * self;
	GearyImapEngineMinimalFolderContainsIdentifiersData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GeeCollection* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	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_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderContainsIdentifiersData);
	_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_minimal_folder_real_contains_identifiers_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (ids);
	_g_object_unref0 (_data_->ids);
	_data_->ids = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_minimal_folder_real_contains_identifiers_co (_data_);
}

static GeeCollection*
geary_imap_engine_minimal_folder_contains_identifiers_finish (GearyFolder* base,
                                                              GAsyncResult* _res_,
                                                              GError** error)
{
	GeeCollection* result;
	GearyImapEngineMinimalFolderContainsIdentifiersData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

/** {@inheritDoc} */
static void
geary_imap_engine_minimal_folder_contains_identifiers_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	GearyImapEngineMinimalFolderContainsIdentifiersData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_contains_identifiers_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_contains_identifiers_co (GearyImapEngineMinimalFolderContainsIdentifiersData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "contains_identifiers", &_data_->_inner_error0_);
	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_->_tmp1_ = _data_->self->priv->_local_folder;
	_data_->_state_ = 1;
	geary_imap_db_folder_contains_identifiers (_data_->_tmp1_, _data_->ids, _data_->cancellable, geary_imap_engine_minimal_folder_contains_identifiers_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = geary_imap_db_folder_contains_identifiers_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp0_ = _data_->_tmp2_;
	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_->_tmp3_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_data_->result = _data_->_tmp3_;
	_g_object_unref0 (_data_->_tmp0_);
	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_minimal_folder_real_list_email_by_id_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderListEmailByIdAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->initial_id);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderListEmailByIdAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_list_email_by_id_async (GearyFolder* base,
                                                              GearyEmailIdentifier* initial_id,
                                                              gint count,
                                                              GearyEmailField required_fields,
                                                              GearyFolderListFlags flags,
                                                              GCancellable* cancellable,
                                                              GAsyncReadyCallback _callback_,
                                                              gpointer _user_data_)
{
	GearyImapEngineMinimalFolder * self;
	GearyImapEngineMinimalFolderListEmailByIdAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GearyEmailIdentifier* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail ((initial_id == NULL) || GEARY_IS_EMAIL_IDENTIFIER (initial_id));
	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_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderListEmailByIdAsyncData);
	_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_minimal_folder_real_list_email_by_id_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (initial_id);
	_g_object_unref0 (_data_->initial_id);
	_data_->initial_id = _tmp1_;
	_data_->count = count;
	_data_->required_fields = required_fields;
	_data_->flags = flags;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_minimal_folder_real_list_email_by_id_async_co (_data_);
}

static GeeList*
geary_imap_engine_minimal_folder_list_email_by_id_finish (GearyFolder* base,
                                                          GAsyncResult* _res_,
                                                          GError** error)
{
	GeeList* result;
	GearyImapEngineMinimalFolderListEmailByIdAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
geary_imap_engine_minimal_folder_list_email_by_id_async_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_)
{
	GearyImapEngineMinimalFolderListEmailByIdAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_list_email_by_id_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_list_email_by_id_async_co (GearyImapEngineMinimalFolderListEmailByIdAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "list_email_by_id_async", &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_flags (_data_->self, "list_email_by_id_async", _data_->flags, &_data_->_inner_error0_);
	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;
	}
	if (_data_->initial_id != NULL) {
		geary_imap_engine_minimal_folder_check_id (_data_->self, "list_email_by_id_async", _data_->initial_id, &_data_->_inner_error0_);
		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;
		}
	}
	if (_data_->count == 0) {
		_data_->result = NULL;
		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_->_tmp0_ = geary_imap_engine_list_email_by_id_new (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->initial_id, GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier), _data_->count, _data_->required_fields, _data_->flags, _data_->cancellable);
	_data_->op = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->_replay_queue;
	_data_->_tmp2_ = _data_->op;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp3_ = _data_->op;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_list_email_by_id_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->op;
	_data_->_tmp6_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->accumulator;
	_data_->_tmp7_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp8_ = _data_->_tmp7_;
	if (!_data_->_tmp8_) {
		_data_->_tmp9_ = _data_->op;
		_data_->_tmp10_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp9_, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->accumulator;
		_data_->_tmp4_ = _data_->_tmp10_;
	} else {
		_data_->_tmp4_ = NULL;
	}
	_data_->_tmp11_ = _g_object_ref0 (_data_->_tmp4_);
	_data_->result = _data_->_tmp11_;
	_g_object_unref0 (_data_->op);
	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_minimal_folder_real_list_email_by_sparse_id_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->ids);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_list_email_by_sparse_id_async (GearyFolder* base,
                                                                     GeeCollection* ids,
                                                                     GearyEmailField required_fields,
                                                                     GearyFolderListFlags flags,
                                                                     GCancellable* cancellable,
                                                                     GAsyncReadyCallback _callback_,
                                                                     gpointer _user_data_)
{
	GearyImapEngineMinimalFolder * self;
	GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GeeCollection* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	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_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData);
	_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_minimal_folder_real_list_email_by_sparse_id_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (ids);
	_g_object_unref0 (_data_->ids);
	_data_->ids = _tmp1_;
	_data_->required_fields = required_fields;
	_data_->flags = flags;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_minimal_folder_real_list_email_by_sparse_id_async_co (_data_);
}

static GeeList*
geary_imap_engine_minimal_folder_list_email_by_sparse_id_finish (GearyFolder* base,
                                                                 GAsyncResult* _res_,
                                                                 GError** error)
{
	GeeList* result;
	GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
geary_imap_engine_minimal_folder_list_email_by_sparse_id_async_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_)
{
	GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_list_email_by_sparse_id_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_list_email_by_sparse_id_async_co (GearyImapEngineMinimalFolderListEmailBySparseIdAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "list_email_by_sparse_id_async", &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_flags (_data_->self, "list_email_by_sparse_id_async", _data_->flags, &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_ids (_data_->self, "list_email_by_sparse_id_async", _data_->ids, &_data_->_inner_error0_);
	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_->_tmp0_ = gee_collection_get_size (_data_->ids);
	_data_->_tmp1_ = _data_->_tmp0_;
	if (_data_->_tmp1_ == 0) {
		_data_->result = NULL;
		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_->_tmp2_ = geary_imap_engine_list_email_by_sparse_id_new (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->ids, GEE_TYPE_COLLECTION, GeeCollection), _data_->required_fields, _data_->flags, _data_->cancellable);
	_data_->op = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->self->priv->_replay_queue;
	_data_->_tmp4_ = _data_->op;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp3_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp5_ = _data_->op;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_list_email_by_sparse_id_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp7_ = _data_->op;
	_data_->_tmp8_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->accumulator;
	_data_->_tmp9_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp10_ = _data_->_tmp9_;
	if (!_data_->_tmp10_) {
		_data_->_tmp11_ = _data_->op;
		_data_->_tmp12_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->accumulator;
		_data_->_tmp6_ = _data_->_tmp12_;
	} else {
		_data_->_tmp6_ = NULL;
	}
	_data_->_tmp13_ = _g_object_ref0 (_data_->_tmp6_);
	_data_->result = _data_->_tmp13_;
	_g_object_unref0 (_data_->op);
	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_minimal_folder_real_fetch_email_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderFetchEmailAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->id);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderFetchEmailAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_fetch_email_async (GearyFolder* base,
                                                         GearyEmailIdentifier* id,
                                                         GearyEmailField required_fields,
                                                         GearyFolderListFlags flags,
                                                         GCancellable* cancellable,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_)
{
	GearyImapEngineMinimalFolder * self;
	GearyImapEngineMinimalFolderFetchEmailAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GearyEmailIdentifier* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_IS_EMAIL_IDENTIFIER (id));
	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_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderFetchEmailAsyncData);
	_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_minimal_folder_real_fetch_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (id);
	_g_object_unref0 (_data_->id);
	_data_->id = _tmp1_;
	_data_->required_fields = required_fields;
	_data_->flags = flags;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_minimal_folder_real_fetch_email_async_co (_data_);
}

static GearyEmail*
geary_imap_engine_minimal_folder_fetch_email_finish (GearyFolder* base,
                                                     GAsyncResult* _res_,
                                                     GError** error)
{
	GearyEmail* result;
	GearyImapEngineMinimalFolderFetchEmailAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
geary_imap_engine_minimal_folder_fetch_email_async_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_)
{
	GearyImapEngineMinimalFolderFetchEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_fetch_email_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_fetch_email_async_co (GearyImapEngineMinimalFolderFetchEmailAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "fetch_email_async", &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_flags (_data_->self, "fetch_email_async", _data_->flags, &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_id (_data_->self, "fetch_email_async", _data_->id, &_data_->_inner_error0_);
	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_->_tmp0_ = geary_imap_engine_fetch_email_new (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->id, GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier), _data_->required_fields, _data_->flags, _data_->cancellable);
	_data_->op = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->_replay_queue;
	_data_->_tmp2_ = _data_->op;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp3_ = _data_->op;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_fetch_email_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->op;
	_data_->_tmp5_ = _data_->_tmp4_->email;
	_data_->_tmp6_ = _g_object_ref0 (_data_->_tmp5_);
	_data_->result = _data_->_tmp6_;
	_g_object_unref0 (_data_->op);
	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_minimal_folder_expunge_email_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderExpungeEmailAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->to_expunge);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderExpungeEmailAsyncData, _data_);
}

void
geary_imap_engine_minimal_folder_expunge_email_async (GearyImapEngineMinimalFolder* self,
                                                      GeeCollection* to_expunge,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	GearyImapEngineMinimalFolderExpungeEmailAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GeeCollection* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (to_expunge, GEE_TYPE_COLLECTION));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderExpungeEmailAsyncData);
	_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_minimal_folder_expunge_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (to_expunge);
	_g_object_unref0 (_data_->to_expunge);
	_data_->to_expunge = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_minimal_folder_expunge_email_async_co (_data_);
}

void
geary_imap_engine_minimal_folder_expunge_email_finish (GearyImapEngineMinimalFolder* self,
                                                       GAsyncResult* _res_,
                                                       GError** error)
{
	GearyImapEngineMinimalFolderExpungeEmailAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_minimal_folder_expunge_email_async_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_)
{
	GearyImapEngineMinimalFolderExpungeEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_expunge_email_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_expunge_email_async_co (GearyImapEngineMinimalFolderExpungeEmailAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "expunge_email_async", &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_ids (_data_->self, "expunge_email_async", _data_->to_expunge, &_data_->_inner_error0_);
	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_->_tmp0_ = geary_imap_engine_remove_email_new (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->to_expunge, GEE_TYPE_COLLECTION, GeeCollection), _data_->cancellable);
	_data_->remove = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->_replay_queue;
	_data_->_tmp2_ = _data_->remove;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp3_ = _data_->remove;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_expunge_email_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->remove);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->remove);
	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_minimal_folder_expunge_all_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderExpungeAllAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderExpungeAllAsyncData, _data_);
}

void
geary_imap_engine_minimal_folder_expunge_all_async (GearyImapEngineMinimalFolder* self,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	GearyImapEngineMinimalFolderExpungeAllAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderExpungeAllAsyncData);
	_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_minimal_folder_expunge_all_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_minimal_folder_expunge_all_async_co (_data_);
}

void
geary_imap_engine_minimal_folder_expunge_all_finish (GearyImapEngineMinimalFolder* self,
                                                     GAsyncResult* _res_,
                                                     GError** error)
{
	GearyImapEngineMinimalFolderExpungeAllAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_minimal_folder_expunge_all_async_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_)
{
	GearyImapEngineMinimalFolderExpungeAllAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_expunge_all_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_expunge_all_async_co (GearyImapEngineMinimalFolderExpungeAllAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "expunge_all_async", &_data_->_inner_error0_);
	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_->_tmp0_ = geary_imap_engine_empty_folder_new (_data_->self, _data_->cancellable);
	_data_->op = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->_replay_queue;
	_data_->_tmp2_ = _data_->op;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp3_ = _data_->op;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_expunge_all_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->self->priv->_replay_queue;
	_data_->_state_ = 2;
	geary_imap_engine_replay_queue_checkpoint (_data_->_tmp4_, _data_->cancellable, geary_imap_engine_minimal_folder_expunge_all_async_ready, _data_);
	return FALSE;
	_state_2:
	geary_imap_engine_replay_queue_checkpoint_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->self->priv->_account;
	_data_->_tmp6_ = geary_imap_engine_generic_account_get_local (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = geary_imap_db_account_get_db (_data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	_data_->_state_ = 3;
	geary_imap_db_database_run_gc (_data_->_tmp9_, GEARY_IMAP_DB_DATABASE_GARBAGE_COLLECTION_OPTIONS_NONE, NULL, _data_->cancellable, geary_imap_engine_minimal_folder_expunge_all_async_ready, _data_);
	return FALSE;
	_state_3:
	geary_imap_db_database_run_gc_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->op);
	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_minimal_folder_check_open (GearyImapEngineMinimalFolder* self,
                                             const gchar* method,
                                             GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (method != NULL);
	if (self->priv->open_count == 0) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		GError* _tmp2_;
		GError* _tmp3_;
		_tmp0_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_tmp1_ = _tmp0_;
		_tmp2_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_OPEN_REQUIRED, "%s failed: folder %s is not open", method, _tmp1_);
		_tmp3_ = _tmp2_;
		_g_free0 (_tmp1_);
		_inner_error0_ = _tmp3_;
		if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
}

static void
geary_imap_engine_minimal_folder_check_flags (GearyImapEngineMinimalFolder* self,
                                              const gchar* method,
                                              GearyFolderListFlags flags,
                                              GError** error)
{
	gboolean _tmp0_ = FALSE;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (method != NULL);
	if (geary_folder_list_flags_is_all_set (flags, GEARY_FOLDER_LIST_FLAGS_LOCAL_ONLY)) {
		_tmp0_ = geary_folder_list_flags_is_all_set (flags, GEARY_FOLDER_LIST_FLAGS_FORCE_UPDATE);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		gchar* _tmp1_;
		gchar* _tmp2_;
		GError* _tmp3_;
		GError* _tmp4_;
		_tmp1_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_tmp2_ = _tmp1_;
		_tmp3_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS, "%s %s failed: LOCAL_ONLY and FORCE_UPDATE are mutually exclusive", _tmp2_, method);
		_tmp4_ = _tmp3_;
		_g_free0 (_tmp2_);
		_inner_error0_ = _tmp4_;
		if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
}

static void
geary_imap_engine_minimal_folder_check_id (GearyImapEngineMinimalFolder* self,
                                           const gchar* method,
                                           GearyEmailIdentifier* id,
                                           GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (method != NULL);
	g_return_if_fail (GEARY_IS_EMAIL_IDENTIFIER (id));
	if (!GEARY_IMAP_DB_IS_EMAIL_IDENTIFIER (id)) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		GError* _tmp2_;
		GError* _tmp3_;
		_tmp0_ = geary_email_identifier_to_string (id);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS, "Email ID %s is not IMAP Email ID", _tmp1_);
		_tmp3_ = _tmp2_;
		_g_free0 (_tmp1_);
		_inner_error0_ = _tmp3_;
		if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return;
		} else {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return;
		}
	}
}

static void
geary_imap_engine_minimal_folder_check_ids (GearyImapEngineMinimalFolder* self,
                                            const gchar* method,
                                            GeeCollection* ids,
                                            GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (method != NULL);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	{
		GeeIterator* _id_it = NULL;
		GeeIterator* _tmp0_;
		_tmp0_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (ids, GEE_TYPE_ITERABLE, GeeIterable));
		_id_it = _tmp0_;
		while (TRUE) {
			GeeIterator* _tmp1_;
			GearyEmailIdentifier* id = NULL;
			GeeIterator* _tmp2_;
			gpointer _tmp3_;
			GearyEmailIdentifier* _tmp4_;
			_tmp1_ = _id_it;
			if (!gee_iterator_next (_tmp1_)) {
				break;
			}
			_tmp2_ = _id_it;
			_tmp3_ = gee_iterator_get (_tmp2_);
			id = (GearyEmailIdentifier*) _tmp3_;
			_tmp4_ = id;
			geary_imap_engine_minimal_folder_check_id (self, method, _tmp4_, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (id);
					_g_object_unref0 (_id_it);
					return;
				} else {
					_g_object_unref0 (id);
					_g_object_unref0 (_id_it);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return;
				}
			}
			_g_object_unref0 (id);
		}
		_g_object_unref0 (_id_it);
	}
}

static void
geary_imap_engine_minimal_folder_real_mark_email_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderMarkEmailAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->to_mark);
	_g_object_unref0 (_data_->flags_to_add);
	_g_object_unref0 (_data_->flags_to_remove);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderMarkEmailAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_mark_email_async (GearyImapEngineMinimalFolder* self,
                                                        GeeCollection* to_mark,
                                                        GearyEmailFlags* flags_to_add,
                                                        GearyEmailFlags* flags_to_remove,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	GearyImapEngineMinimalFolderMarkEmailAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GeeCollection* _tmp1_;
	GearyEmailFlags* _tmp2_;
	GearyEmailFlags* _tmp3_;
	GCancellable* _tmp4_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (to_mark, GEE_TYPE_COLLECTION));
	g_return_if_fail ((flags_to_add == NULL) || GEARY_IS_EMAIL_FLAGS (flags_to_add));
	g_return_if_fail ((flags_to_remove == NULL) || GEARY_IS_EMAIL_FLAGS (flags_to_remove));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderMarkEmailAsyncData);
	_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_minimal_folder_real_mark_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (to_mark);
	_g_object_unref0 (_data_->to_mark);
	_data_->to_mark = _tmp1_;
	_tmp2_ = _g_object_ref0 (flags_to_add);
	_g_object_unref0 (_data_->flags_to_add);
	_data_->flags_to_add = _tmp2_;
	_tmp3_ = _g_object_ref0 (flags_to_remove);
	_g_object_unref0 (_data_->flags_to_remove);
	_data_->flags_to_remove = _tmp3_;
	_tmp4_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp4_;
	geary_imap_engine_minimal_folder_real_mark_email_async_co (_data_);
}

static void
geary_imap_engine_minimal_folder_real_mark_email_finish (GearyImapEngineMinimalFolder* self,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	GearyImapEngineMinimalFolderMarkEmailAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_minimal_folder_mark_email_async_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	GearyImapEngineMinimalFolderMarkEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_mark_email_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_mark_email_async_co (GearyImapEngineMinimalFolderMarkEmailAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "mark_email_async", &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_ids (_data_->self, "mark_email_async", _data_->to_mark, &_data_->_inner_error0_);
	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_->_tmp0_ = geary_imap_engine_mark_email_new (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->to_mark, GEE_TYPE_COLLECTION, GeeCollection), _data_->flags_to_add, _data_->flags_to_remove, _data_->cancellable);
	_data_->mark = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->_replay_queue;
	_data_->_tmp2_ = _data_->mark;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp3_ = _data_->mark;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_mark_email_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->mark);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = geary_folder_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp5_ = _data_->_tmp4_;
	geary_account_cancel_remote_update (_data_->_tmp5_);
	_g_object_unref0 (_data_->mark);
	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;
}

void
geary_imap_engine_minimal_folder_mark_email_async (GearyImapEngineMinimalFolder* self,
                                                   GeeCollection* to_mark,
                                                   GearyEmailFlags* flags_to_add,
                                                   GearyEmailFlags* flags_to_remove,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	GearyImapEngineMinimalFolderClass* _klass_;
	_klass_ = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS (self);
	if (_klass_->mark_email_async) {
		_klass_->mark_email_async (self, to_mark, flags_to_add, flags_to_remove, cancellable, _callback_, _user_data_);
	}
}

void
geary_imap_engine_minimal_folder_mark_email_finish (GearyImapEngineMinimalFolder* self,
                                                    GAsyncResult* _res_,
                                                    GError** error)
{
	GearyImapEngineMinimalFolderClass* _klass_;
	_klass_ = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS (self);
	if (_klass_->mark_email_finish) {
		_klass_->mark_email_finish (self, _res_, error);
	}
}

static void
geary_imap_engine_minimal_folder_real_copy_email_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderCopyEmailAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->to_copy);
	_g_object_unref0 (_data_->destination);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderCopyEmailAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_copy_email_async (GearyImapEngineMinimalFolder* self,
                                                        GeeCollection* to_copy,
                                                        GearyFolderPath* destination,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCopyEmailAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GeeCollection* _tmp1_;
	GearyFolderPath* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (to_copy, GEE_TYPE_COLLECTION));
	g_return_if_fail (GEARY_IS_FOLDER_PATH (destination));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderCopyEmailAsyncData);
	_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_minimal_folder_real_copy_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (to_copy);
	_g_object_unref0 (_data_->to_copy);
	_data_->to_copy = _tmp1_;
	_tmp2_ = _g_object_ref0 (destination);
	_g_object_unref0 (_data_->destination);
	_data_->destination = _tmp2_;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp3_;
	geary_imap_engine_minimal_folder_real_copy_email_async_co (_data_);
}

static void
geary_imap_engine_minimal_folder_real_copy_email_finish (GearyImapEngineMinimalFolder* self,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	GearyImapEngineMinimalFolderCopyEmailAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_minimal_folder_copy_email_async_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCopyEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_copy_email_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_copy_email_async_co (GearyImapEngineMinimalFolderCopyEmailAsyncData* _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->_account;
	_data_->_tmp1_ = geary_account_get_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->destination, &_data_->_inner_error0_);
	_data_->target = _data_->_tmp1_;
	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_->_state_ = 1;
	geary_imap_engine_minimal_folder_copy_email_uids_async (_data_->self, _data_->to_copy, _data_->destination, _data_->cancellable, geary_imap_engine_minimal_folder_copy_email_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = geary_imap_engine_minimal_folder_copy_email_uids_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_g_object_unref0 (_data_->_tmp3_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->target);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->self->priv->_account;
	_data_->_tmp5_ = _data_->target;
	geary_imap_engine_generic_account_update_folder (_data_->_tmp4_, _data_->_tmp5_);
	_g_object_unref0 (_data_->target);
	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;
}

void
geary_imap_engine_minimal_folder_copy_email_async (GearyImapEngineMinimalFolder* self,
                                                   GeeCollection* to_copy,
                                                   GearyFolderPath* destination,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	GearyImapEngineMinimalFolderClass* _klass_;
	_klass_ = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS (self);
	if (_klass_->copy_email_async) {
		_klass_->copy_email_async (self, to_copy, destination, cancellable, _callback_, _user_data_);
	}
}

void
geary_imap_engine_minimal_folder_copy_email_finish (GearyImapEngineMinimalFolder* self,
                                                    GAsyncResult* _res_,
                                                    GError** error)
{
	GearyImapEngineMinimalFolderClass* _klass_;
	_klass_ = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS (self);
	if (_klass_->copy_email_finish) {
		_klass_->copy_email_finish (self, _res_, error);
	}
}

static void
geary_imap_engine_minimal_folder_copy_email_uids_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderCopyEmailUidsAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->to_copy);
	_g_object_unref0 (_data_->destination);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderCopyEmailUidsAsyncData, _data_);
}

void
geary_imap_engine_minimal_folder_copy_email_uids_async (GearyImapEngineMinimalFolder* self,
                                                        GeeCollection* to_copy,
                                                        GearyFolderPath* destination,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCopyEmailUidsAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GeeCollection* _tmp1_;
	GearyFolderPath* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (to_copy, GEE_TYPE_COLLECTION));
	g_return_if_fail (GEARY_IS_FOLDER_PATH (destination));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderCopyEmailUidsAsyncData);
	_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_minimal_folder_copy_email_uids_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (to_copy);
	_g_object_unref0 (_data_->to_copy);
	_data_->to_copy = _tmp1_;
	_tmp2_ = _g_object_ref0 (destination);
	_g_object_unref0 (_data_->destination);
	_data_->destination = _tmp2_;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp3_;
	geary_imap_engine_minimal_folder_copy_email_uids_async_co (_data_);
}

GeeSet*
geary_imap_engine_minimal_folder_copy_email_uids_finish (GearyImapEngineMinimalFolder* self,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	GeeSet* result;
	GearyImapEngineMinimalFolderCopyEmailUidsAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

/**
     * Returns the destination folder's UIDs for the copied messages.
     */
static void
geary_imap_engine_minimal_folder_copy_email_uids_async_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCopyEmailUidsAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_copy_email_uids_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_copy_email_uids_async_co (GearyImapEngineMinimalFolderCopyEmailUidsAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "copy_email_uids_async", &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_ids (_data_->self, "copy_email_uids_async", _data_->to_copy, &_data_->_inner_error0_);
	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_->_tmp0_ = geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp1_ = _data_->_tmp0_;
	if (gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_data_->destination, GEE_TYPE_HASHABLE, GeeHashable), _data_->_tmp1_)) {
		_data_->result = NULL;
		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_->_tmp2_ = geary_traverse (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->to_copy, GEE_TYPE_ITERABLE, GeeIterable));
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = geary_iterable_to_array_list (_data_->_tmp3_, NULL, NULL, NULL);
	_data_->_tmp5_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, GEE_TYPE_LIST, GeeList);
	_data_->_tmp6_ = geary_imap_engine_copy_email_new (_data_->self, _data_->_tmp5_, _data_->destination, NULL);
	_data_->_tmp7_ = _data_->_tmp6_;
	_g_object_unref0 (_data_->_tmp5_);
	_g_object_unref0 (_data_->_tmp3_);
	_data_->copy = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->self->priv->_replay_queue;
	_data_->_tmp9_ = _data_->copy;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp8_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp9_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp10_ = _data_->copy;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp10_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_copy_email_uids_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp10_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->copy);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp12_ = _data_->copy;
	_data_->_tmp13_ = _data_->_tmp12_->destination_uids;
	_data_->_tmp14_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp13_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp15_ = _data_->_tmp14_;
	if (_data_->_tmp15_ > 0) {
		_data_->_tmp16_ = _data_->copy;
		_data_->_tmp17_ = _data_->_tmp16_->destination_uids;
		_data_->_tmp11_ = _data_->_tmp17_;
	} else {
		_data_->_tmp11_ = NULL;
	}
	_data_->_tmp18_ = _g_object_ref0 (_data_->_tmp11_);
	_data_->result = _data_->_tmp18_;
	_g_object_unref0 (_data_->copy);
	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_minimal_folder_real_move_email_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderMoveEmailAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->to_move);
	_g_object_unref0 (_data_->destination);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderMoveEmailAsyncData, _data_);
}

static void
geary_imap_engine_minimal_folder_real_move_email_async (GearyImapEngineMinimalFolder* self,
                                                        GeeCollection* to_move,
                                                        GearyFolderPath* destination,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	GearyImapEngineMinimalFolderMoveEmailAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GeeCollection* _tmp1_;
	GearyFolderPath* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (to_move, GEE_TYPE_COLLECTION));
	g_return_if_fail (GEARY_IS_FOLDER_PATH (destination));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderMoveEmailAsyncData);
	_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_minimal_folder_real_move_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (to_move);
	_g_object_unref0 (_data_->to_move);
	_data_->to_move = _tmp1_;
	_tmp2_ = _g_object_ref0 (destination);
	_g_object_unref0 (_data_->destination);
	_data_->destination = _tmp2_;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp3_;
	geary_imap_engine_minimal_folder_real_move_email_async_co (_data_);
}

static GearyRevokable*
geary_imap_engine_minimal_folder_real_move_email_finish (GearyImapEngineMinimalFolder* self,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	GearyRevokable* result;
	GearyImapEngineMinimalFolderMoveEmailAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
geary_imap_engine_minimal_folder_move_email_async_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	GearyImapEngineMinimalFolderMoveEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_real_move_email_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_real_move_email_async_co (GearyImapEngineMinimalFolderMoveEmailAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "move_email_async", &_data_->_inner_error0_);
	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;
	}
	geary_imap_engine_minimal_folder_check_ids (_data_->self, "move_email_async", _data_->to_move, &_data_->_inner_error0_);
	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_->_tmp0_ = geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp1_ = _data_->_tmp0_;
	if (gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_data_->destination, GEE_TYPE_HASHABLE, GeeHashable), _data_->_tmp1_)) {
		_data_->result = NULL;
		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_->_tmp2_ = geary_imap_engine_move_email_prepare_new (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->to_move, GEE_TYPE_COLLECTION, GeeCollection), _data_->cancellable);
	_data_->prepare = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->self->priv->_replay_queue;
	_data_->_tmp4_ = _data_->prepare;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp3_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp5_ = _data_->prepare;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_move_email_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->prepare);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp7_ = _data_->prepare;
	_data_->_tmp8_ = _data_->_tmp7_->prepared_for_move;
	if (_data_->_tmp8_ == NULL) {
		_data_->_tmp6_ = TRUE;
	} else {
		_data_->_tmp9_ = _data_->prepare;
		_data_->_tmp10_ = _data_->_tmp9_->prepared_for_move;
		_data_->_tmp11_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp10_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp6_ = _data_->_tmp12_ == 0;
	}
	if (_data_->_tmp6_) {
		_data_->result = NULL;
		_g_object_unref0 (_data_->prepare);
		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_->_tmp13_ = _data_->self->priv->_account;
	_data_->_tmp14_ = geary_account_get_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp13_, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->destination, &_data_->_inner_error0_);
	_data_->target = _data_->_tmp14_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->prepare);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp15_ = _data_->self->priv->_account;
	_data_->_tmp16_ = _data_->target;
	_data_->_tmp17_ = _data_->prepare;
	_data_->_tmp18_ = _data_->_tmp17_->prepared_for_move;
	_data_->_tmp19_ = geary_imap_engine_revokable_move_new (_data_->_tmp15_, _data_->self, _data_->_tmp16_, _data_->_tmp18_);
	_data_->result = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp19_, GEARY_TYPE_REVOKABLE, GearyRevokable);
	_g_object_unref0 (_data_->target);
	_g_object_unref0 (_data_->prepare);
	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;
}

void
geary_imap_engine_minimal_folder_move_email_async (GearyImapEngineMinimalFolder* self,
                                                   GeeCollection* to_move,
                                                   GearyFolderPath* destination,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	GearyImapEngineMinimalFolderClass* _klass_;
	_klass_ = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS (self);
	if (_klass_->move_email_async) {
		_klass_->move_email_async (self, to_move, destination, cancellable, _callback_, _user_data_);
	}
}

GearyRevokable*
geary_imap_engine_minimal_folder_move_email_finish (GearyImapEngineMinimalFolder* self,
                                                    GAsyncResult* _res_,
                                                    GError** error)
{
	GearyImapEngineMinimalFolderClass* _klass_;
	_klass_ = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS (self);
	if (_klass_->move_email_finish) {
		return _klass_->move_email_finish (self, _res_, error);
	}
	return NULL;
}

void
geary_imap_engine_minimal_folder_schedule_op (GearyImapEngineMinimalFolder* self,
                                              GearyImapEngineReplayOperation* op,
                                              GError** error)
{
	GearyImapEngineReplayQueue* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_REPLAY_OPERATION (op));
	geary_imap_engine_minimal_folder_check_open (self, "schedule_op", &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
	_tmp0_ = self->priv->_replay_queue;
	geary_imap_engine_replay_queue_schedule (_tmp0_, op);
}

static void
geary_imap_engine_minimal_folder_exec_op_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderExecOpAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->op);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderExecOpAsyncData, _data_);
}

void
geary_imap_engine_minimal_folder_exec_op_async (GearyImapEngineMinimalFolder* self,
                                                GearyImapEngineReplayOperation* op,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	GearyImapEngineMinimalFolderExecOpAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GearyImapEngineReplayOperation* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_REPLAY_OPERATION (op));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderExecOpAsyncData);
	_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_minimal_folder_exec_op_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (op);
	_g_object_unref0 (_data_->op);
	_data_->op = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_minimal_folder_exec_op_async_co (_data_);
}

void
geary_imap_engine_minimal_folder_exec_op_finish (GearyImapEngineMinimalFolder* self,
                                                 GAsyncResult* _res_,
                                                 GError** error)
{
	GearyImapEngineMinimalFolderExecOpAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_minimal_folder_exec_op_async_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_)
{
	GearyImapEngineMinimalFolderExecOpAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_exec_op_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_exec_op_async_co (GearyImapEngineMinimalFolderExecOpAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_schedule_op (_data_->self, _data_->op, &_data_->_inner_error0_);
	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_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (_data_->op, _data_->cancellable, geary_imap_engine_minimal_folder_exec_op_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (_data_->op, _data_->_res_, &_data_->_inner_error0_);
	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;
	}
	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;
}

/** {@inheritDoc} */
static GearyLoggingState*
geary_imap_engine_minimal_folder_real_to_logging_state (GearyFolder* base)
{
	GearyImapEngineMinimalFolder * self;
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GearyImapFolderSession* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GearyLoggingState* _tmp7_;
	GearyLoggingState* _tmp8_;
	GearyLoggingState* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	_tmp0_ = geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder));
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_folder_path_to_string (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = self->priv->remote_session;
	_tmp5_ = bool_to_string (_tmp4_ != NULL);
	_tmp6_ = _tmp5_;
	_tmp7_ = geary_logging_state_new (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "%s, open_count=%d, remote_opened=%s", _tmp3_, self->priv->open_count, _tmp6_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	_g_free0 (_tmp3_);
	result = _tmp8_;
	return result;
}

/**
     * Schedules a refresh of the unseen count for the folder.
     *
     * This will only refresh folders that are not open, since if they
     * are open or opening, they will already be updated. Hence it is safe to be called on closed folders.
     */
void
geary_imap_engine_minimal_folder_refresh_unseen (GearyImapEngineMinimalFolder* self)
{
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	if (self->priv->open_count == 0) {
		GearyTimeoutManager* _tmp0_;
		_tmp0_ = self->priv->refresh_unseen_timer;
		geary_timeout_manager_start (_tmp0_);
	}
}

static void
geary_imap_engine_minimal_folder_find_earliest_email_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderFindEarliestEmailAsyncData* _data_;
	_data_ = _data;
	_g_date_time_unref0 (_data_->datetime);
	_g_object_unref0 (_data_->before_id);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderFindEarliestEmailAsyncData, _data_);
}

static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

void
geary_imap_engine_minimal_folder_find_earliest_email_async (GearyImapEngineMinimalFolder* self,
                                                            GDateTime* datetime,
                                                            GearyEmailIdentifier* before_id,
                                                            GCancellable* cancellable,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_)
{
	GearyImapEngineMinimalFolderFindEarliestEmailAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GDateTime* _tmp1_;
	GearyEmailIdentifier* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (datetime != NULL);
	g_return_if_fail ((before_id == NULL) || GEARY_IS_EMAIL_IDENTIFIER (before_id));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderFindEarliestEmailAsyncData);
	_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_minimal_folder_find_earliest_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_date_time_ref0 (datetime);
	_g_date_time_unref0 (_data_->datetime);
	_data_->datetime = _tmp1_;
	_tmp2_ = _g_object_ref0 (before_id);
	_g_object_unref0 (_data_->before_id);
	_data_->before_id = _tmp2_;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp3_;
	geary_imap_engine_minimal_folder_find_earliest_email_async_co (_data_);
}

GearyEmail*
geary_imap_engine_minimal_folder_find_earliest_email_finish (GearyImapEngineMinimalFolder* self,
                                                             GAsyncResult* _res_,
                                                             GError** error)
{
	GearyEmail* result;
	GearyImapEngineMinimalFolderFindEarliestEmailAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
geary_imap_engine_minimal_folder_find_earliest_email_async_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_)
{
	GearyImapEngineMinimalFolderFindEarliestEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_find_earliest_email_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_find_earliest_email_async_co (GearyImapEngineMinimalFolderFindEarliestEmailAsyncData* _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:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "find_earliest_email_async", &_data_->_inner_error0_);
	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;
	}
	if (_data_->before_id != NULL) {
		geary_imap_engine_minimal_folder_check_id (_data_->self, "find_earliest_email_async", _data_->before_id, &_data_->_inner_error0_);
		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_->_tmp0_ = geary_imap_search_criteria_new (NULL);
	_data_->criteria = _data_->_tmp0_;
	_data_->_tmp2_ = geary_imap_internal_date_new_from_date_time (_data_->datetime, &_data_->_inner_error0_);
	_data_->_tmp1_ = _data_->_tmp2_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->criteria);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = _data_->criteria;
	_data_->_tmp4_ = geary_imap_search_criterion_since_internaldate (_data_->_tmp1_);
	_data_->_tmp5_ = _data_->_tmp4_;
	geary_imap_search_criteria_is_ (_data_->_tmp3_, _data_->_tmp5_);
	_g_object_unref0 (_data_->_tmp5_);
	if (_data_->before_id != NULL) {
		_data_->_tmp6_ = _data_->self->priv->_local_folder;
		_data_->_state_ = 1;
		geary_imap_db_folder_get_uid_async (_data_->_tmp6_, G_TYPE_CHECK_INSTANCE_CAST (_data_->before_id, GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier), GEARY_IMAP_DB_FOLDER_LIST_FLAGS_NONE, _data_->cancellable, geary_imap_engine_minimal_folder_find_earliest_email_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp7_ = geary_imap_db_folder_get_uid_finish (_data_->_tmp6_, _data_->_res_, &_data_->_inner_error0_);
		_data_->before_uid = _data_->_tmp7_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->_tmp1_);
			_g_object_unref0 (_data_->criteria);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp8_ = _data_->before_uid;
		if (_data_->_tmp8_ == NULL) {
			_data_->_tmp9_ = geary_email_identifier_to_string (_data_->before_id);
			_data_->_tmp10_ = _data_->_tmp9_;
			_data_->_tmp11_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
			_data_->_tmp12_ = _data_->_tmp11_;
			_data_->_tmp13_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "before_id %s not found in %s", _data_->_tmp10_, _data_->_tmp12_);
			_data_->_tmp14_ = _data_->_tmp13_;
			_g_free0 (_data_->_tmp12_);
			_g_free0 (_data_->_tmp10_);
			_data_->_inner_error0_ = _data_->_tmp14_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->before_uid);
			_g_object_unref0 (_data_->_tmp1_);
			_g_object_unref0 (_data_->criteria);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp15_ = _data_->criteria;
		_data_->_tmp16_ = geary_imap_uid_new (GEARY_IMAP_UID_MIN);
		_data_->_tmp17_ = _data_->_tmp16_;
		_data_->_tmp18_ = _data_->before_uid;
		_data_->_tmp19_ = geary_imap_uid_previous (_data_->_tmp18_, TRUE);
		_data_->_tmp20_ = _data_->_tmp19_;
		_data_->_tmp21_ = geary_imap_message_set_new_uid_range (_data_->_tmp17_, _data_->_tmp20_);
		_data_->_tmp22_ = _data_->_tmp21_;
		_data_->_tmp23_ = geary_imap_search_criterion_message_set (_data_->_tmp22_);
		_data_->_tmp24_ = _data_->_tmp23_;
		geary_imap_search_criteria_and (_data_->_tmp15_, _data_->_tmp24_);
		_g_object_unref0 (_data_->_tmp24_);
		_g_object_unref0 (_data_->_tmp22_);
		_g_object_unref0 (_data_->_tmp20_);
		_g_object_unref0 (_data_->_tmp17_);
		_g_object_unref0 (_data_->before_uid);
	}
	_data_->_tmp25_ = _data_->criteria;
	_data_->_tmp26_ = geary_imap_engine_server_search_email_new (_data_->self, _data_->_tmp25_, GEARY_EMAIL_FIELD_NONE, _data_->cancellable);
	_data_->op = _data_->_tmp26_;
	geary_imap_engine_minimal_folder_check_open (_data_->self, "find_earliest_email_async.schedule operation", &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		_g_object_unref0 (_data_->_tmp1_);
		_g_object_unref0 (_data_->criteria);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp27_ = _data_->self->priv->_replay_queue;
	_data_->_tmp28_ = _data_->op;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp27_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp28_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp29_ = _data_->op;
	_data_->_state_ = 2;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp29_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_find_earliest_email_async_ready, _data_);
	return FALSE;
	_state_2:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp29_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		_g_object_unref0 (_data_->_tmp1_);
		_g_object_unref0 (_data_->criteria);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->earliest = NULL;
	_data_->earliest_id = NULL;
	{
		_data_->_tmp30_ = _data_->op;
		_data_->_tmp31_ = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp30_, GEARY_IMAP_ENGINE_TYPE_ABSTRACT_LIST_EMAIL, GearyImapEngineAbstractListEmail)->accumulator;
		_data_->_email_list = _data_->_tmp31_;
		_data_->_tmp32_ = _data_->_email_list;
		_data_->_tmp33_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp32_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp34_ = _data_->_tmp33_;
		_data_->_email_size = _data_->_tmp34_;
		_data_->_email_index = -1;
		while (TRUE) {
			_data_->_email_index = _data_->_email_index + 1;
			_data_->_tmp35_ = _data_->_email_index;
			_data_->_tmp36_ = _data_->_email_size;
			if (!(_data_->_tmp35_ < _data_->_tmp36_)) {
				break;
			}
			_data_->_tmp37_ = _data_->_email_list;
			_data_->_tmp38_ = gee_list_get (_data_->_tmp37_, _data_->_email_index);
			_data_->email = (GearyEmail*) _data_->_tmp38_;
			_data_->_tmp39_ = _data_->email;
			_data_->_tmp40_ = geary_email_get_id (_data_->_tmp39_);
			_data_->_tmp41_ = _data_->_tmp40_;
			_data_->_tmp42_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp41_, GEARY_IMAP_DB_TYPE_EMAIL_IDENTIFIER, GearyImapDBEmailIdentifier));
			_data_->email_id = _data_->_tmp42_;
			_data_->_tmp44_ = _data_->earliest_id;
			if (_data_->_tmp44_ == NULL) {
				_data_->_tmp43_ = TRUE;
			} else {
				_data_->_tmp45_ = _data_->email_id;
				_data_->_tmp46_ = geary_imap_db_email_identifier_get_uid (_data_->_tmp45_);
				_data_->_tmp47_ = _data_->_tmp46_;
				_data_->_tmp48_ = _data_->earliest_id;
				_data_->_tmp49_ = geary_imap_db_email_identifier_get_uid (_data_->_tmp48_);
				_data_->_tmp50_ = _data_->_tmp49_;
				_data_->_tmp43_ = geary_imap_uid_compare_to (_data_->_tmp47_, _data_->_tmp50_) < 0;
			}
			if (_data_->_tmp43_) {
				_data_->_tmp51_ = _data_->email;
				_data_->_tmp52_ = _g_object_ref0 (_data_->_tmp51_);
				_g_object_unref0 (_data_->earliest);
				_data_->earliest = _data_->_tmp52_;
				_data_->_tmp53_ = _data_->email_id;
				_data_->_tmp54_ = _g_object_ref0 (_data_->_tmp53_);
				_g_object_unref0 (_data_->earliest_id);
				_data_->earliest_id = _data_->_tmp54_;
			}
			_g_object_unref0 (_data_->email_id);
			_g_object_unref0 (_data_->email);
		}
	}
	_data_->result = _data_->earliest;
	_g_object_unref0 (_data_->earliest_id);
	_g_object_unref0 (_data_->op);
	_g_object_unref0 (_data_->_tmp1_);
	_g_object_unref0 (_data_->criteria);
	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_minimal_folder_create_email_async_data_free (gpointer _data)
{
	GearyImapEngineMinimalFolderCreateEmailAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->rfc822);
	_g_object_unref0 (_data_->flags);
	_g_date_time_unref0 (_data_->date_received);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineMinimalFolderCreateEmailAsyncData, _data_);
}

void
geary_imap_engine_minimal_folder_create_email_async (GearyImapEngineMinimalFolder* self,
                                                     GearyRFC822Message* rfc822,
                                                     GearyEmailFlags* flags,
                                                     GDateTime* date_received,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCreateEmailAsyncData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GearyRFC822Message* _tmp1_;
	GearyEmailFlags* _tmp2_;
	GDateTime* _tmp3_;
	GCancellable* _tmp4_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (GEARY_RF_C822_IS_MESSAGE (rfc822));
	g_return_if_fail ((flags == NULL) || GEARY_IS_EMAIL_FLAGS (flags));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderCreateEmailAsyncData);
	_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_minimal_folder_create_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (rfc822);
	_g_object_unref0 (_data_->rfc822);
	_data_->rfc822 = _tmp1_;
	_tmp2_ = _g_object_ref0 (flags);
	_g_object_unref0 (_data_->flags);
	_data_->flags = _tmp2_;
	_tmp3_ = _g_date_time_ref0 (date_received);
	_g_date_time_unref0 (_data_->date_received);
	_data_->date_received = _tmp3_;
	_tmp4_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp4_;
	geary_imap_engine_minimal_folder_create_email_async_co (_data_);
}

GearyEmailIdentifier*
geary_imap_engine_minimal_folder_create_email_finish (GearyImapEngineMinimalFolder* self,
                                                      GAsyncResult* _res_,
                                                      GError** error)
{
	GearyEmailIdentifier* result;
	GearyImapEngineMinimalFolderCreateEmailAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static void
geary_imap_engine_minimal_folder_create_email_async_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_)
{
	GearyImapEngineMinimalFolderCreateEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_create_email_async_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_create_email_async_co (GearyImapEngineMinimalFolderCreateEmailAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_minimal_folder_check_open (_data_->self, "create_email_async", &_data_->_inner_error0_);
	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_->_tmp0_ = geary_imap_engine_create_email_new (_data_->self, _data_->rfc822, _data_->flags, _data_->date_received, _data_->cancellable);
	_data_->op = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->_replay_queue;
	_data_->_tmp2_ = _data_->op;
	geary_imap_engine_replay_queue_schedule (_data_->_tmp1_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation));
	_data_->_tmp3_ = _data_->op;
	_data_->_state_ = 1;
	geary_imap_engine_replay_operation_wait_for_ready_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->cancellable, geary_imap_engine_minimal_folder_create_email_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_replay_operation_wait_for_ready_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEARY_IMAP_ENGINE_TYPE_REPLAY_OPERATION, GearyImapEngineReplayOperation), _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->op);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->self->priv->_account;
	geary_imap_engine_generic_account_update_folder (_data_->_tmp4_, G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp5_ = _data_->op;
	_data_->_tmp6_ = geary_imap_engine_create_email_get_created_id (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	if (_data_->_tmp7_ != NULL) {
		_data_->_tmp8_ = _data_->op;
		_data_->_tmp9_ = geary_imap_engine_create_email_get_created_id (_data_->_tmp8_);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_state_ = 2;
		geary_folder_list_email_by_id_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->_tmp10_, 1, GEARY_EMAIL_FIELD_ALL, GEARY_FOLDER_LIST_FLAGS_INCLUDING_ID, _data_->cancellable, geary_imap_engine_minimal_folder_create_email_async_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp11_ = geary_folder_list_email_by_id_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp12_ = _data_->_tmp11_;
		_g_object_unref0 (_data_->_tmp12_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->op);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	} else {
		_data_->_state_ = 3;
		geary_folder_synchronise_remote (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->cancellable, geary_imap_engine_minimal_folder_create_email_async_ready, _data_);
		return FALSE;
		_state_3:
		geary_folder_synchronise_remote_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->op);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->_tmp13_ = _data_->op;
	_data_->_tmp14_ = geary_imap_engine_create_email_get_created_id (_data_->_tmp13_);
	_data_->_tmp15_ = _data_->_tmp14_;
	_data_->_tmp16_ = _g_object_ref0 (_data_->_tmp15_);
	_data_->result = _data_->_tmp16_;
	_g_object_unref0 (_data_->op);
	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;
}

/** Fires a {@link marked_email_removed} signal for this folder. */
static void
geary_imap_engine_minimal_folder_real_notify_marked_email_removed (GearyImapEngineMinimalFolder* self,
                                                                   GeeCollection* removed)
{
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION));
	g_signal_emit (self, geary_imap_engine_minimal_folder_signals[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_MARKED_EMAIL_REMOVED_SIGNAL], 0, removed);
}

void
geary_imap_engine_minimal_folder_notify_marked_email_removed (GearyImapEngineMinimalFolder* self,
                                                              GeeCollection* removed)
{
	GearyImapEngineMinimalFolderClass* _klass_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_klass_ = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_GET_CLASS (self);
	if (_klass_->notify_marked_email_removed) {
		_klass_->notify_marked_email_removed (self, removed);
	}
}

static inline void
geary_imap_engine_minimal_folder_notify_remote_waiters (GearyImapEngineMinimalFolder* self,
                                                        gboolean successful)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	{
		GearyNonblockingReportingSemaphore* _tmp0_;
		_tmp0_ = self->priv->remote_wait_semaphore;
		geary_nonblocking_reporting_semaphore_notify_result (_tmp0_, (gpointer) ((gintptr) successful), NULL, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

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

static void
geary_imap_engine_minimal_folder_update_flags (GearyImapEngineMinimalFolder* self,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	GearyImapEngineMinimalFolderUpdateFlagsData* _data_;
	GearyImapEngineMinimalFolder* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineMinimalFolderUpdateFlagsData);
	_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_minimal_folder_update_flags_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_minimal_folder_update_flags_co (_data_);
}

static void
geary_imap_engine_minimal_folder_update_flags_finish (GearyImapEngineMinimalFolder* self,
                                                      GAsyncResult* _res_,
                                                      GError** error)
{
	GearyImapEngineMinimalFolderUpdateFlagsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/**
     * Checks for changes to {@link EmailFlags} after a folder opens.
     */
static void
geary_imap_engine_minimal_folder_update_flags_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_)
{
	GearyImapEngineMinimalFolderUpdateFlagsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_minimal_folder_update_flags_co (_data_);
}

static gboolean
geary_imap_engine_minimal_folder_update_flags_co (GearyImapEngineMinimalFolderUpdateFlagsData* _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_->chunk_size = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FLAG_UPDATE_START_CHUNK;
	_data_->lowest = NULL;
	while (TRUE) {
		if (!(geary_folder_get_open_state (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder)) != GEARY_FOLDER_OPEN_STATE_CLOSED)) {
			break;
		}
		_data_->_tmp0_ = _data_->lowest;
		_data_->_state_ = 1;
		geary_folder_list_email_by_id_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->_tmp0_, _data_->chunk_size, GEARY_EMAIL_FIELD_FLAGS, GEARY_FOLDER_LIST_FLAGS_LOCAL_ONLY, _data_->cancellable, geary_imap_engine_minimal_folder_update_flags_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = geary_folder_list_email_by_id_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		_data_->list_local = _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->lowest);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp3_ = _data_->list_local;
		if (_data_->_tmp3_ == NULL) {
			_data_->_tmp2_ = TRUE;
		} else {
			_data_->_tmp4_ = _data_->list_local;
			_data_->_tmp5_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp6_ = _data_->_tmp5_;
			_data_->_tmp2_ = _data_->_tmp6_;
		}
		if (_data_->_tmp2_) {
			_g_object_unref0 (_data_->list_local);
			break;
		}
		_data_->_tmp7_ = _data_->list_local;
		_data_->_tmp8_ = geary_email_identifier_sort_emails (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = gee_sorted_set_first (_data_->_tmp9_);
		_data_->_tmp11_ = (GearyEmail*) _data_->_tmp10_;
		_data_->_tmp12_ = geary_email_get_id (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = _g_object_ref0 (_data_->_tmp13_);
		_g_object_unref0 (_data_->lowest);
		_data_->lowest = _data_->_tmp14_;
		_g_object_unref0 (_data_->_tmp11_);
		_g_object_unref0 (_data_->_tmp9_);
		_data_->_tmp15_ = gee_hash_map_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_TYPE_EMAIL_FLAGS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
		_data_->local_map = _data_->_tmp15_;
		{
			_data_->_tmp16_ = _data_->list_local;
			_data_->_e_list = _data_->_tmp16_;
			_data_->_tmp17_ = _data_->_e_list;
			_data_->_tmp18_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp17_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp19_ = _data_->_tmp18_;
			_data_->_e_size = _data_->_tmp19_;
			_data_->_e_index = -1;
			while (TRUE) {
				_data_->_e_index = _data_->_e_index + 1;
				_data_->_tmp20_ = _data_->_e_index;
				_data_->_tmp21_ = _data_->_e_size;
				if (!(_data_->_tmp20_ < _data_->_tmp21_)) {
					break;
				}
				_data_->_tmp22_ = _data_->_e_list;
				_data_->_tmp23_ = gee_list_get (_data_->_tmp22_, _data_->_e_index);
				_data_->e = (GearyEmail*) _data_->_tmp23_;
				_data_->_tmp24_ = _data_->local_map;
				_data_->_tmp25_ = _data_->e;
				_data_->_tmp26_ = geary_email_get_id (_data_->_tmp25_);
				_data_->_tmp27_ = _data_->_tmp26_;
				_data_->_tmp28_ = _data_->e;
				_data_->_tmp29_ = geary_email_get_email_flags (_data_->_tmp28_);
				_data_->_tmp30_ = _data_->_tmp29_;
				gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp24_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _data_->_tmp27_, _data_->_tmp30_);
				_g_object_unref0 (_data_->e);
			}
		}
		_data_->_tmp31_ = _data_->local_map;
		_data_->_tmp32_ = gee_abstract_map_get_keys (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp31_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_data_->_tmp33_ = _data_->_tmp32_;
		_data_->_tmp34_ = _data_->_tmp33_;
		_data_->_tmp35_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp34_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp36_ = _data_->_tmp35_;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Fetching %d flags", _data_->_tmp36_);
		_g_object_unref0 (_data_->_tmp34_);
		_data_->_tmp37_ = _data_->local_map;
		_data_->_tmp38_ = gee_abstract_map_get_keys (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp37_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
		_data_->_tmp39_ = _data_->_tmp38_;
		_data_->_tmp40_ = _data_->_tmp39_;
		_data_->_state_ = 2;
		geary_folder_list_email_by_sparse_id_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp40_, GEE_TYPE_COLLECTION, GeeCollection), GEARY_EMAIL_FIELD_FLAGS, GEARY_FOLDER_LIST_FLAGS_FORCE_UPDATE | GEARY_FOLDER_LIST_FLAGS_NO_UNREAD_UPDATE, _data_->cancellable, geary_imap_engine_minimal_folder_update_flags_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp41_ = geary_folder_list_email_by_sparse_id_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp42_ = _data_->_tmp41_;
		_g_object_unref0 (_data_->_tmp40_);
		_data_->list_remote = _data_->_tmp42_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->local_map);
			_g_object_unref0 (_data_->list_local);
			_g_object_unref0 (_data_->lowest);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp44_ = _data_->list_remote;
		if (_data_->_tmp44_ == NULL) {
			_data_->_tmp43_ = TRUE;
		} else {
			_data_->_tmp45_ = _data_->list_remote;
			_data_->_tmp46_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp45_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp47_ = _data_->_tmp46_;
			_data_->_tmp43_ = _data_->_tmp47_;
		}
		if (_data_->_tmp43_) {
			_g_object_unref0 (_data_->list_remote);
			_g_object_unref0 (_data_->local_map);
			_g_object_unref0 (_data_->list_local);
			break;
		}
		_data_->_tmp48_ = gee_hash_map_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_TYPE_EMAIL_FLAGS, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
		_data_->changed_map = _data_->_tmp48_;
		{
			_data_->_tmp49_ = _data_->list_remote;
			_data_->_vala1__e_list = _data_->_tmp49_;
			_data_->_tmp50_ = _data_->_vala1__e_list;
			_data_->_tmp51_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp50_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp52_ = _data_->_tmp51_;
			_data_->_vala1__e_size = _data_->_tmp52_;
			_data_->_vala1__e_index = -1;
			while (TRUE) {
				_data_->_vala1__e_index = _data_->_vala1__e_index + 1;
				_data_->_tmp53_ = _data_->_vala1__e_index;
				_data_->_tmp54_ = _data_->_vala1__e_size;
				if (!(_data_->_tmp53_ < _data_->_tmp54_)) {
					break;
				}
				_data_->_tmp55_ = _data_->_vala1__e_list;
				_data_->_tmp56_ = gee_list_get (_data_->_tmp55_, _data_->_vala1__e_index);
				_data_->_vala1_e = (GearyEmail*) _data_->_tmp56_;
				_data_->_tmp57_ = _data_->local_map;
				_data_->_tmp58_ = _data_->_vala1_e;
				_data_->_tmp59_ = geary_email_get_id (_data_->_tmp58_);
				_data_->_tmp60_ = _data_->_tmp59_;
				if (!gee_abstract_map_has_key (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp57_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _data_->_tmp60_)) {
					_g_object_unref0 (_data_->_vala1_e);
					continue;
				}
				_data_->_tmp61_ = _data_->local_map;
				_data_->_tmp62_ = _data_->_vala1_e;
				_data_->_tmp63_ = geary_email_get_id (_data_->_tmp62_);
				_data_->_tmp64_ = _data_->_tmp63_;
				_data_->_tmp65_ = gee_abstract_map_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp61_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _data_->_tmp64_);
				_data_->_tmp66_ = (GearyEmailFlags*) _data_->_tmp65_;
				_data_->_tmp67_ = _data_->_vala1_e;
				_data_->_tmp68_ = geary_email_get_email_flags (_data_->_tmp67_);
				_data_->_tmp69_ = _data_->_tmp68_;
				_data_->_tmp70_ = !gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp66_, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp69_, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags));
				_g_object_unref0 (_data_->_tmp66_);
				if (_data_->_tmp70_) {
					_data_->_tmp71_ = _data_->changed_map;
					_data_->_tmp72_ = _data_->_vala1_e;
					_data_->_tmp73_ = geary_email_get_id (_data_->_tmp72_);
					_data_->_tmp74_ = _data_->_tmp73_;
					_data_->_tmp75_ = _data_->_vala1_e;
					_data_->_tmp76_ = geary_email_get_email_flags (_data_->_tmp75_);
					_data_->_tmp77_ = _data_->_tmp76_;
					gee_abstract_map_set (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp71_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap), _data_->_tmp74_, _data_->_tmp77_);
				}
				_g_object_unref0 (_data_->_vala1_e);
			}
		}
		if (!g_cancellable_is_cancelled (_data_->cancellable)) {
			_data_->_tmp79_ = _data_->changed_map;
			_data_->_tmp80_ = gee_abstract_map_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp79_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
			_data_->_tmp81_ = _data_->_tmp80_;
			_data_->_tmp78_ = _data_->_tmp81_ > 0;
		} else {
			_data_->_tmp78_ = FALSE;
		}
		if (_data_->_tmp78_) {
			_data_->_tmp82_ = _data_->changed_map;
			geary_folder_notify_email_flags_changed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_FOLDER, GearyFolder), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp82_, GEE_TYPE_MAP, GeeMap));
		}
		_data_->chunk_size *= 2;
		if (_data_->chunk_size > GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FLAG_UPDATE_MAX_CHUNK) {
			_data_->chunk_size = GEARY_IMAP_ENGINE_MINIMAL_FOLDER_FLAG_UPDATE_MAX_CHUNK;
		}
		_g_object_unref0 (_data_->changed_map);
		_g_object_unref0 (_data_->list_remote);
		_g_object_unref0 (_data_->local_map);
		_g_object_unref0 (_data_->list_local);
	}
	_g_object_unref0 (_data_->lowest);
	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_minimal_folder_update_harvester (GearyImapEngineMinimalFolder* self)
{
	GearyAccount* _tmp0_;
	GearyAccount* _tmp1_;
	GearyContactStore* _tmp2_;
	GearyContactStore* _tmp3_;
	GearyAccount* _tmp4_;
	GearyAccount* _tmp5_;
	GearyAccountInformation* _tmp6_;
	GearyAccountInformation* _tmp7_;
	GeeList* _tmp8_;
	GeeList* _tmp9_;
	GeeList* _tmp10_;
	GearyContactHarvesterImpl* _tmp11_;
	GearyContactHarvesterImpl* _tmp12_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_tmp0_ = geary_folder_get_account (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder));
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_account_get_contact_store (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_folder_get_account (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder));
	_tmp5_ = _tmp4_;
	_tmp6_ = geary_account_get_information (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = geary_account_information_get_sender_mailboxes (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = geary_contact_harvester_impl_new (_tmp3_, self->priv->_used_as, G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp12_ = _tmp11_;
	geary_imap_engine_minimal_folder_set_harvester (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEARY_TYPE_CONTACT_HARVESTER, GearyContactHarvester));
	_g_object_unref0 (_tmp12_);
	_g_object_unref0 (_tmp10_);
}

static void
geary_imap_engine_minimal_folder_on_refresh_unseen (GearyImapEngineMinimalFolder* self)
{
	GearyImapEngineRefreshFolderUnseen* op = NULL;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyImapEngineRefreshFolderUnseen* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_tmp0_ = self->priv->_account;
	_tmp1_ = geary_imap_engine_refresh_folder_unseen_new (self, _tmp0_);
	op = _tmp1_;
	{
		GearyImapEngineGenericAccount* _tmp2_;
		_tmp2_ = self->priv->_account;
		geary_imap_engine_generic_account_queue_operation (_tmp2_, G_TYPE_CHECK_INSTANCE_CAST (op, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation), &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (op);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	_g_object_unref0 (op);
}

static void
__lambda116_ (GearyImapEngineMinimalFolder* self,
              GObject* obj,
              GAsyncResult* res)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail ((obj == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_OBJECT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (res, g_async_result_get_type ()));
	{
		geary_imap_engine_minimal_folder_update_flags_finish (self, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (g_error_matches (_inner_error0_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
				goto __catch0_g_io_error_cancelled;
			}
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_io_error_cancelled:
	{
		g_clear_error (&_inner_error0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp0_;
		const gchar* _tmp1_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp0_ = err;
		_tmp1_ = _tmp0_->message;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error updating flags: %s", _tmp1_);
		_g_error_free0 (err);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
___lambda116__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda116_ ((GearyImapEngineMinimalFolder*) self, source_object, res);
	g_object_unref (self);
}

static void
geary_imap_engine_minimal_folder_on_update_flags (GearyImapEngineMinimalFolder* self)
{
	GCancellable* _tmp0_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_tmp0_ = self->priv->open_cancellable;
	geary_imap_engine_minimal_folder_update_flags (self, _tmp0_, ___lambda116__gasync_ready_callback, g_object_ref (self));
}

static void
geary_imap_engine_minimal_folder_on_remote_status_notify (GearyImapEngineMinimalFolder* self)
{
	GearyImapEngineGenericAccount* _tmp0_;
	GearyImapClientService* _tmp1_;
	GearyImapClientService* _tmp2_;
	GearyClientServiceStatus _tmp3_;
	GearyClientServiceStatus _tmp4_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_tmp0_ = self->priv->_account;
	_tmp1_ = geary_imap_engine_generic_account_get_imap (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = geary_client_service_get_current_status (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
	_tmp4_ = _tmp3_;
	if (_tmp4_ == GEARY_CLIENT_SERVICE_STATUS_CONNECTED) {
		geary_imap_engine_minimal_folder_open_remote_session (self, NULL, NULL);
	}
}

static Block101Data*
block101_data_ref (Block101Data* _data101_)
{
	g_atomic_int_inc (&_data101_->_ref_count_);
	return _data101_;
}

static void
block101_data_unref (void * _userdata_)
{
	Block101Data* _data101_;
	_data101_ = (Block101Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data101_->_ref_count_)) {
		GearyImapEngineMinimalFolder* self;
		self = _data101_->self;
		_g_object_unref0 (self);
		g_slice_free (Block101Data, _data101_);
	}
}

static void
__lambda111_ (Block101Data* _data101_,
              GObject* obj,
              GAsyncResult* res)
{
	GearyImapEngineMinimalFolder* self;
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	self = _data101_->self;
	g_return_if_fail ((obj == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_OBJECT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (res, g_async_result_get_type ()));
	geary_imap_engine_minimal_folder_close_remote_session_finish (self, res);
	if (_data101_->is_error) {
		GearyImapEngineGenericAccount* _tmp2_;
		GearyImapClientService* _tmp3_;
		GearyImapClientService* _tmp4_;
		GearyClientServiceStatus _tmp5_;
		GearyClientServiceStatus _tmp6_;
		_tmp2_ = self->priv->_account;
		_tmp3_ = geary_imap_engine_generic_account_get_imap (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = geary_client_service_get_current_status (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
		_tmp6_ = _tmp5_;
		_tmp1_ = _tmp6_ == GEARY_CLIENT_SERVICE_STATUS_CONNECTED;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		GCancellable* _tmp7_;
		_tmp7_ = self->priv->open_cancellable;
		_tmp0_ = !g_cancellable_is_cancelled (_tmp7_);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		geary_imap_engine_minimal_folder_open_remote_session (self, NULL, NULL);
	}
}

static void
___lambda111__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	__lambda111_ (self, source_object, res);
	block101_data_unref (self);
}

static void
geary_imap_engine_minimal_folder_on_remote_disconnected (GearyImapEngineMinimalFolder* self,
                                                         GearyImapClientSessionDisconnectReason reason)
{
	Block101Data* _data101_;
	GearyFolderCloseReason _tmp0_ = 0;
	GearyFolderCloseReason remote_reason = 0;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (self));
	_data101_ = g_slice_new0 (Block101Data);
	_data101_->_ref_count_ = 1;
	_data101_->self = g_object_ref (self);
	_data101_->is_error = geary_imap_client_session_disconnect_reason_is_error (reason);
	if (_data101_->is_error) {
		_tmp0_ = GEARY_FOLDER_CLOSE_REASON_REMOTE_ERROR;
	} else {
		_tmp0_ = GEARY_FOLDER_CLOSE_REASON_REMOTE_CLOSE;
	}
	remote_reason = _tmp0_;
	geary_imap_engine_minimal_folder_close_remote_session (self, remote_reason, ___lambda111__gasync_ready_callback, block101_data_ref (_data101_));
	block101_data_unref (_data101_);
	_data101_ = NULL;
}

static void
geary_imap_engine_minimal_folder_class_init (GearyImapEngineMinimalFolderClass * klass,
                                             gpointer klass_data)
{
	geary_imap_engine_minimal_folder_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEngineMinimalFolder_private_offset);
	((GearyImapEngineMinimalFolderClass *) klass)->notify_closing = (void (*) (GearyImapEngineMinimalFolder*, GeeList*)) geary_imap_engine_minimal_folder_real_notify_closing;
	((GearyFolderClass *) klass)->set_used_as_custom = (void (*) (GearyFolder*, gboolean, GError**)) geary_imap_engine_minimal_folder_real_set_used_as_custom;
	((GearyFolderClass *) klass)->get_open_state = (GearyFolderOpenState (*) (GearyFolder*)) geary_imap_engine_minimal_folder_real_get_open_state;
	((GearyFolderClass *) klass)->open_async = (void (*) (GearyFolder*, GearyFolderOpenFlags, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_open_async;
	((GearyFolderClass *) klass)->open_finish = (gboolean (*) (GearyFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_open_finish;
	((GearyFolderClass *) klass)->close_async = (void (*) (GearyFolder*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_close_async;
	((GearyFolderClass *) klass)->close_finish = (gboolean (*) (GearyFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_close_finish;
	((GearyFolderClass *) klass)->wait_for_close_async = (void (*) (GearyFolder*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_wait_for_close_async;
	((GearyFolderClass *) klass)->wait_for_close_finish = (void (*) (GearyFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_wait_for_close_finish;
	((GearyFolderClass *) klass)->synchronise_remote = (void (*) (GearyFolder*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_synchronise_remote;
	((GearyFolderClass *) klass)->synchronise_remote_finish = (void (*) (GearyFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_synchronise_remote_finish;
	((GearyFolderClass *) klass)->contains_identifiers = (void (*) (GearyFolder*, GeeCollection*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_contains_identifiers;
	((GearyFolderClass *) klass)->contains_identifiers_finish = (GeeCollection* (*) (GearyFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_contains_identifiers_finish;
	((GearyFolderClass *) klass)->list_email_by_id_async = (void (*) (GearyFolder*, GearyEmailIdentifier*, gint, GearyEmailField, GearyFolderListFlags, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_list_email_by_id_async;
	((GearyFolderClass *) klass)->list_email_by_id_finish = (GeeList* (*) (GearyFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_list_email_by_id_finish;
	((GearyFolderClass *) klass)->list_email_by_sparse_id_async = (void (*) (GearyFolder*, GeeCollection*, GearyEmailField, GearyFolderListFlags, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_list_email_by_sparse_id_async;
	((GearyFolderClass *) klass)->list_email_by_sparse_id_finish = (GeeList* (*) (GearyFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_list_email_by_sparse_id_finish;
	((GearyFolderClass *) klass)->fetch_email_async = (void (*) (GearyFolder*, GearyEmailIdentifier*, GearyEmailField, GearyFolderListFlags, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_fetch_email_async;
	((GearyFolderClass *) klass)->fetch_email_finish = (GearyEmail* (*) (GearyFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_fetch_email_finish;
	((GearyImapEngineMinimalFolderClass *) klass)->mark_email_async = (void (*) (GearyImapEngineMinimalFolder*, GeeCollection*, GearyEmailFlags*, GearyEmailFlags*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_mark_email_async;
	((GearyImapEngineMinimalFolderClass *) klass)->mark_email_finish = (void (*) (GearyImapEngineMinimalFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_real_mark_email_finish;
	((GearyImapEngineMinimalFolderClass *) klass)->copy_email_async = (void (*) (GearyImapEngineMinimalFolder*, GeeCollection*, GearyFolderPath*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_copy_email_async;
	((GearyImapEngineMinimalFolderClass *) klass)->copy_email_finish = (void (*) (GearyImapEngineMinimalFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_real_copy_email_finish;
	((GearyImapEngineMinimalFolderClass *) klass)->move_email_async = (void (*) (GearyImapEngineMinimalFolder*, GeeCollection*, GearyFolderPath*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_real_move_email_async;
	((GearyImapEngineMinimalFolderClass *) klass)->move_email_finish = (GearyRevokable* (*) (GearyImapEngineMinimalFolder*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_real_move_email_finish;
	((GearyFolderClass *) klass)->to_logging_state = (GearyLoggingState* (*) (GearyFolder*)) geary_imap_engine_minimal_folder_real_to_logging_state;
	((GearyImapEngineMinimalFolderClass *) klass)->notify_marked_email_removed = (void (*) (GearyImapEngineMinimalFolder*, GeeCollection*)) geary_imap_engine_minimal_folder_real_notify_marked_email_removed;
	GEARY_FOLDER_CLASS (klass)->get_account = (GearyAccount* (*) (GearyFolder*)) geary_imap_engine_minimal_folder_real_get_account;
	GEARY_FOLDER_CLASS (klass)->get_properties = (GearyFolderProperties* (*) (GearyFolder*)) geary_imap_engine_minimal_folder_real_get_properties;
	GEARY_FOLDER_CLASS (klass)->get_path = (GearyFolderPath* (*) (GearyFolder*)) geary_imap_engine_minimal_folder_real_get_path;
	GEARY_FOLDER_CLASS (klass)->get_used_as = (GearyFolderSpecialUse (*) (GearyFolder*)) geary_imap_engine_minimal_folder_real_get_used_as;
	GEARY_FOLDER_CLASS (klass)->get_opening_monitor = (GearyProgressMonitor* (*) (GearyFolder*)) geary_imap_engine_minimal_folder_real_get_opening_monitor;
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_imap_engine_minimal_folder_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_geary_imap_engine_minimal_folder_set_property;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_engine_minimal_folder_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_MINIMAL_FOLDER_ACCOUNT_PROPERTY, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_ACCOUNT_PROPERTY] = g_param_spec_object ("account", "account", "account", GEARY_TYPE_ACCOUNT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_MINIMAL_FOLDER_PROPERTIES_PROPERTY, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_PROPERTIES_PROPERTY] = g_param_spec_object ("properties", "properties", "properties", GEARY_TYPE_FOLDER_PROPERTIES, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_MINIMAL_FOLDER_PATH_PROPERTY, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_PATH_PROPERTY] = g_param_spec_object ("path", "path", "path", GEARY_TYPE_FOLDER_PATH, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_MINIMAL_FOLDER_USED_AS_PROPERTY, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_USED_AS_PROPERTY] = g_param_spec_enum ("used-as", "used-as", "used-as", GEARY_FOLDER_TYPE_SPECIAL_USE, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_MINIMAL_FOLDER_OPENING_MONITOR_PROPERTY, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_OPENING_MONITOR_PROPERTY] = g_param_spec_object ("opening-monitor", "opening-monitor", "opening-monitor", GEARY_TYPE_PROGRESS_MONITOR, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** The IMAP database representation of the folder. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_MINIMAL_FOLDER_LOCAL_FOLDER_PROPERTY, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_LOCAL_FOLDER_PROPERTY] = g_param_spec_object ("local-folder", "local-folder", "local-folder", GEARY_IMAP_DB_TYPE_FOLDER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REPLAY_QUEUE_PROPERTY, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REPLAY_QUEUE_PROPERTY] = g_param_spec_object ("replay-queue", "replay-queue", "replay-queue", GEARY_IMAP_ENGINE_TYPE_REPLAY_QUEUE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_MINIMAL_FOLDER_HARVESTER_PROPERTY, geary_imap_engine_minimal_folder_properties[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_HARVESTER_PROPERTY] = g_param_spec_object ("harvester", "harvester", "harvester", GEARY_TYPE_CONTACT_HARVESTER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	     * Called when the folder is closing (and not reestablishing a connection) and will be flushing
	     * the replay queue.  Subscribers may add ReplayOperations to the list, which will be enqueued
	     * before the queue is flushed.
	     *
	     * Note that this is ''not'' fired if the queue is not being flushed.
	     */
	geary_imap_engine_minimal_folder_signals[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_CLOSING_SIGNAL] = g_signal_new ("closing", GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_LIST);
	/**
	     * Fired when an {@link EmailIdentifier} that was marked for removal is actually reported as
	     * removed (expunged) from the server.
	     *
	     * Marked messages are reported as removed when marked in the database, to make the operation
	     * appear speedy to the caller.  When the message is finally acknowledged as removed by the
	     * server, "email-removed" is not fired to avoid double-reporting.
	     *
	     * Some internal code (especially Revokables) mark messages for removal but delay the network
	     * operation.  They need to know if the message is removed by another client, however.
	     */
	geary_imap_engine_minimal_folder_signals[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_MARKED_EMAIL_REMOVED_SIGNAL] = g_signal_new ("marked-email-removed", GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_COLLECTION);
	/** Emitted to notify the account that some problem has occurred. */
	geary_imap_engine_minimal_folder_signals[GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REPORT_PROBLEM_SIGNAL] = g_signal_new ("report-problem", GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEARY_TYPE_PROBLEM_REPORT);
}

static void
geary_imap_engine_minimal_folder_geary_folder_support_copy_interface_init (GearyFolderSupportCopyIface * iface,
                                                                           gpointer iface_data)
{
	geary_imap_engine_minimal_folder_geary_folder_support_copy_parent_iface = g_type_interface_peek_parent (iface);
	iface->copy_email_async = (void (*) (GearyFolderSupportCopy*, GeeCollection*, GearyFolderPath*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_copy_email_async;
	iface->copy_email_finish = (void (*) (GearyFolderSupportCopy*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_copy_email_finish;
}

static void
geary_imap_engine_minimal_folder_geary_folder_support_mark_interface_init (GearyFolderSupportMarkIface * iface,
                                                                           gpointer iface_data)
{
	geary_imap_engine_minimal_folder_geary_folder_support_mark_parent_iface = g_type_interface_peek_parent (iface);
	iface->mark_email_async = (void (*) (GearyFolderSupportMark*, GeeCollection*, GearyEmailFlags*, GearyEmailFlags*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_mark_email_async;
	iface->mark_email_finish = (void (*) (GearyFolderSupportMark*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_mark_email_finish;
}

static void
geary_imap_engine_minimal_folder_geary_folder_support_move_interface_init (GearyFolderSupportMoveIface * iface,
                                                                           gpointer iface_data)
{
	geary_imap_engine_minimal_folder_geary_folder_support_move_parent_iface = g_type_interface_peek_parent (iface);
	iface->move_email_async = (void (*) (GearyFolderSupportMove*, GeeCollection*, GearyFolderPath*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_minimal_folder_move_email_async;
	iface->move_email_finish = (GearyRevokable* (*) (GearyFolderSupportMove*, GAsyncResult*, GError**)) geary_imap_engine_minimal_folder_move_email_finish;
}

static void
geary_imap_engine_minimal_folder_instance_init (GearyImapEngineMinimalFolder * self,
                                                gpointer klass)
{
	GearyReentrantProgressMonitor* _tmp0_;
	GearyAggregatedFolderProperties* _tmp1_;
	GearyNonblockingMutex* _tmp2_;
	GearyNonblockingSemaphore* _tmp3_;
	GearyNonblockingMutex* _tmp4_;
	GearyNonblockingReportingSemaphore* _tmp5_;
	self->priv = geary_imap_engine_minimal_folder_get_instance_private (self);
	_tmp0_ = geary_reentrant_progress_monitor_new (GEARY_PROGRESS_TYPE_ACTIVITY);
	self->priv->_opening_monitor = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEARY_TYPE_PROGRESS_MONITOR, GearyProgressMonitor);
	self->priv->_replay_queue = NULL;
	_tmp1_ = geary_aggregated_folder_properties_new (FALSE, FALSE);
	self->priv->_properties = _tmp1_;
	self->priv->open_count = 0;
	self->priv->open_flags = GEARY_FOLDER_OPEN_FLAGS_NONE;
	self->priv->open_cancellable = NULL;
	_tmp2_ = geary_nonblocking_mutex_new ();
	self->priv->lifecycle_mutex = _tmp2_;
	_tmp3_ = geary_nonblocking_semaphore_new (NULL);
	self->priv->closed_semaphore = _tmp3_;
	self->priv->remote_session = NULL;
	_tmp4_ = geary_nonblocking_mutex_new ();
	self->priv->remote_mutex = _tmp4_;
	_tmp5_ = geary_nonblocking_reporting_semaphore_new (G_TYPE_BOOLEAN, NULL, NULL, (gpointer) ((gintptr) FALSE), NULL);
	self->priv->remote_wait_semaphore = _tmp5_;
}

static void
geary_imap_engine_minimal_folder_finalize (GObject * obj)
{
	GearyImapEngineMinimalFolder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	if (self->priv->open_count > 0) {
		gchar* _tmp0_;
		gchar* _tmp1_;
		_tmp0_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_tmp1_ = _tmp0_;
		geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Folder %s destroyed without closing", _tmp1_);
		_g_free0 (_tmp1_);
	}
	_g_object_unref0 (self->priv->_opening_monitor);
	_g_object_unref0 (self->priv->_local_folder);
	_g_object_unref0 (self->priv->_replay_queue);
	_g_object_unref0 (self->priv->_harvester);
	_g_object_unref0 (self->priv->_properties);
	_g_object_unref0 (self->priv->email_prefetcher);
	_g_object_unref0 (self->priv->open_cancellable);
	_g_object_unref0 (self->priv->lifecycle_mutex);
	_g_object_unref0 (self->priv->closed_semaphore);
	_g_object_unref0 (self->priv->remote_session);
	_g_object_unref0 (self->priv->remote_mutex);
	_g_object_unref0 (self->priv->remote_wait_semaphore);
	_g_object_unref0 (self->priv->remote_open_timer);
	_g_object_unref0 (self->priv->update_flags_timer);
	_g_object_unref0 (self->priv->refresh_unseen_timer);
	G_OBJECT_CLASS (geary_imap_engine_minimal_folder_parent_class)->finalize (obj);
}

/**
 * Base implementation of {@link Geary.Folder}.
 *
 * This class maintains both a local database and a remote IMAP
 * session and mediates between the two using the replay queue. Events
 * generated locally (message move, folder close, etc) are placed in
 * the local replay queue for execution, IMAP server messages (new
 * message delivered, etc) are placed in the remote replay queue. The
 * queue ensures that message state changes caused by server messages
 * are interleaved correctly with local operations.
 *
 * The remote folder connection is not always automatically
 * established, depending on flags passed to `open_async`. In any case
 * the remote connection may go away if the network changes while the
 * folder is still held open. In this case, the folder's remote
 * connection is reestablished when the a `ready` signal is received
 * from the IMAP stack, i.e. when connectivity to the server has been
 * restored.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_engine_minimal_folder_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineMinimalFolderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_minimal_folder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineMinimalFolder), 0, (GInstanceInitFunc) geary_imap_engine_minimal_folder_instance_init, NULL };
	static const GInterfaceInfo geary_folder_support_copy_info = { (GInterfaceInitFunc) geary_imap_engine_minimal_folder_geary_folder_support_copy_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo geary_folder_support_mark_info = { (GInterfaceInitFunc) geary_imap_engine_minimal_folder_geary_folder_support_mark_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo geary_folder_support_move_info = { (GInterfaceInitFunc) geary_imap_engine_minimal_folder_geary_folder_support_move_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType geary_imap_engine_minimal_folder_type_id;
	geary_imap_engine_minimal_folder_type_id = g_type_register_static (GEARY_TYPE_FOLDER, "GearyImapEngineMinimalFolder", &g_define_type_info, 0);
	g_type_add_interface_static (geary_imap_engine_minimal_folder_type_id, GEARY_FOLDER_SUPPORT_TYPE_COPY, &geary_folder_support_copy_info);
	g_type_add_interface_static (geary_imap_engine_minimal_folder_type_id, GEARY_FOLDER_SUPPORT_TYPE_MARK, &geary_folder_support_mark_info);
	g_type_add_interface_static (geary_imap_engine_minimal_folder_type_id, GEARY_FOLDER_SUPPORT_TYPE_MOVE, &geary_folder_support_move_info);
	GearyImapEngineMinimalFolder_private_offset = g_type_add_instance_private (geary_imap_engine_minimal_folder_type_id, sizeof (GearyImapEngineMinimalFolderPrivate));
	return geary_imap_engine_minimal_folder_type_id;
}

GType
geary_imap_engine_minimal_folder_get_type (void)
{
	static gsize geary_imap_engine_minimal_folder_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_minimal_folder_type_id__once)) {
		GType geary_imap_engine_minimal_folder_type_id;
		geary_imap_engine_minimal_folder_type_id = geary_imap_engine_minimal_folder_get_type_once ();
		g_once_init_leave (&geary_imap_engine_minimal_folder_type_id__once, geary_imap_engine_minimal_folder_type_id);
	}
	return geary_imap_engine_minimal_folder_type_id__once;
}

static void
_vala_geary_imap_engine_minimal_folder_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	GearyImapEngineMinimalFolder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	switch (property_id) {
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_ACCOUNT_PROPERTY:
		g_value_set_object (value, geary_folder_get_account (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder)));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_PROPERTIES_PROPERTY:
		g_value_set_object (value, geary_folder_get_properties (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder)));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_PATH_PROPERTY:
		g_value_set_object (value, geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder)));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_USED_AS_PROPERTY:
		g_value_set_enum (value, geary_folder_get_used_as (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder)));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_OPENING_MONITOR_PROPERTY:
		g_value_set_object (value, geary_folder_get_opening_monitor (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_FOLDER, GearyFolder)));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_LOCAL_FOLDER_PROPERTY:
		g_value_set_object (value, geary_imap_engine_minimal_folder_get_local_folder (self));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REPLAY_QUEUE_PROPERTY:
		g_value_set_object (value, geary_imap_engine_minimal_folder_get_replay_queue (self));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_HARVESTER_PROPERTY:
		g_value_set_object (value, geary_imap_engine_minimal_folder_get_harvester (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_geary_imap_engine_minimal_folder_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec)
{
	GearyImapEngineMinimalFolder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder);
	switch (property_id) {
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_LOCAL_FOLDER_PROPERTY:
		geary_imap_engine_minimal_folder_set_local_folder (self, g_value_get_object (value));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_REPLAY_QUEUE_PROPERTY:
		geary_imap_engine_minimal_folder_set_replay_queue (self, g_value_get_object (value));
		break;
		case GEARY_IMAP_ENGINE_MINIMAL_FOLDER_HARVESTER_PROPERTY:
		geary_imap_engine_minimal_folder_set_harvester (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

