/* imap-engine-generic-account.c generated by valac 0.56.3, the Vala compiler
 * generated from imap-engine-generic-account.vala, do not modify */

/*
 * Copyright 2016 Software Freedom Conservancy Inc.
 * Copyright 2017-2019 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 <glib.h>
#include <gio/gio.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include "libstemmer.h"
#include <glib/gi18n-lib.h>

#define GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_IMAP_MIN_POOL_SIZE 2
#define GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_REFRESH_FOLDER_LIST_SEC (15 * 60)
#define GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_APP_BACKGROUNDED_CLEANUP_WORK_INTERVAL_MINUTES ((guint) (60 * 24))

#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;
typedef struct _GearyImapEngineGenericAccountPrivate GearyImapEngineGenericAccountPrivate;

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

#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_ENGINE_TYPE_ACCOUNT_SYNCHRONIZER (geary_imap_engine_account_synchronizer_get_type ())
#define GEARY_IMAP_ENGINE_ACCOUNT_SYNCHRONIZER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_SYNCHRONIZER, GearyImapEngineAccountSynchronizer))
#define GEARY_IMAP_ENGINE_ACCOUNT_SYNCHRONIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_SYNCHRONIZER, GearyImapEngineAccountSynchronizerClass))
#define GEARY_IMAP_ENGINE_IS_ACCOUNT_SYNCHRONIZER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_SYNCHRONIZER))
#define GEARY_IMAP_ENGINE_IS_ACCOUNT_SYNCHRONIZER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_SYNCHRONIZER))
#define GEARY_IMAP_ENGINE_ACCOUNT_SYNCHRONIZER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_SYNCHRONIZER, GearyImapEngineAccountSynchronizerClass))

typedef struct _GearyImapEngineAccountSynchronizer GearyImapEngineAccountSynchronizer;
typedef struct _GearyImapEngineAccountSynchronizerClass GearyImapEngineAccountSynchronizerClass;

#define GEARY_IMAP_ENGINE_TYPE_ACCOUNT_PROCESSOR (geary_imap_engine_account_processor_get_type ())
#define GEARY_IMAP_ENGINE_ACCOUNT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_PROCESSOR, GearyImapEngineAccountProcessor))
#define GEARY_IMAP_ENGINE_ACCOUNT_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_PROCESSOR, GearyImapEngineAccountProcessorClass))
#define GEARY_IMAP_ENGINE_IS_ACCOUNT_PROCESSOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_PROCESSOR))
#define GEARY_IMAP_ENGINE_IS_ACCOUNT_PROCESSOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_PROCESSOR))
#define GEARY_IMAP_ENGINE_ACCOUNT_PROCESSOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_ACCOUNT_PROCESSOR, GearyImapEngineAccountProcessorClass))

typedef struct _GearyImapEngineAccountProcessor GearyImapEngineAccountProcessor;
typedef struct _GearyImapEngineAccountProcessorClass GearyImapEngineAccountProcessorClass;
enum  {
	GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_0_PROPERTY,
	GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_IMAP_PROPERTY,
	GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SMTP_PROPERTY,
	GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_LOCAL_PROPERTY,
	GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SYNC_PROPERTY,
	GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _sb_stemmer_delete0(var) ((var == NULL) ? NULL : (var = (sb_stemmer_delete (var), NULL)))

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

#define GEARY_TYPE_CONTACT_STORE_IMPL (geary_contact_store_impl_get_type ())
#define GEARY_CONTACT_STORE_IMPL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_TYPE_CONTACT_STORE_IMPL, GearyContactStoreImpl))
#define GEARY_CONTACT_STORE_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_TYPE_CONTACT_STORE_IMPL, GearyContactStoreImplClass))
#define GEARY_IS_CONTACT_STORE_IMPL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_TYPE_CONTACT_STORE_IMPL))
#define GEARY_IS_CONTACT_STORE_IMPL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_TYPE_CONTACT_STORE_IMPL))
#define GEARY_CONTACT_STORE_IMPL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_TYPE_CONTACT_STORE_IMPL, GearyContactStoreImplClass))

typedef struct _GearyContactStoreImpl GearyContactStoreImpl;
typedef struct _GearyContactStoreImplClass GearyContactStoreImplClass;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _GearyImapEngineGenericAccountOpenAsyncData GearyImapEngineGenericAccountOpenAsyncData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

#define GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS (geary_imap_engine_load_folders_get_type ())
#define GEARY_IMAP_ENGINE_LOAD_FOLDERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS, GearyImapEngineLoadFolders))
#define GEARY_IMAP_ENGINE_LOAD_FOLDERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS, GearyImapEngineLoadFoldersClass))
#define GEARY_IMAP_ENGINE_IS_LOAD_FOLDERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS))
#define GEARY_IMAP_ENGINE_IS_LOAD_FOLDERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS))
#define GEARY_IMAP_ENGINE_LOAD_FOLDERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS, GearyImapEngineLoadFoldersClass))

typedef struct _GearyImapEngineLoadFolders GearyImapEngineLoadFolders;
typedef struct _GearyImapEngineLoadFoldersClass GearyImapEngineLoadFoldersClass;
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))

#define GEARY_IMAP_ENGINE_TYPE_START_SERVICES (geary_imap_engine_start_services_get_type ())
#define GEARY_IMAP_ENGINE_START_SERVICES(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_START_SERVICES, GearyImapEngineStartServices))
#define GEARY_IMAP_ENGINE_START_SERVICES_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_START_SERVICES, GearyImapEngineStartServicesClass))
#define GEARY_IMAP_ENGINE_IS_START_SERVICES(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_START_SERVICES))
#define GEARY_IMAP_ENGINE_IS_START_SERVICES_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_START_SERVICES))
#define GEARY_IMAP_ENGINE_START_SERVICES_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_START_SERVICES, GearyImapEngineStartServicesClass))

typedef struct _GearyImapEngineStartServices GearyImapEngineStartServices;
typedef struct _GearyImapEngineStartServicesClass GearyImapEngineStartServicesClass;

#define GEARY_IMAP_ENGINE_TYPE_POPULATE_SEARCH_TABLE (geary_imap_engine_populate_search_table_get_type ())
#define GEARY_IMAP_ENGINE_POPULATE_SEARCH_TABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_POPULATE_SEARCH_TABLE, GearyImapEnginePopulateSearchTable))
#define GEARY_IMAP_ENGINE_POPULATE_SEARCH_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_POPULATE_SEARCH_TABLE, GearyImapEnginePopulateSearchTableClass))
#define GEARY_IMAP_ENGINE_IS_POPULATE_SEARCH_TABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_POPULATE_SEARCH_TABLE))
#define GEARY_IMAP_ENGINE_IS_POPULATE_SEARCH_TABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_POPULATE_SEARCH_TABLE))
#define GEARY_IMAP_ENGINE_POPULATE_SEARCH_TABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_POPULATE_SEARCH_TABLE, GearyImapEnginePopulateSearchTableClass))

typedef struct _GearyImapEnginePopulateSearchTable GearyImapEnginePopulateSearchTable;
typedef struct _GearyImapEnginePopulateSearchTableClass GearyImapEnginePopulateSearchTableClass;
typedef struct _GearyImapEngineGenericAccountInternalOpenAsyncData GearyImapEngineGenericAccountInternalOpenAsyncData;
typedef struct _GearyImapEngineGenericAccountCloseAsyncData GearyImapEngineGenericAccountCloseAsyncData;

#define GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS (geary_imap_engine_update_remote_folders_get_type ())
#define GEARY_IMAP_ENGINE_UPDATE_REMOTE_FOLDERS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS, GearyImapEngineUpdateRemoteFolders))
#define GEARY_IMAP_ENGINE_UPDATE_REMOTE_FOLDERS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS, GearyImapEngineUpdateRemoteFoldersClass))
#define GEARY_IMAP_ENGINE_IS_UPDATE_REMOTE_FOLDERS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS))
#define GEARY_IMAP_ENGINE_IS_UPDATE_REMOTE_FOLDERS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS))
#define GEARY_IMAP_ENGINE_UPDATE_REMOTE_FOLDERS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS, GearyImapEngineUpdateRemoteFoldersClass))

typedef struct _GearyImapEngineUpdateRemoteFolders GearyImapEngineUpdateRemoteFolders;
typedef struct _GearyImapEngineUpdateRemoteFoldersClass GearyImapEngineUpdateRemoteFoldersClass;
typedef struct _GearyImapEngineGenericAccountRebuildAsyncData GearyImapEngineGenericAccountRebuildAsyncData;

#define GEARY_IMAP_TYPE_ACCOUNT_SESSION (geary_imap_account_session_get_type ())
#define GEARY_IMAP_ACCOUNT_SESSION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_IMAP_TYPE_ACCOUNT_SESSION, GearyImapAccountSession))
#define GEARY_IMAP_ACCOUNT_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_IMAP_TYPE_ACCOUNT_SESSION, GearyImapAccountSessionClass))
#define GEARY_IMAP_IS_ACCOUNT_SESSION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_IMAP_TYPE_ACCOUNT_SESSION))
#define GEARY_IMAP_IS_ACCOUNT_SESSION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_IMAP_TYPE_ACCOUNT_SESSION))
#define GEARY_IMAP_ACCOUNT_SESSION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_IMAP_TYPE_ACCOUNT_SESSION, GearyImapAccountSessionClass))

typedef struct _GearyImapAccountSession GearyImapAccountSession;
typedef struct _GearyImapAccountSessionClass GearyImapAccountSessionClass;
typedef struct _GearyImapEngineGenericAccountClaimAccountSessionData GearyImapEngineGenericAccountClaimAccountSessionData;

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

typedef struct _GearyImapFolderSession GearyImapFolderSession;
typedef struct _GearyImapFolderSessionClass GearyImapFolderSessionClass;

#define GEARY_IMAP_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 _GearyImapEngineGenericAccountClaimFolderSessionData GearyImapEngineGenericAccountClaimFolderSessionData;
typedef struct _GearyImapEngineGenericAccountReleaseFolderSessionData GearyImapEngineGenericAccountReleaseFolderSessionData;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))

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

#define GEARY_OUTBOX_TYPE_EMAIL_IDENTIFIER (geary_outbox_email_identifier_get_type ())
#define GEARY_OUTBOX_EMAIL_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_OUTBOX_TYPE_EMAIL_IDENTIFIER, GearyOutboxEmailIdentifier))
#define GEARY_OUTBOX_EMAIL_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_OUTBOX_TYPE_EMAIL_IDENTIFIER, GearyOutboxEmailIdentifierClass))
#define GEARY_OUTBOX_IS_EMAIL_IDENTIFIER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_OUTBOX_TYPE_EMAIL_IDENTIFIER))
#define GEARY_OUTBOX_IS_EMAIL_IDENTIFIER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_OUTBOX_TYPE_EMAIL_IDENTIFIER))
#define GEARY_OUTBOX_EMAIL_IDENTIFIER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_OUTBOX_TYPE_EMAIL_IDENTIFIER, GearyOutboxEmailIdentifierClass))

typedef struct _GearyOutboxEmailIdentifier GearyOutboxEmailIdentifier;
typedef struct _GearyOutboxEmailIdentifierClass GearyOutboxEmailIdentifierClass;
typedef struct _Block96Data Block96Data;
typedef struct _GearyImapEngineGenericAccountGetRequiredSpecialFolderAsyncData GearyImapEngineGenericAccountGetRequiredSpecialFolderAsyncData;
typedef struct _GearyImapEngineGenericAccountCreatePersonalFolderData GearyImapEngineGenericAccountCreatePersonalFolderData;

#define GEARY_TYPE_FTS_SEARCH_QUERY (geary_fts_search_query_get_type ())
#define GEARY_FTS_SEARCH_QUERY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEARY_TYPE_FTS_SEARCH_QUERY, GearyFtsSearchQuery))
#define GEARY_FTS_SEARCH_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEARY_TYPE_FTS_SEARCH_QUERY, GearyFtsSearchQueryClass))
#define GEARY_IS_FTS_SEARCH_QUERY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEARY_TYPE_FTS_SEARCH_QUERY))
#define GEARY_IS_FTS_SEARCH_QUERY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEARY_TYPE_FTS_SEARCH_QUERY))
#define GEARY_FTS_SEARCH_QUERY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEARY_TYPE_FTS_SEARCH_QUERY, GearyFtsSearchQueryClass))

typedef struct _GearyFtsSearchQuery GearyFtsSearchQuery;
typedef struct _GearyFtsSearchQueryClass GearyFtsSearchQueryClass;
typedef struct _GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData;
typedef struct _GearyImapEngineGenericAccountLocalFetchEmailAsyncData GearyImapEngineGenericAccountLocalFetchEmailAsyncData;
typedef struct _GearyImapEngineGenericAccountListLocalEmailAsyncData GearyImapEngineGenericAccountListLocalEmailAsyncData;
typedef struct _GearyImapEngineGenericAccountLocalSearchAsyncData GearyImapEngineGenericAccountLocalSearchAsyncData;
typedef struct _GearyImapEngineGenericAccountGetSearchMatchesAsyncData GearyImapEngineGenericAccountGetSearchMatchesAsyncData;
typedef struct _GearyImapEngineGenericAccountGetContainingFoldersAsyncData GearyImapEngineGenericAccountGetContainingFoldersAsyncData;
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 _GearyImapEngineGenericAccountCleanupStorageData GearyImapEngineGenericAccountCleanupStorageData;
typedef struct _GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData;
typedef struct _GearyImapEngineLoadFoldersPrivate GearyImapEngineLoadFoldersPrivate;
enum  {
	GEARY_IMAP_ENGINE_LOAD_FOLDERS_0_PROPERTY,
	GEARY_IMAP_ENGINE_LOAD_FOLDERS_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_load_folders_properties[GEARY_IMAP_ENGINE_LOAD_FOLDERS_NUM_PROPERTIES];
typedef struct _GearyImapEngineLoadFoldersExecuteData GearyImapEngineLoadFoldersExecuteData;
typedef struct _GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData;
typedef struct _GearyImapEngineStartServicesPrivate GearyImapEngineStartServicesPrivate;
enum  {
	GEARY_IMAP_ENGINE_START_SERVICES_0_PROPERTY,
	GEARY_IMAP_ENGINE_START_SERVICES_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_start_services_properties[GEARY_IMAP_ENGINE_START_SERVICES_NUM_PROPERTIES];
typedef struct _GearyImapEngineStartServicesExecuteData GearyImapEngineStartServicesExecuteData;
typedef struct _GearyImapEnginePopulateSearchTablePrivate GearyImapEnginePopulateSearchTablePrivate;
enum  {
	GEARY_IMAP_ENGINE_POPULATE_SEARCH_TABLE_0_PROPERTY,
	GEARY_IMAP_ENGINE_POPULATE_SEARCH_TABLE_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_populate_search_table_properties[GEARY_IMAP_ENGINE_POPULATE_SEARCH_TABLE_NUM_PROPERTIES];
typedef struct _GearyImapEnginePopulateSearchTableExecuteData GearyImapEnginePopulateSearchTableExecuteData;
typedef struct _GearyImapEngineUpdateRemoteFoldersPrivate GearyImapEngineUpdateRemoteFoldersPrivate;
enum  {
	GEARY_IMAP_ENGINE_UPDATE_REMOTE_FOLDERS_0_PROPERTY,
	GEARY_IMAP_ENGINE_UPDATE_REMOTE_FOLDERS_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_update_remote_folders_properties[GEARY_IMAP_ENGINE_UPDATE_REMOTE_FOLDERS_NUM_PROPERTIES];
typedef struct _GearyImapEngineUpdateRemoteFoldersExecuteData GearyImapEngineUpdateRemoteFoldersExecuteData;
typedef struct _GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData;
typedef struct _Block97Data Block97Data;
typedef struct _GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData;

#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 _GearyImapEngineRefreshFolderUnseenPrivate GearyImapEngineRefreshFolderUnseenPrivate;
enum  {
	GEARY_IMAP_ENGINE_REFRESH_FOLDER_UNSEEN_0_PROPERTY,
	GEARY_IMAP_ENGINE_REFRESH_FOLDER_UNSEEN_NUM_PROPERTIES
};
static GParamSpec* geary_imap_engine_refresh_folder_unseen_properties[GEARY_IMAP_ENGINE_REFRESH_FOLDER_UNSEEN_NUM_PROPERTIES];
typedef struct _GearyImapEngineRefreshFolderUnseenExecuteData GearyImapEngineRefreshFolderUnseenExecuteData;

struct _GearyImapEngineGenericAccount {
	GearyAccount parent_instance;
	GearyImapEngineGenericAccountPrivate * priv;
};

struct _GearyImapEngineGenericAccountClass {
	GearyAccountClass parent_class;
	GearyImapEngineMinimalFolder* (*new_folder) (GearyImapEngineGenericAccount* self, GearyImapDBFolder* local_folder);
	GearyFolderSpecialUse* (*get_supported_special_folders) (GearyImapEngineGenericAccount* self, gint* result_length1);
};

struct _GearyImapEngineGenericAccountPrivate {
	GearyImapClientService* _imap;
	GearySmtpClientService* _smtp;
	GearyImapDBAccount* _local;
	GearyImapEngineAccountSynchronizer* _sync;
	gboolean open;
	GCancellable* open_cancellable;
	GearyNonblockingSemaphore* remote_ready_lock;
	GeeMap* remote_folders;
	GeeMap* local_folders;
	GearyImapEngineAccountProcessor* processor;
	GearyTimeoutManager* refresh_folder_timer;
	GeeMap* special_search_names;
	struct sb_stemmer* stemmer;
};

struct _GearyImapEngineGenericAccountOpenAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GCancellable* cancellable;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GError* _tmp2_;
	GError* _tmp3_;
	GearyProgressMonitor* _tmp4_;
	GearyProgressMonitor* _tmp5_;
	GError* _inner_error1_;
	GearyProgressMonitor* _tmp6_;
	GearyProgressMonitor* _tmp7_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountInternalOpenAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GCancellable* cancellable;
	GCancellable* _tmp0_;
	GCancellable* _tmp1_;
	GearyNonblockingSemaphore* _tmp2_;
	GearyProgressMonitor* _tmp3_;
	GearyProgressMonitor* _tmp4_;
	GearyImapEngineAccountProcessor* _tmp5_;
	GearyImapEngineAccountProcessor* _tmp6_;
	GearyImapEngineAccountProcessor* _tmp7_;
	GearyImapDBAccount* _tmp8_;
	GError* err;
	GError* _tmp9_;
	GError* _tmp10_;
	const gchar* _tmp11_;
	GError* _tmp12_;
	GError* _tmp13_;
	GError* _tmp14_;
	const gchar* _tmp15_;
	GError* _tmp16_;
	GError* _tmp17_;
	GError* _tmp18_;
	const gchar* _tmp19_;
	GError* _tmp20_;
	GError* _tmp21_;
	GError* _tmp22_;
	GDateTime* _tmp23_;
	GearyImapDBAccount* _tmp24_;
	GDateTime* _tmp25_;
	GearyImapDBAccount* _tmp26_;
	GearyImapEngineLoadFolders* _tmp27_;
	GearyImapEngineLoadFolders* _tmp28_;
	GearySmtpClientService* _tmp29_;
	GearyOutboxFolder* _tmp30_;
	GearyOutboxFolder* _tmp31_;
	GearyImapEngineStartServices* _tmp32_;
	GearyImapEngineStartServices* _tmp33_;
	GearyImapEnginePopulateSearchTable* _tmp34_;
	GearyImapEnginePopulateSearchTable* _tmp35_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountCloseAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GCancellable* cancellable;
	GearySmtpClientService* _tmp0_;
	GError* err;
	GError* _tmp1_;
	const gchar* _tmp2_;
	GearyTimeoutManager* _tmp3_;
	GCancellable* _tmp4_;
	GearyImapEngineAccountProcessor* _tmp5_;
	GearyImapClientService* _tmp6_;
	GearyNonblockingSemaphore* _tmp7_;
	GeeBidirSortedSet* locals;
	GeeMap* _tmp8_;
	GeeCollection* _tmp9_;
	GeeCollection* _tmp10_;
	GeeCollection* _tmp11_;
	GeeBidirSortedSet* _tmp12_;
	GeeBidirSortedSet* _tmp13_;
	GeeMap* _tmp14_;
	GeeBidirSortedSet* _tmp15_;
	GeeBidirSortedSet* remotes;
	GeeMap* _tmp16_;
	GeeCollection* _tmp17_;
	GeeCollection* _tmp18_;
	GeeCollection* _tmp19_;
	GeeBidirSortedSet* _tmp20_;
	GeeBidirSortedSet* _tmp21_;
	GeeMap* _tmp22_;
	GeeBidirSortedSet* _tmp23_;
	GeeIterator* _folder_it;
	GeeBidirSortedSet* _tmp24_;
	GeeIterator* _tmp25_;
	GeeIterator* _tmp26_;
	GearyFolder* folder;
	GeeIterator* _tmp27_;
	gpointer _tmp28_;
	GearyFolder* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	GearyFolder* _tmp32_;
	GearyImapClientService* _tmp33_;
	GError* _vala1_err;
	GError* _tmp34_;
	const gchar* _tmp35_;
	GearyImapDBAccount* _tmp36_;
	GError* _inner_error1_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountRebuildAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GCancellable* cancellable;
	GError* _tmp0_;
	GearyImapDBAccount* _tmp1_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountClaimAccountSessionData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GCancellable* cancellable;
	GearyImapAccountSession* result;
	GearyNonblockingSemaphore* _tmp0_;
	GearyImapClientSession* client;
	GearyImapClientService* _tmp1_;
	GearyImapClientSession* _tmp2_;
	GearyImapAccountSession* session;
	GearyImapDBAccount* _tmp3_;
	GearyImapFolderRoot* _tmp4_;
	GearyImapFolderRoot* _tmp5_;
	GearyImapClientSession* _tmp6_;
	GearyImapAccountSession* _tmp7_;
	GearyImapAccountSession* _tmp8_;
	GearyImapClientService* _tmp9_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountClaimFolderSessionData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GearyFolderPath* path;
	GCancellable* cancellable;
	GearyImapFolderSession* result;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GearyNonblockingSemaphore* _tmp2_;
	GearyImapClientSession* client;
	GearyImapClientService* _tmp3_;
	GearyImapClientSession* _tmp4_;
	GearyImapAccountSession* account;
	GearyImapDBAccount* _tmp5_;
	GearyImapFolderRoot* _tmp6_;
	GearyImapFolderRoot* _tmp7_;
	GearyImapClientSession* _tmp8_;
	GearyImapAccountSession* _tmp9_;
	GearyImapAccountSession* _tmp10_;
	GearyImapClientService* _tmp11_;
	GearyImapFolder* folder;
	GError* folder_err;
	GearyImapFolder* _tmp12_;
	GearyImapAccountSession* _tmp13_;
	GearyImapFolder* _tmp14_;
	GearyImapFolder* _tmp15_;
	GError* err;
	GError* _tmp16_;
	GError* _tmp17_;
	GearyImapAccountSession* _tmp18_;
	GearyImapClientSession* _tmp19_;
	GearyImapClientSession* _tmp20_;
	GearyImapFolderSession* folder_session;
	GError* _tmp21_;
	GearyImapFolderSession* _tmp22_;
	GearyImapClientSession* _tmp23_;
	GearyImapFolder* _tmp24_;
	GearyImapFolderSession* _tmp25_;
	GearyImapFolderSession* _tmp26_;
	GearyImapFolderSession* _tmp27_;
	GearyImapClientService* _tmp28_;
	GError* _vala1_err;
	GError* _tmp29_;
	GError* _tmp30_;
	GError* _tmp31_;
	GearyImapClientService* _tmp32_;
	GearyImapClientSession* _tmp33_;
	GError* release_err;
	GError* _tmp34_;
	const gchar* _tmp35_;
	GError* _tmp36_;
	GError* _tmp37_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountReleaseFolderSessionData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GearyImapFolderSession* session;
	GearyImapClientSession* old_session;
	GearyImapClientSession* _tmp0_;
	GearyImapClientSession* _tmp1_;
	GearyImapClientService* _tmp2_;
	GearyImapClientSession* _tmp3_;
	GError* err;
	GearyImapFolder* _tmp4_;
	GearyImapFolder* _tmp5_;
	GearyFolderPath* _tmp6_;
	GearyFolderPath* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GError* _tmp10_;
	const gchar* _tmp11_;
	GError* _inner_error0_;
};

struct _Block96Data {
	int _ref_count_;
	GearyImapEngineGenericAccount* self;
	GeeMap* folders;
	GearyFolderPath* parent;
};

struct _GearyImapEngineGenericAccountGetRequiredSpecialFolderAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GearyFolderSpecialUse special;
	GCancellable* cancellable;
	GearyFolder* result;
	gint _tmp0_;
	GearyFolderSpecialUse* _tmp1_;
	GearyFolderSpecialUse* _tmp2_;
	gint _tmp2__length1;
	gboolean _tmp3_;
	gchar* _tmp4_;
	GError* _tmp5_;
	GError* _tmp6_;
	GearyFolder* folder;
	GearyFolder* _tmp7_;
	GearyFolder* _tmp8_;
	GearyImapAccountSession* account;
	GearyImapAccountSession* _tmp9_;
	GearyFolder* _tmp10_;
	GearyImapAccountSession* _tmp11_;
	GearyFolder* _tmp12_;
	GearyFolder* _tmp13_;
	GError* _inner_error1_;
	GearyImapAccountSession* _tmp14_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountCreatePersonalFolderData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	gchar* name;
	GearyFolderSpecialUse use;
	GCancellable* cancellable;
	GearyFolder* result;
	GearyImapAccountSession* remote;
	GearyImapAccountSession* _tmp0_;
	GearyFolderPath* root;
	GearyImapAccountSession* _tmp1_;
	GearyFolderPath* _tmp2_;
	GearyFolderPath* path;
	GearyFolderPath* _tmp3_;
	GearyFolderPath* _tmp4_;
	GeeMap* _tmp5_;
	GearyFolderPath* _tmp6_;
	GearyFolderPath* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GError* _tmp10_;
	GError* _tmp11_;
	GearyImapAccountSession* _tmp12_;
	GearyFolderPath* _tmp13_;
	GearyImapFolder* remote_folder;
	GearyImapAccountSession* _tmp14_;
	GearyFolderPath* _tmp15_;
	GearyImapFolder* _tmp16_;
	GearyImapDBFolder* local_folder;
	GearyImapDBAccount* _tmp17_;
	GearyImapFolder* _tmp18_;
	GearyImapDBFolder* _tmp19_;
	GearyImapDBFolder* _tmp20_;
	GeeCollection* _tmp21_;
	GeeCollection* _tmp22_;
	GeeCollection* _tmp23_;
	GeeCollection* _tmp24_;
	GearyImapEngineMinimalFolder* folder;
	GeeMap* _tmp25_;
	GearyFolderPath* _tmp26_;
	gpointer _tmp27_;
	GearyImapEngineMinimalFolder* _tmp28_;
	GeeMap* _tmp29_;
	GeeMap* _tmp30_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GearyRFC822MessageID* message_id;
	GearyEmailField requested_fields;
	gboolean partial_ok;
	GeeCollection* folder_blacklist;
	GearyEmailFlags* flag_blacklist;
	GCancellable* cancellable;
	GeeMultiMap* result;
	GeeMultiMap* _tmp0_;
	GearyImapDBAccount* _tmp1_;
	GeeMultiMap* _tmp2_;
	GeeMultiMap* _tmp3_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountLocalFetchEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GearyEmailIdentifier* email_id;
	GearyEmailField required_fields;
	GCancellable* cancellable;
	GearyEmail* result;
	GearyImapDBEmailIdentifier* _tmp0_;
	GearyImapDBEmailIdentifier* _tmp1_;
	GearyEmail* _tmp2_;
	GearyImapDBAccount* _tmp3_;
	GearyEmail* _tmp4_;
	GearyEmail* _tmp5_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountListLocalEmailAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GeeCollection* ids;
	GearyEmailField required_fields;
	GCancellable* cancellable;
	GeeList* result;
	GeeCollection* _tmp0_;
	GeeCollection* _tmp1_;
	GeeList* _tmp2_;
	GearyImapDBAccount* _tmp3_;
	GeeList* _tmp4_;
	GeeList* _tmp5_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountLocalSearchAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GearySearchQuery* query;
	gint limit;
	gint offset;
	GeeCollection* folder_blacklist;
	GeeCollection* search_ids;
	GCancellable* cancellable;
	GeeCollection* result;
	GError* _tmp0_;
	GeeCollection* _tmp1_;
	GearyImapDBAccount* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountGetSearchMatchesAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GearySearchQuery* query;
	GeeCollection* ids;
	GCancellable* cancellable;
	GeeSet* result;
	GeeCollection* _tmp0_;
	GeeCollection* _tmp1_;
	GeeSet* _tmp2_;
	GearyImapDBAccount* _tmp3_;
	GeeSet* _tmp4_;
	GeeSet* _tmp5_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountGetContainingFoldersAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GeeCollection* ids;
	GCancellable* cancellable;
	GeeMultiMap* result;
	GeeMultiMap* map;
	GeeHashMultiMap* _tmp0_;
	GearyImapDBAccount* _tmp1_;
	GeeMultiMap* _tmp2_;
	GeeIterator* _folder_it;
	GeeMap* _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	GeeCollection* _tmp6_;
	GeeIterator* _tmp7_;
	GeeIterator* _tmp8_;
	GeeIterator* _tmp9_;
	GearyFolder* folder;
	GeeIterator* _tmp10_;
	gpointer _tmp11_;
	GearyFolderPath* path;
	GearyFolder* _tmp12_;
	GearyFolderPath* _tmp13_;
	GearyFolderPath* _tmp14_;
	GearyFolderPath* _tmp15_;
	GeeCollection* matching;
	GearyFolder* _tmp16_;
	GeeCollection* _tmp17_;
	GeeIterator* _id_it;
	GeeCollection* _tmp18_;
	GeeIterator* _tmp19_;
	GeeIterator* _tmp20_;
	GearyEmailIdentifier* id;
	GeeIterator* _tmp21_;
	gpointer _tmp22_;
	GeeMultiMap* _tmp23_;
	GearyEmailIdentifier* _tmp24_;
	GearyFolderPath* _tmp25_;
	GeeMultiMap* _tmp26_;
	GeeMultiMap* _tmp27_;
	gint _tmp28_;
	gint _tmp29_;
	GeeMultiMap* _tmp30_;
	GeeMultiMap* _tmp31_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountCleanupStorageData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GCancellable* cancellable;
	GearyAccountInformation* _tmp0_;
	GearyAccountInformation* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GDateTime* now;
	GDateTime* _tmp4_;
	GDateTime* last_cleanup;
	GDateTime* _tmp5_;
	GDateTime* _tmp6_;
	GDateTime* _tmp7_;
	gboolean _tmp8_;
	GDateTime* _tmp9_;
	GDateTime* _tmp10_;
	GDateTime* _tmp11_;
	GDateTime* _tmp12_;
	GearyImapEngineAccountSynchronizer* _tmp13_;
	GearyImapDBAccount* _tmp14_;
	GearyImapDBDatabase* _tmp15_;
	GearyImapDBDatabase* _tmp16_;
	gboolean _tmp17_;
	gboolean _tmp18_;
	GearyImapDBAccount* _tmp19_;
	GearyImapDBDatabase* _tmp20_;
	GearyImapDBDatabase* _tmp21_;
	GearyImapClientService* _tmp22_;
	GearyClientService* _tmp23_;
	GearySmtpClientService* _tmp24_;
	GearyClientService* _tmp25_;
	GearyClientService** _tmp26_;
	GeeArrayList* _tmp27_;
	GeeArrayList* _tmp28_;
	GError* _inner_error0_;
};

struct _GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineGenericAccount* self;
	GearyImapAccountSession* remote;
	GearyFolderSpecialUse use;
	GCancellable* cancellable;
	GearyFolder* result;
	GearyFolder* special;
	GearyFolder* _tmp0_;
	GearyFolder* _tmp1_;
	GearyFolderPath* path;
	GearyAccountInformation* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyImapDBAccount* _tmp4_;
	GearyImapFolderRoot* _tmp5_;
	GearyImapFolderRoot* _tmp6_;
	GearyFolderPath* _tmp7_;
	gboolean _tmp8_;
	GearyFolderPath* _tmp9_;
	gboolean _tmp10_;
	GearyFolderPath* _tmp11_;
	GearyFolderPath* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	GearyFolderPath* _tmp16_;
	GearyFolderPath* root;
	GearyFolderPath* _tmp17_;
	GeeList* search_names;
	GeeMap* _tmp18_;
	gpointer _tmp19_;
	GeeList* _search_name_list;
	GeeList* _tmp20_;
	gint _search_name_size;
	GeeList* _tmp21_;
	gint _tmp22_;
	gint _tmp23_;
	gint _search_name_index;
	gint _tmp24_;
	gint _tmp25_;
	gchar* search_name;
	GeeList* _tmp26_;
	gpointer _tmp27_;
	GearyFolderPath* search_path;
	GearyFolderPath* _tmp28_;
	const gchar* _tmp29_;
	GearyFolderPath* _tmp30_;
	GeeIterator* _test_path_it;
	GeeMap* _tmp31_;
	GeeSet* _tmp32_;
	GeeSet* _tmp33_;
	GeeSet* _tmp34_;
	GeeIterator* _tmp35_;
	GeeIterator* _tmp36_;
	GeeIterator* _tmp37_;
	GearyFolderPath* test_path;
	GeeIterator* _tmp38_;
	gpointer _tmp39_;
	GearyFolderPath* _tmp40_;
	GearyFolderPath* _tmp41_;
	GearyFolderPath* _tmp42_;
	GearyFolderPath* _tmp43_;
	GearyFolderPath* _tmp44_;
	GearyFolderPath* _tmp45_;
	GearyFolderPath* _tmp46_;
	GeeList* _tmp47_;
	gpointer _tmp48_;
	gchar* _tmp49_;
	GearyFolderPath* _tmp50_;
	GearyFolderPath* _tmp51_;
	gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	GearyAccountInformation* _tmp55_;
	GearyAccountInformation* _tmp56_;
	GearyFolderPath* _tmp57_;
	gint _tmp58_;
	gchar** _tmp59_;
	GeeArrayList* _tmp60_;
	GeeArrayList* _tmp61_;
	GeeMap* _tmp62_;
	GearyFolderPath* _tmp63_;
	GeeMap* _tmp64_;
	GearyFolderPath* _tmp65_;
	gpointer _tmp66_;
	GearyFolder* _tmp67_;
	GeeMap* _tmp68_;
	GeeMap* _tmp69_;
	GearyFolderPath* _tmp70_;
	gchar* _tmp71_;
	gchar* _tmp72_;
	gchar* _tmp73_;
	GearyFolder* _tmp74_;
	GearyFolderPath* _tmp75_;
	const gchar* _tmp76_;
	const gchar* _tmp77_;
	GearyFolder* _tmp78_;
	GearyFolder* _tmp79_;
	GError* _inner_error0_;
};

struct _GearyImapEngineLoadFolders {
	GearyImapEngineAccountOperation parent_instance;
	GearyImapEngineLoadFoldersPrivate * priv;
};

struct _GearyImapEngineLoadFoldersClass {
	GearyImapEngineAccountOperationClass parent_class;
};

struct _GearyImapEngineLoadFoldersPrivate {
	GearyImapDBAccount* local;
	GeeList* folders;
};

struct _GearyImapEngineLoadFoldersExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineLoadFolders* self;
	GCancellable* cancellable;
	GearyImapEngineGenericAccount* generic;
	GearyAccount* _tmp0_;
	GearyAccount* _tmp1_;
	GearyImapEngineGenericAccount* _tmp2_;
	GearyImapDBAccount* _tmp3_;
	GearyImapDBAccount* _tmp4_;
	GearyImapFolderRoot* _tmp5_;
	GearyImapFolderRoot* _tmp6_;
	GeeList* _tmp7_;
	GeeCollection* _tmp8_;
	GeeCollection* _tmp9_;
	GError* _inner_error0_;
};

struct _GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineLoadFolders* self;
	GearyFolderPath* parent;
	GCancellable* cancellable;
	GeeCollection* children;
	GeeCollection* _tmp0_;
	GearyImapDBAccount* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GError* err;
	GError* _tmp4_;
	GError* _tmp5_;
	GError* _tmp6_;
	GeeCollection* _tmp7_;
	GeeIterator* _child_it;
	GeeCollection* _tmp8_;
	GeeIterator* _tmp9_;
	GeeIterator* _tmp10_;
	GearyImapDBFolder* child;
	GeeIterator* _tmp11_;
	gpointer _tmp12_;
	GeeList* _tmp13_;
	GearyImapDBFolder* _tmp14_;
	GearyImapDBFolder* _tmp15_;
	GearyFolderPath* _tmp16_;
	GError* _inner_error0_;
};

struct _GearyImapEngineStartServices {
	GearyImapEngineAccountOperation parent_instance;
	GearyImapEngineStartServicesPrivate * priv;
};

struct _GearyImapEngineStartServicesClass {
	GearyImapEngineAccountOperationClass parent_class;
};

struct _GearyImapEngineStartServicesPrivate {
	GearyOutboxFolder* outbox;
};

struct _GearyImapEngineStartServicesExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineStartServices* self;
	GCancellable* cancellable;
	GearyAccount* _tmp0_;
	GearyAccount* _tmp1_;
	GearyClientService* _tmp2_;
	GearyClientService* _tmp3_;
	GearyAccount* _tmp4_;
	GearyAccount* _tmp5_;
	GearyOutboxFolder* _tmp6_;
	GearyAccount* _tmp7_;
	GearyAccount* _tmp8_;
	GearyClientService* _tmp9_;
	GearyClientService* _tmp10_;
	GError* _inner_error0_;
};

struct _GearyImapEnginePopulateSearchTable {
	GearyImapEngineAccountOperation parent_instance;
	GearyImapEnginePopulateSearchTablePrivate * priv;
};

struct _GearyImapEnginePopulateSearchTableClass {
	GearyImapEngineAccountOperationClass parent_class;
};

struct _GearyImapEnginePopulateSearchTableExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEnginePopulateSearchTable* self;
	GCancellable* cancellable;
	GearyAccount* _tmp0_;
	GearyAccount* _tmp1_;
	GearyImapDBAccount* _tmp2_;
	GearyImapDBAccount* _tmp3_;
};

struct _GearyImapEngineUpdateRemoteFolders {
	GearyImapEngineAccountOperation parent_instance;
	GearyImapEngineUpdateRemoteFoldersPrivate * priv;
};

struct _GearyImapEngineUpdateRemoteFoldersClass {
	GearyImapEngineAccountOperationClass parent_class;
};

struct _GearyImapEngineUpdateRemoteFoldersPrivate {
	GearyImapEngineGenericAccount* generic_account;
	gboolean already_connected;
	GearyFolderSpecialUse* specials;
	gint specials_length1;
	gint _specials_size_;
};

struct _GearyImapEngineUpdateRemoteFoldersExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineUpdateRemoteFolders* self;
	GCancellable* cancellable;
	GeeTreeMap* existing_folders;
	GeeTreeMap* _tmp0_;
	GeeTreeMap* remote_folders;
	GeeTreeMap* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccount* _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	GearyIterable* _tmp6_;
	GearyIterable* _tmp7_;
	GeeTreeMap* _tmp8_;
	GeeMap* _tmp9_;
	GeeMap* _tmp10_;
	GearyImapEngineGenericAccount* account;
	GearyAccount* _tmp11_;
	GearyAccount* _tmp12_;
	GearyImapEngineGenericAccount* _tmp13_;
	GearyImapAccountSession* remote;
	GearyImapEngineGenericAccount* _tmp14_;
	GearyImapAccountSession* _tmp15_;
	gboolean is_suspect;
	GearyImapAccountSession* _tmp16_;
	GeeTreeMap* _tmp17_;
	GearyImapEngineGenericAccount* _tmp18_;
	GearyImapDBAccount* _tmp19_;
	GearyImapDBAccount* _tmp20_;
	GearyImapFolderRoot* _tmp21_;
	GearyImapFolderRoot* _tmp22_;
	GeeIterator* _path_it;
	GeeTreeMap* _tmp23_;
	GeeSet* _tmp24_;
	GeeSet* _tmp25_;
	GeeSet* _tmp26_;
	GeeIterator* _tmp27_;
	GeeIterator* _tmp28_;
	GeeIterator* _tmp29_;
	GearyFolderPath* path;
	GeeIterator* _tmp30_;
	gpointer _tmp31_;
	GearyFolderPath* _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	GearyFolderPath* _tmp35_;
	GeeIterator* _vala1__path_it;
	GeeTreeMap* _tmp36_;
	GeeSet* _tmp37_;
	GeeSet* _tmp38_;
	GeeSet* _tmp39_;
	GeeIterator* _tmp40_;
	GeeIterator* _tmp41_;
	GeeIterator* _tmp42_;
	GearyFolderPath* _vala1_path;
	GeeIterator* _tmp43_;
	gpointer _tmp44_;
	GearyFolderPath* _tmp45_;
	gchar* _tmp46_;
	gchar* _tmp47_;
	GearyFolderPath* _tmp48_;
	GearyImapAccountSession* _tmp49_;
	GeeTreeMap* _tmp50_;
	GeeTreeMap* _tmp51_;
	GError* _inner_error1_;
	GearyImapEngineGenericAccount* _tmp52_;
	GearyImapAccountSession* _tmp53_;
	GError* _inner_error0_;
};

struct _GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineUpdateRemoteFolders* self;
	GearyImapAccountSession* remote;
	GeeMap* folders;
	GearyFolderPath* parent;
	GCancellable* cancellable;
	gboolean result;
	gboolean results_suspect;
	GeeList* children;
	GeeList* _tmp0_;
	GeeList* _tmp1_;
	GeeList* _tmp2_;
	GError* err;
	gboolean _tmp3_;
	GError* _tmp4_;
	GError* _tmp5_;
	GError* _tmp6_;
	GError* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	GError* _tmp11_;
	const gchar* _tmp12_;
	GeeList* _tmp13_;
	GeeList* _child_list;
	GeeList* _tmp14_;
	gint _child_size;
	GeeList* _tmp15_;
	gint _tmp16_;
	gint _tmp17_;
	gint _child_index;
	gint _tmp18_;
	gint _tmp19_;
	GearyImapFolder* child;
	GeeList* _tmp20_;
	gpointer _tmp21_;
	GearyFolderPath* path;
	GearyImapFolder* _tmp22_;
	GearyFolderPath* _tmp23_;
	GearyFolderPath* _tmp24_;
	GearyFolderPath* _tmp25_;
	GearyFolderPath* _tmp26_;
	GearyImapFolder* _tmp27_;
	gboolean _tmp28_;
	GearyImapFolder* _tmp29_;
	GearyImapFolderProperties* _tmp30_;
	GearyImapFolderProperties* _tmp31_;
	GearyTrillian _tmp32_;
	GearyTrillian _tmp33_;
	gboolean _tmp34_;
	GearyFolderPath* _tmp35_;
	GError* _inner_error0_;
};

struct _Block97Data {
	int _ref_count_;
	GearyImapEngineUpdateRemoteFolders* self;
	GeeMap* existing_folders;
	GeeMap* remote_folders;
	gpointer _async_data_;
};

struct _GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineUpdateRemoteFolders* self;
	GearyImapAccountSession* remote;
	GeeMap* existing_folders;
	GeeMap* remote_folders;
	gboolean remote_folders_suspect;
	GCancellable* cancellable;
	Block97Data* _data97_;
	GeeHashSet* altered_paths;
	GeeHashSet* _tmp0_;
	GeeIterator* _remote_folder_it;
	GeeCollection* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GeeIterator* _tmp4_;
	GeeIterator* _tmp5_;
	GeeIterator* _tmp6_;
	GearyImapFolder* remote_folder;
	GeeIterator* _tmp7_;
	gpointer _tmp8_;
	GearyImapEngineMinimalFolder* minimal_folder;
	GearyImapFolder* _tmp9_;
	GearyFolderPath* _tmp10_;
	GearyFolderPath* _tmp11_;
	gpointer _tmp12_;
	GearyFolder* _tmp13_;
	GearyImapEngineMinimalFolder* _tmp14_;
	GearyImapEngineMinimalFolder* _tmp15_;
	GearyImapFolder* _tmp16_;
	GearyImapFolderProperties* _tmp17_;
	GearyImapFolderProperties* _tmp18_;
	GearyTrillian _tmp19_;
	GearyTrillian _tmp20_;
	GearyImapDBFolder* local_folder;
	GearyImapEngineMinimalFolder* _tmp21_;
	GearyImapDBFolder* _tmp22_;
	GearyImapDBFolder* _tmp23_;
	GearyImapDBFolder* _tmp24_;
	GearyImapFolder* _tmp25_;
	GearyImapFolderProperties* _tmp26_;
	GearyImapFolderProperties* _tmp27_;
	GearyImapDBFolder* _tmp28_;
	GearyImapFolderProperties* _tmp29_;
	GearyImapFolderProperties* _tmp30_;
	GearyImapEngineMinimalFolder* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	gboolean _tmp34_;
	GeeHashSet* _tmp35_;
	GearyImapFolder* _tmp36_;
	GearyFolderPath* _tmp37_;
	GearyFolderPath* _tmp38_;
	GearyImapEngineMinimalFolder* _tmp39_;
	GearyImapDBFolder* _tmp40_;
	GearyImapDBFolder* _tmp41_;
	GearyImapFolder* _tmp42_;
	GearyImapFolderProperties* _tmp43_;
	GearyImapFolderProperties* _tmp44_;
	GError* update_error;
	GearyImapFolder* _tmp45_;
	GearyFolderPath* _tmp46_;
	GearyFolderPath* _tmp47_;
	gchar* _tmp48_;
	gchar* _tmp49_;
	GError* _tmp50_;
	const gchar* _tmp51_;
	GearyImapEngineMinimalFolder* _tmp52_;
	GearyFolderSpecialUse _tmp53_;
	GearyFolderSpecialUse _tmp54_;
	GearyImapEngineMinimalFolder* _tmp55_;
	GearyImapFolder* _tmp56_;
	GearyImapFolderProperties* _tmp57_;
	GearyImapFolderProperties* _tmp58_;
	GearyImapMailboxAttributes* _tmp59_;
	GearyImapMailboxAttributes* _tmp60_;
	GeeArrayList* to_add;
	GeeCollection* _tmp61_;
	GeeCollection* _tmp62_;
	GeeCollection* _tmp63_;
	GearyIterable* _tmp64_;
	GearyIterable* _tmp65_;
	GearyIterable* _tmp66_;
	GearyIterable* _tmp67_;
	GeeArrayList* _tmp68_;
	GeeArrayList* _tmp69_;
	GeeArrayList* to_remove;
	GearyIterable* _tmp70_;
	GearyIterable* _tmp71_;
	GearyIterable* _tmp72_;
	GearyIterable* _tmp73_;
	GearyIterable* _tmp74_;
	GearyIterable* _tmp75_;
	GeeArrayList* _tmp76_;
	GeeArrayList* _tmp77_;
	GearyImapEngineGenericAccount* generic_account;
	GearyAccount* _tmp78_;
	GearyAccount* _tmp79_;
	GearyImapEngineGenericAccount* _tmp80_;
	GearyImapDBAccount* local;
	GearyImapEngineGenericAccount* _tmp81_;
	GearyImapDBAccount* _tmp82_;
	GearyImapDBAccount* _tmp83_;
	GearyImapDBAccount* _tmp84_;
	GeeArrayList* to_build;
	GeeArrayList* _tmp85_;
	GeeArrayList* _remote_folder_list;
	GeeArrayList* _tmp86_;
	gint _remote_folder_size;
	GeeArrayList* _tmp87_;
	gint _tmp88_;
	gint _tmp89_;
	gint _remote_folder_index;
	gint _tmp90_;
	gint _tmp91_;
	GearyImapFolder* _vala1_remote_folder;
	GeeArrayList* _tmp92_;
	gpointer _tmp93_;
	GearyImapDBFolder* _tmp94_;
	GearyImapDBAccount* _tmp95_;
	GearyImapFolder* _tmp96_;
	GearyImapDBFolder* _tmp97_;
	GeeArrayList* _tmp98_;
	GError* err;
	GearyImapFolder* _tmp99_;
	GearyFolderPath* _tmp100_;
	GearyFolderPath* _tmp101_;
	gchar* _tmp102_;
	gchar* _tmp103_;
	GError* _tmp104_;
	const gchar* _tmp105_;
	GearyImapEngineGenericAccount* _tmp106_;
	GeeArrayList* _tmp107_;
	GeeCollection* _tmp108_;
	GeeCollection* _tmp109_;
	GeeBidirSortedSet* removed;
	GearyImapEngineGenericAccount* _tmp110_;
	GeeArrayList* _tmp111_;
	GeeBidirSortedSet* _tmp112_;
	GeeBidirIterator* removed_iterator;
	GeeBidirSortedSet* _tmp113_;
	GeeBidirIterator* _tmp114_;
	gboolean has_prev;
	GeeBidirIterator* _tmp115_;
	GearyImapEngineMinimalFolder* folder;
	GeeBidirIterator* _tmp116_;
	gpointer _tmp117_;
	GearyImapEngineMinimalFolder* _tmp118_;
	gchar* _tmp119_;
	gchar* _tmp120_;
	GearyImapDBAccount* _tmp121_;
	GearyImapEngineMinimalFolder* _tmp122_;
	GearyFolderPath* _tmp123_;
	GearyFolderPath* _tmp124_;
	GError* e;
	GearyImapEngineMinimalFolder* _tmp125_;
	gchar* _tmp126_;
	gchar* _tmp127_;
	GError* _tmp128_;
	const gchar* _tmp129_;
	GeeBidirIterator* _tmp130_;
	GeeBidirSortedSet* _tmp131_;
	GearyIterable* _tmp132_;
	GearyIterable* _tmp133_;
	GearyIterable* _tmp134_;
	GearyIterable* _tmp135_;
	GeeArrayList* _tmp136_;
	GeeArrayList* _tmp137_;
	GeeHashSet* _tmp138_;
	gint _tmp139_;
	gint _tmp140_;
	GeeArrayList* altered;
	GeeArrayList* _tmp141_;
	GeeIterator* _altered_path_it;
	GeeHashSet* _tmp142_;
	GeeIterator* _tmp143_;
	GeeIterator* _tmp144_;
	GearyFolderPath* altered_path;
	GeeIterator* _tmp145_;
	gpointer _tmp146_;
	GearyFolderPath* _tmp147_;
	GeeArrayList* _tmp148_;
	GearyFolderPath* _tmp149_;
	gpointer _tmp150_;
	GearyFolder* _tmp151_;
	GearyFolderPath* _tmp152_;
	gchar* _tmp153_;
	gchar* _tmp154_;
	GearyImapEngineGenericAccount* _tmp155_;
	GeeArrayList* _tmp156_;
	gint _tmp157_;
	gint _tmp158_;
	GeeArrayList* remotes;
	GeeArrayList* _tmp159_;
	GeeIterator* _path_it;
	GeeSet* _tmp160_;
	GeeSet* _tmp161_;
	GeeSet* _tmp162_;
	GeeIterator* _tmp163_;
	GeeIterator* _tmp164_;
	GeeIterator* _tmp165_;
	GearyFolderPath* path;
	GeeIterator* _tmp166_;
	gpointer _tmp167_;
	GearyFolderPath* _tmp168_;
	GeeArrayList* _tmp169_;
	GearyFolderPath* _tmp170_;
	gpointer _tmp171_;
	GearyFolder* _tmp172_;
	GearyFolderPath* _tmp173_;
	gchar* _tmp174_;
	gchar* _tmp175_;
	GearyImapEngineGenericAccount* _tmp176_;
	GearyImapEngineAccountSynchronizer* _tmp177_;
	GearyImapEngineAccountSynchronizer* _tmp178_;
	GeeArrayList* _tmp179_;
	GearyFolderSpecialUse* _tmp180_;
	gint _tmp180__length1;
	GearyFolderSpecialUse* use_collection;
	gint use_collection_length1;
	gint _use_collection_size_;
	gint use_it;
	GearyFolderSpecialUse use;
	GearyImapEngineGenericAccount* _tmp181_;
	GearyFolder* _tmp182_;
	GearyFolder* _tmp183_;
	GError* _vala1_e;
	gchar* _tmp184_;
	GError* _tmp185_;
	const gchar* _tmp186_;
	GError* _inner_error0_;
};

struct _GearyImapEngineRefreshFolderUnseen {
	GearyImapEngineFolderOperation parent_instance;
	GearyImapEngineRefreshFolderUnseenPrivate * priv;
};

struct _GearyImapEngineRefreshFolderUnseenClass {
	GearyImapEngineFolderOperationClass parent_class;
};

struct _GearyImapEngineRefreshFolderUnseenExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GearyImapEngineRefreshFolderUnseen* self;
	GCancellable* cancellable;
	GearyImapEngineGenericAccount* account;
	GearyAccount* _tmp0_;
	GearyAccount* _tmp1_;
	GearyImapEngineGenericAccount* _tmp2_;
	GearyFolder* _tmp3_;
	GearyFolder* _tmp4_;
	GearyImapAccountSession* remote;
	GearyImapEngineGenericAccount* _tmp5_;
	GearyImapAccountSession* _tmp6_;
	GearyImapFolder* remote_folder;
	GearyImapAccountSession* _tmp7_;
	GearyFolder* _tmp8_;
	GearyFolder* _tmp9_;
	GearyFolderPath* _tmp10_;
	GearyFolderPath* _tmp11_;
	GearyImapFolder* _tmp12_;
	GearyImapDBFolder* local_folder;
	GearyFolder* _tmp13_;
	GearyFolder* _tmp14_;
	GearyImapDBFolder* _tmp15_;
	GearyImapDBFolder* _tmp16_;
	GearyImapDBFolder* _tmp17_;
	GearyImapFolder* _tmp18_;
	GearyImapFolderProperties* _tmp19_;
	GearyImapFolderProperties* _tmp20_;
	GearyImapDBFolder* _tmp21_;
	GearyImapFolderProperties* _tmp22_;
	GearyImapFolderProperties* _tmp23_;
	GearyFolder* _tmp24_;
	GearyFolder* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	gboolean _tmp28_;
	GearyImapDBFolder* _tmp29_;
	GearyImapFolder* _tmp30_;
	GearyImapFolderProperties* _tmp31_;
	GearyImapFolderProperties* _tmp32_;
	GearyAccount* _tmp33_;
	GearyAccount* _tmp34_;
	GearyFolder* _tmp35_;
	GearyFolder* _tmp36_;
	GError* _inner_error1_;
	GearyImapEngineGenericAccount* _tmp37_;
	GearyImapAccountSession* _tmp38_;
	GError* _inner_error0_;
};

static gint GearyImapEngineGenericAccount_private_offset;
static gpointer geary_imap_engine_generic_account_parent_class = NULL;
static GVariantType* geary_imap_engine_generic_account_email_id_type;
static GVariantType* geary_imap_engine_generic_account_email_id_type = NULL;
static gint GearyImapEngineLoadFolders_private_offset;
static gpointer geary_imap_engine_load_folders_parent_class = NULL;
static gint GearyImapEngineStartServices_private_offset;
static gpointer geary_imap_engine_start_services_parent_class = NULL;
static gpointer geary_imap_engine_populate_search_table_parent_class = NULL;
static gint GearyImapEngineUpdateRemoteFolders_private_offset;
static gpointer geary_imap_engine_update_remote_folders_parent_class = NULL;
static gpointer geary_imap_engine_refresh_folder_unseen_parent_class = NULL;

VALA_EXTERN GType geary_imap_engine_generic_account_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_minimal_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_db_account_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_account_synchronizer_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType geary_imap_engine_account_processor_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineMinimalFolder* geary_imap_engine_generic_account_new_folder (GearyImapEngineGenericAccount* self,
                                                                            GearyImapDBFolder* local_folder);
VALA_EXTERN GearyFolderSpecialUse* geary_imap_engine_generic_account_get_supported_special_folders (GearyImapEngineGenericAccount* self,
                                                                                        gint* result_length1);
VALA_EXTERN GearyImapClientService* geary_imap_engine_generic_account_get_imap (GearyImapEngineGenericAccount* self);
static void geary_imap_engine_generic_account_set_imap (GearyImapEngineGenericAccount* self,
                                                 GearyImapClientService* value);
VALA_EXTERN GearySmtpClientService* geary_imap_engine_generic_account_get_smtp (GearyImapEngineGenericAccount* self);
static void geary_imap_engine_generic_account_set_smtp (GearyImapEngineGenericAccount* self,
                                                 GearySmtpClientService* value);
VALA_EXTERN GearyImapDBAccount* geary_imap_engine_generic_account_get_local (GearyImapEngineGenericAccount* self);
static void geary_imap_engine_generic_account_set_local (GearyImapEngineGenericAccount* self,
                                                  GearyImapDBAccount* value);
VALA_EXTERN GearyImapEngineAccountSynchronizer* geary_imap_engine_generic_account_get_sync (GearyImapEngineGenericAccount* self);
static void geary_imap_engine_generic_account_set_sync (GearyImapEngineGenericAccount* self,
                                                 GearyImapEngineAccountSynchronizer* value);
VALA_EXTERN GearyImapEngineGenericAccount* geary_imap_engine_generic_account_construct (GType object_type,
                                                                            GearyAccountInformation* config,
                                                                            GearyImapDBAccount* local,
                                                                            GearyEndpoint* incoming_remote,
                                                                            GearyEndpoint* outgoing_remote);
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 GearyContactStoreImpl* geary_contact_store_impl_new (GearyDbDatabase* backing);
VALA_EXTERN GearyContactStoreImpl* geary_contact_store_impl_construct (GType object_type,
                                                           GearyDbDatabase* backing);
VALA_EXTERN GType geary_contact_store_impl_get_type (void) G_GNUC_CONST ;
static void geary_imap_engine_generic_account_on_imap_status_notify (GearyImapEngineGenericAccount* self);
static void _geary_imap_engine_generic_account_on_imap_status_notify_g_object_notify (GObject* _sender,
                                                                               GParamSpec* pspec,
                                                                               gpointer self);
VALA_EXTERN void geary_client_service_set_logging_parent (GearyClientService* self,
                                              GearyLoggingSource* parent);
VALA_EXTERN GearyOutboxFolder* geary_outbox_folder_new (GearyAccount* account,
                                            GearyFolderRoot* root,
                                            GearyImapDBAccount* local);
VALA_EXTERN GearyOutboxFolder* geary_outbox_folder_construct (GType object_type,
                                                  GearyAccount* account,
                                                  GearyFolderRoot* root,
                                                  GearyImapDBAccount* local);
VALA_EXTERN void geary_smtp_client_service_set_outbox (GearySmtpClientService* self,
                                           GearyOutboxFolder* value);
static void _geary_account_notify_report_problem_geary_smtp_client_service_report_problem (GearySmtpClientService* _sender,
                                                                                    GearyProblemReport* problem,
                                                                                    gpointer self);
VALA_EXTERN GearyImapEngineAccountSynchronizer* geary_imap_engine_account_synchronizer_new (GearyImapEngineGenericAccount* account);
VALA_EXTERN GearyImapEngineAccountSynchronizer* geary_imap_engine_account_synchronizer_construct (GType object_type,
                                                                                      GearyImapEngineGenericAccount* account);
static void __lambda144_ (GearyImapEngineGenericAccount* self);
static void geary_imap_engine_generic_account_update_remote_folders (GearyImapEngineGenericAccount* self,
                                                              gboolean already_connected);
static void ___lambda144__geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                       gpointer self);
VALA_EXTERN GearySimpleProgressMonitor* geary_imap_db_account_get_upgrade_monitor (GearyImapDBAccount* self);
VALA_EXTERN GearySimpleProgressMonitor* geary_imap_db_account_get_vacuum_monitor (GearyImapDBAccount* self);
static void geary_imap_engine_generic_account_compile_special_search_names (GearyImapEngineGenericAccount* self);
static gchar* geary_imap_engine_generic_account_find_appropriate_search_stemmer (GearyImapEngineGenericAccount* self);
static void geary_imap_engine_generic_account_real_open_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_open_async (GearyAccount* base,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_open_async_co (GearyImapEngineGenericAccountOpenAsyncData* _data_);
static void geary_imap_engine_generic_account_internal_open_async (GearyImapEngineGenericAccount* self,
                                                            GCancellable* cancellable,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
static void geary_imap_engine_generic_account_internal_open_finish (GearyImapEngineGenericAccount* self,
                                                             GAsyncResult* _res_,
                                                             GError** error);
static void geary_imap_engine_generic_account_open_async_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void geary_imap_engine_generic_account_internal_open_async_data_free (gpointer _data);
static gboolean geary_imap_engine_generic_account_internal_open_async_co (GearyImapEngineGenericAccountInternalOpenAsyncData* _data_);
VALA_EXTERN GearyImapEngineAccountProcessor* geary_imap_engine_account_processor_new (GearyProgressMonitor* progress);
VALA_EXTERN GearyImapEngineAccountProcessor* geary_imap_engine_account_processor_construct (GType object_type,
                                                                                GearyProgressMonitor* progress);
static void geary_imap_engine_generic_account_on_operation_error (GearyImapEngineGenericAccount* self,
                                                           GearyImapEngineAccountOperation* op,
                                                           GError* _error_);
static void _geary_imap_engine_generic_account_on_operation_error_geary_imap_engine_account_processor_operation_error (GearyImapEngineAccountProcessor* _sender,
                                                                                                                GearyImapEngineAccountOperation* op,
                                                                                                                GError* _error_,
                                                                                                                gpointer self);
VALA_EXTERN void geary_imap_engine_account_processor_set_logging_parent (GearyImapEngineAccountProcessor* self,
                                                             GearyLoggingSource* parent);
VALA_EXTERN void geary_imap_db_account_open_async (GearyImapDBAccount* self,
                                       GCancellable* cancellable,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
VALA_EXTERN void geary_imap_db_account_open_finish (GearyImapDBAccount* self,
                                        GAsyncResult* _res_,
                                        GError** error);
static void geary_imap_engine_generic_account_internal_open_async_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
VALA_EXTERN void geary_imap_db_account_fetch_last_cleanup_async (GearyImapDBAccount* self,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
VALA_EXTERN GDateTime* geary_imap_db_account_fetch_last_cleanup_finish (GearyImapDBAccount* self,
                                                            GAsyncResult* _res_,
                                                            GError** error);
static void geary_imap_engine_generic_account_on_last_storage_cleanup_notify (GearyImapEngineGenericAccount* self);
static void _geary_imap_engine_generic_account_on_last_storage_cleanup_notify_g_object_notify (GObject* _sender,
                                                                                        GParamSpec* pspec,
                                                                                        gpointer self);
VALA_EXTERN void geary_imap_engine_generic_account_queue_operation (GearyImapEngineGenericAccount* self,
                                                        GearyImapEngineAccountOperation* op,
                                                        GError** error);
VALA_EXTERN GearyImapEngineLoadFolders* geary_imap_engine_load_folders_new (GearyImapEngineGenericAccount* account,
                                                                GearyImapDBAccount* local);
VALA_EXTERN GearyImapEngineLoadFolders* geary_imap_engine_load_folders_construct (GType object_type,
                                                                      GearyImapEngineGenericAccount* account,
                                                                      GearyImapDBAccount* local);
VALA_EXTERN GType geary_imap_engine_load_folders_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEngineStartServices* geary_imap_engine_start_services_new (GearyAccount* account,
                                                                    GearyOutboxFolder* outbox);
VALA_EXTERN GearyImapEngineStartServices* geary_imap_engine_start_services_construct (GType object_type,
                                                                          GearyAccount* account,
                                                                          GearyOutboxFolder* outbox);
VALA_EXTERN GType geary_imap_engine_start_services_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapEnginePopulateSearchTable* geary_imap_engine_populate_search_table_new (GearyImapEngineGenericAccount* account);
VALA_EXTERN GearyImapEnginePopulateSearchTable* geary_imap_engine_populate_search_table_construct (GType object_type,
                                                                                       GearyImapEngineGenericAccount* account);
VALA_EXTERN GType geary_imap_engine_populate_search_table_get_type (void) G_GNUC_CONST ;
static void geary_imap_engine_generic_account_real_close_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_close_async (GearyAccount* base,
                                                         GCancellable* cancellable,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_close_async_co (GearyImapEngineGenericAccountCloseAsyncData* _data_);
static void geary_imap_engine_generic_account_close_async_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_account_processor_stop (GearyImapEngineAccountProcessor* self);
VALA_EXTERN void geary_imap_db_account_close_async (GearyImapDBAccount* self,
                                        GCancellable* cancellable,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
VALA_EXTERN void geary_imap_db_account_close_finish (GearyImapDBAccount* self,
                                         GAsyncResult* _res_,
                                         GError** error);
static gboolean geary_imap_engine_generic_account_real_is_open (GearyAccount* base);
static void geary_imap_engine_generic_account_real_cancel_remote_update (GearyAccount* base);
VALA_EXTERN gboolean geary_imap_engine_account_processor_dequeue_by_type (GearyImapEngineAccountProcessor* self,
                                                              GType type);
VALA_EXTERN GType geary_imap_engine_update_remote_folders_get_type (void) G_GNUC_CONST ;
static void geary_imap_engine_generic_account_real_rebuild_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_rebuild_async (GearyAccount* base,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_rebuild_async_co (GearyImapEngineGenericAccountRebuildAsyncData* _data_);
VALA_EXTERN void geary_imap_db_account_delete_all_data (GearyImapDBAccount* self,
                                            GCancellable* cancellable,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
VALA_EXTERN void geary_imap_db_account_delete_all_data_finish (GearyImapDBAccount* self,
                                                   GAsyncResult* _res_,
                                                   GError** error);
static void geary_imap_engine_generic_account_rebuild_async_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static void geary_imap_engine_generic_account_check_open (GearyImapEngineGenericAccount* self,
                                                   GError** error);
VALA_EXTERN void geary_imap_engine_account_processor_enqueue (GearyImapEngineAccountProcessor* self,
                                                  GearyImapEngineAccountOperation* op);
static void geary_imap_engine_generic_account_claim_account_session_data_free (gpointer _data);
VALA_EXTERN GType geary_imap_account_session_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_engine_generic_account_claim_account_session (GearyImapEngineGenericAccount* self,
                                                              GCancellable* cancellable,
                                                              GAsyncReadyCallback _callback_,
                                                              gpointer _user_data_);
VALA_EXTERN GearyImapAccountSession* geary_imap_engine_generic_account_claim_account_session_finish (GearyImapEngineGenericAccount* self,
                                                                                         GAsyncResult* _res_,
                                                                                         GError** error);
static gboolean geary_imap_engine_generic_account_claim_account_session_co (GearyImapEngineGenericAccountClaimAccountSessionData* _data_);
static void geary_imap_engine_generic_account_claim_account_session_ready (GObject* source_object,
                                                                    GAsyncResult* _res_,
                                                                    gpointer _user_data_);
VALA_EXTERN GearyImapFolderRoot* geary_imap_db_account_get_imap_folder_root (GearyImapDBAccount* self);
VALA_EXTERN GearyImapAccountSession* geary_imap_account_session_new (GearyImapFolderRoot* root,
                                                         GearyImapClientSession* session);
VALA_EXTERN GearyImapAccountSession* geary_imap_account_session_construct (GType object_type,
                                                               GearyImapFolderRoot* root,
                                                               GearyImapClientSession* session);
VALA_EXTERN void geary_imap_session_object_set_logging_parent (GearyImapSessionObject* self,
                                                   GearyLoggingSource* parent);
VALA_EXTERN void geary_imap_engine_generic_account_release_account_session (GearyImapEngineGenericAccount* self,
                                                                GearyImapAccountSession* session);
static void ___lambda128_ (GearyImapEngineGenericAccount* self,
                    GObject* obj,
                    GAsyncResult* res);
static void ____lambda128__gasync_ready_callback (GObject* source_object,
                                           GAsyncResult* res,
                                           gpointer self);
static void geary_imap_engine_generic_account_claim_folder_session_data_free (gpointer _data);
VALA_EXTERN GType geary_imap_folder_session_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_engine_generic_account_claim_folder_session (GearyImapEngineGenericAccount* self,
                                                             GearyFolderPath* path,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
VALA_EXTERN GearyImapFolderSession* geary_imap_engine_generic_account_claim_folder_session_finish (GearyImapEngineGenericAccount* self,
                                                                                       GAsyncResult* _res_,
                                                                                       GError** error);
static gboolean geary_imap_engine_generic_account_claim_folder_session_co (GearyImapEngineGenericAccountClaimFolderSessionData* _data_);
static void geary_imap_engine_generic_account_claim_folder_session_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_);
VALA_EXTERN GType geary_imap_folder_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void geary_imap_account_session_fetch_folder_async (GearyImapAccountSession* self,
                                                    GearyFolderPath* path,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
VALA_EXTERN GearyImapFolder* geary_imap_account_session_fetch_folder_finish (GearyImapAccountSession* self,
                                                                 GAsyncResult* _res_,
                                                                 GError** error);
VALA_EXTERN void geary_imap_folder_session_new (GearyImapClientSession* session,
                                    GearyImapFolder* folder,
                                    GCancellable* cancellable,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
VALA_EXTERN GearyImapFolderSession* geary_imap_folder_session_new_finish (GAsyncResult* _res_,
                                                              GError** error);
VALA_EXTERN void geary_imap_folder_session_construct (GType object_type,
                                          GearyImapClientSession* session,
                                          GearyImapFolder* folder,
                                          GCancellable* cancellable,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN GearyImapFolderSession* geary_imap_folder_session_construct_finish (GAsyncResult* _res_,
                                                                    GError** error);
static void geary_imap_engine_generic_account_release_folder_session_data_free (gpointer _data);
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 gboolean geary_imap_engine_generic_account_release_folder_session_co (GearyImapEngineGenericAccountReleaseFolderSessionData* _data_);
static void geary_imap_engine_generic_account_release_folder_session_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_);
VALA_EXTERN GearyImapFolder* geary_imap_folder_session_get_folder (GearyImapFolderSession* self);
VALA_EXTERN GearyFolderPath* geary_imap_folder_get_path (GearyImapFolder* self);
static GearyEmailIdentifier* geary_imap_engine_generic_account_real_to_email_identifier (GearyAccount* base,
                                                                                  GVariant* serialised,
                                                                                  GError** error);
VALA_EXTERN GType geary_imap_db_email_identifier_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyImapDBEmailIdentifier* geary_imap_db_email_identifier_new_from_variant (GVariant* serialised,
                                                                             GError** error);
VALA_EXTERN GearyImapDBEmailIdentifier* geary_imap_db_email_identifier_construct_from_variant (GType object_type,
                                                                                   GVariant* serialised,
                                                                                   GError** error);
VALA_EXTERN GType geary_outbox_email_identifier_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GearyOutboxEmailIdentifier* geary_outbox_email_identifier_new_from_variant (GVariant* serialised,
                                                                            GError** error);
VALA_EXTERN GearyOutboxEmailIdentifier* geary_outbox_email_identifier_construct_from_variant (GType object_type,
                                                                                  GVariant* serialised,
                                                                                  GError** error);
static GearyFolderPath* geary_imap_engine_generic_account_real_to_folder_path (GearyAccount* base,
                                                                        GVariant* serialised,
                                                                        GError** error);
static GearyFolder* geary_imap_engine_generic_account_real_get_folder (GearyAccount* base,
                                                                GearyFolderPath* path,
                                                                GError** error);
static GeeCollection* geary_imap_engine_generic_account_real_list_folders (GearyAccount* base);
static GeeCollection* geary_imap_engine_generic_account_real_list_matching_folders (GearyAccount* base,
                                                                             GearyFolderPath* parent,
                                                                             GError** error);
static Block96Data* block96_data_ref (Block96Data* _data96_);
static void block96_data_unref (void * _userdata_);
static gboolean __lambda145_ (Block96Data* _data96_,
                       GearyFolderPath* p);
static gboolean ___lambda145__gee_predicate (gconstpointer g,
                                      gpointer self);
static GearyFolder* __lambda146_ (Block96Data* _data96_,
                           GearyFolderPath* p);
static gpointer ___lambda146__gee_map_func (gpointer g,
                                     gpointer self);
static void geary_imap_engine_generic_account_real_get_required_special_folder_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_get_required_special_folder_async (GearyAccount* base,
                                                                               GearyFolderSpecialUse special,
                                                                               GCancellable* cancellable,
                                                                               GAsyncReadyCallback _callback_,
                                                                               gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_get_required_special_folder_async_co (GearyImapEngineGenericAccountGetRequiredSpecialFolderAsyncData* _data_);
static gboolean _vala_geary_folder_special_use_array_contains (GearyFolderSpecialUse * stack,
                                                        gssize stack_length,
                                                        const GearyFolderSpecialUse needle);
static void geary_imap_engine_generic_account_get_required_special_folder_async_ready (GObject* source_object,
                                                                                GAsyncResult* _res_,
                                                                                gpointer _user_data_);
VALA_EXTERN void geary_imap_engine_generic_account_ensure_special_folder_async (GearyImapEngineGenericAccount* self,
                                                                    GearyImapAccountSession* remote,
                                                                    GearyFolderSpecialUse use,
                                                                    GCancellable* cancellable,
                                                                    GAsyncReadyCallback _callback_,
                                                                    gpointer _user_data_);
VALA_EXTERN GearyFolder* geary_imap_engine_generic_account_ensure_special_folder_finish (GearyImapEngineGenericAccount* self,
                                                                             GAsyncResult* _res_,
                                                                             GError** error);
static void geary_imap_engine_generic_account_real_create_personal_folder_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_create_personal_folder (GearyAccount* base,
                                                                    const gchar* name,
                                                                    GearyFolderSpecialUse use,
                                                                    GCancellable* cancellable,
                                                                    GAsyncReadyCallback _callback_,
                                                                    gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_create_personal_folder_co (GearyImapEngineGenericAccountCreatePersonalFolderData* _data_);
static void geary_imap_engine_generic_account_create_personal_folder_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_);
VALA_EXTERN void geary_imap_account_session_get_default_personal_namespace (GearyImapAccountSession* self,
                                                                GCancellable* cancellable,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
VALA_EXTERN GearyFolderPath* geary_imap_account_session_get_default_personal_namespace_finish (GearyImapAccountSession* self,
                                                                                   GAsyncResult* _res_,
                                                                                   GError** error);
VALA_EXTERN void geary_imap_account_session_create_folder_async (GearyImapAccountSession* self,
                                                     GearyFolderPath* path,
                                                     GearyFolderSpecialUse* use,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
VALA_EXTERN void geary_imap_account_session_create_folder_finish (GearyImapAccountSession* self,
                                                      GAsyncResult* _res_,
                                                      GError** error);
VALA_EXTERN void geary_imap_db_account_clone_folder_async (GearyImapDBAccount* self,
                                               GearyImapFolder* imap_folder,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
VALA_EXTERN GearyImapDBFolder* geary_imap_db_account_clone_folder_finish (GearyImapDBAccount* self,
                                                              GAsyncResult* _res_,
                                                              GError** error);
VALA_EXTERN GeeCollection* geary_imap_engine_generic_account_add_folders (GearyImapEngineGenericAccount* self,
                                                              GeeCollection* db_folders,
                                                              gboolean are_existing);
VALA_EXTERN void geary_imap_engine_generic_account_promote_folders (GearyImapEngineGenericAccount* self,
                                                        GeeMap* specials);
static void geary_imap_engine_generic_account_real_register_local_folder (GearyAccount* base,
                                                                   GearyFolder* local,
                                                                   GError** error);
static void geary_imap_engine_generic_account_real_deregister_local_folder (GearyAccount* base,
                                                                     GearyFolder* local,
                                                                     GError** error);
static GearyImapDBEmailIdentifier* geary_imap_engine_generic_account_check_id (GearyImapEngineGenericAccount* self,
                                                                        GearyEmailIdentifier* id,
                                                                        GError** error);
static GeeCollection* geary_imap_engine_generic_account_check_ids (GearyImapEngineGenericAccount* self,
                                                            GeeCollection* ids,
                                                            GError** error);
static GearySearchQuery* geary_imap_engine_generic_account_real_new_search_query (GearyAccount* base,
                                                                           GeeList* expression,
                                                                           const gchar* text,
                                                                           GError** error);
VALA_EXTERN GearyFtsSearchQuery* geary_fts_search_query_new (GeeList* expression,
                                                 const gchar* raw,
                                                 struct sb_stemmer* stemmer);
VALA_EXTERN GearyFtsSearchQuery* geary_fts_search_query_construct (GType object_type,
                                                       GeeList* expression,
                                                       const gchar* raw,
                                                       struct sb_stemmer* stemmer);
VALA_EXTERN GType geary_fts_search_query_get_type (void) G_GNUC_CONST ;
static void geary_imap_engine_generic_account_real_local_search_message_id_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_local_search_message_id_async (GearyAccount* base,
                                                                           GearyRFC822MessageID* message_id,
                                                                           GearyEmailField requested_fields,
                                                                           gboolean partial_ok,
                                                                           GeeCollection* folder_blacklist,
                                                                           GearyEmailFlags* flag_blacklist,
                                                                           GCancellable* cancellable,
                                                                           GAsyncReadyCallback _callback_,
                                                                           gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_local_search_message_id_async_co (GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData* _data_);
VALA_EXTERN void geary_imap_db_account_search_message_id_async (GearyImapDBAccount* self,
                                                    GearyRFC822MessageID* message_id,
                                                    GearyEmailField requested_fields,
                                                    gboolean partial_ok,
                                                    GeeCollection* folder_blacklist,
                                                    GearyEmailFlags* flag_blacklist,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
VALA_EXTERN GeeMultiMap* geary_imap_db_account_search_message_id_finish (GearyImapDBAccount* self,
                                                             GAsyncResult* _res_,
                                                             GError** error);
static void geary_imap_engine_generic_account_local_search_message_id_async_ready (GObject* source_object,
                                                                            GAsyncResult* _res_,
                                                                            gpointer _user_data_);
static void geary_imap_engine_generic_account_real_local_fetch_email_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_local_fetch_email_async (GearyAccount* base,
                                                                     GearyEmailIdentifier* email_id,
                                                                     GearyEmailField required_fields,
                                                                     GCancellable* cancellable,
                                                                     GAsyncReadyCallback _callback_,
                                                                     gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_local_fetch_email_async_co (GearyImapEngineGenericAccountLocalFetchEmailAsyncData* _data_);
VALA_EXTERN void geary_imap_db_account_fetch_email_async (GearyImapDBAccount* self,
                                              GearyImapDBEmailIdentifier* email_id,
                                              GearyEmailField required_fields,
                                              GCancellable* cancellable,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
VALA_EXTERN GearyEmail* geary_imap_db_account_fetch_email_finish (GearyImapDBAccount* self,
                                                      GAsyncResult* _res_,
                                                      GError** error);
static void geary_imap_engine_generic_account_local_fetch_email_async_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_);
static void geary_imap_engine_generic_account_real_list_local_email_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_list_local_email_async (GearyAccount* base,
                                                                    GeeCollection* ids,
                                                                    GearyEmailField required_fields,
                                                                    GCancellable* cancellable,
                                                                    GAsyncReadyCallback _callback_,
                                                                    gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_list_local_email_async_co (GearyImapEngineGenericAccountListLocalEmailAsyncData* _data_);
VALA_EXTERN void geary_imap_db_account_list_email (GearyImapDBAccount* self,
                                       GeeCollection* ids,
                                       GearyEmailField required_fields,
                                       GCancellable* cancellable,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
VALA_EXTERN GeeList* geary_imap_db_account_list_email_finish (GearyImapDBAccount* self,
                                                  GAsyncResult* _res_,
                                                  GError** error);
static void geary_imap_engine_generic_account_list_local_email_async_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_);
static void geary_imap_engine_generic_account_real_local_search_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_local_search_async (GearyAccount* base,
                                                                GearySearchQuery* query,
                                                                gint limit,
                                                                gint offset,
                                                                GeeCollection* folder_blacklist,
                                                                GeeCollection* search_ids,
                                                                GCancellable* cancellable,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_local_search_async_co (GearyImapEngineGenericAccountLocalSearchAsyncData* _data_);
VALA_EXTERN void geary_imap_db_account_search_async (GearyImapDBAccount* self,
                                         GearySearchQuery* q,
                                         gint limit,
                                         gint offset,
                                         GeeCollection* excluded_folders,
                                         GeeCollection* search_ids,
                                         GCancellable* cancellable,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
VALA_EXTERN GeeCollection* geary_imap_db_account_search_finish (GearyImapDBAccount* self,
                                                    GAsyncResult* _res_,
                                                    GError** error);
static void geary_imap_engine_generic_account_local_search_async_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_);
static void geary_imap_engine_generic_account_real_get_search_matches_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_get_search_matches_async (GearyAccount* base,
                                                                      GearySearchQuery* query,
                                                                      GeeCollection* ids,
                                                                      GCancellable* cancellable,
                                                                      GAsyncReadyCallback _callback_,
                                                                      gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_get_search_matches_async_co (GearyImapEngineGenericAccountGetSearchMatchesAsyncData* _data_);
VALA_EXTERN void geary_imap_db_account_get_search_matches_async (GearyImapDBAccount* self,
                                                     GearySearchQuery* q,
                                                     GeeCollection* ids,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
VALA_EXTERN GeeSet* geary_imap_db_account_get_search_matches_finish (GearyImapDBAccount* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
static void geary_imap_engine_generic_account_get_search_matches_async_ready (GObject* source_object,
                                                                       GAsyncResult* _res_,
                                                                       gpointer _user_data_);
static void geary_imap_engine_generic_account_real_get_containing_folders_async_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_get_containing_folders_async (GearyAccount* base,
                                                                          GeeCollection* ids,
                                                                          GCancellable* cancellable,
                                                                          GAsyncReadyCallback _callback_,
                                                                          gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_get_containing_folders_async_co (GearyImapEngineGenericAccountGetContainingFoldersAsyncData* _data_);
VALA_EXTERN void geary_imap_db_account_get_containing_folders_async (GearyImapDBAccount* self,
                                                         GeeCollection* ids,
                                                         GeeMultiMap* map,
                                                         GCancellable* cancellable,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
VALA_EXTERN void geary_imap_db_account_get_containing_folders_finish (GearyImapDBAccount* self,
                                                          GAsyncResult* _res_,
                                                          GError** error);
static void geary_imap_engine_generic_account_get_containing_folders_async_ready (GObject* source_object,
                                                                           GAsyncResult* _res_,
                                                                           gpointer _user_data_);
static void geary_imap_engine_generic_account_real_cleanup_storage_data_free (gpointer _data);
static void geary_imap_engine_generic_account_real_cleanup_storage (GearyAccount* base,
                                                             GCancellable* cancellable,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_);
static gboolean geary_imap_engine_generic_account_real_cleanup_storage_co (GearyImapEngineGenericAccountCleanupStorageData* _data_);
VALA_EXTERN void geary_imap_engine_account_synchronizer_cleanup_storage (GearyImapEngineAccountSynchronizer* self);
VALA_EXTERN gboolean geary_imap_db_database_get_want_background_vacuum (GearyImapDBDatabase* 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 gint _geary_account_folder_path_comparator_gcompare_data_func (gconstpointer a,
                                                               gconstpointer b,
                                                               gpointer self);
VALA_EXTERN GearyFolderPath* geary_imap_db_folder_get_path (GearyImapDBFolder* self);
static void _geary_account_notify_report_problem_geary_imap_engine_minimal_folder_report_problem (GearyImapEngineMinimalFolder* _sender,
                                                                                           GearyProblemReport* problem,
                                                                                           gpointer self);
VALA_EXTERN void geary_imap_engine_minimal_folder_set_use (GearyImapEngineMinimalFolder* self,
                                               GearyFolderSpecialUse new_use);
VALA_EXTERN void geary_imap_engine_generic_account_update_folder (GearyImapEngineGenericAccount* self,
                                                      GearyFolder* folder);
VALA_EXTERN void geary_imap_engine_account_synchronizer_folders_contents_altered (GearyImapEngineAccountSynchronizer* self,
                                                                      GeeCollection* altered);
VALA_EXTERN void geary_imap_engine_generic_account_update_folders (GearyImapEngineGenericAccount* self,
                                                       GeeCollection* folders);
VALA_EXTERN GeeBidirSortedSet* geary_imap_engine_generic_account_remove_folders (GearyImapEngineGenericAccount* self,
                                                                     GeeCollection* folders);
static void geary_imap_engine_generic_account_ensure_special_folder_async_data_free (gpointer _data);
static gboolean geary_imap_engine_generic_account_ensure_special_folder_async_co (GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData* _data_);
VALA_EXTERN gboolean geary_imap_account_session_is_folder_path_valid (GearyImapAccountSession* self,
                                                          GearyFolderPath* path,
                                                          GError** error);
static void geary_imap_engine_generic_account_ensure_special_folder_async_ready (GObject* source_object,
                                                                          GAsyncResult* _res_,
                                                                          gpointer _user_data_);
static GearyImapEngineMinimalFolder* geary_imap_engine_generic_account_real_new_folder (GearyImapEngineGenericAccount* self,
                                                                                 GearyImapDBFolder* local_folder);
static void geary_imap_engine_generic_account_real_notify_folders_available_unavailable (GearyAccount* base,
                                                                                  GeeBidirSortedSet* available,
                                                                                  GeeBidirSortedSet* unavailable);
static void _geary_account_notify_email_appended_geary_folder_email_appended (GearyFolder* _sender,
                                                                       GeeCollection* ids,
                                                                       gpointer self);
static void _geary_account_notify_email_inserted_geary_folder_email_inserted (GearyFolder* _sender,
                                                                       GeeCollection* ids,
                                                                       gpointer self);
static void _geary_account_notify_email_removed_geary_folder_email_removed (GearyFolder* _sender,
                                                                     GeeCollection* ids,
                                                                     gpointer self);
static void _geary_account_notify_email_locally_removed_geary_folder_email_locally_removed (GearyFolder* _sender,
                                                                                     GeeCollection* ids,
                                                                                     gpointer self);
static void _geary_account_notify_email_locally_complete_geary_folder_email_locally_complete (GearyFolder* _sender,
                                                                                       GeeCollection* ids,
                                                                                       gpointer self);
static void _geary_account_notify_email_flags_changed_geary_folder_email_flags_changed (GearyFolder* _sender,
                                                                                 GeeMap* map,
                                                                                 gpointer self);
static void geary_imap_engine_generic_account_real_notify_email_appended (GearyAccount* base,
                                                                   GearyFolder* folder,
                                                                   GeeCollection* ids);
static void geary_imap_engine_generic_account_schedule_unseen_update (GearyImapEngineGenericAccount* self,
                                                               GearyFolder* folder);
static void geary_imap_engine_generic_account_real_notify_email_inserted (GearyAccount* base,
                                                                   GearyFolder* folder,
                                                                   GeeCollection* ids);
static void geary_imap_engine_generic_account_real_notify_email_removed (GearyAccount* base,
                                                                  GearyFolder* folder,
                                                                  GeeCollection* ids);
static void geary_imap_engine_generic_account_real_notify_email_locally_removed (GearyAccount* base,
                                                                          GearyFolder* folder,
                                                                          GeeCollection* ids);
static void geary_imap_engine_generic_account_real_notify_email_flags_changed (GearyAccount* base,
                                                                        GearyFolder* folder,
                                                                        GeeMap* flag_map);
VALA_EXTERN GearyImapEngineUpdateRemoteFolders* geary_imap_engine_update_remote_folders_new (GearyImapEngineGenericAccount* account,
                                                                                 gboolean already_connected,
                                                                                 GearyFolderSpecialUse* specials,
                                                                                 gint specials_length1);
VALA_EXTERN GearyImapEngineUpdateRemoteFolders* geary_imap_engine_update_remote_folders_construct (GType object_type,
                                                                                       GearyImapEngineGenericAccount* account,
                                                                                       gboolean already_connected,
                                                                                       GearyFolderSpecialUse* specials,
                                                                                       gint specials_length1);
static void __lambda143_ (GearyImapEngineGenericAccount* self);
static void ___lambda143__geary_imap_engine_account_operation_completed (GearyImapEngineAccountOperation* _sender,
                                                                  gpointer self);
VALA_EXTERN void geary_imap_engine_account_processor_dequeue (GearyImapEngineAccountProcessor* self,
                                                  GearyImapEngineAccountOperation* op);
VALA_EXTERN void geary_imap_engine_minimal_folder_refresh_unseen (GearyImapEngineMinimalFolder* self);
static GearyFolderSpecialUse* geary_imap_engine_generic_account_real_get_supported_special_folders (GearyImapEngineGenericAccount* self,
                                                                                             gint* result_length1);
static GearyFolderSpecialUse* _vala_array_dup5 (GearyFolderSpecialUse* self,
                                         gssize length);
static GeeList* geary_imap_engine_generic_account_get_special_search_names (GearyImapEngineGenericAccount* self,
                                                                     GearyFolderSpecialUse type);
VALA_EXTERN void geary_imap_db_account_set_last_cleanup_async (GearyImapDBAccount* self,
                                                   GDateTime* dt,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
VALA_EXTERN void geary_imap_db_account_set_last_cleanup_finish (GearyImapDBAccount* self,
                                                    GAsyncResult* _res_,
                                                    GError** error);
static void geary_imap_engine_generic_account_finalize (GObject * obj);
static GType geary_imap_engine_generic_account_get_type_once (void);
static void _vala_geary_imap_engine_generic_account_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec);
static void _vala_geary_imap_engine_generic_account_set_property (GObject * object,
                                                           guint property_id,
                                                           const GValue * value,
                                                           GParamSpec * pspec);
static void geary_imap_engine_load_folders_real_execute_data_free (gpointer _data);
static void geary_imap_engine_load_folders_real_execute (GearyImapEngineAccountOperation* base,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static gboolean geary_imap_engine_load_folders_real_execute_co (GearyImapEngineLoadFoldersExecuteData* _data_);
static void geary_imap_engine_load_folders_enumerate_local_folders_async (GearyImapEngineLoadFolders* self,
                                                                   GearyFolderPath* parent,
                                                                   GCancellable* cancellable,
                                                                   GAsyncReadyCallback _callback_,
                                                                   gpointer _user_data_);
static void geary_imap_engine_load_folders_enumerate_local_folders_finish (GearyImapEngineLoadFolders* self,
                                                                    GAsyncResult* _res_,
                                                                    GError** error);
static void geary_imap_engine_load_folders_execute_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void geary_imap_engine_load_folders_enumerate_local_folders_async_data_free (gpointer _data);
static gboolean geary_imap_engine_load_folders_enumerate_local_folders_async_co (GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData* _data_);
VALA_EXTERN void geary_imap_db_account_list_folders_async (GearyImapDBAccount* self,
                                               GearyFolderPath* parent,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
VALA_EXTERN GeeCollection* geary_imap_db_account_list_folders_finish (GearyImapDBAccount* self,
                                                          GAsyncResult* _res_,
                                                          GError** error);
static void geary_imap_engine_load_folders_enumerate_local_folders_async_ready (GObject* source_object,
                                                                         GAsyncResult* _res_,
                                                                         gpointer _user_data_);
static void geary_imap_engine_load_folders_finalize (GObject * obj);
static GType geary_imap_engine_load_folders_get_type_once (void);
static void geary_imap_engine_start_services_real_execute_data_free (gpointer _data);
static void geary_imap_engine_start_services_real_execute (GearyImapEngineAccountOperation* base,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
static gboolean geary_imap_engine_start_services_real_execute_co (GearyImapEngineStartServicesExecuteData* _data_);
static void geary_imap_engine_start_services_execute_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
static void geary_imap_engine_start_services_finalize (GObject * obj);
static GType geary_imap_engine_start_services_get_type_once (void);
static void geary_imap_engine_populate_search_table_real_execute_data_free (gpointer _data);
static void geary_imap_engine_populate_search_table_real_execute (GearyImapEngineAccountOperation* base,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
static gboolean geary_imap_engine_populate_search_table_real_execute_co (GearyImapEnginePopulateSearchTableExecuteData* _data_);
VALA_EXTERN void geary_imap_db_account_populate_search_table (GearyImapDBAccount* self,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN void geary_imap_db_account_populate_search_table_finish (GearyImapDBAccount* self,
                                                         GAsyncResult* _res_);
static void geary_imap_engine_populate_search_table_execute_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static GType geary_imap_engine_populate_search_table_get_type_once (void);
static GearyFolderSpecialUse* _vala_array_dup6 (GearyFolderSpecialUse* self,
                                         gssize length);
static void geary_imap_engine_update_remote_folders_real_execute_data_free (gpointer _data);
static void geary_imap_engine_update_remote_folders_real_execute (GearyImapEngineAccountOperation* base,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
static gboolean geary_imap_engine_update_remote_folders_real_execute_co (GearyImapEngineUpdateRemoteFoldersExecuteData* _data_);
static gint __lambda134_ (GearyImapEngineUpdateRemoteFolders* self,
                   GearyFolderPath* a,
                   GearyFolderPath* b);
static gint ___lambda134__gcompare_data_func (gconstpointer a,
                                       gconstpointer b,
                                       gpointer self);
static gint __lambda135_ (GearyImapEngineUpdateRemoteFolders* self,
                   GearyFolderPath* a,
                   GearyFolderPath* b);
static gint ___lambda135__gcompare_data_func (gconstpointer a,
                                       gconstpointer b,
                                       gpointer self);
static GearyFolderPath* __lambda136_ (GearyImapEngineUpdateRemoteFolders* self,
                               GearyFolder* f);
static gpointer ___lambda136__gee_map_func (gpointer g,
                                     gpointer self);
static void geary_imap_engine_update_remote_folders_execute_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static void geary_imap_engine_update_remote_folders_enumerate_remote_folders_async (GearyImapEngineUpdateRemoteFolders* self,
                                                                             GearyImapAccountSession* remote,
                                                                             GeeMap* folders,
                                                                             GearyFolderPath* parent,
                                                                             GCancellable* cancellable,
                                                                             GAsyncReadyCallback _callback_,
                                                                             gpointer _user_data_);
static gboolean geary_imap_engine_update_remote_folders_enumerate_remote_folders_finish (GearyImapEngineUpdateRemoteFolders* self,
                                                                                  GAsyncResult* _res_,
                                                                                  GError** error);
static void geary_imap_engine_update_remote_folders_update_folders_async (GearyImapEngineUpdateRemoteFolders* self,
                                                                   GearyImapAccountSession* remote,
                                                                   GeeMap* existing_folders,
                                                                   GeeMap* remote_folders,
                                                                   gboolean remote_folders_suspect,
                                                                   GCancellable* cancellable,
                                                                   GAsyncReadyCallback _callback_,
                                                                   gpointer _user_data_);
static void geary_imap_engine_update_remote_folders_update_folders_finish (GearyImapEngineUpdateRemoteFolders* self,
                                                                    GAsyncResult* _res_);
static void geary_imap_engine_update_remote_folders_enumerate_remote_folders_async_data_free (gpointer _data);
static gboolean geary_imap_engine_update_remote_folders_enumerate_remote_folders_async_co (GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData* _data_);
VALA_EXTERN void geary_imap_account_session_fetch_child_folders_async (GearyImapAccountSession* self,
                                                           GearyFolderPath* parent,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
VALA_EXTERN GeeList* geary_imap_account_session_fetch_child_folders_finish (GearyImapAccountSession* self,
                                                                GAsyncResult* _res_,
                                                                GError** error);
static void geary_imap_engine_update_remote_folders_enumerate_remote_folders_async_ready (GObject* source_object,
                                                                                   GAsyncResult* _res_,
                                                                                   gpointer _user_data_);
VALA_EXTERN GearyImapFolderProperties* geary_imap_folder_get_properties (GearyImapFolder* self);
static void geary_imap_engine_update_remote_folders_update_folders_async_data_free (gpointer _data);
static gboolean geary_imap_engine_update_remote_folders_update_folders_async_co (GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData* _data_);
static Block97Data* block97_data_ref (Block97Data* _data97_);
static void block97_data_unref (void * _userdata_);
VALA_EXTERN GearyImapDBFolder* geary_imap_engine_minimal_folder_get_local_folder (GearyImapEngineMinimalFolder* self);
VALA_EXTERN GearyImapFolderProperties* geary_imap_db_folder_get_properties (GearyImapDBFolder* self);
VALA_EXTERN void geary_imap_db_folder_update_folder_status (GearyImapDBFolder* self,
                                                GearyImapFolderProperties* remote_properties,
                                                gboolean respect_marked_for_remove,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN void geary_imap_db_folder_update_folder_status_finish (GearyImapDBFolder* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
static void geary_imap_engine_update_remote_folders_update_folders_async_ready (GObject* source_object,
                                                                         GAsyncResult* _res_,
                                                                         gpointer _user_data_);
static gboolean __lambda137_ (Block97Data* _data97_,
                       GearyImapFolder* f);
static gboolean ___lambda137__gee_predicate (gconstpointer g,
                                      gpointer self);
static gboolean __lambda138_ (Block97Data* _data97_,
                       GeeMapEntry* e);
static gboolean ___lambda138__gee_predicate (gconstpointer g,
                                      gpointer self);
static GearyFolder* __lambda139_ (GearyImapEngineUpdateRemoteFolders* self,
                           GeeMapEntry* e);
static gpointer ___lambda139__gee_map_func (gpointer g,
                                     gpointer self);
VALA_EXTERN void geary_imap_db_account_delete_folder_async (GearyImapDBAccount* self,
                                                GearyFolderPath* path,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN void geary_imap_db_account_delete_folder_finish (GearyImapDBAccount* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
VALA_EXTERN void geary_imap_account_session_folders_removed (GearyImapAccountSession* self,
                                                 GeeCollection* paths);
static GearyFolderPath* ___lambda142_ (GearyImapEngineUpdateRemoteFolders* self,
                                GearyFolder* f);
static gpointer ____lambda142__gee_map_func (gpointer g,
                                      gpointer self);
VALA_EXTERN void geary_imap_engine_account_synchronizer_folders_discovered (GearyImapEngineAccountSynchronizer* self,
                                                                GeeCollection* available);
static void geary_imap_engine_update_remote_folders_finalize (GObject * obj);
static GType geary_imap_engine_update_remote_folders_get_type_once (void);
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);
static void geary_imap_engine_refresh_folder_unseen_real_execute_data_free (gpointer _data);
static void geary_imap_engine_refresh_folder_unseen_real_execute (GearyImapEngineAccountOperation* base,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
static gboolean geary_imap_engine_refresh_folder_unseen_real_execute_co (GearyImapEngineRefreshFolderUnseenExecuteData* _data_);
static void geary_imap_engine_refresh_folder_unseen_execute_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_);
static GType geary_imap_engine_refresh_folder_unseen_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);
static gssize _vala_array_length (gpointer array);

static const GearyFolderSpecialUse GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SUPPORTED_SPECIAL_FOLDERS[5] = {GEARY_FOLDER_SPECIAL_USE_DRAFTS, GEARY_FOLDER_SPECIAL_USE_SENT, GEARY_FOLDER_SPECIAL_USE_JUNK, GEARY_FOLDER_SPECIAL_USE_TRASH, GEARY_FOLDER_SPECIAL_USE_ARCHIVE};

static inline gpointer
geary_imap_engine_generic_account_get_instance_private (GearyImapEngineGenericAccount* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEngineGenericAccount_private_offset);
}

GearyImapClientService*
geary_imap_engine_generic_account_get_imap (GearyImapEngineGenericAccount* self)
{
	GearyImapClientService* result;
	GearyImapClientService* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	_tmp0_ = self->priv->_imap;
	result = _tmp0_;
	return result;
}

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

static void
geary_imap_engine_generic_account_set_imap (GearyImapEngineGenericAccount* self,
                                            GearyImapClientService* value)
{
	GearyImapClientService* old_value;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	old_value = geary_imap_engine_generic_account_get_imap (self);
	if (old_value != value) {
		GearyImapClientService* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_imap);
		self->priv->_imap = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_IMAP_PROPERTY]);
	}
}

GearySmtpClientService*
geary_imap_engine_generic_account_get_smtp (GearyImapEngineGenericAccount* self)
{
	GearySmtpClientService* result;
	GearySmtpClientService* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	_tmp0_ = self->priv->_smtp;
	result = _tmp0_;
	return result;
}

static void
geary_imap_engine_generic_account_set_smtp (GearyImapEngineGenericAccount* self,
                                            GearySmtpClientService* value)
{
	GearySmtpClientService* old_value;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	old_value = geary_imap_engine_generic_account_get_smtp (self);
	if (old_value != value) {
		GearySmtpClientService* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_smtp);
		self->priv->_smtp = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SMTP_PROPERTY]);
	}
}

GearyImapDBAccount*
geary_imap_engine_generic_account_get_local (GearyImapEngineGenericAccount* self)
{
	GearyImapDBAccount* result;
	GearyImapDBAccount* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	_tmp0_ = self->priv->_local;
	result = _tmp0_;
	return result;
}

static void
geary_imap_engine_generic_account_set_local (GearyImapEngineGenericAccount* self,
                                             GearyImapDBAccount* value)
{
	GearyImapDBAccount* old_value;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	old_value = geary_imap_engine_generic_account_get_local (self);
	if (old_value != value) {
		GearyImapDBAccount* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_local);
		self->priv->_local = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_LOCAL_PROPERTY]);
	}
}

GearyImapEngineAccountSynchronizer*
geary_imap_engine_generic_account_get_sync (GearyImapEngineGenericAccount* self)
{
	GearyImapEngineAccountSynchronizer* result;
	GearyImapEngineAccountSynchronizer* _tmp0_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	_tmp0_ = self->priv->_sync;
	result = _tmp0_;
	return result;
}

static void
geary_imap_engine_generic_account_set_sync (GearyImapEngineGenericAccount* self,
                                            GearyImapEngineAccountSynchronizer* value)
{
	GearyImapEngineAccountSynchronizer* old_value;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	old_value = geary_imap_engine_generic_account_get_sync (self);
	if (old_value != value) {
		GearyImapEngineAccountSynchronizer* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_sync);
		self->priv->_sync = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SYNC_PROPERTY]);
	}
}

static void
_geary_imap_engine_generic_account_on_imap_status_notify_g_object_notify (GObject* _sender,
                                                                          GParamSpec* pspec,
                                                                          gpointer self)
{
	geary_imap_engine_generic_account_on_imap_status_notify ((GearyImapEngineGenericAccount*) self);
}

static void
_geary_account_notify_report_problem_geary_smtp_client_service_report_problem (GearySmtpClientService* _sender,
                                                                               GearyProblemReport* problem,
                                                                               gpointer self)
{
	geary_account_notify_report_problem ((GearyAccount*) self, problem);
}

static void
__lambda144_ (GearyImapEngineGenericAccount* self)
{
	geary_imap_engine_generic_account_update_remote_folders (self, TRUE);
}

static void
___lambda144__geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                  gpointer self)
{
	__lambda144_ ((GearyImapEngineGenericAccount*) self);
}

GearyImapEngineGenericAccount*
geary_imap_engine_generic_account_construct (GType object_type,
                                             GearyAccountInformation* config,
                                             GearyImapDBAccount* local,
                                             GearyEndpoint* incoming_remote,
                                             GearyEndpoint* outgoing_remote)
{
	GearyImapEngineGenericAccount * self = NULL;
	GearyImapClientService* imap = NULL;
	GearyServiceInformation* _tmp0_;
	GearyServiceInformation* _tmp1_;
	GearyImapClientService* _tmp2_;
	GearySmtpClientService* smtp = NULL;
	GearyServiceInformation* _tmp3_;
	GearyServiceInformation* _tmp4_;
	GearySmtpClientService* _tmp5_;
	GearyImapDBAccount* _tmp6_;
	GearyImapDBDatabase* _tmp7_;
	GearyImapDBDatabase* _tmp8_;
	GearyImapDBDatabase* _tmp9_;
	GearyImapDBDatabase* _tmp10_;
	GearyContactStoreImpl* _tmp11_;
	GearyContactStoreImpl* _tmp12_;
	GearyFolderRoot* _tmp13_;
	GearyFolderRoot* _tmp14_;
	GearyOutboxFolder* _tmp15_;
	GearyOutboxFolder* _tmp16_;
	GearyImapEngineAccountSynchronizer* _tmp17_;
	GearyImapEngineAccountSynchronizer* _tmp18_;
	GearyTimeoutManager* _tmp19_;
	GearyReentrantProgressMonitor* _tmp20_;
	GearyReentrantProgressMonitor* _tmp21_;
	GearySimpleProgressMonitor* _tmp22_;
	GearySimpleProgressMonitor* _tmp23_;
	GearySimpleProgressMonitor* _tmp24_;
	GearySimpleProgressMonitor* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	struct sb_stemmer* _tmp28_;
	g_return_val_if_fail (GEARY_IS_ACCOUNT_INFORMATION (config), NULL);
	g_return_val_if_fail (GEARY_IMAP_DB_IS_ACCOUNT (local), NULL);
	g_return_val_if_fail (GEARY_IS_ENDPOINT (incoming_remote), NULL);
	g_return_val_if_fail (GEARY_IS_ENDPOINT (outgoing_remote), NULL);
	_tmp0_ = geary_account_information_get_incoming (config);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_imap_client_service_new (config, _tmp1_, incoming_remote);
	imap = _tmp2_;
	_tmp3_ = geary_account_information_get_outgoing (config);
	_tmp4_ = _tmp3_;
	_tmp5_ = geary_smtp_client_service_new (config, _tmp4_, outgoing_remote);
	smtp = _tmp5_;
	self = (GearyImapEngineGenericAccount*) geary_account_construct (object_type, config, G_TYPE_CHECK_INSTANCE_CAST (imap, GEARY_TYPE_CLIENT_SERVICE, GearyClientService), G_TYPE_CHECK_INSTANCE_CAST (smtp, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
	geary_imap_engine_generic_account_set_local (self, local);
	_tmp6_ = self->priv->_local;
	_tmp7_ = geary_imap_db_account_get_db (_tmp6_);
	_tmp8_ = _tmp7_;
	geary_db_database_set_logging_parent (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEARY_DB_TYPE_DATABASE, GearyDbDatabase), G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
	_tmp9_ = geary_imap_db_account_get_db (local);
	_tmp10_ = _tmp9_;
	_tmp11_ = geary_contact_store_impl_new (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEARY_DB_TYPE_DATABASE, GearyDbDatabase));
	_tmp12_ = _tmp11_;
	geary_account_set_contact_store (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEARY_TYPE_CONTACT_STORE, GearyContactStore));
	_g_object_unref0 (_tmp12_);
	geary_imap_client_service_set_min_pool_size (imap, GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_IMAP_MIN_POOL_SIZE);
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (imap, G_TYPE_OBJECT, GObject), "notify::current-status", (GCallback) _geary_imap_engine_generic_account_on_imap_status_notify_g_object_notify, self, 0);
	geary_client_service_set_logging_parent (G_TYPE_CHECK_INSTANCE_CAST (imap, GEARY_TYPE_CLIENT_SERVICE, GearyClientService), G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
	geary_imap_engine_generic_account_set_imap (self, imap);
	_tmp13_ = geary_account_get_local_folder_root (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_tmp14_ = _tmp13_;
	_tmp15_ = geary_outbox_folder_new (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), _tmp14_, local);
	_tmp16_ = _tmp15_;
	geary_smtp_client_service_set_outbox (smtp, _tmp16_);
	_g_object_unref0 (_tmp16_);
	g_signal_connect_object (smtp, "report-problem", (GCallback) _geary_account_notify_report_problem_geary_smtp_client_service_report_problem, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), 0);
	geary_client_service_set_logging_parent (G_TYPE_CHECK_INSTANCE_CAST (smtp, GEARY_TYPE_CLIENT_SERVICE, GearyClientService), G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
	geary_imap_engine_generic_account_set_smtp (self, smtp);
	_tmp17_ = geary_imap_engine_account_synchronizer_new (self);
	_tmp18_ = _tmp17_;
	geary_imap_engine_generic_account_set_sync (self, _tmp18_);
	_g_object_unref0 (_tmp18_);
	_tmp19_ = geary_timeout_manager_new_seconds ((guint) GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_REFRESH_FOLDER_LIST_SEC, ___lambda144__geary_timeout_manager_timeout_func, self);
	_g_object_unref0 (self->priv->refresh_folder_timer);
	self->priv->refresh_folder_timer = _tmp19_;
	_tmp20_ = geary_reentrant_progress_monitor_new (GEARY_PROGRESS_TYPE_ACTIVITY);
	_tmp21_ = _tmp20_;
	geary_account_set_background_progress (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, GEARY_TYPE_PROGRESS_MONITOR, GearyProgressMonitor));
	_g_object_unref0 (_tmp21_);
	_tmp22_ = geary_imap_db_account_get_upgrade_monitor (local);
	_tmp23_ = _tmp22_;
	geary_account_set_db_upgrade_monitor (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, GEARY_TYPE_PROGRESS_MONITOR, GearyProgressMonitor));
	_tmp24_ = geary_imap_db_account_get_vacuum_monitor (local);
	_tmp25_ = _tmp24_;
	geary_account_set_db_vacuum_monitor (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, GEARY_TYPE_PROGRESS_MONITOR, GearyProgressMonitor));
	geary_imap_engine_generic_account_compile_special_search_names (self);
	_tmp26_ = geary_imap_engine_generic_account_find_appropriate_search_stemmer (self);
	_tmp27_ = _tmp26_;
	_tmp28_ = sb_stemmer_new (_tmp27_, "UTF_8");
	_sb_stemmer_delete0 (self->priv->stemmer);
	self->priv->stemmer = _tmp28_;
	_g_free0 (_tmp27_);
	_g_object_unref0 (smtp);
	_g_object_unref0 (imap);
	return self;
}

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

static void
geary_imap_engine_generic_account_real_open_async (GearyAccount* base,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountOpenAsyncData* _data_;
	GearyImapEngineGenericAccount* _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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountOpenAsyncData);
	_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_generic_account_real_open_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_generic_account_real_open_async_co (_data_);
}

static void
geary_imap_engine_generic_account_open_finish (GearyAccount* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	GearyImapEngineGenericAccountOpenAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** {@inheritDoc} */
static void
geary_imap_engine_generic_account_open_async_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	GearyImapEngineGenericAccountOpenAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_open_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_open_async_co (GearyImapEngineGenericAccountOpenAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->open) {
		_data_->_tmp0_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_data_->_tmp1_ = _data_->_tmp0_;
		_data_->_tmp2_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_ALREADY_OPEN, "Account %s already opened", _data_->_tmp1_);
		_data_->_tmp3_ = _data_->_tmp2_;
		_g_free0 (_data_->_tmp1_);
		_data_->_inner_error0_ = _data_->_tmp3_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = geary_account_get_background_progress (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_data_->_tmp5_ = _data_->_tmp4_;
	geary_progress_monitor_notify_start (_data_->_tmp5_);
	{
		_data_->_state_ = 1;
		geary_imap_engine_generic_account_internal_open_async (_data_->self, _data_->cancellable, geary_imap_engine_generic_account_open_async_ready, _data_);
		return FALSE;
		_state_1:
		geary_imap_engine_generic_account_internal_open_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
	}
	__finally0:
	{
		_data_->_tmp6_ = geary_account_get_background_progress (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
		_data_->_tmp7_ = _data_->_tmp6_;
		geary_progress_monitor_notify_finish (_data_->_tmp7_);
	}
	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_generic_account_internal_open_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountInternalOpenAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountInternalOpenAsyncData, _data_);
}

static void
geary_imap_engine_generic_account_internal_open_async (GearyImapEngineGenericAccount* self,
                                                       GCancellable* cancellable,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	GearyImapEngineGenericAccountInternalOpenAsyncData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountInternalOpenAsyncData);
	_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_generic_account_internal_open_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_generic_account_internal_open_async_co (_data_);
}

static void
geary_imap_engine_generic_account_internal_open_finish (GearyImapEngineGenericAccount* self,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	GearyImapEngineGenericAccountInternalOpenAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
_geary_imap_engine_generic_account_on_operation_error_geary_imap_engine_account_processor_operation_error (GearyImapEngineAccountProcessor* _sender,
                                                                                                           GearyImapEngineAccountOperation* op,
                                                                                                           GError* _error_,
                                                                                                           gpointer self)
{
	geary_imap_engine_generic_account_on_operation_error ((GearyImapEngineGenericAccount*) self, op, _error_);
}

static void
geary_imap_engine_generic_account_internal_open_async_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	GearyImapEngineGenericAccountInternalOpenAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_internal_open_async_co (_data_);
}

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

static void
_geary_imap_engine_generic_account_on_last_storage_cleanup_notify_g_object_notify (GObject* _sender,
                                                                                   GParamSpec* pspec,
                                                                                   gpointer self)
{
	geary_imap_engine_generic_account_on_last_storage_cleanup_notify ((GearyImapEngineGenericAccount*) self);
}

static gboolean
geary_imap_engine_generic_account_internal_open_async_co (GearyImapEngineGenericAccountInternalOpenAsyncData* _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_ = g_cancellable_new ();
	_g_object_unref0 (_data_->self->priv->open_cancellable);
	_data_->self->priv->open_cancellable = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->open_cancellable;
	_data_->_tmp2_ = geary_nonblocking_semaphore_new (_data_->_tmp1_);
	_g_object_unref0 (_data_->self->priv->remote_ready_lock);
	_data_->self->priv->remote_ready_lock = _data_->_tmp2_;
	_data_->_tmp3_ = geary_account_get_background_progress (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = geary_imap_engine_account_processor_new (_data_->_tmp4_);
	_g_object_unref0 (_data_->self->priv->processor);
	_data_->self->priv->processor = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->self->priv->processor;
	g_signal_connect_object (_data_->_tmp6_, "operation-error", (GCallback) _geary_imap_engine_generic_account_on_operation_error_geary_imap_engine_account_processor_operation_error, _data_->self, 0);
	_data_->_tmp7_ = _data_->self->priv->processor;
	geary_imap_engine_account_processor_set_logging_parent (_data_->_tmp7_, G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
	{
		_data_->_tmp8_ = _data_->self->priv->_local;
		_data_->_state_ = 1;
		geary_imap_db_account_open_async (_data_->_tmp8_, _data_->cancellable, geary_imap_engine_generic_account_internal_open_async_ready, _data_);
		return FALSE;
		_state_1:
		geary_imap_db_account_open_finish (_data_->_tmp8_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp9_ = _data_->err;
		if (g_error_matches (_data_->_tmp9_, GEARY_DATABASE_ERROR, GEARY_DATABASE_ERROR_CORRUPT)) {
			_data_->_tmp10_ = _data_->err;
			_data_->_tmp11_ = _data_->_tmp10_->message;
			_data_->_tmp12_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_CORRUPT, "%s", _data_->_tmp11_);
			_data_->_inner_error0_ = _data_->_tmp12_;
			_g_error_free0 (_data_->err);
			goto __finally0;
		} else {
			_data_->_tmp13_ = _data_->err;
			if (g_error_matches (_data_->_tmp13_, GEARY_DATABASE_ERROR, GEARY_DATABASE_ERROR_ACCESS)) {
				_data_->_tmp14_ = _data_->err;
				_data_->_tmp15_ = _data_->_tmp14_->message;
				_data_->_tmp16_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_PERMISSIONS, "%s", _data_->_tmp15_);
				_data_->_inner_error0_ = _data_->_tmp16_;
				_g_error_free0 (_data_->err);
				goto __finally0;
			} else {
				_data_->_tmp17_ = _data_->err;
				if (g_error_matches (_data_->_tmp17_, GEARY_DATABASE_ERROR, GEARY_DATABASE_ERROR_SCHEMA_VERSION)) {
					_data_->_tmp18_ = _data_->err;
					_data_->_tmp19_ = _data_->_tmp18_->message;
					_data_->_tmp20_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_VERSION, "%s", _data_->_tmp19_);
					_data_->_inner_error0_ = _data_->_tmp20_;
					_g_error_free0 (_data_->err);
					goto __finally0;
				} else {
					_data_->_tmp21_ = _data_->err;
					_data_->_tmp22_ = _g_error_copy0 (_data_->_tmp21_);
					_data_->_inner_error0_ = _data_->_tmp22_;
					_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_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp24_ = _data_->self->priv->_local;
	_data_->_state_ = 2;
	geary_imap_db_account_fetch_last_cleanup_async (_data_->_tmp24_, _data_->cancellable, geary_imap_engine_generic_account_internal_open_async_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp25_ = geary_imap_db_account_fetch_last_cleanup_finish (_data_->_tmp24_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp23_ = _data_->_tmp25_;
	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_account_set_last_storage_cleanup (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->_tmp23_);
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, G_TYPE_OBJECT, GObject), "notify::last_storage_cleanup", (GCallback) _geary_imap_engine_generic_account_on_last_storage_cleanup_notify_g_object_notify, _data_->self, 0);
	_data_->self->priv->open = TRUE;
	geary_account_notify_opened (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_data_->_tmp26_ = _data_->self->priv->_local;
	_data_->_tmp27_ = geary_imap_engine_load_folders_new (_data_->self, _data_->_tmp26_);
	_data_->_tmp28_ = _data_->_tmp27_;
	geary_imap_engine_generic_account_queue_operation (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp28_, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation), &_data_->_inner_error0_);
	_g_object_unref0 (_data_->_tmp28_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_date_time_unref0 (_data_->_tmp23_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp29_ = _data_->self->priv->_smtp;
	_data_->_tmp30_ = geary_smtp_client_service_get_outbox (_data_->_tmp29_);
	_data_->_tmp31_ = _data_->_tmp30_;
	_data_->_tmp32_ = geary_imap_engine_start_services_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->_tmp31_);
	_data_->_tmp33_ = _data_->_tmp32_;
	geary_imap_engine_generic_account_queue_operation (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp33_, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation), &_data_->_inner_error0_);
	_g_object_unref0 (_data_->_tmp33_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_date_time_unref0 (_data_->_tmp23_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp34_ = geary_imap_engine_populate_search_table_new (_data_->self);
	_data_->_tmp35_ = _data_->_tmp34_;
	geary_imap_engine_generic_account_queue_operation (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp35_, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation), &_data_->_inner_error0_);
	_g_object_unref0 (_data_->_tmp35_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_date_time_unref0 (_data_->_tmp23_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_date_time_unref0 (_data_->_tmp23_);
	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_generic_account_real_close_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountCloseAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountCloseAsyncData, _data_);
}

static void
geary_imap_engine_generic_account_real_close_async (GearyAccount* base,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountCloseAsyncData* _data_;
	GearyImapEngineGenericAccount* _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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountCloseAsyncData);
	_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_generic_account_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_generic_account_real_close_async_co (_data_);
}

static void
geary_imap_engine_generic_account_close_finish (GearyAccount* base,
                                                GAsyncResult* _res_,
                                                GError** error)
{
	GearyImapEngineGenericAccountCloseAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_generic_account_close_async_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_)
{
	GearyImapEngineGenericAccountCloseAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_close_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_close_async_co (GearyImapEngineGenericAccountCloseAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (!_data_->self->priv->open) {
		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_ = _data_->self->priv->_smtp;
		_data_->_state_ = 1;
		geary_client_service_stop (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService), NULL, geary_imap_engine_generic_account_close_async_ready, _data_);
		return FALSE;
		_state_1:
		geary_client_service_stop_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService), _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp1_ = _data_->err;
		_data_->_tmp2_ = _data_->_tmp1_->message;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error stopping SMTP service: %s", _data_->_tmp2_);
		_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_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp3_ = _data_->self->priv->refresh_folder_timer;
	geary_timeout_manager_reset (_data_->_tmp3_);
	_data_->_tmp4_ = _data_->self->priv->open_cancellable;
	g_cancellable_cancel (_data_->_tmp4_);
	_data_->_tmp5_ = _data_->self->priv->processor;
	geary_imap_engine_account_processor_stop (_data_->_tmp5_);
	_data_->_tmp6_ = _data_->self->priv->_imap;
	_data_->_tmp6_->discard_returned_sessions = TRUE;
	_data_->_tmp7_ = _data_->self->priv->remote_ready_lock;
	geary_nonblocking_lock_reset (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
	_data_->_tmp8_ = _data_->self->priv->local_folders;
	_data_->_tmp9_ = gee_map_get_values (_data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_tmp11_ = _data_->_tmp10_;
	_data_->_tmp12_ = geary_account_sort_by_path (_data_->_tmp11_);
	_data_->_tmp13_ = _data_->_tmp12_;
	_g_object_unref0 (_data_->_tmp11_);
	_data_->locals = _data_->_tmp13_;
	_data_->_tmp14_ = _data_->self->priv->local_folders;
	gee_map_clear (_data_->_tmp14_);
	_data_->_tmp15_ = _data_->locals;
	geary_account_notify_folders_available_unavailable (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), NULL, _data_->_tmp15_);
	_data_->_tmp16_ = _data_->self->priv->remote_folders;
	_data_->_tmp17_ = gee_map_get_values (_data_->_tmp16_);
	_data_->_tmp18_ = _data_->_tmp17_;
	_data_->_tmp19_ = _data_->_tmp18_;
	_data_->_tmp20_ = geary_account_sort_by_path (_data_->_tmp19_);
	_data_->_tmp21_ = _data_->_tmp20_;
	_g_object_unref0 (_data_->_tmp19_);
	_data_->remotes = _data_->_tmp21_;
	_data_->_tmp22_ = _data_->self->priv->remote_folders;
	gee_map_clear (_data_->_tmp22_);
	_data_->_tmp23_ = _data_->remotes;
	geary_account_notify_folders_available_unavailable (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), NULL, _data_->_tmp23_);
	{
		_data_->_tmp24_ = _data_->remotes;
		_data_->_tmp25_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp24_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_folder_it = _data_->_tmp25_;
		while (TRUE) {
			_data_->_tmp26_ = _data_->_folder_it;
			if (!gee_iterator_next (_data_->_tmp26_)) {
				break;
			}
			_data_->_tmp27_ = _data_->_folder_it;
			_data_->_tmp28_ = gee_iterator_get (_data_->_tmp27_);
			_data_->folder = (GearyFolder*) _data_->_tmp28_;
			_data_->_tmp29_ = _data_->folder;
			_data_->_tmp30_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp29_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
			_data_->_tmp31_ = _data_->_tmp30_;
			geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Waiting for remote to close: %s", _data_->_tmp31_);
			_g_free0 (_data_->_tmp31_);
			_data_->_tmp32_ = _data_->folder;
			_data_->_state_ = 2;
			geary_folder_wait_for_close_async (_data_->_tmp32_, NULL, geary_imap_engine_generic_account_close_async_ready, _data_);
			return FALSE;
			_state_2:
			geary_folder_wait_for_close_finish (_data_->_tmp32_, _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_->folder);
				_g_object_unref0 (_data_->_folder_it);
				_g_object_unref0 (_data_->remotes);
				_g_object_unref0 (_data_->locals);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_g_object_unref0 (_data_->folder);
		}
		_g_object_unref0 (_data_->_folder_it);
	}
	{
		_data_->_tmp33_ = _data_->self->priv->_imap;
		_data_->_state_ = 3;
		geary_client_service_stop (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp33_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService), NULL, geary_imap_engine_generic_account_close_async_ready, _data_);
		return FALSE;
		_state_3:
		geary_client_service_stop_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp33_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService), _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_->_tmp34_ = _data_->_vala1_err;
		_data_->_tmp35_ = _data_->_tmp34_->message;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error stopping IMAP service: %s", _data_->_tmp35_);
		_g_error_free0 (_data_->_vala1_err);
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->remotes);
		_g_object_unref0 (_data_->locals);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->self->priv->remote_ready_lock);
	_data_->self->priv->remote_ready_lock = NULL;
	{
		_data_->_tmp36_ = _data_->self->priv->_local;
		_data_->_state_ = 4;
		geary_imap_db_account_close_async (_data_->_tmp36_, _data_->cancellable, geary_imap_engine_generic_account_close_async_ready, _data_);
		return FALSE;
		_state_4:
		geary_imap_db_account_close_finish (_data_->_tmp36_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally2;
		}
	}
	__finally2:
	{
		_data_->self->priv->open = FALSE;
		geary_account_notify_closed (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
	}
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->remotes);
		_g_object_unref0 (_data_->locals);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->remotes);
	_g_object_unref0 (_data_->locals);
	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 gboolean
geary_imap_engine_generic_account_real_is_open (GearyAccount* base)
{
	GearyImapEngineGenericAccount * self;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	result = self->priv->open;
	return result;
}

/** {@inheritDoc} */
static void
geary_imap_engine_generic_account_real_cancel_remote_update (GearyAccount* base)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineAccountProcessor* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_tmp0_ = self->priv->processor;
	if (geary_imap_engine_account_processor_dequeue_by_type (_tmp0_, GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS)) {
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Cancelled a remote update! Updating again...\n");
		geary_imap_engine_generic_account_update_remote_folders (self, FALSE);
	}
}

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

static void
geary_imap_engine_generic_account_real_rebuild_async (GearyAccount* base,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountRebuildAsyncData* _data_;
	GearyImapEngineGenericAccount* _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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountRebuildAsyncData);
	_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_generic_account_real_rebuild_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_generic_account_real_rebuild_async_co (_data_);
}

static void
geary_imap_engine_generic_account_rebuild_finish (GearyAccount* base,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	GearyImapEngineGenericAccountRebuildAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_generic_account_rebuild_async_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	GearyImapEngineGenericAccountRebuildAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_rebuild_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_rebuild_async_co (GearyImapEngineGenericAccountRebuildAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->self->priv->open) {
		_data_->_tmp0_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_ALREADY_OPEN, "Account cannot be open during rebuild");
		_data_->_inner_error0_ = _data_->_tmp0_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	geary_logging_source_message (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Rebuilding account local data");
	_data_->_tmp1_ = _data_->self->priv->_local;
	_data_->_state_ = 1;
	geary_imap_db_account_delete_all_data (_data_->_tmp1_, _data_->cancellable, geary_imap_engine_generic_account_rebuild_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_db_account_delete_all_data_finish (_data_->_tmp1_, _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;
	}
	geary_logging_source_message (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Rebuild complete");
	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;
}

/**
     * Queues an operation for execution by this account.
     *
     * The operation will added to the account's {@link
     * AccountProcessor} and executed asynchronously by that when it
     * reaches the front.
     */
void
geary_imap_engine_generic_account_queue_operation (GearyImapEngineGenericAccount* self,
                                                   GearyImapEngineAccountOperation* op,
                                                   GError** error)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	GearyImapEngineAccountProcessor* _tmp2_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_ACCOUNT_OPERATION (op));
	geary_imap_engine_generic_account_check_open (self, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		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;
		}
	}
	_tmp0_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (op, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
	_tmp1_ = _tmp0_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Enqueuing operation: %s", _tmp1_);
	_g_free0 (_tmp1_);
	_tmp2_ = self->priv->processor;
	geary_imap_engine_account_processor_enqueue (_tmp2_, op);
}

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

void
geary_imap_engine_generic_account_claim_account_session (GearyImapEngineGenericAccount* self,
                                                         GCancellable* cancellable,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_)
{
	GearyImapEngineGenericAccountClaimAccountSessionData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountClaimAccountSessionData);
	_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_generic_account_claim_account_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_generic_account_claim_account_session_co (_data_);
}

GearyImapAccountSession*
geary_imap_engine_generic_account_claim_account_session_finish (GearyImapEngineGenericAccount* self,
                                                                GAsyncResult* _res_,
                                                                GError** error)
{
	GearyImapAccountSession* result;
	GearyImapEngineGenericAccountClaimAccountSessionData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

/**
     * Claims a new IMAP account session from the pool.
     *
     * A new IMAP client session will be retrieved from the pool,
     * connecting if needed, and used for a new account session. This
     * call will wait until the pool is ready to provide sessions. The
     * session must be returned via {@link release_account_session}
     * after use.
     *
     * The account must have been opened before calling this method.
     */
static void
geary_imap_engine_generic_account_claim_account_session_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_)
{
	GearyImapEngineGenericAccountClaimAccountSessionData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_claim_account_session_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_claim_account_session_co (GearyImapEngineGenericAccountClaimAccountSessionData* _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_generic_account_check_open (_data_->self, &_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), "Acquiring account session");
	_data_->_tmp0_ = _data_->self->priv->remote_ready_lock;
	_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_generic_account_claim_account_session_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;
	}
	_data_->_tmp1_ = _data_->self->priv->_imap;
	_data_->_state_ = 2;
	geary_imap_client_service_claim_authorized_session_async (_data_->_tmp1_, _data_->cancellable, geary_imap_engine_generic_account_claim_account_session_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp2_ = geary_imap_client_service_claim_authorized_session_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
	_data_->client = _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_->self->priv->_local;
	_data_->_tmp4_ = geary_imap_db_account_get_imap_folder_root (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = _data_->client;
	_data_->_tmp7_ = geary_imap_account_session_new (_data_->_tmp5_, _data_->_tmp6_);
	_data_->session = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->session;
	_data_->_tmp9_ = _data_->self->priv->_imap;
	geary_imap_session_object_set_logging_parent (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEARY_IMAP_TYPE_SESSION_OBJECT, GearyImapSessionObject), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp9_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
	_data_->result = _data_->session;
	_g_object_unref0 (_data_->client);
	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;
}

/**
     * Returns an IMAP account session to the pool for re-use.
     */
static void
___lambda128_ (GearyImapEngineGenericAccount* 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 ()));
	{
		GearyImapClientService* _tmp0_;
		_tmp0_ = self->priv->_imap;
		geary_imap_client_service_release_session_finish (_tmp0_, res, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = err;
		_tmp2_ = _tmp1_->message;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error releasing account session: %s", _tmp2_);
		_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
____lambda128__gasync_ready_callback (GObject* source_object,
                                      GAsyncResult* res,
                                      gpointer self)
{
	___lambda128_ ((GearyImapEngineGenericAccount*) self, source_object, res);
	g_object_unref (self);
}

void
geary_imap_engine_generic_account_release_account_session (GearyImapEngineGenericAccount* self,
                                                           GearyImapAccountSession* session)
{
	GearyImapClientSession* old_session = NULL;
	GearyImapClientSession* _tmp0_;
	GearyImapClientSession* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (GEARY_IMAP_IS_ACCOUNT_SESSION (session));
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Releasing account session");
	_tmp0_ = geary_imap_session_object_close (G_TYPE_CHECK_INSTANCE_CAST (session, GEARY_IMAP_TYPE_SESSION_OBJECT, GearyImapSessionObject));
	old_session = _tmp0_;
	_tmp1_ = old_session;
	if (_tmp1_ != NULL) {
		GearyImapClientService* _tmp2_;
		GearyImapClientSession* _tmp3_;
		_tmp2_ = self->priv->_imap;
		_tmp3_ = old_session;
		geary_imap_client_service_release_session_async (_tmp2_, _tmp3_, ____lambda128__gasync_ready_callback, g_object_ref (self));
	}
	_g_object_unref0 (old_session);
}

static void
geary_imap_engine_generic_account_claim_folder_session_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountClaimFolderSessionData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->path);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountClaimFolderSessionData, _data_);
}

void
geary_imap_engine_generic_account_claim_folder_session (GearyImapEngineGenericAccount* self,
                                                        GearyFolderPath* path,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	GearyImapEngineGenericAccountClaimFolderSessionData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyFolderPath* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (GEARY_IS_FOLDER_PATH (path));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountClaimFolderSessionData);
	_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_generic_account_claim_folder_session_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (path);
	_g_object_unref0 (_data_->path);
	_data_->path = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_generic_account_claim_folder_session_co (_data_);
}

GearyImapFolderSession*
geary_imap_engine_generic_account_claim_folder_session_finish (GearyImapEngineGenericAccount* self,
                                                               GAsyncResult* _res_,
                                                               GError** error)
{
	GearyImapFolderSession* result;
	GearyImapEngineGenericAccountClaimFolderSessionData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

/**
     * Claims a new IMAP folder session from the pool.
     *
     * A new IMAP client session will be retrieved from the pool,
     * connecting if needed, and used for a new folder session. This
     * call will wait until the pool is ready to provide sessions. The
     * session must be returned via {@link release_folder_session}
     * after use.
     *
     * The account must have been opened before calling this method.
     */
static void
geary_imap_engine_generic_account_claim_folder_session_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_)
{
	GearyImapEngineGenericAccountClaimFolderSessionData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_claim_folder_session_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_claim_folder_session_co (GearyImapEngineGenericAccountClaimFolderSessionData* _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_generic_account_check_open (_data_->self, &_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_path_to_string (_data_->path);
	_data_->_tmp1_ = _data_->_tmp0_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Acquiring folder session for: %s", _data_->_tmp1_);
	_g_free0 (_data_->_tmp1_);
	_data_->_tmp2_ = _data_->self->priv->remote_ready_lock;
	_data_->_state_ = 1;
	geary_nonblocking_lock_wait_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), _data_->cancellable, geary_imap_engine_generic_account_claim_folder_session_ready, _data_);
	return FALSE;
	_state_1:
	geary_nonblocking_lock_wait_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, 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;
	}
	_data_->_tmp3_ = _data_->self->priv->_imap;
	_data_->_state_ = 2;
	geary_imap_client_service_claim_authorized_session_async (_data_->_tmp3_, _data_->cancellable, geary_imap_engine_generic_account_claim_folder_session_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp4_ = geary_imap_client_service_claim_authorized_session_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
	_data_->client = _data_->_tmp4_;
	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_->_tmp5_ = _data_->self->priv->_local;
	_data_->_tmp6_ = geary_imap_db_account_get_imap_folder_root (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = _data_->client;
	_data_->_tmp9_ = geary_imap_account_session_new (_data_->_tmp7_, _data_->_tmp8_);
	_data_->account = _data_->_tmp9_;
	_data_->_tmp10_ = _data_->account;
	_data_->_tmp11_ = _data_->self->priv->_imap;
	geary_imap_session_object_set_logging_parent (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp10_, GEARY_IMAP_TYPE_SESSION_OBJECT, GearyImapSessionObject), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
	_data_->folder = NULL;
	_data_->folder_err = NULL;
	{
		_data_->_tmp13_ = _data_->account;
		_data_->_state_ = 3;
		geary_imap_account_session_fetch_folder_async (_data_->_tmp13_, _data_->path, _data_->cancellable, geary_imap_engine_generic_account_claim_folder_session_ready, _data_);
		return FALSE;
		_state_3:
		_data_->_tmp14_ = geary_imap_account_session_fetch_folder_finish (_data_->_tmp13_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp12_ = _data_->_tmp14_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp15_ = _data_->_tmp12_;
		_data_->_tmp12_ = NULL;
		_g_object_unref0 (_data_->folder);
		_data_->folder = _data_->_tmp15_;
		_g_object_unref0 (_data_->_tmp12_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp16_ = _data_->err;
		_data_->_tmp17_ = _g_error_copy0 (_data_->_tmp16_);
		_g_error_free0 (_data_->folder_err);
		_data_->folder_err = _data_->_tmp17_;
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_error_free0 (_data_->folder_err);
		_g_object_unref0 (_data_->folder);
		_g_object_unref0 (_data_->account);
		_g_object_unref0 (_data_->client);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp18_ = _data_->account;
	_data_->_tmp19_ = geary_imap_session_object_close (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, GEARY_IMAP_TYPE_SESSION_OBJECT, GearyImapSessionObject));
	_data_->_tmp20_ = _data_->_tmp19_;
	_g_object_unref0 (_data_->_tmp20_);
	_data_->folder_session = NULL;
	_data_->_tmp21_ = _data_->folder_err;
	if (_data_->_tmp21_ == NULL) {
		{
			_data_->_tmp23_ = _data_->client;
			_data_->_tmp24_ = _data_->folder;
			_data_->_state_ = 4;
			geary_imap_folder_session_new (_data_->_tmp23_, _data_->_tmp24_, _data_->cancellable, geary_imap_engine_generic_account_claim_folder_session_ready, _data_);
			return FALSE;
			_state_4:
			_data_->_tmp25_ = geary_imap_folder_session_new_finish (_data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp22_ = _data_->_tmp25_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
			_data_->_tmp26_ = _data_->_tmp22_;
			_data_->_tmp22_ = NULL;
			_g_object_unref0 (_data_->folder_session);
			_data_->folder_session = _data_->_tmp26_;
			_data_->_tmp27_ = _data_->folder_session;
			_data_->_tmp28_ = _data_->self->priv->_imap;
			geary_imap_session_object_set_logging_parent (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp27_, GEARY_IMAP_TYPE_SESSION_OBJECT, GearyImapSessionObject), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp28_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
			_g_object_unref0 (_data_->_tmp22_);
		}
		goto __finally1;
		__catch1_g_error:
		{
			_data_->_vala1_err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp29_ = _data_->_vala1_err;
			_data_->_tmp30_ = _g_error_copy0 (_data_->_tmp29_);
			_g_error_free0 (_data_->folder_err);
			_data_->folder_err = _data_->_tmp30_;
			_g_error_free0 (_data_->_vala1_err);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->folder_session);
			_g_error_free0 (_data_->folder_err);
			_g_object_unref0 (_data_->folder);
			_g_object_unref0 (_data_->account);
			_g_object_unref0 (_data_->client);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->_tmp31_ = _data_->folder_err;
	if (_data_->_tmp31_ != NULL) {
		{
			_data_->_tmp32_ = _data_->self->priv->_imap;
			_data_->_tmp33_ = _data_->client;
			_data_->_state_ = 5;
			geary_imap_client_service_release_session_async (_data_->_tmp32_, _data_->_tmp33_, geary_imap_engine_generic_account_claim_folder_session_ready, _data_);
			return FALSE;
			_state_5:
			geary_imap_client_service_release_session_finish (_data_->_tmp32_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch2_g_error;
			}
		}
		goto __finally2;
		__catch2_g_error:
		{
			_data_->release_err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp34_ = _data_->release_err;
			_data_->_tmp35_ = _data_->_tmp34_->message;
			geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error releasing folder session: %s", _data_->_tmp35_);
			_g_error_free0 (_data_->release_err);
		}
		__finally2:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->folder_session);
			_g_error_free0 (_data_->folder_err);
			_g_object_unref0 (_data_->folder);
			_g_object_unref0 (_data_->account);
			_g_object_unref0 (_data_->client);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp36_ = _data_->folder_err;
		_data_->_tmp37_ = _g_error_copy0 (_data_->_tmp36_);
		_data_->_inner_error0_ = _data_->_tmp37_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->folder_session);
		_g_error_free0 (_data_->folder_err);
		_g_object_unref0 (_data_->folder);
		_g_object_unref0 (_data_->account);
		_g_object_unref0 (_data_->client);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->folder_session;
	_g_error_free0 (_data_->folder_err);
	_g_object_unref0 (_data_->folder);
	_g_object_unref0 (_data_->account);
	_g_object_unref0 (_data_->client);
	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_generic_account_release_folder_session_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountReleaseFolderSessionData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->session);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountReleaseFolderSessionData, _data_);
}

void
geary_imap_engine_generic_account_release_folder_session (GearyImapEngineGenericAccount* self,
                                                          GearyImapFolderSession* session,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	GearyImapEngineGenericAccountReleaseFolderSessionData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyImapFolderSession* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (GEARY_IMAP_IS_FOLDER_SESSION (session));
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountReleaseFolderSessionData);
	_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_generic_account_release_folder_session_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (session);
	_g_object_unref0 (_data_->session);
	_data_->session = _tmp1_;
	geary_imap_engine_generic_account_release_folder_session_co (_data_);
}

void
geary_imap_engine_generic_account_release_folder_session_finish (GearyImapEngineGenericAccount* self,
                                                                 GAsyncResult* _res_)
{
	GearyImapEngineGenericAccountReleaseFolderSessionData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/**
     * Returns an IMAP folder session to the pool for cleanup and re-use.
     */
static void
geary_imap_engine_generic_account_release_folder_session_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_)
{
	GearyImapEngineGenericAccountReleaseFolderSessionData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_release_folder_session_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_release_folder_session_co (GearyImapEngineGenericAccountReleaseFolderSessionData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Releasing folder session");
	_data_->_tmp0_ = geary_imap_session_object_close (G_TYPE_CHECK_INSTANCE_CAST (_data_->session, GEARY_IMAP_TYPE_SESSION_OBJECT, GearyImapSessionObject));
	_data_->old_session = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->old_session;
	if (_data_->_tmp1_ != NULL) {
		{
			_data_->_tmp2_ = _data_->self->priv->_imap;
			_data_->_tmp3_ = _data_->old_session;
			_data_->_state_ = 1;
			geary_imap_client_service_release_session_async (_data_->_tmp2_, _data_->_tmp3_, geary_imap_engine_generic_account_release_folder_session_ready, _data_);
			return FALSE;
			_state_1:
			geary_imap_client_service_release_session_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			_data_->err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp4_ = geary_imap_folder_session_get_folder (_data_->session);
			_data_->_tmp5_ = _data_->_tmp4_;
			_data_->_tmp6_ = geary_imap_folder_get_path (_data_->_tmp5_);
			_data_->_tmp7_ = _data_->_tmp6_;
			_data_->_tmp8_ = geary_folder_path_to_string (_data_->_tmp7_);
			_data_->_tmp9_ = _data_->_tmp8_;
			_data_->_tmp10_ = _data_->err;
			_data_->_tmp11_ = _data_->_tmp10_->message;
			geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Error releasing %s session: %s", _data_->_tmp9_, _data_->_tmp11_);
			_g_free0 (_data_->_tmp9_);
			_g_error_free0 (_data_->err);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->old_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;
		}
	}
	_g_object_unref0 (_data_->old_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;
}

/** {@inheritDoc} */
static GearyEmailIdentifier*
geary_imap_engine_generic_account_real_to_email_identifier (GearyAccount* base,
                                                            GVariant* serialised,
                                                            GError** error)
{
	GearyImapEngineGenericAccount * self;
	const GVariantType* _tmp0_;
	gchar type = '\0';
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	gchar _tmp4_;
	GError* _tmp11_;
	GError* _inner_error0_ = NULL;
	GearyEmailIdentifier* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_val_if_fail (serialised != NULL, NULL);
	_tmp0_ = geary_imap_engine_generic_account_email_id_type;
	if (!g_variant_is_of_type (serialised, _tmp0_)) {
		GError* _tmp1_;
		_tmp1_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS, "Invalid outer serialised type");
		_inner_error0_ = _tmp1_;
		if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			return NULL;
		} 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 NULL;
		}
	}
	_tmp2_ = g_variant_get_child_value (serialised, (gsize) 0);
	_tmp3_ = _tmp2_;
	_tmp4_ = (gchar) g_variant_get_byte (_tmp3_);
	_g_variant_unref0 (_tmp3_);
	type = _tmp4_;
	if (type == 'i') {
		GearyImapDBEmailIdentifier* _tmp5_ = NULL;
		GearyImapDBEmailIdentifier* _tmp6_;
		GearyImapDBEmailIdentifier* _tmp7_;
		_tmp6_ = geary_imap_db_email_identifier_new_from_variant (serialised, &_inner_error0_);
		_tmp5_ = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
				g_propagate_error (error, _inner_error0_);
				return NULL;
			} 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 NULL;
			}
		}
		_tmp7_ = _tmp5_;
		_tmp5_ = NULL;
		result = G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEARY_TYPE_EMAIL_IDENTIFIER, GearyEmailIdentifier);
		_g_object_unref0 (_tmp5_);
		return result;
	}
	if (type == 'o') {
		GearyOutboxEmailIdentifier* _tmp8_ = NULL;
		GearyOutboxEmailIdentifier* _tmp9_;
		GearyOutboxEmailIdentifier* _tmp10_;
		_tmp9_ = geary_outbox_email_identifier_new_from_variant (serialised, &_inner_error0_);
		_tmp8_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
				g_propagate_error (error, _inner_error0_);
				return NULL;
			} 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 NULL;
			}
		}
		_tmp10_ = _tmp8_;
		_tmp8_ = NULL;
		result = G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEARY_TYPE_EMAIL_IDENTIFIER, GearyEmailIdentifier);
		_g_object_unref0 (_tmp8_);
		return result;
	}
	_tmp11_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS, "Unknown serialised type: %c", (gint) type);
	_inner_error0_ = _tmp11_;
	if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
		g_propagate_error (error, _inner_error0_);
		return NULL;
	} 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 NULL;
	}
}

/** {@inheritDoc} */
static GearyFolderPath*
geary_imap_engine_generic_account_real_to_folder_path (GearyAccount* base,
                                                       GVariant* serialised,
                                                       GError** error)
{
	GearyImapEngineGenericAccount * self;
	GearyFolderPath* path = NULL;
	GError* _inner_error0_ = NULL;
	GearyFolderPath* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_val_if_fail (serialised != NULL, NULL);
	path = NULL;
	{
		GearyFolderPath* _tmp0_ = NULL;
		GearyImapDBAccount* _tmp1_;
		GearyImapFolderRoot* _tmp2_;
		GearyImapFolderRoot* _tmp3_;
		GearyFolderPath* _tmp4_;
		GearyFolderPath* _tmp5_;
		_tmp1_ = self->priv->_local;
		_tmp2_ = geary_imap_db_account_get_imap_folder_root (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = geary_folder_root_from_variant (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_TYPE_FOLDER_ROOT, GearyFolderRoot), serialised, &_inner_error0_);
		_tmp0_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (g_error_matches (_inner_error0_, GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS)) {
				goto __catch0_geary_engine_error_bad_parameters;
			}
			_g_object_unref0 (path);
			g_critical ("file %s: line %d: unexpected 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 NULL;
		}
		_tmp5_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (path);
		path = _tmp5_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_geary_engine_error_bad_parameters:
	{
		GearyFolderPath* _tmp6_ = NULL;
		GearyFolderRoot* _tmp7_;
		GearyFolderRoot* _tmp8_;
		GearyFolderPath* _tmp9_;
		GearyFolderPath* _tmp10_;
		g_clear_error (&_inner_error0_);
		_tmp7_ = geary_account_get_local_folder_root (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
		_tmp8_ = _tmp7_;
		_tmp9_ = geary_folder_root_from_variant (_tmp8_, serialised, &_inner_error0_);
		_tmp6_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_tmp10_ = _tmp6_;
		_tmp6_ = NULL;
		_g_object_unref0 (path);
		path = _tmp10_;
		_g_object_unref0 (_tmp6_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (path);
			return NULL;
		} else {
			_g_object_unref0 (path);
			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 NULL;
		}
	}
	result = path;
	return result;
}

/** {@inheritDoc} */
static GearyFolder*
geary_imap_engine_generic_account_real_get_folder (GearyAccount* base,
                                                   GearyFolderPath* path,
                                                   GError** error)
{
	GearyImapEngineGenericAccount * self;
	GearyFolder* folder = NULL;
	GearyImapDBAccount* _tmp0_;
	GearyImapFolderRoot* _tmp1_;
	GearyImapFolderRoot* _tmp2_;
	GearyFolder* _tmp9_;
	GError* _inner_error0_ = NULL;
	GearyFolder* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (path), NULL);
	folder = NULL;
	_tmp0_ = self->priv->_local;
	_tmp1_ = geary_imap_db_account_get_imap_folder_root (_tmp0_);
	_tmp2_ = _tmp1_;
	if (geary_folder_path_is_descendant (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_TYPE_FOLDER_PATH, GearyFolderPath), path)) {
		GeeMap* _tmp3_;
		gpointer _tmp4_;
		_tmp3_ = self->priv->remote_folders;
		_tmp4_ = gee_map_get (_tmp3_, path);
		_g_object_unref0 (folder);
		folder = G_TYPE_CHECK_INSTANCE_CAST ((GearyImapEngineMinimalFolder*) _tmp4_, GEARY_TYPE_FOLDER, GearyFolder);
	} else {
		GearyFolderRoot* _tmp5_;
		GearyFolderRoot* _tmp6_;
		_tmp5_ = geary_account_get_local_folder_root (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
		_tmp6_ = _tmp5_;
		if (geary_folder_path_is_descendant (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEARY_TYPE_FOLDER_PATH, GearyFolderPath), path)) {
			GeeMap* _tmp7_;
			gpointer _tmp8_;
			_tmp7_ = self->priv->local_folders;
			_tmp8_ = gee_map_get (_tmp7_, path);
			_g_object_unref0 (folder);
			folder = (GearyFolder*) _tmp8_;
		}
	}
	_tmp9_ = folder;
	if (_tmp9_ == NULL) {
		gchar* _tmp10_;
		gchar* _tmp11_;
		GError* _tmp12_;
		GError* _tmp13_;
		_tmp10_ = geary_folder_path_to_string (path);
		_tmp11_ = _tmp10_;
		_tmp12_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "Folder not found: %s", _tmp11_);
		_tmp13_ = _tmp12_;
		_g_free0 (_tmp11_);
		_inner_error0_ = _tmp13_;
		if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (folder);
			return NULL;
		} else {
			_g_object_unref0 (folder);
			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 NULL;
		}
	}
	result = folder;
	return result;
}

/** {@inheritDoc} */
static GeeCollection*
geary_imap_engine_generic_account_real_list_folders (GearyAccount* base)
{
	GearyImapEngineGenericAccount * self;
	GeeHashSet* all = NULL;
	GeeHashSet* _tmp0_;
	GeeMap* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	GeeMap* _tmp5_;
	GeeCollection* _tmp6_;
	GeeCollection* _tmp7_;
	GeeCollection* _tmp8_;
	GeeCollection* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_tmp0_ = gee_hash_set_new (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	all = _tmp0_;
	_tmp1_ = self->priv->remote_folders;
	_tmp2_ = gee_map_get_values (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (all, GEE_TYPE_COLLECTION, GeeCollection), _tmp4_);
	_g_object_unref0 (_tmp4_);
	_tmp5_ = self->priv->local_folders;
	_tmp6_ = gee_map_get_values (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (all, GEE_TYPE_COLLECTION, GeeCollection), _tmp8_);
	_g_object_unref0 (_tmp8_);
	result = G_TYPE_CHECK_INSTANCE_CAST (all, GEE_TYPE_COLLECTION, GeeCollection);
	return result;
}

/** {@inheritDoc} */
static Block96Data*
block96_data_ref (Block96Data* _data96_)
{
	g_atomic_int_inc (&_data96_->_ref_count_);
	return _data96_;
}

static void
block96_data_unref (void * _userdata_)
{
	Block96Data* _data96_;
	_data96_ = (Block96Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data96_->_ref_count_)) {
		GearyImapEngineGenericAccount* self;
		self = _data96_->self;
		_g_object_unref0 (_data96_->folders);
		_g_object_unref0 (_data96_->parent);
		_g_object_unref0 (self);
		g_slice_free (Block96Data, _data96_);
	}
}

static gboolean
__lambda145_ (Block96Data* _data96_,
              GearyFolderPath* p)
{
	GearyImapEngineGenericAccount* self;
	GearyFolderPath* path_parent = NULL;
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean result;
	self = _data96_->self;
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (p), FALSE);
	_tmp0_ = geary_folder_path_get_parent (p);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	path_parent = _tmp2_;
	if (_data96_->parent == NULL) {
		GearyFolderPath* _tmp5_;
		_tmp5_ = path_parent;
		_tmp4_ = _tmp5_ == NULL;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		gboolean _tmp6_ = FALSE;
		gboolean _tmp7_ = FALSE;
		if (_data96_->parent != NULL) {
			GearyFolderPath* _tmp8_;
			_tmp8_ = path_parent;
			_tmp7_ = _tmp8_ != NULL;
		} else {
			_tmp7_ = FALSE;
		}
		if (_tmp7_) {
			GearyFolderPath* _tmp9_;
			_tmp9_ = path_parent;
			_tmp6_ = gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEE_TYPE_HASHABLE, GeeHashable), _data96_->parent);
		} else {
			_tmp6_ = FALSE;
		}
		_tmp3_ = _tmp6_;
	}
	result = _tmp3_;
	_g_object_unref0 (path_parent);
	return result;
}

static gboolean
___lambda145__gee_predicate (gconstpointer g,
                             gpointer self)
{
	gboolean result;
	result = __lambda145_ (self, (GearyFolderPath*) g);
	return result;
}

static GearyFolder*
__lambda146_ (Block96Data* _data96_,
              GearyFolderPath* p)
{
	GearyImapEngineGenericAccount* self;
	GeeMap* _tmp0_;
	gpointer _tmp1_;
	GearyFolder* result;
	self = _data96_->self;
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (p), NULL);
	_tmp0_ = _data96_->folders;
	_tmp1_ = gee_map_get (_tmp0_, p);
	result = (GearyFolder*) _tmp1_;
	_g_object_unref0 (p);
	return result;
}

static gpointer
___lambda146__gee_map_func (gpointer g,
                            gpointer self)
{
	gpointer result;
	result = __lambda146_ (self, (GearyFolderPath*) g);
	return result;
}

static GeeCollection*
geary_imap_engine_generic_account_real_list_matching_folders (GearyAccount* base,
                                                              GearyFolderPath* parent,
                                                              GError** error)
{
	GearyImapEngineGenericAccount * self;
	Block96Data* _data96_;
	GearyFolderPath* _tmp0_;
	GearyImapDBAccount* _tmp1_;
	GearyImapFolderRoot* _tmp2_;
	GearyImapFolderRoot* _tmp3_;
	GeeMap* _tmp14_;
	GeeMap* _tmp19_;
	GeeSet* _tmp20_;
	GeeSet* _tmp21_;
	GeeSet* _tmp22_;
	GearyIterable* _tmp23_;
	GearyIterable* _tmp24_;
	GearyIterable* _tmp25_;
	GearyIterable* _tmp26_;
	GearyIterable* _tmp27_;
	GearyIterable* _tmp28_;
	GeeArrayList* _tmp29_;
	GeeCollection* _tmp30_;
	GError* _inner_error0_ = NULL;
	GeeCollection* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_val_if_fail ((parent == NULL) || GEARY_IS_FOLDER_PATH (parent), NULL);
	_data96_ = g_slice_new0 (Block96Data);
	_data96_->_ref_count_ = 1;
	_data96_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (parent);
	_g_object_unref0 (_data96_->parent);
	_data96_->parent = _tmp0_;
	_data96_->folders = NULL;
	_tmp1_ = self->priv->_local;
	_tmp2_ = geary_imap_db_account_get_imap_folder_root (_tmp1_);
	_tmp3_ = _tmp2_;
	if (geary_folder_path_is_descendant (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_TYPE_FOLDER_PATH, GearyFolderPath), _data96_->parent)) {
		GeeMap* _tmp4_;
		GeeMap* _tmp5_;
		_tmp4_ = self->priv->remote_folders;
		_tmp5_ = _g_object_ref0 (_tmp4_);
		_g_object_unref0 (_data96_->folders);
		_data96_->folders = _tmp5_;
	} else {
		GearyFolderRoot* _tmp6_;
		GearyFolderRoot* _tmp7_;
		_tmp6_ = geary_account_get_local_folder_root (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
		_tmp7_ = _tmp6_;
		if (geary_folder_path_is_descendant (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEARY_TYPE_FOLDER_PATH, GearyFolderPath), _data96_->parent)) {
			GeeMap* _tmp8_;
			GeeMap* _tmp9_;
			_tmp8_ = self->priv->local_folders;
			_tmp9_ = _g_object_ref0 (_tmp8_);
			_g_object_unref0 (_data96_->folders);
			_data96_->folders = _tmp9_;
		} else {
			gchar* _tmp10_;
			gchar* _tmp11_;
			GError* _tmp12_;
			GError* _tmp13_;
			_tmp10_ = geary_folder_path_to_string (_data96_->parent);
			_tmp11_ = _tmp10_;
			_tmp12_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "Unknown folder root: %s", _tmp11_);
			_tmp13_ = _tmp12_;
			_g_free0 (_tmp11_);
			_inner_error0_ = _tmp13_;
			if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
				g_propagate_error (error, _inner_error0_);
				block96_data_unref (_data96_);
				_data96_ = NULL;
				return NULL;
			} else {
				block96_data_unref (_data96_);
				_data96_ = 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 NULL;
			}
		}
	}
	_tmp14_ = _data96_->folders;
	if (!gee_map_has_key (_tmp14_, _data96_->parent)) {
		gchar* _tmp15_;
		gchar* _tmp16_;
		GError* _tmp17_;
		GError* _tmp18_;
		_tmp15_ = geary_folder_path_to_string (_data96_->parent);
		_tmp16_ = _tmp15_;
		_tmp17_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "Unknown parent: %s", _tmp16_);
		_tmp18_ = _tmp17_;
		_g_free0 (_tmp16_);
		_inner_error0_ = _tmp18_;
		if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			block96_data_unref (_data96_);
			_data96_ = NULL;
			return NULL;
		} else {
			block96_data_unref (_data96_);
			_data96_ = 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 NULL;
		}
	}
	_tmp19_ = _data96_->folders;
	_tmp20_ = gee_map_get_keys (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = _tmp21_;
	_tmp23_ = geary_traverse (GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, GEE_TYPE_ITERABLE, GeeIterable));
	_tmp24_ = _tmp23_;
	_tmp25_ = geary_iterable_filter (_tmp24_, ___lambda145__gee_predicate, block96_data_ref (_data96_), block96_data_unref);
	_tmp26_ = _tmp25_;
	_tmp27_ = geary_iterable_map (_tmp26_, GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, ___lambda146__gee_map_func, _data96_);
	_tmp28_ = _tmp27_;
	_tmp29_ = geary_iterable_to_array_list (_tmp28_, NULL, NULL, NULL);
	_tmp30_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, GEE_TYPE_COLLECTION, GeeCollection);
	_g_object_unref0 (_tmp28_);
	_g_object_unref0 (_tmp26_);
	_g_object_unref0 (_tmp24_);
	_g_object_unref0 (_tmp22_);
	result = _tmp30_;
	block96_data_unref (_data96_);
	_data96_ = NULL;
	return result;
}

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

static void
geary_imap_engine_generic_account_real_get_required_special_folder_async (GearyAccount* base,
                                                                          GearyFolderSpecialUse special,
                                                                          GCancellable* cancellable,
                                                                          GAsyncReadyCallback _callback_,
                                                                          gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountGetRequiredSpecialFolderAsyncData* _data_;
	GearyImapEngineGenericAccount* _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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountGetRequiredSpecialFolderAsyncData);
	_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_generic_account_real_get_required_special_folder_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->special = special;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	geary_imap_engine_generic_account_real_get_required_special_folder_async_co (_data_);
}

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

static gboolean
_vala_geary_folder_special_use_array_contains (GearyFolderSpecialUse * stack,
                                               gssize stack_length,
                                               const GearyFolderSpecialUse needle)
{
	gssize i;
	for (i = 0; i < stack_length; i++) {
		if (needle == stack[i]) {
			return TRUE;
		}
	}
	return FALSE;
}

static void
geary_imap_engine_generic_account_get_required_special_folder_async_ready (GObject* source_object,
                                                                           GAsyncResult* _res_,
                                                                           gpointer _user_data_)
{
	GearyImapEngineGenericAccountGetRequiredSpecialFolderAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_get_required_special_folder_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_get_required_special_folder_async_co (GearyImapEngineGenericAccountGetRequiredSpecialFolderAsyncData* _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_ = 0;
	_data_->_tmp1_ = geary_imap_engine_generic_account_get_supported_special_folders (_data_->self, &_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp2__length1 = _data_->_tmp0_;
	_data_->_tmp3_ = !_vala_geary_folder_special_use_array_contains (_data_->_tmp2_, _data_->_tmp0_, _data_->special);
	_data_->_tmp2_ = (g_free (_data_->_tmp2_), NULL);
	if (_data_->_tmp3_) {
		_data_->_tmp4_ = g_enum_to_string (GEARY_FOLDER_TYPE_SPECIAL_USE, _data_->special);
		_data_->_tmp5_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS, "Invalid special folder type %s passed to get_required_special_folder_a" \
"sync", _data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_g_free0 (_data_->_tmp4_);
		_data_->_inner_error0_ = _data_->_tmp6_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	geary_imap_engine_generic_account_check_open (_data_->self, &_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_->_tmp7_ = geary_account_get_special_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->special);
	_data_->folder = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->folder;
	if (_data_->_tmp8_ == NULL) {
		_data_->_state_ = 1;
		geary_imap_engine_generic_account_claim_account_session (_data_->self, _data_->cancellable, geary_imap_engine_generic_account_get_required_special_folder_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp9_ = geary_imap_engine_generic_account_claim_account_session_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		_data_->account = _data_->_tmp9_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->folder);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		{
			_data_->_tmp11_ = _data_->account;
			_data_->_state_ = 2;
			geary_imap_engine_generic_account_ensure_special_folder_async (_data_->self, _data_->_tmp11_, _data_->special, _data_->cancellable, geary_imap_engine_generic_account_get_required_special_folder_async_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp12_ = geary_imap_engine_generic_account_ensure_special_folder_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp10_ = _data_->_tmp12_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __finally0;
			}
			_data_->_tmp13_ = _data_->_tmp10_;
			_data_->_tmp10_ = NULL;
			_g_object_unref0 (_data_->folder);
			_data_->folder = _data_->_tmp13_;
			_g_object_unref0 (_data_->_tmp10_);
		}
		__finally0:
		{
			_data_->_tmp14_ = _data_->account;
			geary_imap_engine_generic_account_release_account_session (_data_->self, _data_->_tmp14_);
		}
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->account);
			_g_object_unref0 (_data_->folder);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->account);
	}
	_data_->result = _data_->folder;
	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_generic_account_real_create_personal_folder_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountCreatePersonalFolderData* _data_;
	_data_ = _data;
	_g_free0 (_data_->name);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountCreatePersonalFolderData, _data_);
}

static void
geary_imap_engine_generic_account_real_create_personal_folder (GearyAccount* base,
                                                               const gchar* name,
                                                               GearyFolderSpecialUse use,
                                                               GCancellable* cancellable,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountCreatePersonalFolderData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	gchar* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (name != NULL);
	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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountCreatePersonalFolderData);
	_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_generic_account_real_create_personal_folder_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (name);
	_g_free0 (_data_->name);
	_data_->name = _tmp1_;
	_data_->use = use;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_generic_account_real_create_personal_folder_co (_data_);
}

static GearyFolder*
geary_imap_engine_generic_account_create_personal_folder_finish (GearyAccount* base,
                                                                 GAsyncResult* _res_,
                                                                 GError** error)
{
	GearyFolder* result;
	GearyImapEngineGenericAccountCreatePersonalFolderData* _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_generic_account_create_personal_folder_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_)
{
	GearyImapEngineGenericAccountCreatePersonalFolderData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_create_personal_folder_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_create_personal_folder_co (GearyImapEngineGenericAccountCreatePersonalFolderData* _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_generic_account_check_open (_data_->self, &_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_generic_account_claim_account_session (_data_->self, _data_->cancellable, geary_imap_engine_generic_account_create_personal_folder_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = geary_imap_engine_generic_account_claim_account_session_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
	_data_->remote = _data_->_tmp0_;
	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_->remote;
	_data_->_state_ = 2;
	geary_imap_account_session_get_default_personal_namespace (_data_->_tmp1_, _data_->cancellable, geary_imap_engine_generic_account_create_personal_folder_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp2_ = geary_imap_account_session_get_default_personal_namespace_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
	_data_->root = _data_->_tmp2_;
	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;
	}
	_data_->_tmp3_ = _data_->root;
	_data_->_tmp4_ = geary_folder_path_get_child (_data_->_tmp3_, _data_->name, GEARY_TRILLIAN_UNKNOWN);
	_data_->path = _data_->_tmp4_;
	_data_->_tmp5_ = _data_->self->priv->remote_folders;
	_data_->_tmp6_ = _data_->path;
	if (gee_map_has_key (_data_->_tmp5_, _data_->_tmp6_)) {
		_data_->_tmp7_ = _data_->path;
		_data_->_tmp8_ = geary_folder_path_to_string (_data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_ALREADY_EXISTS, "Folder already exists: %s", _data_->_tmp9_);
		_data_->_tmp11_ = _data_->_tmp10_;
		_g_free0 (_data_->_tmp9_);
		_data_->_inner_error0_ = _data_->_tmp11_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->path);
		_g_object_unref0 (_data_->root);
		_g_object_unref0 (_data_->remote);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp12_ = _data_->remote;
	_data_->_tmp13_ = _data_->path;
	_data_->_state_ = 3;
	geary_imap_account_session_create_folder_async (_data_->_tmp12_, _data_->_tmp13_, &_data_->use, _data_->cancellable, geary_imap_engine_generic_account_create_personal_folder_ready, _data_);
	return FALSE;
	_state_3:
	geary_imap_account_session_create_folder_finish (_data_->_tmp12_, _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_->path);
		_g_object_unref0 (_data_->root);
		_g_object_unref0 (_data_->remote);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp14_ = _data_->remote;
	_data_->_tmp15_ = _data_->path;
	_data_->_state_ = 4;
	geary_imap_account_session_fetch_folder_async (_data_->_tmp14_, _data_->_tmp15_, _data_->cancellable, geary_imap_engine_generic_account_create_personal_folder_ready, _data_);
	return FALSE;
	_state_4:
	_data_->_tmp16_ = geary_imap_account_session_fetch_folder_finish (_data_->_tmp14_, _data_->_res_, &_data_->_inner_error0_);
	_data_->remote_folder = _data_->_tmp16_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->path);
		_g_object_unref0 (_data_->root);
		_g_object_unref0 (_data_->remote);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp17_ = _data_->self->priv->_local;
	_data_->_tmp18_ = _data_->remote_folder;
	_data_->_state_ = 5;
	geary_imap_db_account_clone_folder_async (_data_->_tmp17_, _data_->_tmp18_, _data_->cancellable, geary_imap_engine_generic_account_create_personal_folder_ready, _data_);
	return FALSE;
	_state_5:
	_data_->_tmp19_ = geary_imap_db_account_clone_folder_finish (_data_->_tmp17_, _data_->_res_, &_data_->_inner_error0_);
	_data_->local_folder = _data_->_tmp19_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->remote_folder);
		_g_object_unref0 (_data_->path);
		_g_object_unref0 (_data_->root);
		_g_object_unref0 (_data_->remote);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp20_ = _data_->local_folder;
	_data_->_tmp21_ = geary_collection_single (GEARY_IMAP_DB_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp20_);
	_data_->_tmp22_ = _data_->_tmp21_;
	_data_->_tmp23_ = geary_imap_engine_generic_account_add_folders (_data_->self, _data_->_tmp22_, FALSE);
	_data_->_tmp24_ = _data_->_tmp23_;
	_g_object_unref0 (_data_->_tmp24_);
	_g_object_unref0 (_data_->_tmp22_);
	_data_->_tmp25_ = _data_->self->priv->remote_folders;
	_data_->_tmp26_ = _data_->path;
	_data_->_tmp27_ = gee_map_get (_data_->_tmp25_, _data_->_tmp26_);
	_data_->folder = (GearyImapEngineMinimalFolder*) _data_->_tmp27_;
	if (_data_->use != GEARY_FOLDER_SPECIAL_USE_NONE) {
		_data_->_tmp28_ = _data_->folder;
		_data_->_tmp29_ = geary_collection_single_map (GEARY_FOLDER_TYPE_SPECIAL_USE, NULL, NULL, GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, (gpointer) ((gintptr) _data_->use), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp28_, GEARY_TYPE_FOLDER, GearyFolder));
		_data_->_tmp30_ = _data_->_tmp29_;
		geary_imap_engine_generic_account_promote_folders (_data_->self, _data_->_tmp30_);
		_g_object_unref0 (_data_->_tmp30_);
	}
	_data_->result = G_TYPE_CHECK_INSTANCE_CAST (_data_->folder, GEARY_TYPE_FOLDER, GearyFolder);
	_g_object_unref0 (_data_->local_folder);
	_g_object_unref0 (_data_->remote_folder);
	_g_object_unref0 (_data_->path);
	_g_object_unref0 (_data_->root);
	_g_object_unref0 (_data_->remote);
	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 void
geary_imap_engine_generic_account_real_register_local_folder (GearyAccount* base,
                                                              GearyFolder* local,
                                                              GError** error)
{
	GearyImapEngineGenericAccount * self;
	GearyFolderPath* path = NULL;
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	GeeMap* _tmp3_;
	GearyFolderPath* _tmp4_;
	GearyFolderRoot* _tmp10_;
	GearyFolderRoot* _tmp11_;
	GearyFolderPath* _tmp12_;
	GeeMap* _tmp18_;
	GearyFolderPath* _tmp19_;
	GeeCollection* _tmp20_;
	GeeCollection* _tmp21_;
	GeeBidirSortedSet* _tmp22_;
	GeeBidirSortedSet* _tmp23_;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_if_fail (GEARY_IS_FOLDER (local));
	_tmp0_ = geary_folder_get_path (local);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	path = _tmp2_;
	_tmp3_ = self->priv->local_folders;
	_tmp4_ = path;
	if (gee_map_has_key (_tmp3_, _tmp4_)) {
		GearyFolderPath* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		GError* _tmp8_;
		GError* _tmp9_;
		_tmp5_ = path;
		_tmp6_ = geary_folder_path_to_string (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_ALREADY_EXISTS, "Folder already exists: %s", _tmp7_);
		_tmp9_ = _tmp8_;
		_g_free0 (_tmp7_);
		_inner_error0_ = _tmp9_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (path);
		return;
	}
	_tmp10_ = geary_account_get_local_folder_root (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_tmp11_ = _tmp10_;
	_tmp12_ = path;
	if (!geary_folder_path_is_descendant (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEARY_TYPE_FOLDER_PATH, GearyFolderPath), _tmp12_)) {
		GearyFolderPath* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		GError* _tmp16_;
		GError* _tmp17_;
		_tmp13_ = path;
		_tmp14_ = geary_folder_path_to_string (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "Not a desendant of the local folder root: %s", _tmp15_);
		_tmp17_ = _tmp16_;
		_g_free0 (_tmp15_);
		_inner_error0_ = _tmp17_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (path);
		return;
	}
	_tmp18_ = self->priv->local_folders;
	_tmp19_ = path;
	gee_map_set (_tmp18_, _tmp19_, local);
	_tmp20_ = geary_collection_single (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, local);
	_tmp21_ = _tmp20_;
	_tmp22_ = geary_account_sort_by_path (_tmp21_);
	_tmp23_ = _tmp22_;
	geary_account_notify_folders_available_unavailable (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), _tmp23_, NULL);
	_g_object_unref0 (_tmp23_);
	_g_object_unref0 (_tmp21_);
	_g_object_unref0 (path);
}

/** {@inheritDoc} */
static void
geary_imap_engine_generic_account_real_deregister_local_folder (GearyAccount* base,
                                                                GearyFolder* local,
                                                                GError** error)
{
	GearyImapEngineGenericAccount * self;
	GearyFolderPath* path = NULL;
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	GeeMap* _tmp3_;
	GearyFolderPath* _tmp4_;
	GeeCollection* _tmp10_;
	GeeCollection* _tmp11_;
	GeeBidirSortedSet* _tmp12_;
	GeeBidirSortedSet* _tmp13_;
	GeeMap* _tmp14_;
	GearyFolderPath* _tmp15_;
	GError* _inner_error0_ = NULL;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_if_fail (GEARY_IS_FOLDER (local));
	_tmp0_ = geary_folder_get_path (local);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	path = _tmp2_;
	_tmp3_ = self->priv->local_folders;
	_tmp4_ = path;
	if (!gee_map_has_key (_tmp3_, _tmp4_)) {
		GearyFolderPath* _tmp5_;
		gchar* _tmp6_;
		gchar* _tmp7_;
		GError* _tmp8_;
		GError* _tmp9_;
		_tmp5_ = path;
		_tmp6_ = geary_folder_path_to_string (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "Unknown folder: %s", _tmp7_);
		_tmp9_ = _tmp8_;
		_g_free0 (_tmp7_);
		_inner_error0_ = _tmp9_;
		g_propagate_error (error, _inner_error0_);
		_g_object_unref0 (path);
		return;
	}
	_tmp10_ = geary_collection_single (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, local);
	_tmp11_ = _tmp10_;
	_tmp12_ = geary_account_sort_by_path (_tmp11_);
	_tmp13_ = _tmp12_;
	geary_account_notify_folders_available_unavailable (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), NULL, _tmp13_);
	_g_object_unref0 (_tmp13_);
	_g_object_unref0 (_tmp11_);
	_tmp14_ = self->priv->local_folders;
	_tmp15_ = path;
	gee_map_unset (_tmp14_, _tmp15_, NULL);
	_g_object_unref0 (path);
}

static GearyImapDBEmailIdentifier*
geary_imap_engine_generic_account_check_id (GearyImapEngineGenericAccount* self,
                                            GearyEmailIdentifier* id,
                                            GError** error)
{
	GearyImapDBEmailIdentifier* imapdb_id = NULL;
	GearyImapDBEmailIdentifier* _tmp0_;
	GearyImapDBEmailIdentifier* _tmp1_;
	GError* _inner_error0_ = NULL;
	GearyImapDBEmailIdentifier* result;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	g_return_val_if_fail (GEARY_IS_EMAIL_IDENTIFIER (id), NULL);
	_tmp0_ = _g_object_ref0 (GEARY_IMAP_DB_IS_EMAIL_IDENTIFIER (id) ? ((GearyImapDBEmailIdentifier*) id) : NULL);
	imapdb_id = _tmp0_;
	_tmp1_ = imapdb_id;
	if (_tmp1_ == NULL) {
		gchar* _tmp2_;
		gchar* _tmp3_;
		GError* _tmp4_;
		GError* _tmp5_;
		_tmp2_ = geary_email_identifier_to_string (id);
		_tmp3_ = _tmp2_;
		_tmp4_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS, "EmailIdentifier %s not from ImapDB folder", _tmp3_);
		_tmp5_ = _tmp4_;
		_g_free0 (_tmp3_);
		_inner_error0_ = _tmp5_;
		if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
			g_propagate_error (error, _inner_error0_);
			_g_object_unref0 (imapdb_id);
			return NULL;
		} else {
			_g_object_unref0 (imapdb_id);
			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 NULL;
		}
	}
	result = imapdb_id;
	return result;
}

static GeeCollection*
geary_imap_engine_generic_account_check_ids (GearyImapEngineGenericAccount* self,
                                             GeeCollection* ids,
                                             GError** error)
{
	GeeCollection* _tmp10_;
	GError* _inner_error0_ = NULL;
	GeeCollection* result;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION), NULL);
	{
		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;
			if (!GEARY_IMAP_DB_IS_EMAIL_IDENTIFIER (_tmp4_)) {
				GearyEmailIdentifier* _tmp5_;
				gchar* _tmp6_;
				gchar* _tmp7_;
				GError* _tmp8_;
				GError* _tmp9_;
				_tmp5_ = id;
				_tmp6_ = geary_email_identifier_to_string (_tmp5_);
				_tmp7_ = _tmp6_;
				_tmp8_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS, "EmailIdentifier %s not from ImapDB folder", _tmp7_);
				_tmp9_ = _tmp8_;
				_g_free0 (_tmp7_);
				_inner_error0_ = _tmp9_;
				if (_inner_error0_->domain == GEARY_ENGINE_ERROR) {
					g_propagate_error (error, _inner_error0_);
					_g_object_unref0 (id);
					_g_object_unref0 (_id_it);
					return NULL;
				} 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 NULL;
				}
			}
			_g_object_unref0 (id);
		}
		_g_object_unref0 (_id_it);
	}
	_tmp10_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (ids, GEE_TYPE_COLLECTION, GeeCollection));
	result = _tmp10_;
	return result;
}

/** {@inheritDoc} */
static GearySearchQuery*
geary_imap_engine_generic_account_real_new_search_query (GearyAccount* base,
                                                         GeeList* expression,
                                                         const gchar* text,
                                                         GError** error)
{
	GearyImapEngineGenericAccount * self;
	struct sb_stemmer* _tmp0_;
	GearyFtsSearchQuery* _tmp1_;
	GearySearchQuery* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (expression, GEE_TYPE_LIST), NULL);
	g_return_val_if_fail (text != NULL, NULL);
	_tmp0_ = self->priv->stemmer;
	_tmp1_ = geary_fts_search_query_new (expression, text, _tmp0_);
	result = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEARY_TYPE_SEARCH_QUERY, GearySearchQuery);
	return result;
}

static void
geary_imap_engine_generic_account_real_local_search_message_id_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->message_id);
	_g_object_unref0 (_data_->folder_blacklist);
	_g_object_unref0 (_data_->flag_blacklist);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData, _data_);
}

static void
geary_imap_engine_generic_account_real_local_search_message_id_async (GearyAccount* base,
                                                                      GearyRFC822MessageID* message_id,
                                                                      GearyEmailField requested_fields,
                                                                      gboolean partial_ok,
                                                                      GeeCollection* folder_blacklist,
                                                                      GearyEmailFlags* flag_blacklist,
                                                                      GCancellable* cancellable,
                                                                      GAsyncReadyCallback _callback_,
                                                                      gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyRFC822MessageID* _tmp1_;
	GeeCollection* _tmp2_;
	GearyEmailFlags* _tmp3_;
	GCancellable* _tmp4_;
	g_return_if_fail (GEARY_RF_C822_IS_MESSAGE_ID (message_id));
	g_return_if_fail ((folder_blacklist == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (folder_blacklist, GEE_TYPE_COLLECTION));
	g_return_if_fail ((flag_blacklist == NULL) || GEARY_IS_EMAIL_FLAGS (flag_blacklist));
	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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData);
	_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_generic_account_real_local_search_message_id_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (message_id);
	_g_object_unref0 (_data_->message_id);
	_data_->message_id = _tmp1_;
	_data_->requested_fields = requested_fields;
	_data_->partial_ok = partial_ok;
	_tmp2_ = _g_object_ref0 (folder_blacklist);
	_g_object_unref0 (_data_->folder_blacklist);
	_data_->folder_blacklist = _tmp2_;
	_tmp3_ = _g_object_ref0 (flag_blacklist);
	_g_object_unref0 (_data_->flag_blacklist);
	_data_->flag_blacklist = _tmp3_;
	_tmp4_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp4_;
	geary_imap_engine_generic_account_real_local_search_message_id_async_co (_data_);
}

static GeeMultiMap*
geary_imap_engine_generic_account_local_search_message_id_finish (GearyAccount* base,
                                                                  GAsyncResult* _res_,
                                                                  GError** error)
{
	GeeMultiMap* result;
	GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData* _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_generic_account_local_search_message_id_async_ready (GObject* source_object,
                                                                       GAsyncResult* _res_,
                                                                       gpointer _user_data_)
{
	GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_local_search_message_id_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_local_search_message_id_async_co (GearyImapEngineGenericAccountLocalSearchMessageIdAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _data_->self->priv->_local;
	_data_->_state_ = 1;
	geary_imap_db_account_search_message_id_async (_data_->_tmp1_, _data_->message_id, _data_->requested_fields, _data_->partial_ok, _data_->folder_blacklist, _data_->flag_blacklist, _data_->cancellable, geary_imap_engine_generic_account_local_search_message_id_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = geary_imap_db_account_search_message_id_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_generic_account_real_local_fetch_email_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountLocalFetchEmailAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->email_id);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountLocalFetchEmailAsyncData, _data_);
}

static void
geary_imap_engine_generic_account_real_local_fetch_email_async (GearyAccount* base,
                                                                GearyEmailIdentifier* email_id,
                                                                GearyEmailField required_fields,
                                                                GCancellable* cancellable,
                                                                GAsyncReadyCallback _callback_,
                                                                gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountLocalFetchEmailAsyncData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyEmailIdentifier* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_IS_EMAIL_IDENTIFIER (email_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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountLocalFetchEmailAsyncData);
	_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_generic_account_real_local_fetch_email_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (email_id);
	_g_object_unref0 (_data_->email_id);
	_data_->email_id = _tmp1_;
	_data_->required_fields = required_fields;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_generic_account_real_local_fetch_email_async_co (_data_);
}

static GearyEmail*
geary_imap_engine_generic_account_local_fetch_email_finish (GearyAccount* base,
                                                            GAsyncResult* _res_,
                                                            GError** error)
{
	GearyEmail* result;
	GearyImapEngineGenericAccountLocalFetchEmailAsyncData* _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_generic_account_local_fetch_email_async_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_)
{
	GearyImapEngineGenericAccountLocalFetchEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_local_fetch_email_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_local_fetch_email_async_co (GearyImapEngineGenericAccountLocalFetchEmailAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = geary_imap_engine_generic_account_check_id (_data_->self, _data_->email_id, &_data_->_inner_error0_);
	_data_->_tmp0_ = _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_->_tmp3_ = _data_->self->priv->_local;
	_data_->_state_ = 1;
	geary_imap_db_account_fetch_email_async (_data_->_tmp3_, _data_->_tmp0_, _data_->required_fields, _data_->cancellable, geary_imap_engine_generic_account_local_fetch_email_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp4_ = geary_imap_db_account_fetch_email_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp2_ = _data_->_tmp4_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->_tmp2_;
	_data_->_tmp2_ = NULL;
	_data_->result = _data_->_tmp5_;
	_g_object_unref0 (_data_->_tmp2_);
	_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_generic_account_real_list_local_email_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountListLocalEmailAsyncData* _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 (GearyImapEngineGenericAccountListLocalEmailAsyncData, _data_);
}

static void
geary_imap_engine_generic_account_real_list_local_email_async (GearyAccount* base,
                                                               GeeCollection* ids,
                                                               GearyEmailField required_fields,
                                                               GCancellable* cancellable,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountListLocalEmailAsyncData* _data_;
	GearyImapEngineGenericAccount* _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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountListLocalEmailAsyncData);
	_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_generic_account_real_list_local_email_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;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_generic_account_real_list_local_email_async_co (_data_);
}

static GeeList*
geary_imap_engine_generic_account_list_local_email_finish (GearyAccount* base,
                                                           GAsyncResult* _res_,
                                                           GError** error)
{
	GeeList* result;
	GearyImapEngineGenericAccountListLocalEmailAsyncData* _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_generic_account_list_local_email_async_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_)
{
	GearyImapEngineGenericAccountListLocalEmailAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_list_local_email_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_list_local_email_async_co (GearyImapEngineGenericAccountListLocalEmailAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = geary_imap_engine_generic_account_check_ids (_data_->self, _data_->ids, &_data_->_inner_error0_);
	_data_->_tmp0_ = _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_->_tmp3_ = _data_->self->priv->_local;
	_data_->_state_ = 1;
	geary_imap_db_account_list_email (_data_->_tmp3_, _data_->_tmp0_, _data_->required_fields, _data_->cancellable, geary_imap_engine_generic_account_list_local_email_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp4_ = geary_imap_db_account_list_email_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp2_ = _data_->_tmp4_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->_tmp2_;
	_data_->_tmp2_ = NULL;
	_data_->result = _data_->_tmp5_;
	_g_object_unref0 (_data_->_tmp2_);
	_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_generic_account_real_local_search_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountLocalSearchAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->query);
	_g_object_unref0 (_data_->folder_blacklist);
	_g_object_unref0 (_data_->search_ids);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountLocalSearchAsyncData, _data_);
}

static void
geary_imap_engine_generic_account_real_local_search_async (GearyAccount* base,
                                                           GearySearchQuery* query,
                                                           gint limit,
                                                           gint offset,
                                                           GeeCollection* folder_blacklist,
                                                           GeeCollection* search_ids,
                                                           GCancellable* cancellable,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountLocalSearchAsyncData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GearySearchQuery* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GCancellable* _tmp4_;
	g_return_if_fail (GEARY_IS_SEARCH_QUERY (query));
	g_return_if_fail ((folder_blacklist == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (folder_blacklist, GEE_TYPE_COLLECTION));
	g_return_if_fail ((search_ids == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (search_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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountLocalSearchAsyncData);
	_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_generic_account_real_local_search_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (query);
	_g_object_unref0 (_data_->query);
	_data_->query = _tmp1_;
	_data_->limit = limit;
	_data_->offset = offset;
	_tmp2_ = _g_object_ref0 (folder_blacklist);
	_g_object_unref0 (_data_->folder_blacklist);
	_data_->folder_blacklist = _tmp2_;
	_tmp3_ = _g_object_ref0 (search_ids);
	_g_object_unref0 (_data_->search_ids);
	_data_->search_ids = _tmp3_;
	_tmp4_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp4_;
	geary_imap_engine_generic_account_real_local_search_async_co (_data_);
}

static GeeCollection*
geary_imap_engine_generic_account_local_search_finish (GearyAccount* base,
                                                       GAsyncResult* _res_,
                                                       GError** error)
{
	GeeCollection* result;
	GearyImapEngineGenericAccountLocalSearchAsyncData* _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_generic_account_local_search_async_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_)
{
	GearyImapEngineGenericAccountLocalSearchAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_local_search_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_local_search_async_co (GearyImapEngineGenericAccountLocalSearchAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->offset < 0) {
		_data_->_tmp0_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_BAD_PARAMETERS, "Offset must not be negative");
		_data_->_inner_error0_ = _data_->_tmp0_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp2_ = _data_->self->priv->_local;
	_data_->_state_ = 1;
	geary_imap_db_account_search_async (_data_->_tmp2_, _data_->query, _data_->limit, _data_->offset, _data_->folder_blacklist, _data_->search_ids, _data_->cancellable, geary_imap_engine_generic_account_local_search_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp3_ = geary_imap_db_account_search_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp1_ = _data_->_tmp3_;
	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_->_tmp4_ = _data_->_tmp1_;
	_data_->_tmp1_ = NULL;
	_data_->result = _data_->_tmp4_;
	_g_object_unref0 (_data_->_tmp1_);
	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_generic_account_real_get_search_matches_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountGetSearchMatchesAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->query);
	_g_object_unref0 (_data_->ids);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountGetSearchMatchesAsyncData, _data_);
}

static void
geary_imap_engine_generic_account_real_get_search_matches_async (GearyAccount* base,
                                                                 GearySearchQuery* query,
                                                                 GeeCollection* ids,
                                                                 GCancellable* cancellable,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountGetSearchMatchesAsyncData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GearySearchQuery* _tmp1_;
	GeeCollection* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (GEARY_IS_SEARCH_QUERY (query));
	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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountGetSearchMatchesAsyncData);
	_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_generic_account_real_get_search_matches_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (query);
	_g_object_unref0 (_data_->query);
	_data_->query = _tmp1_;
	_tmp2_ = _g_object_ref0 (ids);
	_g_object_unref0 (_data_->ids);
	_data_->ids = _tmp2_;
	_tmp3_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp3_;
	geary_imap_engine_generic_account_real_get_search_matches_async_co (_data_);
}

static GeeSet*
geary_imap_engine_generic_account_get_search_matches_finish (GearyAccount* base,
                                                             GAsyncResult* _res_,
                                                             GError** error)
{
	GeeSet* result;
	GearyImapEngineGenericAccountGetSearchMatchesAsyncData* _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_generic_account_get_search_matches_async_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_)
{
	GearyImapEngineGenericAccountGetSearchMatchesAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_get_search_matches_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_get_search_matches_async_co (GearyImapEngineGenericAccountGetSearchMatchesAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = geary_imap_engine_generic_account_check_ids (_data_->self, _data_->ids, &_data_->_inner_error0_);
	_data_->_tmp0_ = _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_->_tmp3_ = _data_->self->priv->_local;
	_data_->_state_ = 1;
	geary_imap_db_account_get_search_matches_async (_data_->_tmp3_, _data_->query, _data_->_tmp0_, _data_->cancellable, geary_imap_engine_generic_account_get_search_matches_async_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp4_ = geary_imap_db_account_get_search_matches_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp2_ = _data_->_tmp4_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->_tmp2_;
	_data_->_tmp2_ = NULL;
	_data_->result = _data_->_tmp5_;
	_g_object_unref0 (_data_->_tmp2_);
	_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_generic_account_real_get_containing_folders_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountGetContainingFoldersAsyncData* _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 (GearyImapEngineGenericAccountGetContainingFoldersAsyncData, _data_);
}

static void
geary_imap_engine_generic_account_real_get_containing_folders_async (GearyAccount* base,
                                                                     GeeCollection* ids,
                                                                     GCancellable* cancellable,
                                                                     GAsyncReadyCallback _callback_,
                                                                     gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountGetContainingFoldersAsyncData* _data_;
	GearyImapEngineGenericAccount* _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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountGetContainingFoldersAsyncData);
	_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_generic_account_real_get_containing_folders_async_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_generic_account_real_get_containing_folders_async_co (_data_);
}

static GeeMultiMap*
geary_imap_engine_generic_account_get_containing_folders_finish (GearyAccount* base,
                                                                 GAsyncResult* _res_,
                                                                 GError** error)
{
	GeeMultiMap* result;
	GearyImapEngineGenericAccountGetContainingFoldersAsyncData* _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_generic_account_get_containing_folders_async_ready (GObject* source_object,
                                                                      GAsyncResult* _res_,
                                                                      gpointer _user_data_)
{
	GearyImapEngineGenericAccountGetContainingFoldersAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_real_get_containing_folders_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_real_get_containing_folders_async_co (GearyImapEngineGenericAccountGetContainingFoldersAsyncData* _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_ = gee_hash_multi_map_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->map = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEE_TYPE_MULTI_MAP, GeeMultiMap);
	_data_->_tmp1_ = _data_->self->priv->_local;
	_data_->_tmp2_ = _data_->map;
	_data_->_state_ = 1;
	geary_imap_db_account_get_containing_folders_async (_data_->_tmp1_, _data_->ids, _data_->_tmp2_, _data_->cancellable, geary_imap_engine_generic_account_get_containing_folders_async_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_db_account_get_containing_folders_finish (_data_->_tmp1_, _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_->map);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->_tmp3_ = _data_->self->priv->local_folders;
		_data_->_tmp4_ = gee_map_get_values (_data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp8_ = _data_->_tmp7_;
		_g_object_unref0 (_data_->_tmp6_);
		_data_->_folder_it = _data_->_tmp8_;
		while (TRUE) {
			_data_->_tmp9_ = _data_->_folder_it;
			if (!gee_iterator_next (_data_->_tmp9_)) {
				break;
			}
			_data_->_tmp10_ = _data_->_folder_it;
			_data_->_tmp11_ = gee_iterator_get (_data_->_tmp10_);
			_data_->folder = (GearyFolder*) _data_->_tmp11_;
			_data_->_tmp12_ = _data_->folder;
			_data_->_tmp13_ = geary_folder_get_path (_data_->_tmp12_);
			_data_->_tmp14_ = _data_->_tmp13_;
			_data_->_tmp15_ = _g_object_ref0 (_data_->_tmp14_);
			_data_->path = _data_->_tmp15_;
			_data_->_tmp16_ = _data_->folder;
			_data_->_state_ = 2;
			geary_folder_contains_identifiers (_data_->_tmp16_, _data_->ids, _data_->cancellable, geary_imap_engine_generic_account_get_containing_folders_async_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp17_ = geary_folder_contains_identifiers_finish (_data_->_tmp16_, _data_->_res_, &_data_->_inner_error0_);
			_data_->matching = _data_->_tmp17_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->path);
				_g_object_unref0 (_data_->folder);
				_g_object_unref0 (_data_->_folder_it);
				_g_object_unref0 (_data_->map);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			{
				_data_->_tmp18_ = _data_->matching;
				_data_->_tmp19_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, GEE_TYPE_ITERABLE, GeeIterable));
				_data_->_id_it = _data_->_tmp19_;
				while (TRUE) {
					_data_->_tmp20_ = _data_->_id_it;
					if (!gee_iterator_next (_data_->_tmp20_)) {
						break;
					}
					_data_->_tmp21_ = _data_->_id_it;
					_data_->_tmp22_ = gee_iterator_get (_data_->_tmp21_);
					_data_->id = (GearyEmailIdentifier*) _data_->_tmp22_;
					_data_->_tmp23_ = _data_->map;
					_data_->_tmp24_ = _data_->id;
					_data_->_tmp25_ = _data_->path;
					gee_multi_map_set (_data_->_tmp23_, _data_->_tmp24_, _data_->_tmp25_);
					_g_object_unref0 (_data_->id);
				}
				_g_object_unref0 (_data_->_id_it);
			}
			_g_object_unref0 (_data_->matching);
			_g_object_unref0 (_data_->path);
			_g_object_unref0 (_data_->folder);
		}
		_g_object_unref0 (_data_->_folder_it);
	}
	_data_->_tmp27_ = _data_->map;
	_data_->_tmp28_ = gee_multi_map_get_size (_data_->_tmp27_);
	_data_->_tmp29_ = _data_->_tmp28_;
	if (_data_->_tmp29_ == 0) {
		_data_->_tmp26_ = NULL;
	} else {
		_data_->_tmp30_ = _data_->map;
		_data_->_tmp26_ = _data_->_tmp30_;
	}
	_data_->_tmp31_ = _g_object_ref0 (_data_->_tmp26_);
	_data_->result = _data_->_tmp31_;
	_g_object_unref0 (_data_->map);
	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_generic_account_real_cleanup_storage_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountCleanupStorageData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountCleanupStorageData, _data_);
}

static void
geary_imap_engine_generic_account_real_cleanup_storage (GearyAccount* base,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_)
{
	GearyImapEngineGenericAccount * self;
	GearyImapEngineGenericAccountCleanupStorageData* _data_;
	GearyImapEngineGenericAccount* _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_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountCleanupStorageData);
	_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_generic_account_real_cleanup_storage_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_generic_account_real_cleanup_storage_co (_data_);
}

static void
geary_imap_engine_generic_account_cleanup_storage_finish (GearyAccount* base,
                                                          GAsyncResult* _res_,
                                                          GError** error)
{
	GearyImapEngineGenericAccountCleanupStorageData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** {@inheritDoc} */
static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

static gboolean
geary_imap_engine_generic_account_real_cleanup_storage_co (GearyImapEngineGenericAccountCleanupStorageData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	geary_imap_engine_generic_account_check_open (_data_->self, &_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_account_get_information (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = geary_account_information_get_display_name (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Backgrounded storage cleanup check for %s account", _data_->_tmp3_);
	_data_->_tmp4_ = g_date_time_new_now_local ();
	_data_->now = _data_->_tmp4_;
	_data_->_tmp5_ = geary_account_get_last_storage_cleanup (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = _g_date_time_ref0 (_data_->_tmp6_);
	_data_->last_cleanup = _data_->_tmp7_;
	_data_->_tmp9_ = _data_->last_cleanup;
	if (_data_->_tmp9_ == NULL) {
		_data_->_tmp8_ = TRUE;
	} else {
		_data_->_tmp10_ = _data_->now;
		_data_->_tmp11_ = _data_->last_cleanup;
		_data_->_tmp8_ = (g_date_time_difference (_data_->_tmp10_, _data_->_tmp11_) / G_TIME_SPAN_MINUTE) > ((GTimeSpan) GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_APP_BACKGROUNDED_CLEANUP_WORK_INTERVAL_MINUTES);
	}
	if (_data_->_tmp8_) {
		_data_->_tmp12_ = _data_->now;
		geary_account_set_last_storage_cleanup (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->_tmp12_);
		_data_->_tmp13_ = _data_->self->priv->_sync;
		geary_imap_engine_account_synchronizer_cleanup_storage (_data_->_tmp13_);
	} else {
		_data_->_tmp14_ = _data_->self->priv->_local;
		_data_->_tmp15_ = geary_imap_db_account_get_db (_data_->_tmp14_);
		_data_->_tmp16_ = _data_->_tmp15_;
		_data_->_tmp17_ = geary_imap_db_database_get_want_background_vacuum (_data_->_tmp16_);
		_data_->_tmp18_ = _data_->_tmp17_;
		if (_data_->_tmp18_) {
			_data_->_tmp19_ = _data_->self->priv->_local;
			_data_->_tmp20_ = geary_imap_db_account_get_db (_data_->_tmp19_);
			_data_->_tmp21_ = _data_->_tmp20_;
			_data_->_tmp22_ = _data_->self->priv->_imap;
			_data_->_tmp23_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp22_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
			_data_->_tmp24_ = _data_->self->priv->_smtp;
			_data_->_tmp25_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp24_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
			_data_->_tmp26_ = g_new0 (GearyClientService*, 2 + 1);
			_data_->_tmp26_[0] = _data_->_tmp23_;
			_data_->_tmp26_[1] = _data_->_tmp25_;
			_data_->_tmp27_ = gee_array_list_new_wrap (GEARY_TYPE_CLIENT_SERVICE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp26_, 2, NULL, NULL, NULL);
			_data_->_tmp28_ = _data_->_tmp27_;
			geary_imap_db_database_run_gc (_data_->_tmp21_, GEARY_IMAP_DB_DATABASE_GARBAGE_COLLECTION_OPTIONS_ALLOW_VACUUM, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp28_, GEE_TYPE_COLLECTION, GeeCollection), _data_->cancellable, NULL, NULL);
			_g_object_unref0 (_data_->_tmp28_);
		}
	}
	_g_date_time_unref0 (_data_->last_cleanup);
	_g_date_time_unref0 (_data_->now);
	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;
}

/**
     * Constructs a set of folders and adds them to the account.
     *
     * This constructs a high-level folder representation for each
     * folder, adds them to this account object, fires the appropriate
     * signals, then returns them. Both the local and remote folder
     * equivalents need to exist beforehand — they are not created.
     *
     * If `are_existing` is true, the folders are assumed to have been
     * seen before and the {@link Geary.Account.folders_created} signal is
     * not fired.
     */
static gint
_geary_account_folder_path_comparator_gcompare_data_func (gconstpointer a,
                                                          gconstpointer b,
                                                          gpointer self)
{
	gint result;
	result = geary_account_folder_path_comparator ((GearyFolder*) a, (GearyFolder*) b);
	return result;
}

static void
_geary_account_notify_report_problem_geary_imap_engine_minimal_folder_report_problem (GearyImapEngineMinimalFolder* _sender,
                                                                                      GearyProblemReport* problem,
                                                                                      gpointer self)
{
	geary_account_notify_report_problem ((GearyAccount*) self, problem);
}

GeeCollection*
geary_imap_engine_generic_account_add_folders (GearyImapEngineGenericAccount* self,
                                               GeeCollection* db_folders,
                                               gboolean are_existing)
{
	GeeTreeSet* built_folders = NULL;
	GeeTreeSet* _tmp0_;
	GeeTreeSet* _tmp27_;
	gboolean _tmp28_;
	gboolean _tmp29_;
	GeeCollection* result;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (db_folders, GEE_TYPE_COLLECTION), NULL);
	_tmp0_ = gee_tree_set_new (GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _geary_account_folder_path_comparator_gcompare_data_func, NULL, NULL);
	built_folders = _tmp0_;
	{
		GeeIterator* _db_folder_it = NULL;
		GeeIterator* _tmp1_;
		_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (db_folders, GEE_TYPE_ITERABLE, GeeIterable));
		_db_folder_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			GearyImapDBFolder* db_folder = NULL;
			GeeIterator* _tmp3_;
			gpointer _tmp4_;
			GearyFolderPath* path = NULL;
			GearyImapDBFolder* _tmp5_;
			GearyFolderPath* _tmp6_;
			GearyFolderPath* _tmp7_;
			GeeMap* _tmp8_;
			GearyFolderPath* _tmp9_;
			_tmp2_ = _db_folder_it;
			if (!gee_iterator_next (_tmp2_)) {
				break;
			}
			_tmp3_ = _db_folder_it;
			_tmp4_ = gee_iterator_get (_tmp3_);
			db_folder = (GearyImapDBFolder*) _tmp4_;
			_tmp5_ = db_folder;
			_tmp6_ = geary_imap_db_folder_get_path (_tmp5_);
			_tmp7_ = _g_object_ref0 (_tmp6_);
			path = _tmp7_;
			_tmp8_ = self->priv->remote_folders;
			_tmp9_ = path;
			if (!gee_map_has_key (_tmp8_, _tmp9_)) {
				GearyImapEngineMinimalFolder* folder = NULL;
				GearyImapDBFolder* _tmp10_;
				GearyImapEngineMinimalFolder* _tmp11_;
				GearyImapEngineMinimalFolder* _tmp12_;
				GearyImapEngineMinimalFolder* _tmp13_;
				GearyFolderSpecialUse _tmp14_;
				GearyFolderSpecialUse _tmp15_;
				GeeTreeSet* _tmp20_;
				GearyImapEngineMinimalFolder* _tmp21_;
				GeeMap* _tmp22_;
				GearyImapEngineMinimalFolder* _tmp23_;
				GearyFolderPath* _tmp24_;
				GearyFolderPath* _tmp25_;
				GearyImapEngineMinimalFolder* _tmp26_;
				_tmp10_ = db_folder;
				_tmp11_ = geary_imap_engine_generic_account_new_folder (self, _tmp10_);
				folder = _tmp11_;
				_tmp12_ = folder;
				g_signal_connect_object (_tmp12_, "report-problem", (GCallback) _geary_account_notify_report_problem_geary_imap_engine_minimal_folder_report_problem, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), 0);
				_tmp13_ = folder;
				_tmp14_ = geary_folder_get_used_as (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEARY_TYPE_FOLDER, GearyFolder));
				_tmp15_ = _tmp14_;
				if (_tmp15_ == GEARY_FOLDER_SPECIAL_USE_NONE) {
					GearyFolderSpecialUse use = 0;
					GearyAccountInformation* _tmp16_;
					GearyAccountInformation* _tmp17_;
					GearyFolderPath* _tmp18_;
					_tmp16_ = geary_account_get_information (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
					_tmp17_ = _tmp16_;
					_tmp18_ = path;
					use = geary_account_information_get_folder_use_for_path (_tmp17_, _tmp18_);
					if (use != GEARY_FOLDER_SPECIAL_USE_NONE) {
						GearyImapEngineMinimalFolder* _tmp19_;
						_tmp19_ = folder;
						geary_imap_engine_minimal_folder_set_use (_tmp19_, use);
					}
				}
				_tmp20_ = built_folders;
				_tmp21_ = folder;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp21_);
				_tmp22_ = self->priv->remote_folders;
				_tmp23_ = folder;
				_tmp24_ = geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, GEARY_TYPE_FOLDER, GearyFolder));
				_tmp25_ = _tmp24_;
				_tmp26_ = folder;
				gee_map_set (_tmp22_, _tmp25_, _tmp26_);
				_g_object_unref0 (folder);
			}
			_g_object_unref0 (path);
			_g_object_unref0 (db_folder);
		}
		_g_object_unref0 (_db_folder_it);
	}
	_tmp27_ = built_folders;
	_tmp28_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp29_ = _tmp28_;
	if (!_tmp29_) {
		GeeTreeSet* _tmp30_;
		_tmp30_ = built_folders;
		geary_account_notify_folders_available_unavailable (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, GEE_TYPE_BIDIR_SORTED_SET, GeeBidirSortedSet), NULL);
		if (!are_existing) {
			GeeTreeSet* _tmp31_;
			_tmp31_ = built_folders;
			geary_account_notify_folders_created (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, GEE_TYPE_BIDIR_SORTED_SET, GeeBidirSortedSet));
		}
	}
	result = G_TYPE_CHECK_INSTANCE_CAST (built_folders, GEE_TYPE_COLLECTION, GeeCollection);
	return result;
}

/**
     * Notifies the engine a folder's contents have been altered.
     *
     * This is functionally equivalent to {@link update_folders}.
     */
void
geary_imap_engine_generic_account_update_folder (GearyImapEngineGenericAccount* self,
                                                 GearyFolder* folder)
{
	GeeCollection* folders = NULL;
	GeeLinkedList* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GearyImapEngineAccountSynchronizer* _tmp5_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	_tmp0_ = gee_linked_list_new (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	folders = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection);
	gee_collection_add (folders, folder);
	_tmp1_ = geary_folder_get_path (folder);
	_tmp2_ = _tmp1_;
	_tmp3_ = geary_folder_path_to_string (_tmp2_);
	_tmp4_ = _tmp3_;
	geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Folder updated: %s", _tmp4_);
	_g_free0 (_tmp4_);
	_tmp5_ = self->priv->_sync;
	geary_imap_engine_account_synchronizer_folders_contents_altered (_tmp5_, folders);
	_g_object_unref0 (folders);
}

/**
     * Notifies the engine multiple folders' contents have been altered.
     *
     * This is functionally equivalent to {@link update_folder}.
     */
void
geary_imap_engine_generic_account_update_folders (GearyImapEngineGenericAccount* self,
                                                  GeeCollection* folders)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (folders, GEE_TYPE_COLLECTION));
	_tmp0_ = gee_collection_get_is_empty (folders);
	_tmp1_ = _tmp0_;
	if (!_tmp1_) {
		GearyImapEngineAccountSynchronizer* _tmp2_;
		_tmp2_ = self->priv->_sync;
		geary_imap_engine_account_synchronizer_folders_contents_altered (_tmp2_, folders);
	}
}

/**
     * Marks a folder as a specific special folder type.
     */
void
geary_imap_engine_generic_account_promote_folders (GearyImapEngineGenericAccount* self,
                                                   GeeMap* specials)
{
	GeeHashSet* changed = NULL;
	GeeHashSet* _tmp0_;
	GeeHashSet* _tmp31_;
	gboolean _tmp32_;
	gboolean _tmp33_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (specials, GEE_TYPE_MAP));
	_tmp0_ = gee_hash_set_new (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	changed = _tmp0_;
	{
		GeeIterator* _special_it = NULL;
		GeeSet* _tmp1_;
		GeeSet* _tmp2_;
		GeeSet* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp1_ = gee_map_get_keys (specials);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_special_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			GearyFolderSpecialUse special = 0;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GearyImapEngineMinimalFolder* minimal = NULL;
			gpointer _tmp9_;
			GearyFolder* _tmp10_;
			GearyImapEngineMinimalFolder* _tmp11_;
			GearyImapEngineMinimalFolder* _tmp12_;
			GearyFolderSpecialUse _tmp13_;
			GearyFolderSpecialUse _tmp14_;
			_tmp6_ = _special_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _special_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			special = (GearyFolderSpecialUse) ((gintptr) _tmp8_);
			_tmp9_ = gee_map_get (specials, (gpointer) ((gintptr) special));
			_tmp10_ = (GearyFolder*) _tmp9_;
			_tmp11_ = GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (_tmp10_) ? ((GearyImapEngineMinimalFolder*) _tmp10_) : NULL;
			if (_tmp11_ == NULL) {
				_g_object_unref0 (_tmp10_);
			}
			minimal = _tmp11_;
			_tmp12_ = minimal;
			_tmp13_ = geary_folder_get_used_as (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEARY_TYPE_FOLDER, GearyFolder));
			_tmp14_ = _tmp13_;
			if (_tmp14_ != special) {
				GearyImapEngineMinimalFolder* _tmp15_;
				gchar* _tmp16_;
				gchar* _tmp17_;
				gchar* _tmp18_;
				GearyImapEngineMinimalFolder* _tmp19_;
				GeeHashSet* _tmp20_;
				GearyImapEngineMinimalFolder* _tmp21_;
				GearyImapEngineMinimalFolder* existing = NULL;
				GearyFolder* _tmp22_;
				GearyImapEngineMinimalFolder* _tmp23_;
				gboolean _tmp24_ = FALSE;
				GearyImapEngineMinimalFolder* _tmp25_;
				_tmp15_ = minimal;
				_tmp16_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_tmp17_ = _tmp16_;
				_tmp18_ = g_enum_to_string (GEARY_FOLDER_TYPE_SPECIAL_USE, special);
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Promoting %s to %s", _tmp17_, _tmp18_);
				_g_free0 (_tmp18_);
				_g_free0 (_tmp17_);
				_tmp19_ = minimal;
				geary_imap_engine_minimal_folder_set_use (_tmp19_, special);
				_tmp20_ = changed;
				_tmp21_ = minimal;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, GEARY_TYPE_FOLDER, GearyFolder));
				_tmp22_ = geary_account_get_special_folder (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), special);
				_tmp23_ = GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (_tmp22_) ? ((GearyImapEngineMinimalFolder*) _tmp22_) : NULL;
				if (_tmp23_ == NULL) {
					_g_object_unref0 (_tmp22_);
				}
				existing = _tmp23_;
				_tmp25_ = existing;
				if (_tmp25_ != NULL) {
					GearyImapEngineMinimalFolder* _tmp26_;
					GearyImapEngineMinimalFolder* _tmp27_;
					_tmp26_ = existing;
					_tmp27_ = minimal;
					_tmp24_ = _tmp26_ != _tmp27_;
				} else {
					_tmp24_ = FALSE;
				}
				if (_tmp24_) {
					GearyImapEngineMinimalFolder* _tmp28_;
					GeeHashSet* _tmp29_;
					GearyImapEngineMinimalFolder* _tmp30_;
					_tmp28_ = existing;
					geary_imap_engine_minimal_folder_set_use (_tmp28_, GEARY_FOLDER_SPECIAL_USE_NONE);
					_tmp29_ = changed;
					_tmp30_ = existing;
					gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), G_TYPE_CHECK_INSTANCE_CAST (_tmp30_, GEARY_TYPE_FOLDER, GearyFolder));
				}
				_g_object_unref0 (existing);
			}
			_g_object_unref0 (minimal);
		}
		_g_object_unref0 (_special_it);
	}
	_tmp31_ = changed;
	_tmp32_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp33_ = _tmp32_;
	if (!_tmp33_) {
		GeeHashSet* _tmp34_;
		_tmp34_ = changed;
		g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), "folders-use-changed", G_TYPE_CHECK_INSTANCE_CAST (_tmp34_, GEE_TYPE_COLLECTION, GeeCollection));
	}
	_g_object_unref0 (changed);
}

/**
     * Removes a set of folders from the account.
     *
     * This removes the high-level folder representations from this
     * account object, and fires the appropriate signals. Deletion of
     * both the local and remote folder equivalents must be handled
     * before, then after calling this method.
     *
     * A collection of folders that was actually removed is returned.
     */
GeeBidirSortedSet*
geary_imap_engine_generic_account_remove_folders (GearyImapEngineGenericAccount* self,
                                                  GeeCollection* folders)
{
	GeeTreeSet* removed = NULL;
	GeeTreeSet* _tmp0_;
	GeeTreeSet* _tmp17_;
	gboolean _tmp18_;
	gboolean _tmp19_;
	GeeBidirSortedSet* result;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (folders, GEE_TYPE_COLLECTION), NULL);
	_tmp0_ = gee_tree_set_new (GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _geary_account_folder_path_comparator_gcompare_data_func, NULL, NULL);
	removed = _tmp0_;
	{
		GeeIterator* _folder_it = NULL;
		GeeIterator* _tmp1_;
		_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (folders, GEE_TYPE_ITERABLE, GeeIterable));
		_folder_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			GearyFolder* folder = NULL;
			GeeIterator* _tmp3_;
			gpointer _tmp4_;
			GearyImapEngineMinimalFolder* impl = NULL;
			GeeMap* _tmp5_;
			GearyFolder* _tmp6_;
			GearyFolderPath* _tmp7_;
			GearyFolderPath* _tmp8_;
			gpointer _tmp9_;
			GearyImapEngineMinimalFolder* _tmp10_;
			_tmp2_ = _folder_it;
			if (!gee_iterator_next (_tmp2_)) {
				break;
			}
			_tmp3_ = _folder_it;
			_tmp4_ = gee_iterator_get (_tmp3_);
			folder = (GearyFolder*) _tmp4_;
			_tmp5_ = self->priv->remote_folders;
			_tmp6_ = folder;
			_tmp7_ = geary_folder_get_path (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = gee_map_get (_tmp5_, _tmp8_);
			impl = (GearyImapEngineMinimalFolder*) _tmp9_;
			_tmp10_ = impl;
			if (_tmp10_ != NULL) {
				GeeMap* _tmp11_;
				GearyFolder* _tmp12_;
				GearyFolderPath* _tmp13_;
				GearyFolderPath* _tmp14_;
				GeeTreeSet* _tmp15_;
				GearyImapEngineMinimalFolder* _tmp16_;
				_tmp11_ = self->priv->remote_folders;
				_tmp12_ = folder;
				_tmp13_ = geary_folder_get_path (_tmp12_);
				_tmp14_ = _tmp13_;
				gee_map_unset (_tmp11_, _tmp14_, NULL);
				_tmp15_ = removed;
				_tmp16_ = impl;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp16_);
			}
			_g_object_unref0 (impl);
			_g_object_unref0 (folder);
		}
		_g_object_unref0 (_folder_it);
	}
	_tmp17_ = removed;
	_tmp18_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, GEE_TYPE_COLLECTION, GeeCollection));
	_tmp19_ = _tmp18_;
	if (!_tmp19_) {
		GeeTreeSet* _tmp20_;
		GeeTreeSet* _tmp21_;
		_tmp20_ = removed;
		geary_account_notify_folders_available_unavailable (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), NULL, G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, GEE_TYPE_BIDIR_SORTED_SET, GeeBidirSortedSet));
		_tmp21_ = removed;
		geary_account_notify_folders_deleted (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, GEE_TYPE_BIDIR_SORTED_SET, GeeBidirSortedSet));
	}
	result = G_TYPE_CHECK_INSTANCE_CAST (removed, GEE_TYPE_BIDIR_SORTED_SET, GeeBidirSortedSet);
	return result;
}

static void
geary_imap_engine_generic_account_ensure_special_folder_async_data_free (gpointer _data)
{
	GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->remote);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData, _data_);
}

void
geary_imap_engine_generic_account_ensure_special_folder_async (GearyImapEngineGenericAccount* self,
                                                               GearyImapAccountSession* remote,
                                                               GearyFolderSpecialUse use,
                                                               GCancellable* cancellable,
                                                               GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_)
{
	GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData* _data_;
	GearyImapEngineGenericAccount* _tmp0_;
	GearyImapAccountSession* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (GEARY_IMAP_IS_ACCOUNT_SESSION (remote));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData);
	_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_generic_account_ensure_special_folder_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (remote);
	_g_object_unref0 (_data_->remote);
	_data_->remote = _tmp1_;
	_data_->use = use;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_generic_account_ensure_special_folder_async_co (_data_);
}

GearyFolder*
geary_imap_engine_generic_account_ensure_special_folder_finish (GearyImapEngineGenericAccount* self,
                                                                GAsyncResult* _res_,
                                                                GError** error)
{
	GearyFolder* result;
	GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

/**
     * Locates a special folder, creating it if needed.
     */
static void
geary_imap_engine_generic_account_ensure_special_folder_async_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_)
{
	GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_generic_account_ensure_special_folder_async_co (_data_);
}

static gboolean
geary_imap_engine_generic_account_ensure_special_folder_async_co (GearyImapEngineGenericAccountEnsureSpecialFolderAsyncData* _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_ = geary_account_get_special_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->use);
	_data_->special = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->special;
	if (_data_->_tmp1_ == NULL) {
		_data_->_tmp2_ = geary_account_get_information (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = _data_->self->priv->_local;
		_data_->_tmp5_ = geary_imap_db_account_get_imap_folder_root (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = geary_account_information_new_folder_path_for_use (_data_->_tmp3_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, GEARY_TYPE_FOLDER_ROOT, GearyFolderRoot), _data_->use);
		_data_->path = _data_->_tmp7_;
		_data_->_tmp9_ = _data_->path;
		if (_data_->_tmp9_ != NULL) {
			_data_->_tmp11_ = _data_->path;
			_data_->_tmp10_ = geary_imap_account_session_is_folder_path_valid (_data_->remote, _data_->_tmp11_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->path);
				_g_object_unref0 (_data_->special);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp8_ = !_data_->_tmp10_;
		} else {
			_data_->_tmp8_ = FALSE;
		}
		if (_data_->_tmp8_) {
			_data_->_tmp12_ = _data_->path;
			_data_->_tmp13_ = geary_folder_path_to_string (_data_->_tmp12_);
			_data_->_tmp14_ = _data_->_tmp13_;
			_data_->_tmp15_ = g_enum_to_string (GEARY_FOLDER_TYPE_SPECIAL_USE, _data_->use);
			geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Ignoring bad special folder path '%s' for type %s", _data_->_tmp14_, _data_->_tmp15_);
			_g_free0 (_data_->_tmp15_);
			_g_free0 (_data_->_tmp14_);
			_g_object_unref0 (_data_->path);
			_data_->path = NULL;
		}
		_data_->_tmp16_ = _data_->path;
		if (_data_->_tmp16_ == NULL) {
			_data_->_state_ = 1;
			geary_imap_account_session_get_default_personal_namespace (_data_->remote, _data_->cancellable, geary_imap_engine_generic_account_ensure_special_folder_async_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp17_ = geary_imap_account_session_get_default_personal_namespace_finish (_data_->remote, _data_->_res_, &_data_->_inner_error0_);
			_data_->root = _data_->_tmp17_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->path);
				_g_object_unref0 (_data_->special);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp18_ = _data_->self->priv->special_search_names;
			_data_->_tmp19_ = gee_map_get (_data_->_tmp18_, (gpointer) ((gintptr) _data_->use));
			_data_->search_names = (GeeList*) _data_->_tmp19_;
			{
				_data_->_tmp20_ = _data_->search_names;
				_data_->_search_name_list = _data_->_tmp20_;
				_data_->_tmp21_ = _data_->_search_name_list;
				_data_->_tmp22_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp21_, GEE_TYPE_COLLECTION, GeeCollection));
				_data_->_tmp23_ = _data_->_tmp22_;
				_data_->_search_name_size = _data_->_tmp23_;
				_data_->_search_name_index = -1;
				while (TRUE) {
					_data_->_search_name_index = _data_->_search_name_index + 1;
					_data_->_tmp24_ = _data_->_search_name_index;
					_data_->_tmp25_ = _data_->_search_name_size;
					if (!(_data_->_tmp24_ < _data_->_tmp25_)) {
						break;
					}
					_data_->_tmp26_ = _data_->_search_name_list;
					_data_->_tmp27_ = gee_list_get (_data_->_tmp26_, _data_->_search_name_index);
					_data_->search_name = (gchar*) _data_->_tmp27_;
					_data_->_tmp28_ = _data_->root;
					_data_->_tmp29_ = _data_->search_name;
					_data_->_tmp30_ = geary_folder_path_get_child (_data_->_tmp28_, _data_->_tmp29_, GEARY_TRILLIAN_UNKNOWN);
					_data_->search_path = _data_->_tmp30_;
					{
						_data_->_tmp31_ = _data_->self->priv->remote_folders;
						_data_->_tmp32_ = gee_map_get_keys (_data_->_tmp31_);
						_data_->_tmp33_ = _data_->_tmp32_;
						_data_->_tmp34_ = _data_->_tmp33_;
						_data_->_tmp35_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp34_, GEE_TYPE_ITERABLE, GeeIterable));
						_data_->_tmp36_ = _data_->_tmp35_;
						_g_object_unref0 (_data_->_tmp34_);
						_data_->_test_path_it = _data_->_tmp36_;
						while (TRUE) {
							_data_->_tmp37_ = _data_->_test_path_it;
							if (!gee_iterator_next (_data_->_tmp37_)) {
								break;
							}
							_data_->_tmp38_ = _data_->_test_path_it;
							_data_->_tmp39_ = gee_iterator_get (_data_->_tmp38_);
							_data_->test_path = (GearyFolderPath*) _data_->_tmp39_;
							_data_->_tmp40_ = _data_->test_path;
							_data_->_tmp41_ = _data_->search_path;
							if (geary_folder_path_compare_normalized_ci (_data_->_tmp40_, _data_->_tmp41_) == 0) {
								_data_->_tmp42_ = _data_->search_path;
								_data_->_tmp43_ = _g_object_ref0 (_data_->_tmp42_);
								_g_object_unref0 (_data_->path);
								_data_->path = _data_->_tmp43_;
								_g_object_unref0 (_data_->test_path);
								break;
							}
							_g_object_unref0 (_data_->test_path);
						}
						_g_object_unref0 (_data_->_test_path_it);
					}
					_data_->_tmp44_ = _data_->path;
					if (_data_->_tmp44_ != NULL) {
						_g_object_unref0 (_data_->search_path);
						_g_free0 (_data_->search_name);
						break;
					}
					_g_object_unref0 (_data_->search_path);
					_g_free0 (_data_->search_name);
				}
			}
			_data_->_tmp45_ = _data_->path;
			if (_data_->_tmp45_ == NULL) {
				_data_->_tmp46_ = _data_->root;
				_data_->_tmp47_ = _data_->search_names;
				_data_->_tmp48_ = gee_list_get (_data_->_tmp47_, 0);
				_data_->_tmp49_ = (gchar*) _data_->_tmp48_;
				_data_->_tmp50_ = geary_folder_path_get_child (_data_->_tmp46_, _data_->_tmp49_, GEARY_TRILLIAN_UNKNOWN);
				_g_object_unref0 (_data_->path);
				_data_->path = _data_->_tmp50_;
				_g_free0 (_data_->_tmp49_);
			}
			_data_->_tmp51_ = _data_->path;
			_data_->_tmp52_ = geary_folder_path_to_string (_data_->_tmp51_);
			_data_->_tmp53_ = _data_->_tmp52_;
			_data_->_tmp54_ = g_enum_to_string (GEARY_FOLDER_TYPE_SPECIAL_USE, _data_->use);
			geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Guessed folder \'%s\' for special_path %s", _data_->_tmp53_, _data_->_tmp54_);
			_g_free0 (_data_->_tmp54_);
			_g_free0 (_data_->_tmp53_);
			_data_->_tmp55_ = geary_account_get_information (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount));
			_data_->_tmp56_ = _data_->_tmp55_;
			_data_->_tmp57_ = _data_->path;
			_data_->_tmp58_ = 0;
			_data_->_tmp59_ = geary_folder_path_as_array (_data_->_tmp57_, &_data_->_tmp58_);
			_data_->_tmp60_ = gee_array_list_new_wrap (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp59_, _data_->_tmp58_, NULL, NULL, NULL);
			_data_->_tmp61_ = _data_->_tmp60_;
			geary_account_information_set_folder_steps_for_use (_data_->_tmp56_, _data_->use, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp61_, GEE_TYPE_LIST, GeeList));
			_g_object_unref0 (_data_->_tmp61_);
			_g_object_unref0 (_data_->search_names);
			_g_object_unref0 (_data_->root);
		}
		_data_->_tmp62_ = _data_->self->priv->remote_folders;
		_data_->_tmp63_ = _data_->path;
		if (gee_map_has_key (_data_->_tmp62_, _data_->_tmp63_)) {
			_data_->_tmp64_ = _data_->self->priv->remote_folders;
			_data_->_tmp65_ = _data_->path;
			_data_->_tmp66_ = gee_map_get (_data_->_tmp64_, _data_->_tmp65_);
			_g_object_unref0 (_data_->special);
			_data_->special = G_TYPE_CHECK_INSTANCE_CAST ((GearyImapEngineMinimalFolder*) _data_->_tmp66_, GEARY_TYPE_FOLDER, GearyFolder);
			_data_->_tmp67_ = _data_->special;
			_data_->_tmp68_ = geary_collection_single_map (GEARY_FOLDER_TYPE_SPECIAL_USE, NULL, NULL, GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, (gpointer) ((gintptr) _data_->use), _data_->_tmp67_);
			_data_->_tmp69_ = _data_->_tmp68_;
			geary_imap_engine_generic_account_promote_folders (_data_->self, _data_->_tmp69_);
			_g_object_unref0 (_data_->_tmp69_);
		} else {
			_data_->_tmp70_ = _data_->path;
			_data_->_tmp71_ = geary_folder_path_to_string (_data_->_tmp70_);
			_data_->_tmp72_ = _data_->_tmp71_;
			_data_->_tmp73_ = g_enum_to_string (GEARY_FOLDER_TYPE_SPECIAL_USE, _data_->use);
			geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Creating \"%s\" to use as special folder %s", _data_->_tmp72_, _data_->_tmp73_);
			_g_free0 (_data_->_tmp73_);
			_g_free0 (_data_->_tmp72_);
			_data_->_tmp75_ = _data_->path;
			_data_->_tmp76_ = geary_folder_path_get_name (_data_->_tmp75_);
			_data_->_tmp77_ = _data_->_tmp76_;
			_data_->_state_ = 2;
			geary_account_create_personal_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->_tmp77_, _data_->use, _data_->cancellable, geary_imap_engine_generic_account_ensure_special_folder_async_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp78_ = geary_account_create_personal_folder_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_TYPE_ACCOUNT, GearyAccount), _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp74_ = _data_->_tmp78_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->path);
				_g_object_unref0 (_data_->special);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp79_ = _data_->_tmp74_;
			_data_->_tmp74_ = NULL;
			_g_object_unref0 (_data_->special);
			_data_->special = _data_->_tmp79_;
			_g_object_unref0 (_data_->_tmp74_);
		}
		_g_object_unref0 (_data_->path);
	}
	_data_->result = _data_->special;
	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;
}

/**
     * Constructs a concrete folder implementation.
     *
     * Subclasses should implement this to return their flavor of a
     * MinimalFolder with the appropriate interfaces attached.  The
     * returned folder should have its SpecialFolderType set using
     * either the properties from the local folder or its path.
     *
     * This won't be called to build the Outbox or search folder, but
     * for all others (including Inbox) it will.
     */
static GearyImapEngineMinimalFolder*
geary_imap_engine_generic_account_real_new_folder (GearyImapEngineGenericAccount* self,
                                                   GearyImapDBFolder* local_folder)
{
	g_critical ("Type `%s' does not implement abstract method `geary_imap_engine_generic_account_new_folder'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

GearyImapEngineMinimalFolder*
geary_imap_engine_generic_account_new_folder (GearyImapEngineGenericAccount* self,
                                              GearyImapDBFolder* local_folder)
{
	GearyImapEngineGenericAccountClass* _klass_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	_klass_ = GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_GET_CLASS (self);
	if (_klass_->new_folder) {
		return _klass_->new_folder (self, local_folder);
	}
	return NULL;
}

/** {@inheritDoc} */
static void
_geary_account_notify_email_appended_geary_folder_email_appended (GearyFolder* _sender,
                                                                  GeeCollection* ids,
                                                                  gpointer self)
{
	geary_account_notify_email_appended ((GearyAccount*) self, _sender, ids);
}

static void
_geary_account_notify_email_inserted_geary_folder_email_inserted (GearyFolder* _sender,
                                                                  GeeCollection* ids,
                                                                  gpointer self)
{
	geary_account_notify_email_inserted ((GearyAccount*) self, _sender, ids);
}

static void
_geary_account_notify_email_removed_geary_folder_email_removed (GearyFolder* _sender,
                                                                GeeCollection* ids,
                                                                gpointer self)
{
	geary_account_notify_email_removed ((GearyAccount*) self, _sender, ids);
}

static void
_geary_account_notify_email_locally_removed_geary_folder_email_locally_removed (GearyFolder* _sender,
                                                                                GeeCollection* ids,
                                                                                gpointer self)
{
	geary_account_notify_email_locally_removed ((GearyAccount*) self, _sender, ids);
}

static void
_geary_account_notify_email_locally_complete_geary_folder_email_locally_complete (GearyFolder* _sender,
                                                                                  GeeCollection* ids,
                                                                                  gpointer self)
{
	geary_account_notify_email_locally_complete ((GearyAccount*) self, _sender, ids);
}

static void
_geary_account_notify_email_flags_changed_geary_folder_email_flags_changed (GearyFolder* _sender,
                                                                            GeeMap* map,
                                                                            gpointer self)
{
	geary_account_notify_email_flags_changed ((GearyAccount*) self, _sender, map);
}

static void
geary_imap_engine_generic_account_real_notify_folders_available_unavailable (GearyAccount* base,
                                                                             GeeBidirSortedSet* available,
                                                                             GeeBidirSortedSet* unavailable)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_if_fail ((available == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (available, GEE_TYPE_BIDIR_SORTED_SET));
	g_return_if_fail ((unavailable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (unavailable, GEE_TYPE_BIDIR_SORTED_SET));
	GEARY_ACCOUNT_CLASS (geary_imap_engine_generic_account_parent_class)->notify_folders_available_unavailable (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), available, unavailable);
	if (available != NULL) {
		{
			GeeIterator* _folder_it = NULL;
			GeeIterator* _tmp0_;
			_tmp0_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (available, GEE_TYPE_ITERABLE, GeeIterable));
			_folder_it = _tmp0_;
			while (TRUE) {
				GeeIterator* _tmp1_;
				GearyFolder* folder = NULL;
				GeeIterator* _tmp2_;
				gpointer _tmp3_;
				GearyFolder* _tmp4_;
				GearyFolder* _tmp5_;
				GearyFolder* _tmp6_;
				GearyFolder* _tmp7_;
				GearyFolder* _tmp8_;
				GearyFolder* _tmp9_;
				_tmp1_ = _folder_it;
				if (!gee_iterator_next (_tmp1_)) {
					break;
				}
				_tmp2_ = _folder_it;
				_tmp3_ = gee_iterator_get (_tmp2_);
				folder = (GearyFolder*) _tmp3_;
				_tmp4_ = folder;
				g_signal_connect_object (_tmp4_, "email-appended", (GCallback) _geary_account_notify_email_appended_geary_folder_email_appended, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), 0);
				_tmp5_ = folder;
				g_signal_connect_object (_tmp5_, "email-inserted", (GCallback) _geary_account_notify_email_inserted_geary_folder_email_inserted, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), 0);
				_tmp6_ = folder;
				g_signal_connect_object (_tmp6_, "email-removed", (GCallback) _geary_account_notify_email_removed_geary_folder_email_removed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), 0);
				_tmp7_ = folder;
				g_signal_connect_object (_tmp7_, "email-locally-removed", (GCallback) _geary_account_notify_email_locally_removed_geary_folder_email_locally_removed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), 0);
				_tmp8_ = folder;
				g_signal_connect_object (_tmp8_, "email-locally-complete", (GCallback) _geary_account_notify_email_locally_complete_geary_folder_email_locally_complete, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), 0);
				_tmp9_ = folder;
				g_signal_connect_object (_tmp9_, "email-flags-changed", (GCallback) _geary_account_notify_email_flags_changed_geary_folder_email_flags_changed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), 0);
				_g_object_unref0 (folder);
			}
			_g_object_unref0 (_folder_it);
		}
	}
	if (unavailable != NULL) {
		{
			GeeIterator* _folder_it = NULL;
			GeeIterator* _tmp10_;
			_tmp10_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (unavailable, GEE_TYPE_ITERABLE, GeeIterable));
			_folder_it = _tmp10_;
			while (TRUE) {
				GeeIterator* _tmp11_;
				GearyFolder* folder = NULL;
				GeeIterator* _tmp12_;
				gpointer _tmp13_;
				GearyFolder* _tmp14_;
				guint _tmp15_;
				GearyFolder* _tmp16_;
				guint _tmp17_;
				GearyFolder* _tmp18_;
				guint _tmp19_;
				GearyFolder* _tmp20_;
				guint _tmp21_;
				GearyFolder* _tmp22_;
				guint _tmp23_;
				GearyFolder* _tmp24_;
				guint _tmp25_;
				_tmp11_ = _folder_it;
				if (!gee_iterator_next (_tmp11_)) {
					break;
				}
				_tmp12_ = _folder_it;
				_tmp13_ = gee_iterator_get (_tmp12_);
				folder = (GearyFolder*) _tmp13_;
				_tmp14_ = folder;
				g_signal_parse_name ("email-appended", GEARY_TYPE_FOLDER, &_tmp15_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp14_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp15_, 0, NULL, (GCallback) _geary_account_notify_email_appended_geary_folder_email_appended, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
				_tmp16_ = folder;
				g_signal_parse_name ("email-inserted", GEARY_TYPE_FOLDER, &_tmp17_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp16_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp17_, 0, NULL, (GCallback) _geary_account_notify_email_inserted_geary_folder_email_inserted, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
				_tmp18_ = folder;
				g_signal_parse_name ("email-removed", GEARY_TYPE_FOLDER, &_tmp19_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp18_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp19_, 0, NULL, (GCallback) _geary_account_notify_email_removed_geary_folder_email_removed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
				_tmp20_ = folder;
				g_signal_parse_name ("email-locally-removed", GEARY_TYPE_FOLDER, &_tmp21_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp20_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp21_, 0, NULL, (GCallback) _geary_account_notify_email_locally_removed_geary_folder_email_locally_removed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
				_tmp22_ = folder;
				g_signal_parse_name ("email-locally-complete", GEARY_TYPE_FOLDER, &_tmp23_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp22_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp23_, 0, NULL, (GCallback) _geary_account_notify_email_locally_complete_geary_folder_email_locally_complete, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
				_tmp24_ = folder;
				g_signal_parse_name ("email-flags-changed", GEARY_TYPE_FOLDER, &_tmp25_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp24_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp25_, 0, NULL, (GCallback) _geary_account_notify_email_flags_changed_geary_folder_email_flags_changed, G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
				_g_object_unref0 (folder);
			}
			_g_object_unref0 (_folder_it);
		}
	}
}

/** {@inheritDoc} */
static void
geary_imap_engine_generic_account_real_notify_email_appended (GearyAccount* base,
                                                              GearyFolder* folder,
                                                              GeeCollection* ids)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	GEARY_ACCOUNT_CLASS (geary_imap_engine_generic_account_parent_class)->notify_email_appended (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), folder, ids);
	geary_imap_engine_generic_account_schedule_unseen_update (self, folder);
}

/** {@inheritDoc} */
static void
geary_imap_engine_generic_account_real_notify_email_inserted (GearyAccount* base,
                                                              GearyFolder* folder,
                                                              GeeCollection* ids)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	GEARY_ACCOUNT_CLASS (geary_imap_engine_generic_account_parent_class)->notify_email_inserted (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), folder, ids);
	geary_imap_engine_generic_account_schedule_unseen_update (self, folder);
}

/** {@inheritDoc} */
static void
geary_imap_engine_generic_account_real_notify_email_removed (GearyAccount* base,
                                                             GearyFolder* folder,
                                                             GeeCollection* ids)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	GEARY_ACCOUNT_CLASS (geary_imap_engine_generic_account_parent_class)->notify_email_removed (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), folder, ids);
	geary_imap_engine_generic_account_schedule_unseen_update (self, folder);
}

/** {@inheritDoc} */
static void
geary_imap_engine_generic_account_real_notify_email_locally_removed (GearyAccount* base,
                                                                     GearyFolder* folder,
                                                                     GeeCollection* ids)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ids, GEE_TYPE_COLLECTION));
	GEARY_ACCOUNT_CLASS (geary_imap_engine_generic_account_parent_class)->notify_email_locally_removed (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), folder, ids);
}

/** {@inheritDoc} */
static void
geary_imap_engine_generic_account_real_notify_email_flags_changed (GearyAccount* base,
                                                                   GearyFolder* folder,
                                                                   GeeMap* flag_map)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (flag_map, GEE_TYPE_MAP));
	GEARY_ACCOUNT_CLASS (geary_imap_engine_generic_account_parent_class)->notify_email_flags_changed (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), folder, flag_map);
	geary_imap_engine_generic_account_schedule_unseen_update (self, folder);
}

/**
     * Hooks up and queues an {@link UpdateRemoteFolders} operation.
     */
static void
__lambda143_ (GearyImapEngineGenericAccount* self)
{
	GearyTimeoutManager* _tmp0_;
	_tmp0_ = self->priv->refresh_folder_timer;
	geary_timeout_manager_start (_tmp0_);
}

static void
___lambda143__geary_imap_engine_account_operation_completed (GearyImapEngineAccountOperation* _sender,
                                                             gpointer self)
{
	__lambda143_ ((GearyImapEngineGenericAccount*) self);
}

static void
geary_imap_engine_generic_account_update_remote_folders (GearyImapEngineGenericAccount* self,
                                                         gboolean already_connected)
{
	GearyTimeoutManager* _tmp0_;
	GearyImapEngineUpdateRemoteFolders* op = NULL;
	gint _tmp1_ = 0;
	GearyFolderSpecialUse* _tmp2_;
	GearyFolderSpecialUse* _tmp3_;
	gint _tmp3__length1;
	GearyImapEngineUpdateRemoteFolders* _tmp4_;
	GearyImapEngineUpdateRemoteFolders* _tmp5_;
	GearyImapEngineUpdateRemoteFolders* _tmp6_;
	GearyImapClientService* _tmp7_;
	GearyClientServiceStatus _tmp8_;
	GearyClientServiceStatus _tmp9_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	_tmp0_ = self->priv->refresh_folder_timer;
	geary_timeout_manager_reset (_tmp0_);
	_tmp2_ = geary_imap_engine_generic_account_get_supported_special_folders (self, &_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp3__length1 = _tmp1_;
	_tmp4_ = geary_imap_engine_update_remote_folders_new (self, already_connected, _tmp3_, _tmp1_);
	_tmp5_ = _tmp4_;
	_tmp3_ = (g_free (_tmp3_), NULL);
	op = _tmp5_;
	_tmp6_ = op;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation), "completed", (GCallback) ___lambda143__geary_imap_engine_account_operation_completed, self, 0);
	_tmp7_ = self->priv->_imap;
	_tmp8_ = geary_client_service_get_current_status (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
	_tmp9_ = _tmp8_;
	if (_tmp9_ == GEARY_CLIENT_SERVICE_STATUS_CONNECTED) {
		{
			GearyImapEngineUpdateRemoteFolders* _tmp10_;
			_tmp10_ = op;
			geary_imap_engine_generic_account_queue_operation (self, G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation), &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* err = NULL;
			GearyImapEngineUpdateRemoteFolders* _tmp11_;
			gchar* _tmp12_;
			gchar* _tmp13_;
			GError* _tmp14_;
			const gchar* _tmp15_;
			err = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp11_ = op;
			_tmp12_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
			_tmp13_ = _tmp12_;
			_tmp14_ = err;
			_tmp15_ = _tmp14_->message;
			geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Failed to update queue for  %s %s", _tmp13_, _tmp15_);
			_g_free0 (_tmp13_);
			_g_error_free0 (err);
		}
		__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;
		}
	} else {
		GearyImapEngineAccountProcessor* _tmp16_;
		GearyImapEngineUpdateRemoteFolders* _tmp17_;
		_tmp16_ = self->priv->processor;
		_tmp17_ = op;
		geary_imap_engine_account_processor_dequeue (_tmp16_, G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	}
	_g_object_unref0 (op);
}

/**
     * Hooks up and queues an {@link RefreshFolderUnseen} operation.
     */
static void
geary_imap_engine_generic_account_schedule_unseen_update (GearyImapEngineGenericAccount* self,
                                                          GearyFolder* folder)
{
	GearyImapEngineMinimalFolder* impl = NULL;
	GearyImapEngineMinimalFolder* _tmp0_;
	GearyImapEngineMinimalFolder* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (GEARY_IS_FOLDER (folder));
	_tmp0_ = _g_object_ref0 (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (folder) ? ((GearyImapEngineMinimalFolder*) folder) : NULL);
	impl = _tmp0_;
	_tmp1_ = impl;
	if (_tmp1_ != NULL) {
		GearyImapEngineMinimalFolder* _tmp2_;
		_tmp2_ = impl;
		geary_imap_engine_minimal_folder_refresh_unseen (_tmp2_);
	}
	_g_object_unref0 (impl);
}

static GearyFolderSpecialUse*
_vala_array_dup5 (GearyFolderSpecialUse* self,
                  gssize length)
{
	if (length > 0) {
		return g_memdup2 (self, length * sizeof (GearyFolderSpecialUse));
	}
	return NULL;
}

static GearyFolderSpecialUse*
geary_imap_engine_generic_account_real_get_supported_special_folders (GearyImapEngineGenericAccount* self,
                                                                      gint* result_length1)
{
	GearyFolderSpecialUse* _tmp0_;
	gint _tmp0__length1;
	GearyFolderSpecialUse* _tmp1_;
	gint _tmp1__length1;
	GearyFolderSpecialUse* result;
	_tmp0_ = _vala_array_dup5 (GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SUPPORTED_SPECIAL_FOLDERS, G_N_ELEMENTS (GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SUPPORTED_SPECIAL_FOLDERS));
	_tmp0__length1 = G_N_ELEMENTS (GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SUPPORTED_SPECIAL_FOLDERS);
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

GearyFolderSpecialUse*
geary_imap_engine_generic_account_get_supported_special_folders (GearyImapEngineGenericAccount* self,
                                                                 gint* result_length1)
{
	GearyImapEngineGenericAccountClass* _klass_;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	_klass_ = GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_GET_CLASS (self);
	if (_klass_->get_supported_special_folders) {
		return _klass_->get_supported_special_folders (self, result_length1);
	}
	return NULL;
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

static void
geary_imap_engine_generic_account_compile_special_search_names (GearyImapEngineGenericAccount* self)
{
	gint _tmp0_ = 0;
	GearyFolderSpecialUse* _tmp1_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	_tmp1_ = geary_imap_engine_generic_account_get_supported_special_folders (self, &_tmp0_);
	{
		GearyFolderSpecialUse* type_collection = NULL;
		gint type_collection_length1 = 0;
		gint _type_collection_size_ = 0;
		gint type_it = 0;
		type_collection = _tmp1_;
		type_collection_length1 = _tmp0_;
		for (type_it = 0; type_it < type_collection_length1; type_it = type_it + 1) {
			GearyFolderSpecialUse type = 0;
			type = type_collection[type_it];
			{
				GeeList* compiled = NULL;
				GeeArrayList* _tmp2_;
				GeeMap* _tmp30_;
				GeeList* _tmp31_;
				_tmp2_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
				compiled = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_LIST, GeeList);
				{
					GeeList* _names_list = NULL;
					GeeList* _tmp3_;
					gint _names_size = 0;
					GeeList* _tmp4_;
					gint _tmp5_;
					gint _tmp6_;
					gint _names_index = 0;
					_tmp3_ = geary_imap_engine_generic_account_get_special_search_names (self, type);
					_names_list = _tmp3_;
					_tmp4_ = _names_list;
					_tmp5_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_COLLECTION, GeeCollection));
					_tmp6_ = _tmp5_;
					_names_size = _tmp6_;
					_names_index = -1;
					while (TRUE) {
						gint _tmp7_;
						gint _tmp8_;
						gchar* names = NULL;
						GeeList* _tmp9_;
						gpointer _tmp10_;
						const gchar* _tmp11_;
						gchar** _tmp12_;
						gchar** _tmp13_;
						_names_index = _names_index + 1;
						_tmp7_ = _names_index;
						_tmp8_ = _names_size;
						if (!(_tmp7_ < _tmp8_)) {
							break;
						}
						_tmp9_ = _names_list;
						_tmp10_ = gee_list_get (_tmp9_, _names_index);
						names = (gchar*) _tmp10_;
						_tmp11_ = names;
						_tmp13_ = _tmp12_ = g_strsplit (_tmp11_, "|", 0);
						{
							gchar** name_collection = NULL;
							gint name_collection_length1 = 0;
							gint _name_collection_size_ = 0;
							gint name_it = 0;
							name_collection = _tmp13_;
							name_collection_length1 = _vala_array_length (_tmp12_);
							for (name_it = 0; name_it < name_collection_length1; name_it = name_it + 1) {
								gchar* _tmp14_;
								gchar* name = NULL;
								_tmp14_ = g_strdup (name_collection[name_it]);
								name = _tmp14_;
								{
									const gchar* _tmp15_;
									gchar* _tmp16_;
									const gchar* _tmp17_;
									gint _tmp18_;
									gint _tmp19_;
									_tmp15_ = name;
									_tmp16_ = string_strip (_tmp15_);
									_g_free0 (name);
									name = _tmp16_;
									_tmp17_ = name;
									_tmp18_ = strlen (_tmp17_);
									_tmp19_ = _tmp18_;
									if (_tmp19_ != 0) {
										GeeList* _tmp20_;
										const gchar* _tmp21_;
										const gchar* _tmp24_;
										gchar* _tmp25_;
										GeeList* _tmp26_;
										const gchar* _tmp27_;
										_tmp20_ = compiled;
										_tmp21_ = name;
										if (!gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, GEE_TYPE_COLLECTION, GeeCollection), _tmp21_)) {
											GeeList* _tmp22_;
											const gchar* _tmp23_;
											_tmp22_ = compiled;
											_tmp23_ = name;
											gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp22_, GEE_TYPE_COLLECTION, GeeCollection), _tmp23_);
										}
										_tmp24_ = name;
										_tmp25_ = g_utf8_strdown (_tmp24_, (gssize) -1);
										_g_free0 (name);
										name = _tmp25_;
										_tmp26_ = compiled;
										_tmp27_ = name;
										if (!gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp26_, GEE_TYPE_COLLECTION, GeeCollection), _tmp27_)) {
											GeeList* _tmp28_;
											const gchar* _tmp29_;
											_tmp28_ = compiled;
											_tmp29_ = name;
											gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp28_, GEE_TYPE_COLLECTION, GeeCollection), _tmp29_);
										}
									}
									_g_free0 (name);
								}
							}
							name_collection = (_vala_array_free (name_collection, name_collection_length1, (GDestroyNotify) g_free), NULL);
						}
						_g_free0 (names);
					}
					_g_object_unref0 (_names_list);
				}
				_tmp30_ = self->priv->special_search_names;
				_tmp31_ = compiled;
				gee_map_set (_tmp30_, (gpointer) ((gintptr) type), _tmp31_);
				_g_object_unref0 (compiled);
			}
		}
		type_collection = (g_free (type_collection), NULL);
	}
}

static GeeList*
geary_imap_engine_generic_account_get_special_search_names (GearyImapEngineGenericAccount* self,
                                                            GearyFolderSpecialUse type)
{
	GeeList* loc_names = NULL;
	GeeArrayList* _tmp0_;
	GeeList* unloc_names = NULL;
	GeeArrayList* _tmp1_;
	GeeList* _tmp16_;
	GeeList* _tmp17_;
	GeeList* result;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	loc_names = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_LIST, GeeList);
	_tmp1_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	unloc_names = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_LIST, GeeList);
	switch (type) {
		case GEARY_FOLDER_SPECIAL_USE_DRAFTS:
		{
			GeeList* _tmp2_;
			GeeList* _tmp3_;
			_tmp2_ = loc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_COLLECTION, GeeCollection), _ ("Drafts | Draft"));
			_tmp3_ = unloc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_COLLECTION, GeeCollection), "Drafts | Draft");
			break;
		}
		case GEARY_FOLDER_SPECIAL_USE_SENT:
		{
			GeeList* _tmp4_;
			GeeList* _tmp5_;
			GeeList* _tmp6_;
			GeeList* _tmp7_;
			_tmp4_ = loc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEE_TYPE_COLLECTION, GeeCollection), _ ("Sent | Sent Mail | Sent Email | Sent E-Mail"));
			_tmp5_ = unloc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEE_TYPE_COLLECTION, GeeCollection), "Sent | Sent Mail | Sent Email | Sent E-Mail");
			_tmp6_ = loc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_COLLECTION, GeeCollection), NC_ ("Outlook localised name", "Sent Items"));
			_tmp7_ = unloc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_COLLECTION, GeeCollection), "Sent Items");
			break;
		}
		case GEARY_FOLDER_SPECIAL_USE_JUNK:
		{
			GeeList* _tmp8_;
			GeeList* _tmp9_;
			_tmp8_ = loc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEE_TYPE_COLLECTION, GeeCollection), _ ("Junk | Spam | Junk Mail | Junk Email | Junk E-Mail | Bulk Mail | Bulk " \
"Email | Bulk E-Mail"));
			_tmp9_ = unloc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, GEE_TYPE_COLLECTION, GeeCollection), "Junk | Spam | Junk Mail | Junk Email | Junk E-Mail | Bulk Mail | Bulk " \
"Email | Bulk E-Mail");
			break;
		}
		case GEARY_FOLDER_SPECIAL_USE_TRASH:
		{
			GeeList* _tmp10_;
			GeeList* _tmp11_;
			GeeList* _tmp12_;
			GeeList* _tmp13_;
			_tmp10_ = loc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEE_TYPE_COLLECTION, GeeCollection), _ ("Trash | Rubbish | Rubbish Bin"));
			_tmp11_ = unloc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEE_TYPE_COLLECTION, GeeCollection), "Trash | Rubbish | Rubbish Bin");
			_tmp12_ = loc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, GEE_TYPE_COLLECTION, GeeCollection), NC_ ("Outlook localised name", "Deleted Items"));
			_tmp13_ = unloc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEE_TYPE_COLLECTION, GeeCollection), "Deleted Items");
			break;
		}
		case GEARY_FOLDER_SPECIAL_USE_ARCHIVE:
		{
			GeeList* _tmp14_;
			GeeList* _tmp15_;
			_tmp14_ = loc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, GEE_TYPE_COLLECTION, GeeCollection), _ ("Archive | Archives"));
			_tmp15_ = unloc_names;
			gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, GEE_TYPE_COLLECTION, GeeCollection), "Archive | Archives");
			break;
		}
		default:
		{
			break;
		}
	}
	_tmp16_ = loc_names;
	_tmp17_ = unloc_names;
	gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp16_, GEE_TYPE_COLLECTION, GeeCollection), G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, GEE_TYPE_COLLECTION, GeeCollection));
	result = loc_names;
	_g_object_unref0 (unloc_names);
	return result;
}

static void
geary_imap_engine_generic_account_check_open (GearyImapEngineGenericAccount* self,
                                              GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	if (!self->priv->open) {
		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, "Account %s not opened", _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 gchar*
geary_imap_engine_generic_account_find_appropriate_search_stemmer (GearyImapEngineGenericAccount* self)
{
	gchar** _tmp0_;
	gchar** _tmp1_;
	gchar* _tmp33_;
	gchar* result;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self), NULL);
	_tmp1_ = _tmp0_ = g_get_language_names ();
	{
		gchar** l_collection = NULL;
		gint l_collection_length1 = 0;
		gint _l_collection_size_ = 0;
		gint l_it = 0;
		l_collection = _tmp1_;
		l_collection_length1 = _vala_array_length (_tmp0_);
		for (l_it = 0; l_it < l_collection_length1; l_it = l_it + 1) {
			gchar* _tmp2_;
			gchar* l = NULL;
			_tmp2_ = g_strdup (l_collection[l_it]);
			l = _tmp2_;
			{
				const gchar* _tmp3_;
				const gchar* _tmp4_;
				GQuark _tmp6_ = 0U;
				static GQuark _tmp5_label0 = 0;
				static GQuark _tmp5_label1 = 0;
				static GQuark _tmp5_label2 = 0;
				static GQuark _tmp5_label3 = 0;
				static GQuark _tmp5_label4 = 0;
				static GQuark _tmp5_label5 = 0;
				static GQuark _tmp5_label6 = 0;
				static GQuark _tmp5_label7 = 0;
				static GQuark _tmp5_label8 = 0;
				static GQuark _tmp5_label9 = 0;
				static GQuark _tmp5_label10 = 0;
				static GQuark _tmp5_label11 = 0;
				static GQuark _tmp5_label12 = 0;
				static GQuark _tmp5_label13 = 0;
				static GQuark _tmp5_label14 = 0;
				static GQuark _tmp5_label15 = 0;
				static GQuark _tmp5_label16 = 0;
				static GQuark _tmp5_label17 = 0;
				static GQuark _tmp5_label18 = 0;
				static GQuark _tmp5_label19 = 0;
				static GQuark _tmp5_label20 = 0;
				static GQuark _tmp5_label21 = 0;
				static GQuark _tmp5_label22 = 0;
				static GQuark _tmp5_label23 = 0;
				static GQuark _tmp5_label24 = 0;
				static GQuark _tmp5_label25 = 0;
				_tmp3_ = l;
				_tmp4_ = _tmp3_;
				_tmp6_ = (NULL == _tmp4_) ? 0 : g_quark_from_string (_tmp4_);
				if (_tmp6_ == ((0 != _tmp5_label0) ? _tmp5_label0 : (_tmp5_label0 = g_quark_from_static_string ("ar")))) {
					switch (0) {
						default:
						{
							gchar* _tmp7_;
							_tmp7_ = g_strdup ("arabic");
							result = _tmp7_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label1) ? _tmp5_label1 : (_tmp5_label1 = g_quark_from_static_string ("eu")))) {
					switch (0) {
						default:
						{
							gchar* _tmp8_;
							_tmp8_ = g_strdup ("basque");
							result = _tmp8_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label2) ? _tmp5_label2 : (_tmp5_label2 = g_quark_from_static_string ("ca")))) {
					switch (0) {
						default:
						{
							gchar* _tmp9_;
							_tmp9_ = g_strdup ("catalan");
							result = _tmp9_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label3) ? _tmp5_label3 : (_tmp5_label3 = g_quark_from_static_string ("da")))) {
					switch (0) {
						default:
						{
							gchar* _tmp10_;
							_tmp10_ = g_strdup ("danish");
							result = _tmp10_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label4) ? _tmp5_label4 : (_tmp5_label4 = g_quark_from_static_string ("nl")))) {
					switch (0) {
						default:
						{
							gchar* _tmp11_;
							_tmp11_ = g_strdup ("dutch");
							result = _tmp11_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label5) ? _tmp5_label5 : (_tmp5_label5 = g_quark_from_static_string ("en")))) {
					switch (0) {
						default:
						{
							gchar* _tmp12_;
							_tmp12_ = g_strdup ("english");
							result = _tmp12_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label6) ? _tmp5_label6 : (_tmp5_label6 = g_quark_from_static_string ("fi")))) {
					switch (0) {
						default:
						{
							gchar* _tmp13_;
							_tmp13_ = g_strdup ("finnish");
							result = _tmp13_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label7) ? _tmp5_label7 : (_tmp5_label7 = g_quark_from_static_string ("fr")))) {
					switch (0) {
						default:
						{
							gchar* _tmp14_;
							_tmp14_ = g_strdup ("french");
							result = _tmp14_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label8) ? _tmp5_label8 : (_tmp5_label8 = g_quark_from_static_string ("de")))) {
					switch (0) {
						default:
						{
							gchar* _tmp15_;
							_tmp15_ = g_strdup ("german");
							result = _tmp15_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label9) ? _tmp5_label9 : (_tmp5_label9 = g_quark_from_static_string ("el")))) {
					switch (0) {
						default:
						{
							gchar* _tmp16_;
							_tmp16_ = g_strdup ("greek");
							result = _tmp16_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label10) ? _tmp5_label10 : (_tmp5_label10 = g_quark_from_static_string ("hi")))) {
					switch (0) {
						default:
						{
							gchar* _tmp17_;
							_tmp17_ = g_strdup ("hindi");
							result = _tmp17_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label11) ? _tmp5_label11 : (_tmp5_label11 = g_quark_from_static_string ("hu")))) {
					switch (0) {
						default:
						{
							gchar* _tmp18_;
							_tmp18_ = g_strdup ("hungarian");
							result = _tmp18_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label12) ? _tmp5_label12 : (_tmp5_label12 = g_quark_from_static_string ("id")))) {
					switch (0) {
						default:
						{
							gchar* _tmp19_;
							_tmp19_ = g_strdup ("indonesian");
							result = _tmp19_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label13) ? _tmp5_label13 : (_tmp5_label13 = g_quark_from_static_string ("ga")))) {
					switch (0) {
						default:
						{
							gchar* _tmp20_;
							_tmp20_ = g_strdup ("irish");
							result = _tmp20_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label14) ? _tmp5_label14 : (_tmp5_label14 = g_quark_from_static_string ("it")))) {
					switch (0) {
						default:
						{
							gchar* _tmp21_;
							_tmp21_ = g_strdup ("italian");
							result = _tmp21_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label15) ? _tmp5_label15 : (_tmp5_label15 = g_quark_from_static_string ("lt")))) {
					switch (0) {
						default:
						{
							gchar* _tmp22_;
							_tmp22_ = g_strdup ("lithuanian");
							result = _tmp22_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label16) ? _tmp5_label16 : (_tmp5_label16 = g_quark_from_static_string ("ne")))) {
					switch (0) {
						default:
						{
							gchar* _tmp23_;
							_tmp23_ = g_strdup ("nepali");
							result = _tmp23_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label17) ? _tmp5_label17 : (_tmp5_label17 = g_quark_from_static_string ("no")))) {
					switch (0) {
						default:
						{
							gchar* _tmp24_;
							_tmp24_ = g_strdup ("norwegian");
							result = _tmp24_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label18) ? _tmp5_label18 : (_tmp5_label18 = g_quark_from_static_string ("pt")))) {
					switch (0) {
						default:
						{
							gchar* _tmp25_;
							_tmp25_ = g_strdup ("portuguese");
							result = _tmp25_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label19) ? _tmp5_label19 : (_tmp5_label19 = g_quark_from_static_string ("ro")))) {
					switch (0) {
						default:
						{
							gchar* _tmp26_;
							_tmp26_ = g_strdup ("romanian");
							result = _tmp26_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label20) ? _tmp5_label20 : (_tmp5_label20 = g_quark_from_static_string ("ru")))) {
					switch (0) {
						default:
						{
							gchar* _tmp27_;
							_tmp27_ = g_strdup ("russian");
							result = _tmp27_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label21) ? _tmp5_label21 : (_tmp5_label21 = g_quark_from_static_string ("sr")))) {
					switch (0) {
						default:
						{
							gchar* _tmp28_;
							_tmp28_ = g_strdup ("serbian");
							result = _tmp28_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label22) ? _tmp5_label22 : (_tmp5_label22 = g_quark_from_static_string ("es")))) {
					switch (0) {
						default:
						{
							gchar* _tmp29_;
							_tmp29_ = g_strdup ("spanish");
							result = _tmp29_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label23) ? _tmp5_label23 : (_tmp5_label23 = g_quark_from_static_string ("sv")))) {
					switch (0) {
						default:
						{
							gchar* _tmp30_;
							_tmp30_ = g_strdup ("swedish");
							result = _tmp30_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label24) ? _tmp5_label24 : (_tmp5_label24 = g_quark_from_static_string ("ta")))) {
					switch (0) {
						default:
						{
							gchar* _tmp31_;
							_tmp31_ = g_strdup ("tamil");
							result = _tmp31_;
							_g_free0 (l);
							return result;
						}
					}
				} else if (_tmp6_ == ((0 != _tmp5_label25) ? _tmp5_label25 : (_tmp5_label25 = g_quark_from_static_string ("tr")))) {
					switch (0) {
						default:
						{
							gchar* _tmp32_;
							_tmp32_ = g_strdup ("turkish");
							result = _tmp32_;
							_g_free0 (l);
							return result;
						}
					}
				}
				_g_free0 (l);
			}
		}
	}
	_tmp33_ = g_strdup ("english");
	result = _tmp33_;
	return result;
}

static void
geary_imap_engine_generic_account_on_operation_error (GearyImapEngineGenericAccount* self,
                                                      GearyImapEngineAccountOperation* op,
                                                      GError* _error_)
{
	GearyAccountInformation* _tmp0_;
	GearyAccountInformation* _tmp1_;
	GearyServiceInformation* _tmp2_;
	GearyServiceInformation* _tmp3_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_ACCOUNT_OPERATION (op));
	g_return_if_fail (_error_ != NULL);
	_tmp0_ = geary_account_get_information (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_account_information_get_incoming (_tmp1_);
	_tmp3_ = _tmp2_;
	geary_account_notify_service_problem (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount), _tmp3_, _error_);
}

static void
geary_imap_engine_generic_account_on_imap_status_notify (GearyImapEngineGenericAccount* self)
{
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	if (self->priv->open) {
		GearyImapClientService* _tmp0_;
		GearyClientServiceStatus _tmp1_;
		GearyClientServiceStatus _tmp2_;
		_tmp0_ = self->priv->_imap;
		_tmp1_ = geary_client_service_get_current_status (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
		_tmp2_ = _tmp1_;
		if (_tmp2_ == GEARY_CLIENT_SERVICE_STATUS_CONNECTED) {
			GearyNonblockingSemaphore* _tmp3_;
			_tmp3_ = self->priv->remote_ready_lock;
			geary_nonblocking_lock_blind_notify (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
			geary_imap_engine_generic_account_update_remote_folders (self, FALSE);
		} else {
			GearyNonblockingSemaphore* _tmp4_;
			GearyTimeoutManager* _tmp5_;
			_tmp4_ = self->priv->remote_ready_lock;
			geary_nonblocking_lock_reset (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
			_tmp5_ = self->priv->refresh_folder_timer;
			geary_timeout_manager_reset (_tmp5_);
		}
	}
}

static void
geary_imap_engine_generic_account_on_last_storage_cleanup_notify (GearyImapEngineGenericAccount* self)
{
	GearyImapDBAccount* _tmp0_;
	GDateTime* _tmp1_;
	GDateTime* _tmp2_;
	GCancellable* _tmp3_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (self));
	_tmp0_ = self->priv->_local;
	_tmp1_ = geary_account_get_last_storage_cleanup (G_TYPE_CHECK_INSTANCE_CAST (self, GEARY_TYPE_ACCOUNT, GearyAccount));
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->open_cancellable;
	geary_imap_db_account_set_last_cleanup_async (_tmp0_, _tmp2_, _tmp3_, NULL, NULL);
}

static void
geary_imap_engine_generic_account_class_init (GearyImapEngineGenericAccountClass * klass,
                                              gpointer klass_data)
{
	GVariantType* _tmp0_;
	geary_imap_engine_generic_account_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEngineGenericAccount_private_offset);
	((GearyAccountClass *) klass)->open_async = (void (*) (GearyAccount*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_open_async;
	((GearyAccountClass *) klass)->open_finish = (void (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_open_finish;
	((GearyAccountClass *) klass)->close_async = (void (*) (GearyAccount*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_close_async;
	((GearyAccountClass *) klass)->close_finish = (void (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_close_finish;
	((GearyAccountClass *) klass)->is_open = (gboolean (*) (GearyAccount*)) geary_imap_engine_generic_account_real_is_open;
	((GearyAccountClass *) klass)->cancel_remote_update = (void (*) (GearyAccount*)) geary_imap_engine_generic_account_real_cancel_remote_update;
	((GearyAccountClass *) klass)->rebuild_async = (void (*) (GearyAccount*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_rebuild_async;
	((GearyAccountClass *) klass)->rebuild_finish = (void (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_rebuild_finish;
	((GearyAccountClass *) klass)->to_email_identifier = (GearyEmailIdentifier* (*) (GearyAccount*, GVariant*, GError**)) geary_imap_engine_generic_account_real_to_email_identifier;
	((GearyAccountClass *) klass)->to_folder_path = (GearyFolderPath* (*) (GearyAccount*, GVariant*, GError**)) geary_imap_engine_generic_account_real_to_folder_path;
	((GearyAccountClass *) klass)->get_folder = (GearyFolder* (*) (GearyAccount*, GearyFolderPath*, GError**)) geary_imap_engine_generic_account_real_get_folder;
	((GearyAccountClass *) klass)->list_folders = (GeeCollection* (*) (GearyAccount*)) geary_imap_engine_generic_account_real_list_folders;
	((GearyAccountClass *) klass)->list_matching_folders = (GeeCollection* (*) (GearyAccount*, GearyFolderPath*, GError**)) geary_imap_engine_generic_account_real_list_matching_folders;
	((GearyAccountClass *) klass)->get_required_special_folder_async = (void (*) (GearyAccount*, GearyFolderSpecialUse, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_get_required_special_folder_async;
	((GearyAccountClass *) klass)->get_required_special_folder_finish = (GearyFolder* (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_get_required_special_folder_finish;
	((GearyAccountClass *) klass)->create_personal_folder = (void (*) (GearyAccount*, const gchar*, GearyFolderSpecialUse, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_create_personal_folder;
	((GearyAccountClass *) klass)->create_personal_folder_finish = (GearyFolder* (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_create_personal_folder_finish;
	((GearyAccountClass *) klass)->register_local_folder = (void (*) (GearyAccount*, GearyFolder*, GError**)) geary_imap_engine_generic_account_real_register_local_folder;
	((GearyAccountClass *) klass)->deregister_local_folder = (void (*) (GearyAccount*, GearyFolder*, GError**)) geary_imap_engine_generic_account_real_deregister_local_folder;
	((GearyAccountClass *) klass)->new_search_query = (GearySearchQuery* (*) (GearyAccount*, GeeList*, const gchar*, GError**)) geary_imap_engine_generic_account_real_new_search_query;
	((GearyAccountClass *) klass)->local_search_message_id_async = (void (*) (GearyAccount*, GearyRFC822MessageID*, GearyEmailField, gboolean, GeeCollection*, GearyEmailFlags*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_local_search_message_id_async;
	((GearyAccountClass *) klass)->local_search_message_id_finish = (GeeMultiMap* (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_local_search_message_id_finish;
	((GearyAccountClass *) klass)->local_fetch_email_async = (void (*) (GearyAccount*, GearyEmailIdentifier*, GearyEmailField, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_local_fetch_email_async;
	((GearyAccountClass *) klass)->local_fetch_email_finish = (GearyEmail* (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_local_fetch_email_finish;
	((GearyAccountClass *) klass)->list_local_email_async = (void (*) (GearyAccount*, GeeCollection*, GearyEmailField, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_list_local_email_async;
	((GearyAccountClass *) klass)->list_local_email_finish = (GeeList* (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_list_local_email_finish;
	((GearyAccountClass *) klass)->local_search_async = (void (*) (GearyAccount*, GearySearchQuery*, gint, gint, GeeCollection*, GeeCollection*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_local_search_async;
	((GearyAccountClass *) klass)->local_search_finish = (GeeCollection* (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_local_search_finish;
	((GearyAccountClass *) klass)->get_search_matches_async = (void (*) (GearyAccount*, GearySearchQuery*, GeeCollection*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_get_search_matches_async;
	((GearyAccountClass *) klass)->get_search_matches_finish = (GeeSet* (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_get_search_matches_finish;
	((GearyAccountClass *) klass)->get_containing_folders_async = (void (*) (GearyAccount*, GeeCollection*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_get_containing_folders_async;
	((GearyAccountClass *) klass)->get_containing_folders_finish = (GeeMultiMap* (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_get_containing_folders_finish;
	((GearyAccountClass *) klass)->cleanup_storage = (void (*) (GearyAccount*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_generic_account_real_cleanup_storage;
	((GearyAccountClass *) klass)->cleanup_storage_finish = (void (*) (GearyAccount*, GAsyncResult*, GError**)) geary_imap_engine_generic_account_cleanup_storage_finish;
	((GearyImapEngineGenericAccountClass *) klass)->new_folder = (GearyImapEngineMinimalFolder* (*) (GearyImapEngineGenericAccount*, GearyImapDBFolder*)) geary_imap_engine_generic_account_real_new_folder;
	((GearyAccountClass *) klass)->notify_folders_available_unavailable = (void (*) (GearyAccount*, GeeBidirSortedSet*, GeeBidirSortedSet*)) geary_imap_engine_generic_account_real_notify_folders_available_unavailable;
	((GearyAccountClass *) klass)->notify_email_appended = (void (*) (GearyAccount*, GearyFolder*, GeeCollection*)) geary_imap_engine_generic_account_real_notify_email_appended;
	((GearyAccountClass *) klass)->notify_email_inserted = (void (*) (GearyAccount*, GearyFolder*, GeeCollection*)) geary_imap_engine_generic_account_real_notify_email_inserted;
	((GearyAccountClass *) klass)->notify_email_removed = (void (*) (GearyAccount*, GearyFolder*, GeeCollection*)) geary_imap_engine_generic_account_real_notify_email_removed;
	((GearyAccountClass *) klass)->notify_email_locally_removed = (void (*) (GearyAccount*, GearyFolder*, GeeCollection*)) geary_imap_engine_generic_account_real_notify_email_locally_removed;
	((GearyAccountClass *) klass)->notify_email_flags_changed = (void (*) (GearyAccount*, GearyFolder*, GeeMap*)) geary_imap_engine_generic_account_real_notify_email_flags_changed;
	((GearyImapEngineGenericAccountClass *) klass)->get_supported_special_folders = (GearyFolderSpecialUse* (*) (GearyImapEngineGenericAccount*, gint*)) geary_imap_engine_generic_account_real_get_supported_special_folders;
	G_OBJECT_CLASS (klass)->get_property = _vala_geary_imap_engine_generic_account_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_geary_imap_engine_generic_account_set_property;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_engine_generic_account_finalize;
	/** Service for incoming IMAP connections. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_IMAP_PROPERTY, geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_IMAP_PROPERTY] = g_param_spec_object ("imap", "imap", "imap", GEARY_IMAP_TYPE_CLIENT_SERVICE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Service for outgoing SMTP connections. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SMTP_PROPERTY, geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SMTP_PROPERTY] = g_param_spec_object ("smtp", "smtp", "smtp", GEARY_SMTP_TYPE_CLIENT_SERVICE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Local database for the account. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_LOCAL_PROPERTY, geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_LOCAL_PROPERTY] = g_param_spec_object ("local", "local", "local", GEARY_IMAP_DB_TYPE_ACCOUNT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** The account's remote folder synchroniser. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SYNC_PROPERTY, geary_imap_engine_generic_account_properties[GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SYNC_PROPERTY] = g_param_spec_object ("sync", "sync", "sync", GEARY_IMAP_ENGINE_TYPE_ACCOUNT_SYNCHRONIZER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = g_variant_type_new (GEARY_EMAIL_IDENTIFIER_BASE_VARIANT_TYPE);
	geary_imap_engine_generic_account_email_id_type = _tmp0_;
}

static void
geary_imap_engine_generic_account_instance_init (GearyImapEngineGenericAccount * self,
                                                 gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	self->priv = geary_imap_engine_generic_account_get_instance_private (self);
	self->priv->open = FALSE;
	self->priv->open_cancellable = NULL;
	self->priv->remote_ready_lock = NULL;
	_tmp0_ = gee_hash_map_new (GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->remote_folders = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_MAP, GeeMap);
	_tmp1_ = gee_hash_map_new (GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->local_folders = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_MAP, GeeMap);
	_tmp2_ = gee_hash_map_new (GEARY_FOLDER_TYPE_SPECIAL_USE, NULL, NULL, GEE_TYPE_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->special_search_names = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_MAP, GeeMap);
}

static void
geary_imap_engine_generic_account_finalize (GObject * obj)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	_g_object_unref0 (self->priv->_imap);
	_g_object_unref0 (self->priv->_smtp);
	_g_object_unref0 (self->priv->_local);
	_g_object_unref0 (self->priv->_sync);
	_g_object_unref0 (self->priv->open_cancellable);
	_g_object_unref0 (self->priv->remote_ready_lock);
	_g_object_unref0 (self->priv->remote_folders);
	_g_object_unref0 (self->priv->local_folders);
	_g_object_unref0 (self->priv->processor);
	_g_object_unref0 (self->priv->refresh_folder_timer);
	_g_object_unref0 (self->priv->special_search_names);
	_sb_stemmer_delete0 (self->priv->stemmer);
	G_OBJECT_CLASS (geary_imap_engine_generic_account_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
geary_imap_engine_generic_account_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineGenericAccountClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_generic_account_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineGenericAccount), 0, (GInstanceInitFunc) geary_imap_engine_generic_account_instance_init, NULL };
	GType geary_imap_engine_generic_account_type_id;
	geary_imap_engine_generic_account_type_id = g_type_register_static (GEARY_TYPE_ACCOUNT, "GearyImapEngineGenericAccount", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	GearyImapEngineGenericAccount_private_offset = g_type_add_instance_private (geary_imap_engine_generic_account_type_id, sizeof (GearyImapEngineGenericAccountPrivate));
	return geary_imap_engine_generic_account_type_id;
}

GType
geary_imap_engine_generic_account_get_type (void)
{
	static gsize geary_imap_engine_generic_account_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_generic_account_type_id__once)) {
		GType geary_imap_engine_generic_account_type_id;
		geary_imap_engine_generic_account_type_id = geary_imap_engine_generic_account_get_type_once ();
		g_once_init_leave (&geary_imap_engine_generic_account_type_id__once, geary_imap_engine_generic_account_type_id);
	}
	return geary_imap_engine_generic_account_type_id__once;
}

static void
_vala_geary_imap_engine_generic_account_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	switch (property_id) {
		case GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_IMAP_PROPERTY:
		g_value_set_object (value, geary_imap_engine_generic_account_get_imap (self));
		break;
		case GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SMTP_PROPERTY:
		g_value_set_object (value, geary_imap_engine_generic_account_get_smtp (self));
		break;
		case GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_LOCAL_PROPERTY:
		g_value_set_object (value, geary_imap_engine_generic_account_get_local (self));
		break;
		case GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SYNC_PROPERTY:
		g_value_set_object (value, geary_imap_engine_generic_account_get_sync (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_geary_imap_engine_generic_account_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec)
{
	GearyImapEngineGenericAccount * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount);
	switch (property_id) {
		case GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_IMAP_PROPERTY:
		geary_imap_engine_generic_account_set_imap (self, g_value_get_object (value));
		break;
		case GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SMTP_PROPERTY:
		geary_imap_engine_generic_account_set_smtp (self, g_value_get_object (value));
		break;
		case GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_LOCAL_PROPERTY:
		geary_imap_engine_generic_account_set_local (self, g_value_get_object (value));
		break;
		case GEARY_IMAP_ENGINE_GENERIC_ACCOUNT_SYNC_PROPERTY:
		geary_imap_engine_generic_account_set_sync (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
geary_imap_engine_load_folders_get_instance_private (GearyImapEngineLoadFolders* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEngineLoadFolders_private_offset);
}

GearyImapEngineLoadFolders*
geary_imap_engine_load_folders_construct (GType object_type,
                                          GearyImapEngineGenericAccount* account,
                                          GearyImapDBAccount* local)
{
	GearyImapEngineLoadFolders * self = NULL;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (account), NULL);
	g_return_val_if_fail (GEARY_IMAP_DB_IS_ACCOUNT (local), NULL);
	self = (GearyImapEngineLoadFolders*) geary_imap_engine_account_operation_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (account, GEARY_TYPE_ACCOUNT, GearyAccount));
	self->priv->local = local;
	return self;
}

GearyImapEngineLoadFolders*
geary_imap_engine_load_folders_new (GearyImapEngineGenericAccount* account,
                                    GearyImapDBAccount* local)
{
	return geary_imap_engine_load_folders_construct (GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS, account, local);
}

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

static void
geary_imap_engine_load_folders_real_execute (GearyImapEngineAccountOperation* base,
                                             GCancellable* cancellable,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	GearyImapEngineLoadFolders * self;
	GearyImapEngineLoadFoldersExecuteData* _data_;
	GearyImapEngineLoadFolders* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS, GearyImapEngineLoadFolders);
	_data_ = g_slice_new0 (GearyImapEngineLoadFoldersExecuteData);
	_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_load_folders_real_execute_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_load_folders_real_execute_co (_data_);
}

static void
geary_imap_engine_load_folders_execute_finish (GearyImapEngineAccountOperation* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	GearyImapEngineLoadFoldersExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_load_folders_execute_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	GearyImapEngineLoadFoldersExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_load_folders_real_execute_co (_data_);
}

static gboolean
geary_imap_engine_load_folders_real_execute_co (GearyImapEngineLoadFoldersExecuteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp1_, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount));
	_data_->generic = _data_->_tmp2_;
	_data_->_tmp3_ = geary_imap_engine_generic_account_get_local (_data_->generic);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = geary_imap_db_account_get_imap_folder_root (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_state_ = 1;
	geary_imap_engine_load_folders_enumerate_local_folders_async (_data_->self, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, GEARY_TYPE_FOLDER_PATH, GearyFolderPath), _data_->cancellable, geary_imap_engine_load_folders_execute_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_engine_load_folders_enumerate_local_folders_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_->generic);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp7_ = _data_->self->priv->folders;
	_data_->_tmp8_ = geary_imap_engine_generic_account_add_folders (_data_->generic, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEE_TYPE_COLLECTION, GeeCollection), TRUE);
	_data_->_tmp9_ = _data_->_tmp8_;
	_g_object_unref0 (_data_->_tmp9_);
	_g_object_unref0 (_data_->generic);
	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_load_folders_enumerate_local_folders_async_data_free (gpointer _data)
{
	GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->parent);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData, _data_);
}

static void
geary_imap_engine_load_folders_enumerate_local_folders_async (GearyImapEngineLoadFolders* self,
                                                              GearyFolderPath* parent,
                                                              GCancellable* cancellable,
                                                              GAsyncReadyCallback _callback_,
                                                              gpointer _user_data_)
{
	GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData* _data_;
	GearyImapEngineLoadFolders* _tmp0_;
	GearyFolderPath* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_LOAD_FOLDERS (self));
	g_return_if_fail (GEARY_IS_FOLDER_PATH (parent));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData);
	_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_load_folders_enumerate_local_folders_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (parent);
	_g_object_unref0 (_data_->parent);
	_data_->parent = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	geary_imap_engine_load_folders_enumerate_local_folders_async_co (_data_);
}

static void
geary_imap_engine_load_folders_enumerate_local_folders_finish (GearyImapEngineLoadFolders* self,
                                                               GAsyncResult* _res_,
                                                               GError** error)
{
	GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_load_folders_enumerate_local_folders_async_ready (GObject* source_object,
                                                                    GAsyncResult* _res_,
                                                                    gpointer _user_data_)
{
	GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_load_folders_enumerate_local_folders_async_co (_data_);
}

static gboolean
geary_imap_engine_load_folders_enumerate_local_folders_async_co (GearyImapEngineLoadFoldersEnumerateLocalFoldersAsyncData* _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_->children = NULL;
	{
		_data_->_tmp1_ = _data_->self->priv->local;
		_data_->_state_ = 1;
		geary_imap_db_account_list_folders_async (_data_->_tmp1_, _data_->parent, _data_->cancellable, geary_imap_engine_load_folders_enumerate_local_folders_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp2_ = geary_imap_db_account_list_folders_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp0_ = _data_->_tmp2_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == GEARY_ENGINE_ERROR) {
				goto __catch0_geary_engine_error;
			}
			goto __finally0;
		}
		_data_->_tmp3_ = _data_->_tmp0_;
		_data_->_tmp0_ = NULL;
		_g_object_unref0 (_data_->children);
		_data_->children = _data_->_tmp3_;
		_g_object_unref0 (_data_->_tmp0_);
	}
	goto __finally0;
	__catch0_geary_engine_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp4_ = _data_->err;
		if (!g_error_matches (_data_->_tmp4_, GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND)) {
			_data_->_tmp5_ = _data_->err;
			_data_->_tmp6_ = _g_error_copy0 (_data_->_tmp5_);
			_data_->_inner_error0_ = _data_->_tmp6_;
			_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_->children);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp7_ = _data_->children;
	if (_data_->_tmp7_ != NULL) {
		{
			_data_->_tmp8_ = _data_->children;
			_data_->_tmp9_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEE_TYPE_ITERABLE, GeeIterable));
			_data_->_child_it = _data_->_tmp9_;
			while (TRUE) {
				_data_->_tmp10_ = _data_->_child_it;
				if (!gee_iterator_next (_data_->_tmp10_)) {
					break;
				}
				_data_->_tmp11_ = _data_->_child_it;
				_data_->_tmp12_ = gee_iterator_get (_data_->_tmp11_);
				_data_->child = (GearyImapDBFolder*) _data_->_tmp12_;
				_data_->_tmp13_ = _data_->self->priv->folders;
				_data_->_tmp14_ = _data_->child;
				gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp13_, GEE_TYPE_COLLECTION, GeeCollection), _data_->_tmp14_);
				_data_->_tmp15_ = _data_->child;
				_data_->_tmp16_ = geary_imap_db_folder_get_path (_data_->_tmp15_);
				_data_->_state_ = 2;
				geary_imap_engine_load_folders_enumerate_local_folders_async (_data_->self, _data_->_tmp16_, _data_->cancellable, geary_imap_engine_load_folders_enumerate_local_folders_async_ready, _data_);
				return FALSE;
				_state_2:
				geary_imap_engine_load_folders_enumerate_local_folders_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_->child);
					_g_object_unref0 (_data_->_child_it);
					_g_object_unref0 (_data_->children);
					g_object_unref (_data_->_async_result);
					return FALSE;
				}
				_g_object_unref0 (_data_->child);
			}
			_g_object_unref0 (_data_->_child_it);
		}
	}
	_g_object_unref0 (_data_->children);
	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_load_folders_class_init (GearyImapEngineLoadFoldersClass * klass,
                                           gpointer klass_data)
{
	geary_imap_engine_load_folders_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEngineLoadFolders_private_offset);
	((GearyImapEngineAccountOperationClass *) klass)->execute = (void (*) (GearyImapEngineAccountOperation*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_load_folders_real_execute;
	((GearyImapEngineAccountOperationClass *) klass)->execute_finish = (void (*) (GearyImapEngineAccountOperation*, GAsyncResult*, GError**)) geary_imap_engine_load_folders_execute_finish;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_engine_load_folders_finalize;
}

static void
geary_imap_engine_load_folders_instance_init (GearyImapEngineLoadFolders * self,
                                              gpointer klass)
{
	GeeLinkedList* _tmp0_;
	self->priv = geary_imap_engine_load_folders_get_instance_private (self);
	_tmp0_ = gee_linked_list_new (GEARY_IMAP_DB_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->folders = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_LIST, GeeList);
}

static void
geary_imap_engine_load_folders_finalize (GObject * obj)
{
	GearyImapEngineLoadFolders * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_ENGINE_TYPE_LOAD_FOLDERS, GearyImapEngineLoadFolders);
	_g_object_unref0 (self->priv->folders);
	G_OBJECT_CLASS (geary_imap_engine_load_folders_parent_class)->finalize (obj);
}

/**
 * Account operation for loading local folders from the database.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_engine_load_folders_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineLoadFoldersClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_load_folders_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineLoadFolders), 0, (GInstanceInitFunc) geary_imap_engine_load_folders_instance_init, NULL };
	GType geary_imap_engine_load_folders_type_id;
	geary_imap_engine_load_folders_type_id = g_type_register_static (GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, "GearyImapEngineLoadFolders", &g_define_type_info, 0);
	GearyImapEngineLoadFolders_private_offset = g_type_add_instance_private (geary_imap_engine_load_folders_type_id, sizeof (GearyImapEngineLoadFoldersPrivate));
	return geary_imap_engine_load_folders_type_id;
}

GType
geary_imap_engine_load_folders_get_type (void)
{
	static gsize geary_imap_engine_load_folders_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_load_folders_type_id__once)) {
		GType geary_imap_engine_load_folders_type_id;
		geary_imap_engine_load_folders_type_id = geary_imap_engine_load_folders_get_type_once ();
		g_once_init_leave (&geary_imap_engine_load_folders_type_id__once, geary_imap_engine_load_folders_type_id);
	}
	return geary_imap_engine_load_folders_type_id__once;
}

static inline gpointer
geary_imap_engine_start_services_get_instance_private (GearyImapEngineStartServices* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEngineStartServices_private_offset);
}

GearyImapEngineStartServices*
geary_imap_engine_start_services_construct (GType object_type,
                                            GearyAccount* account,
                                            GearyOutboxFolder* outbox)
{
	GearyImapEngineStartServices * self = NULL;
	GearyOutboxFolder* _tmp0_;
	g_return_val_if_fail (GEARY_IS_ACCOUNT (account), NULL);
	g_return_val_if_fail (GEARY_OUTBOX_IS_FOLDER (outbox), NULL);
	self = (GearyImapEngineStartServices*) geary_imap_engine_account_operation_construct (object_type, account);
	_tmp0_ = _g_object_ref0 (outbox);
	_g_object_unref0 (self->priv->outbox);
	self->priv->outbox = _tmp0_;
	return self;
}

GearyImapEngineStartServices*
geary_imap_engine_start_services_new (GearyAccount* account,
                                      GearyOutboxFolder* outbox)
{
	return geary_imap_engine_start_services_construct (GEARY_IMAP_ENGINE_TYPE_START_SERVICES, account, outbox);
}

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

static void
geary_imap_engine_start_services_real_execute (GearyImapEngineAccountOperation* base,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	GearyImapEngineStartServices * self;
	GearyImapEngineStartServicesExecuteData* _data_;
	GearyImapEngineStartServices* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_START_SERVICES, GearyImapEngineStartServices);
	_data_ = g_slice_new0 (GearyImapEngineStartServicesExecuteData);
	_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_start_services_real_execute_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_start_services_real_execute_co (_data_);
}

static void
geary_imap_engine_start_services_execute_finish (GearyImapEngineAccountOperation* base,
                                                 GAsyncResult* _res_,
                                                 GError** error)
{
	GearyImapEngineStartServicesExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_start_services_execute_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	GearyImapEngineStartServicesExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_start_services_real_execute_co (_data_);
}

static gboolean
geary_imap_engine_start_services_real_execute_co (GearyImapEngineStartServicesExecuteData* _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_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = geary_account_get_incoming (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_state_ = 1;
	geary_client_service_start (_data_->_tmp3_, _data_->cancellable, geary_imap_engine_start_services_execute_ready, _data_);
	return FALSE;
	_state_1:
	geary_client_service_start_finish (_data_->_tmp3_, _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_->_tmp4_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = _data_->self->priv->outbox;
	geary_account_register_local_folder (_data_->_tmp5_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, GEARY_TYPE_FOLDER, GearyFolder), &_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_->_tmp7_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = geary_account_get_outgoing (_data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_state_ = 2;
	geary_client_service_start (_data_->_tmp10_, _data_->cancellable, geary_imap_engine_start_services_execute_ready, _data_);
	return FALSE;
	_state_2:
	geary_client_service_start_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;
	}
	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_start_services_class_init (GearyImapEngineStartServicesClass * klass,
                                             gpointer klass_data)
{
	geary_imap_engine_start_services_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEngineStartServices_private_offset);
	((GearyImapEngineAccountOperationClass *) klass)->execute = (void (*) (GearyImapEngineAccountOperation*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_start_services_real_execute;
	((GearyImapEngineAccountOperationClass *) klass)->execute_finish = (void (*) (GearyImapEngineAccountOperation*, GAsyncResult*, GError**)) geary_imap_engine_start_services_execute_finish;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_engine_start_services_finalize;
}

static void
geary_imap_engine_start_services_instance_init (GearyImapEngineStartServices * self,
                                                gpointer klass)
{
	self->priv = geary_imap_engine_start_services_get_instance_private (self);
}

static void
geary_imap_engine_start_services_finalize (GObject * obj)
{
	GearyImapEngineStartServices * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_ENGINE_TYPE_START_SERVICES, GearyImapEngineStartServices);
	_g_object_unref0 (self->priv->outbox);
	G_OBJECT_CLASS (geary_imap_engine_start_services_parent_class)->finalize (obj);
}

/**
 * Account operation for starting remote mail services.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_engine_start_services_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineStartServicesClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_start_services_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineStartServices), 0, (GInstanceInitFunc) geary_imap_engine_start_services_instance_init, NULL };
	GType geary_imap_engine_start_services_type_id;
	geary_imap_engine_start_services_type_id = g_type_register_static (GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, "GearyImapEngineStartServices", &g_define_type_info, 0);
	GearyImapEngineStartServices_private_offset = g_type_add_instance_private (geary_imap_engine_start_services_type_id, sizeof (GearyImapEngineStartServicesPrivate));
	return geary_imap_engine_start_services_type_id;
}

GType
geary_imap_engine_start_services_get_type (void)
{
	static gsize geary_imap_engine_start_services_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_start_services_type_id__once)) {
		GType geary_imap_engine_start_services_type_id;
		geary_imap_engine_start_services_type_id = geary_imap_engine_start_services_get_type_once ();
		g_once_init_leave (&geary_imap_engine_start_services_type_id__once, geary_imap_engine_start_services_type_id);
	}
	return geary_imap_engine_start_services_type_id__once;
}

GearyImapEnginePopulateSearchTable*
geary_imap_engine_populate_search_table_construct (GType object_type,
                                                   GearyImapEngineGenericAccount* account)
{
	GearyImapEnginePopulateSearchTable * self = NULL;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (account), NULL);
	self = (GearyImapEnginePopulateSearchTable*) geary_imap_engine_account_operation_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (account, GEARY_TYPE_ACCOUNT, GearyAccount));
	return self;
}

GearyImapEnginePopulateSearchTable*
geary_imap_engine_populate_search_table_new (GearyImapEngineGenericAccount* account)
{
	return geary_imap_engine_populate_search_table_construct (GEARY_IMAP_ENGINE_TYPE_POPULATE_SEARCH_TABLE, account);
}

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

static void
geary_imap_engine_populate_search_table_real_execute (GearyImapEngineAccountOperation* base,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	GearyImapEnginePopulateSearchTable * self;
	GearyImapEnginePopulateSearchTableExecuteData* _data_;
	GearyImapEnginePopulateSearchTable* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_POPULATE_SEARCH_TABLE, GearyImapEnginePopulateSearchTable);
	_data_ = g_slice_new0 (GearyImapEnginePopulateSearchTableExecuteData);
	_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_populate_search_table_real_execute_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_populate_search_table_real_execute_co (_data_);
}

static void
geary_imap_engine_populate_search_table_execute_finish (GearyImapEngineAccountOperation* base,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	GearyImapEnginePopulateSearchTableExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_populate_search_table_execute_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	GearyImapEnginePopulateSearchTableExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_populate_search_table_real_execute_co (_data_);
}

static gboolean
geary_imap_engine_populate_search_table_real_execute_co (GearyImapEnginePopulateSearchTableExecuteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = geary_imap_engine_generic_account_get_local (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp1_, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount));
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_state_ = 1;
	geary_imap_db_account_populate_search_table (_data_->_tmp3_, _data_->cancellable, geary_imap_engine_populate_search_table_execute_ready, _data_);
	return FALSE;
	_state_1:
	geary_imap_db_account_populate_search_table_finish (_data_->_tmp3_, _data_->_res_);
	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_populate_search_table_class_init (GearyImapEnginePopulateSearchTableClass * klass,
                                                    gpointer klass_data)
{
	geary_imap_engine_populate_search_table_parent_class = g_type_class_peek_parent (klass);
	((GearyImapEngineAccountOperationClass *) klass)->execute = (void (*) (GearyImapEngineAccountOperation*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_populate_search_table_real_execute;
	((GearyImapEngineAccountOperationClass *) klass)->execute_finish = (void (*) (GearyImapEngineAccountOperation*, GAsyncResult*, GError**)) geary_imap_engine_populate_search_table_execute_finish;
}

static void
geary_imap_engine_populate_search_table_instance_init (GearyImapEnginePopulateSearchTable * self,
                                                       gpointer klass)
{
}

/**
 * Account operation for populating the full-text-search table.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_engine_populate_search_table_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEnginePopulateSearchTableClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_populate_search_table_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEnginePopulateSearchTable), 0, (GInstanceInitFunc) geary_imap_engine_populate_search_table_instance_init, NULL };
	GType geary_imap_engine_populate_search_table_type_id;
	geary_imap_engine_populate_search_table_type_id = g_type_register_static (GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, "GearyImapEnginePopulateSearchTable", &g_define_type_info, 0);
	return geary_imap_engine_populate_search_table_type_id;
}

GType
geary_imap_engine_populate_search_table_get_type (void)
{
	static gsize geary_imap_engine_populate_search_table_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_populate_search_table_type_id__once)) {
		GType geary_imap_engine_populate_search_table_type_id;
		geary_imap_engine_populate_search_table_type_id = geary_imap_engine_populate_search_table_get_type_once ();
		g_once_init_leave (&geary_imap_engine_populate_search_table_type_id__once, geary_imap_engine_populate_search_table_type_id);
	}
	return geary_imap_engine_populate_search_table_type_id__once;
}

static inline gpointer
geary_imap_engine_update_remote_folders_get_instance_private (GearyImapEngineUpdateRemoteFolders* self)
{
	return G_STRUCT_MEMBER_P (self, GearyImapEngineUpdateRemoteFolders_private_offset);
}

static GearyFolderSpecialUse*
_vala_array_dup6 (GearyFolderSpecialUse* self,
                  gssize length)
{
	if (length > 0) {
		return g_memdup2 (self, length * sizeof (GearyFolderSpecialUse));
	}
	return NULL;
}

GearyImapEngineUpdateRemoteFolders*
geary_imap_engine_update_remote_folders_construct (GType object_type,
                                                   GearyImapEngineGenericAccount* account,
                                                   gboolean already_connected,
                                                   GearyFolderSpecialUse* specials,
                                                   gint specials_length1)
{
	GearyImapEngineUpdateRemoteFolders * self = NULL;
	GearyFolderSpecialUse* _tmp0_;
	gint _tmp0__length1;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (account), NULL);
	self = (GearyImapEngineUpdateRemoteFolders*) geary_imap_engine_account_operation_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (account, GEARY_TYPE_ACCOUNT, GearyAccount));
	self->priv->generic_account = account;
	self->priv->already_connected = already_connected;
	_tmp0_ = (specials != NULL) ? _vala_array_dup6 (specials, specials_length1) : specials;
	_tmp0__length1 = specials_length1;
	self->priv->specials = (g_free (self->priv->specials), NULL);
	self->priv->specials = _tmp0_;
	self->priv->specials_length1 = _tmp0__length1;
	self->priv->_specials_size_ = self->priv->specials_length1;
	return self;
}

GearyImapEngineUpdateRemoteFolders*
geary_imap_engine_update_remote_folders_new (GearyImapEngineGenericAccount* account,
                                             gboolean already_connected,
                                             GearyFolderSpecialUse* specials,
                                             gint specials_length1)
{
	return geary_imap_engine_update_remote_folders_construct (GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS, account, already_connected, specials, specials_length1);
}

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

static void
geary_imap_engine_update_remote_folders_real_execute (GearyImapEngineAccountOperation* base,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	GearyImapEngineUpdateRemoteFolders * self;
	GearyImapEngineUpdateRemoteFoldersExecuteData* _data_;
	GearyImapEngineUpdateRemoteFolders* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS, GearyImapEngineUpdateRemoteFolders);
	_data_ = g_slice_new0 (GearyImapEngineUpdateRemoteFoldersExecuteData);
	_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_update_remote_folders_real_execute_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_update_remote_folders_real_execute_co (_data_);
}

static void
geary_imap_engine_update_remote_folders_execute_finish (GearyImapEngineAccountOperation* base,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	GearyImapEngineUpdateRemoteFoldersExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gint
__lambda134_ (GearyImapEngineUpdateRemoteFolders* self,
              GearyFolderPath* a,
              GearyFolderPath* b)
{
	gint result;
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (a), 0);
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (b), 0);
	result = gee_comparable_compare_to (G_TYPE_CHECK_INSTANCE_CAST (a, GEE_TYPE_COMPARABLE, GeeComparable), b);
	return result;
}

static gint
___lambda134__gcompare_data_func (gconstpointer a,
                                  gconstpointer b,
                                  gpointer self)
{
	gint result;
	result = __lambda134_ ((GearyImapEngineUpdateRemoteFolders*) self, (GearyFolderPath*) a, (GearyFolderPath*) b);
	return result;
}

static gint
__lambda135_ (GearyImapEngineUpdateRemoteFolders* self,
              GearyFolderPath* a,
              GearyFolderPath* b)
{
	gint result;
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (a), 0);
	g_return_val_if_fail (GEARY_IS_FOLDER_PATH (b), 0);
	result = gee_comparable_compare_to (G_TYPE_CHECK_INSTANCE_CAST (a, GEE_TYPE_COMPARABLE, GeeComparable), b);
	return result;
}

static gint
___lambda135__gcompare_data_func (gconstpointer a,
                                  gconstpointer b,
                                  gpointer self)
{
	gint result;
	result = __lambda135_ ((GearyImapEngineUpdateRemoteFolders*) self, (GearyFolderPath*) a, (GearyFolderPath*) b);
	return result;
}

static GearyFolderPath*
__lambda136_ (GearyImapEngineUpdateRemoteFolders* self,
              GearyFolder* f)
{
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	GearyFolderPath* result;
	g_return_val_if_fail (GEARY_IS_FOLDER (f), NULL);
	_tmp0_ = geary_folder_get_path (f);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	result = _tmp2_;
	_g_object_unref0 (f);
	return result;
}

static gpointer
___lambda136__gee_map_func (gpointer g,
                            gpointer self)
{
	gpointer result;
	result = __lambda136_ ((GearyImapEngineUpdateRemoteFolders*) self, (GearyFolder*) g);
	return result;
}

static void
geary_imap_engine_update_remote_folders_execute_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	GearyImapEngineUpdateRemoteFoldersExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_update_remote_folders_real_execute_co (_data_);
}

static gboolean
geary_imap_engine_update_remote_folders_real_execute_co (GearyImapEngineUpdateRemoteFoldersExecuteData* _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:
	_data_->_tmp0_ = gee_tree_map_new (GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, ___lambda134__gcompare_data_func, g_object_ref (_data_->self), g_object_unref, NULL, NULL, NULL);
	_data_->existing_folders = _data_->_tmp0_;
	_data_->_tmp1_ = gee_tree_map_new (GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, GEARY_IMAP_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, ___lambda135__gcompare_data_func, g_object_ref (_data_->self), g_object_unref, NULL, NULL, NULL);
	_data_->remote_folders = _data_->_tmp1_;
	_data_->_tmp2_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = geary_account_list_folders (_data_->_tmp3_);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = geary_traverse (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEE_TYPE_ITERABLE, GeeIterable));
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = _data_->existing_folders;
	_data_->_tmp9_ = geary_iterable_add_all_to_map (_data_->_tmp7_, GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEE_TYPE_MAP, GeeMap), ___lambda136__gee_map_func, _data_->self);
	_data_->_tmp10_ = _data_->_tmp9_;
	_g_object_unref0 (_data_->_tmp10_);
	_g_object_unref0 (_data_->_tmp7_);
	_g_object_unref0 (_data_->_tmp5_);
	_data_->_tmp11_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp12_ = _data_->_tmp11_;
	_data_->_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp12_, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount));
	_data_->account = _data_->_tmp13_;
	_data_->_tmp14_ = _data_->account;
	_data_->_state_ = 1;
	geary_imap_engine_generic_account_claim_account_session (_data_->_tmp14_, _data_->cancellable, geary_imap_engine_update_remote_folders_execute_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp15_ = geary_imap_engine_generic_account_claim_account_session_finish (_data_->_tmp14_, _data_->_res_, &_data_->_inner_error0_);
	_data_->remote = _data_->_tmp15_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->account);
		_g_object_unref0 (_data_->remote_folders);
		_g_object_unref0 (_data_->existing_folders);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	{
		_data_->_tmp16_ = _data_->remote;
		_data_->_tmp17_ = _data_->remote_folders;
		_data_->_tmp18_ = _data_->account;
		_data_->_tmp19_ = geary_imap_engine_generic_account_get_local (_data_->_tmp18_);
		_data_->_tmp20_ = _data_->_tmp19_;
		_data_->_tmp21_ = geary_imap_db_account_get_imap_folder_root (_data_->_tmp20_);
		_data_->_tmp22_ = _data_->_tmp21_;
		_data_->_state_ = 2;
		geary_imap_engine_update_remote_folders_enumerate_remote_folders_async (_data_->self, _data_->_tmp16_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp17_, GEE_TYPE_MAP, GeeMap), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp22_, GEARY_TYPE_FOLDER_PATH, GearyFolderPath), _data_->cancellable, geary_imap_engine_update_remote_folders_execute_ready, _data_);
		return FALSE;
		_state_2:
		_data_->is_suspect = geary_imap_engine_update_remote_folders_enumerate_remote_folders_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Existing folders:");
		{
			_data_->_tmp23_ = _data_->existing_folders;
			_data_->_tmp24_ = gee_abstract_map_get_keys (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp23_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
			_data_->_tmp25_ = _data_->_tmp24_;
			_data_->_tmp26_ = _data_->_tmp25_;
			_data_->_tmp27_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp26_, GEE_TYPE_ITERABLE, GeeIterable));
			_data_->_tmp28_ = _data_->_tmp27_;
			_g_object_unref0 (_data_->_tmp26_);
			_data_->_path_it = _data_->_tmp28_;
			while (TRUE) {
				_data_->_tmp29_ = _data_->_path_it;
				if (!gee_iterator_next (_data_->_tmp29_)) {
					break;
				}
				_data_->_tmp30_ = _data_->_path_it;
				_data_->_tmp31_ = gee_iterator_get (_data_->_tmp30_);
				_data_->path = (GearyFolderPath*) _data_->_tmp31_;
				_data_->_tmp32_ = _data_->path;
				_data_->_tmp33_ = geary_folder_path_to_string (_data_->_tmp32_);
				_data_->_tmp34_ = _data_->_tmp33_;
				_data_->_tmp35_ = _data_->path;
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), " - %s (%u)", _data_->_tmp34_, gee_hashable_hash (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp35_, GEE_TYPE_HASHABLE, GeeHashable)));
				_g_free0 (_data_->_tmp34_);
				_g_object_unref0 (_data_->path);
			}
			_g_object_unref0 (_data_->_path_it);
		}
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Remote folders:");
		{
			_data_->_tmp36_ = _data_->remote_folders;
			_data_->_tmp37_ = gee_abstract_map_get_keys (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp36_, GEE_TYPE_ABSTRACT_MAP, GeeAbstractMap));
			_data_->_tmp38_ = _data_->_tmp37_;
			_data_->_tmp39_ = _data_->_tmp38_;
			_data_->_tmp40_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp39_, GEE_TYPE_ITERABLE, GeeIterable));
			_data_->_tmp41_ = _data_->_tmp40_;
			_g_object_unref0 (_data_->_tmp39_);
			_data_->_vala1__path_it = _data_->_tmp41_;
			while (TRUE) {
				_data_->_tmp42_ = _data_->_vala1__path_it;
				if (!gee_iterator_next (_data_->_tmp42_)) {
					break;
				}
				_data_->_tmp43_ = _data_->_vala1__path_it;
				_data_->_tmp44_ = gee_iterator_get (_data_->_tmp43_);
				_data_->_vala1_path = (GearyFolderPath*) _data_->_tmp44_;
				_data_->_tmp45_ = _data_->_vala1_path;
				_data_->_tmp46_ = geary_folder_path_to_string (_data_->_tmp45_);
				_data_->_tmp47_ = _data_->_tmp46_;
				_data_->_tmp48_ = _data_->_vala1_path;
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), " - %s (%u)", _data_->_tmp47_, gee_hashable_hash (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp48_, GEE_TYPE_HASHABLE, GeeHashable)));
				_g_free0 (_data_->_tmp47_);
				_g_object_unref0 (_data_->_vala1_path);
			}
			_g_object_unref0 (_data_->_vala1__path_it);
		}
		_data_->_tmp49_ = _data_->remote;
		_data_->_tmp50_ = _data_->existing_folders;
		_data_->_tmp51_ = _data_->remote_folders;
		_data_->_state_ = 3;
		geary_imap_engine_update_remote_folders_update_folders_async (_data_->self, _data_->_tmp49_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp50_, GEE_TYPE_MAP, GeeMap), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp51_, GEE_TYPE_MAP, GeeMap), _data_->is_suspect, _data_->cancellable, geary_imap_engine_update_remote_folders_execute_ready, _data_);
		return FALSE;
		_state_3:
		geary_imap_engine_update_remote_folders_update_folders_finish (_data_->self, _data_->_res_);
	}
	__finally0:
	{
		_data_->_tmp52_ = _data_->account;
		_data_->_tmp53_ = _data_->remote;
		geary_imap_engine_generic_account_release_account_session (_data_->_tmp52_, _data_->_tmp53_);
	}
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->remote);
		_g_object_unref0 (_data_->account);
		_g_object_unref0 (_data_->remote_folders);
		_g_object_unref0 (_data_->existing_folders);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->remote);
	_g_object_unref0 (_data_->account);
	_g_object_unref0 (_data_->remote_folders);
	_g_object_unref0 (_data_->existing_folders);
	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_update_remote_folders_enumerate_remote_folders_async_data_free (gpointer _data)
{
	GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->remote);
	_g_object_unref0 (_data_->folders);
	_g_object_unref0 (_data_->parent);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData, _data_);
}

static void
geary_imap_engine_update_remote_folders_enumerate_remote_folders_async (GearyImapEngineUpdateRemoteFolders* self,
                                                                        GearyImapAccountSession* remote,
                                                                        GeeMap* folders,
                                                                        GearyFolderPath* parent,
                                                                        GCancellable* cancellable,
                                                                        GAsyncReadyCallback _callback_,
                                                                        gpointer _user_data_)
{
	GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData* _data_;
	GearyImapEngineUpdateRemoteFolders* _tmp0_;
	GearyImapAccountSession* _tmp1_;
	GeeMap* _tmp2_;
	GearyFolderPath* _tmp3_;
	GCancellable* _tmp4_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_UPDATE_REMOTE_FOLDERS (self));
	g_return_if_fail (GEARY_IMAP_IS_ACCOUNT_SESSION (remote));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (folders, GEE_TYPE_MAP));
	g_return_if_fail ((parent == NULL) || GEARY_IS_FOLDER_PATH (parent));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData);
	_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_update_remote_folders_enumerate_remote_folders_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (remote);
	_g_object_unref0 (_data_->remote);
	_data_->remote = _tmp1_;
	_tmp2_ = _g_object_ref0 (folders);
	_g_object_unref0 (_data_->folders);
	_data_->folders = _tmp2_;
	_tmp3_ = _g_object_ref0 (parent);
	_g_object_unref0 (_data_->parent);
	_data_->parent = _tmp3_;
	_tmp4_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp4_;
	geary_imap_engine_update_remote_folders_enumerate_remote_folders_async_co (_data_);
}

static gboolean
geary_imap_engine_update_remote_folders_enumerate_remote_folders_finish (GearyImapEngineUpdateRemoteFolders* self,
                                                                         GAsyncResult* _res_,
                                                                         GError** error)
{
	gboolean result;
	GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData* _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_update_remote_folders_enumerate_remote_folders_async_ready (GObject* source_object,
                                                                              GAsyncResult* _res_,
                                                                              gpointer _user_data_)
{
	GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_update_remote_folders_enumerate_remote_folders_async_co (_data_);
}

static gboolean
geary_imap_engine_update_remote_folders_enumerate_remote_folders_async_co (GearyImapEngineUpdateRemoteFoldersEnumerateRemoteFoldersAsyncData* _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_->results_suspect = FALSE;
	_data_->children = NULL;
	{
		_data_->_state_ = 1;
		geary_imap_account_session_fetch_child_folders_async (_data_->remote, _data_->parent, _data_->cancellable, geary_imap_engine_update_remote_folders_enumerate_remote_folders_async_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = geary_imap_account_session_fetch_child_folders_finish (_data_->remote, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp0_ = _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->_tmp0_;
		_data_->_tmp0_ = NULL;
		_g_object_unref0 (_data_->children);
		_data_->children = _data_->_tmp2_;
		_g_object_unref0 (_data_->_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp4_ = _data_->err;
		if (_data_->_tmp4_->domain == G_IO_ERROR) {
			_data_->_tmp3_ = TRUE;
		} else {
			_data_->_tmp5_ = _data_->err;
			_data_->_tmp3_ = _data_->_tmp5_->domain == GEARY_IMAP_ERROR;
		}
		if (_data_->_tmp3_) {
			_data_->_tmp6_ = _data_->err;
			_data_->_tmp7_ = _g_error_copy0 (_data_->_tmp6_);
			_data_->_inner_error0_ = _data_->_tmp7_;
			_g_error_free0 (_data_->err);
			goto __finally0;
		}
		if (_data_->parent != NULL) {
			_data_->_tmp9_ = geary_folder_path_to_string (_data_->parent);
			_g_free0 (_data_->_tmp8_);
			_data_->_tmp8_ = _data_->_tmp9_;
		} else {
			_data_->_tmp10_ = g_strdup ("root");
			_g_free0 (_data_->_tmp8_);
			_data_->_tmp8_ = _data_->_tmp10_;
		}
		_data_->_tmp11_ = _data_->err;
		_data_->_tmp12_ = _data_->_tmp11_->message;
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Ignoring error listing child folders of %s: %s", _data_->_tmp8_, _data_->_tmp12_);
		_data_->results_suspect = TRUE;
		_g_free0 (_data_->_tmp8_);
		_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_->children);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp13_ = _data_->children;
	if (_data_->_tmp13_ != NULL) {
		{
			_data_->_tmp14_ = _data_->children;
			_data_->_child_list = _data_->_tmp14_;
			_data_->_tmp15_ = _data_->_child_list;
			_data_->_tmp16_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp15_, GEE_TYPE_COLLECTION, GeeCollection));
			_data_->_tmp17_ = _data_->_tmp16_;
			_data_->_child_size = _data_->_tmp17_;
			_data_->_child_index = -1;
			while (TRUE) {
				_data_->_child_index = _data_->_child_index + 1;
				_data_->_tmp18_ = _data_->_child_index;
				_data_->_tmp19_ = _data_->_child_size;
				if (!(_data_->_tmp18_ < _data_->_tmp19_)) {
					break;
				}
				_data_->_tmp20_ = _data_->_child_list;
				_data_->_tmp21_ = gee_list_get (_data_->_tmp20_, _data_->_child_index);
				_data_->child = (GearyImapFolder*) _data_->_tmp21_;
				_data_->_tmp22_ = _data_->child;
				_data_->_tmp23_ = geary_imap_folder_get_path (_data_->_tmp22_);
				_data_->_tmp24_ = _data_->_tmp23_;
				_data_->_tmp25_ = _g_object_ref0 (_data_->_tmp24_);
				_data_->path = _data_->_tmp25_;
				_data_->_tmp26_ = _data_->path;
				_data_->_tmp27_ = _data_->child;
				gee_map_set (_data_->folders, _data_->_tmp26_, _data_->_tmp27_);
				_data_->_tmp29_ = _data_->child;
				_data_->_tmp30_ = geary_imap_folder_get_properties (_data_->_tmp29_);
				_data_->_tmp31_ = _data_->_tmp30_;
				_data_->_tmp32_ = geary_folder_properties_get_has_children (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp31_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
				_data_->_tmp33_ = _data_->_tmp32_;
				if (geary_trillian_is_possible (_data_->_tmp33_)) {
					_data_->_tmp35_ = _data_->path;
					_data_->_state_ = 2;
					geary_imap_engine_update_remote_folders_enumerate_remote_folders_async (_data_->self, _data_->remote, _data_->folders, _data_->_tmp35_, _data_->cancellable, geary_imap_engine_update_remote_folders_enumerate_remote_folders_async_ready, _data_);
					return FALSE;
					_state_2:
					_data_->_tmp34_ = geary_imap_engine_update_remote_folders_enumerate_remote_folders_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_->path);
						_g_object_unref0 (_data_->child);
						_g_object_unref0 (_data_->children);
						g_object_unref (_data_->_async_result);
						return FALSE;
					}
					_data_->_tmp28_ = _data_->_tmp34_;
				} else {
					_data_->_tmp28_ = FALSE;
				}
				if (_data_->_tmp28_) {
					_data_->results_suspect = TRUE;
				}
				_g_object_unref0 (_data_->path);
				_g_object_unref0 (_data_->child);
			}
		}
	}
	_data_->result = _data_->results_suspect;
	_g_object_unref0 (_data_->children);
	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_update_remote_folders_update_folders_async_data_free (gpointer _data)
{
	GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->remote);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData, _data_);
}

static void
geary_imap_engine_update_remote_folders_update_folders_async (GearyImapEngineUpdateRemoteFolders* self,
                                                              GearyImapAccountSession* remote,
                                                              GeeMap* existing_folders,
                                                              GeeMap* remote_folders,
                                                              gboolean remote_folders_suspect,
                                                              GCancellable* cancellable,
                                                              GAsyncReadyCallback _callback_,
                                                              gpointer _user_data_)
{
	GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData* _data_;
	GearyImapEngineUpdateRemoteFolders* _tmp0_;
	GearyImapAccountSession* _tmp1_;
	GeeMap* _tmp2_;
	GeeMap* _tmp3_;
	GCancellable* _tmp4_;
	g_return_if_fail (GEARY_IMAP_ENGINE_IS_UPDATE_REMOTE_FOLDERS (self));
	g_return_if_fail (GEARY_IMAP_IS_ACCOUNT_SESSION (remote));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (existing_folders, GEE_TYPE_MAP));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (remote_folders, GEE_TYPE_MAP));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData);
	_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_update_remote_folders_update_folders_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (remote);
	_g_object_unref0 (_data_->remote);
	_data_->remote = _tmp1_;
	_tmp2_ = _g_object_ref0 (existing_folders);
	_g_object_unref0 (_data_->existing_folders);
	_data_->existing_folders = _tmp2_;
	_tmp3_ = _g_object_ref0 (remote_folders);
	_g_object_unref0 (_data_->remote_folders);
	_data_->remote_folders = _tmp3_;
	_data_->remote_folders_suspect = remote_folders_suspect;
	_tmp4_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp4_;
	geary_imap_engine_update_remote_folders_update_folders_async_co (_data_);
}

static void
geary_imap_engine_update_remote_folders_update_folders_finish (GearyImapEngineUpdateRemoteFolders* self,
                                                               GAsyncResult* _res_)
{
	GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	if (NULL == _data_) {
		return;
	}
}

static Block97Data*
block97_data_ref (Block97Data* _data97_)
{
	g_atomic_int_inc (&_data97_->_ref_count_);
	return _data97_;
}

static void
block97_data_unref (void * _userdata_)
{
	Block97Data* _data97_;
	_data97_ = (Block97Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data97_->_ref_count_)) {
		GearyImapEngineUpdateRemoteFolders* self;
		self = _data97_->self;
		_g_object_unref0 (_data97_->existing_folders);
		_g_object_unref0 (_data97_->remote_folders);
		_g_object_unref0 (self);
		g_slice_free (Block97Data, _data97_);
	}
}

static void
geary_imap_engine_update_remote_folders_update_folders_async_ready (GObject* source_object,
                                                                    GAsyncResult* _res_,
                                                                    gpointer _user_data_)
{
	GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_update_remote_folders_update_folders_async_co (_data_);
}

static gboolean
__lambda137_ (Block97Data* _data97_,
              GearyImapFolder* f)
{
	GearyImapEngineUpdateRemoteFolders* self;
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	gboolean result;
	self = _data97_->self;
	g_return_val_if_fail (GEARY_IMAP_IS_FOLDER (f), FALSE);
	_tmp0_ = geary_imap_folder_get_path (f);
	_tmp1_ = _tmp0_;
	result = !gee_map_has_key (_data97_->existing_folders, _tmp1_);
	return result;
}

static gboolean
___lambda137__gee_predicate (gconstpointer g,
                             gpointer self)
{
	gboolean result;
	result = __lambda137_ (self, (GearyImapFolder*) g);
	return result;
}

static gboolean
__lambda138_ (Block97Data* _data97_,
              GeeMapEntry* e)
{
	GearyImapEngineUpdateRemoteFolders* self;
	gconstpointer _tmp0_;
	gconstpointer _tmp1_;
	gboolean result;
	self = _data97_->self;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (e, GEE_MAP_TYPE_ENTRY), FALSE);
	_tmp0_ = gee_map_entry_get_key (e);
	_tmp1_ = _tmp0_;
	result = !gee_map_has_key (_data97_->remote_folders, (GearyFolderPath*) _tmp1_);
	return result;
}

static gboolean
___lambda138__gee_predicate (gconstpointer g,
                             gpointer self)
{
	gboolean result;
	result = __lambda138_ (self, (GeeMapEntry*) g);
	return result;
}

static GearyFolder*
__lambda139_ (GearyImapEngineUpdateRemoteFolders* self,
              GeeMapEntry* e)
{
	gconstpointer _tmp0_;
	gconstpointer _tmp1_;
	GearyFolder* _tmp2_;
	GearyFolder* result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (e, GEE_MAP_TYPE_ENTRY), NULL);
	_tmp0_ = gee_map_entry_get_value (e);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST ((GearyFolder*) _tmp1_, GEARY_TYPE_FOLDER, GearyFolder));
	result = _tmp2_;
	_g_object_unref0 (e);
	return result;
}

static gpointer
___lambda139__gee_map_func (gpointer g,
                            gpointer self)
{
	gpointer result;
	result = __lambda139_ ((GearyImapEngineUpdateRemoteFolders*) self, (GeeMapEntry*) g);
	return result;
}

static GearyFolderPath*
___lambda142_ (GearyImapEngineUpdateRemoteFolders* self,
               GearyFolder* f)
{
	GearyFolderPath* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	GearyFolderPath* result;
	g_return_val_if_fail (GEARY_IS_FOLDER (f), NULL);
	_tmp0_ = geary_folder_get_path (f);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	result = _tmp2_;
	_g_object_unref0 (f);
	return result;
}

static gpointer
____lambda142__gee_map_func (gpointer g,
                             gpointer self)
{
	gpointer result;
	result = ___lambda142_ ((GearyImapEngineUpdateRemoteFolders*) self, (GearyFolder*) g);
	return result;
}

static gboolean
geary_imap_engine_update_remote_folders_update_folders_async_co (GearyImapEngineUpdateRemoteFoldersUpdateFoldersAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data97_ = g_slice_new0 (Block97Data);
	_data_->_data97_->_ref_count_ = 1;
	_data_->_data97_->self = g_object_ref (_data_->self);
	_g_object_unref0 (_data_->_data97_->existing_folders);
	_data_->_data97_->existing_folders = _data_->existing_folders;
	_g_object_unref0 (_data_->_data97_->remote_folders);
	_data_->_data97_->remote_folders = _data_->remote_folders;
	_data_->_data97_->_async_data_ = _data_;
	_data_->_tmp0_ = gee_hash_set_new (GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_data_->altered_paths = _data_->_tmp0_;
	{
		_data_->_tmp1_ = gee_map_get_values (_data_->_data97_->remote_folders);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp5_ = _data_->_tmp4_;
		_g_object_unref0 (_data_->_tmp3_);
		_data_->_remote_folder_it = _data_->_tmp5_;
		while (TRUE) {
			_data_->_tmp6_ = _data_->_remote_folder_it;
			if (!gee_iterator_next (_data_->_tmp6_)) {
				break;
			}
			_data_->_tmp7_ = _data_->_remote_folder_it;
			_data_->_tmp8_ = gee_iterator_get (_data_->_tmp7_);
			_data_->remote_folder = (GearyImapFolder*) _data_->_tmp8_;
			_data_->_tmp9_ = _data_->remote_folder;
			_data_->_tmp10_ = geary_imap_folder_get_path (_data_->_tmp9_);
			_data_->_tmp11_ = _data_->_tmp10_;
			_data_->_tmp12_ = gee_map_get (_data_->_data97_->existing_folders, _data_->_tmp11_);
			_data_->_tmp13_ = (GearyFolder*) _data_->_tmp12_;
			_data_->_tmp14_ = GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (_data_->_tmp13_) ? ((GearyImapEngineMinimalFolder*) _data_->_tmp13_) : NULL;
			if (_data_->_tmp14_ == NULL) {
				_g_object_unref0 (_data_->_tmp13_);
			}
			_data_->minimal_folder = _data_->_tmp14_;
			_data_->_tmp15_ = _data_->minimal_folder;
			if (_data_->_tmp15_ == NULL) {
				_g_object_unref0 (_data_->minimal_folder);
				_g_object_unref0 (_data_->remote_folder);
				continue;
			}
			_data_->_tmp16_ = _data_->remote_folder;
			_data_->_tmp17_ = geary_imap_folder_get_properties (_data_->_tmp16_);
			_data_->_tmp18_ = _data_->_tmp17_;
			_data_->_tmp19_ = geary_folder_properties_get_is_openable (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, GEARY_TYPE_FOLDER_PROPERTIES, GearyFolderProperties));
			_data_->_tmp20_ = _data_->_tmp19_;
			if (geary_trillian_is_possible (_data_->_tmp20_)) {
				_data_->_tmp21_ = _data_->minimal_folder;
				_data_->_tmp22_ = geary_imap_engine_minimal_folder_get_local_folder (_data_->_tmp21_);
				_data_->_tmp23_ = _data_->_tmp22_;
				_data_->_tmp24_ = _g_object_ref0 (_data_->_tmp23_);
				_data_->local_folder = _data_->_tmp24_;
				_data_->_tmp25_ = _data_->remote_folder;
				_data_->_tmp26_ = geary_imap_folder_get_properties (_data_->_tmp25_);
				_data_->_tmp27_ = _data_->_tmp26_;
				_data_->_tmp28_ = _data_->local_folder;
				_data_->_tmp29_ = geary_imap_db_folder_get_properties (_data_->_tmp28_);
				_data_->_tmp30_ = _data_->_tmp29_;
				_data_->_tmp31_ = _data_->minimal_folder;
				_data_->_tmp32_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp31_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp33_ = _data_->_tmp32_;
				_data_->_tmp34_ = geary_imap_folder_properties_have_contents_changed (_data_->_tmp27_, _data_->_tmp30_, _data_->_tmp33_);
				_g_free0 (_data_->_tmp33_);
				_g_object_unref0 (_data_->_tmp30_);
				if (_data_->_tmp34_) {
					_data_->_tmp35_ = _data_->altered_paths;
					_data_->_tmp36_ = _data_->remote_folder;
					_data_->_tmp37_ = geary_imap_folder_get_path (_data_->_tmp36_);
					_data_->_tmp38_ = _data_->_tmp37_;
					gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp35_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _data_->_tmp38_);
				}
				_g_object_unref0 (_data_->local_folder);
			}
			{
				_data_->_tmp39_ = _data_->minimal_folder;
				_data_->_tmp40_ = geary_imap_engine_minimal_folder_get_local_folder (_data_->_tmp39_);
				_data_->_tmp41_ = _data_->_tmp40_;
				_data_->_tmp42_ = _data_->remote_folder;
				_data_->_tmp43_ = geary_imap_folder_get_properties (_data_->_tmp42_);
				_data_->_tmp44_ = _data_->_tmp43_;
				_data_->_state_ = 1;
				geary_imap_db_folder_update_folder_status (_data_->_tmp41_, _data_->_tmp44_, FALSE, _data_->cancellable, geary_imap_engine_update_remote_folders_update_folders_async_ready, _data_);
				return FALSE;
				_state_1:
				geary_imap_db_folder_update_folder_status_finish (_data_->_tmp41_, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
			}
			goto __finally0;
			__catch0_g_error:
			{
				_data_->update_error = _data_->_inner_error0_;
				_data_->_inner_error0_ = NULL;
				_data_->_tmp45_ = _data_->remote_folder;
				_data_->_tmp46_ = geary_imap_folder_get_path (_data_->_tmp45_);
				_data_->_tmp47_ = _data_->_tmp46_;
				_data_->_tmp48_ = geary_folder_path_to_string (_data_->_tmp47_);
				_data_->_tmp49_ = _data_->_tmp48_;
				_data_->_tmp50_ = _data_->update_error;
				_data_->_tmp51_ = _data_->_tmp50_->message;
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unable to update local folder %s with remote properties: %s", _data_->_tmp49_, _data_->_tmp51_);
				_g_free0 (_data_->_tmp49_);
				_g_error_free0 (_data_->update_error);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->minimal_folder);
				_g_object_unref0 (_data_->remote_folder);
				_g_object_unref0 (_data_->_remote_folder_it);
				_g_object_unref0 (_data_->altered_paths);
				block97_data_unref (_data_->_data97_);
				_data_->_data97_ = 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_->_tmp52_ = _data_->minimal_folder;
			_data_->_tmp53_ = geary_folder_get_used_as (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp52_, GEARY_TYPE_FOLDER, GearyFolder));
			_data_->_tmp54_ = _data_->_tmp53_;
			if (_data_->_tmp54_ == GEARY_FOLDER_SPECIAL_USE_NONE) {
				_data_->_tmp55_ = _data_->minimal_folder;
				_data_->_tmp56_ = _data_->remote_folder;
				_data_->_tmp57_ = geary_imap_folder_get_properties (_data_->_tmp56_);
				_data_->_tmp58_ = _data_->_tmp57_;
				_data_->_tmp59_ = geary_imap_folder_properties_get_attrs (_data_->_tmp58_);
				_data_->_tmp60_ = _data_->_tmp59_;
				geary_imap_engine_minimal_folder_set_use (_data_->_tmp55_, geary_imap_mailbox_attributes_get_special_use (_data_->_tmp60_));
			}
			_g_object_unref0 (_data_->minimal_folder);
			_g_object_unref0 (_data_->remote_folder);
		}
		_g_object_unref0 (_data_->_remote_folder_it);
	}
	_data_->_tmp61_ = gee_map_get_values (_data_->_data97_->remote_folders);
	_data_->_tmp62_ = _data_->_tmp61_;
	_data_->_tmp63_ = _data_->_tmp62_;
	_data_->_tmp64_ = geary_traverse (GEARY_IMAP_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp63_, GEE_TYPE_ITERABLE, GeeIterable));
	_data_->_tmp65_ = _data_->_tmp64_;
	_data_->_tmp66_ = geary_iterable_filter (_data_->_tmp65_, ___lambda137__gee_predicate, block97_data_ref (_data_->_data97_), block97_data_unref);
	_data_->_tmp67_ = _data_->_tmp66_;
	_data_->_tmp68_ = geary_iterable_to_array_list (_data_->_tmp67_, NULL, NULL, NULL);
	_data_->_tmp69_ = _data_->_tmp68_;
	_g_object_unref0 (_data_->_tmp67_);
	_g_object_unref0 (_data_->_tmp65_);
	_g_object_unref0 (_data_->_tmp63_);
	_data_->to_add = _data_->_tmp69_;
	_data_->_tmp70_ = geary_traverse (GEE_MAP_TYPE_ENTRY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_data97_->existing_folders, GEE_TYPE_ITERABLE, GeeIterable));
	_data_->_tmp71_ = _data_->_tmp70_;
	_data_->_tmp72_ = geary_iterable_filter (_data_->_tmp71_, ___lambda138__gee_predicate, block97_data_ref (_data_->_data97_), block97_data_unref);
	_data_->_tmp73_ = _data_->_tmp72_;
	_data_->_tmp74_ = geary_iterable_map (_data_->_tmp73_, GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, ___lambda139__gee_map_func, _data_->self);
	_data_->_tmp75_ = _data_->_tmp74_;
	_data_->_tmp76_ = geary_iterable_to_array_list (_data_->_tmp75_, NULL, NULL, NULL);
	_data_->_tmp77_ = _data_->_tmp76_;
	_g_object_unref0 (_data_->_tmp75_);
	_g_object_unref0 (_data_->_tmp73_);
	_g_object_unref0 (_data_->_tmp71_);
	_data_->to_remove = _data_->_tmp77_;
	_data_->_tmp78_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp79_ = _data_->_tmp78_;
	_data_->_tmp80_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp79_, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount));
	_data_->generic_account = _data_->_tmp80_;
	_data_->_tmp81_ = _data_->generic_account;
	_data_->_tmp82_ = geary_imap_engine_generic_account_get_local (_data_->_tmp81_);
	_data_->_tmp83_ = _data_->_tmp82_;
	_data_->_tmp84_ = _g_object_ref0 (_data_->_tmp83_);
	_data_->local = _data_->_tmp84_;
	_data_->_tmp85_ = gee_array_list_new (GEARY_IMAP_DB_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data_->to_build = _data_->_tmp85_;
	{
		_data_->_tmp86_ = _data_->to_add;
		_data_->_remote_folder_list = _data_->_tmp86_;
		_data_->_tmp87_ = _data_->_remote_folder_list;
		_data_->_tmp88_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp87_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
		_data_->_tmp89_ = _data_->_tmp88_;
		_data_->_remote_folder_size = _data_->_tmp89_;
		_data_->_remote_folder_index = -1;
		while (TRUE) {
			_data_->_remote_folder_index = _data_->_remote_folder_index + 1;
			_data_->_tmp90_ = _data_->_remote_folder_index;
			_data_->_tmp91_ = _data_->_remote_folder_size;
			if (!(_data_->_tmp90_ < _data_->_tmp91_)) {
				break;
			}
			_data_->_tmp92_ = _data_->_remote_folder_list;
			_data_->_tmp93_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp92_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), _data_->_remote_folder_index);
			_data_->_vala1_remote_folder = (GearyImapFolder*) _data_->_tmp93_;
			{
				_data_->_tmp95_ = _data_->local;
				_data_->_tmp96_ = _data_->_vala1_remote_folder;
				_data_->_state_ = 2;
				geary_imap_db_account_clone_folder_async (_data_->_tmp95_, _data_->_tmp96_, _data_->cancellable, geary_imap_engine_update_remote_folders_update_folders_async_ready, _data_);
				return FALSE;
				_state_2:
				_data_->_tmp97_ = geary_imap_db_account_clone_folder_finish (_data_->_tmp95_, _data_->_res_, &_data_->_inner_error0_);
				_data_->_tmp94_ = _data_->_tmp97_;
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch1_g_error;
				}
				_data_->_tmp98_ = _data_->to_build;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp98_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _data_->_tmp94_);
				_g_object_unref0 (_data_->_tmp94_);
			}
			goto __finally1;
			__catch1_g_error:
			{
				_data_->err = _data_->_inner_error0_;
				_data_->_inner_error0_ = NULL;
				_data_->_tmp99_ = _data_->_vala1_remote_folder;
				_data_->_tmp100_ = geary_imap_folder_get_path (_data_->_tmp99_);
				_data_->_tmp101_ = _data_->_tmp100_;
				_data_->_tmp102_ = geary_folder_path_to_string (_data_->_tmp101_);
				_data_->_tmp103_ = _data_->_tmp102_;
				_data_->_tmp104_ = _data_->err;
				_data_->_tmp105_ = _data_->_tmp104_->message;
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unable to clone folder %s in local store: %s", _data_->_tmp103_, _data_->_tmp105_);
				_g_free0 (_data_->_tmp103_);
				_g_error_free0 (_data_->err);
			}
			__finally1:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->_vala1_remote_folder);
				_g_object_unref0 (_data_->to_build);
				_g_object_unref0 (_data_->local);
				_g_object_unref0 (_data_->generic_account);
				_g_object_unref0 (_data_->to_remove);
				_g_object_unref0 (_data_->to_add);
				_g_object_unref0 (_data_->altered_paths);
				block97_data_unref (_data_->_data97_);
				_data_->_data97_ = 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_object_unref0 (_data_->_vala1_remote_folder);
		}
	}
	_data_->_tmp106_ = _data_->self->priv->generic_account;
	_data_->_tmp107_ = _data_->to_build;
	_data_->_tmp108_ = geary_imap_engine_generic_account_add_folders (_data_->_tmp106_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp107_, GEE_TYPE_COLLECTION, GeeCollection), FALSE);
	_data_->_tmp109_ = _data_->_tmp108_;
	_g_object_unref0 (_data_->_tmp109_);
	if (_data_->remote_folders_suspect) {
		geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Skipping removing folders due to prior errors");
	} else {
		_data_->_tmp110_ = _data_->self->priv->generic_account;
		_data_->_tmp111_ = _data_->to_remove;
		_data_->_tmp112_ = geary_imap_engine_generic_account_remove_folders (_data_->_tmp110_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp111_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->removed = _data_->_tmp112_;
		_data_->_tmp113_ = _data_->removed;
		_data_->_tmp114_ = gee_bidir_sorted_set_bidir_iterator (_data_->_tmp113_);
		_data_->removed_iterator = _data_->_tmp114_;
		_data_->_tmp115_ = _data_->removed_iterator;
		_data_->has_prev = gee_bidir_iterator_last (_data_->_tmp115_);
		while (TRUE) {
			if (!_data_->has_prev) {
				break;
			}
			_data_->_tmp116_ = _data_->removed_iterator;
			_data_->_tmp117_ = gee_iterator_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp116_, GEE_TYPE_ITERATOR, GeeIterator));
			_data_->folder = (GearyImapEngineMinimalFolder*) _data_->_tmp117_;
			{
				_data_->_tmp118_ = _data_->folder;
				_data_->_tmp119_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp118_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp120_ = _data_->_tmp119_;
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Locally deleting removed folder %s", _data_->_tmp120_);
				_g_free0 (_data_->_tmp120_);
				_data_->_tmp121_ = _data_->local;
				_data_->_tmp122_ = _data_->folder;
				_data_->_tmp123_ = geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp122_, GEARY_TYPE_FOLDER, GearyFolder));
				_data_->_tmp124_ = _data_->_tmp123_;
				_data_->_state_ = 3;
				geary_imap_db_account_delete_folder_async (_data_->_tmp121_, _data_->_tmp124_, _data_->cancellable, geary_imap_engine_update_remote_folders_update_folders_async_ready, _data_);
				return FALSE;
				_state_3:
				geary_imap_db_account_delete_folder_finish (_data_->_tmp121_, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch2_g_error;
				}
			}
			goto __finally2;
			__catch2_g_error:
			{
				_data_->e = _data_->_inner_error0_;
				_data_->_inner_error0_ = NULL;
				_data_->_tmp125_ = _data_->folder;
				_data_->_tmp126_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp125_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp127_ = _data_->_tmp126_;
				_data_->_tmp128_ = _data_->e;
				_data_->_tmp129_ = _data_->_tmp128_->message;
				geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unable to locally delete removed folder %s: %s", _data_->_tmp127_, _data_->_tmp129_);
				_g_free0 (_data_->_tmp127_);
				_g_error_free0 (_data_->e);
			}
			__finally2:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->folder);
				_g_object_unref0 (_data_->removed_iterator);
				_g_object_unref0 (_data_->removed);
				_g_object_unref0 (_data_->to_build);
				_g_object_unref0 (_data_->local);
				_g_object_unref0 (_data_->generic_account);
				_g_object_unref0 (_data_->to_remove);
				_g_object_unref0 (_data_->to_add);
				_g_object_unref0 (_data_->altered_paths);
				block97_data_unref (_data_->_data97_);
				_data_->_data97_ = 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_->_tmp130_ = _data_->removed_iterator;
			_data_->has_prev = gee_bidir_iterator_previous (_data_->_tmp130_);
			_g_object_unref0 (_data_->folder);
		}
		_data_->_tmp131_ = _data_->removed;
		_data_->_tmp132_ = geary_traverse (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp131_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp133_ = _data_->_tmp132_;
		_data_->_tmp134_ = geary_iterable_map (_data_->_tmp133_, GEARY_TYPE_FOLDER_PATH, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, ____lambda142__gee_map_func, _data_->self);
		_data_->_tmp135_ = _data_->_tmp134_;
		_data_->_tmp136_ = geary_iterable_to_array_list (_data_->_tmp135_, NULL, NULL, NULL);
		_data_->_tmp137_ = _data_->_tmp136_;
		geary_imap_account_session_folders_removed (_data_->remote, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp137_, GEE_TYPE_COLLECTION, GeeCollection));
		_g_object_unref0 (_data_->_tmp137_);
		_g_object_unref0 (_data_->_tmp135_);
		_g_object_unref0 (_data_->_tmp133_);
		_g_object_unref0 (_data_->removed_iterator);
		_g_object_unref0 (_data_->removed);
	}
	if (_data_->self->priv->already_connected) {
		_data_->_tmp138_ = _data_->altered_paths;
		_data_->_tmp139_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp138_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
		_data_->_tmp140_ = _data_->_tmp139_;
		if (_data_->_tmp140_ > 0) {
			_data_->_tmp141_ = gee_array_list_new (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
			_data_->altered = _data_->_tmp141_;
			{
				_data_->_tmp142_ = _data_->altered_paths;
				_data_->_tmp143_ = gee_abstract_collection_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp142_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
				_data_->_altered_path_it = _data_->_tmp143_;
				while (TRUE) {
					_data_->_tmp144_ = _data_->_altered_path_it;
					if (!gee_iterator_next (_data_->_tmp144_)) {
						break;
					}
					_data_->_tmp145_ = _data_->_altered_path_it;
					_data_->_tmp146_ = gee_iterator_get (_data_->_tmp145_);
					_data_->altered_path = (GearyFolderPath*) _data_->_tmp146_;
					_data_->_tmp147_ = _data_->altered_path;
					if (gee_map_has_key (_data_->_data97_->existing_folders, _data_->_tmp147_)) {
						_data_->_tmp148_ = _data_->altered;
						_data_->_tmp149_ = _data_->altered_path;
						_data_->_tmp150_ = gee_map_get (_data_->_data97_->existing_folders, _data_->_tmp149_);
						_data_->_tmp151_ = (GearyFolder*) _data_->_tmp150_;
						gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp148_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _data_->_tmp151_);
						_g_object_unref0 (_data_->_tmp151_);
					} else {
						_data_->_tmp152_ = _data_->altered_path;
						_data_->_tmp153_ = geary_folder_path_to_string (_data_->_tmp152_);
						_data_->_tmp154_ = _data_->_tmp153_;
						geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unable to report %s altered: no local representation", _data_->_tmp154_);
						_g_free0 (_data_->_tmp154_);
					}
					_g_object_unref0 (_data_->altered_path);
				}
				_g_object_unref0 (_data_->_altered_path_it);
			}
			_data_->_tmp155_ = _data_->self->priv->generic_account;
			_data_->_tmp156_ = _data_->altered;
			geary_imap_engine_generic_account_update_folders (_data_->_tmp155_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp156_, GEE_TYPE_COLLECTION, GeeCollection));
			_g_object_unref0 (_data_->altered);
		}
	} else {
		_data_->_tmp157_ = gee_map_get_size (_data_->_data97_->remote_folders);
		_data_->_tmp158_ = _data_->_tmp157_;
		if (_data_->_tmp158_ > 0) {
			_data_->_tmp159_ = gee_array_list_new (GEARY_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
			_data_->remotes = _data_->_tmp159_;
			{
				_data_->_tmp160_ = gee_map_get_keys (_data_->_data97_->remote_folders);
				_data_->_tmp161_ = _data_->_tmp160_;
				_data_->_tmp162_ = _data_->_tmp161_;
				_data_->_tmp163_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp162_, GEE_TYPE_ITERABLE, GeeIterable));
				_data_->_tmp164_ = _data_->_tmp163_;
				_g_object_unref0 (_data_->_tmp162_);
				_data_->_path_it = _data_->_tmp164_;
				while (TRUE) {
					_data_->_tmp165_ = _data_->_path_it;
					if (!gee_iterator_next (_data_->_tmp165_)) {
						break;
					}
					_data_->_tmp166_ = _data_->_path_it;
					_data_->_tmp167_ = gee_iterator_get (_data_->_tmp166_);
					_data_->path = (GearyFolderPath*) _data_->_tmp167_;
					_data_->_tmp168_ = _data_->path;
					if (gee_map_has_key (_data_->_data97_->existing_folders, _data_->_tmp168_)) {
						_data_->_tmp169_ = _data_->remotes;
						_data_->_tmp170_ = _data_->path;
						_data_->_tmp171_ = gee_map_get (_data_->_data97_->existing_folders, _data_->_tmp170_);
						_data_->_tmp172_ = (GearyFolder*) _data_->_tmp171_;
						gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp169_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _data_->_tmp172_);
						_g_object_unref0 (_data_->_tmp172_);
					} else {
						_data_->_tmp173_ = _data_->path;
						_data_->_tmp174_ = geary_folder_path_to_string (_data_->_tmp173_);
						_data_->_tmp175_ = _data_->_tmp174_;
						geary_logging_source_debug (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unable to report %s remote: no local representation", _data_->_tmp175_);
						_g_free0 (_data_->_tmp175_);
					}
					_g_object_unref0 (_data_->path);
				}
				_g_object_unref0 (_data_->_path_it);
			}
			_data_->_tmp176_ = _data_->self->priv->generic_account;
			_data_->_tmp177_ = geary_imap_engine_generic_account_get_sync (_data_->_tmp176_);
			_data_->_tmp178_ = _data_->_tmp177_;
			_data_->_tmp179_ = _data_->remotes;
			geary_imap_engine_account_synchronizer_folders_discovered (_data_->_tmp178_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp179_, GEE_TYPE_COLLECTION, GeeCollection));
			_g_object_unref0 (_data_->remotes);
		}
	}
	_data_->_tmp180_ = _data_->self->priv->specials;
	_data_->_tmp180__length1 = _data_->self->priv->specials_length1;
	{
		_data_->use_collection_length1 = 0;
		_data_->_use_collection_size_ = 0;
		_data_->use_collection = _data_->_tmp180_;
		_data_->use_collection_length1 = _data_->_tmp180__length1;
		for (_data_->use_it = 0; _data_->use_it < _data_->use_collection_length1; _data_->use_it = _data_->use_it + 1) {
			_data_->use = _data_->use_collection[_data_->use_it];
			{
				{
					_data_->_tmp181_ = _data_->self->priv->generic_account;
					_data_->_state_ = 4;
					geary_imap_engine_generic_account_ensure_special_folder_async (_data_->_tmp181_, _data_->remote, _data_->use, _data_->cancellable, geary_imap_engine_update_remote_folders_update_folders_async_ready, _data_);
					return FALSE;
					_state_4:
					_data_->_tmp182_ = geary_imap_engine_generic_account_ensure_special_folder_finish (_data_->_tmp181_, _data_->_res_, &_data_->_inner_error0_);
					_data_->_tmp183_ = _data_->_tmp182_;
					_g_object_unref0 (_data_->_tmp183_);
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						goto __catch3_g_error;
					}
				}
				goto __finally3;
				__catch3_g_error:
				{
					_data_->_vala1_e = _data_->_inner_error0_;
					_data_->_inner_error0_ = NULL;
					_data_->_tmp184_ = g_enum_to_string (GEARY_FOLDER_TYPE_SPECIAL_USE, _data_->use);
					_data_->_tmp185_ = _data_->_vala1_e;
					_data_->_tmp186_ = _data_->_tmp185_->message;
					geary_logging_source_warning (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource), "Unable to ensure special folder %s: %s", _data_->_tmp184_, _data_->_tmp186_);
					_g_free0 (_data_->_tmp184_);
					_g_error_free0 (_data_->_vala1_e);
				}
				__finally3:
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->to_build);
					_g_object_unref0 (_data_->local);
					_g_object_unref0 (_data_->generic_account);
					_g_object_unref0 (_data_->to_remove);
					_g_object_unref0 (_data_->to_add);
					_g_object_unref0 (_data_->altered_paths);
					block97_data_unref (_data_->_data97_);
					_data_->_data97_ = 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_object_unref0 (_data_->to_build);
	_g_object_unref0 (_data_->local);
	_g_object_unref0 (_data_->generic_account);
	_g_object_unref0 (_data_->to_remove);
	_g_object_unref0 (_data_->to_add);
	_g_object_unref0 (_data_->altered_paths);
	block97_data_unref (_data_->_data97_);
	_data_->_data97_ = 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_update_remote_folders_class_init (GearyImapEngineUpdateRemoteFoldersClass * klass,
                                                    gpointer klass_data)
{
	geary_imap_engine_update_remote_folders_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GearyImapEngineUpdateRemoteFolders_private_offset);
	((GearyImapEngineAccountOperationClass *) klass)->execute = (void (*) (GearyImapEngineAccountOperation*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_update_remote_folders_real_execute;
	((GearyImapEngineAccountOperationClass *) klass)->execute_finish = (void (*) (GearyImapEngineAccountOperation*, GAsyncResult*, GError**)) geary_imap_engine_update_remote_folders_execute_finish;
	G_OBJECT_CLASS (klass)->finalize = geary_imap_engine_update_remote_folders_finalize;
}

static void
geary_imap_engine_update_remote_folders_instance_init (GearyImapEngineUpdateRemoteFolders * self,
                                                       gpointer klass)
{
	self->priv = geary_imap_engine_update_remote_folders_get_instance_private (self);
}

static void
geary_imap_engine_update_remote_folders_finalize (GObject * obj)
{
	GearyImapEngineUpdateRemoteFolders * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEARY_IMAP_ENGINE_TYPE_UPDATE_REMOTE_FOLDERS, GearyImapEngineUpdateRemoteFolders);
	self->priv->specials = (g_free (self->priv->specials), NULL);
	G_OBJECT_CLASS (geary_imap_engine_update_remote_folders_parent_class)->finalize (obj);
}

/**
 * Account operation that updates folders from the remote.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_engine_update_remote_folders_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineUpdateRemoteFoldersClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_update_remote_folders_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineUpdateRemoteFolders), 0, (GInstanceInitFunc) geary_imap_engine_update_remote_folders_instance_init, NULL };
	GType geary_imap_engine_update_remote_folders_type_id;
	geary_imap_engine_update_remote_folders_type_id = g_type_register_static (GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, "GearyImapEngineUpdateRemoteFolders", &g_define_type_info, 0);
	GearyImapEngineUpdateRemoteFolders_private_offset = g_type_add_instance_private (geary_imap_engine_update_remote_folders_type_id, sizeof (GearyImapEngineUpdateRemoteFoldersPrivate));
	return geary_imap_engine_update_remote_folders_type_id;
}

GType
geary_imap_engine_update_remote_folders_get_type (void)
{
	static gsize geary_imap_engine_update_remote_folders_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_update_remote_folders_type_id__once)) {
		GType geary_imap_engine_update_remote_folders_type_id;
		geary_imap_engine_update_remote_folders_type_id = geary_imap_engine_update_remote_folders_get_type_once ();
		g_once_init_leave (&geary_imap_engine_update_remote_folders_type_id__once, geary_imap_engine_update_remote_folders_type_id);
	}
	return geary_imap_engine_update_remote_folders_type_id__once;
}

GearyImapEngineRefreshFolderUnseen*
geary_imap_engine_refresh_folder_unseen_construct (GType object_type,
                                                   GearyImapEngineMinimalFolder* folder,
                                                   GearyImapEngineGenericAccount* account)
{
	GearyImapEngineRefreshFolderUnseen * self = NULL;
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_MINIMAL_FOLDER (folder), NULL);
	g_return_val_if_fail (GEARY_IMAP_ENGINE_IS_GENERIC_ACCOUNT (account), NULL);
	self = (GearyImapEngineRefreshFolderUnseen*) geary_imap_engine_folder_operation_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (account, GEARY_TYPE_ACCOUNT, GearyAccount), G_TYPE_CHECK_INSTANCE_CAST (folder, GEARY_TYPE_FOLDER, GearyFolder));
	return self;
}

GearyImapEngineRefreshFolderUnseen*
geary_imap_engine_refresh_folder_unseen_new (GearyImapEngineMinimalFolder* folder,
                                             GearyImapEngineGenericAccount* account)
{
	return geary_imap_engine_refresh_folder_unseen_construct (GEARY_IMAP_ENGINE_TYPE_REFRESH_FOLDER_UNSEEN, folder, account);
}

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

static void
geary_imap_engine_refresh_folder_unseen_real_execute (GearyImapEngineAccountOperation* base,
                                                      GCancellable* cancellable,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	GearyImapEngineRefreshFolderUnseen * self;
	GearyImapEngineRefreshFolderUnseenExecuteData* _data_;
	GearyImapEngineRefreshFolderUnseen* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, GEARY_IMAP_ENGINE_TYPE_REFRESH_FOLDER_UNSEEN, GearyImapEngineRefreshFolderUnseen);
	_data_ = g_slice_new0 (GearyImapEngineRefreshFolderUnseenExecuteData);
	_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_refresh_folder_unseen_real_execute_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_refresh_folder_unseen_real_execute_co (_data_);
}

static void
geary_imap_engine_refresh_folder_unseen_execute_finish (GearyImapEngineAccountOperation* base,
                                                        GAsyncResult* _res_,
                                                        GError** error)
{
	GearyImapEngineRefreshFolderUnseenExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
geary_imap_engine_refresh_folder_unseen_execute_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_)
{
	GearyImapEngineRefreshFolderUnseenExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	geary_imap_engine_refresh_folder_unseen_real_execute_co (_data_);
}

static gboolean
geary_imap_engine_refresh_folder_unseen_real_execute_co (GearyImapEngineRefreshFolderUnseenExecuteData* _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:
	_data_->_tmp0_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp1_, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount));
	_data_->account = _data_->_tmp2_;
	_data_->_tmp3_ = geary_imap_engine_folder_operation_get_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_FOLDER_OPERATION, GearyImapEngineFolderOperation));
	_data_->_tmp4_ = _data_->_tmp3_;
	if (geary_folder_get_open_state (_data_->_tmp4_) == GEARY_FOLDER_OPEN_STATE_CLOSED) {
		_data_->_tmp5_ = _data_->account;
		_data_->_state_ = 1;
		geary_imap_engine_generic_account_claim_account_session (_data_->_tmp5_, _data_->cancellable, geary_imap_engine_refresh_folder_unseen_execute_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp6_ = geary_imap_engine_generic_account_claim_account_session_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
		_data_->remote = _data_->_tmp6_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->account);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		{
			_data_->_tmp7_ = _data_->remote;
			_data_->_tmp8_ = geary_imap_engine_folder_operation_get_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_FOLDER_OPERATION, GearyImapEngineFolderOperation));
			_data_->_tmp9_ = _data_->_tmp8_;
			_data_->_tmp10_ = geary_folder_get_path (_data_->_tmp9_);
			_data_->_tmp11_ = _data_->_tmp10_;
			_data_->_state_ = 2;
			geary_imap_account_session_fetch_folder_async (_data_->_tmp7_, _data_->_tmp11_, _data_->cancellable, geary_imap_engine_refresh_folder_unseen_execute_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp12_ = geary_imap_account_session_fetch_folder_finish (_data_->_tmp7_, _data_->_res_, &_data_->_inner_error0_);
			_data_->remote_folder = _data_->_tmp12_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __finally0;
			}
			_data_->_tmp13_ = geary_imap_engine_folder_operation_get_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_FOLDER_OPERATION, GearyImapEngineFolderOperation));
			_data_->_tmp14_ = _data_->_tmp13_;
			_data_->_tmp15_ = geary_imap_engine_minimal_folder_get_local_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp14_, GEARY_IMAP_ENGINE_TYPE_MINIMAL_FOLDER, GearyImapEngineMinimalFolder));
			_data_->_tmp16_ = _data_->_tmp15_;
			_data_->_tmp17_ = _g_object_ref0 (_data_->_tmp16_);
			_data_->local_folder = _data_->_tmp17_;
			_data_->_tmp18_ = _data_->remote_folder;
			_data_->_tmp19_ = geary_imap_folder_get_properties (_data_->_tmp18_);
			_data_->_tmp20_ = _data_->_tmp19_;
			_data_->_tmp21_ = _data_->local_folder;
			_data_->_tmp22_ = geary_imap_db_folder_get_properties (_data_->_tmp21_);
			_data_->_tmp23_ = _data_->_tmp22_;
			_data_->_tmp24_ = geary_imap_engine_folder_operation_get_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_FOLDER_OPERATION, GearyImapEngineFolderOperation));
			_data_->_tmp25_ = _data_->_tmp24_;
			_data_->_tmp26_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp25_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
			_data_->_tmp27_ = _data_->_tmp26_;
			_data_->_tmp28_ = geary_imap_folder_properties_have_contents_changed (_data_->_tmp20_, _data_->_tmp23_, _data_->_tmp27_);
			_g_free0 (_data_->_tmp27_);
			_g_object_unref0 (_data_->_tmp23_);
			if (_data_->_tmp28_) {
				_data_->_tmp29_ = _data_->local_folder;
				_data_->_tmp30_ = _data_->remote_folder;
				_data_->_tmp31_ = geary_imap_folder_get_properties (_data_->_tmp30_);
				_data_->_tmp32_ = _data_->_tmp31_;
				_data_->_state_ = 3;
				geary_imap_db_folder_update_folder_status (_data_->_tmp29_, _data_->_tmp32_, TRUE, _data_->cancellable, geary_imap_engine_refresh_folder_unseen_execute_ready, _data_);
				return FALSE;
				_state_3:
				geary_imap_db_folder_update_folder_status_finish (_data_->_tmp29_, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->local_folder);
					_g_object_unref0 (_data_->remote_folder);
					goto __finally0;
				}
				_data_->_tmp33_ = geary_imap_engine_account_operation_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_ACCOUNT_OPERATION, GearyImapEngineAccountOperation));
				_data_->_tmp34_ = _data_->_tmp33_;
				_data_->_tmp35_ = geary_imap_engine_folder_operation_get_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, GEARY_IMAP_ENGINE_TYPE_FOLDER_OPERATION, GearyImapEngineFolderOperation));
				_data_->_tmp36_ = _data_->_tmp35_;
				geary_imap_engine_generic_account_update_folder (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp34_, GEARY_IMAP_ENGINE_TYPE_GENERIC_ACCOUNT, GearyImapEngineGenericAccount), _data_->_tmp36_);
			}
			_g_object_unref0 (_data_->local_folder);
			_g_object_unref0 (_data_->remote_folder);
		}
		__finally0:
		{
			_data_->_tmp37_ = _data_->account;
			_data_->_tmp38_ = _data_->remote;
			geary_imap_engine_generic_account_release_account_session (_data_->_tmp37_, _data_->_tmp38_);
		}
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->remote);
			_g_object_unref0 (_data_->account);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->remote);
	}
	_g_object_unref0 (_data_->account);
	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_refresh_folder_unseen_class_init (GearyImapEngineRefreshFolderUnseenClass * klass,
                                                    gpointer klass_data)
{
	geary_imap_engine_refresh_folder_unseen_parent_class = g_type_class_peek_parent (klass);
	((GearyImapEngineAccountOperationClass *) klass)->execute = (void (*) (GearyImapEngineAccountOperation*, GCancellable*, GAsyncReadyCallback, gpointer)) geary_imap_engine_refresh_folder_unseen_real_execute;
	((GearyImapEngineAccountOperationClass *) klass)->execute_finish = (void (*) (GearyImapEngineAccountOperation*, GAsyncResult*, GError**)) geary_imap_engine_refresh_folder_unseen_execute_finish;
}

static void
geary_imap_engine_refresh_folder_unseen_instance_init (GearyImapEngineRefreshFolderUnseen * self,
                                                       gpointer klass)
{
}

/**
 * Account operation that updates a folder's unseen message count.
 *
 * This performs a IMAP STATUS on the folder, but only if it is not
 * open - if it is open it is already maintaining its unseen count.
 */
 G_GNUC_NO_INLINE static GType
geary_imap_engine_refresh_folder_unseen_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GearyImapEngineRefreshFolderUnseenClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) geary_imap_engine_refresh_folder_unseen_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GearyImapEngineRefreshFolderUnseen), 0, (GInstanceInitFunc) geary_imap_engine_refresh_folder_unseen_instance_init, NULL };
	GType geary_imap_engine_refresh_folder_unseen_type_id;
	geary_imap_engine_refresh_folder_unseen_type_id = g_type_register_static (GEARY_IMAP_ENGINE_TYPE_FOLDER_OPERATION, "GearyImapEngineRefreshFolderUnseen", &g_define_type_info, 0);
	return geary_imap_engine_refresh_folder_unseen_type_id;
}

GType
geary_imap_engine_refresh_folder_unseen_get_type (void)
{
	static gsize geary_imap_engine_refresh_folder_unseen_type_id__once = 0;
	if (g_once_init_enter (&geary_imap_engine_refresh_folder_unseen_type_id__once)) {
		GType geary_imap_engine_refresh_folder_unseen_type_id;
		geary_imap_engine_refresh_folder_unseen_type_id = geary_imap_engine_refresh_folder_unseen_get_type_once ();
		g_once_init_leave (&geary_imap_engine_refresh_folder_unseen_type_id__once, geary_imap_engine_refresh_folder_unseen_type_id);
	}
	return geary_imap_engine_refresh_folder_unseen_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

