/* application-controller.c generated by valac 0.56.19, the Vala compiler
 * generated from application-controller.vala, do not modify */

/*
 * Copyright © 2016 Software Freedom Conservancy Inc.
 * Copyright © 2016-2020 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 "geary-client-46.0.h"
#include <gee.h>
#include <gio/gio.h>
#include <glib.h>
#include <folks/folks.h>
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>

#define APPLICATION_CONTROLLER_MAX_AUTH_ATTEMPTS ((guint) 3)
#define APPLICATION_CONTROLLER_CLEANUP_CHECK_AFTER_IDLE_BACKGROUND_MINUTES ((guint) 5)
#define APPLICATION_SAVE_COMPOSER_COMMAND_DESTROY_TIMEOUT_SEC (30 * 60)
#define APPLICATION_DISCARD_COMPOSER_COMMAND_DESTROY_TIMEOUT_SEC (30 * 60)
#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define APPLICATION_TYPE_ACCOUNT_INTERFACE (application_account_interface_get_type ())
#define APPLICATION_ACCOUNT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_ACCOUNT_INTERFACE, ApplicationAccountInterface))
#define APPLICATION_IS_ACCOUNT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_ACCOUNT_INTERFACE))
#define APPLICATION_ACCOUNT_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), APPLICATION_TYPE_ACCOUNT_INTERFACE, ApplicationAccountInterfaceIface))

typedef struct _ApplicationAccountInterface ApplicationAccountInterface;
typedef struct _ApplicationAccountInterfaceIface ApplicationAccountInterfaceIface;

#define COMPOSER_TYPE_APPLICATION_INTERFACE (composer_application_interface_get_type ())
#define COMPOSER_APPLICATION_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface))
#define COMPOSER_IS_APPLICATION_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), COMPOSER_TYPE_APPLICATION_INTERFACE))
#define COMPOSER_APPLICATION_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterfaceIface))

typedef struct _ComposerApplicationInterface ComposerApplicationInterface;
typedef struct _ComposerApplicationInterfaceIface ComposerApplicationInterfaceIface;

#define APPLICATION_TYPE_CONTROLLER (application_controller_get_type ())
#define APPLICATION_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_CONTROLLER, ApplicationController))
#define APPLICATION_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_CONTROLLER, ApplicationControllerClass))
#define APPLICATION_IS_CONTROLLER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_CONTROLLER))
#define APPLICATION_IS_CONTROLLER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_CONTROLLER))
#define APPLICATION_CONTROLLER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_CONTROLLER, ApplicationControllerClass))

typedef struct _ApplicationController ApplicationController;
typedef struct _ApplicationControllerClass ApplicationControllerClass;
typedef struct _ApplicationControllerPrivate ApplicationControllerPrivate;

#define APPLICATION_TYPE_DATABASE_MANAGER (application_database_manager_get_type ())
#define APPLICATION_DATABASE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_DATABASE_MANAGER, ApplicationDatabaseManager))
#define APPLICATION_DATABASE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_DATABASE_MANAGER, ApplicationDatabaseManagerClass))
#define APPLICATION_IS_DATABASE_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_DATABASE_MANAGER))
#define APPLICATION_IS_DATABASE_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_DATABASE_MANAGER))
#define APPLICATION_DATABASE_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_DATABASE_MANAGER, ApplicationDatabaseManagerClass))

typedef struct _ApplicationDatabaseManager ApplicationDatabaseManager;
typedef struct _ApplicationDatabaseManagerClass ApplicationDatabaseManagerClass;
enum  {
	APPLICATION_CONTROLLER_0_PROPERTY,
	APPLICATION_CONTROLLER_IS_OPEN_PROPERTY,
	APPLICATION_CONTROLLER_APPLICATION_PROPERTY,
	APPLICATION_CONTROLLER_ACCOUNT_MANAGER_PROPERTY,
	APPLICATION_CONTROLLER_PLUGINS_PROPERTY,
	APPLICATION_CONTROLLER_CERTIFICATE_MANAGER_PROPERTY,
	APPLICATION_CONTROLLER_NUM_PROPERTIES
};
static GParamSpec* application_controller_properties[APPLICATION_CONTROLLER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _ApplicationControllerNewData ApplicationControllerNewData;
typedef struct _Block7Data Block7Data;
typedef struct _Block8Data Block8Data;
typedef struct _Block9Data Block9Data;
typedef struct _ApplicationControllerCloseData ApplicationControllerCloseData;
typedef struct _ApplicationControllerComposeBlankData ApplicationControllerComposeBlankData;
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _ApplicationControllerComposeWithContextData ApplicationControllerComposeWithContextData;
typedef struct _ApplicationControllerComposeMailtoData ApplicationControllerComposeMailtoData;
typedef struct _Block10Data Block10Data;
typedef struct _ApplicationControllerMarkConversationsData ApplicationControllerMarkConversationsData;

#define APPLICATION_TYPE_MARK_EMAIL_COMMAND (application_mark_email_command_get_type ())
#define APPLICATION_MARK_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_MARK_EMAIL_COMMAND, ApplicationMarkEmailCommand))
#define APPLICATION_MARK_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_MARK_EMAIL_COMMAND, ApplicationMarkEmailCommandClass))
#define APPLICATION_IS_MARK_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_MARK_EMAIL_COMMAND))
#define APPLICATION_IS_MARK_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_MARK_EMAIL_COMMAND))
#define APPLICATION_MARK_EMAIL_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_MARK_EMAIL_COMMAND, ApplicationMarkEmailCommandClass))

typedef struct _ApplicationMarkEmailCommand ApplicationMarkEmailCommand;
typedef struct _ApplicationMarkEmailCommandClass ApplicationMarkEmailCommandClass;
typedef struct _ApplicationControllerMarkMessagesData ApplicationControllerMarkMessagesData;

#define APPLICATION_TYPE_REVOKABLE_COMMAND (application_revokable_command_get_type ())
#define APPLICATION_REVOKABLE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand))
#define APPLICATION_REVOKABLE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommandClass))
#define APPLICATION_IS_REVOKABLE_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_REVOKABLE_COMMAND))
#define APPLICATION_IS_REVOKABLE_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_REVOKABLE_COMMAND))
#define APPLICATION_REVOKABLE_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommandClass))

typedef struct _ApplicationRevokableCommand ApplicationRevokableCommand;
typedef struct _ApplicationRevokableCommandClass ApplicationRevokableCommandClass;

#define APPLICATION_TYPE_MOVE_EMAIL_COMMAND (application_move_email_command_get_type ())
#define APPLICATION_MOVE_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_MOVE_EMAIL_COMMAND, ApplicationMoveEmailCommand))
#define APPLICATION_MOVE_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_MOVE_EMAIL_COMMAND, ApplicationMoveEmailCommandClass))
#define APPLICATION_IS_MOVE_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_MOVE_EMAIL_COMMAND))
#define APPLICATION_IS_MOVE_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_MOVE_EMAIL_COMMAND))
#define APPLICATION_MOVE_EMAIL_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_MOVE_EMAIL_COMMAND, ApplicationMoveEmailCommandClass))

typedef struct _ApplicationMoveEmailCommand ApplicationMoveEmailCommand;
typedef struct _ApplicationMoveEmailCommandClass ApplicationMoveEmailCommandClass;
typedef struct _ApplicationControllerMoveConversationsData ApplicationControllerMoveConversationsData;

#define APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND (application_archive_email_command_get_type ())
#define APPLICATION_ARCHIVE_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommand))
#define APPLICATION_ARCHIVE_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommandClass))
#define APPLICATION_IS_ARCHIVE_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND))
#define APPLICATION_IS_ARCHIVE_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND))
#define APPLICATION_ARCHIVE_EMAIL_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommandClass))

typedef struct _ApplicationArchiveEmailCommand ApplicationArchiveEmailCommand;
typedef struct _ApplicationArchiveEmailCommandClass ApplicationArchiveEmailCommandClass;
typedef struct _ApplicationControllerMoveConversationsSpecialData ApplicationControllerMoveConversationsSpecialData;
typedef struct _ApplicationControllerMoveMessagesSpecialData ApplicationControllerMoveMessagesSpecialData;

#define APPLICATION_TYPE_COPY_EMAIL_COMMAND (application_copy_email_command_get_type ())
#define APPLICATION_COPY_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommand))
#define APPLICATION_COPY_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommandClass))
#define APPLICATION_IS_COPY_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_COPY_EMAIL_COMMAND))
#define APPLICATION_IS_COPY_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_COPY_EMAIL_COMMAND))
#define APPLICATION_COPY_EMAIL_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommandClass))

typedef struct _ApplicationCopyEmailCommand ApplicationCopyEmailCommand;
typedef struct _ApplicationCopyEmailCommandClass ApplicationCopyEmailCommandClass;
typedef struct _ApplicationControllerCopyConversationsData ApplicationControllerCopyConversationsData;
typedef struct _ApplicationControllerDeleteConversationsData ApplicationControllerDeleteConversationsData;
typedef struct _Block11Data Block11Data;

#define APPLICATION_TYPE_DELETE_EMAIL_COMMAND (application_delete_email_command_get_type ())
#define APPLICATION_DELETE_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_DELETE_EMAIL_COMMAND, ApplicationDeleteEmailCommand))
#define APPLICATION_DELETE_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_DELETE_EMAIL_COMMAND, ApplicationDeleteEmailCommandClass))
#define APPLICATION_IS_DELETE_EMAIL_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_DELETE_EMAIL_COMMAND))
#define APPLICATION_IS_DELETE_EMAIL_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_DELETE_EMAIL_COMMAND))
#define APPLICATION_DELETE_EMAIL_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_DELETE_EMAIL_COMMAND, ApplicationDeleteEmailCommandClass))

typedef struct _ApplicationDeleteEmailCommand ApplicationDeleteEmailCommand;
typedef struct _ApplicationDeleteEmailCommandClass ApplicationDeleteEmailCommandClass;

#define APPLICATION_TYPE_CONTROLLER_COMMAND_STACK (application_controller_command_stack_get_type ())
#define APPLICATION_CONTROLLER_COMMAND_STACK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_CONTROLLER_COMMAND_STACK, ApplicationControllerCommandStack))
#define APPLICATION_CONTROLLER_COMMAND_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_CONTROLLER_COMMAND_STACK, ApplicationControllerCommandStackClass))
#define APPLICATION_IS_CONTROLLER_COMMAND_STACK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_CONTROLLER_COMMAND_STACK))
#define APPLICATION_IS_CONTROLLER_COMMAND_STACK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_CONTROLLER_COMMAND_STACK))
#define APPLICATION_CONTROLLER_COMMAND_STACK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_CONTROLLER_COMMAND_STACK, ApplicationControllerCommandStackClass))

typedef struct _ApplicationControllerCommandStack ApplicationControllerCommandStack;
typedef struct _ApplicationControllerCommandStackClass ApplicationControllerCommandStackClass;
typedef struct _ApplicationControllerDeleteMessagesData ApplicationControllerDeleteMessagesData;
typedef struct _Block12Data Block12Data;
typedef struct _Block13Data Block13Data;

#define APPLICATION_TYPE_EMPTY_FOLDER_COMMAND (application_empty_folder_command_get_type ())
#define APPLICATION_EMPTY_FOLDER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommand))
#define APPLICATION_EMPTY_FOLDER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommandClass))
#define APPLICATION_IS_EMPTY_FOLDER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_EMPTY_FOLDER_COMMAND))
#define APPLICATION_IS_EMPTY_FOLDER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_EMPTY_FOLDER_COMMAND))
#define APPLICATION_EMPTY_FOLDER_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommandClass))

typedef struct _ApplicationEmptyFolderCommand ApplicationEmptyFolderCommand;
typedef struct _ApplicationEmptyFolderCommandClass ApplicationEmptyFolderCommandClass;
typedef struct _ApplicationControllerEmptyFolderData ApplicationControllerEmptyFolderData;
typedef struct _ApplicationControllerProcessPendingComposersData ApplicationControllerProcessPendingComposersData;

#define APPLICATION_TYPE_COMPOSER_COMMAND (application_composer_command_get_type ())
#define APPLICATION_COMPOSER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand))
#define APPLICATION_COMPOSER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommandClass))
#define APPLICATION_IS_COMPOSER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_COMPOSER_COMMAND))
#define APPLICATION_IS_COMPOSER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_COMPOSER_COMMAND))
#define APPLICATION_COMPOSER_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommandClass))

typedef struct _ApplicationComposerCommand ApplicationComposerCommand;
typedef struct _ApplicationComposerCommandClass ApplicationComposerCommandClass;

#define APPLICATION_TYPE_SEND_COMPOSER_COMMAND (application_send_composer_command_get_type ())
#define APPLICATION_SEND_COMPOSER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_SEND_COMPOSER_COMMAND, ApplicationSendComposerCommand))
#define APPLICATION_SEND_COMPOSER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_SEND_COMPOSER_COMMAND, ApplicationSendComposerCommandClass))
#define APPLICATION_IS_SEND_COMPOSER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_SEND_COMPOSER_COMMAND))
#define APPLICATION_IS_SEND_COMPOSER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_SEND_COMPOSER_COMMAND))
#define APPLICATION_SEND_COMPOSER_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_SEND_COMPOSER_COMMAND, ApplicationSendComposerCommandClass))

typedef struct _ApplicationSendComposerCommand ApplicationSendComposerCommand;
typedef struct _ApplicationSendComposerCommandClass ApplicationSendComposerCommandClass;
typedef struct _ApplicationControllerSendComposedEmailData ApplicationControllerSendComposedEmailData;

#define APPLICATION_TYPE_SAVE_COMPOSER_COMMAND (application_save_composer_command_get_type ())
#define APPLICATION_SAVE_COMPOSER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, ApplicationSaveComposerCommand))
#define APPLICATION_SAVE_COMPOSER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, ApplicationSaveComposerCommandClass))
#define APPLICATION_IS_SAVE_COMPOSER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_SAVE_COMPOSER_COMMAND))
#define APPLICATION_IS_SAVE_COMPOSER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_SAVE_COMPOSER_COMMAND))
#define APPLICATION_SAVE_COMPOSER_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, ApplicationSaveComposerCommandClass))

typedef struct _ApplicationSaveComposerCommand ApplicationSaveComposerCommand;
typedef struct _ApplicationSaveComposerCommandClass ApplicationSaveComposerCommandClass;
typedef struct _ApplicationControllerSaveComposedEmailData ApplicationControllerSaveComposedEmailData;

#define APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND (application_discard_composer_command_get_type ())
#define APPLICATION_DISCARD_COMPOSER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, ApplicationDiscardComposerCommand))
#define APPLICATION_DISCARD_COMPOSER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, ApplicationDiscardComposerCommandClass))
#define APPLICATION_IS_DISCARD_COMPOSER_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND))
#define APPLICATION_IS_DISCARD_COMPOSER_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND))
#define APPLICATION_DISCARD_COMPOSER_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, ApplicationDiscardComposerCommandClass))

typedef struct _ApplicationDiscardComposerCommand ApplicationDiscardComposerCommand;
typedef struct _ApplicationDiscardComposerCommandClass ApplicationDiscardComposerCommandClass;
typedef struct _ApplicationControllerDiscardComposedEmailData ApplicationControllerDiscardComposedEmailData;
typedef struct _ApplicationControllerExpungeAccountsData ApplicationControllerExpungeAccountsData;
typedef struct _ApplicationControllerOpenAccountData ApplicationControllerOpenAccountData;
typedef struct _ApplicationControllerRemoveAccountData ApplicationControllerRemoveAccountData;
typedef struct _ApplicationControllerCloseAccountData ApplicationControllerCloseAccountData;
#define _password_dialog_unref0(var) ((var == NULL) ? NULL : (var = (password_dialog_unref (var), NULL)))
typedef struct _ApplicationControllerPromptForPasswordData ApplicationControllerPromptForPasswordData;
typedef struct _ApplicationControllerPromptUntrustedHostData ApplicationControllerPromptUntrustedHostData;

#define TYPE_ALERT_DIALOG (alert_dialog_get_type ())
#define ALERT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ALERT_DIALOG, AlertDialog))
#define ALERT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ALERT_DIALOG, AlertDialogClass))
#define IS_ALERT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ALERT_DIALOG))
#define IS_ALERT_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ALERT_DIALOG))
#define ALERT_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ALERT_DIALOG, AlertDialogClass))

typedef struct _AlertDialog AlertDialog;
typedef struct _AlertDialogClass AlertDialogClass;

#define TYPE_QUESTION_DIALOG (question_dialog_get_type ())
#define QUESTION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_QUESTION_DIALOG, QuestionDialog))
#define QUESTION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_QUESTION_DIALOG, QuestionDialogClass))
#define IS_QUESTION_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_QUESTION_DIALOG))
#define IS_QUESTION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_QUESTION_DIALOG))
#define QUESTION_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_QUESTION_DIALOG, QuestionDialogClass))

typedef struct _QuestionDialog QuestionDialog;
typedef struct _QuestionDialogClass QuestionDialogClass;

#define TYPE_ERROR_DIALOG (error_dialog_get_type ())
#define ERROR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_ERROR_DIALOG, ErrorDialog))
#define ERROR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_ERROR_DIALOG, ErrorDialogClass))
#define IS_ERROR_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_ERROR_DIALOG))
#define IS_ERROR_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_ERROR_DIALOG))
#define ERROR_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_ERROR_DIALOG, ErrorDialogClass))

typedef struct _ErrorDialog ErrorDialog;
typedef struct _ErrorDialogClass ErrorDialogClass;
typedef struct _ApplicationControllerAccountDatabaseErrorAsyncData ApplicationControllerAccountDatabaseErrorAsyncData;

#define APPLICATION_TYPE_NOTIFICATION_PLUGIN_CONTEXT (application_notification_plugin_context_get_type ())
#define APPLICATION_NOTIFICATION_PLUGIN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_NOTIFICATION_PLUGIN_CONTEXT, ApplicationNotificationPluginContext))
#define APPLICATION_NOTIFICATION_PLUGIN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_NOTIFICATION_PLUGIN_CONTEXT, ApplicationNotificationPluginContextClass))
#define APPLICATION_IS_NOTIFICATION_PLUGIN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_NOTIFICATION_PLUGIN_CONTEXT))
#define APPLICATION_IS_NOTIFICATION_PLUGIN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_NOTIFICATION_PLUGIN_CONTEXT))
#define APPLICATION_NOTIFICATION_PLUGIN_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_NOTIFICATION_PLUGIN_CONTEXT, ApplicationNotificationPluginContextClass))

typedef struct _ApplicationNotificationPluginContext ApplicationNotificationPluginContext;
typedef struct _ApplicationNotificationPluginContextClass ApplicationNotificationPluginContextClass;

#define APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT (application_email_plugin_context_get_type ())
#define APPLICATION_EMAIL_PLUGIN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT, ApplicationEmailPluginContext))
#define APPLICATION_EMAIL_PLUGIN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT, ApplicationEmailPluginContextClass))
#define APPLICATION_IS_EMAIL_PLUGIN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT))
#define APPLICATION_IS_EMAIL_PLUGIN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT))
#define APPLICATION_EMAIL_PLUGIN_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT, ApplicationEmailPluginContextClass))

typedef struct _ApplicationEmailPluginContext ApplicationEmailPluginContext;
typedef struct _ApplicationEmailPluginContextClass ApplicationEmailPluginContextClass;
typedef struct _ApplicationControllerDoBackgroundStorageCleanupData ApplicationControllerDoBackgroundStorageCleanupData;
enum  {
	APPLICATION_CONTROLLER_COMPOSER_REGISTERED_SIGNAL,
	APPLICATION_CONTROLLER_COMPOSER_DEREGISTERED_SIGNAL,
	APPLICATION_CONTROLLER_NUM_SIGNALS
};
static guint application_controller_signals[APPLICATION_CONTROLLER_NUM_SIGNALS] = {0};
typedef struct _ApplicationControllerCommandStackPrivate ApplicationControllerCommandStackPrivate;
enum  {
	APPLICATION_CONTROLLER_COMMAND_STACK_0_PROPERTY,
	APPLICATION_CONTROLLER_COMMAND_STACK_NUM_PROPERTIES
};
static GParamSpec* application_controller_command_stack_properties[APPLICATION_CONTROLLER_COMMAND_STACK_NUM_PROPERTIES];
typedef struct _ApplicationControllerCommandStackExecuteData ApplicationControllerCommandStackExecuteData;
typedef struct _ApplicationControllerCommandStackUndoData ApplicationControllerCommandStackUndoData;
typedef struct _ApplicationControllerCommandStackRedoData ApplicationControllerCommandStackRedoData;
enum  {
	APPLICATION_EMAIL_COMMAND_0_PROPERTY,
	APPLICATION_EMAIL_COMMAND_LOCATION_PROPERTY,
	APPLICATION_EMAIL_COMMAND_CONVERSATIONS_PROPERTY,
	APPLICATION_EMAIL_COMMAND_EMAIL_PROPERTY,
	APPLICATION_EMAIL_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_email_command_properties[APPLICATION_EMAIL_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationMarkEmailCommandPrivate ApplicationMarkEmailCommandPrivate;
enum  {
	APPLICATION_MARK_EMAIL_COMMAND_0_PROPERTY,
	APPLICATION_MARK_EMAIL_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_mark_email_command_properties[APPLICATION_MARK_EMAIL_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationMarkEmailCommandExecuteData ApplicationMarkEmailCommandExecuteData;
typedef struct _ApplicationMarkEmailCommandUndoData ApplicationMarkEmailCommandUndoData;
typedef struct _ApplicationRevokableCommandPrivate ApplicationRevokableCommandPrivate;
enum  {
	APPLICATION_REVOKABLE_COMMAND_0_PROPERTY,
	APPLICATION_REVOKABLE_COMMAND_CAN_UNDO_PROPERTY,
	APPLICATION_REVOKABLE_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_revokable_command_properties[APPLICATION_REVOKABLE_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationRevokableCommandExecuteData ApplicationRevokableCommandExecuteData;
typedef struct _ApplicationRevokableCommandUndoData ApplicationRevokableCommandUndoData;
typedef struct _ApplicationMoveEmailCommandPrivate ApplicationMoveEmailCommandPrivate;
enum  {
	APPLICATION_MOVE_EMAIL_COMMAND_0_PROPERTY,
	APPLICATION_MOVE_EMAIL_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_move_email_command_properties[APPLICATION_MOVE_EMAIL_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationMoveEmailCommandExecuteImplData ApplicationMoveEmailCommandExecuteImplData;
typedef struct _ApplicationArchiveEmailCommandPrivate ApplicationArchiveEmailCommandPrivate;
enum  {
	APPLICATION_ARCHIVE_EMAIL_COMMAND_0_PROPERTY,
	APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_LOCATION_PROPERTY,
	APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_CONVERSATIONS_PROPERTY,
	APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_EMAIL_PROPERTY,
	APPLICATION_ARCHIVE_EMAIL_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_archive_email_command_properties[APPLICATION_ARCHIVE_EMAIL_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationArchiveEmailCommandExecuteImplData ApplicationArchiveEmailCommandExecuteImplData;
typedef struct _ApplicationCopyEmailCommandPrivate ApplicationCopyEmailCommandPrivate;
enum  {
	APPLICATION_COPY_EMAIL_COMMAND_0_PROPERTY,
	APPLICATION_COPY_EMAIL_COMMAND_CAN_UNDO_PROPERTY,
	APPLICATION_COPY_EMAIL_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_copy_email_command_properties[APPLICATION_COPY_EMAIL_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationCopyEmailCommandExecuteData ApplicationCopyEmailCommandExecuteData;
typedef struct _ApplicationCopyEmailCommandUndoData ApplicationCopyEmailCommandUndoData;
typedef struct _ApplicationDeleteEmailCommandPrivate ApplicationDeleteEmailCommandPrivate;
enum  {
	APPLICATION_DELETE_EMAIL_COMMAND_0_PROPERTY,
	APPLICATION_DELETE_EMAIL_COMMAND_CAN_UNDO_PROPERTY,
	APPLICATION_DELETE_EMAIL_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_delete_email_command_properties[APPLICATION_DELETE_EMAIL_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationDeleteEmailCommandExecuteData ApplicationDeleteEmailCommandExecuteData;
typedef struct _ApplicationDeleteEmailCommandUndoData ApplicationDeleteEmailCommandUndoData;
typedef struct _ApplicationEmptyFolderCommandPrivate ApplicationEmptyFolderCommandPrivate;
enum  {
	APPLICATION_EMPTY_FOLDER_COMMAND_0_PROPERTY,
	APPLICATION_EMPTY_FOLDER_COMMAND_CAN_UNDO_PROPERTY,
	APPLICATION_EMPTY_FOLDER_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_empty_folder_command_properties[APPLICATION_EMPTY_FOLDER_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationEmptyFolderCommandExecuteData ApplicationEmptyFolderCommandExecuteData;
typedef struct _ApplicationEmptyFolderCommandUndoData ApplicationEmptyFolderCommandUndoData;
typedef struct _ApplicationComposerCommandPrivate ApplicationComposerCommandPrivate;
enum  {
	APPLICATION_COMPOSER_COMMAND_0_PROPERTY,
	APPLICATION_COMPOSER_COMMAND_CAN_REDO_PROPERTY,
	APPLICATION_COMPOSER_COMMAND_COMPOSER_PROPERTY,
	APPLICATION_COMPOSER_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_composer_command_properties[APPLICATION_COMPOSER_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationSendComposerCommandPrivate ApplicationSendComposerCommandPrivate;
enum  {
	APPLICATION_SEND_COMPOSER_COMMAND_0_PROPERTY,
	APPLICATION_SEND_COMPOSER_COMMAND_CAN_UNDO_PROPERTY,
	APPLICATION_SEND_COMPOSER_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_send_composer_command_properties[APPLICATION_SEND_COMPOSER_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationSendComposerCommandExecuteData ApplicationSendComposerCommandExecuteData;
typedef struct _ApplicationSendComposerCommandUndoData ApplicationSendComposerCommandUndoData;
typedef struct _ApplicationSaveComposerCommandPrivate ApplicationSaveComposerCommandPrivate;
enum  {
	APPLICATION_SAVE_COMPOSER_COMMAND_0_PROPERTY,
	APPLICATION_SAVE_COMPOSER_COMMAND_CAN_REDO_PROPERTY,
	APPLICATION_SAVE_COMPOSER_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_save_composer_command_properties[APPLICATION_SAVE_COMPOSER_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationSaveComposerCommandExecuteData ApplicationSaveComposerCommandExecuteData;
typedef struct _ApplicationSaveComposerCommandUndoData ApplicationSaveComposerCommandUndoData;
typedef struct _ApplicationDiscardComposerCommandPrivate ApplicationDiscardComposerCommandPrivate;
enum  {
	APPLICATION_DISCARD_COMPOSER_COMMAND_0_PROPERTY,
	APPLICATION_DISCARD_COMPOSER_COMMAND_CAN_REDO_PROPERTY,
	APPLICATION_DISCARD_COMPOSER_COMMAND_NUM_PROPERTIES
};
static GParamSpec* application_discard_composer_command_properties[APPLICATION_DISCARD_COMPOSER_COMMAND_NUM_PROPERTIES];
typedef struct _ApplicationDiscardComposerCommandExecuteData ApplicationDiscardComposerCommandExecuteData;
typedef struct _ApplicationDiscardComposerCommandUndoData ApplicationDiscardComposerCommandUndoData;

struct _ApplicationAccountInterfaceIface {
	GTypeInterface parent_iface;
	ApplicationAccountContext* (*get_context_for_account) (ApplicationAccountInterface* self, GearyAccountInformation* account);
	GeeCollection* (*get_account_contexts) (ApplicationAccountInterface* self);
};

struct _ComposerApplicationInterfaceIface {
	GTypeInterface parent_iface;
	void (*report_problem) (ComposerApplicationInterface* self, GearyProblemReport* report);
	void (*send_composed_email) (ComposerApplicationInterface* self, ComposerWidget* composer, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*send_composed_email_finish) (ComposerApplicationInterface* self, GAsyncResult* _res_);
	void (*save_composed_email) (ComposerApplicationInterface* self, ComposerWidget* composer, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*save_composed_email_finish) (ComposerApplicationInterface* self, GAsyncResult* _res_);
	void (*discard_composed_email) (ComposerApplicationInterface* self, ComposerWidget* composer, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*discard_composed_email_finish) (ComposerApplicationInterface* self, GAsyncResult* _res_);
};

struct _ApplicationController {
	GearyBaseObject parent_instance;
	ApplicationControllerPrivate * priv;
};

struct _ApplicationControllerClass {
	GearyBaseObjectClass parent_class;
};

struct _ApplicationControllerPrivate {
	ApplicationClient* _application;
	AccountsManager* _account_manager;
	ApplicationPluginManager* _plugins;
	ApplicationCertificateManager* _certificate_manager;
	GeeMap* accounts;
	gboolean is_loading_accounts;
	GCancellable* controller_open;
	ApplicationDatabaseManager* database_manager;
	FolksIndividualAggregator* folks;
	GeeCollection* composer_widgets;
	GeeList* pending_mailtos;
	GearyTimeoutManager* all_windows_backgrounded_timeout;
	GCancellable* storage_cleanup_cancellable;
};

struct _ApplicationControllerNewData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GType object_type;
	ApplicationController* self;
	ApplicationClient* application;
	GCancellable* cancellable;
	GCancellable* _tmp0_;
	GFile* config_dir;
	GFile* _tmp1_;
	GFile* data_dir;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	ApplicationDatabaseManager* _tmp5_;
	ApplicationClient* _tmp6_;
	ApplicationConfiguration* _tmp7_;
	ApplicationConfiguration* _tmp8_;
	ApplicationClient* _tmp9_;
	GFile* _tmp10_;
	GFile* _tmp11_;
	ApplicationClient* _tmp12_;
	GFile* _tmp13_;
	GFile* _tmp14_;
	GFile* _tmp15_;
	GFile* _tmp16_;
	GFile* _tmp17_;
	GearyTimeoutManager* _tmp18_;
	FolksIndividualAggregator* _tmp19_;
	FolksIndividualAggregator* _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp22_;
	FolksIndividualAggregator* _tmp23_;
	ApplicationPluginManager* _tmp24_;
	ApplicationClient* _tmp25_;
	ApplicationClient* _tmp26_;
	ApplicationConfiguration* _tmp27_;
	ApplicationConfiguration* _tmp28_;
	ApplicationClient* _tmp29_;
	GFile* _tmp30_;
	GFile* _tmp31_;
	ApplicationPluginManager* _tmp32_;
	ApplicationPluginManager* _tmp33_;
	GFile* _tmp34_;
	GFile* _tmp35_;
	GFile* _tmp36_;
	gint _tmp37_;
	GFile** _tmp38_;
	GFile** _tmp39_;
	gint _tmp39__length1;
	GFile* _tmp40_;
	GFile* _tmp41_;
	GFile* _tmp42_;
	GFile* _tmp43_;
	ApplicationCertificateManager* _tmp44_;
	ApplicationCertificateManager* _tmp45_;
	GFile* _tmp46_;
	GFile* _tmp47_;
	GFile* _tmp48_;
	SecretMediator* libsecret;
	ApplicationClient* _tmp49_;
	SecretMediator* _tmp50_;
	GearyEngine* _tmp51_;
	GearyEngine* _tmp52_;
	SecretMediator* _tmp53_;
	GFile* _tmp54_;
	GFile* _tmp55_;
	AccountsManager* _tmp56_;
	AccountsManager* _tmp57_;
	AccountsManager* _tmp58_;
	AccountsManager* _tmp59_;
	AccountsManager* _tmp60_;
	AccountsManager* _tmp61_;
	AccountsManager* _tmp62_;
	AccountsManager* _tmp63_;
	GError* _inner_error0_;
};

struct _Block7Data {
	int _ref_count_;
	ApplicationController* self;
	GearyNonblockingCountingSemaphore* composer_barrier;
	GearyNonblockingCountingSemaphore* window_barrier;
	GearyNonblockingCountingSemaphore* account_barrier;
	gpointer _async_data_;
};

struct _Block8Data {
	int _ref_count_;
	Block7Data * _data7_;
	ComposerWidget* composer;
};

struct _Block9Data {
	int _ref_count_;
	Block7Data * _data7_;
	ApplicationMainWindow* window;
};

struct _ApplicationControllerCloseData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	Block7Data* _data7_;
	AccountsManager* _tmp0_;
	guint _tmp1_;
	AccountsManager* _tmp2_;
	guint _tmp3_;
	AccountsManager* _tmp4_;
	guint _tmp5_;
	ApplicationClient* _tmp6_;
	GearyEngine* _tmp7_;
	GearyEngine* _tmp8_;
	guint _tmp9_;
	GeeIterator* _window_it;
	ApplicationClient* _tmp10_;
	GeeCollection* _tmp11_;
	GeeCollection* _tmp12_;
	GeeIterator* _tmp13_;
	GeeIterator* _tmp14_;
	GeeIterator* _tmp15_;
	ApplicationMainWindow* window;
	GeeIterator* _tmp16_;
	gpointer _tmp17_;
	ApplicationMainWindow* _tmp18_;
	GearyNonblockingCountingSemaphore* _tmp19_;
	GeeLinkedList* composers;
	GeeLinkedList* _tmp20_;
	GeeLinkedList* _tmp21_;
	GeeCollection* _tmp22_;
	GeeLinkedList* _composer_list;
	GeeLinkedList* _tmp23_;
	gint _composer_size;
	GeeLinkedList* _tmp24_;
	gint _tmp25_;
	gint _tmp26_;
	gint _composer_index;
	Block8Data* _data8_;
	gint _tmp27_;
	gint _tmp28_;
	GeeLinkedList* _tmp29_;
	gpointer _tmp30_;
	ComposerWidget* _tmp31_;
	ComposerWidgetPresentationMode _tmp32_;
	ComposerWidgetPresentationMode _tmp33_;
	GearyNonblockingCountingSemaphore* _tmp34_;
	ComposerWidget* _tmp35_;
	GearyNonblockingCountingSemaphore* _tmp36_;
	GError* err;
	GError* _tmp37_;
	const gchar* _tmp38_;
	GCancellable* _tmp39_;
	GearyNonblockingCountingSemaphore* _tmp40_;
	GeeIterator* _vala1__window_it;
	ApplicationClient* _tmp41_;
	GeeCollection* _tmp42_;
	GeeCollection* _tmp43_;
	GeeIterator* _tmp44_;
	GeeIterator* _tmp45_;
	Block9Data* _data9_;
	GeeIterator* _tmp46_;
	GeeIterator* _tmp47_;
	gpointer _tmp48_;
	GearyNonblockingCountingSemaphore* _tmp49_;
	ApplicationMainWindow* _tmp50_;
	GearyNonblockingCountingSemaphore* _tmp51_;
	GError* _vala1_err;
	GError* _tmp52_;
	const gchar* _tmp53_;
	ApplicationPluginManager* _tmp54_;
	GError* _vala2_err;
	GError* _tmp55_;
	const gchar* _tmp56_;
	GeeList* _tmp57_;
	GeeCollection* _tmp58_;
	GeeLinkedList* closing_accounts;
	GeeLinkedList* _tmp59_;
	GeeLinkedList* _tmp60_;
	GeeMap* _tmp61_;
	GeeCollection* _tmp62_;
	GeeCollection* _tmp63_;
	GeeCollection* _tmp64_;
	GearyNonblockingCountingSemaphore* _tmp65_;
	GeeLinkedList* _context_list;
	GeeLinkedList* _tmp66_;
	gint _context_size;
	GeeLinkedList* _tmp67_;
	gint _tmp68_;
	gint _tmp69_;
	gint _context_index;
	gint _tmp70_;
	gint _tmp71_;
	ApplicationAccountContext* context;
	GeeLinkedList* _tmp72_;
	gpointer _tmp73_;
	GearyNonblockingCountingSemaphore* _tmp74_;
	ApplicationAccountContext* _tmp75_;
	GearyAccount* _tmp76_;
	GearyAccount* _tmp77_;
	GearyAccountInformation* _tmp78_;
	GearyAccountInformation* _tmp79_;
	GearyNonblockingCountingSemaphore* _tmp80_;
	GError* _vala3_err;
	GError* _tmp81_;
	const gchar* _tmp82_;
	GError* _inner_error0_;
};

struct _ApplicationControllerComposeBlankData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	ApplicationAccountContext* send_context;
	GearyRFC822MailboxAddress* to;
	ComposerWidget* result;
	ApplicationMainWindow* main;
	ApplicationClient* _tmp0_;
	ApplicationMainWindow* _tmp1_;
	ComposerWidget* composer;
	ApplicationMainWindow* _tmp2_;
	ConversationViewer* _tmp3_;
	ConversationViewer* _tmp4_;
	ComposerWidget* _tmp5_;
	ComposerWidget* _tmp6_;
	ComposerWidget* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	ComposerWidget* _tmp11_;
	ComposerWidget* _tmp12_;
	ComposerWidgetPresentationMode _tmp13_;
	ComposerWidgetPresentationMode _tmp14_;
	ComposerWidget* _tmp15_;
	gboolean _tmp16_;
	gboolean _tmp17_;
	ComposerWidget* _tmp18_;
	ApplicationAccountContext* _tmp19_;
	ApplicationAccountContext* _tmp20_;
	ApplicationClient* _tmp21_;
	ApplicationConfiguration* _tmp22_;
	ApplicationConfiguration* _tmp23_;
	ComposerWidget* _tmp24_;
	ComposerWidget* _tmp25_;
	ComposerWidget* _tmp26_;
	GError* err;
	GError* _tmp27_;
	GearyProblemReport* _tmp28_;
	GearyProblemReport* _tmp29_;
	GError* _inner_error0_;
};

struct _ApplicationControllerComposeWithContextData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	ApplicationAccountContext* send_context;
	ComposerWidgetContextType type;
	GearyEmail* context;
	gchar* quote;
	ComposerWidget* result;
	ApplicationMainWindow* main;
	ApplicationClient* _tmp0_;
	ApplicationMainWindow* _tmp1_;
	ComposerWidget* composer;
	GeeIterator* _existing_it;
	GeeCollection* _tmp2_;
	GeeIterator* _tmp3_;
	GeeIterator* _tmp4_;
	ComposerWidget* existing;
	GeeIterator* _tmp5_;
	gpointer _tmp6_;
	gboolean _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	gboolean _tmp10_;
	ComposerWidget* _tmp11_;
	ComposerWidgetPresentationMode _tmp12_;
	ComposerWidgetPresentationMode _tmp13_;
	ComposerWidget* _tmp14_;
	ComposerWidgetPresentationMode _tmp15_;
	ComposerWidgetPresentationMode _tmp16_;
	ComposerWidget* _tmp17_;
	ApplicationAccountContext* _tmp18_;
	ApplicationAccountContext* _tmp19_;
	ComposerWidget* _tmp20_;
	GearyEmailIdentifier* _tmp21_;
	GearyEmailIdentifier* _tmp22_;
	ComposerWidget* _tmp23_;
	GearyEmailIdentifier* _tmp24_;
	GearyEmailIdentifier* _tmp25_;
	GearyEmailIdentifier* _tmp26_;
	GearyEmailIdentifier* _tmp27_;
	ComposerWidget* _tmp28_;
	ComposerWidget* _tmp29_;
	GeeIterator* _vala1__existing_it;
	GeeCollection* _tmp30_;
	GeeIterator* _tmp31_;
	GeeIterator* _tmp32_;
	ComposerWidget* _vala1_existing;
	GeeIterator* _tmp33_;
	gpointer _tmp34_;
	gboolean _tmp35_;
	gboolean _tmp36_;
	gboolean _tmp37_;
	ComposerWidget* _tmp38_;
	GtkWidget* _tmp39_;
	ApplicationMainWindow* _tmp40_;
	gboolean _tmp41_;
	ComposerWidget* _tmp42_;
	ComposerWidgetPresentationMode _tmp43_;
	ComposerWidgetPresentationMode _tmp44_;
	ComposerWidget* _tmp45_;
	ComposerWidgetPresentationMode _tmp46_;
	ComposerWidgetPresentationMode _tmp47_;
	ComposerWidget* _tmp48_;
	ApplicationAccountContext* _tmp49_;
	ApplicationAccountContext* _tmp50_;
	gboolean _tmp51_;
	ComposerWidget* _tmp52_;
	GeeSet* _tmp53_;
	GeeSet* _tmp54_;
	GearyEmailIdentifier* _tmp55_;
	GearyEmailIdentifier* _tmp56_;
	gboolean _tmp57_;
	ComposerWidget* _tmp58_;
	ComposerWidget* _tmp59_;
	ComposerWidget* _tmp60_;
	GError* _error_;
	GError* _tmp61_;
	GearyProblemReport* _tmp62_;
	GearyProblemReport* _tmp63_;
	gboolean _tmp64_;
	ComposerWidget* _tmp65_;
	ApplicationMainWindow* _tmp66_;
	ComposerWidget* _tmp67_;
	ApplicationClient* _tmp68_;
	ApplicationConfiguration* _tmp69_;
	ApplicationConfiguration* _tmp70_;
	ComposerWidget* _tmp71_;
	ComposerWidget* _tmp72_;
	ComposerWidget* _tmp73_;
	GError* err;
	GError* _tmp74_;
	GearyProblemReport* _tmp75_;
	GearyProblemReport* _tmp76_;
	GError* _inner_error0_;
};

struct _ApplicationControllerComposeMailtoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	gchar* mailto;
	ApplicationMainWindow* window;
	ApplicationClient* _tmp0_;
	ApplicationMainWindow* _tmp1_;
	ApplicationMainWindow* _tmp2_;
	ApplicationMainWindow* _tmp3_;
	gboolean _tmp4_;
	ApplicationMainWindow* _tmp5_;
	ApplicationMainWindow* _tmp6_;
	GearyAccount* _tmp7_;
	GearyAccount* _tmp8_;
	ApplicationAccountContext* context;
	GeeMap* _tmp9_;
	ApplicationMainWindow* _tmp10_;
	GearyAccount* _tmp11_;
	GearyAccount* _tmp12_;
	GearyAccountInformation* _tmp13_;
	GearyAccountInformation* _tmp14_;
	gpointer _tmp15_;
	ApplicationAccountContext* _tmp16_;
	ComposerWidget* composer;
	ApplicationClient* _tmp17_;
	ApplicationConfiguration* _tmp18_;
	ApplicationConfiguration* _tmp19_;
	ApplicationAccountContext* _tmp20_;
	ComposerWidget* _tmp21_;
	ComposerWidget* _tmp22_;
	ComposerWidget* _tmp23_;
	ComposerWidget* _tmp24_;
	GError* err;
	GError* _tmp25_;
	GearyProblemReport* _tmp26_;
	GearyProblemReport* _tmp27_;
	GeeList* _tmp28_;
	GError* _inner_error0_;
};

struct _Block10Data {
	int _ref_count_;
	ApplicationController* self;
	gboolean prefer_adding;
	gpointer _async_data_;
};

struct _ApplicationControllerMarkConversationsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolder* location;
	GeeCollection* conversations;
	GearyNamedFlag* flag;
	gboolean prefer_adding;
	Block10Data* _data10_;
	GearyIterable* selecting;
	GearyIterable* _tmp0_;
	GearyEmailFlags* flags;
	GearyEmailFlags* _tmp1_;
	GearyNamedFlag* _tmp2_;
	GearyNamedFlag* _tmp3_;
	GearyNamedFlag* _tmp4_;
	gboolean _tmp5_;
	GearyIterable* _tmp6_;
	GearyIterable* _tmp7_;
	GearyEmailFlags* _tmp8_;
	GearyNamedFlag* _tmp9_;
	GearyNamedFlag* _tmp10_;
	GearyNamedFlag* _tmp11_;
	GearyNamedFlag* _tmp12_;
	GearyNamedFlag* _tmp13_;
	GearyNamedFlag* _tmp14_;
	gboolean _tmp15_;
	GearyIterable* _tmp16_;
	GearyIterable* _tmp17_;
	GearyEmailFlags* _tmp18_;
	GearyNamedFlag* _tmp19_;
	GearyNamedFlag* _tmp20_;
	GearyNamedFlag* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	GError* _tmp24_;
	GError* _tmp25_;
	GeeCollection* messages;
	GeeCollection* selected;
	GearyIterable* _tmp26_;
	GeeLinkedList* _tmp27_;
	gboolean do_add;
	GeeCollection* _tmp28_;
	gboolean _tmp29_;
	gboolean _tmp30_;
	GeeCollection* _tmp31_;
	gboolean _tmp32_;
	gboolean _tmp33_;
	GeeCollection* _tmp34_;
	GeeCollection* _tmp35_;
	GearyIterable* _tmp36_;
	GearyIterable* _tmp37_;
	GearyIterable* _tmp38_;
	GearyIterable* _tmp39_;
	GeeLinkedList* _tmp40_;
	GeeLinkedList* _tmp41_;
	GeeIterator* _convo_it;
	GeeCollection* _tmp42_;
	GeeIterator* _tmp43_;
	GeeIterator* _tmp44_;
	GearyAppConversation* convo;
	GeeIterator* _tmp45_;
	gpointer _tmp46_;
	GeeList* _email_list;
	GearyAppConversation* _tmp47_;
	GeeList* _tmp48_;
	gint _email_size;
	GeeList* _tmp49_;
	gint _tmp50_;
	gint _tmp51_;
	gint _email_index;
	gint _tmp52_;
	gint _tmp53_;
	GearyEmail* email;
	GeeList* _tmp54_;
	gpointer _tmp55_;
	gboolean _tmp56_;
	GearyEmail* _tmp57_;
	GearyEmailFlags* _tmp58_;
	GearyEmailFlags* _tmp59_;
	GearyEmail* _tmp60_;
	GearyEmailFlags* _tmp61_;
	GearyEmailFlags* _tmp62_;
	GeeCollection* _tmp63_;
	GearyEmail* _tmp64_;
	GearyEmailIdentifier* _tmp65_;
	GearyEmailIdentifier* _tmp66_;
	GearyEmailFlags* _tmp67_;
	GearyEmailFlags* _tmp68_;
	GearyEmailFlags* _tmp69_;
	GearyEmailFlags* _tmp70_;
	GeeCollection* _tmp71_;
	GError* _inner_error0_;
};

struct _ApplicationControllerMarkMessagesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolder* location;
	GeeCollection* conversations;
	GeeCollection* messages;
	GearyEmailFlags* to_add;
	GearyEmailFlags* to_remove;
	ApplicationAccountContext* context;
	GeeMap* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	gpointer _tmp5_;
	ApplicationAccountContext* _tmp6_;
	ApplicationAccountContext* _tmp7_;
	ApplicationCommandStack* _tmp8_;
	ApplicationCommandStack* _tmp9_;
	ApplicationAccountContext* _tmp10_;
	GearyAppEmailStore* _tmp11_;
	GearyAppEmailStore* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	ApplicationMarkEmailCommand* _tmp17_;
	ApplicationMarkEmailCommand* _tmp18_;
	ApplicationAccountContext* _tmp19_;
	GCancellable* _tmp20_;
	GCancellable* _tmp21_;
	GError* _inner_error0_;
};

struct _ApplicationControllerMoveConversationsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolderSupportMove* source;
	GearyFolder* destination;
	GeeCollection* conversations;
	ApplicationAccountContext* context;
	GeeMap* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	gpointer _tmp5_;
	ApplicationAccountContext* _tmp6_;
	ApplicationAccountContext* _tmp7_;
	ApplicationCommandStack* _tmp8_;
	ApplicationCommandStack* _tmp9_;
	GeeCollection* _tmp10_;
	GeeCollection* _tmp11_;
	gint _tmp12_;
	gint _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gint _tmp18_;
	gint _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	ApplicationMoveEmailCommand* _tmp24_;
	ApplicationMoveEmailCommand* _tmp25_;
	ApplicationAccountContext* _tmp26_;
	GCancellable* _tmp27_;
	GCancellable* _tmp28_;
	GError* _inner_error0_;
};

struct _ApplicationControllerMoveConversationsSpecialData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolder* source;
	GearyFolderSpecialUse destination;
	GeeCollection* conversations;
	ApplicationAccountContext* context;
	GeeMap* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	gpointer _tmp5_;
	ApplicationAccountContext* _tmp6_;
	ApplicationCommand* command;
	GeeCollection* messages;
	GeeCollection* _tmp7_;
	gchar* undone_tooltip;
	GeeCollection* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	GearyFolderSupportArchive* archive_source;
	GearyFolderSupportArchive* _tmp15_;
	GearyFolderSupportArchive* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	GError* _tmp19_;
	GError* _tmp20_;
	GearyFolderSupportArchive* _tmp21_;
	GeeCollection* _tmp22_;
	GeeCollection* _tmp23_;
	gint _tmp24_;
	gint _tmp25_;
	const gchar* _tmp26_;
	ApplicationArchiveEmailCommand* _tmp27_;
	GearyFolderSupportMove* move_source;
	GearyFolderSupportMove* _tmp28_;
	GearyFolderSupportMove* _tmp29_;
	gchar* _tmp30_;
	gchar* _tmp31_;
	GError* _tmp32_;
	GError* _tmp33_;
	GearyFolder* dest;
	GearyAccount* _tmp34_;
	GearyAccount* _tmp35_;
	GearyFolder* _tmp36_;
	GearyFolder* _tmp37_;
	GEnumValue* _tmp38_;
	GError* _tmp39_;
	GearyFolderSupportMove* _tmp40_;
	GearyFolder* _tmp41_;
	GeeCollection* _tmp42_;
	GeeCollection* _tmp43_;
	gint _tmp44_;
	gint _tmp45_;
	GearyFolder* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	gchar* _tmp49_;
	gchar* _tmp50_;
	const gchar* _tmp51_;
	ApplicationMoveEmailCommand* _tmp52_;
	ApplicationAccountContext* _tmp53_;
	ApplicationCommandStack* _tmp54_;
	ApplicationCommandStack* _tmp55_;
	ApplicationCommand* _tmp56_;
	ApplicationAccountContext* _tmp57_;
	GCancellable* _tmp58_;
	GCancellable* _tmp59_;
	GError* _inner_error0_;
};

struct _ApplicationControllerMoveMessagesSpecialData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolder* source;
	GearyFolderSpecialUse destination;
	GeeCollection* conversations;
	GeeCollection* messages;
	ApplicationAccountContext* context;
	GeeMap* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	gpointer _tmp5_;
	ApplicationAccountContext* _tmp6_;
	ApplicationCommand* command;
	gchar* undone_tooltip;
	gint _tmp7_;
	gint _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	GearyFolderSupportArchive* archive_source;
	GearyFolderSupportArchive* _tmp13_;
	GearyFolderSupportArchive* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	GError* _tmp17_;
	GError* _tmp18_;
	GearyFolderSupportArchive* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	const gchar* _tmp22_;
	ApplicationArchiveEmailCommand* _tmp23_;
	GearyFolderSupportMove* move_source;
	GearyFolderSupportMove* _tmp24_;
	GearyFolderSupportMove* _tmp25_;
	gchar* _tmp26_;
	gchar* _tmp27_;
	GError* _tmp28_;
	GError* _tmp29_;
	GearyFolder* dest;
	GearyAccount* _tmp30_;
	GearyAccount* _tmp31_;
	GearyFolder* _tmp32_;
	GearyFolder* _tmp33_;
	GEnumValue* _tmp34_;
	GError* _tmp35_;
	GearyFolderSupportMove* _tmp36_;
	GearyFolder* _tmp37_;
	gint _tmp38_;
	gint _tmp39_;
	GearyFolder* _tmp40_;
	gchar* _tmp41_;
	gchar* _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	const gchar* _tmp45_;
	ApplicationMoveEmailCommand* _tmp46_;
	ApplicationAccountContext* _tmp47_;
	ApplicationCommandStack* _tmp48_;
	ApplicationCommandStack* _tmp49_;
	ApplicationCommand* _tmp50_;
	ApplicationAccountContext* _tmp51_;
	GCancellable* _tmp52_;
	GCancellable* _tmp53_;
	GError* _inner_error0_;
};

struct _ApplicationControllerCopyConversationsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolderSupportCopy* source;
	GearyFolder* destination;
	GeeCollection* conversations;
	ApplicationAccountContext* context;
	GeeMap* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	gpointer _tmp5_;
	ApplicationAccountContext* _tmp6_;
	ApplicationAccountContext* _tmp7_;
	ApplicationCommandStack* _tmp8_;
	ApplicationCommandStack* _tmp9_;
	GeeCollection* _tmp10_;
	GeeCollection* _tmp11_;
	gint _tmp12_;
	gint _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gint _tmp18_;
	gint _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	gchar* _tmp23_;
	ApplicationCopyEmailCommand* _tmp24_;
	ApplicationCopyEmailCommand* _tmp25_;
	ApplicationAccountContext* _tmp26_;
	GCancellable* _tmp27_;
	GCancellable* _tmp28_;
	GError* _inner_error0_;
};

struct _ApplicationControllerDeleteConversationsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolderSupportRemove* target;
	GeeCollection* conversations;
	GeeCollection* _tmp0_;
	GearyFolderProperties* _tmp1_;
	GearyFolderProperties* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GeeCollection* _tmp5_;
	GeeCollection* _tmp6_;
	GeeCollection* messages;
	GeeCollection* _tmp7_;
	GError* _inner_error0_;
};

struct _Block11Data {
	int _ref_count_;
	ApplicationController* self;
	ApplicationAccountContext* context;
	GearyFolderSupportRemove* target;
	GeeCollection* messages;
	gpointer _async_data_;
};

struct _ApplicationControllerDeleteMessagesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolderSupportRemove* target;
	GeeCollection* conversations;
	GeeCollection* messages;
	Block11Data* _data11_;
	GeeMap* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	gpointer _tmp5_;
	ApplicationAccountContext* _tmp6_;
	ApplicationCommand* command;
	ApplicationDeleteEmailCommand* _tmp7_;
	ApplicationCommand* _tmp8_;
	ApplicationAccountContext* _tmp9_;
	ApplicationCommandStack* _tmp10_;
	ApplicationCommandStack* _tmp11_;
	ApplicationCommand* _tmp12_;
	ApplicationAccountContext* _tmp13_;
	GCancellable* _tmp14_;
	GCancellable* _tmp15_;
	GError* _inner_error0_;
};

struct _Block12Data {
	int _ref_count_;
	ApplicationController* self;
	ApplicationAccountContext* context;
	gpointer _async_data_;
};

struct _Block13Data {
	int _ref_count_;
	Block12Data * _data12_;
	GearyFolderSupportEmpty* emptyable;
};

struct _ApplicationControllerEmptyFolderData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyFolder* target;
	Block12Data* _data12_;
	GeeMap* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	gpointer _tmp5_;
	ApplicationAccountContext* _tmp6_;
	Block13Data* _data13_;
	GearyFolderSupportEmpty* _tmp7_;
	GearyFolderSupportEmpty* _tmp8_;
	GearyFolderPath* _tmp9_;
	GearyFolderPath* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	GError* _tmp13_;
	GError* _tmp14_;
	ApplicationCommand* command;
	GearyFolderSupportEmpty* _tmp15_;
	ApplicationEmptyFolderCommand* _tmp16_;
	ApplicationCommand* _tmp17_;
	ApplicationAccountContext* _tmp18_;
	ApplicationCommandStack* _tmp19_;
	ApplicationCommandStack* _tmp20_;
	ApplicationCommand* _tmp21_;
	ApplicationAccountContext* _tmp22_;
	GCancellable* _tmp23_;
	GCancellable* _tmp24_;
	GError* _inner_error0_;
};

struct _ApplicationControllerProcessPendingComposersData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GeeList* _mailto_list;
	GeeList* _tmp0_;
	gint _mailto_size;
	GeeList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gint _mailto_index;
	gint _tmp4_;
	gint _tmp5_;
	gchar* mailto;
	GeeList* _tmp6_;
	gpointer _tmp7_;
	const gchar* _tmp8_;
	GeeList* _tmp9_;
};

struct _ApplicationControllerSendComposedEmailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	ComposerWidget* composer;
	ApplicationAccountContext* context;
	ApplicationAccountContext* _tmp0_;
	ApplicationAccountContext* _tmp1_;
	ApplicationAccountContext* _tmp2_;
	ApplicationCommandStack* _tmp3_;
	ApplicationCommandStack* _tmp4_;
	ApplicationClient* _tmp5_;
	ApplicationSendComposerCommand* _tmp6_;
	ApplicationSendComposerCommand* _tmp7_;
	GCancellable* _tmp8_;
	GCancellable* _tmp9_;
	GError* err;
	GError* _tmp10_;
	GearyProblemReport* _tmp11_;
	GearyProblemReport* _tmp12_;
	GError* _inner_error0_;
};

struct _ApplicationControllerSaveComposedEmailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	ComposerWidget* composer;
	ApplicationAccountContext* context;
	ApplicationAccountContext* _tmp0_;
	ApplicationAccountContext* _tmp1_;
	ApplicationAccountContext* _tmp2_;
	ApplicationCommandStack* _tmp3_;
	ApplicationCommandStack* _tmp4_;
	ApplicationSaveComposerCommand* _tmp5_;
	ApplicationSaveComposerCommand* _tmp6_;
	GCancellable* _tmp7_;
	GCancellable* _tmp8_;
	GError* err;
	GError* _tmp9_;
	GearyProblemReport* _tmp10_;
	GearyProblemReport* _tmp11_;
	GError* _inner_error0_;
};

struct _ApplicationControllerDiscardComposedEmailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	ComposerWidget* composer;
	ApplicationAccountContext* context;
	ApplicationAccountContext* _tmp0_;
	ApplicationAccountContext* _tmp1_;
	ApplicationAccountContext* _tmp2_;
	ApplicationCommandStack* _tmp3_;
	ApplicationCommandStack* _tmp4_;
	ApplicationDiscardComposerCommand* _tmp5_;
	ApplicationDiscardComposerCommand* _tmp6_;
	GCancellable* _tmp7_;
	GCancellable* _tmp8_;
	GError* err;
	GError* _tmp9_;
	GearyProblemReport* _tmp10_;
	GearyProblemReport* _tmp11_;
	GError* _inner_error0_;
};

struct _ApplicationControllerExpungeAccountsData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	AccountsManager* _tmp0_;
	GCancellable* _tmp1_;
	GError* err;
	GError* _tmp2_;
	GearyProblemReport* _tmp3_;
	GearyProblemReport* _tmp4_;
	GError* _inner_error0_;
};

struct _ApplicationControllerOpenAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyAccount* account;
	ApplicationAccountContext* context;
	GearyFolderRoot* _tmp0_;
	GearyFolderRoot* _tmp1_;
	GearyAppSearchFolder* _tmp2_;
	GearyAppSearchFolder* _tmp3_;
	GearyAppEmailStore* _tmp4_;
	GearyAppEmailStore* _tmp5_;
	FolksIndividualAggregator* _tmp6_;
	ApplicationContactStore* _tmp7_;
	ApplicationContactStore* _tmp8_;
	ApplicationAccountContext* _tmp9_;
	ApplicationAccountContext* _tmp10_;
	GeeMap* _tmp11_;
	GearyAccountInformation* _tmp12_;
	GearyAccountInformation* _tmp13_;
	ApplicationAccountContext* _tmp14_;
	ApplicationDatabaseManager* _tmp15_;
	GCancellable* _tmp16_;
	GearyAccountInformation* _tmp17_;
	GearyAccountInformation* _tmp18_;
	GearyAccountInformation* _tmp19_;
	GearyAccountInformation* _tmp20_;
	GearySmtpClientService* smtp;
	GearyClientService* _tmp21_;
	GearyClientService* _tmp22_;
	GearySmtpClientService* _tmp23_;
	GearySmtpClientService* _tmp24_;
	GearySmtpClientService* _tmp25_;
	ApplicationAccountContext* _tmp26_;
	gboolean retry;
	gboolean _tmp27_;
	GCancellable* _tmp28_;
	GError* open_err;
	gchar* _tmp29_;
	gchar* _tmp30_;
	GError* _tmp31_;
	const gchar* _tmp32_;
	GError* _tmp33_;
	GearyAccountInformation* _tmp34_;
	GearyAccountInformation* _tmp35_;
	GError* _tmp36_;
	GearyAccountProblemReport* _tmp37_;
	GearyAccountProblemReport* _tmp38_;
	AccountsManager* _tmp39_;
	GearyAccountInformation* _tmp40_;
	GearyAccountInformation* _tmp41_;
	GeeMap* _tmp42_;
	GearyAccountInformation* _tmp43_;
	GearyAccountInformation* _tmp44_;
	GError* _inner_error0_;
};

struct _ApplicationControllerRemoveAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyAccountInformation* removed;
	ApplicationClient* _tmp0_;
	GearyEngine* _tmp1_;
	GearyEngine* _tmp2_;
	GError* err;
	GError* _tmp3_;
	GearyAccountProblemReport* _tmp4_;
	GearyAccountProblemReport* _tmp5_;
	GError* _inner_error0_;
};

struct _ApplicationControllerCloseAccountData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyAccountInformation* config;
	gboolean is_shutdown;
	ApplicationAccountContext* context;
	GeeMap* _tmp0_;
	gpointer _tmp1_;
	ApplicationAccountContext* _tmp2_;
	ApplicationAccountContext* _tmp3_;
	GearyAccount* _tmp4_;
	GearyAccount* _tmp5_;
	GearyAccountInformation* _tmp6_;
	GearyAccountInformation* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	GearyAccount* account;
	ApplicationAccountContext* _tmp10_;
	GearyAccount* _tmp11_;
	GearyAccount* _tmp12_;
	GearyAccount* _tmp13_;
	ApplicationAccountContext* _tmp14_;
	GeeMap* _tmp15_;
	GearyAccount* _tmp16_;
	GearyAccountInformation* _tmp17_;
	GearyAccountInformation* _tmp18_;
	ApplicationDatabaseManager* _tmp19_;
	GearyAccount* _tmp20_;
	GearyAccount* _tmp21_;
	guint _tmp22_;
	GearyAccount* _tmp23_;
	GearyAccountInformation* _tmp24_;
	GearyAccountInformation* _tmp25_;
	guint _tmp26_;
	GearyAccount* _tmp27_;
	GearyAccountInformation* _tmp28_;
	GearyAccountInformation* _tmp29_;
	guint _tmp30_;
	GearyAccount* _tmp31_;
	guint _tmp32_;
	GQuark _tmp33_;
	GearyAccount* _tmp34_;
	guint _tmp35_;
	GearySmtpClientService* smtp;
	GearyAccount* _tmp36_;
	GearyClientService* _tmp37_;
	GearyClientService* _tmp38_;
	GearySmtpClientService* _tmp39_;
	GearySmtpClientService* _tmp40_;
	GearySmtpClientService* _tmp41_;
	guint _tmp42_;
	ApplicationAccountContext* _tmp43_;
	GearyAppSearchFolder* _tmp44_;
	ApplicationAccountContext* _tmp45_;
	ApplicationContactStore* _tmp46_;
	ApplicationContactStore* _tmp47_;
	ApplicationAccountContext* _tmp48_;
	GCancellable* _tmp49_;
	GCancellable* _tmp50_;
	GearyFolder* inbox;
	ApplicationAccountContext* _tmp51_;
	GearyFolder* _tmp52_;
	GearyFolder* _tmp53_;
	GearyFolder* _tmp54_;
	GearyFolder* _tmp55_;
	GError* close_inbox_err;
	GError* _tmp56_;
	const gchar* _tmp57_;
	ApplicationAccountContext* _tmp58_;
	GearyAccount* _tmp59_;
	GError* close_err;
	GearyAccount* _tmp60_;
	gchar* _tmp61_;
	gchar* _tmp62_;
	GError* _tmp63_;
	const gchar* _tmp64_;
	GearyAccount* _tmp65_;
	gchar* _tmp66_;
	gchar* _tmp67_;
	GError* _inner_error0_;
};

struct _ApplicationControllerPromptForPasswordData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	ApplicationAccountContext* context;
	GearyServiceInformation* service;
	GearyAccountInformation* account;
	GearyAccount* _tmp0_;
	GearyAccount* _tmp1_;
	GearyAccountInformation* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	gboolean is_incoming;
	GearyAccountInformation* _tmp5_;
	GearyServiceInformation* _tmp6_;
	GearyServiceInformation* _tmp7_;
	GearyCredentials* _tmp8_;
	GearyAccountInformation* _tmp9_;
	GearyServiceInformation* _tmp10_;
	GearyServiceInformation* _tmp11_;
	GearyCredentials* _tmp12_;
	GearyCredentials* _tmp13_;
	GearyCredentials* _tmp14_;
	GearyAccountInformation* _tmp15_;
	GearyCredentials* _tmp16_;
	GearyCredentials* credentials;
	GearyCredentials* _tmp17_;
	gboolean handled;
	gboolean _tmp18_;
	guint _tmp19_;
	guint _tmp20_;
	GearyCredentials* _tmp21_;
	AccountsManager* _tmp22_;
	GearyAccountInformation* _tmp23_;
	GearyAccountInformation* _tmp24_;
	GCancellable* _tmp25_;
	GCancellable* _tmp26_;
	GearyAccountInformation* _tmp27_;
	GCancellable* _tmp28_;
	GCancellable* _tmp29_;
	GError* err;
	GearyAccountInformation* _tmp30_;
	GError* _tmp31_;
	GearyAccountProblemReport* _tmp32_;
	GearyAccountProblemReport* _tmp33_;
	PasswordDialog* password_dialog;
	ApplicationClient* _tmp34_;
	GtkWindow* _tmp35_;
	GearyAccountInformation* _tmp36_;
	GearyCredentials* _tmp37_;
	PasswordDialog* _tmp38_;
	PasswordDialog* _tmp39_;
	GearyServiceInformation* _tmp40_;
	GearyCredentials* _tmp41_;
	GearyAccountInformation* _tmp42_;
	GearyServiceInformation* _tmp43_;
	GearyServiceInformation* _tmp44_;
	GearyCredentials* _tmp45_;
	GearyCredentials* _tmp46_;
	GearyAccountInformation* _tmp47_;
	GearyServiceInformation* _tmp48_;
	GearyServiceInformation* _tmp49_;
	GearyAccountInformation* _tmp50_;
	GearyServiceInformation* _tmp51_;
	GearyServiceInformation* _tmp52_;
	GearyServiceInformation* creds_service;
	GearyServiceInformation* _tmp53_;
	GearyServiceInformation* _tmp54_;
	GearyCredentials* _tmp55_;
	PasswordDialog* _tmp56_;
	const gchar* _tmp57_;
	const gchar* _tmp58_;
	GearyCredentials* _tmp59_;
	GearyCredentials* _tmp60_;
	gboolean remember;
	PasswordDialog* _tmp61_;
	gboolean _tmp62_;
	gboolean _tmp63_;
	GearyServiceInformation* _tmp64_;
	gboolean _tmp65_;
	gboolean _tmp66_;
	GearyServiceInformation* _tmp67_;
	GearyAccountInformation* _tmp68_;
	SecretMediator* libsecret;
	GearyAccountInformation* _tmp69_;
	GearyCredentialsMediator* _tmp70_;
	GearyCredentialsMediator* _tmp71_;
	SecretMediator* _tmp72_;
	GearyServiceInformation* _tmp73_;
	gboolean _tmp74_;
	gboolean _tmp75_;
	SecretMediator* _tmp76_;
	GearyAccountInformation* _tmp77_;
	GearyServiceInformation* _tmp78_;
	GCancellable* _tmp79_;
	GCancellable* _tmp80_;
	SecretMediator* _tmp81_;
	GearyAccountInformation* _tmp82_;
	GearyServiceInformation* _tmp83_;
	GCancellable* _tmp84_;
	GCancellable* _tmp85_;
	GError* _vala1_err;
	GearyAccountInformation* _tmp86_;
	GError* _tmp87_;
	GearyServiceProblemReport* _tmp88_;
	GearyServiceProblemReport* _tmp89_;
	guint _tmp90_;
	guint _tmp91_;
	ApplicationClient* _tmp92_;
	GearyEngine* _tmp93_;
	GearyEngine* _tmp94_;
	GearyAccountInformation* _tmp95_;
	GCancellable* _tmp96_;
	GCancellable* _tmp97_;
	GError* _vala2_err;
	GearyAccountInformation* _tmp98_;
	GError* _tmp99_;
	GearyServiceProblemReport* _tmp100_;
	GearyServiceProblemReport* _tmp101_;
	GError* _inner_error0_;
};

struct _ApplicationControllerPromptUntrustedHostData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	ApplicationAccountContext* context;
	GearyServiceInformation* service;
	GearyEndpoint* endpoint;
	GTlsConnection* cx;
	ApplicationClient* _tmp0_;
	ApplicationConfiguration* _tmp1_;
	ApplicationConfiguration* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	ApplicationCertificateManager* _tmp5_;
	ApplicationClient* _tmp6_;
	ApplicationMainWindow* _tmp7_;
	ApplicationMainWindow* _tmp8_;
	GearyAccount* _tmp9_;
	GearyAccount* _tmp10_;
	GearyAccountInformation* _tmp11_;
	GearyAccountInformation* _tmp12_;
	GCancellable* _tmp13_;
	GCancellable* _tmp14_;
	GError* err;
	GearyAccount* _tmp15_;
	GearyAccount* _tmp16_;
	GearyAccountInformation* _tmp17_;
	GearyAccountInformation* _tmp18_;
	GError* _tmp19_;
	GearyServiceProblemReport* _tmp20_;
	GearyServiceProblemReport* _tmp21_;
	GError* _inner_error0_;
};

struct _ApplicationControllerAccountDatabaseErrorAsyncData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GearyAccount* account;
	gboolean result;
	gboolean retry;
	QuestionDialog* dialog;
	ApplicationClient* _tmp0_;
	ApplicationMainWindow* _tmp1_;
	ApplicationMainWindow* _tmp2_;
	GearyAccountInformation* _tmp3_;
	GearyAccountInformation* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GearyAccountInformation* _tmp9_;
	GearyAccountInformation* _tmp10_;
	GFile* _tmp11_;
	GFile* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	QuestionDialog* _tmp17_;
	QuestionDialog* _tmp18_;
	QuestionDialog* _tmp19_;
	QuestionDialog* _tmp20_;
	GError* err;
	ErrorDialog* errdialog;
	ApplicationClient* _tmp21_;
	ApplicationMainWindow* _tmp22_;
	ApplicationMainWindow* _tmp23_;
	GearyAccountInformation* _tmp24_;
	GearyAccountInformation* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	gchar* _tmp29_;
	GError* _tmp30_;
	const gchar* _tmp31_;
	gchar* _tmp32_;
	gchar* _tmp33_;
	ErrorDialog* _tmp34_;
	ErrorDialog* _tmp35_;
	ErrorDialog* _tmp36_;
	GError* _inner_error0_;
};

struct _ApplicationControllerDoBackgroundStorageCleanupData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationController* self;
	GCancellable* _tmp0_;
	GeeIterator* _context_it;
	GeeMap* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	GeeIterator* _tmp5_;
	GeeIterator* _tmp6_;
	GeeIterator* _tmp7_;
	ApplicationAccountContext* context;
	GeeIterator* _tmp8_;
	gpointer _tmp9_;
	GearyAccount* account;
	ApplicationAccountContext* _tmp10_;
	GearyAccount* _tmp11_;
	GearyAccount* _tmp12_;
	GearyAccount* _tmp13_;
	ApplicationAccountContext* _tmp14_;
	GCancellable* _tmp15_;
	GCancellable* _tmp16_;
	GCancellable* _tmp17_;
	GearyAccount* _tmp18_;
	GCancellable* _tmp19_;
	GError* err;
	GError* _tmp20_;
	GearyProblemReport* _tmp21_;
	GearyProblemReport* _tmp22_;
	ApplicationAccountContext* _tmp23_;
	GCancellable* _tmp24_;
	GCancellable* _tmp25_;
	GCancellable* _tmp26_;
	guint _tmp27_;
	GCancellable* _tmp28_;
	GError* _inner_error0_;
};

struct _ApplicationControllerCommandStack {
	ApplicationCommandStack parent_instance;
	ApplicationControllerCommandStackPrivate * priv;
};

struct _ApplicationControllerCommandStackClass {
	ApplicationCommandStackClass parent_class;
};

struct _ApplicationControllerCommandStackPrivate {
	ApplicationEmailCommand* last_executed;
	GearyTimeoutManager* last_executed_timeout;
};

struct _ApplicationControllerCommandStackExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationControllerCommandStack* self;
	ApplicationCommand* target;
	GCancellable* cancellable;
	GearyTimeoutManager* _tmp0_;
	gboolean _tmp1_;
	ApplicationEmailCommand* _tmp2_;
	ApplicationEmailCommand* _tmp3_;
	ApplicationEmailCommand* _tmp4_;
	GearyTimeoutManager* _tmp5_;
	GError* _inner_error0_;
};

struct _ApplicationControllerCommandStackUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationControllerCommandStack* self;
	GCancellable* cancellable;
	GError* _inner_error0_;
};

struct _ApplicationControllerCommandStackRedoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationControllerCommandStack* self;
	GCancellable* cancellable;
	GError* _inner_error0_;
};

struct _ApplicationEmailCommandPrivate {
	GearyFolder* _location;
	GeeCollection* _conversations;
	GeeCollection* _email;
	GeeCollection* mutable_conversations;
	GeeCollection* mutable_email;
};

struct _ApplicationMarkEmailCommand {
	ApplicationEmailCommand parent_instance;
	ApplicationMarkEmailCommandPrivate * priv;
};

struct _ApplicationMarkEmailCommandClass {
	ApplicationEmailCommandClass parent_class;
};

struct _ApplicationMarkEmailCommandPrivate {
	GearyAppEmailStore* store;
	GearyEmailFlags* to_add;
	GearyEmailFlags* to_remove;
};

struct _ApplicationMarkEmailCommandExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationMarkEmailCommand* self;
	GCancellable* cancellable;
	GearyFolder* _tmp0_;
	GearyFolder* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccount* _tmp3_;
	GearyAppEmailStore* _tmp4_;
	GeeCollection* _tmp5_;
	GeeCollection* _tmp6_;
	GearyEmailFlags* _tmp7_;
	GearyEmailFlags* _tmp8_;
	GError* _inner_error0_;
};

struct _ApplicationMarkEmailCommandUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationMarkEmailCommand* self;
	GCancellable* cancellable;
	GearyAppEmailStore* _tmp0_;
	GeeCollection* _tmp1_;
	GeeCollection* _tmp2_;
	GearyEmailFlags* _tmp3_;
	GearyEmailFlags* _tmp4_;
	GError* _inner_error0_;
};

struct _ApplicationRevokableCommand {
	ApplicationEmailCommand parent_instance;
	ApplicationRevokableCommandPrivate * priv;
};

struct _ApplicationRevokableCommandClass {
	ApplicationEmailCommandClass parent_class;
	void (*execute_impl) (ApplicationRevokableCommand* self, GCancellable* cancellable, GAsyncReadyCallback _callback_, gpointer _user_data_);
	GearyRevokable* (*execute_impl_finish) (ApplicationRevokableCommand* self, GAsyncResult* _res_, GError** error);
};

struct _ApplicationRevokableCommandPrivate {
	GearyRevokable* revokable;
};

struct _ApplicationRevokableCommandExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationRevokableCommand* self;
	GCancellable* cancellable;
	GearyRevokable* _tmp0_;
	GearyRevokable* _tmp1_;
	gboolean _tmp2_;
	GearyRevokable* _tmp3_;
	GearyRevokable* _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	GearyRevokable* _tmp7_;
	GError* _inner_error0_;
};

struct _ApplicationRevokableCommandUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationRevokableCommand* self;
	GCancellable* cancellable;
	GearyRevokable* _tmp0_;
	GError* _tmp1_;
	GearyRevokable* _tmp2_;
	GError* _inner_error0_;
};

struct _ApplicationMoveEmailCommand {
	ApplicationRevokableCommand parent_instance;
	ApplicationMoveEmailCommandPrivate * priv;
};

struct _ApplicationMoveEmailCommandClass {
	ApplicationRevokableCommandClass parent_class;
};

struct _ApplicationMoveEmailCommandPrivate {
	GearyFolderSupportMove* source;
	GearyFolder* destination;
};

struct _ApplicationMoveEmailCommandExecuteImplData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationMoveEmailCommand* self;
	GCancellable* cancellable;
	GearyRevokable* result;
	gboolean open;
	GearyFolderSupportMove* _tmp0_;
	GearyRevokable* _tmp1_;
	GearyFolderSupportMove* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	GearyFolder* _tmp5_;
	GearyFolderPath* _tmp6_;
	GearyFolderPath* _tmp7_;
	GearyRevokable* _tmp8_;
	GearyRevokable* _tmp9_;
	GearyFolderSupportMove* _tmp10_;
	GError* _inner_error1_;
	GearyFolderSupportMove* _tmp11_;
	GError* _inner_error0_;
};

struct _ApplicationArchiveEmailCommand {
	ApplicationRevokableCommand parent_instance;
	ApplicationArchiveEmailCommandPrivate * priv;
};

struct _ApplicationArchiveEmailCommandClass {
	ApplicationRevokableCommandClass parent_class;
};

struct _ApplicationArchiveEmailCommandPrivate {
	GearyFolder* _command_location;
	GeeCollection* _command_conversations;
	GeeCollection* _command_email;
	GearyFolderSupportArchive* source;
};

struct _ApplicationArchiveEmailCommandExecuteImplData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationArchiveEmailCommand* self;
	GCancellable* cancellable;
	GearyRevokable* result;
	gboolean open;
	GearyFolderSupportArchive* _tmp0_;
	GearyRevokable* _tmp1_;
	GearyFolderSupportArchive* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	GearyRevokable* _tmp5_;
	GearyRevokable* _tmp6_;
	GearyFolderSupportArchive* _tmp7_;
	GError* _inner_error1_;
	GearyFolderSupportArchive* _tmp8_;
	GError* _inner_error0_;
};

struct _ApplicationCopyEmailCommand {
	ApplicationEmailCommand parent_instance;
	ApplicationCopyEmailCommandPrivate * priv;
};

struct _ApplicationCopyEmailCommandClass {
	ApplicationEmailCommandClass parent_class;
};

struct _ApplicationCopyEmailCommandPrivate {
	GearyFolderSupportCopy* source;
	GearyFolder* destination;
};

struct _ApplicationCopyEmailCommandExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationCopyEmailCommand* self;
	GCancellable* cancellable;
	gboolean open;
	GearyFolderSupportCopy* _tmp0_;
	GearyFolderSupportCopy* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GearyFolder* _tmp4_;
	GearyFolderPath* _tmp5_;
	GearyFolderPath* _tmp6_;
	GError* _inner_error1_;
	GearyFolderSupportCopy* _tmp7_;
	GError* _inner_error0_;
};

struct _ApplicationCopyEmailCommandUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationCopyEmailCommand* self;
	GCancellable* cancellable;
	GError* _tmp0_;
	GError* _inner_error0_;
};

struct _ApplicationDeleteEmailCommand {
	ApplicationEmailCommand parent_instance;
	ApplicationDeleteEmailCommandPrivate * priv;
};

struct _ApplicationDeleteEmailCommandClass {
	ApplicationEmailCommandClass parent_class;
};

struct _ApplicationDeleteEmailCommandPrivate {
	GearyFolderSupportRemove* target;
};

struct _ApplicationDeleteEmailCommandExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationDeleteEmailCommand* self;
	GCancellable* cancellable;
	gboolean open;
	GearyFolderSupportRemove* _tmp0_;
	GearyFolderSupportRemove* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GError* _inner_error1_;
	GearyFolderSupportRemove* _tmp4_;
	GError* _inner_error0_;
};

struct _ApplicationDeleteEmailCommandUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationDeleteEmailCommand* self;
	GCancellable* cancellable;
	GearyFolderSupportRemove* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GError* _tmp5_;
	GError* _tmp6_;
	GError* _inner_error0_;
};

struct _ApplicationEmptyFolderCommand {
	ApplicationCommand parent_instance;
	ApplicationEmptyFolderCommandPrivate * priv;
};

struct _ApplicationEmptyFolderCommandClass {
	ApplicationCommandClass parent_class;
};

struct _ApplicationEmptyFolderCommandPrivate {
	GearyFolderSupportEmpty* target;
};

struct _ApplicationEmptyFolderCommandExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationEmptyFolderCommand* self;
	GCancellable* cancellable;
	gboolean open;
	GearyFolderSupportEmpty* _tmp0_;
	GearyFolderSupportEmpty* _tmp1_;
	GError* _inner_error1_;
	GearyFolderSupportEmpty* _tmp2_;
	GError* _inner_error0_;
};

struct _ApplicationEmptyFolderCommandUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationEmptyFolderCommand* self;
	GCancellable* cancellable;
	GearyFolderSupportEmpty* _tmp0_;
	GearyFolderPath* _tmp1_;
	GearyFolderPath* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GError* _tmp5_;
	GError* _tmp6_;
	GError* _inner_error0_;
};

struct _ApplicationComposerCommand {
	ApplicationCommand parent_instance;
	ApplicationComposerCommandPrivate * priv;
};

struct _ApplicationComposerCommandClass {
	ApplicationCommandClass parent_class;
};

struct _ApplicationComposerCommandPrivate {
	ComposerWidget* _composer;
};

struct _ApplicationSendComposerCommand {
	ApplicationComposerCommand parent_instance;
	ApplicationSendComposerCommandPrivate * priv;
};

struct _ApplicationSendComposerCommandClass {
	ApplicationComposerCommandClass parent_class;
};

struct _ApplicationSendComposerCommandPrivate {
	ApplicationClient* application;
	ApplicationAccountContext* context;
	GearySmtpClientService* smtp;
	GearyTimeoutManager* commit_timer;
	GearyEmailIdentifier* saved;
};

struct _ApplicationSendComposerCommandExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationSendComposerCommand* self;
	GCancellable* cancellable;
	GearyComposedEmail* email;
	ComposerWidget* _tmp0_;
	ComposerWidget* _tmp1_;
	GearyComposedEmail* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GearyComposedEmail* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GearyEmailIdentifier* _tmp10_;
	GearySmtpClientService* _tmp11_;
	GearyComposedEmail* _tmp12_;
	GearyEmailIdentifier* _tmp13_;
	GearyEmailIdentifier* _tmp14_;
	GearyTimeoutManager* _tmp15_;
	GearySmtpClientService* _tmp16_;
	GearyComposedEmail* _tmp17_;
	GError* _inner_error0_;
};

struct _ApplicationSendComposerCommandUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationSendComposerCommand* self;
	GCancellable* cancellable;
	GearyTimeoutManager* _tmp0_;
	GearySmtpClientService* _tmp1_;
	GearyOutboxFolder* _tmp2_;
	GearyOutboxFolder* _tmp3_;
	GearyEmailIdentifier* _tmp4_;
	GeeCollection* _tmp5_;
	GeeCollection* _tmp6_;
	ComposerWidget* _tmp7_;
	ComposerWidget* _tmp8_;
	ApplicationClient* _tmp9_;
	ApplicationController* _tmp10_;
	ApplicationController* _tmp11_;
	ComposerWidget* _tmp12_;
	ComposerWidget* _tmp13_;
	GError* _inner_error0_;
};

struct _ApplicationSaveComposerCommand {
	ApplicationComposerCommand parent_instance;
	ApplicationSaveComposerCommandPrivate * priv;
};

struct _ApplicationSaveComposerCommandClass {
	ApplicationComposerCommandClass parent_class;
};

struct _ApplicationSaveComposerCommandPrivate {
	ApplicationController* controller;
	GearyTimeoutManager* destroy_timer;
};

struct _ApplicationSaveComposerCommandExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationSaveComposerCommand* self;
	GCancellable* cancellable;
	GearyTimeoutManager* _tmp0_;
};

struct _ApplicationSaveComposerCommandUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationSaveComposerCommand* self;
	GCancellable* cancellable;
	ComposerWidget* _tmp0_;
	ComposerWidget* _tmp1_;
	GearyTimeoutManager* _tmp2_;
	ComposerWidget* _tmp3_;
	ComposerWidget* _tmp4_;
	ApplicationController* _tmp5_;
	ComposerWidget* _tmp6_;
	ComposerWidget* _tmp7_;
};

struct _ApplicationDiscardComposerCommand {
	ApplicationComposerCommand parent_instance;
	ApplicationDiscardComposerCommandPrivate * priv;
};

struct _ApplicationDiscardComposerCommandClass {
	ApplicationComposerCommandClass parent_class;
};

struct _ApplicationDiscardComposerCommandPrivate {
	ApplicationController* controller;
	GearyTimeoutManager* destroy_timer;
};

struct _ApplicationDiscardComposerCommandExecuteData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationDiscardComposerCommand* self;
	GCancellable* cancellable;
	GearyTimeoutManager* _tmp0_;
};

struct _ApplicationDiscardComposerCommandUndoData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationDiscardComposerCommand* self;
	GCancellable* cancellable;
	ComposerWidget* _tmp0_;
	ComposerWidget* _tmp1_;
	GearyTimeoutManager* _tmp2_;
	ComposerWidget* _tmp3_;
	ComposerWidget* _tmp4_;
	ApplicationController* _tmp5_;
	ComposerWidget* _tmp6_;
	ComposerWidget* _tmp7_;
};

static gint ApplicationController_private_offset;
static gpointer application_controller_parent_class = NULL;
static ApplicationAccountInterfaceIface * application_controller_application_account_interface_parent_iface = NULL;
static ComposerApplicationInterfaceIface * application_controller_composer_application_interface_parent_iface = NULL;
static gint ApplicationControllerCommandStack_private_offset;
static gpointer application_controller_command_stack_parent_class = NULL;
static gint ApplicationEmailCommand_private_offset;
static gpointer application_email_command_parent_class = NULL;
static gint ApplicationMarkEmailCommand_private_offset;
static gpointer application_mark_email_command_parent_class = NULL;
static ApplicationTrivialCommandIface * application_mark_email_command_application_trivial_command_parent_iface = NULL;
static gint ApplicationRevokableCommand_private_offset;
static gpointer application_revokable_command_parent_class = NULL;
static gint ApplicationMoveEmailCommand_private_offset;
static gpointer application_move_email_command_parent_class = NULL;
static gint ApplicationArchiveEmailCommand_private_offset;
static gpointer application_archive_email_command_parent_class = NULL;
static gint ApplicationCopyEmailCommand_private_offset;
static gpointer application_copy_email_command_parent_class = NULL;
static gint ApplicationDeleteEmailCommand_private_offset;
static gpointer application_delete_email_command_parent_class = NULL;
static gint ApplicationEmptyFolderCommand_private_offset;
static gpointer application_empty_folder_command_parent_class = NULL;
static gint ApplicationComposerCommand_private_offset;
static gpointer application_composer_command_parent_class = NULL;
static gint ApplicationSendComposerCommand_private_offset;
static gpointer application_send_composer_command_parent_class = NULL;
static gint ApplicationSaveComposerCommand_private_offset;
static gpointer application_save_composer_command_parent_class = NULL;
static gint ApplicationDiscardComposerCommand_private_offset;
static gpointer application_discard_composer_command_parent_class = NULL;

VALA_EXTERN GType application_account_interface_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType composer_application_interface_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType application_controller_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType application_database_manager_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gboolean application_controller_does_folder_support_trash (GearyFolder* target);
static gboolean application_controller_should_add_folder (GeeCollection* all,
                                                   GearyFolder* folder);
VALA_EXTERN gboolean application_controller_get_is_open (ApplicationController* self);
VALA_EXTERN ApplicationClient* application_controller_get_application (ApplicationController* self);
static void application_controller_set_application (ApplicationController* self,
                                             ApplicationClient* value);
VALA_EXTERN AccountsManager* application_controller_get_account_manager (ApplicationController* self);
static void application_controller_set_account_manager (ApplicationController* self,
                                                 AccountsManager* value);
VALA_EXTERN ApplicationPluginManager* application_controller_get_plugins (ApplicationController* self);
static void application_controller_set_plugins (ApplicationController* self,
                                         ApplicationPluginManager* value);
VALA_EXTERN ApplicationCertificateManager* application_controller_get_certificate_manager (ApplicationController* self);
static void application_controller_set_certificate_manager (ApplicationController* self,
                                                     ApplicationCertificateManager* value);
static void application_controller_construct_data_free (gpointer _data);
VALA_EXTERN void application_controller_new (ApplicationClient* application,
                                 GCancellable* cancellable,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
VALA_EXTERN ApplicationController* application_controller_new_finish (GAsyncResult* _res_,
                                                          GError** error);
VALA_EXTERN void application_controller_construct (GType object_type,
                                       ApplicationClient* application,
                                       GCancellable* cancellable,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
VALA_EXTERN ApplicationController* application_controller_construct_finish (GAsyncResult* _res_,
                                                                GError** error);
static gboolean application_controller_construct_co (ApplicationControllerNewData* _data_);
VALA_EXTERN ApplicationDatabaseManager* application_database_manager_new (ApplicationClient* application);
VALA_EXTERN ApplicationDatabaseManager* application_database_manager_construct (GType object_type,
                                                                    ApplicationClient* application);
static void application_controller_on_unfocused_idle (ApplicationController* self);
static void _application_controller_on_unfocused_idle_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                   gpointer self);
static void ___lambda150_ (ApplicationController* self,
                    GObject* obj,
                    GAsyncResult* res);
static void ____lambda150__gasync_ready_callback (GObject* source_object,
                                           GAsyncResult* res,
                                           gpointer self);
VALA_EXTERN ApplicationPluginManager* application_plugin_manager_new (ApplicationClient* application,
                                                          ApplicationController* controller,
                                                          ApplicationConfiguration* config,
                                                          GFile* trusted_plugin_path,
                                                          GError** error);
VALA_EXTERN ApplicationPluginManager* application_plugin_manager_construct (GType object_type,
                                                                ApplicationClient* application,
                                                                ApplicationController* controller,
                                                                ApplicationConfiguration* config,
                                                                GFile* trusted_plugin_path,
                                                                GError** error);
VALA_EXTERN GFile** application_client_get_config_search_path (ApplicationClient* self,
                                                   gint* result_length1);
static void application_controller_new_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_);
static void application_controller_on_account_available (ApplicationController* self,
                                                  GearyAccountInformation* info);
static void _application_controller_on_account_available_geary_engine_account_available (GearyEngine* _sender,
                                                                                  GearyAccountInformation* account,
                                                                                  gpointer self);
static void application_controller_on_account_added (ApplicationController* self,
                                              GearyAccountInformation* added,
                                              AccountsManagerStatus status);
static void _application_controller_on_account_added_accounts_manager_account_added (AccountsManager* _sender,
                                                                              GearyAccountInformation* added,
                                                                              AccountsManagerStatus status,
                                                                              gpointer self);
static void application_controller_on_account_status_changed (ApplicationController* self,
                                                       GearyAccountInformation* changed,
                                                       AccountsManagerStatus status);
static void _application_controller_on_account_status_changed_accounts_manager_account_status_changed (AccountsManager* _sender,
                                                                                                GearyAccountInformation* changed,
                                                                                                AccountsManagerStatus new_status,
                                                                                                gpointer self);
static void application_controller_on_account_removed (ApplicationController* self,
                                                GearyAccountInformation* removed);
static void _application_controller_on_account_removed_accounts_manager_account_removed (AccountsManager* _sender,
                                                                                  GearyAccountInformation* removed,
                                                                                  gpointer self);
static void application_controller_on_report_problem (ApplicationController* self,
                                               GearyProblemReport* problem);
static void _application_controller_on_report_problem_accounts_manager_report_problem (AccountsManager* _sender,
                                                                                GearyProblemReport* problem,
                                                                                gpointer self);
VALA_EXTERN void application_controller_expunge_accounts (ApplicationController* self,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
VALA_EXTERN void application_controller_expunge_accounts_finish (ApplicationController* self,
                                                     GAsyncResult* _res_);
static void application_controller_close_data_free (gpointer _data);
VALA_EXTERN void application_controller_close (ApplicationController* self,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
VALA_EXTERN void application_controller_close_finish (ApplicationController* self,
                                          GAsyncResult* _res_);
static gboolean application_controller_close_co (ApplicationControllerCloseData* _data_);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void _____lambda152_ (Block8Data* _data8_,
                      GObject* obj,
                      GAsyncResult* res);
static void ______lambda152__gasync_ready_callback (GObject* source_object,
                                             GAsyncResult* res,
                                             gpointer self);
static void application_controller_close_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static void ____lambda153_ (Block9Data* _data9_,
                     GObject* obj,
                     GAsyncResult* res);
static void _____lambda153__gasync_ready_callback (GObject* source_object,
                                            GAsyncResult* res,
                                            gpointer self);
VALA_EXTERN void application_plugin_manager_close (ApplicationPluginManager* self,
                                       GError** error);
static void application_controller_close_account (ApplicationController* self,
                                           GearyAccountInformation* config,
                                           gboolean is_shutdown,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
static void application_controller_close_account_finish (ApplicationController* self,
                                                  GAsyncResult* _res_);
static void ____lambda154_ (Block7Data* _data7_,
                     GObject* obj,
                     GAsyncResult* ret);
static void _____lambda154__gasync_ready_callback (GObject* source_object,
                                            GAsyncResult* res,
                                            gpointer self);
static void application_controller_compose_blank_data_free (gpointer _data);
VALA_EXTERN void application_controller_compose_blank (ApplicationController* self,
                                           ApplicationAccountContext* send_context,
                                           GearyRFC822MailboxAddress* to,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
VALA_EXTERN ComposerWidget* application_controller_compose_blank_finish (ApplicationController* self,
                                                             GAsyncResult* _res_);
static gboolean application_controller_compose_blank_co (ApplicationControllerComposeBlankData* _data_);
VALA_EXTERN ComposerWidget* composer_widget_new (ComposerApplicationInterface* application,
                                     ApplicationConfiguration* config,
                                     ApplicationAccountContext* initial_account,
                                     GearyFolder* save_to);
VALA_EXTERN ComposerWidget* composer_widget_construct (GType object_type,
                                           ComposerApplicationInterface* application,
                                           ApplicationConfiguration* config,
                                           ApplicationAccountContext* initial_account,
                                           GearyFolder* save_to);
VALA_EXTERN void application_controller_register_composer (ApplicationController* self,
                                               ComposerWidget* widget);
static void application_controller_compose_blank_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
VALA_EXTERN void composer_application_interface_report_problem (ComposerApplicationInterface* self,
                                                    GearyProblemReport* report);
static void application_controller_compose_with_context_data_free (gpointer _data);
VALA_EXTERN void application_controller_compose_with_context (ApplicationController* self,
                                                  ApplicationAccountContext* send_context,
                                                  ComposerWidgetContextType type,
                                                  GearyEmail* context,
                                                  const gchar* quote,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN ComposerWidget* application_controller_compose_with_context_finish (ApplicationController* self,
                                                                    GAsyncResult* _res_);
static gboolean application_controller_compose_with_context_co (ApplicationControllerComposeWithContextData* _data_);
VALA_EXTERN gboolean application_main_window_close_composer (ApplicationMainWindow* self,
                                                 gboolean should_prompt,
                                                 gboolean is_shutdown);
static void application_controller_compose_with_context_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_);
static void application_controller_compose_mailto_data_free (gpointer _data);
VALA_EXTERN void application_controller_compose_mailto (ApplicationController* self,
                                            const gchar* mailto,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
VALA_EXTERN void application_controller_compose_mailto_finish (ApplicationController* self,
                                                   GAsyncResult* _res_);
static gboolean application_controller_compose_mailto_co (ApplicationControllerComposeMailtoData* _data_);
VALA_EXTERN void application_controller_present_composer (ApplicationController* self,
                                              ComposerWidget* composer);
static void application_controller_compose_mailto_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_);
static void application_controller_real_report_problem (ComposerApplicationInterface* base,
                                                 GearyProblemReport* report);
static void application_controller_on_retry_problem (ApplicationController* self,
                                              ComponentsProblemReportInfoBar* info_bar);
static void _application_controller_on_retry_problem_components_problem_report_info_bar_retry (ComponentsProblemReportInfoBar* _sender,
                                                                                        gpointer self);
VALA_EXTERN void application_client_send_error_notification (ApplicationClient* self,
                                                 const gchar* summary,
                                                 const gchar* body);
static void application_controller_mark_conversations_data_free (gpointer _data);
VALA_EXTERN void application_controller_mark_conversations (ApplicationController* self,
                                                GearyFolder* location,
                                                GeeCollection* conversations,
                                                GearyNamedFlag* flag,
                                                gboolean prefer_adding,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN void application_controller_mark_conversations_finish (ApplicationController* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
static gboolean application_controller_mark_conversations_co (ApplicationControllerMarkConversationsData* _data_);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
static gboolean ___lambda155_ (Block10Data* _data10_,
                        GearyAppConversation* c);
static gboolean ____lambda155__gee_predicate (gconstpointer g,
                                       gpointer self);
static gboolean ____lambda156_ (Block10Data* _data10_,
                         GearyAppConversation* c);
static gboolean _____lambda156__gee_predicate (gconstpointer g,
                                        gpointer self);
static GearyEmailIdentifier* ___lambda157_ (ApplicationController* self,
                                     GearyAppConversation* c);
static gpointer ____lambda157__gee_map_func (gpointer g,
                                      gpointer self);
VALA_EXTERN void application_controller_mark_messages (ApplicationController* self,
                                           GearyFolder* location,
                                           GeeCollection* conversations,
                                           GeeCollection* messages,
                                           GearyEmailFlags* to_add,
                                           GearyEmailFlags* to_remove,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
VALA_EXTERN void application_controller_mark_messages_finish (ApplicationController* self,
                                                  GAsyncResult* _res_,
                                                  GError** error);
static void application_controller_mark_conversations_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static void application_controller_mark_messages_data_free (gpointer _data);
static gboolean application_controller_mark_messages_co (ApplicationControllerMarkMessagesData* _data_);
VALA_EXTERN ApplicationMarkEmailCommand* application_mark_email_command_new (GearyFolder* location,
                                                                 GeeCollection* conversations,
                                                                 GeeCollection* messages,
                                                                 GearyAppEmailStore* store,
                                                                 GearyEmailFlags* to_add,
                                                                 GearyEmailFlags* to_remove,
                                                                 const gchar* executed_label,
                                                                 const gchar* undone_label);
VALA_EXTERN ApplicationMarkEmailCommand* application_mark_email_command_construct (GType object_type,
                                                                       GearyFolder* location,
                                                                       GeeCollection* conversations,
                                                                       GeeCollection* messages,
                                                                       GearyAppEmailStore* store,
                                                                       GearyEmailFlags* to_add,
                                                                       GearyEmailFlags* to_remove,
                                                                       const gchar* executed_label,
                                                                       const gchar* undone_label);
VALA_EXTERN GType application_mark_email_command_get_type (void) G_GNUC_CONST ;
static void application_controller_mark_messages_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
static void application_controller_move_conversations_data_free (gpointer _data);
VALA_EXTERN void application_controller_move_conversations (ApplicationController* self,
                                                GearyFolderSupportMove* source,
                                                GearyFolder* destination,
                                                GeeCollection* conversations,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN void application_controller_move_conversations_finish (ApplicationController* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
static gboolean application_controller_move_conversations_co (ApplicationControllerMoveConversationsData* _data_);
static GeeCollection* application_controller_to_in_folder_email_ids (ApplicationController* self,
                                                              GeeCollection* conversations);
VALA_EXTERN ApplicationMoveEmailCommand* application_move_email_command_new (GearyFolderSupportMove* source,
                                                                 GearyFolder* destination,
                                                                 GeeCollection* conversations,
                                                                 GeeCollection* messages,
                                                                 const gchar* executed_label,
                                                                 const gchar* undone_label);
VALA_EXTERN ApplicationMoveEmailCommand* application_move_email_command_construct (GType object_type,
                                                                       GearyFolderSupportMove* source,
                                                                       GearyFolder* destination,
                                                                       GeeCollection* conversations,
                                                                       GeeCollection* messages,
                                                                       const gchar* executed_label,
                                                                       const gchar* undone_label);
VALA_EXTERN GType application_revokable_command_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType application_move_email_command_get_type (void) G_GNUC_CONST ;
static void application_controller_move_conversations_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static void application_controller_move_conversations_special_data_free (gpointer _data);
VALA_EXTERN void application_controller_move_conversations_special (ApplicationController* self,
                                                        GearyFolder* source,
                                                        GearyFolderSpecialUse destination,
                                                        GeeCollection* conversations,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
VALA_EXTERN void application_controller_move_conversations_special_finish (ApplicationController* self,
                                                               GAsyncResult* _res_,
                                                               GError** error);
static gboolean application_controller_move_conversations_special_co (ApplicationControllerMoveConversationsSpecialData* _data_);
VALA_EXTERN ApplicationArchiveEmailCommand* application_archive_email_command_new (GearyFolderSupportArchive* source,
                                                                       GeeCollection* conversations,
                                                                       GeeCollection* messages,
                                                                       const gchar* executed_label,
                                                                       const gchar* undone_label);
VALA_EXTERN ApplicationArchiveEmailCommand* application_archive_email_command_construct (GType object_type,
                                                                             GearyFolderSupportArchive* source,
                                                                             GeeCollection* conversations,
                                                                             GeeCollection* messages,
                                                                             const gchar* executed_label,
                                                                             const gchar* undone_label);
VALA_EXTERN GType application_archive_email_command_get_type (void) G_GNUC_CONST ;
static void application_controller_move_conversations_special_ready (GObject* source_object,
                                                              GAsyncResult* _res_,
                                                              gpointer _user_data_);
static void application_controller_move_messages_special_data_free (gpointer _data);
VALA_EXTERN void application_controller_move_messages_special (ApplicationController* self,
                                                   GearyFolder* source,
                                                   GearyFolderSpecialUse destination,
                                                   GeeCollection* conversations,
                                                   GeeCollection* messages,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
VALA_EXTERN void application_controller_move_messages_special_finish (ApplicationController* self,
                                                          GAsyncResult* _res_,
                                                          GError** error);
static gboolean application_controller_move_messages_special_co (ApplicationControllerMoveMessagesSpecialData* _data_);
static void application_controller_move_messages_special_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void application_controller_copy_conversations_data_free (gpointer _data);
VALA_EXTERN void application_controller_copy_conversations (ApplicationController* self,
                                                GearyFolderSupportCopy* source,
                                                GearyFolder* destination,
                                                GeeCollection* conversations,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
VALA_EXTERN void application_controller_copy_conversations_finish (ApplicationController* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
static gboolean application_controller_copy_conversations_co (ApplicationControllerCopyConversationsData* _data_);
VALA_EXTERN ApplicationCopyEmailCommand* application_copy_email_command_new (GearyFolderSupportCopy* source,
                                                                 GearyFolder* destination,
                                                                 GeeCollection* conversations,
                                                                 GeeCollection* messages,
                                                                 const gchar* executed_label,
                                                                 const gchar* undone_label);
VALA_EXTERN ApplicationCopyEmailCommand* application_copy_email_command_construct (GType object_type,
                                                                       GearyFolderSupportCopy* source,
                                                                       GearyFolder* destination,
                                                                       GeeCollection* conversations,
                                                                       GeeCollection* messages,
                                                                       const gchar* executed_label,
                                                                       const gchar* undone_label);
VALA_EXTERN GType application_copy_email_command_get_type (void) G_GNUC_CONST ;
static void application_controller_copy_conversations_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static void application_controller_delete_conversations_data_free (gpointer _data);
VALA_EXTERN void application_controller_delete_conversations (ApplicationController* self,
                                                  GearyFolderSupportRemove* target,
                                                  GeeCollection* conversations,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN void application_controller_delete_conversations_finish (ApplicationController* self,
                                                         GAsyncResult* _res_,
                                                         GError** error);
static gboolean application_controller_delete_conversations_co (ApplicationControllerDeleteConversationsData* _data_);
static GeeCollection* application_controller_to_all_email_ids (ApplicationController* self,
                                                        GeeCollection* conversations);
VALA_EXTERN void application_controller_delete_messages (ApplicationController* self,
                                             GearyFolderSupportRemove* target,
                                             GeeCollection* conversations,
                                             GeeCollection* messages,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_);
VALA_EXTERN void application_controller_delete_messages_finish (ApplicationController* self,
                                                    GAsyncResult* _res_,
                                                    GError** error);
static void application_controller_delete_conversations_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_);
static void application_controller_delete_messages_data_free (gpointer _data);
static gboolean application_controller_delete_messages_co (ApplicationControllerDeleteMessagesData* _data_);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
VALA_EXTERN ApplicationDeleteEmailCommand* application_delete_email_command_new (GearyFolderSupportRemove* target,
                                                                     GeeCollection* conversations,
                                                                     GeeCollection* email);
VALA_EXTERN ApplicationDeleteEmailCommand* application_delete_email_command_construct (GType object_type,
                                                                           GearyFolderSupportRemove* target,
                                                                           GeeCollection* conversations,
                                                                           GeeCollection* email);
VALA_EXTERN GType application_delete_email_command_get_type (void) G_GNUC_CONST ;
static void ___lambda158_ (Block11Data* _data11_);
VALA_EXTERN GType application_controller_command_stack_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ApplicationControllerCommandStack* application_account_context_get_controller_stack (ApplicationAccountContext* self);
VALA_EXTERN void application_controller_command_stack_email_removed (ApplicationControllerCommandStack* self,
                                                         GearyFolder* location,
                                                         GeeCollection* targets);
static void ____lambda158__application_command_executed (ApplicationCommand* _sender,
                                                  gpointer self);
static void application_controller_delete_messages_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void application_controller_empty_folder_data_free (gpointer _data);
VALA_EXTERN void application_controller_empty_folder (ApplicationController* self,
                                          GearyFolder* target,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
VALA_EXTERN void application_controller_empty_folder_finish (ApplicationController* self,
                                                 GAsyncResult* _res_,
                                                 GError** error);
static gboolean application_controller_empty_folder_co (ApplicationControllerEmptyFolderData* _data_);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
VALA_EXTERN ApplicationEmptyFolderCommand* application_empty_folder_command_new (GearyFolderSupportEmpty* target);
VALA_EXTERN ApplicationEmptyFolderCommand* application_empty_folder_command_construct (GType object_type,
                                                                           GearyFolderSupportEmpty* target);
VALA_EXTERN GType application_empty_folder_command_get_type (void) G_GNUC_CONST ;
static void ___lambda145_ (Block13Data* _data13_);
VALA_EXTERN void application_controller_command_stack_folders_removed (ApplicationControllerCommandStack* self,
                                                           GeeCollection* removed);
static void ____lambda145__application_command_executed (ApplicationCommand* _sender,
                                                  gpointer self);
static void application_controller_empty_folder_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
static ApplicationAccountContext* application_controller_real_get_context_for_account (ApplicationAccountInterface* base,
                                                                                GearyAccountInformation* account);
static GeeCollection* application_controller_real_get_account_contexts (ApplicationAccountInterface* base);
VALA_EXTERN void application_controller_register_window (ApplicationController* self,
                                             ApplicationMainWindow* window);
static void application_controller_on_retry_service_problem (ApplicationController* self,
                                                      GearyClientServiceStatus type);
static void _application_controller_on_retry_service_problem_application_main_window_retry_service_problem (ApplicationMainWindow* _sender,
                                                                                                     GearyClientServiceStatus problem,
                                                                                                     gpointer self);
VALA_EXTERN void application_controller_unregister_window (ApplicationController* self,
                                               ApplicationMainWindow* window);
static void application_controller_process_pending_composers_data_free (gpointer _data);
VALA_EXTERN void application_controller_process_pending_composers (ApplicationController* self,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
VALA_EXTERN void application_controller_process_pending_composers_finish (ApplicationController* self,
                                                              GAsyncResult* _res_);
static gboolean application_controller_process_pending_composers_co (ApplicationControllerProcessPendingComposersData* _data_);
static void application_controller_process_pending_composers_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_);
static void application_controller_real_send_composed_email_data_free (gpointer _data);
static void application_controller_real_send_composed_email (ComposerApplicationInterface* base,
                                                      ComposerWidget* composer,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_);
static gboolean application_controller_real_send_composed_email_co (ApplicationControllerSendComposedEmailData* _data_);
VALA_EXTERN ApplicationSendComposerCommand* application_send_composer_command_new (ApplicationClient* application,
                                                                       ApplicationAccountContext* context,
                                                                       ComposerWidget* composer);
VALA_EXTERN ApplicationSendComposerCommand* application_send_composer_command_construct (GType object_type,
                                                                             ApplicationClient* application,
                                                                             ApplicationAccountContext* context,
                                                                             ComposerWidget* composer);
VALA_EXTERN GType application_composer_command_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType application_send_composer_command_get_type (void) G_GNUC_CONST ;
static void application_controller_send_composed_email_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_);
static void application_controller_real_save_composed_email_data_free (gpointer _data);
static void application_controller_real_save_composed_email (ComposerApplicationInterface* base,
                                                      ComposerWidget* composer,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_);
static gboolean application_controller_real_save_composed_email_co (ApplicationControllerSaveComposedEmailData* _data_);
VALA_EXTERN ApplicationSaveComposerCommand* application_save_composer_command_new (ApplicationController* controller,
                                                                       ComposerWidget* composer);
VALA_EXTERN ApplicationSaveComposerCommand* application_save_composer_command_construct (GType object_type,
                                                                             ApplicationController* controller,
                                                                             ComposerWidget* composer);
VALA_EXTERN GType application_save_composer_command_get_type (void) G_GNUC_CONST ;
static void application_controller_save_composed_email_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_);
static void application_controller_real_discard_composed_email_data_free (gpointer _data);
static void application_controller_real_discard_composed_email (ComposerApplicationInterface* base,
                                                         ComposerWidget* composer,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
static gboolean application_controller_real_discard_composed_email_co (ApplicationControllerDiscardComposedEmailData* _data_);
VALA_EXTERN ApplicationDiscardComposerCommand* application_discard_composer_command_new (ApplicationController* controller,
                                                                             ComposerWidget* composer);
VALA_EXTERN ApplicationDiscardComposerCommand* application_discard_composer_command_construct (GType object_type,
                                                                                   ApplicationController* controller,
                                                                                   ComposerWidget* composer);
VALA_EXTERN GType application_discard_composer_command_get_type (void) G_GNUC_CONST ;
static void application_controller_discard_composed_email_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_);
static void application_controller_expunge_accounts_data_free (gpointer _data);
static gboolean application_controller_expunge_accounts_co (ApplicationControllerExpungeAccountsData* _data_);
static void application_controller_expunge_accounts_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_);
static void application_controller_add_account (ApplicationController* self,
                                         GearyAccountInformation* added);
static void application_controller_open_account_data_free (gpointer _data);
static void application_controller_open_account (ApplicationController* self,
                                          GearyAccount* account,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void application_controller_open_account_finish (ApplicationController* self,
                                                 GAsyncResult* _res_);
static gboolean application_controller_open_account_co (ApplicationControllerOpenAccountData* _data_);
VALA_EXTERN ApplicationContactStore* application_contact_store_new (GearyAccount* account,
                                                        FolksIndividualAggregator* individuals);
VALA_EXTERN ApplicationContactStore* application_contact_store_construct (GType object_type,
                                                              GearyAccount* account,
                                                              FolksIndividualAggregator* individuals);
VALA_EXTERN void application_database_manager_add_account (ApplicationDatabaseManager* self,
                                               GearyAccount* account,
                                               GCancellable* cancellable);
static void application_controller_on_authentication_failure (ApplicationController* self,
                                                       GearyAccountInformation* account,
                                                       GearyServiceInformation* service);
static void _application_controller_on_authentication_failure_geary_account_information_authentication_failure (GearyAccountInformation* _sender,
                                                                                                         GearyServiceInformation* service,
                                                                                                         gpointer self);
static void application_controller_on_untrusted_host (ApplicationController* self,
                                               GearyAccountInformation* account,
                                               GearyServiceInformation* service,
                                               GearyEndpoint* endpoint,
                                               GTlsConnection* cx);
static void _application_controller_on_untrusted_host_geary_account_information_untrusted_host (GearyAccountInformation* _sender,
                                                                                         GearyServiceInformation* service,
                                                                                         GearyEndpoint* endpoint,
                                                                                         GTlsConnection* cx,
                                                                                         gpointer self);
static void application_controller_on_account_status_notify (ApplicationController* self);
static void _application_controller_on_account_status_notify_g_object_notify (GObject* _sender,
                                                                       GParamSpec* pspec,
                                                                       gpointer self);
static void application_controller_on_folders_available_unavailable (ApplicationController* self,
                                                              GearyAccount* account,
                                                              GeeBidirSortedSet* available,
                                                              GeeBidirSortedSet* unavailable);
static void _application_controller_on_folders_available_unavailable_geary_account_folders_available_unavailable (GearyAccount* _sender,
                                                                                                           GeeBidirSortedSet* available,
                                                                                                           GeeBidirSortedSet* unavailable,
                                                                                                           gpointer self);
static void _application_controller_on_report_problem_geary_account_report_problem (GearyAccount* _sender,
                                                                             GearyProblemReport* problem,
                                                                             gpointer self);
static void application_controller_on_sent (ApplicationController* self,
                                     GearySmtpClientService* service,
                                     GearyEmail* sent);
static void _application_controller_on_sent_geary_smtp_client_service_email_sent (GearySmtpClientService* _sender,
                                                                           GearyEmail* email,
                                                                           gpointer self);
static void application_controller_open_account_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
static void application_controller_account_database_error_async (ApplicationController* self,
                                                          GearyAccount* account,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_);
static gboolean application_controller_account_database_error_finish (ApplicationController* self,
                                                               GAsyncResult* _res_);
static void application_controller_update_account_status (ApplicationController* self);
static void application_controller_remove_account_data_free (gpointer _data);
static void application_controller_remove_account (ApplicationController* self,
                                            GearyAccountInformation* removed,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_);
static void application_controller_remove_account_finish (ApplicationController* self,
                                                   GAsyncResult* _res_);
static gboolean application_controller_remove_account_co (ApplicationControllerRemoveAccountData* _data_);
static void application_controller_remove_account_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_);
static void application_controller_close_account_data_free (gpointer _data);
static gboolean application_controller_close_account_co (ApplicationControllerCloseAccountData* _data_);
VALA_EXTERN void application_database_manager_remove_account (ApplicationDatabaseManager* self,
                                                  GearyAccount* account);
VALA_EXTERN void application_contact_store_close (ApplicationContactStore* self);
static void application_controller_close_account_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
VALA_EXTERN gboolean application_account_context_get_authentication_failed (ApplicationAccountContext* self);
VALA_EXTERN gboolean application_account_context_get_tls_validation_failed (ApplicationAccountContext* self);
static gboolean application_controller_is_currently_prompting (ApplicationController* self);
static gboolean __lambda151_ (ApplicationController* self,
                       ApplicationAccountContext* ctx,
                       gboolean seed);
VALA_EXTERN gboolean application_account_context_get_authentication_prompting (ApplicationAccountContext* self);
VALA_EXTERN gboolean application_account_context_get_tls_validation_prompting (ApplicationAccountContext* self);
static gpointer ___lambda151__gee_fold_func (gpointer g,
                                      gpointer a,
                                      gpointer self);
static void application_controller_prompt_for_password_data_free (gpointer _data);
static void application_controller_prompt_for_password (ApplicationController* self,
                                                 ApplicationAccountContext* context,
                                                 GearyServiceInformation* service,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static void application_controller_prompt_for_password_finish (ApplicationController* self,
                                                        GAsyncResult* _res_);
static gboolean application_controller_prompt_for_password_co (ApplicationControllerPromptForPasswordData* _data_);
VALA_EXTERN guint application_account_context_get_authentication_attempts (ApplicationAccountContext* self);
VALA_EXTERN void application_account_context_set_authentication_prompting (ApplicationAccountContext* self,
                                                               gboolean value);
static void application_controller_prompt_for_password_ready (GObject* source_object,
                                                       GAsyncResult* _res_,
                                                       gpointer _user_data_);
VALA_EXTERN void application_account_context_set_authentication_attempts (ApplicationAccountContext* self,
                                                              guint value);
VALA_EXTERN void application_account_context_set_authentication_failed (ApplicationAccountContext* self,
                                                            gboolean value);
static void application_controller_prompt_untrusted_host_data_free (gpointer _data);
static void application_controller_prompt_untrusted_host (ApplicationController* self,
                                                   ApplicationAccountContext* context,
                                                   GearyServiceInformation* service,
                                                   GearyEndpoint* endpoint,
                                                   GTlsConnection* cx,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_);
static void application_controller_prompt_untrusted_host_finish (ApplicationController* self,
                                                          GAsyncResult* _res_);
static gboolean application_controller_prompt_untrusted_host_co (ApplicationControllerPromptUntrustedHostData* _data_);
VALA_EXTERN void application_account_context_set_tls_validation_prompting (ApplicationAccountContext* self,
                                                               gboolean value);
static void application_controller_prompt_untrusted_host_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
VALA_EXTERN void application_account_context_set_tls_validation_failed (ApplicationAccountContext* self,
                                                            gboolean value);
static void application_controller_account_database_error_async_data_free (gpointer _data);
static gboolean application_controller_account_database_error_async_co (ApplicationControllerAccountDatabaseErrorAsyncData* _data_);
VALA_EXTERN GType alert_dialog_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType question_dialog_get_type (void) G_GNUC_CONST ;
VALA_EXTERN QuestionDialog* question_dialog_new (GtkWindow* parent,
                                     const gchar* title,
                                     const gchar* description,
                                     const gchar* yes_button,
                                     const gchar* no_button);
VALA_EXTERN QuestionDialog* question_dialog_construct (GType object_type,
                                           GtkWindow* parent,
                                           const gchar* title,
                                           const gchar* description,
                                           const gchar* yes_button,
                                           const gchar* no_button);
VALA_EXTERN void alert_dialog_use_secondary_markup (AlertDialog* self,
                                        gboolean markup);
VALA_EXTERN GtkResponseType alert_dialog_run (AlertDialog* self);
static void application_controller_account_database_error_async_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_);
VALA_EXTERN GType error_dialog_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ErrorDialog* error_dialog_new (GtkWindow* parent,
                               const gchar* title,
                               const gchar* description);
VALA_EXTERN ErrorDialog* error_dialog_construct (GType object_type,
                                     GtkWindow* parent,
                                     const gchar* title,
                                     const gchar* description);
VALA_EXTERN void application_controller_clear_new_messages (ApplicationController* self,
                                                GearyFolder* source,
                                                GeeSet* visible);
VALA_EXTERN GType application_notification_plugin_context_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GeeCollection* application_plugin_manager_get_notification_contexts (ApplicationPluginManager* self);
VALA_EXTERN void application_notification_plugin_context_clear_new_messages (ApplicationNotificationPluginContext* self,
                                                                 GearyFolder* location,
                                                                 GeeSet* visible);
VALA_EXTERN void application_controller_email_loaded (ApplicationController* self,
                                          GearyAccountInformation* account,
                                          GearyEmail* loaded);
VALA_EXTERN GType application_email_plugin_context_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GeeCollection* application_plugin_manager_get_email_contexts (ApplicationPluginManager* self);
VALA_EXTERN void application_email_plugin_context_email_displayed (ApplicationEmailPluginContext* self,
                                                       GearyAccountInformation* account,
                                                       GearyEmail* email);
VALA_EXTERN void application_controller_window_focus_in (ApplicationController* self);
static void _g_cancellable_cancel_g_cancellable_cancelled (GCancellable* _sender,
                                                    gpointer self);
VALA_EXTERN void application_controller_window_focus_out (ApplicationController* self);
VALA_EXTERN void application_main_window_show_composer (ApplicationMainWindow* self,
                                            ComposerWidget* composer);
VALA_EXTERN gboolean application_controller_check_open_composers (ApplicationController* self);
static void application_controller_on_composer_widget_destroy (ApplicationController* self,
                                                        GtkWidget* sender);
static void _application_controller_on_composer_widget_destroy_gtk_widget_destroy (GtkWidget* _sender,
                                                                            gpointer self);
VALA_EXTERN void application_email_plugin_context_email_sent (ApplicationEmailPluginContext* self,
                                                  GearyAccountInformation* account,
                                                  GearyEmail* email);
static void application_controller_do_background_storage_cleanup (ApplicationController* self,
                                                           GAsyncReadyCallback _callback_,
                                                           gpointer _user_data_);
static void application_controller_do_background_storage_cleanup_finish (ApplicationController* self,
                                                                  GAsyncResult* _res_);
static void application_controller_do_background_storage_cleanup_data_free (gpointer _data);
static gboolean application_controller_do_background_storage_cleanup_co (ApplicationControllerDoBackgroundStorageCleanupData* _data_);
static void application_controller_do_background_storage_cleanup_ready (GObject* source_object,
                                                                 GAsyncResult* _res_,
                                                                 gpointer _user_data_);
VALA_EXTERN ApplicationAccountContext* application_account_interface_get_context_for_account (ApplicationAccountInterface* self,
                                                                                  GearyAccountInformation* account);
VALA_EXTERN GeeCollection* application_account_interface_get_account_contexts (ApplicationAccountInterface* self);
VALA_EXTERN void composer_application_interface_send_composed_email (ComposerApplicationInterface* self,
                                                         ComposerWidget* composer,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
VALA_EXTERN void composer_application_interface_send_composed_email_finish (ComposerApplicationInterface* self,
                                                                GAsyncResult* _res_);
VALA_EXTERN void composer_application_interface_save_composed_email (ComposerApplicationInterface* self,
                                                         ComposerWidget* composer,
                                                         GAsyncReadyCallback _callback_,
                                                         gpointer _user_data_);
VALA_EXTERN void composer_application_interface_save_composed_email_finish (ComposerApplicationInterface* self,
                                                                GAsyncResult* _res_);
VALA_EXTERN void composer_application_interface_discard_composed_email (ComposerApplicationInterface* self,
                                                            ComposerWidget* composer,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
VALA_EXTERN void composer_application_interface_discard_composed_email_finish (ComposerApplicationInterface* self,
                                                                   GAsyncResult* _res_);
static void application_controller_finalize (GObject * obj);
static GType application_controller_get_type_once (void);
static void _vala_application_controller_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_application_controller_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
VALA_EXTERN ApplicationControllerCommandStack* application_controller_command_stack_new (void);
VALA_EXTERN ApplicationControllerCommandStack* application_controller_command_stack_construct (GType object_type);
static void __lambda4_ (ApplicationControllerCommandStack* self);
static void ___lambda4__geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                     gpointer self);
static void application_controller_command_stack_real_execute_data_free (gpointer _data);
static void application_controller_command_stack_real_execute (ApplicationCommandStack* base,
                                                        ApplicationCommand* target,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
static gboolean application_controller_command_stack_real_execute_co (ApplicationControllerCommandStackExecuteData* _data_);
static void application_controller_command_stack_execute_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_);
static void application_controller_command_stack_real_undo_data_free (gpointer _data);
static void application_controller_command_stack_real_undo (ApplicationCommandStack* base,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean application_controller_command_stack_real_undo_co (ApplicationControllerCommandStackUndoData* _data_);
static void application_controller_command_stack_undo_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static void application_controller_command_stack_real_redo_data_free (gpointer _data);
static void application_controller_command_stack_real_redo (ApplicationCommandStack* base,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean application_controller_command_stack_real_redo_co (ApplicationControllerCommandStackRedoData* _data_);
static void application_controller_command_stack_redo_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
VALA_EXTERN ApplicationEmailCommandStateChangePolicy application_email_command_folders_removed (ApplicationEmailCommand* self,
                                                                                    GeeCollection* removed);
VALA_EXTERN ApplicationEmailCommandStateChangePolicy application_email_command_email_removed (ApplicationEmailCommand* self,
                                                                                  GearyFolder* location,
                                                                                  GeeCollection* targets);
static void application_controller_command_stack_finalize (GObject * obj);
static GType application_controller_command_stack_get_type_once (void);
static void application_email_command_set_conversations (ApplicationEmailCommand* self,
                                                  GeeCollection* value);
static void application_email_command_set_email (ApplicationEmailCommand* self,
                                          GeeCollection* value);
static gboolean application_email_command_real_equal_to (ApplicationCommand* base,
                                                  ApplicationCommand* other);
static ApplicationEmailCommandStateChangePolicy application_email_command_real_folders_removed (ApplicationEmailCommand* self,
                                                                                         GeeCollection* removed);
static ApplicationEmailCommandStateChangePolicy application_email_command_real_email_removed (ApplicationEmailCommand* self,
                                                                                       GearyFolder* location,
                                                                                       GeeCollection* targets);
static void application_email_command_finalize (GObject * obj);
static GType application_email_command_get_type_once (void);
static void _vala_application_email_command_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_application_email_command_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);
static GType application_trivial_command_get_type_once (void);
static void application_mark_email_command_real_execute_data_free (gpointer _data);
static void application_mark_email_command_real_execute (ApplicationCommand* base,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static gboolean application_mark_email_command_real_execute_co (ApplicationMarkEmailCommandExecuteData* _data_);
static void application_mark_email_command_execute_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void application_mark_email_command_real_undo_data_free (gpointer _data);
static void application_mark_email_command_real_undo (ApplicationCommand* base,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static gboolean application_mark_email_command_real_undo_co (ApplicationMarkEmailCommandUndoData* _data_);
static void application_mark_email_command_undo_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
static gboolean application_mark_email_command_real_equal_to (ApplicationCommand* base,
                                                       ApplicationCommand* other);
static void application_mark_email_command_finalize (GObject * obj);
static GType application_mark_email_command_get_type_once (void);
VALA_EXTERN ApplicationRevokableCommand* application_revokable_command_construct (GType object_type,
                                                                      GearyFolder* location,
                                                                      GeeCollection* conversations,
                                                                      GeeCollection* email);
static void application_revokable_command_real_execute_data_free (gpointer _data);
static void application_revokable_command_real_execute (ApplicationCommand* base,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static gboolean application_revokable_command_real_execute_co (ApplicationRevokableCommandExecuteData* _data_);
VALA_EXTERN void application_revokable_command_execute_impl (ApplicationRevokableCommand* self,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
VALA_EXTERN GearyRevokable* application_revokable_command_execute_impl_finish (ApplicationRevokableCommand* self,
                                                                   GAsyncResult* _res_,
                                                                   GError** error);
static void application_revokable_command_execute_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_);
static void application_revokable_command_set_revokable (ApplicationRevokableCommand* self,
                                                  GearyRevokable* updated);
static void application_revokable_command_real_undo_data_free (gpointer _data);
static void application_revokable_command_real_undo (ApplicationCommand* base,
                                              GCancellable* cancellable,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_);
static gboolean application_revokable_command_real_undo_co (ApplicationRevokableCommandUndoData* _data_);
static void application_revokable_command_undo_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
static void application_revokable_command_on_revokable_committed (ApplicationRevokableCommand* self,
                                                           GearyRevokable* updated);
static void _application_revokable_command_on_revokable_committed_geary_revokable_committed (GearyRevokable* _sender,
                                                                                      GearyRevokable* commit_revokable,
                                                                                      gpointer self);
static void application_revokable_command_finalize (GObject * obj);
static GType application_revokable_command_get_type_once (void);
static void _vala_application_revokable_command_get_property (GObject * object,
                                                       guint property_id,
                                                       GValue * value,
                                                       GParamSpec * pspec);
static ApplicationEmailCommandStateChangePolicy application_move_email_command_real_folders_removed (ApplicationEmailCommand* base,
                                                                                              GeeCollection* removed);
static ApplicationEmailCommandStateChangePolicy application_move_email_command_real_email_removed (ApplicationEmailCommand* base,
                                                                                            GearyFolder* location,
                                                                                            GeeCollection* targets);
static void application_move_email_command_real_execute_impl_data_free (gpointer _data);
static void application_move_email_command_real_execute_impl (ApplicationRevokableCommand* base,
                                                       GCancellable* cancellable,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_);
static gboolean application_move_email_command_real_execute_impl_co (ApplicationMoveEmailCommandExecuteImplData* _data_);
static void application_move_email_command_execute_impl_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_);
static void application_move_email_command_finalize (GObject * obj);
static GType application_move_email_command_get_type_once (void);
VALA_EXTERN GearyFolder* application_archive_email_command_get_command_location (ApplicationArchiveEmailCommand* self);
VALA_EXTERN void application_archive_email_command_set_command_location (ApplicationArchiveEmailCommand* self,
                                                             GearyFolder* value);
VALA_EXTERN GeeCollection* application_archive_email_command_get_command_conversations (ApplicationArchiveEmailCommand* self);
VALA_EXTERN void application_archive_email_command_set_command_conversations (ApplicationArchiveEmailCommand* self,
                                                                  GeeCollection* value);
VALA_EXTERN GeeCollection* application_archive_email_command_get_command_email (ApplicationArchiveEmailCommand* self);
VALA_EXTERN void application_archive_email_command_set_command_email (ApplicationArchiveEmailCommand* self,
                                                          GeeCollection* value);
static ApplicationEmailCommandStateChangePolicy application_archive_email_command_real_folders_removed (ApplicationEmailCommand* base,
                                                                                                 GeeCollection* removed);
static ApplicationEmailCommandStateChangePolicy application_archive_email_command_real_email_removed (ApplicationEmailCommand* base,
                                                                                               GearyFolder* location,
                                                                                               GeeCollection* targets);
static void application_archive_email_command_real_execute_impl_data_free (gpointer _data);
static void application_archive_email_command_real_execute_impl (ApplicationRevokableCommand* base,
                                                          GCancellable* cancellable,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_);
static gboolean application_archive_email_command_real_execute_impl_co (ApplicationArchiveEmailCommandExecuteImplData* _data_);
static void application_archive_email_command_execute_impl_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_);
static void application_archive_email_command_finalize (GObject * obj);
static GType application_archive_email_command_get_type_once (void);
static void _vala_application_archive_email_command_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec);
static void _vala_application_archive_email_command_set_property (GObject * object,
                                                           guint property_id,
                                                           const GValue * value,
                                                           GParamSpec * pspec);
static void application_copy_email_command_real_execute_data_free (gpointer _data);
static void application_copy_email_command_real_execute (ApplicationCommand* base,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static gboolean application_copy_email_command_real_execute_co (ApplicationCopyEmailCommandExecuteData* _data_);
static void application_copy_email_command_execute_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
static void application_copy_email_command_real_undo_data_free (gpointer _data);
static void application_copy_email_command_real_undo (ApplicationCommand* base,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
static gboolean application_copy_email_command_real_undo_co (ApplicationCopyEmailCommandUndoData* _data_);
static ApplicationEmailCommandStateChangePolicy application_copy_email_command_real_folders_removed (ApplicationEmailCommand* base,
                                                                                              GeeCollection* removed);
static ApplicationEmailCommandStateChangePolicy application_copy_email_command_real_email_removed (ApplicationEmailCommand* base,
                                                                                            GearyFolder* location,
                                                                                            GeeCollection* targets);
static void application_copy_email_command_finalize (GObject * obj);
static GType application_copy_email_command_get_type_once (void);
static void _vala_application_copy_email_command_get_property (GObject * object,
                                                        guint property_id,
                                                        GValue * value,
                                                        GParamSpec * pspec);
static void application_delete_email_command_real_execute_data_free (gpointer _data);
static void application_delete_email_command_real_execute (ApplicationCommand* base,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
static gboolean application_delete_email_command_real_execute_co (ApplicationDeleteEmailCommandExecuteData* _data_);
static void application_delete_email_command_execute_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
static void application_delete_email_command_real_undo_data_free (gpointer _data);
static void application_delete_email_command_real_undo (ApplicationCommand* base,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static gboolean application_delete_email_command_real_undo_co (ApplicationDeleteEmailCommandUndoData* _data_);
static void application_delete_email_command_finalize (GObject * obj);
static GType application_delete_email_command_get_type_once (void);
static void _vala_application_delete_email_command_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static void application_empty_folder_command_real_execute_data_free (gpointer _data);
static void application_empty_folder_command_real_execute (ApplicationCommand* base,
                                                    GCancellable* cancellable,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
static gboolean application_empty_folder_command_real_execute_co (ApplicationEmptyFolderCommandExecuteData* _data_);
static void application_empty_folder_command_execute_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_);
static void application_empty_folder_command_real_undo_data_free (gpointer _data);
static void application_empty_folder_command_real_undo (ApplicationCommand* base,
                                                 GCancellable* cancellable,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_);
static gboolean application_empty_folder_command_real_undo_co (ApplicationEmptyFolderCommandUndoData* _data_);
static gboolean application_empty_folder_command_real_equal_to (ApplicationCommand* base,
                                                         ApplicationCommand* other);
static void application_empty_folder_command_finalize (GObject * obj);
static GType application_empty_folder_command_get_type_once (void);
static void _vala_application_empty_folder_command_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
VALA_EXTERN ComposerWidget* application_composer_command_get_composer (ApplicationComposerCommand* self);
static void application_composer_command_set_composer (ApplicationComposerCommand* self,
                                                ComposerWidget* value);
VALA_EXTERN ApplicationComposerCommand* application_composer_command_construct (GType object_type,
                                                                    ComposerWidget* composer);
VALA_EXTERN void application_composer_command_clear_composer (ApplicationComposerCommand* self);
VALA_EXTERN void application_composer_command_close_composer (ApplicationComposerCommand* self);
static void application_composer_command_finalize (GObject * obj);
static GType application_composer_command_get_type_once (void);
static void _vala_application_composer_command_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec);
static void _vala_application_composer_command_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec);
static void application_send_composer_command_on_commit_timeout (ApplicationSendComposerCommand* self);
static void _application_send_composer_command_on_commit_timeout_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                              gpointer self);
static void application_send_composer_command_real_execute_data_free (gpointer _data);
static void application_send_composer_command_real_execute (ApplicationCommand* base,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean application_send_composer_command_real_execute_co (ApplicationSendComposerCommandExecuteData* _data_);
static void application_send_composer_command_execute_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static void application_send_composer_command_real_undo_data_free (gpointer _data);
static void application_send_composer_command_real_undo (ApplicationCommand* base,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static gboolean application_send_composer_command_real_undo_co (ApplicationSendComposerCommandUndoData* _data_);
static void application_send_composer_command_undo_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_);
VALA_EXTERN ApplicationController* application_client_get_controller (ApplicationClient* self);
static void application_send_composer_command_finalize (GObject * obj);
static GType application_send_composer_command_get_type_once (void);
static void _vala_application_send_composer_command_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec);
static void application_save_composer_command_on_destroy_timeout (ApplicationSaveComposerCommand* self);
static void _application_save_composer_command_on_destroy_timeout_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                               gpointer self);
static void application_save_composer_command_real_execute_data_free (gpointer _data);
static void application_save_composer_command_real_execute (ApplicationCommand* base,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean application_save_composer_command_real_execute_co (ApplicationSaveComposerCommandExecuteData* _data_);
static void application_save_composer_command_real_undo_data_free (gpointer _data);
static void application_save_composer_command_real_undo (ApplicationCommand* base,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static gboolean application_save_composer_command_real_undo_co (ApplicationSaveComposerCommandUndoData* _data_);
static void application_save_composer_command_finalize (GObject * obj);
static GType application_save_composer_command_get_type_once (void);
static void _vala_application_save_composer_command_get_property (GObject * object,
                                                           guint property_id,
                                                           GValue * value,
                                                           GParamSpec * pspec);
static void application_discard_composer_command_on_destroy_timeout (ApplicationDiscardComposerCommand* self);
static void _application_discard_composer_command_on_destroy_timeout_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                                  gpointer self);
static void application_discard_composer_command_real_execute_data_free (gpointer _data);
static void application_discard_composer_command_real_execute (ApplicationCommand* base,
                                                        GCancellable* cancellable,
                                                        GAsyncReadyCallback _callback_,
                                                        gpointer _user_data_);
static gboolean application_discard_composer_command_real_execute_co (ApplicationDiscardComposerCommandExecuteData* _data_);
static void application_discard_composer_command_real_undo_data_free (gpointer _data);
static void application_discard_composer_command_real_undo (ApplicationCommand* base,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_);
static gboolean application_discard_composer_command_real_undo_co (ApplicationDiscardComposerCommandUndoData* _data_);
static void application_discard_composer_command_finalize (GObject * obj);
static GType application_discard_composer_command_get_type_once (void);
static void _vala_application_discard_composer_command_get_property (GObject * object,
                                                              guint property_id,
                                                              GValue * value,
                                                              GParamSpec * pspec);
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 inline gpointer
application_controller_get_instance_private (ApplicationController* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationController_private_offset);
}

/** Determines if conversations can be trashed from the given folder. */
gboolean
application_controller_does_folder_support_trash (GearyFolder* target)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean result;
	g_return_val_if_fail ((target == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (target, GEARY_TYPE_FOLDER), FALSE);
	if (target != NULL) {
		GearyFolderSpecialUse _tmp3_;
		GearyFolderSpecialUse _tmp4_;
		_tmp3_ = geary_folder_get_used_as (target);
		_tmp4_ = _tmp3_;
		_tmp2_ = _tmp4_ != GEARY_FOLDER_SPECIAL_USE_TRASH;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		GearyFolderProperties* _tmp5_;
		GearyFolderProperties* _tmp6_;
		gboolean _tmp7_;
		gboolean _tmp8_;
		_tmp5_ = geary_folder_get_properties (target);
		_tmp6_ = _tmp5_;
		_tmp7_ = geary_folder_properties_get_is_local_only (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp1_ = !_tmp8_;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = (G_TYPE_CHECK_INSTANCE_TYPE (target, GEARY_FOLDER_SUPPORT_TYPE_MOVE) ? ((GearyFolderSupportMove*) target) : NULL) != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

/** Determines if folders should be added to main windows. */
static gboolean
application_controller_should_add_folder (GeeCollection* all,
                                          GearyFolder* folder)
{
	GearyFolderProperties* _tmp0_;
	GearyFolderProperties* _tmp1_;
	GearyTrillian _tmp2_;
	GearyTrillian _tmp3_;
	GearyFolderSpecialUse type = 0;
	GearyFolderSpecialUse _tmp8_;
	GearyFolderSpecialUse _tmp9_;
	gboolean result;
	g_return_val_if_fail ((all == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (all, GEE_TYPE_COLLECTION), FALSE);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (folder, GEARY_TYPE_FOLDER), FALSE);
	_tmp0_ = geary_folder_get_properties (folder);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_folder_properties_get_is_openable (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != GEARY_TRILLIAN_FALSE) {
		result = TRUE;
		return result;
	} else {
		GearyFolderProperties* _tmp4_;
		GearyFolderProperties* _tmp5_;
		GearyTrillian _tmp6_;
		GearyTrillian _tmp7_;
		_tmp4_ = geary_folder_get_properties (folder);
		_tmp5_ = _tmp4_;
		_tmp6_ = geary_folder_properties_get_has_children (_tmp5_);
		_tmp7_ = _tmp6_;
		if (_tmp7_ == GEARY_TRILLIAN_FALSE) {
			result = FALSE;
			return result;
		}
	}
	_tmp8_ = geary_folder_get_used_as (folder);
	_tmp9_ = _tmp8_;
	type = _tmp9_;
	{
		GeeIterator* _other_it = NULL;
		GeeIterator* _tmp10_;
		_tmp10_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (all, GEE_TYPE_ITERABLE, GeeIterable));
		_other_it = _tmp10_;
		while (TRUE) {
			GeeIterator* _tmp11_;
			GearyFolder* other = NULL;
			GeeIterator* _tmp12_;
			gpointer _tmp13_;
			gboolean _tmp14_ = FALSE;
			GearyFolder* _tmp15_;
			GearyFolderSpecialUse _tmp16_;
			GearyFolderSpecialUse _tmp17_;
			_tmp11_ = _other_it;
			if (!gee_iterator_next (_tmp11_)) {
				break;
			}
			_tmp12_ = _other_it;
			_tmp13_ = gee_iterator_get (_tmp12_);
			other = (GearyFolder*) _tmp13_;
			_tmp15_ = other;
			_tmp16_ = geary_folder_get_used_as (_tmp15_);
			_tmp17_ = _tmp16_;
			if (_tmp17_ == type) {
				GearyFolder* _tmp18_;
				GearyFolderPath* _tmp19_;
				GearyFolderPath* _tmp20_;
				GearyFolderPath* _tmp21_;
				GearyFolderPath* _tmp22_;
				GearyFolderPath* _tmp23_;
				GearyFolderPath* _tmp24_;
				_tmp18_ = other;
				_tmp19_ = geary_folder_get_path (_tmp18_);
				_tmp20_ = _tmp19_;
				_tmp21_ = geary_folder_path_get_parent (_tmp20_);
				_tmp22_ = _tmp21_;
				_tmp23_ = geary_folder_get_path (folder);
				_tmp24_ = _tmp23_;
				_tmp14_ = _tmp22_ == _tmp24_;
			} else {
				_tmp14_ = FALSE;
			}
			if (_tmp14_) {
				result = TRUE;
				_g_object_unref0 (other);
				_g_object_unref0 (_other_it);
				return result;
			}
			_g_object_unref0 (other);
		}
		_g_object_unref0 (_other_it);
	}
	result = FALSE;
	return result;
}

gboolean
application_controller_get_is_open (ApplicationController* self)
{
	gboolean result;
	GCancellable* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), FALSE);
	_tmp0_ = self->priv->controller_open;
	result = !g_cancellable_is_cancelled (_tmp0_);
	return result;
}

ApplicationClient*
application_controller_get_application (ApplicationController* self)
{
	ApplicationClient* result;
	ApplicationClient* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), NULL);
	_tmp0_ = self->priv->_application;
	result = _tmp0_;
	return result;
}

static void
application_controller_set_application (ApplicationController* self,
                                        ApplicationClient* value)
{
	ApplicationClient* old_value;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	old_value = application_controller_get_application (self);
	if (old_value != value) {
		self->priv->_application = value;
		g_object_notify_by_pspec ((GObject *) self, application_controller_properties[APPLICATION_CONTROLLER_APPLICATION_PROPERTY]);
	}
}

AccountsManager*
application_controller_get_account_manager (ApplicationController* self)
{
	AccountsManager* result;
	AccountsManager* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), NULL);
	_tmp0_ = self->priv->_account_manager;
	result = _tmp0_;
	return result;
}

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

static void
application_controller_set_account_manager (ApplicationController* self,
                                            AccountsManager* value)
{
	AccountsManager* old_value;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	old_value = application_controller_get_account_manager (self);
	if (old_value != value) {
		AccountsManager* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_account_manager);
		self->priv->_account_manager = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_controller_properties[APPLICATION_CONTROLLER_ACCOUNT_MANAGER_PROPERTY]);
	}
}

ApplicationPluginManager*
application_controller_get_plugins (ApplicationController* self)
{
	ApplicationPluginManager* result;
	ApplicationPluginManager* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), NULL);
	_tmp0_ = self->priv->_plugins;
	result = _tmp0_;
	return result;
}

static void
application_controller_set_plugins (ApplicationController* self,
                                    ApplicationPluginManager* value)
{
	ApplicationPluginManager* old_value;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	old_value = application_controller_get_plugins (self);
	if (old_value != value) {
		ApplicationPluginManager* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_plugins);
		self->priv->_plugins = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_controller_properties[APPLICATION_CONTROLLER_PLUGINS_PROPERTY]);
	}
}

ApplicationCertificateManager*
application_controller_get_certificate_manager (ApplicationController* self)
{
	ApplicationCertificateManager* result;
	ApplicationCertificateManager* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), NULL);
	_tmp0_ = self->priv->_certificate_manager;
	result = _tmp0_;
	return result;
}

static void
application_controller_set_certificate_manager (ApplicationController* self,
                                                ApplicationCertificateManager* value)
{
	ApplicationCertificateManager* old_value;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	old_value = application_controller_get_certificate_manager (self);
	if (old_value != value) {
		ApplicationCertificateManager* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_certificate_manager);
		self->priv->_certificate_manager = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_controller_properties[APPLICATION_CONTROLLER_CERTIFICATE_MANAGER_PROPERTY]);
	}
}

static void
application_controller_construct_data_free (gpointer _data)
{
	ApplicationControllerNewData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->application);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerNewData, _data_);
}

void
application_controller_construct (GType object_type,
                                  ApplicationClient* application,
                                  GCancellable* cancellable,
                                  GAsyncReadyCallback _callback_,
                                  gpointer _user_data_)
{
	ApplicationControllerNewData* _data_;
	ApplicationClient* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CLIENT (application));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	_data_ = g_slice_new0 (ApplicationControllerNewData);
	_data_->_async_result = g_task_new (NULL, cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_construct_data_free);
	_data_->object_type = object_type;
	_tmp0_ = _g_object_ref0 (application);
	_g_object_unref0 (_data_->application);
	_data_->application = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_controller_construct_co (_data_);
}

ApplicationController*
application_controller_construct_finish (GAsyncResult* _res_,
                                         GError** error)
{
	ApplicationController* result;
	ApplicationControllerNewData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->self;
	_data_->self = NULL;
	return result;
}

/**
     * Constructs a new instance of the controller.
     */
static void
_application_controller_on_unfocused_idle_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                              gpointer self)
{
	application_controller_on_unfocused_idle ((ApplicationController*) self);
}

static void
___lambda150_ (ApplicationController* 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 ()));
	{
		FolksIndividualAggregator* _tmp0_;
		_tmp0_ = self->priv->folks;
		folks_individual_aggregator_prepare_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;
		g_warning ("application-controller.vala:160: Error preparing Folks: %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
____lambda150__gasync_ready_callback (GObject* source_object,
                                      GAsyncResult* res,
                                      gpointer self)
{
	___lambda150_ ((ApplicationController*) self, source_object, res);
	g_object_unref (self);
}

static void
application_controller_new_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_)
{
	ApplicationControllerNewData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_construct_co (_data_);
}

static void
_application_controller_on_account_available_geary_engine_account_available (GearyEngine* _sender,
                                                                             GearyAccountInformation* account,
                                                                             gpointer self)
{
	application_controller_on_account_available ((ApplicationController*) self, account);
}

static void
_application_controller_on_account_added_accounts_manager_account_added (AccountsManager* _sender,
                                                                         GearyAccountInformation* added,
                                                                         AccountsManagerStatus status,
                                                                         gpointer self)
{
	application_controller_on_account_added ((ApplicationController*) self, added, status);
}

static void
_application_controller_on_account_status_changed_accounts_manager_account_status_changed (AccountsManager* _sender,
                                                                                           GearyAccountInformation* changed,
                                                                                           AccountsManagerStatus new_status,
                                                                                           gpointer self)
{
	application_controller_on_account_status_changed ((ApplicationController*) self, changed, new_status);
}

static void
_application_controller_on_account_removed_accounts_manager_account_removed (AccountsManager* _sender,
                                                                             GearyAccountInformation* removed,
                                                                             gpointer self)
{
	application_controller_on_account_removed ((ApplicationController*) self, removed);
}

static void
_application_controller_on_report_problem_accounts_manager_report_problem (AccountsManager* _sender,
                                                                           GearyProblemReport* problem,
                                                                           gpointer self)
{
	application_controller_on_report_problem ((ApplicationController*) self, problem);
}

static gboolean
application_controller_construct_co (ApplicationControllerNewData* _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:
	_data_->self = (ApplicationController*) geary_base_object_construct (_data_->object_type);
	application_controller_set_application (_data_->self, _data_->application);
	_data_->_tmp0_ = _g_object_ref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self->priv->controller_open);
	_data_->self->priv->controller_open = _data_->_tmp0_;
	_data_->_tmp1_ = application_client_get_home_config_directory (_data_->application);
	_data_->config_dir = _data_->_tmp1_;
	_data_->_tmp2_ = application_client_get_home_data_directory (_data_->application);
	_data_->data_dir = _data_->_tmp2_;
	_data_->_tmp3_ = application_client_get_resource_directory (_data_->application);
	_data_->_tmp4_ = _data_->_tmp3_;
	icon_factory_init (_data_->_tmp4_);
	_g_object_unref0 (_data_->_tmp4_);
	_data_->_tmp5_ = application_database_manager_new (_data_->application);
	_g_object_unref0 (_data_->self->priv->database_manager);
	_data_->self->priv->database_manager = _data_->_tmp5_;
	_data_->_tmp6_ = _data_->self->priv->_application;
	_data_->_tmp7_ = application_client_get_config (_data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = _data_->self->priv->_application;
	_data_->_tmp10_ = application_client_get_web_extensions_dir (_data_->_tmp9_);
	_data_->_tmp11_ = _data_->_tmp10_;
	_data_->_tmp12_ = _data_->self->priv->_application;
	_data_->_tmp13_ = application_client_get_home_cache_directory (_data_->_tmp12_);
	_data_->_tmp14_ = _data_->_tmp13_;
	_data_->_tmp15_ = g_file_get_child (_data_->_tmp14_, "web-resources");
	_data_->_tmp16_ = _data_->_tmp15_;
	components_web_view_init_web_context (_data_->_tmp8_, _data_->_tmp11_, _data_->_tmp16_, TRUE);
	_g_object_unref0 (_data_->_tmp16_);
	_g_object_unref0 (_data_->_tmp14_);
	_g_object_unref0 (_data_->_tmp11_);
	_data_->_tmp17_ = _data_->config_dir;
	components_web_view_load_resources (_data_->_tmp17_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	composer_web_view_load_resources (&_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	conversation_web_view_load_resources (&_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	accounts_signature_web_view_load_resources (&_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp18_ = geary_timeout_manager_new_seconds (APPLICATION_CONTROLLER_CLEANUP_CHECK_AFTER_IDLE_BACKGROUND_MINUTES * 60, _application_controller_on_unfocused_idle_geary_timeout_manager_timeout_func, _data_->self);
	_g_object_unref0 (_data_->self->priv->all_windows_backgrounded_timeout);
	_data_->self->priv->all_windows_backgrounded_timeout = _data_->_tmp18_;
	_data_->_tmp19_ = folks_individual_aggregator_dup ();
	_g_object_unref0 (_data_->self->priv->folks);
	_data_->self->priv->folks = _data_->_tmp19_;
	_data_->_tmp20_ = _data_->self->priv->folks;
	_data_->_tmp21_ = folks_individual_aggregator_get_is_prepared (_data_->_tmp20_);
	_data_->_tmp22_ = _data_->_tmp21_;
	if (!_data_->_tmp22_) {
		_data_->_tmp23_ = _data_->self->priv->folks;
		folks_individual_aggregator_prepare (_data_->_tmp23_, ____lambda150__gasync_ready_callback, g_object_ref (_data_->self));
	}
	_data_->_tmp25_ = _data_->self->priv->_application;
	_data_->_tmp26_ = _data_->self->priv->_application;
	_data_->_tmp27_ = application_client_get_config (_data_->_tmp26_);
	_data_->_tmp28_ = _data_->_tmp27_;
	_data_->_tmp29_ = _data_->self->priv->_application;
	_data_->_tmp30_ = application_client_get_app_plugins_dir (_data_->_tmp29_);
	_data_->_tmp31_ = _data_->_tmp30_;
	_data_->_tmp32_ = application_plugin_manager_new (_data_->_tmp25_, _data_->self, _data_->_tmp28_, _data_->_tmp31_, &_data_->_inner_error0_);
	_data_->_tmp33_ = _data_->_tmp32_;
	_g_object_unref0 (_data_->_tmp31_);
	_data_->_tmp24_ = _data_->_tmp33_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	application_controller_set_plugins (_data_->self, _data_->_tmp24_);
	{
		_data_->_tmp34_ = _data_->config_dir;
		g_file_make_directory_with_parents (_data_->_tmp34_, NULL, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_EXISTS)) {
				goto __catch0_g_io_error_exists;
			}
			goto __finally0;
		}
	}
	goto __finally0;
	__catch0_g_io_error_exists:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp24_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp35_ = _data_->config_dir;
	_data_->_tmp36_ = _data_->data_dir;
	util_migrate_xdg_config_dir (_data_->_tmp35_, _data_->_tmp36_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp24_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp37_ = 0;
	_data_->_tmp38_ = application_client_get_config_search_path (_data_->application, &_data_->_tmp37_);
	_data_->_tmp39_ = _data_->_tmp38_;
	_data_->_tmp39__length1 = _data_->_tmp37_;
	_data_->_tmp40_ = _data_->config_dir;
	util_migrate_release_config (_data_->_tmp39_, (gint) _data_->_tmp37_, _data_->_tmp40_, &_data_->_inner_error0_);
	_data_->_tmp39_ = (_vala_array_free (_data_->_tmp39_, _data_->_tmp39__length1, (GDestroyNotify) g_object_unref), NULL);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp24_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp41_ = _data_->data_dir;
	_data_->_tmp42_ = g_file_get_child (_data_->_tmp41_, "pinned-certs");
	_data_->_tmp43_ = _data_->_tmp42_;
	_data_->_state_ = 1;
	application_certificate_manager_new (_data_->_tmp43_, _data_->cancellable, application_controller_new_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp44_ = application_certificate_manager_new_finish (_data_->_res_);
	_data_->_tmp45_ = _data_->_tmp44_;
	application_controller_set_certificate_manager (_data_->self, _data_->_tmp45_);
	_g_object_unref0 (_data_->_tmp45_);
	_g_object_unref0 (_data_->_tmp43_);
	{
		_data_->_tmp46_ = _data_->config_dir;
		_data_->_tmp47_ = g_file_get_child (_data_->_tmp46_, "pinned-certs");
		_data_->_tmp48_ = _data_->_tmp47_;
		_data_->_state_ = 2;
		geary_files_recursive_delete_async (_data_->_tmp48_, G_PRIORITY_DEFAULT, NULL, application_controller_new_ready, _data_);
		return FALSE;
		_state_2:
		geary_files_recursive_delete_finish (_data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp48_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_NOT_FOUND)) {
				goto __catch1_g_io_error_not_found;
			}
			goto __finally1;
		}
	}
	goto __finally1;
	__catch1_g_io_error_not_found:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp24_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp49_ = _data_->self->priv->_application;
	_data_->_state_ = 3;
	secret_mediator_new (_data_->_tmp49_, _data_->cancellable, application_controller_new_ready, _data_);
	return FALSE;
	_state_3:
	_data_->_tmp50_ = secret_mediator_new_finish (_data_->_res_, &_data_->_inner_error0_);
	_data_->libsecret = _data_->_tmp50_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp24_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp51_ = application_client_get_engine (_data_->application);
	_data_->_tmp52_ = _data_->_tmp51_;
	g_signal_connect_object (_data_->_tmp52_, "account-available", (GCallback) _application_controller_on_account_available_geary_engine_account_available, _data_->self, 0);
	_data_->_tmp53_ = _data_->libsecret;
	_data_->_tmp54_ = _data_->config_dir;
	_data_->_tmp55_ = _data_->data_dir;
	_data_->_tmp56_ = accounts_manager_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp53_, GEARY_TYPE_CREDENTIALS_MEDIATOR, GearyCredentialsMediator), _data_->_tmp54_, _data_->_tmp55_);
	_data_->_tmp57_ = _data_->_tmp56_;
	application_controller_set_account_manager (_data_->self, _data_->_tmp57_);
	_g_object_unref0 (_data_->_tmp57_);
	_data_->_tmp58_ = _data_->self->priv->_account_manager;
	g_signal_connect_object (_data_->_tmp58_, "account-added", (GCallback) _application_controller_on_account_added_accounts_manager_account_added, _data_->self, 0);
	_data_->_tmp59_ = _data_->self->priv->_account_manager;
	g_signal_connect_object (_data_->_tmp59_, "account-status-changed", (GCallback) _application_controller_on_account_status_changed_accounts_manager_account_status_changed, _data_->self, 0);
	_data_->_tmp60_ = _data_->self->priv->_account_manager;
	g_signal_connect_object (_data_->_tmp60_, "account-removed", (GCallback) _application_controller_on_account_removed_accounts_manager_account_removed, _data_->self, 0);
	_data_->_tmp61_ = _data_->self->priv->_account_manager;
	g_signal_connect_object (_data_->_tmp61_, "report-problem", (GCallback) _application_controller_on_report_problem_accounts_manager_report_problem, _data_->self, 0);
	_data_->_tmp62_ = _data_->self->priv->_account_manager;
	_data_->_state_ = 4;
	accounts_manager_connect_goa (_data_->_tmp62_, _data_->cancellable, application_controller_new_ready, _data_);
	return FALSE;
	_state_4:
	accounts_manager_connect_goa_finish (_data_->_tmp62_, _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_->libsecret);
		_g_object_unref0 (_data_->_tmp24_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp63_ = _data_->self->priv->_account_manager;
	_data_->_state_ = 5;
	accounts_manager_load_accounts (_data_->_tmp63_, _data_->cancellable, application_controller_new_ready, _data_);
	return FALSE;
	_state_5:
	accounts_manager_load_accounts_finish (_data_->_tmp63_, _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_->libsecret);
		_g_object_unref0 (_data_->_tmp24_);
		_g_object_unref0 (_data_->data_dir);
		_g_object_unref0 (_data_->config_dir);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->self->priv->is_loading_accounts = FALSE;
	application_controller_expunge_accounts (_data_->self, NULL, NULL);
	_g_object_unref0 (_data_->libsecret);
	_g_object_unref0 (_data_->_tmp24_);
	_g_object_unref0 (_data_->data_dir);
	_g_object_unref0 (_data_->config_dir);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
application_controller_new (ApplicationClient* application,
                            GCancellable* cancellable,
                            GAsyncReadyCallback _callback_,
                            gpointer _user_data_)
{
	application_controller_construct (APPLICATION_TYPE_CONTROLLER, application, cancellable, _callback_, _user_data_);
}

ApplicationController*
application_controller_new_finish (GAsyncResult* _res_,
                                   GError** error)
{
	return application_controller_construct_finish (_res_, error);
}

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

void
application_controller_close (ApplicationController* self,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	ApplicationControllerCloseData* _data_;
	ApplicationController* _tmp0_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	_data_ = g_slice_new0 (ApplicationControllerCloseData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_close_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	application_controller_close_co (_data_);
}

void
application_controller_close_finish (ApplicationController* self,
                                     GAsyncResult* _res_)
{
	ApplicationControllerCloseData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/** Closes all windows and accounts, releasing held resources. */
static Block7Data*
block7_data_ref (Block7Data* _data7_)
{
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}

static void
block7_data_unref (void * _userdata_)
{
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		ApplicationController* self;
		self = _data7_->self;
		_g_object_unref0 (_data7_->account_barrier);
		_g_object_unref0 (_data7_->window_barrier);
		_g_object_unref0 (_data7_->composer_barrier);
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		ApplicationController* self;
		self = _data8_->_data7_->self;
		_g_object_unref0 (_data8_->composer);
		block7_data_unref (_data8_->_data7_);
		_data8_->_data7_ = NULL;
		g_slice_free (Block8Data, _data8_);
	}
}

static void
_____lambda152_ (Block8Data* _data8_,
                 GObject* obj,
                 GAsyncResult* res)
{
	Block7Data* _data7_;
	ApplicationController* self;
	ComposerWidget* _tmp0_;
	GearyNonblockingCountingSemaphore* _tmp1_;
	_data7_ = _data8_->_data7_;
	self = _data7_->self;
	g_return_if_fail ((obj == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_OBJECT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (res, g_async_result_get_type ()));
	_tmp0_ = _data8_->composer;
	composer_widget_close_finish (_tmp0_, res);
	_tmp1_ = _data7_->composer_barrier;
	geary_nonblocking_lock_blind_notify (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
}

static void
______lambda152__gasync_ready_callback (GObject* source_object,
                                        GAsyncResult* res,
                                        gpointer self)
{
	_____lambda152_ (self, source_object, res);
	block8_data_unref (self);
}

static void
application_controller_close_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_)
{
	ApplicationControllerCloseData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_close_co (_data_);
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		ApplicationController* self;
		self = _data9_->_data7_->self;
		_g_object_unref0 (_data9_->window);
		block7_data_unref (_data9_->_data7_);
		_data9_->_data7_ = NULL;
		g_slice_free (Block9Data, _data9_);
	}
}

static void
____lambda153_ (Block9Data* _data9_,
                GObject* obj,
                GAsyncResult* res)
{
	Block7Data* _data7_;
	ApplicationController* self;
	ApplicationMainWindow* _tmp0_;
	ApplicationMainWindow* _tmp1_;
	GearyNonblockingCountingSemaphore* _tmp2_;
	_data7_ = _data9_->_data7_;
	self = _data7_->self;
	g_return_if_fail ((obj == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_OBJECT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (res, g_async_result_get_type ()));
	_tmp0_ = _data9_->window;
	application_main_window_select_folder_finish (_tmp0_, res);
	_tmp1_ = _data9_->window;
	gtk_window_close (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_window_get_type (), GtkWindow));
	_tmp2_ = _data7_->window_barrier;
	geary_nonblocking_lock_blind_notify (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
}

static void
_____lambda153__gasync_ready_callback (GObject* source_object,
                                       GAsyncResult* res,
                                       gpointer self)
{
	____lambda153_ (self, source_object, res);
	block9_data_unref (self);
}

static void
____lambda154_ (Block7Data* _data7_,
                GObject* obj,
                GAsyncResult* ret)
{
	ApplicationController* self;
	GearyNonblockingCountingSemaphore* _tmp0_;
	self = _data7_->self;
	g_return_if_fail ((obj == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (obj, G_TYPE_OBJECT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (ret, g_async_result_get_type ()));
	application_controller_close_account_finish (self, ret);
	_tmp0_ = _data7_->account_barrier;
	geary_nonblocking_lock_blind_notify (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock));
}

static void
_____lambda154__gasync_ready_callback (GObject* source_object,
                                       GAsyncResult* res,
                                       gpointer self)
{
	____lambda154_ (self, source_object, res);
	block7_data_unref (self);
}

static gboolean
application_controller_close_co (ApplicationControllerCloseData* _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_->_data7_ = g_slice_new0 (Block7Data);
	_data_->_data7_->_ref_count_ = 1;
	_data_->_data7_->self = g_object_ref (_data_->self);
	_data_->_data7_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->_account_manager;
	g_signal_parse_name ("account-added", ACCOUNTS_TYPE_MANAGER, &_data_->_tmp1_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp0_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp1_, 0, NULL, (GCallback) _application_controller_on_account_added_accounts_manager_account_added, _data_->self);
	_data_->_tmp2_ = _data_->self->priv->_account_manager;
	g_signal_parse_name ("account-status-changed", ACCOUNTS_TYPE_MANAGER, &_data_->_tmp3_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp2_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp3_, 0, NULL, (GCallback) _application_controller_on_account_status_changed_accounts_manager_account_status_changed, _data_->self);
	_data_->_tmp4_ = _data_->self->priv->_account_manager;
	g_signal_parse_name ("account-removed", ACCOUNTS_TYPE_MANAGER, &_data_->_tmp5_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp4_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp5_, 0, NULL, (GCallback) _application_controller_on_account_removed_accounts_manager_account_removed, _data_->self);
	_data_->_tmp6_ = _data_->self->priv->_application;
	_data_->_tmp7_ = application_client_get_engine (_data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	g_signal_parse_name ("account-available", GEARY_TYPE_ENGINE, &_data_->_tmp9_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp8_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp9_, 0, NULL, (GCallback) _application_controller_on_account_available_geary_engine_account_available, _data_->self);
	{
		_data_->_tmp10_ = _data_->self->priv->_application;
		_data_->_tmp11_ = application_client_get_main_windows (_data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp13_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp12_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp14_ = _data_->_tmp13_;
		_g_object_unref0 (_data_->_tmp12_);
		_data_->_window_it = _data_->_tmp14_;
		while (TRUE) {
			_data_->_tmp15_ = _data_->_window_it;
			if (!gee_iterator_next (_data_->_tmp15_)) {
				break;
			}
			_data_->_tmp16_ = _data_->_window_it;
			_data_->_tmp17_ = gee_iterator_get (_data_->_tmp16_);
			_data_->window = (ApplicationMainWindow*) _data_->_tmp17_;
			_data_->_tmp18_ = _data_->window;
			gtk_widget_set_sensitive (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, gtk_widget_get_type (), GtkWidget), FALSE);
			_g_object_unref0 (_data_->window);
		}
		_g_object_unref0 (_data_->_window_it);
	}
	_data_->_tmp19_ = geary_nonblocking_counting_semaphore_new (NULL);
	_data_->_data7_->composer_barrier = _data_->_tmp19_;
	_data_->_tmp20_ = gee_linked_list_new (COMPOSER_TYPE_WIDGET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data_->composers = _data_->_tmp20_;
	_data_->_tmp21_ = _data_->composers;
	_data_->_tmp22_ = _data_->self->priv->composer_widgets;
	gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp21_, GEE_TYPE_COLLECTION, GeeCollection), _data_->_tmp22_);
	{
		_data_->_tmp23_ = _data_->composers;
		_data_->_composer_list = _data_->_tmp23_;
		_data_->_tmp24_ = _data_->_composer_list;
		_data_->_tmp25_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp24_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
		_data_->_tmp26_ = _data_->_tmp25_;
		_data_->_composer_size = _data_->_tmp26_;
		_data_->_composer_index = -1;
		while (TRUE) {
			_data_->_data8_ = g_slice_new0 (Block8Data);
			_data_->_data8_->_ref_count_ = 1;
			_data_->_data8_->_data7_ = block7_data_ref (_data_->_data7_);
			_data_->_composer_index = _data_->_composer_index + 1;
			_data_->_tmp27_ = _data_->_composer_index;
			_data_->_tmp28_ = _data_->_composer_size;
			if (!(_data_->_tmp27_ < _data_->_tmp28_)) {
				block8_data_unref (_data_->_data8_);
				_data_->_data8_ = NULL;
				break;
			}
			_data_->_tmp29_ = _data_->_composer_list;
			_data_->_tmp30_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp29_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), _data_->_composer_index);
			_data_->_data8_->composer = (ComposerWidget*) _data_->_tmp30_;
			_data_->_tmp31_ = _data_->_data8_->composer;
			_data_->_tmp32_ = composer_widget_get_current_mode (_data_->_tmp31_);
			_data_->_tmp33_ = _data_->_tmp32_;
			if (_data_->_tmp33_ != COMPOSER_WIDGET_PRESENTATION_MODE_CLOSED) {
				_data_->_tmp34_ = _data_->_data7_->composer_barrier;
				geary_nonblocking_counting_semaphore_acquire (_data_->_tmp34_);
				_data_->_tmp35_ = _data_->_data8_->composer;
				composer_widget_close (_data_->_tmp35_, ______lambda152__gasync_ready_callback, block8_data_ref (_data_->_data8_));
			}
			block8_data_unref (_data_->_data8_);
			_data_->_data8_ = NULL;
		}
	}
	{
		_data_->_tmp36_ = _data_->_data7_->composer_barrier;
		_data_->_state_ = 1;
		geary_nonblocking_lock_wait_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp36_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), NULL, application_controller_close_ready, _data_);
		return FALSE;
		_state_1:
		geary_nonblocking_lock_wait_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp36_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), _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_->_tmp37_ = _data_->err;
		_data_->_tmp38_ = _data_->_tmp37_->message;
		g_warning ("application-controller.vala:282: Error waiting at composer barrier: %s", _data_->_tmp38_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->composers);
		block7_data_unref (_data_->_data7_);
		_data_->_data7_ = 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_->_tmp39_ = _data_->self->priv->controller_open;
	g_cancellable_cancel (_data_->_tmp39_);
	_data_->_tmp40_ = geary_nonblocking_counting_semaphore_new (NULL);
	_data_->_data7_->window_barrier = _data_->_tmp40_;
	{
		_data_->_tmp41_ = _data_->self->priv->_application;
		_data_->_tmp42_ = application_client_get_main_windows (_data_->_tmp41_);
		_data_->_tmp43_ = _data_->_tmp42_;
		_data_->_tmp44_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp43_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp45_ = _data_->_tmp44_;
		_g_object_unref0 (_data_->_tmp43_);
		_data_->_vala1__window_it = _data_->_tmp45_;
		while (TRUE) {
			_data_->_data9_ = g_slice_new0 (Block9Data);
			_data_->_data9_->_ref_count_ = 1;
			_data_->_data9_->_data7_ = block7_data_ref (_data_->_data7_);
			_data_->_tmp46_ = _data_->_vala1__window_it;
			if (!gee_iterator_next (_data_->_tmp46_)) {
				block9_data_unref (_data_->_data9_);
				_data_->_data9_ = NULL;
				break;
			}
			_data_->_tmp47_ = _data_->_vala1__window_it;
			_data_->_tmp48_ = gee_iterator_get (_data_->_tmp47_);
			_data_->_data9_->window = (ApplicationMainWindow*) _data_->_tmp48_;
			_data_->_tmp49_ = _data_->_data7_->window_barrier;
			geary_nonblocking_counting_semaphore_acquire (_data_->_tmp49_);
			_data_->_tmp50_ = _data_->_data9_->window;
			application_main_window_select_folder (_data_->_tmp50_, NULL, FALSE, TRUE, _____lambda153__gasync_ready_callback, block9_data_ref (_data_->_data9_));
			block9_data_unref (_data_->_data9_);
			_data_->_data9_ = NULL;
		}
		_g_object_unref0 (_data_->_vala1__window_it);
	}
	{
		_data_->_tmp51_ = _data_->_data7_->window_barrier;
		_data_->_state_ = 2;
		geary_nonblocking_lock_wait_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp51_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), NULL, application_controller_close_ready, _data_);
		return FALSE;
		_state_2:
		geary_nonblocking_lock_wait_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp51_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), _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_->_tmp52_ = _data_->_vala1_err;
		_data_->_tmp53_ = _data_->_tmp52_->message;
		g_warning ("application-controller.vala:310: Error waiting at window barrier: %s", _data_->_tmp53_);
		_g_error_free0 (_data_->_vala1_err);
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->composers);
		block7_data_unref (_data_->_data7_);
		_data_->_data7_ = 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_->_tmp54_ = _data_->self->priv->_plugins;
		application_plugin_manager_close (_data_->_tmp54_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch2_g_error;
		}
	}
	goto __finally2;
	__catch2_g_error:
	{
		_data_->_vala2_err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp55_ = _data_->_vala2_err;
		_data_->_tmp56_ = _data_->_tmp55_->message;
		g_warning ("application-controller.vala:317: Error closing plugin manager: %s", _data_->_tmp56_);
		_g_error_free0 (_data_->_vala2_err);
	}
	__finally2:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->composers);
		block7_data_unref (_data_->_data7_);
		_data_->_data7_ = 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_->_tmp57_ = _data_->self->priv->pending_mailtos;
	gee_collection_clear (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp57_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp58_ = _data_->self->priv->composer_widgets;
	gee_collection_clear (_data_->_tmp58_);
	_data_->_tmp59_ = gee_linked_list_new (APPLICATION_TYPE_ACCOUNT_CONTEXT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	_data_->closing_accounts = _data_->_tmp59_;
	_data_->_tmp60_ = _data_->closing_accounts;
	_data_->_tmp61_ = _data_->self->priv->accounts;
	_data_->_tmp62_ = gee_map_get_values (_data_->_tmp61_);
	_data_->_tmp63_ = _data_->_tmp62_;
	_data_->_tmp64_ = _data_->_tmp63_;
	gee_collection_add_all (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp60_, GEE_TYPE_COLLECTION, GeeCollection), _data_->_tmp64_);
	_g_object_unref0 (_data_->_tmp64_);
	_data_->_tmp65_ = geary_nonblocking_counting_semaphore_new (NULL);
	_data_->_data7_->account_barrier = _data_->_tmp65_;
	{
		_data_->_tmp66_ = _data_->closing_accounts;
		_data_->_context_list = _data_->_tmp66_;
		_data_->_tmp67_ = _data_->_context_list;
		_data_->_tmp68_ = gee_abstract_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp67_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection));
		_data_->_tmp69_ = _data_->_tmp68_;
		_data_->_context_size = _data_->_tmp69_;
		_data_->_context_index = -1;
		while (TRUE) {
			_data_->_context_index = _data_->_context_index + 1;
			_data_->_tmp70_ = _data_->_context_index;
			_data_->_tmp71_ = _data_->_context_size;
			if (!(_data_->_tmp70_ < _data_->_tmp71_)) {
				break;
			}
			_data_->_tmp72_ = _data_->_context_list;
			_data_->_tmp73_ = gee_abstract_list_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp72_, GEE_TYPE_ABSTRACT_LIST, GeeAbstractList), _data_->_context_index);
			_data_->context = (ApplicationAccountContext*) _data_->_tmp73_;
			_data_->_tmp74_ = _data_->_data7_->account_barrier;
			geary_nonblocking_counting_semaphore_acquire (_data_->_tmp74_);
			_data_->_tmp75_ = _data_->context;
			_data_->_tmp76_ = application_account_context_get_account (_data_->_tmp75_);
			_data_->_tmp77_ = _data_->_tmp76_;
			_data_->_tmp78_ = geary_account_get_information (_data_->_tmp77_);
			_data_->_tmp79_ = _data_->_tmp78_;
			application_controller_close_account (_data_->self, _data_->_tmp79_, TRUE, _____lambda154__gasync_ready_callback, block7_data_ref (_data_->_data7_));
			_g_object_unref0 (_data_->context);
		}
	}
	{
		_data_->_tmp80_ = _data_->_data7_->account_barrier;
		_data_->_state_ = 3;
		geary_nonblocking_lock_wait_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp80_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), NULL, application_controller_close_ready, _data_);
		return FALSE;
		_state_3:
		geary_nonblocking_lock_wait_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp80_, GEARY_NONBLOCKING_TYPE_LOCK, GearyNonblockingLock), _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch3_g_error;
		}
	}
	goto __finally3;
	__catch3_g_error:
	{
		_data_->_vala3_err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp81_ = _data_->_vala3_err;
		_data_->_tmp82_ = _data_->_tmp81_->message;
		g_warning ("application-controller.vala:341: Error waiting at account barrier: %s", _data_->_tmp82_);
		_g_error_free0 (_data_->_vala3_err);
	}
	__finally3:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->closing_accounts);
		_g_object_unref0 (_data_->composers);
		block7_data_unref (_data_->_data7_);
		_data_->_data7_ = 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_info ("application-controller.vala:344: Closed Application.Controller");
	_g_object_unref0 (_data_->closing_accounts);
	_g_object_unref0 (_data_->composers);
	block7_data_unref (_data_->_data7_);
	_data_->_data7_ = 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
application_controller_compose_blank_data_free (gpointer _data)
{
	ApplicationControllerComposeBlankData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->send_context);
	_g_object_unref0 (_data_->to);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerComposeBlankData, _data_);
}

void
application_controller_compose_blank (ApplicationController* self,
                                      ApplicationAccountContext* send_context,
                                      GearyRFC822MailboxAddress* to,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	ApplicationControllerComposeBlankData* _data_;
	ApplicationController* _tmp0_;
	ApplicationAccountContext* _tmp1_;
	GearyRFC822MailboxAddress* _tmp2_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (APPLICATION_IS_ACCOUNT_CONTEXT (send_context));
	g_return_if_fail ((to == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (to, GEARY_RF_C822_TYPE_MAILBOX_ADDRESS));
	_data_ = g_slice_new0 (ApplicationControllerComposeBlankData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_compose_blank_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (send_context);
	_g_object_unref0 (_data_->send_context);
	_data_->send_context = _tmp1_;
	_tmp2_ = _g_object_ref0 (to);
	_g_object_unref0 (_data_->to);
	_data_->to = _tmp2_;
	application_controller_compose_blank_co (_data_);
}

ComposerWidget*
application_controller_compose_blank_finish (ApplicationController* self,
                                             GAsyncResult* _res_)
{
	ComposerWidget* result;
	ApplicationControllerComposeBlankData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

/**
     * Opens a composer for writing a new, blank message.
     */
static void
application_controller_compose_blank_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	ApplicationControllerComposeBlankData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_compose_blank_co (_data_);
}

static gboolean
application_controller_compose_blank_co (ApplicationControllerComposeBlankData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_application;
	_data_->_tmp1_ = application_client_get_active_main_window (_data_->_tmp0_);
	_data_->main = _data_->_tmp1_;
	_data_->_tmp2_ = _data_->main;
	_data_->_tmp3_ = application_main_window_get_conversation_viewer (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = conversation_viewer_get_current_composer (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = _g_object_ref0 (_data_->_tmp6_);
	_data_->composer = _data_->_tmp7_;
	_data_->_tmp11_ = _data_->composer;
	if (_data_->_tmp11_ == NULL) {
		_data_->_tmp10_ = TRUE;
	} else {
		_data_->_tmp12_ = _data_->composer;
		_data_->_tmp13_ = composer_widget_get_current_mode (_data_->_tmp12_);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_tmp10_ = _data_->_tmp14_ != COMPOSER_WIDGET_PRESENTATION_MODE_PANED;
	}
	if (_data_->_tmp10_) {
		_data_->_tmp9_ = TRUE;
	} else {
		_data_->_tmp15_ = _data_->composer;
		_data_->_tmp16_ = composer_widget_get_is_blank (_data_->_tmp15_);
		_data_->_tmp17_ = _data_->_tmp16_;
		_data_->_tmp9_ = !_data_->_tmp17_;
	}
	if (_data_->_tmp9_) {
		_data_->_tmp8_ = TRUE;
	} else {
		_data_->_tmp18_ = _data_->composer;
		_data_->_tmp19_ = composer_widget_get_sender_context (_data_->_tmp18_);
		_data_->_tmp20_ = _data_->_tmp19_;
		_data_->_tmp8_ = _data_->_tmp20_ != _data_->send_context;
	}
	if (_data_->_tmp8_) {
		_data_->_tmp21_ = _data_->self->priv->_application;
		_data_->_tmp22_ = application_client_get_config (_data_->_tmp21_);
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_tmp24_ = composer_widget_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp23_, _data_->send_context, NULL);
		g_object_ref_sink (_data_->_tmp24_);
		_g_object_unref0 (_data_->composer);
		_data_->composer = _data_->_tmp24_;
		_data_->_tmp25_ = _data_->composer;
		application_controller_register_composer (_data_->self, _data_->_tmp25_);
	}
	{
		_data_->_tmp26_ = _data_->composer;
		_data_->_state_ = 1;
		composer_widget_load_empty_body (_data_->_tmp26_, _data_->to, application_controller_compose_blank_ready, _data_);
		return FALSE;
		_state_1:
		composer_widget_load_empty_body_finish (_data_->_tmp26_, _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_->_tmp27_ = _data_->err;
		_data_->_tmp28_ = geary_problem_report_new (_data_->_tmp27_);
		_data_->_tmp29_ = _data_->_tmp28_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp29_);
		_g_object_unref0 (_data_->_tmp29_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->composer);
		_g_object_unref0 (_data_->main);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->composer;
	_g_object_unref0 (_data_->main);
	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
application_controller_compose_with_context_data_free (gpointer _data)
{
	ApplicationControllerComposeWithContextData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->send_context);
	_g_object_unref0 (_data_->context);
	_g_free0 (_data_->quote);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerComposeWithContextData, _data_);
}

void
application_controller_compose_with_context (ApplicationController* self,
                                             ApplicationAccountContext* send_context,
                                             ComposerWidgetContextType type,
                                             GearyEmail* context,
                                             const gchar* quote,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	ApplicationControllerComposeWithContextData* _data_;
	ApplicationController* _tmp0_;
	ApplicationAccountContext* _tmp1_;
	GearyEmail* _tmp2_;
	gchar* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (APPLICATION_IS_ACCOUNT_CONTEXT (send_context));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (context, GEARY_TYPE_EMAIL));
	_data_ = g_slice_new0 (ApplicationControllerComposeWithContextData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_compose_with_context_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (send_context);
	_g_object_unref0 (_data_->send_context);
	_data_->send_context = _tmp1_;
	_data_->type = type;
	_tmp2_ = _g_object_ref0 (context);
	_g_object_unref0 (_data_->context);
	_data_->context = _tmp2_;
	_tmp3_ = g_strdup (quote);
	_g_free0 (_data_->quote);
	_data_->quote = _tmp3_;
	application_controller_compose_with_context_co (_data_);
}

ComposerWidget*
application_controller_compose_with_context_finish (ApplicationController* self,
                                                    GAsyncResult* _res_)
{
	ComposerWidget* result;
	ApplicationControllerComposeWithContextData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

/**
     * Opens new composer with an existing message as context.
     *
     * If the given type is {@link Composer.Widget.ContextType.EDIT},
     * the context is loaded to be edited (e.g. for drafts, templates,
     * sending again. Otherwise the context is treated as the email to
     * be replied to, etc.
     *
     * Returns null if there is an existing composer open and the
     * prompt to close it was declined.
     */
static void
application_controller_compose_with_context_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_)
{
	ApplicationControllerComposeWithContextData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_compose_with_context_co (_data_);
}

static gboolean
application_controller_compose_with_context_co (ApplicationControllerComposeWithContextData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_application;
	_data_->_tmp1_ = application_client_get_active_main_window (_data_->_tmp0_);
	_data_->main = _data_->_tmp1_;
	_data_->composer = NULL;
	if (_data_->type == COMPOSER_WIDGET_CONTEXT_TYPE_EDIT) {
		{
			_data_->_tmp2_ = _data_->self->priv->composer_widgets;
			_data_->_tmp3_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEE_TYPE_ITERABLE, GeeIterable));
			_data_->_existing_it = _data_->_tmp3_;
			while (TRUE) {
				_data_->_tmp4_ = _data_->_existing_it;
				if (!gee_iterator_next (_data_->_tmp4_)) {
					break;
				}
				_data_->_tmp5_ = _data_->_existing_it;
				_data_->_tmp6_ = gee_iterator_get (_data_->_tmp5_);
				_data_->existing = (ComposerWidget*) _data_->_tmp6_;
				_data_->_tmp11_ = _data_->existing;
				_data_->_tmp12_ = composer_widget_get_current_mode (_data_->_tmp11_);
				_data_->_tmp13_ = _data_->_tmp12_;
				if (_data_->_tmp13_ != COMPOSER_WIDGET_PRESENTATION_MODE_NONE) {
					_data_->_tmp14_ = _data_->existing;
					_data_->_tmp15_ = composer_widget_get_current_mode (_data_->_tmp14_);
					_data_->_tmp16_ = _data_->_tmp15_;
					_data_->_tmp10_ = _data_->_tmp16_ != COMPOSER_WIDGET_PRESENTATION_MODE_CLOSED;
				} else {
					_data_->_tmp10_ = FALSE;
				}
				if (_data_->_tmp10_) {
					_data_->_tmp17_ = _data_->composer;
					_data_->_tmp18_ = composer_widget_get_sender_context (_data_->_tmp17_);
					_data_->_tmp19_ = _data_->_tmp18_;
					_data_->_tmp9_ = _data_->_tmp19_ == _data_->send_context;
				} else {
					_data_->_tmp9_ = FALSE;
				}
				if (_data_->_tmp9_) {
					_data_->_tmp20_ = _data_->existing;
					_data_->_tmp21_ = composer_widget_get_saved_id (_data_->_tmp20_);
					_data_->_tmp22_ = _data_->_tmp21_;
					_data_->_tmp8_ = _data_->_tmp22_ != NULL;
				} else {
					_data_->_tmp8_ = FALSE;
				}
				if (_data_->_tmp8_) {
					_data_->_tmp23_ = _data_->existing;
					_data_->_tmp24_ = composer_widget_get_saved_id (_data_->_tmp23_);
					_data_->_tmp25_ = _data_->_tmp24_;
					_data_->_tmp26_ = geary_email_get_id (_data_->context);
					_data_->_tmp27_ = _data_->_tmp26_;
					_data_->_tmp7_ = geary_email_identifier_equal_to (_data_->_tmp25_, _data_->_tmp27_);
				} else {
					_data_->_tmp7_ = FALSE;
				}
				if (_data_->_tmp7_) {
					_data_->_tmp28_ = _data_->existing;
					_data_->_tmp29_ = _g_object_ref0 (_data_->_tmp28_);
					_g_object_unref0 (_data_->composer);
					_data_->composer = _data_->_tmp29_;
					_g_object_unref0 (_data_->existing);
					break;
				}
				_g_object_unref0 (_data_->existing);
			}
			_g_object_unref0 (_data_->_existing_it);
		}
	} else {
		{
			_data_->_tmp30_ = _data_->self->priv->composer_widgets;
			_data_->_tmp31_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp30_, GEE_TYPE_ITERABLE, GeeIterable));
			_data_->_vala1__existing_it = _data_->_tmp31_;
			while (TRUE) {
				_data_->_tmp32_ = _data_->_vala1__existing_it;
				if (!gee_iterator_next (_data_->_tmp32_)) {
					break;
				}
				_data_->_tmp33_ = _data_->_vala1__existing_it;
				_data_->_tmp34_ = gee_iterator_get (_data_->_tmp33_);
				_data_->_vala1_existing = (ComposerWidget*) _data_->_tmp34_;
				_data_->_tmp38_ = _data_->_vala1_existing;
				_data_->_tmp39_ = gtk_widget_get_toplevel (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp38_, gtk_widget_get_type (), GtkWidget));
				_data_->_tmp40_ = _data_->main;
				if (_data_->_tmp39_ == G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp40_, gtk_widget_get_type (), GtkWidget)) {
					_data_->_tmp42_ = _data_->_vala1_existing;
					_data_->_tmp43_ = composer_widget_get_current_mode (_data_->_tmp42_);
					_data_->_tmp44_ = _data_->_tmp43_;
					if (_data_->_tmp44_ == COMPOSER_WIDGET_PRESENTATION_MODE_INLINE) {
						_data_->_tmp41_ = TRUE;
					} else {
						_data_->_tmp45_ = _data_->_vala1_existing;
						_data_->_tmp46_ = composer_widget_get_current_mode (_data_->_tmp45_);
						_data_->_tmp47_ = _data_->_tmp46_;
						_data_->_tmp41_ = _data_->_tmp47_ == COMPOSER_WIDGET_PRESENTATION_MODE_INLINE_COMPACT;
					}
					_data_->_tmp37_ = _data_->_tmp41_;
				} else {
					_data_->_tmp37_ = FALSE;
				}
				if (_data_->_tmp37_) {
					_data_->_tmp48_ = _data_->_vala1_existing;
					_data_->_tmp49_ = composer_widget_get_sender_context (_data_->_tmp48_);
					_data_->_tmp50_ = _data_->_tmp49_;
					_data_->_tmp36_ = _data_->_tmp50_ == _data_->send_context;
				} else {
					_data_->_tmp36_ = FALSE;
				}
				if (_data_->_tmp36_) {
					_data_->_tmp52_ = _data_->_vala1_existing;
					_data_->_tmp53_ = composer_widget_get_referred_ids (_data_->_tmp52_);
					_data_->_tmp54_ = _data_->_tmp53_;
					_data_->_tmp55_ = geary_email_get_id (_data_->context);
					_data_->_tmp56_ = _data_->_tmp55_;
					_data_->_tmp57_ = gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp54_, GEE_TYPE_COLLECTION, GeeCollection), _data_->_tmp56_);
					_g_object_unref0 (_data_->_tmp54_);
					if (_data_->_tmp57_) {
						_data_->_tmp51_ = TRUE;
					} else {
						_data_->_tmp51_ = _data_->quote != NULL;
					}
					_data_->_tmp35_ = _data_->_tmp51_;
				} else {
					_data_->_tmp35_ = FALSE;
				}
				if (_data_->_tmp35_) {
					{
						_data_->_tmp58_ = _data_->_vala1_existing;
						composer_widget_append_to_email (_data_->_tmp58_, _data_->context, _data_->quote, _data_->type, &_data_->_inner_error0_);
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							if (_data_->_inner_error0_->domain == GEARY_ENGINE_ERROR) {
								goto __catch0_geary_engine_error;
							}
							_g_object_unref0 (_data_->_vala1_existing);
							_g_object_unref0 (_data_->_vala1__existing_it);
							_g_object_unref0 (_data_->composer);
							_g_object_unref0 (_data_->main);
							g_critical ("file %s: line %d: unexpected 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_->_tmp59_ = _data_->_vala1_existing;
						_data_->_tmp60_ = _g_object_ref0 (_data_->_tmp59_);
						_g_object_unref0 (_data_->composer);
						_data_->composer = _data_->_tmp60_;
						_g_object_unref0 (_data_->_vala1_existing);
						break;
					}
					goto __finally0;
					__catch0_geary_engine_error:
					{
						_data_->_error_ = _data_->_inner_error0_;
						_data_->_inner_error0_ = NULL;
						_data_->_tmp61_ = _data_->_error_;
						_data_->_tmp62_ = geary_problem_report_new (_data_->_tmp61_);
						_data_->_tmp63_ = _data_->_tmp62_;
						composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp63_);
						_g_object_unref0 (_data_->_tmp63_);
						_g_error_free0 (_data_->_error_);
					}
					__finally0:
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						_g_object_unref0 (_data_->_vala1_existing);
						_g_object_unref0 (_data_->_vala1__existing_it);
						_g_object_unref0 (_data_->composer);
						_g_object_unref0 (_data_->main);
						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_existing);
			}
			_g_object_unref0 (_data_->_vala1__existing_it);
		}
		_data_->_tmp65_ = _data_->composer;
		if (_data_->_tmp65_ == NULL) {
			_data_->_tmp66_ = _data_->main;
			_data_->_tmp64_ = !application_main_window_close_composer (_data_->_tmp66_, TRUE, FALSE);
		} else {
			_data_->_tmp64_ = FALSE;
		}
		if (_data_->_tmp64_) {
			_data_->result = NULL;
			_g_object_unref0 (_data_->composer);
			_g_object_unref0 (_data_->main);
			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_->_tmp67_ = _data_->composer;
	if (_data_->_tmp67_ == NULL) {
		_data_->_tmp68_ = _data_->self->priv->_application;
		_data_->_tmp69_ = application_client_get_config (_data_->_tmp68_);
		_data_->_tmp70_ = _data_->_tmp69_;
		_data_->_tmp71_ = composer_widget_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp70_, _data_->send_context, NULL);
		g_object_ref_sink (_data_->_tmp71_);
		_g_object_unref0 (_data_->composer);
		_data_->composer = _data_->_tmp71_;
		_data_->_tmp72_ = _data_->composer;
		application_controller_register_composer (_data_->self, _data_->_tmp72_);
		{
			_data_->_tmp73_ = _data_->composer;
			_data_->_state_ = 1;
			composer_widget_load_context (_data_->_tmp73_, _data_->type, _data_->context, _data_->quote, application_controller_compose_with_context_ready, _data_);
			return FALSE;
			_state_1:
			composer_widget_load_context_finish (_data_->_tmp73_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
		}
		goto __finally1;
		__catch1_g_error:
		{
			_data_->err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp74_ = _data_->err;
			_data_->_tmp75_ = geary_problem_report_new (_data_->_tmp74_);
			_data_->_tmp76_ = _data_->_tmp75_;
			composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp76_);
			_g_object_unref0 (_data_->_tmp76_);
			_g_error_free0 (_data_->err);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->composer);
			_g_object_unref0 (_data_->main);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->result = _data_->composer;
	_g_object_unref0 (_data_->main);
	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
application_controller_compose_mailto_data_free (gpointer _data)
{
	ApplicationControllerComposeMailtoData* _data_;
	_data_ = _data;
	_g_free0 (_data_->mailto);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerComposeMailtoData, _data_);
}

void
application_controller_compose_mailto (ApplicationController* self,
                                       const gchar* mailto,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	ApplicationControllerComposeMailtoData* _data_;
	ApplicationController* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (mailto != NULL);
	_data_ = g_slice_new0 (ApplicationControllerComposeMailtoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_compose_mailto_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = g_strdup (mailto);
	_g_free0 (_data_->mailto);
	_data_->mailto = _tmp1_;
	application_controller_compose_mailto_co (_data_);
}

void
application_controller_compose_mailto_finish (ApplicationController* self,
                                              GAsyncResult* _res_)
{
	ApplicationControllerComposeMailtoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/**
     * Opens a composer with the given `mailto:` URL.
     */
static void
application_controller_compose_mailto_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_)
{
	ApplicationControllerComposeMailtoData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_compose_mailto_co (_data_);
}

static gboolean
application_controller_compose_mailto_co (ApplicationControllerComposeMailtoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_application;
	_data_->_tmp1_ = application_client_get_last_active_main_window (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = _g_object_ref0 (_data_->_tmp2_);
	_data_->window = _data_->_tmp3_;
	_data_->_tmp5_ = _data_->window;
	if (_data_->_tmp5_ != NULL) {
		_data_->_tmp6_ = _data_->window;
		_data_->_tmp7_ = application_main_window_get_selected_account (_data_->_tmp6_);
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_tmp4_ = _data_->_tmp8_ != NULL;
	} else {
		_data_->_tmp4_ = FALSE;
	}
	if (_data_->_tmp4_) {
		_data_->_tmp9_ = _data_->self->priv->accounts;
		_data_->_tmp10_ = _data_->window;
		_data_->_tmp11_ = application_main_window_get_selected_account (_data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp13_ = geary_account_get_information (_data_->_tmp12_);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_tmp15_ = gee_map_get (_data_->_tmp9_, _data_->_tmp14_);
		_data_->context = (ApplicationAccountContext*) _data_->_tmp15_;
		_data_->_tmp16_ = _data_->context;
		if (_data_->_tmp16_ != NULL) {
			_data_->_tmp17_ = _data_->self->priv->_application;
			_data_->_tmp18_ = application_client_get_config (_data_->_tmp17_);
			_data_->_tmp19_ = _data_->_tmp18_;
			_data_->_tmp20_ = _data_->context;
			_data_->_tmp21_ = composer_widget_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp19_, _data_->_tmp20_, NULL);
			g_object_ref_sink (_data_->_tmp21_);
			_data_->composer = _data_->_tmp21_;
			_data_->_tmp22_ = _data_->composer;
			application_controller_register_composer (_data_->self, _data_->_tmp22_);
			_data_->_tmp23_ = _data_->composer;
			application_controller_present_composer (_data_->self, _data_->_tmp23_);
			{
				_data_->_tmp24_ = _data_->composer;
				_data_->_state_ = 1;
				composer_widget_load_mailto (_data_->_tmp24_, _data_->mailto, application_controller_compose_mailto_ready, _data_);
				return FALSE;
				_state_1:
				composer_widget_load_mailto_finish (_data_->_tmp24_, _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_->_tmp25_ = _data_->err;
				_data_->_tmp26_ = geary_problem_report_new (_data_->_tmp25_);
				_data_->_tmp27_ = _data_->_tmp26_;
				composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp27_);
				_g_object_unref0 (_data_->_tmp27_);
				_g_error_free0 (_data_->err);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->composer);
				_g_object_unref0 (_data_->context);
				_g_object_unref0 (_data_->window);
				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_->composer);
		}
		_g_object_unref0 (_data_->context);
	} else {
		_data_->_tmp28_ = _data_->self->priv->pending_mailtos;
		gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp28_, GEE_TYPE_COLLECTION, GeeCollection), _data_->mailto);
	}
	_g_object_unref0 (_data_->window);
	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;
}

/** Displays a problem report when an error has been encountered. */
static void
_application_controller_on_retry_problem_components_problem_report_info_bar_retry (ComponentsProblemReportInfoBar* _sender,
                                                                                   gpointer self)
{
	application_controller_on_retry_problem ((ApplicationController*) self, _sender);
}

static void
application_controller_real_report_problem (ComposerApplicationInterface* base,
                                            GearyProblemReport* report)
{
	ApplicationController * self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	GearyErrorContext* _tmp3_;
	GearyErrorContext* _tmp4_;
	GearyServiceProblemReport* service_report = NULL;
	GearyServiceProblemReport* _tmp15_;
	gboolean _tmp16_ = FALSE;
	GearyServiceProblemReport* _tmp17_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (report, GEARY_TYPE_PROBLEM_REPORT));
	_tmp0_ = geary_problem_report_to_string (report);
	_tmp1_ = _tmp0_;
	g_debug ("application-controller.vala:484: Problem reported: %s", _tmp1_);
	_g_free0 (_tmp1_);
	_tmp3_ = geary_problem_report_get_error (report);
	_tmp4_ = _tmp3_;
	if (_tmp4_ == NULL) {
		_tmp2_ = TRUE;
	} else {
		GearyErrorContext* _tmp5_;
		GearyErrorContext* _tmp6_;
		GError* _tmp7_;
		GError* _tmp8_;
		_tmp5_ = geary_problem_report_get_error (report);
		_tmp6_ = _tmp5_;
		_tmp7_ = geary_error_context_get_thrown (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp2_ = !g_error_matches (_tmp8_, G_IO_ERROR, G_IO_ERROR_CANCELLED);
	}
	if (_tmp2_) {
		ComponentsProblemReportInfoBar* info_bar = NULL;
		ComponentsProblemReportInfoBar* _tmp9_;
		ComponentsProblemReportInfoBar* _tmp10_;
		ApplicationClient* _tmp11_;
		ApplicationMainWindow* _tmp12_;
		ApplicationMainWindow* _tmp13_;
		ComponentsProblemReportInfoBar* _tmp14_;
		_tmp9_ = components_problem_report_info_bar_new (report);
		g_object_ref_sink (_tmp9_);
		info_bar = _tmp9_;
		_tmp10_ = info_bar;
		g_signal_connect_object (_tmp10_, "retry", (GCallback) _application_controller_on_retry_problem_components_problem_report_info_bar_retry, self, 0);
		_tmp11_ = self->priv->_application;
		_tmp12_ = application_client_get_active_main_window (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = info_bar;
		application_main_window_show_info_bar (_tmp13_, G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, COMPONENTS_TYPE_INFO_BAR, ComponentsInfoBar));
		_g_object_unref0 (_tmp13_);
		_g_object_unref0 (info_bar);
	}
	_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (report, GEARY_TYPE_SERVICE_PROBLEM_REPORT) ? ((GearyServiceProblemReport*) report) : NULL);
	service_report = _tmp15_;
	_tmp17_ = service_report;
	if (_tmp17_ != NULL) {
		GearyServiceProblemReport* _tmp18_;
		GearyServiceInformation* _tmp19_;
		GearyServiceInformation* _tmp20_;
		GearyProtocol _tmp21_;
		GearyProtocol _tmp22_;
		_tmp18_ = service_report;
		_tmp19_ = geary_service_problem_report_get_service (_tmp18_);
		_tmp20_ = _tmp19_;
		_tmp21_ = geary_service_information_get_protocol (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp16_ = _tmp22_ == GEARY_PROTOCOL_SMTP;
	} else {
		_tmp16_ = FALSE;
	}
	if (_tmp16_) {
		ApplicationClient* _tmp23_;
		GearyServiceProblemReport* _tmp24_;
		GearyAccountInformation* _tmp25_;
		GearyAccountInformation* _tmp26_;
		const gchar* _tmp27_;
		const gchar* _tmp28_;
		gchar* _tmp29_;
		gchar* _tmp30_;
		_tmp23_ = self->priv->_application;
		_tmp24_ = service_report;
		_tmp25_ = geary_account_problem_report_get_account (G_TYPE_CHECK_INSTANCE_CAST (_tmp24_, GEARY_TYPE_ACCOUNT_PROBLEM_REPORT, GearyAccountProblemReport));
		_tmp26_ = _tmp25_;
		_tmp27_ = geary_account_information_get_display_name (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp29_ = g_strdup_printf (_ ("A problem occurred sending email for %s"), _tmp28_);
		_tmp30_ = _tmp29_;
		application_client_send_error_notification (_tmp23_, _tmp30_, _ ("Email will not be sent until re-connected"));
		_g_free0 (_tmp30_);
	}
	_g_object_unref0 (service_report);
}

static void
application_controller_mark_conversations_data_free (gpointer _data)
{
	ApplicationControllerMarkConversationsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->location);
	_g_object_unref0 (_data_->conversations);
	_g_object_unref0 (_data_->flag);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerMarkConversationsData, _data_);
}

void
application_controller_mark_conversations (ApplicationController* self,
                                           GearyFolder* location,
                                           GeeCollection* conversations,
                                           GearyNamedFlag* flag,
                                           gboolean prefer_adding,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	ApplicationControllerMarkConversationsData* _data_;
	ApplicationController* _tmp0_;
	GearyFolder* _tmp1_;
	GeeCollection* _tmp2_;
	GearyNamedFlag* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (flag, GEARY_TYPE_NAMED_FLAG));
	_data_ = g_slice_new0 (ApplicationControllerMarkConversationsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_mark_conversations_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (location);
	_g_object_unref0 (_data_->location);
	_data_->location = _tmp1_;
	_tmp2_ = _g_object_ref0 (conversations);
	_g_object_unref0 (_data_->conversations);
	_data_->conversations = _tmp2_;
	_tmp3_ = _g_object_ref0 (flag);
	_g_object_unref0 (_data_->flag);
	_data_->flag = _tmp3_;
	_data_->prefer_adding = prefer_adding;
	application_controller_mark_conversations_co (_data_);
}

void
application_controller_mark_conversations_finish (ApplicationController* self,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	ApplicationControllerMarkConversationsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/**
     * Updates flags for a collection of conversations.
     *
     * If `prefer_adding` is true, this will add the flag if not set
     * on all conversations or else will remove it. If false, this
     * will remove the flag if not set on all conversations or else
     * add it.
     */
static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		ApplicationController* self;
		self = _data10_->self;
		_g_object_unref0 (self);
		g_slice_free (Block10Data, _data10_);
	}
}

static gboolean
___lambda155_ (Block10Data* _data10_,
               GearyAppConversation* c)
{
	ApplicationController* self;
	gboolean result;
	self = _data10_->self;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (c, GEARY_APP_TYPE_CONVERSATION), FALSE);
	result = _data10_->prefer_adding ^ geary_app_conversation_is_unread (c);
	return result;
}

static gboolean
____lambda155__gee_predicate (gconstpointer g,
                              gpointer self)
{
	gboolean result;
	result = ___lambda155_ (self, (GearyAppConversation*) g);
	return result;
}

static gboolean
____lambda156_ (Block10Data* _data10_,
                GearyAppConversation* c)
{
	ApplicationController* self;
	gboolean result;
	self = _data10_->self;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (c, GEARY_APP_TYPE_CONVERSATION), FALSE);
	result = _data10_->prefer_adding ^ geary_app_conversation_is_flagged (c);
	return result;
}

static gboolean
_____lambda156__gee_predicate (gconstpointer g,
                               gpointer self)
{
	gboolean result;
	result = ____lambda156_ (self, (GearyAppConversation*) g);
	return result;
}

static GearyEmailIdentifier*
___lambda157_ (ApplicationController* self,
               GearyAppConversation* c)
{
	GearyEmail* _tmp0_;
	GearyEmail* _tmp1_;
	GearyEmailIdentifier* _tmp2_;
	GearyEmailIdentifier* _tmp3_;
	GearyEmailIdentifier* _tmp4_;
	GearyEmailIdentifier* _tmp5_;
	GearyEmailIdentifier* result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (c, GEARY_APP_TYPE_CONVERSATION), NULL);
	_tmp0_ = geary_app_conversation_get_latest_recv_email (c, GEARY_APP_CONVERSATION_LOCATION_IN_FOLDER_OUT_OF_FOLDER, NULL);
	_tmp1_ = _tmp0_;
	_tmp2_ = geary_email_get_id (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _g_object_ref0 (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp1_);
	result = _tmp5_;
	_g_object_unref0 (c);
	return result;
}

static gpointer
____lambda157__gee_map_func (gpointer g,
                             gpointer self)
{
	gpointer result;
	result = ___lambda157_ ((ApplicationController*) self, (GearyAppConversation*) g);
	return result;
}

static void
application_controller_mark_conversations_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	ApplicationControllerMarkConversationsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_mark_conversations_co (_data_);
}

static gboolean
application_controller_mark_conversations_co (ApplicationControllerMarkConversationsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data10_ = g_slice_new0 (Block10Data);
	_data_->_data10_->_ref_count_ = 1;
	_data_->_data10_->self = g_object_ref (_data_->self);
	_data_->_data10_->prefer_adding = _data_->prefer_adding;
	_data_->_data10_->_async_data_ = _data_;
	_data_->_tmp0_ = geary_traverse (GEARY_APP_TYPE_CONVERSATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->conversations, GEE_TYPE_ITERABLE, GeeIterable));
	_data_->selecting = _data_->_tmp0_;
	_data_->_tmp1_ = geary_email_flags_new ();
	_data_->flags = _data_->_tmp1_;
	_data_->_tmp2_ = geary_email_flags_get_UNREAD ();
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_data_->flag, GEE_TYPE_HASHABLE, GeeHashable), _data_->_tmp4_);
	_g_object_unref0 (_data_->_tmp4_);
	if (_data_->_tmp5_) {
		_data_->_tmp6_ = _data_->selecting;
		_data_->_tmp7_ = geary_iterable_filter (_data_->_tmp6_, ____lambda155__gee_predicate, block10_data_ref (_data_->_data10_), block10_data_unref);
		_g_object_unref0 (_data_->selecting);
		_data_->selecting = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->flags;
		_data_->_tmp9_ = geary_email_flags_get_UNREAD ();
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = _data_->_tmp10_;
		geary_named_flags_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _data_->_tmp11_);
		_g_object_unref0 (_data_->_tmp11_);
	} else {
		_data_->_tmp12_ = geary_email_flags_get_FLAGGED ();
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_tmp15_ = gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_data_->flag, GEE_TYPE_HASHABLE, GeeHashable), _data_->_tmp14_);
		_g_object_unref0 (_data_->_tmp14_);
		if (_data_->_tmp15_) {
			_data_->_tmp16_ = _data_->selecting;
			_data_->_tmp17_ = geary_iterable_filter (_data_->_tmp16_, _____lambda156__gee_predicate, block10_data_ref (_data_->_data10_), block10_data_unref);
			_g_object_unref0 (_data_->selecting);
			_data_->selecting = _data_->_tmp17_;
			_data_->_tmp18_ = _data_->flags;
			_data_->_tmp19_ = geary_email_flags_get_FLAGGED ();
			_data_->_tmp20_ = _data_->_tmp19_;
			_data_->_tmp21_ = _data_->_tmp20_;
			geary_named_flags_add (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _data_->_tmp21_);
			_g_object_unref0 (_data_->_tmp21_);
		} else {
			_data_->_tmp22_ = geary_named_flag_to_string (_data_->flag);
			_data_->_tmp23_ = _data_->_tmp22_;
			_data_->_tmp24_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Marking as %s is not supported", _data_->_tmp23_);
			_data_->_tmp25_ = _data_->_tmp24_;
			_g_free0 (_data_->_tmp23_);
			_data_->_inner_error0_ = _data_->_tmp25_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->flags);
			_g_object_unref0 (_data_->selecting);
			block10_data_unref (_data_->_data10_);
			_data_->_data10_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_data_->messages = NULL;
	_data_->_tmp26_ = _data_->selecting;
	_data_->_tmp27_ = geary_iterable_to_linked_list (_data_->_tmp26_, NULL, NULL, NULL);
	_data_->selected = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp27_, GEE_TYPE_COLLECTION, GeeCollection);
	_data_->_tmp28_ = _data_->selected;
	_data_->_tmp29_ = gee_collection_get_is_empty (_data_->_tmp28_);
	_data_->_tmp30_ = _data_->_tmp29_;
	_data_->do_add = _data_->_data10_->prefer_adding ^ _data_->_tmp30_;
	_data_->_tmp31_ = _data_->selected;
	_data_->_tmp32_ = gee_collection_get_is_empty (_data_->_tmp31_);
	_data_->_tmp33_ = _data_->_tmp32_;
	if (_data_->_tmp33_) {
		_data_->_tmp34_ = _g_object_ref0 (_data_->conversations);
		_g_object_unref0 (_data_->selected);
		_data_->selected = _data_->_tmp34_;
	}
	if (_data_->do_add) {
		_data_->_tmp35_ = _data_->selected;
		_data_->_tmp36_ = geary_traverse (GEARY_APP_TYPE_CONVERSATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp35_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp37_ = _data_->_tmp36_;
		_data_->_tmp38_ = geary_iterable_map (_data_->_tmp37_, GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, ____lambda157__gee_map_func, _data_->self);
		_data_->_tmp39_ = _data_->_tmp38_;
		_data_->_tmp40_ = geary_iterable_to_linked_list (_data_->_tmp39_, NULL, NULL, NULL);
		_g_object_unref0 (_data_->messages);
		_data_->messages = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp40_, GEE_TYPE_COLLECTION, GeeCollection);
		_g_object_unref0 (_data_->_tmp39_);
		_g_object_unref0 (_data_->_tmp37_);
	} else {
		_data_->_tmp41_ = gee_linked_list_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		_g_object_unref0 (_data_->messages);
		_data_->messages = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp41_, GEE_TYPE_COLLECTION, GeeCollection);
		{
			_data_->_tmp42_ = _data_->selected;
			_data_->_tmp43_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp42_, GEE_TYPE_ITERABLE, GeeIterable));
			_data_->_convo_it = _data_->_tmp43_;
			while (TRUE) {
				_data_->_tmp44_ = _data_->_convo_it;
				if (!gee_iterator_next (_data_->_tmp44_)) {
					break;
				}
				_data_->_tmp45_ = _data_->_convo_it;
				_data_->_tmp46_ = gee_iterator_get (_data_->_tmp45_);
				_data_->convo = (GearyAppConversation*) _data_->_tmp46_;
				{
					_data_->_tmp47_ = _data_->convo;
					_data_->_tmp48_ = geary_app_conversation_get_emails (_data_->_tmp47_, GEARY_APP_CONVERSATION_ORDERING_RECV_DATE_DESCENDING, GEARY_APP_CONVERSATION_LOCATION_ANYWHERE, NULL, TRUE);
					_data_->_email_list = _data_->_tmp48_;
					_data_->_tmp49_ = _data_->_email_list;
					_data_->_tmp50_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp49_, GEE_TYPE_COLLECTION, GeeCollection));
					_data_->_tmp51_ = _data_->_tmp50_;
					_data_->_email_size = _data_->_tmp51_;
					_data_->_email_index = -1;
					while (TRUE) {
						_data_->_email_index = _data_->_email_index + 1;
						_data_->_tmp52_ = _data_->_email_index;
						_data_->_tmp53_ = _data_->_email_size;
						if (!(_data_->_tmp52_ < _data_->_tmp53_)) {
							break;
						}
						_data_->_tmp54_ = _data_->_email_list;
						_data_->_tmp55_ = gee_list_get (_data_->_tmp54_, _data_->_email_index);
						_data_->email = (GearyEmail*) _data_->_tmp55_;
						_data_->_tmp57_ = _data_->email;
						_data_->_tmp58_ = geary_email_get_email_flags (_data_->_tmp57_);
						_data_->_tmp59_ = _data_->_tmp58_;
						if (_data_->_tmp59_ != NULL) {
							_data_->_tmp60_ = _data_->email;
							_data_->_tmp61_ = geary_email_get_email_flags (_data_->_tmp60_);
							_data_->_tmp62_ = _data_->_tmp61_;
							_data_->_tmp56_ = geary_named_flags_contains (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp62_, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags), _data_->flag);
						} else {
							_data_->_tmp56_ = FALSE;
						}
						if (_data_->_tmp56_) {
							_data_->_tmp63_ = _data_->messages;
							_data_->_tmp64_ = _data_->email;
							_data_->_tmp65_ = geary_email_get_id (_data_->_tmp64_);
							_data_->_tmp66_ = _data_->_tmp65_;
							gee_collection_add (_data_->_tmp63_, _data_->_tmp66_);
						}
						_g_object_unref0 (_data_->email);
					}
					_g_object_unref0 (_data_->_email_list);
				}
				_g_object_unref0 (_data_->convo);
			}
			_g_object_unref0 (_data_->_convo_it);
		}
	}
	if (_data_->do_add) {
		_data_->_tmp68_ = _data_->flags;
		_data_->_tmp67_ = _data_->_tmp68_;
	} else {
		_data_->_tmp67_ = NULL;
	}
	if (_data_->do_add) {
		_data_->_tmp69_ = NULL;
	} else {
		_data_->_tmp70_ = _data_->flags;
		_data_->_tmp69_ = _data_->_tmp70_;
	}
	_data_->_tmp71_ = _data_->messages;
	_data_->_state_ = 1;
	application_controller_mark_messages (_data_->self, _data_->location, _data_->conversations, _data_->_tmp71_, _data_->_tmp67_, _data_->_tmp69_, application_controller_mark_conversations_ready, _data_);
	return FALSE;
	_state_1:
	application_controller_mark_messages_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_->selected);
		_g_object_unref0 (_data_->messages);
		_g_object_unref0 (_data_->flags);
		_g_object_unref0 (_data_->selecting);
		block10_data_unref (_data_->_data10_);
		_data_->_data10_ = NULL;
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->selected);
	_g_object_unref0 (_data_->messages);
	_g_object_unref0 (_data_->flags);
	_g_object_unref0 (_data_->selecting);
	block10_data_unref (_data_->_data10_);
	_data_->_data10_ = 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
application_controller_mark_messages_data_free (gpointer _data)
{
	ApplicationControllerMarkMessagesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->location);
	_g_object_unref0 (_data_->conversations);
	_g_object_unref0 (_data_->messages);
	_g_object_unref0 (_data_->to_add);
	_g_object_unref0 (_data_->to_remove);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerMarkMessagesData, _data_);
}

void
application_controller_mark_messages (ApplicationController* self,
                                      GearyFolder* location,
                                      GeeCollection* conversations,
                                      GeeCollection* messages,
                                      GearyEmailFlags* to_add,
                                      GearyEmailFlags* to_remove,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	ApplicationControllerMarkMessagesData* _data_;
	ApplicationController* _tmp0_;
	GearyFolder* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GearyEmailFlags* _tmp4_;
	GearyEmailFlags* _tmp5_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (messages, GEE_TYPE_COLLECTION));
	g_return_if_fail ((to_add == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (to_add, GEARY_TYPE_EMAIL_FLAGS));
	g_return_if_fail ((to_remove == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (to_remove, GEARY_TYPE_EMAIL_FLAGS));
	_data_ = g_slice_new0 (ApplicationControllerMarkMessagesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_mark_messages_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (location);
	_g_object_unref0 (_data_->location);
	_data_->location = _tmp1_;
	_tmp2_ = _g_object_ref0 (conversations);
	_g_object_unref0 (_data_->conversations);
	_data_->conversations = _tmp2_;
	_tmp3_ = _g_object_ref0 (messages);
	_g_object_unref0 (_data_->messages);
	_data_->messages = _tmp3_;
	_tmp4_ = _g_object_ref0 (to_add);
	_g_object_unref0 (_data_->to_add);
	_data_->to_add = _tmp4_;
	_tmp5_ = _g_object_ref0 (to_remove);
	_g_object_unref0 (_data_->to_remove);
	_data_->to_remove = _tmp5_;
	application_controller_mark_messages_co (_data_);
}

void
application_controller_mark_messages_finish (ApplicationController* self,
                                             GAsyncResult* _res_,
                                             GError** error)
{
	ApplicationControllerMarkMessagesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/**
     * Updates flags for a collection of email.
     *
     * This should only be used when working with specific messages
     * (for example, marking a specific message in a conversation)
     * rather than when working with whole conversations. In that
     * case, use {@link mark_conversations}.
     */
static void
application_controller_mark_messages_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	ApplicationControllerMarkMessagesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_mark_messages_co (_data_);
}

static gboolean
application_controller_mark_messages_co (ApplicationControllerMarkMessagesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->accounts;
	_data_->_tmp1_ = geary_folder_get_account (_data_->location);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_account_get_information (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = gee_map_get (_data_->_tmp0_, _data_->_tmp4_);
	_data_->context = (ApplicationAccountContext*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->context;
	if (_data_->_tmp6_ != NULL) {
		_data_->_tmp7_ = _data_->context;
		_data_->_tmp8_ = application_account_context_get_commands (_data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = _data_->context;
		_data_->_tmp11_ = application_account_context_get_emails (_data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp13_ = gee_collection_get_size (_data_->conversations);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_tmp15_ = gee_collection_get_size (_data_->conversations);
		_data_->_tmp16_ = _data_->_tmp15_;
		_data_->_tmp17_ = application_mark_email_command_new (_data_->location, _data_->conversations, _data_->messages, _data_->_tmp12_, _data_->to_add, _data_->to_remove, ngettext ("Conversation marked", "Conversations marked", (gulong) _data_->_tmp14_), ngettext ("Conversation un-marked", "Conversations un-marked", (gulong) _data_->_tmp16_));
		_data_->_tmp18_ = _data_->_tmp17_;
		_data_->_tmp19_ = _data_->context;
		_data_->_tmp20_ = application_account_context_get_cancellable (_data_->_tmp19_);
		_data_->_tmp21_ = _data_->_tmp20_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp9_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp18_, APPLICATION_TYPE_COMMAND, ApplicationCommand), _data_->_tmp21_, application_controller_mark_messages_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp18_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->context);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_g_object_unref0 (_data_->context);
	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
application_controller_move_conversations_data_free (gpointer _data)
{
	ApplicationControllerMoveConversationsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->source);
	_g_object_unref0 (_data_->destination);
	_g_object_unref0 (_data_->conversations);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerMoveConversationsData, _data_);
}

void
application_controller_move_conversations (ApplicationController* self,
                                           GearyFolderSupportMove* source,
                                           GearyFolder* destination,
                                           GeeCollection* conversations,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	ApplicationControllerMoveConversationsData* _data_;
	ApplicationController* _tmp0_;
	GearyFolderSupportMove* _tmp1_;
	GearyFolder* _tmp2_;
	GeeCollection* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, GEARY_FOLDER_SUPPORT_TYPE_MOVE));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (destination, GEARY_TYPE_FOLDER));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	_data_ = g_slice_new0 (ApplicationControllerMoveConversationsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_move_conversations_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (source);
	_g_object_unref0 (_data_->source);
	_data_->source = _tmp1_;
	_tmp2_ = _g_object_ref0 (destination);
	_g_object_unref0 (_data_->destination);
	_data_->destination = _tmp2_;
	_tmp3_ = _g_object_ref0 (conversations);
	_g_object_unref0 (_data_->conversations);
	_data_->conversations = _tmp3_;
	application_controller_move_conversations_co (_data_);
}

void
application_controller_move_conversations_finish (ApplicationController* self,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	ApplicationControllerMoveConversationsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_controller_move_conversations_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	ApplicationControllerMoveConversationsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_move_conversations_co (_data_);
}

static gboolean
application_controller_move_conversations_co (ApplicationControllerMoveConversationsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->accounts;
	_data_->_tmp1_ = geary_folder_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->source, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_account_get_information (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = gee_map_get (_data_->_tmp0_, _data_->_tmp4_);
	_data_->context = (ApplicationAccountContext*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->context;
	if (_data_->_tmp6_ != NULL) {
		_data_->_tmp7_ = _data_->context;
		_data_->_tmp8_ = application_account_context_get_commands (_data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = application_controller_to_in_folder_email_ids (_data_->self, _data_->conversations);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = gee_collection_get_size (_data_->conversations);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = util_i18n_to_folder_display_name (_data_->destination);
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_tmp16_ = g_strdup_printf (ngettext ("Conversation moved to %s", "Conversations moved to %s", (gulong) _data_->_tmp13_), _data_->_tmp15_);
		_data_->_tmp17_ = _data_->_tmp16_;
		_data_->_tmp18_ = gee_collection_get_size (_data_->conversations);
		_data_->_tmp19_ = _data_->_tmp18_;
		_data_->_tmp20_ = util_i18n_to_folder_display_name (G_TYPE_CHECK_INSTANCE_CAST (_data_->source, GEARY_TYPE_FOLDER, GearyFolder));
		_data_->_tmp21_ = _data_->_tmp20_;
		_data_->_tmp22_ = g_strdup_printf (ngettext ("Conversation restored to %s", "Conversations restored to %s", (gulong) _data_->_tmp19_), _data_->_tmp21_);
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_tmp24_ = application_move_email_command_new (_data_->source, _data_->destination, _data_->conversations, _data_->_tmp11_, _data_->_tmp17_, _data_->_tmp23_);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_tmp26_ = _data_->context;
		_data_->_tmp27_ = application_account_context_get_cancellable (_data_->_tmp26_);
		_data_->_tmp28_ = _data_->_tmp27_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp9_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp25_, APPLICATION_TYPE_COMMAND, ApplicationCommand), _data_->_tmp28_, application_controller_move_conversations_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp25_);
		_g_free0 (_data_->_tmp23_);
		_g_free0 (_data_->_tmp21_);
		_g_free0 (_data_->_tmp17_);
		_g_free0 (_data_->_tmp15_);
		_g_object_unref0 (_data_->_tmp11_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->context);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_g_object_unref0 (_data_->context);
	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
application_controller_move_conversations_special_data_free (gpointer _data)
{
	ApplicationControllerMoveConversationsSpecialData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->source);
	_g_object_unref0 (_data_->conversations);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerMoveConversationsSpecialData, _data_);
}

void
application_controller_move_conversations_special (ApplicationController* self,
                                                   GearyFolder* source,
                                                   GearyFolderSpecialUse destination,
                                                   GeeCollection* conversations,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	ApplicationControllerMoveConversationsSpecialData* _data_;
	ApplicationController* _tmp0_;
	GearyFolder* _tmp1_;
	GeeCollection* _tmp2_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, GEARY_TYPE_FOLDER));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	_data_ = g_slice_new0 (ApplicationControllerMoveConversationsSpecialData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_move_conversations_special_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (source);
	_g_object_unref0 (_data_->source);
	_data_->source = _tmp1_;
	_data_->destination = destination;
	_tmp2_ = _g_object_ref0 (conversations);
	_g_object_unref0 (_data_->conversations);
	_data_->conversations = _tmp2_;
	application_controller_move_conversations_special_co (_data_);
}

void
application_controller_move_conversations_special_finish (ApplicationController* self,
                                                          GAsyncResult* _res_,
                                                          GError** error)
{
	ApplicationControllerMoveConversationsSpecialData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_controller_move_conversations_special_ready (GObject* source_object,
                                                         GAsyncResult* _res_,
                                                         gpointer _user_data_)
{
	ApplicationControllerMoveConversationsSpecialData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_move_conversations_special_co (_data_);
}

static gboolean
application_controller_move_conversations_special_co (ApplicationControllerMoveConversationsSpecialData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->accounts;
	_data_->_tmp1_ = geary_folder_get_account (_data_->source);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_account_get_information (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = gee_map_get (_data_->_tmp0_, _data_->_tmp4_);
	_data_->context = (ApplicationAccountContext*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->context;
	if (_data_->_tmp6_ != NULL) {
		_data_->command = NULL;
		_data_->_tmp7_ = application_controller_to_in_folder_email_ids (_data_->self, _data_->conversations);
		_data_->messages = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->messages;
		_data_->_tmp9_ = gee_collection_get_size (_data_->_tmp8_);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = util_i18n_to_folder_display_name (_data_->source);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp13_ = g_strdup_printf (ngettext ("Conversation restored to %s", "Conversations restored to %s", (gulong) _data_->_tmp10_), _data_->_tmp12_);
		_data_->_tmp14_ = _data_->_tmp13_;
		_g_free0 (_data_->_tmp12_);
		_data_->undone_tooltip = _data_->_tmp14_;
		if (_data_->destination == GEARY_FOLDER_SPECIAL_USE_ARCHIVE) {
			_data_->_tmp15_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->source, GEARY_FOLDER_SUPPORT_TYPE_ARCHIVE) ? ((GearyFolderSupportArchive*) _data_->source) : NULL);
			_data_->archive_source = _data_->_tmp15_;
			_data_->_tmp16_ = _data_->archive_source;
			if (_data_->_tmp16_ == NULL) {
				_data_->_tmp17_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->source, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp18_ = _data_->_tmp17_;
				_data_->_tmp19_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Folder does not support archiving: %s", _data_->_tmp18_);
				_data_->_tmp20_ = _data_->_tmp19_;
				_g_free0 (_data_->_tmp18_);
				_data_->_inner_error0_ = _data_->_tmp20_;
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->archive_source);
				_g_free0 (_data_->undone_tooltip);
				_g_object_unref0 (_data_->messages);
				_g_object_unref0 (_data_->command);
				_g_object_unref0 (_data_->context);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp21_ = _data_->archive_source;
			_data_->_tmp22_ = _data_->messages;
			_data_->_tmp23_ = _data_->messages;
			_data_->_tmp24_ = gee_collection_get_size (_data_->_tmp23_);
			_data_->_tmp25_ = _data_->_tmp24_;
			_data_->_tmp26_ = _data_->undone_tooltip;
			_data_->_tmp27_ = application_archive_email_command_new (_data_->_tmp21_, _data_->conversations, _data_->_tmp22_, ngettext ("Conversation archived", "Conversations archived", (gulong) _data_->_tmp25_), _data_->_tmp26_);
			_g_object_unref0 (_data_->command);
			_data_->command = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp27_, APPLICATION_TYPE_COMMAND, ApplicationCommand);
			_g_object_unref0 (_data_->archive_source);
		} else {
			_data_->_tmp28_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->source, GEARY_FOLDER_SUPPORT_TYPE_MOVE) ? ((GearyFolderSupportMove*) _data_->source) : NULL);
			_data_->move_source = _data_->_tmp28_;
			_data_->_tmp29_ = _data_->move_source;
			if (_data_->_tmp29_ == NULL) {
				_data_->_tmp30_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->source, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp31_ = _data_->_tmp30_;
				_data_->_tmp32_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Folder does not support moving: %s", _data_->_tmp31_);
				_data_->_tmp33_ = _data_->_tmp32_;
				_g_free0 (_data_->_tmp31_);
				_data_->_inner_error0_ = _data_->_tmp33_;
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->move_source);
				_g_free0 (_data_->undone_tooltip);
				_g_object_unref0 (_data_->messages);
				_g_object_unref0 (_data_->command);
				_g_object_unref0 (_data_->context);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp34_ = geary_folder_get_account (_data_->source);
			_data_->_tmp35_ = _data_->_tmp34_;
			_data_->_tmp36_ = geary_account_get_special_folder (_data_->_tmp35_, _data_->destination);
			_data_->dest = _data_->_tmp36_;
			_data_->_tmp37_ = _data_->dest;
			if (_data_->_tmp37_ == NULL) {
				_data_->_tmp38_ = g_enum_get_value (g_type_class_ref (GEARY_FOLDER_TYPE_SPECIAL_USE), _data_->destination);
				_data_->_tmp39_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "No folder found for: %s", (_data_->_tmp38_ != NULL) ? _data_->_tmp38_->value_name : NULL);
				_data_->_inner_error0_ = _data_->_tmp39_;
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->dest);
				_g_object_unref0 (_data_->move_source);
				_g_free0 (_data_->undone_tooltip);
				_g_object_unref0 (_data_->messages);
				_g_object_unref0 (_data_->command);
				_g_object_unref0 (_data_->context);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp40_ = _data_->move_source;
			_data_->_tmp41_ = _data_->dest;
			_data_->_tmp42_ = _data_->messages;
			_data_->_tmp43_ = _data_->messages;
			_data_->_tmp44_ = gee_collection_get_size (_data_->_tmp43_);
			_data_->_tmp45_ = _data_->_tmp44_;
			_data_->_tmp46_ = _data_->dest;
			_data_->_tmp47_ = util_i18n_to_folder_display_name (_data_->_tmp46_);
			_data_->_tmp48_ = _data_->_tmp47_;
			_data_->_tmp49_ = g_strdup_printf (ngettext ("Conversation moved to %s", "Conversations moved to %s", (gulong) _data_->_tmp45_), _data_->_tmp48_);
			_data_->_tmp50_ = _data_->_tmp49_;
			_data_->_tmp51_ = _data_->undone_tooltip;
			_data_->_tmp52_ = application_move_email_command_new (_data_->_tmp40_, _data_->_tmp41_, _data_->conversations, _data_->_tmp42_, _data_->_tmp50_, _data_->_tmp51_);
			_g_object_unref0 (_data_->command);
			_data_->command = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp52_, APPLICATION_TYPE_COMMAND, ApplicationCommand);
			_g_free0 (_data_->_tmp50_);
			_g_free0 (_data_->_tmp48_);
			_g_object_unref0 (_data_->dest);
			_g_object_unref0 (_data_->move_source);
		}
		_data_->_tmp53_ = _data_->context;
		_data_->_tmp54_ = application_account_context_get_commands (_data_->_tmp53_);
		_data_->_tmp55_ = _data_->_tmp54_;
		_data_->_tmp56_ = _data_->command;
		_data_->_tmp57_ = _data_->context;
		_data_->_tmp58_ = application_account_context_get_cancellable (_data_->_tmp57_);
		_data_->_tmp59_ = _data_->_tmp58_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp55_, _data_->_tmp56_, _data_->_tmp59_, application_controller_move_conversations_special_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp55_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_free0 (_data_->undone_tooltip);
			_g_object_unref0 (_data_->messages);
			_g_object_unref0 (_data_->command);
			_g_object_unref0 (_data_->context);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_free0 (_data_->undone_tooltip);
		_g_object_unref0 (_data_->messages);
		_g_object_unref0 (_data_->command);
	}
	_g_object_unref0 (_data_->context);
	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
application_controller_move_messages_special_data_free (gpointer _data)
{
	ApplicationControllerMoveMessagesSpecialData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->source);
	_g_object_unref0 (_data_->conversations);
	_g_object_unref0 (_data_->messages);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerMoveMessagesSpecialData, _data_);
}

void
application_controller_move_messages_special (ApplicationController* self,
                                              GearyFolder* source,
                                              GearyFolderSpecialUse destination,
                                              GeeCollection* conversations,
                                              GeeCollection* messages,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	ApplicationControllerMoveMessagesSpecialData* _data_;
	ApplicationController* _tmp0_;
	GearyFolder* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, GEARY_TYPE_FOLDER));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (messages, GEE_TYPE_COLLECTION));
	_data_ = g_slice_new0 (ApplicationControllerMoveMessagesSpecialData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_move_messages_special_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (source);
	_g_object_unref0 (_data_->source);
	_data_->source = _tmp1_;
	_data_->destination = destination;
	_tmp2_ = _g_object_ref0 (conversations);
	_g_object_unref0 (_data_->conversations);
	_data_->conversations = _tmp2_;
	_tmp3_ = _g_object_ref0 (messages);
	_g_object_unref0 (_data_->messages);
	_data_->messages = _tmp3_;
	application_controller_move_messages_special_co (_data_);
}

void
application_controller_move_messages_special_finish (ApplicationController* self,
                                                     GAsyncResult* _res_,
                                                     GError** error)
{
	ApplicationControllerMoveMessagesSpecialData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_controller_move_messages_special_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	ApplicationControllerMoveMessagesSpecialData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_move_messages_special_co (_data_);
}

static gboolean
application_controller_move_messages_special_co (ApplicationControllerMoveMessagesSpecialData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->accounts;
	_data_->_tmp1_ = geary_folder_get_account (_data_->source);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_account_get_information (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = gee_map_get (_data_->_tmp0_, _data_->_tmp4_);
	_data_->context = (ApplicationAccountContext*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->context;
	if (_data_->_tmp6_ != NULL) {
		_data_->command = NULL;
		_data_->_tmp7_ = gee_collection_get_size (_data_->messages);
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_tmp9_ = util_i18n_to_folder_display_name (_data_->source);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = g_strdup_printf (ngettext ("Message restored to %s", "Messages restored to %s", (gulong) _data_->_tmp8_), _data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		_g_free0 (_data_->_tmp10_);
		_data_->undone_tooltip = _data_->_tmp12_;
		if (_data_->destination == GEARY_FOLDER_SPECIAL_USE_ARCHIVE) {
			_data_->_tmp13_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->source, GEARY_FOLDER_SUPPORT_TYPE_ARCHIVE) ? ((GearyFolderSupportArchive*) _data_->source) : NULL);
			_data_->archive_source = _data_->_tmp13_;
			_data_->_tmp14_ = _data_->archive_source;
			if (_data_->_tmp14_ == NULL) {
				_data_->_tmp15_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->source, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp16_ = _data_->_tmp15_;
				_data_->_tmp17_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Folder does not support archiving: %s", _data_->_tmp16_);
				_data_->_tmp18_ = _data_->_tmp17_;
				_g_free0 (_data_->_tmp16_);
				_data_->_inner_error0_ = _data_->_tmp18_;
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->archive_source);
				_g_free0 (_data_->undone_tooltip);
				_g_object_unref0 (_data_->command);
				_g_object_unref0 (_data_->context);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp19_ = _data_->archive_source;
			_data_->_tmp20_ = gee_collection_get_size (_data_->messages);
			_data_->_tmp21_ = _data_->_tmp20_;
			_data_->_tmp22_ = _data_->undone_tooltip;
			_data_->_tmp23_ = application_archive_email_command_new (_data_->_tmp19_, _data_->conversations, _data_->messages, ngettext ("Message archived", "Messages archived", (gulong) _data_->_tmp21_), _data_->_tmp22_);
			_g_object_unref0 (_data_->command);
			_data_->command = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp23_, APPLICATION_TYPE_COMMAND, ApplicationCommand);
			_g_object_unref0 (_data_->archive_source);
		} else {
			_data_->_tmp24_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->source, GEARY_FOLDER_SUPPORT_TYPE_MOVE) ? ((GearyFolderSupportMove*) _data_->source) : NULL);
			_data_->move_source = _data_->_tmp24_;
			_data_->_tmp25_ = _data_->move_source;
			if (_data_->_tmp25_ == NULL) {
				_data_->_tmp26_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->source, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp27_ = _data_->_tmp26_;
				_data_->_tmp28_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Folder does not support moving: %s", _data_->_tmp27_);
				_data_->_tmp29_ = _data_->_tmp28_;
				_g_free0 (_data_->_tmp27_);
				_data_->_inner_error0_ = _data_->_tmp29_;
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->move_source);
				_g_free0 (_data_->undone_tooltip);
				_g_object_unref0 (_data_->command);
				_g_object_unref0 (_data_->context);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp30_ = geary_folder_get_account (_data_->source);
			_data_->_tmp31_ = _data_->_tmp30_;
			_data_->_tmp32_ = geary_account_get_special_folder (_data_->_tmp31_, _data_->destination);
			_data_->dest = _data_->_tmp32_;
			_data_->_tmp33_ = _data_->dest;
			if (_data_->_tmp33_ == NULL) {
				_data_->_tmp34_ = g_enum_get_value (g_type_class_ref (GEARY_FOLDER_TYPE_SPECIAL_USE), _data_->destination);
				_data_->_tmp35_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "No folder found for: %s", (_data_->_tmp34_ != NULL) ? _data_->_tmp34_->value_name : NULL);
				_data_->_inner_error0_ = _data_->_tmp35_;
				g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
				_g_object_unref0 (_data_->dest);
				_g_object_unref0 (_data_->move_source);
				_g_free0 (_data_->undone_tooltip);
				_g_object_unref0 (_data_->command);
				_g_object_unref0 (_data_->context);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
			_data_->_tmp36_ = _data_->move_source;
			_data_->_tmp37_ = _data_->dest;
			_data_->_tmp38_ = gee_collection_get_size (_data_->messages);
			_data_->_tmp39_ = _data_->_tmp38_;
			_data_->_tmp40_ = _data_->dest;
			_data_->_tmp41_ = util_i18n_to_folder_display_name (_data_->_tmp40_);
			_data_->_tmp42_ = _data_->_tmp41_;
			_data_->_tmp43_ = g_strdup_printf (ngettext ("Message moved to %s", "Messages moved to %s", (gulong) _data_->_tmp39_), _data_->_tmp42_);
			_data_->_tmp44_ = _data_->_tmp43_;
			_data_->_tmp45_ = _data_->undone_tooltip;
			_data_->_tmp46_ = application_move_email_command_new (_data_->_tmp36_, _data_->_tmp37_, _data_->conversations, _data_->messages, _data_->_tmp44_, _data_->_tmp45_);
			_g_object_unref0 (_data_->command);
			_data_->command = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp46_, APPLICATION_TYPE_COMMAND, ApplicationCommand);
			_g_free0 (_data_->_tmp44_);
			_g_free0 (_data_->_tmp42_);
			_g_object_unref0 (_data_->dest);
			_g_object_unref0 (_data_->move_source);
		}
		_data_->_tmp47_ = _data_->context;
		_data_->_tmp48_ = application_account_context_get_commands (_data_->_tmp47_);
		_data_->_tmp49_ = _data_->_tmp48_;
		_data_->_tmp50_ = _data_->command;
		_data_->_tmp51_ = _data_->context;
		_data_->_tmp52_ = application_account_context_get_cancellable (_data_->_tmp51_);
		_data_->_tmp53_ = _data_->_tmp52_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp49_, _data_->_tmp50_, _data_->_tmp53_, application_controller_move_messages_special_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp49_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_free0 (_data_->undone_tooltip);
			_g_object_unref0 (_data_->command);
			_g_object_unref0 (_data_->context);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_free0 (_data_->undone_tooltip);
		_g_object_unref0 (_data_->command);
	}
	_g_object_unref0 (_data_->context);
	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
application_controller_copy_conversations_data_free (gpointer _data)
{
	ApplicationControllerCopyConversationsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->source);
	_g_object_unref0 (_data_->destination);
	_g_object_unref0 (_data_->conversations);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerCopyConversationsData, _data_);
}

void
application_controller_copy_conversations (ApplicationController* self,
                                           GearyFolderSupportCopy* source,
                                           GearyFolder* destination,
                                           GeeCollection* conversations,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	ApplicationControllerCopyConversationsData* _data_;
	ApplicationController* _tmp0_;
	GearyFolderSupportCopy* _tmp1_;
	GearyFolder* _tmp2_;
	GeeCollection* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, GEARY_FOLDER_SUPPORT_TYPE_COPY));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (destination, GEARY_TYPE_FOLDER));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	_data_ = g_slice_new0 (ApplicationControllerCopyConversationsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_copy_conversations_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (source);
	_g_object_unref0 (_data_->source);
	_data_->source = _tmp1_;
	_tmp2_ = _g_object_ref0 (destination);
	_g_object_unref0 (_data_->destination);
	_data_->destination = _tmp2_;
	_tmp3_ = _g_object_ref0 (conversations);
	_g_object_unref0 (_data_->conversations);
	_data_->conversations = _tmp3_;
	application_controller_copy_conversations_co (_data_);
}

void
application_controller_copy_conversations_finish (ApplicationController* self,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	ApplicationControllerCopyConversationsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_controller_copy_conversations_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	ApplicationControllerCopyConversationsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_copy_conversations_co (_data_);
}

static gboolean
application_controller_copy_conversations_co (ApplicationControllerCopyConversationsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->accounts;
	_data_->_tmp1_ = geary_folder_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->source, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_account_get_information (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = gee_map_get (_data_->_tmp0_, _data_->_tmp4_);
	_data_->context = (ApplicationAccountContext*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->context;
	if (_data_->_tmp6_ != NULL) {
		_data_->_tmp7_ = _data_->context;
		_data_->_tmp8_ = application_account_context_get_commands (_data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = application_controller_to_in_folder_email_ids (_data_->self, _data_->conversations);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = gee_collection_get_size (_data_->conversations);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = util_i18n_to_folder_display_name (_data_->destination);
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_tmp16_ = g_strdup_printf (ngettext ("Conversation labelled as %s", "Conversations labelled as %s", (gulong) _data_->_tmp13_), _data_->_tmp15_);
		_data_->_tmp17_ = _data_->_tmp16_;
		_data_->_tmp18_ = gee_collection_get_size (_data_->conversations);
		_data_->_tmp19_ = _data_->_tmp18_;
		_data_->_tmp20_ = util_i18n_to_folder_display_name (_data_->destination);
		_data_->_tmp21_ = _data_->_tmp20_;
		_data_->_tmp22_ = g_strdup_printf (ngettext ("Conversation un-labelled as %s", "Conversations un-labelled as %s", (gulong) _data_->_tmp19_), _data_->_tmp21_);
		_data_->_tmp23_ = _data_->_tmp22_;
		_data_->_tmp24_ = application_copy_email_command_new (_data_->source, _data_->destination, _data_->conversations, _data_->_tmp11_, _data_->_tmp17_, _data_->_tmp23_);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_tmp26_ = _data_->context;
		_data_->_tmp27_ = application_account_context_get_cancellable (_data_->_tmp26_);
		_data_->_tmp28_ = _data_->_tmp27_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp9_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp25_, APPLICATION_TYPE_COMMAND, ApplicationCommand), _data_->_tmp28_, application_controller_copy_conversations_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp9_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp25_);
		_g_free0 (_data_->_tmp23_);
		_g_free0 (_data_->_tmp21_);
		_g_free0 (_data_->_tmp17_);
		_g_free0 (_data_->_tmp15_);
		_g_object_unref0 (_data_->_tmp11_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->context);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_g_object_unref0 (_data_->context);
	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
application_controller_delete_conversations_data_free (gpointer _data)
{
	ApplicationControllerDeleteConversationsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->target);
	_g_object_unref0 (_data_->conversations);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerDeleteConversationsData, _data_);
}

void
application_controller_delete_conversations (ApplicationController* self,
                                             GearyFolderSupportRemove* target,
                                             GeeCollection* conversations,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	ApplicationControllerDeleteConversationsData* _data_;
	ApplicationController* _tmp0_;
	GearyFolderSupportRemove* _tmp1_;
	GeeCollection* _tmp2_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (target, GEARY_FOLDER_SUPPORT_TYPE_REMOVE));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	_data_ = g_slice_new0 (ApplicationControllerDeleteConversationsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_delete_conversations_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (target);
	_g_object_unref0 (_data_->target);
	_data_->target = _tmp1_;
	_tmp2_ = _g_object_ref0 (conversations);
	_g_object_unref0 (_data_->conversations);
	_data_->conversations = _tmp2_;
	application_controller_delete_conversations_co (_data_);
}

void
application_controller_delete_conversations_finish (ApplicationController* self,
                                                    GAsyncResult* _res_,
                                                    GError** error)
{
	ApplicationControllerDeleteConversationsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_controller_delete_conversations_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_)
{
	ApplicationControllerDeleteConversationsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_delete_conversations_co (_data_);
}

static gboolean
application_controller_delete_conversations_co (ApplicationControllerDeleteConversationsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = geary_folder_get_properties (G_TYPE_CHECK_INSTANCE_CAST (_data_->target, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_folder_properties_get_is_virtual (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	if (_data_->_tmp4_) {
		_data_->_tmp5_ = application_controller_to_all_email_ids (_data_->self, _data_->conversations);
		_g_object_unref0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp5_;
	} else {
		_data_->_tmp6_ = application_controller_to_in_folder_email_ids (_data_->self, _data_->conversations);
		_g_object_unref0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp6_;
	}
	_data_->_tmp7_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_data_->messages = _data_->_tmp7_;
	_data_->_state_ = 1;
	application_controller_delete_messages (_data_->self, _data_->target, _data_->conversations, _data_->messages, application_controller_delete_conversations_ready, _data_);
	return FALSE;
	_state_1:
	application_controller_delete_messages_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_->messages);
		_g_object_unref0 (_data_->_tmp0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_g_object_unref0 (_data_->messages);
	_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
application_controller_delete_messages_data_free (gpointer _data)
{
	ApplicationControllerDeleteMessagesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversations);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerDeleteMessagesData, _data_);
}

void
application_controller_delete_messages (ApplicationController* self,
                                        GearyFolderSupportRemove* target,
                                        GeeCollection* conversations,
                                        GeeCollection* messages,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_)
{
	ApplicationControllerDeleteMessagesData* _data_;
	ApplicationController* _tmp0_;
	GearyFolderSupportRemove* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (target, GEARY_FOLDER_SUPPORT_TYPE_REMOVE));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (messages, GEE_TYPE_COLLECTION));
	_data_ = g_slice_new0 (ApplicationControllerDeleteMessagesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_delete_messages_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (target);
	_g_object_unref0 (_data_->target);
	_data_->target = _tmp1_;
	_tmp2_ = _g_object_ref0 (conversations);
	_g_object_unref0 (_data_->conversations);
	_data_->conversations = _tmp2_;
	_tmp3_ = _g_object_ref0 (messages);
	_g_object_unref0 (_data_->messages);
	_data_->messages = _tmp3_;
	application_controller_delete_messages_co (_data_);
}

void
application_controller_delete_messages_finish (ApplicationController* self,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	ApplicationControllerDeleteMessagesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		ApplicationController* self;
		self = _data11_->self;
		_g_object_unref0 (_data11_->context);
		_g_object_unref0 (_data11_->target);
		_g_object_unref0 (_data11_->messages);
		_g_object_unref0 (self);
		g_slice_free (Block11Data, _data11_);
	}
}

static void
___lambda158_ (Block11Data* _data11_)
{
	ApplicationController* self;
	ApplicationAccountContext* _tmp0_;
	ApplicationControllerCommandStack* _tmp1_;
	ApplicationControllerCommandStack* _tmp2_;
	self = _data11_->self;
	_tmp0_ = _data11_->context;
	_tmp1_ = application_account_context_get_controller_stack (_tmp0_);
	_tmp2_ = _tmp1_;
	application_controller_command_stack_email_removed (_tmp2_, G_TYPE_CHECK_INSTANCE_CAST (_data11_->target, GEARY_TYPE_FOLDER, GearyFolder), _data11_->messages);
}

static void
____lambda158__application_command_executed (ApplicationCommand* _sender,
                                             gpointer self)
{
	___lambda158_ (self);
}

static void
application_controller_delete_messages_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	ApplicationControllerDeleteMessagesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_delete_messages_co (_data_);
}

static gboolean
application_controller_delete_messages_co (ApplicationControllerDeleteMessagesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data11_ = g_slice_new0 (Block11Data);
	_data_->_data11_->_ref_count_ = 1;
	_data_->_data11_->self = g_object_ref (_data_->self);
	_g_object_unref0 (_data_->_data11_->target);
	_data_->_data11_->target = _data_->target;
	_g_object_unref0 (_data_->_data11_->messages);
	_data_->_data11_->messages = _data_->messages;
	_data_->_data11_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->accounts;
	_data_->_tmp1_ = geary_folder_get_account (G_TYPE_CHECK_INSTANCE_CAST (_data_->_data11_->target, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_account_get_information (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = gee_map_get (_data_->_tmp0_, _data_->_tmp4_);
	_data_->_data11_->context = (ApplicationAccountContext*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->_data11_->context;
	if (_data_->_tmp6_ != NULL) {
		_data_->_tmp7_ = application_delete_email_command_new (_data_->_data11_->target, _data_->conversations, _data_->_data11_->messages);
		_data_->command = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, APPLICATION_TYPE_COMMAND, ApplicationCommand);
		_data_->_tmp8_ = _data_->command;
		g_signal_connect_data (_data_->_tmp8_, "executed", (GCallback) ____lambda158__application_command_executed, block11_data_ref (_data_->_data11_), (GClosureNotify) block11_data_unref, 0);
		_data_->_tmp9_ = _data_->_data11_->context;
		_data_->_tmp10_ = application_account_context_get_commands (_data_->_tmp9_);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = _data_->command;
		_data_->_tmp13_ = _data_->_data11_->context;
		_data_->_tmp14_ = application_account_context_get_cancellable (_data_->_tmp13_);
		_data_->_tmp15_ = _data_->_tmp14_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp11_, _data_->_tmp12_, _data_->_tmp15_, application_controller_delete_messages_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp11_, _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_->command);
			block11_data_unref (_data_->_data11_);
			_data_->_data11_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->command);
	}
	block11_data_unref (_data_->_data11_);
	_data_->_data11_ = 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
application_controller_empty_folder_data_free (gpointer _data)
{
	ApplicationControllerEmptyFolderData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->target);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerEmptyFolderData, _data_);
}

void
application_controller_empty_folder (ApplicationController* self,
                                     GearyFolder* target,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	ApplicationControllerEmptyFolderData* _data_;
	ApplicationController* _tmp0_;
	GearyFolder* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (target, GEARY_TYPE_FOLDER));
	_data_ = g_slice_new0 (ApplicationControllerEmptyFolderData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_empty_folder_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (target);
	_g_object_unref0 (_data_->target);
	_data_->target = _tmp1_;
	application_controller_empty_folder_co (_data_);
}

void
application_controller_empty_folder_finish (ApplicationController* self,
                                            GAsyncResult* _res_,
                                            GError** error)
{
	ApplicationControllerEmptyFolderData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static Block12Data*
block12_data_ref (Block12Data* _data12_)
{
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}

static void
block12_data_unref (void * _userdata_)
{
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		ApplicationController* self;
		self = _data12_->self;
		_g_object_unref0 (_data12_->context);
		_g_object_unref0 (self);
		g_slice_free (Block12Data, _data12_);
	}
}

static Block13Data*
block13_data_ref (Block13Data* _data13_)
{
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}

static void
block13_data_unref (void * _userdata_)
{
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		ApplicationController* self;
		self = _data13_->_data12_->self;
		_g_object_unref0 (_data13_->emptyable);
		block12_data_unref (_data13_->_data12_);
		_data13_->_data12_ = NULL;
		g_slice_free (Block13Data, _data13_);
	}
}

static void
___lambda145_ (Block13Data* _data13_)
{
	Block12Data* _data12_;
	ApplicationController* self;
	ApplicationAccountContext* _tmp0_;
	ApplicationControllerCommandStack* _tmp1_;
	ApplicationControllerCommandStack* _tmp2_;
	GearyFolderSupportEmpty* _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	_data12_ = _data13_->_data12_;
	self = _data12_->self;
	_tmp0_ = _data12_->context;
	_tmp1_ = application_account_context_get_controller_stack (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _data13_->emptyable;
	_tmp4_ = geary_collection_single (GEARY_FOLDER_SUPPORT_TYPE_EMPTY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp3_);
	_tmp5_ = _tmp4_;
	application_controller_command_stack_folders_removed (_tmp2_, _tmp5_);
	_g_object_unref0 (_tmp5_);
}

static void
____lambda145__application_command_executed (ApplicationCommand* _sender,
                                             gpointer self)
{
	___lambda145_ (self);
}

static void
application_controller_empty_folder_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	ApplicationControllerEmptyFolderData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_empty_folder_co (_data_);
}

static gboolean
application_controller_empty_folder_co (ApplicationControllerEmptyFolderData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data12_ = g_slice_new0 (Block12Data);
	_data_->_data12_->_ref_count_ = 1;
	_data_->_data12_->self = g_object_ref (_data_->self);
	_data_->_data12_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->accounts;
	_data_->_tmp1_ = geary_folder_get_account (_data_->target);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_account_get_information (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = gee_map_get (_data_->_tmp0_, _data_->_tmp4_);
	_data_->_data12_->context = (ApplicationAccountContext*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->_data12_->context;
	if (_data_->_tmp6_ != NULL) {
		_data_->_data13_ = g_slice_new0 (Block13Data);
		_data_->_data13_->_ref_count_ = 1;
		_data_->_data13_->_data12_ = block12_data_ref (_data_->_data12_);
		_data_->_tmp7_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->target, GEARY_FOLDER_SUPPORT_TYPE_EMPTY) ? ((GearyFolderSupportEmpty*) _data_->target) : NULL);
		_data_->_data13_->emptyable = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->_data13_->emptyable;
		if (_data_->_tmp8_ == NULL) {
			_data_->_tmp9_ = geary_folder_get_path (_data_->target);
			_data_->_tmp10_ = _data_->_tmp9_;
			_data_->_tmp11_ = geary_folder_path_to_string (_data_->_tmp10_);
			_data_->_tmp12_ = _data_->_tmp11_;
			_data_->_tmp13_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Emptying folder not supported %s", _data_->_tmp12_);
			_data_->_tmp14_ = _data_->_tmp13_;
			_g_free0 (_data_->_tmp12_);
			_data_->_inner_error0_ = _data_->_tmp14_;
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			block13_data_unref (_data_->_data13_);
			_data_->_data13_ = NULL;
			block12_data_unref (_data_->_data12_);
			_data_->_data12_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp15_ = _data_->_data13_->emptyable;
		_data_->_tmp16_ = application_empty_folder_command_new (_data_->_tmp15_);
		_data_->command = G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp16_, APPLICATION_TYPE_COMMAND, ApplicationCommand);
		_data_->_tmp17_ = _data_->command;
		g_signal_connect_data (_data_->_tmp17_, "executed", (GCallback) ____lambda145__application_command_executed, block13_data_ref (_data_->_data13_), (GClosureNotify) block13_data_unref, 0);
		_data_->_tmp18_ = _data_->_data12_->context;
		_data_->_tmp19_ = application_account_context_get_commands (_data_->_tmp18_);
		_data_->_tmp20_ = _data_->_tmp19_;
		_data_->_tmp21_ = _data_->command;
		_data_->_tmp22_ = _data_->_data12_->context;
		_data_->_tmp23_ = application_account_context_get_cancellable (_data_->_tmp22_);
		_data_->_tmp24_ = _data_->_tmp23_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp20_, _data_->_tmp21_, _data_->_tmp24_, application_controller_empty_folder_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp20_, _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_->command);
			block13_data_unref (_data_->_data13_);
			_data_->_data13_ = NULL;
			block12_data_unref (_data_->_data12_);
			_data_->_data12_ = NULL;
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->command);
		block13_data_unref (_data_->_data13_);
		_data_->_data13_ = NULL;
	}
	block12_data_unref (_data_->_data12_);
	_data_->_data12_ = 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;
}

/** Returns a context for an account, if any. */
static ApplicationAccountContext*
application_controller_real_get_context_for_account (ApplicationAccountInterface* base,
                                                     GearyAccountInformation* account)
{
	ApplicationController * self;
	GeeMap* _tmp0_;
	gpointer _tmp1_;
	ApplicationAccountContext* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT_INFORMATION), NULL);
	_tmp0_ = self->priv->accounts;
	_tmp1_ = gee_map_get (_tmp0_, account);
	result = (ApplicationAccountContext*) _tmp1_;
	return result;
}

/** Returns a read-only collection of contexts each active account. */
static GeeCollection*
application_controller_real_get_account_contexts (ApplicationAccountInterface* base)
{
	ApplicationController * self;
	GeeMap* _tmp0_;
	GeeCollection* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	GeeCollection* _tmp6_;
	GeeCollection* result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	_tmp0_ = self->priv->accounts;
	_tmp1_ = gee_map_get_values (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = gee_collection_get_read_only_view (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_g_object_unref0 (_tmp3_);
	result = _tmp6_;
	return result;
}

static void
_application_controller_on_retry_service_problem_application_main_window_retry_service_problem (ApplicationMainWindow* _sender,
                                                                                                GearyClientServiceStatus problem,
                                                                                                gpointer self)
{
	application_controller_on_retry_service_problem ((ApplicationController*) self, problem);
}

void
application_controller_register_window (ApplicationController* self,
                                        ApplicationMainWindow* window)
{
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (APPLICATION_IS_MAIN_WINDOW (window));
	g_signal_connect_object (window, "retry-service-problem", (GCallback) _application_controller_on_retry_service_problem_application_main_window_retry_service_problem, self, 0);
}

void
application_controller_unregister_window (ApplicationController* self,
                                          ApplicationMainWindow* window)
{
	guint _tmp0_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (APPLICATION_IS_MAIN_WINDOW (window));
	g_signal_parse_name ("retry-service-problem", APPLICATION_TYPE_MAIN_WINDOW, &_tmp0_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (window, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp0_, 0, NULL, (GCallback) _application_controller_on_retry_service_problem_application_main_window_retry_service_problem, self);
}

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

void
application_controller_process_pending_composers (ApplicationController* self,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	ApplicationControllerProcessPendingComposersData* _data_;
	ApplicationController* _tmp0_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	_data_ = g_slice_new0 (ApplicationControllerProcessPendingComposersData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_process_pending_composers_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	application_controller_process_pending_composers_co (_data_);
}

void
application_controller_process_pending_composers_finish (ApplicationController* self,
                                                         GAsyncResult* _res_)
{
	ApplicationControllerProcessPendingComposersData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/** Opens any pending composers. */
static void
application_controller_process_pending_composers_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_)
{
	ApplicationControllerProcessPendingComposersData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_process_pending_composers_co (_data_);
}

static gboolean
application_controller_process_pending_composers_co (ApplicationControllerProcessPendingComposersData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->pending_mailtos;
		_data_->_mailto_list = _data_->_tmp0_;
		_data_->_tmp1_ = _data_->_mailto_list;
		_data_->_tmp2_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp1_, GEE_TYPE_COLLECTION, GeeCollection));
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_mailto_size = _data_->_tmp3_;
		_data_->_mailto_index = -1;
		while (TRUE) {
			_data_->_mailto_index = _data_->_mailto_index + 1;
			_data_->_tmp4_ = _data_->_mailto_index;
			_data_->_tmp5_ = _data_->_mailto_size;
			if (!(_data_->_tmp4_ < _data_->_tmp5_)) {
				break;
			}
			_data_->_tmp6_ = _data_->_mailto_list;
			_data_->_tmp7_ = gee_list_get (_data_->_tmp6_, _data_->_mailto_index);
			_data_->mailto = (gchar*) _data_->_tmp7_;
			_data_->_tmp8_ = _data_->mailto;
			_data_->_state_ = 1;
			application_controller_compose_mailto (_data_->self, _data_->_tmp8_, application_controller_process_pending_composers_ready, _data_);
			return FALSE;
			_state_1:
			application_controller_compose_mailto_finish (_data_->self, _data_->_res_);
			_g_free0 (_data_->mailto);
		}
	}
	_data_->_tmp9_ = _data_->self->priv->pending_mailtos;
	gee_collection_clear (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp9_, GEE_TYPE_COLLECTION, GeeCollection));
	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
application_controller_real_send_composed_email_data_free (gpointer _data)
{
	ApplicationControllerSendComposedEmailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->composer);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerSendComposedEmailData, _data_);
}

static void
application_controller_real_send_composed_email (ComposerApplicationInterface* base,
                                                 ComposerWidget* composer,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_)
{
	ApplicationController * self;
	ApplicationControllerSendComposedEmailData* _data_;
	ApplicationController* _tmp0_;
	ComposerWidget* _tmp1_;
	g_return_if_fail (COMPOSER_IS_WIDGET (composer));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	_data_ = g_slice_new0 (ApplicationControllerSendComposedEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_real_send_composed_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (composer);
	_g_object_unref0 (_data_->composer);
	_data_->composer = _tmp1_;
	application_controller_real_send_composed_email_co (_data_);
}

static void
application_controller_send_composed_email_finish (ComposerApplicationInterface* base,
                                                   GAsyncResult* _res_)
{
	ApplicationControllerSendComposedEmailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/** Queues the email in a composer for delivery. */
static void
application_controller_send_composed_email_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_)
{
	ApplicationControllerSendComposedEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_real_send_composed_email_co (_data_);
}

static gboolean
application_controller_real_send_composed_email_co (ApplicationControllerSendComposedEmailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = composer_widget_get_sender_context (_data_->composer);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = _g_object_ref0 (_data_->_tmp1_);
	_data_->context = _data_->_tmp2_;
	{
		_data_->_tmp3_ = application_account_context_get_commands (_data_->context);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = _data_->self->priv->_application;
		_data_->_tmp6_ = application_send_composer_command_new (_data_->_tmp5_, _data_->context, _data_->composer);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = application_account_context_get_cancellable (_data_->context);
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp4_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, APPLICATION_TYPE_COMMAND, ApplicationCommand), _data_->_tmp9_, application_controller_send_composed_email_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp7_);
		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_->_tmp10_ = _data_->err;
		_data_->_tmp11_ = geary_problem_report_new (_data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp12_);
		_g_object_unref0 (_data_->_tmp12_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->context);
		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_->context);
	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
application_controller_real_save_composed_email_data_free (gpointer _data)
{
	ApplicationControllerSaveComposedEmailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->composer);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerSaveComposedEmailData, _data_);
}

static void
application_controller_real_save_composed_email (ComposerApplicationInterface* base,
                                                 ComposerWidget* composer,
                                                 GAsyncReadyCallback _callback_,
                                                 gpointer _user_data_)
{
	ApplicationController * self;
	ApplicationControllerSaveComposedEmailData* _data_;
	ApplicationController* _tmp0_;
	ComposerWidget* _tmp1_;
	g_return_if_fail (COMPOSER_IS_WIDGET (composer));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	_data_ = g_slice_new0 (ApplicationControllerSaveComposedEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_real_save_composed_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (composer);
	_g_object_unref0 (_data_->composer);
	_data_->composer = _tmp1_;
	application_controller_real_save_composed_email_co (_data_);
}

static void
application_controller_save_composed_email_finish (ComposerApplicationInterface* base,
                                                   GAsyncResult* _res_)
{
	ApplicationControllerSaveComposedEmailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/** Saves the email in a composer as a draft on the server. */
static void
application_controller_save_composed_email_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_)
{
	ApplicationControllerSaveComposedEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_real_save_composed_email_co (_data_);
}

static gboolean
application_controller_real_save_composed_email_co (ApplicationControllerSaveComposedEmailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = composer_widget_get_sender_context (_data_->composer);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = _g_object_ref0 (_data_->_tmp1_);
	_data_->context = _data_->_tmp2_;
	{
		_data_->_tmp3_ = application_account_context_get_commands (_data_->context);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = application_save_composer_command_new (_data_->self, _data_->composer);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = application_account_context_get_cancellable (_data_->context);
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp4_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, APPLICATION_TYPE_COMMAND, ApplicationCommand), _data_->_tmp8_, application_controller_save_composed_email_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp6_);
		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;
		_data_->_tmp10_ = geary_problem_report_new (_data_->_tmp9_);
		_data_->_tmp11_ = _data_->_tmp10_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp11_);
		_g_object_unref0 (_data_->_tmp11_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->context);
		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_->context);
	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
application_controller_real_discard_composed_email_data_free (gpointer _data)
{
	ApplicationControllerDiscardComposedEmailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->composer);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerDiscardComposedEmailData, _data_);
}

static void
application_controller_real_discard_composed_email (ComposerApplicationInterface* base,
                                                    ComposerWidget* composer,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	ApplicationController * self;
	ApplicationControllerDiscardComposedEmailData* _data_;
	ApplicationController* _tmp0_;
	ComposerWidget* _tmp1_;
	g_return_if_fail (COMPOSER_IS_WIDGET (composer));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	_data_ = g_slice_new0 (ApplicationControllerDiscardComposedEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_real_discard_composed_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (composer);
	_g_object_unref0 (_data_->composer);
	_data_->composer = _tmp1_;
	application_controller_real_discard_composed_email_co (_data_);
}

static void
application_controller_discard_composed_email_finish (ComposerApplicationInterface* base,
                                                      GAsyncResult* _res_)
{
	ApplicationControllerDiscardComposedEmailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/** Queues a composer to be discarded. */
static void
application_controller_discard_composed_email_ready (GObject* source_object,
                                                     GAsyncResult* _res_,
                                                     gpointer _user_data_)
{
	ApplicationControllerDiscardComposedEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_real_discard_composed_email_co (_data_);
}

static gboolean
application_controller_real_discard_composed_email_co (ApplicationControllerDiscardComposedEmailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = composer_widget_get_sender_context (_data_->composer);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = _g_object_ref0 (_data_->_tmp1_);
	_data_->context = _data_->_tmp2_;
	{
		_data_->_tmp3_ = application_account_context_get_commands (_data_->context);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = application_discard_composer_command_new (_data_->self, _data_->composer);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = application_account_context_get_cancellable (_data_->context);
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_state_ = 1;
		application_command_stack_execute (_data_->_tmp4_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, APPLICATION_TYPE_COMMAND, ApplicationCommand), _data_->_tmp8_, application_controller_discard_composed_email_ready, _data_);
		return FALSE;
		_state_1:
		application_command_stack_execute_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp6_);
		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;
		_data_->_tmp10_ = geary_problem_report_new (_data_->_tmp9_);
		_data_->_tmp11_ = _data_->_tmp10_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp11_);
		_g_object_unref0 (_data_->_tmp11_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->context);
		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_->context);
	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
application_controller_expunge_accounts_data_free (gpointer _data)
{
	ApplicationControllerExpungeAccountsData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerExpungeAccountsData, _data_);
}

void
application_controller_expunge_accounts (ApplicationController* self,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_)
{
	ApplicationControllerExpungeAccountsData* _data_;
	ApplicationController* _tmp0_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	_data_ = g_slice_new0 (ApplicationControllerExpungeAccountsData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_expunge_accounts_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	application_controller_expunge_accounts_co (_data_);
}

void
application_controller_expunge_accounts_finish (ApplicationController* self,
                                                GAsyncResult* _res_)
{
	ApplicationControllerExpungeAccountsData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

/** Expunges removed accounts while the controller remains open. */
static void
application_controller_expunge_accounts_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_)
{
	ApplicationControllerExpungeAccountsData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_expunge_accounts_co (_data_);
}

static gboolean
application_controller_expunge_accounts_co (ApplicationControllerExpungeAccountsData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->_account_manager;
		_data_->_tmp1_ = _data_->self->priv->controller_open;
		_data_->_state_ = 1;
		accounts_manager_expunge_accounts (_data_->_tmp0_, _data_->_tmp1_, application_controller_expunge_accounts_ready, _data_);
		return FALSE;
		_state_1:
		accounts_manager_expunge_accounts_finish (_data_->_tmp0_, _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_->_tmp2_ = _data_->err;
		_data_->_tmp3_ = geary_problem_report_new (_data_->_tmp2_);
		_data_->_tmp4_ = _data_->_tmp3_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp4_);
		_g_object_unref0 (_data_->_tmp4_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	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
application_controller_add_account (ApplicationController* self,
                                    GearyAccountInformation* added)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (added, GEARY_TYPE_ACCOUNT_INFORMATION));
	{
		ApplicationClient* _tmp0_;
		GearyEngine* _tmp1_;
		GearyEngine* _tmp2_;
		_tmp0_ = self->priv->_application;
		_tmp1_ = application_client_get_engine (_tmp0_);
		_tmp2_ = _tmp1_;
		geary_engine_add_account (_tmp2_, added, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (g_error_matches (_inner_error0_, GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_ALREADY_EXISTS)) {
				goto __catch0_geary_engine_error_already_exists;
			}
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_geary_engine_error_already_exists:
	{
		g_clear_error (&_inner_error0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* err = NULL;
		GError* _tmp3_;
		GearyAccountProblemReport* _tmp4_;
		GearyAccountProblemReport* _tmp5_;
		err = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = err;
		_tmp4_ = geary_account_problem_report_new (added, _tmp3_);
		_tmp5_ = _tmp4_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEARY_TYPE_PROBLEM_REPORT, GearyProblemReport));
		_g_object_unref0 (_tmp5_);
		_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
application_controller_open_account_data_free (gpointer _data)
{
	ApplicationControllerOpenAccountData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerOpenAccountData, _data_);
}

static void
application_controller_open_account (ApplicationController* self,
                                     GearyAccount* account,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	ApplicationControllerOpenAccountData* _data_;
	ApplicationController* _tmp0_;
	GearyAccount* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT));
	_data_ = g_slice_new0 (ApplicationControllerOpenAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_open_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	application_controller_open_account_co (_data_);
}

static void
application_controller_open_account_finish (ApplicationController* self,
                                            GAsyncResult* _res_)
{
	ApplicationControllerOpenAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
_application_controller_on_authentication_failure_geary_account_information_authentication_failure (GearyAccountInformation* _sender,
                                                                                                    GearyServiceInformation* service,
                                                                                                    gpointer self)
{
	application_controller_on_authentication_failure ((ApplicationController*) self, _sender, service);
}

static void
_application_controller_on_untrusted_host_geary_account_information_untrusted_host (GearyAccountInformation* _sender,
                                                                                    GearyServiceInformation* service,
                                                                                    GearyEndpoint* endpoint,
                                                                                    GTlsConnection* cx,
                                                                                    gpointer self)
{
	application_controller_on_untrusted_host ((ApplicationController*) self, _sender, service, endpoint, cx);
}

static void
_application_controller_on_account_status_notify_g_object_notify (GObject* _sender,
                                                                  GParamSpec* pspec,
                                                                  gpointer self)
{
	application_controller_on_account_status_notify ((ApplicationController*) self);
}

static void
_application_controller_on_folders_available_unavailable_geary_account_folders_available_unavailable (GearyAccount* _sender,
                                                                                                      GeeBidirSortedSet* available,
                                                                                                      GeeBidirSortedSet* unavailable,
                                                                                                      gpointer self)
{
	application_controller_on_folders_available_unavailable ((ApplicationController*) self, _sender, available, unavailable);
}

static void
_application_controller_on_report_problem_geary_account_report_problem (GearyAccount* _sender,
                                                                        GearyProblemReport* problem,
                                                                        gpointer self)
{
	application_controller_on_report_problem ((ApplicationController*) self, problem);
}

static void
_application_controller_on_sent_geary_smtp_client_service_email_sent (GearySmtpClientService* _sender,
                                                                      GearyEmail* email,
                                                                      gpointer self)
{
	application_controller_on_sent ((ApplicationController*) self, _sender, email);
}

static void
application_controller_open_account_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	ApplicationControllerOpenAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_open_account_co (_data_);
}

static gboolean
application_controller_open_account_co (ApplicationControllerOpenAccountData* _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_local_folder_root (_data_->account);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = geary_app_search_folder_new (_data_->account, _data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = geary_app_email_store_new (_data_->account);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = _data_->self->priv->folks;
	_data_->_tmp7_ = application_contact_store_new (_data_->account, _data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = application_account_context_new (_data_->account, _data_->_tmp3_, _data_->_tmp5_, _data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	_g_object_unref0 (_data_->_tmp8_);
	_g_object_unref0 (_data_->_tmp5_);
	_g_object_unref0 (_data_->_tmp3_);
	_data_->context = _data_->_tmp10_;
	_data_->_tmp11_ = _data_->self->priv->accounts;
	_data_->_tmp12_ = geary_account_get_information (_data_->account);
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_tmp14_ = _data_->context;
	gee_map_set (_data_->_tmp11_, _data_->_tmp13_, _data_->_tmp14_);
	_data_->_tmp15_ = _data_->self->priv->database_manager;
	_data_->_tmp16_ = _data_->self->priv->controller_open;
	application_database_manager_add_account (_data_->_tmp15_, _data_->account, _data_->_tmp16_);
	_data_->_tmp17_ = geary_account_get_information (_data_->account);
	_data_->_tmp18_ = _data_->_tmp17_;
	g_signal_connect_object (_data_->_tmp18_, "authentication-failure", (GCallback) _application_controller_on_authentication_failure_geary_account_information_authentication_failure, _data_->self, 0);
	_data_->_tmp19_ = geary_account_get_information (_data_->account);
	_data_->_tmp20_ = _data_->_tmp19_;
	g_signal_connect_object (_data_->_tmp20_, "untrusted-host", (GCallback) _application_controller_on_untrusted_host_geary_account_information_untrusted_host, _data_->self, 0);
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_data_->account, G_TYPE_OBJECT, GObject), "notify::current-status", (GCallback) _application_controller_on_account_status_notify_g_object_notify, _data_->self, 0);
	g_signal_connect_object (_data_->account, "folders-available-unavailable", (GCallback) _application_controller_on_folders_available_unavailable_geary_account_folders_available_unavailable, _data_->self, 0);
	g_signal_connect_object (_data_->account, "report-problem", (GCallback) _application_controller_on_report_problem_geary_account_report_problem, _data_->self, 0);
	_data_->_tmp21_ = geary_account_get_outgoing (_data_->account);
	_data_->_tmp22_ = _data_->_tmp21_;
	_data_->_tmp23_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp22_, GEARY_SMTP_TYPE_CLIENT_SERVICE) ? ((GearySmtpClientService*) _data_->_tmp22_) : NULL);
	_data_->smtp = _data_->_tmp23_;
	_data_->_tmp24_ = _data_->smtp;
	if (_data_->_tmp24_ != NULL) {
		_data_->_tmp25_ = _data_->smtp;
		g_signal_connect_object (_data_->_tmp25_, "email-sent", (GCallback) _application_controller_on_sent_geary_smtp_client_service_email_sent, _data_->self, 0);
	}
	_data_->_tmp26_ = _data_->context;
	g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_ACCOUNT_INTERFACE, ApplicationAccountInterface), "account-available", _data_->_tmp26_, _data_->self->priv->is_loading_accounts);
	_data_->retry = FALSE;
	{
		_data_->_tmp27_ = TRUE;
		while (TRUE) {
			if (!_data_->_tmp27_) {
				if (!_data_->retry) {
					break;
				}
			}
			_data_->_tmp27_ = FALSE;
			{
				_data_->_tmp28_ = _data_->self->priv->controller_open;
				_data_->_state_ = 1;
				geary_account_open_async (_data_->account, _data_->_tmp28_, application_controller_open_account_ready, _data_);
				return FALSE;
				_state_1:
				geary_account_open_finish (_data_->account, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_data_->retry = FALSE;
			}
			goto __finally0;
			__catch0_g_error:
			{
				_data_->open_err = _data_->_inner_error0_;
				_data_->_inner_error0_ = NULL;
				_data_->_tmp29_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->account, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
				_data_->_tmp30_ = _data_->_tmp29_;
				_data_->_tmp31_ = _data_->open_err;
				_data_->_tmp32_ = _data_->_tmp31_->message;
				g_debug ("application-controller.vala:1018: Unable to open account %s: %s", _data_->_tmp30_, _data_->_tmp32_);
				_g_free0 (_data_->_tmp30_);
				_data_->_tmp33_ = _data_->open_err;
				if (g_error_matches (_data_->_tmp33_, GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_CORRUPT)) {
					_data_->_state_ = 2;
					application_controller_account_database_error_async (_data_->self, _data_->account, application_controller_open_account_ready, _data_);
					return FALSE;
					_state_2:
					_data_->retry = application_controller_account_database_error_finish (_data_->self, _data_->_res_);
				}
				if (!_data_->retry) {
					_data_->_tmp34_ = geary_account_get_information (_data_->account);
					_data_->_tmp35_ = _data_->_tmp34_;
					_data_->_tmp36_ = _data_->open_err;
					_data_->_tmp37_ = geary_account_problem_report_new (_data_->_tmp35_, _data_->_tmp36_);
					_data_->_tmp38_ = _data_->_tmp37_;
					composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp38_, GEARY_TYPE_PROBLEM_REPORT, GearyProblemReport));
					_g_object_unref0 (_data_->_tmp38_);
					_data_->_tmp39_ = _data_->self->priv->_account_manager;
					_data_->_tmp40_ = geary_account_get_information (_data_->account);
					_data_->_tmp41_ = _data_->_tmp40_;
					accounts_manager_disable_account (_data_->_tmp39_, _data_->_tmp41_);
					_data_->_tmp42_ = _data_->self->priv->accounts;
					_data_->_tmp43_ = geary_account_get_information (_data_->account);
					_data_->_tmp44_ = _data_->_tmp43_;
					gee_map_unset (_data_->_tmp42_, _data_->_tmp44_, NULL);
				}
				_g_error_free0 (_data_->open_err);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->smtp);
				_g_object_unref0 (_data_->context);
				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;
			}
		}
	}
	application_controller_update_account_status (_data_->self);
	_g_object_unref0 (_data_->smtp);
	_g_object_unref0 (_data_->context);
	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
application_controller_remove_account_data_free (gpointer _data)
{
	ApplicationControllerRemoveAccountData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->removed);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerRemoveAccountData, _data_);
}

static void
application_controller_remove_account (ApplicationController* self,
                                       GearyAccountInformation* removed,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_)
{
	ApplicationControllerRemoveAccountData* _data_;
	ApplicationController* _tmp0_;
	GearyAccountInformation* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEARY_TYPE_ACCOUNT_INFORMATION));
	_data_ = g_slice_new0 (ApplicationControllerRemoveAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_remove_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (removed);
	_g_object_unref0 (_data_->removed);
	_data_->removed = _tmp1_;
	application_controller_remove_account_co (_data_);
}

static void
application_controller_remove_account_finish (ApplicationController* self,
                                              GAsyncResult* _res_)
{
	ApplicationControllerRemoveAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
application_controller_remove_account_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_)
{
	ApplicationControllerRemoveAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_remove_account_co (_data_);
}

static gboolean
application_controller_remove_account_co (ApplicationControllerRemoveAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_state_ = 1;
	application_controller_close_account (_data_->self, _data_->removed, FALSE, application_controller_remove_account_ready, _data_);
	return FALSE;
	_state_1:
	application_controller_close_account_finish (_data_->self, _data_->_res_);
	{
		_data_->_tmp0_ = _data_->self->priv->_application;
		_data_->_tmp1_ = application_client_get_engine (_data_->_tmp0_);
		_data_->_tmp2_ = _data_->_tmp1_;
		geary_engine_remove_account (_data_->_tmp2_, _data_->removed, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND)) {
				goto __catch0_geary_engine_error_not_found;
			}
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_geary_engine_error_not_found:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp3_ = _data_->err;
		_data_->_tmp4_ = geary_account_problem_report_new (_data_->removed, _data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEARY_TYPE_PROBLEM_REPORT, GearyProblemReport));
		_g_object_unref0 (_data_->_tmp5_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	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
application_controller_close_account_data_free (gpointer _data)
{
	ApplicationControllerCloseAccountData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->config);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerCloseAccountData, _data_);
}

static void
application_controller_close_account (ApplicationController* self,
                                      GearyAccountInformation* config,
                                      gboolean is_shutdown,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	ApplicationControllerCloseAccountData* _data_;
	ApplicationController* _tmp0_;
	GearyAccountInformation* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (config, GEARY_TYPE_ACCOUNT_INFORMATION));
	_data_ = g_slice_new0 (ApplicationControllerCloseAccountData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_close_account_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (config);
	_g_object_unref0 (_data_->config);
	_data_->config = _tmp1_;
	_data_->is_shutdown = is_shutdown;
	application_controller_close_account_co (_data_);
}

static void
application_controller_close_account_finish (ApplicationController* self,
                                             GAsyncResult* _res_)
{
	ApplicationControllerCloseAccountData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
application_controller_close_account_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	ApplicationControllerCloseAccountData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_close_account_co (_data_);
}

static gboolean
application_controller_close_account_co (ApplicationControllerCloseAccountData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->accounts;
	_data_->_tmp1_ = gee_map_get (_data_->_tmp0_, _data_->config);
	_data_->context = (ApplicationAccountContext*) _data_->_tmp1_;
	_data_->_tmp2_ = _data_->context;
	if (_data_->_tmp2_ != NULL) {
		_data_->_tmp3_ = _data_->context;
		_data_->_tmp4_ = application_account_context_get_account (_data_->_tmp3_);
		_data_->_tmp5_ = _data_->_tmp4_;
		_data_->_tmp6_ = geary_account_get_information (_data_->_tmp5_);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = geary_account_information_get_id (_data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		g_debug ("application-controller.vala:1058: Closing account: %s", _data_->_tmp9_);
		_data_->_tmp10_ = _data_->context;
		_data_->_tmp11_ = application_account_context_get_account (_data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp13_ = _g_object_ref0 (_data_->_tmp12_);
		_data_->account = _data_->_tmp13_;
		_data_->_tmp14_ = _data_->context;
		g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_ACCOUNT_INTERFACE, ApplicationAccountInterface), "account-unavailable", _data_->_tmp14_, _data_->is_shutdown);
		_data_->_tmp15_ = _data_->self->priv->accounts;
		_data_->_tmp16_ = _data_->account;
		_data_->_tmp17_ = geary_account_get_information (_data_->_tmp16_);
		_data_->_tmp18_ = _data_->_tmp17_;
		gee_map_unset (_data_->_tmp15_, _data_->_tmp18_, NULL);
		_data_->_tmp19_ = _data_->self->priv->database_manager;
		_data_->_tmp20_ = _data_->account;
		application_database_manager_remove_account (_data_->_tmp19_, _data_->_tmp20_);
		_data_->_tmp21_ = _data_->account;
		g_signal_parse_name ("report-problem", GEARY_TYPE_ACCOUNT, &_data_->_tmp22_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_data_->_tmp21_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp22_, 0, NULL, (GCallback) _application_controller_on_report_problem_geary_account_report_problem, _data_->self);
		_data_->_tmp23_ = _data_->account;
		_data_->_tmp24_ = geary_account_get_information (_data_->_tmp23_);
		_data_->_tmp25_ = _data_->_tmp24_;
		g_signal_parse_name ("authentication-failure", GEARY_TYPE_ACCOUNT_INFORMATION, &_data_->_tmp26_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_data_->_tmp25_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp26_, 0, NULL, (GCallback) _application_controller_on_authentication_failure_geary_account_information_authentication_failure, _data_->self);
		_data_->_tmp27_ = _data_->account;
		_data_->_tmp28_ = geary_account_get_information (_data_->_tmp27_);
		_data_->_tmp29_ = _data_->_tmp28_;
		g_signal_parse_name ("untrusted-host", GEARY_TYPE_ACCOUNT_INFORMATION, &_data_->_tmp30_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_data_->_tmp29_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp30_, 0, NULL, (GCallback) _application_controller_on_untrusted_host_geary_account_information_untrusted_host, _data_->self);
		_data_->_tmp31_ = _data_->account;
		g_signal_parse_name ("notify::current-status", G_TYPE_OBJECT, &_data_->_tmp32_, &_data_->_tmp33_, TRUE);
		g_signal_handlers_disconnect_matched (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp31_, G_TYPE_OBJECT, GObject), G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_DETAIL | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp32_, _data_->_tmp33_, NULL, (GCallback) _application_controller_on_account_status_notify_g_object_notify, _data_->self);
		_data_->_tmp34_ = _data_->account;
		g_signal_parse_name ("folders-available-unavailable", GEARY_TYPE_ACCOUNT, &_data_->_tmp35_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_data_->_tmp34_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp35_, 0, NULL, (GCallback) _application_controller_on_folders_available_unavailable_geary_account_folders_available_unavailable, _data_->self);
		_data_->_tmp36_ = _data_->account;
		_data_->_tmp37_ = geary_account_get_outgoing (_data_->_tmp36_);
		_data_->_tmp38_ = _data_->_tmp37_;
		_data_->_tmp39_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp38_, GEARY_SMTP_TYPE_CLIENT_SERVICE) ? ((GearySmtpClientService*) _data_->_tmp38_) : NULL);
		_data_->smtp = _data_->_tmp39_;
		_data_->_tmp40_ = _data_->smtp;
		if (_data_->_tmp40_ != NULL) {
			_data_->_tmp41_ = _data_->smtp;
			g_signal_parse_name ("email-sent", GEARY_SMTP_TYPE_CLIENT_SERVICE, &_data_->_tmp42_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_data_->_tmp41_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp42_, 0, NULL, (GCallback) _application_controller_on_sent_geary_smtp_client_service_email_sent, _data_->self);
		}
		application_controller_update_account_status (_data_->self);
		_data_->_tmp43_ = _data_->context;
		_data_->_tmp44_ = _data_->_tmp43_->search;
		geary_app_search_folder_clear_query (_data_->_tmp44_);
		_data_->_tmp45_ = _data_->context;
		_data_->_tmp46_ = application_account_context_get_contacts (_data_->_tmp45_);
		_data_->_tmp47_ = _data_->_tmp46_;
		application_contact_store_close (_data_->_tmp47_);
		_data_->_tmp48_ = _data_->context;
		_data_->_tmp49_ = application_account_context_get_cancellable (_data_->_tmp48_);
		_data_->_tmp50_ = _data_->_tmp49_;
		g_cancellable_cancel (_data_->_tmp50_);
		_data_->_tmp51_ = _data_->context;
		_data_->_tmp52_ = _data_->_tmp51_->inbox;
		_data_->_tmp53_ = _g_object_ref0 (_data_->_tmp52_);
		_data_->inbox = _data_->_tmp53_;
		_data_->_tmp54_ = _data_->inbox;
		if (_data_->_tmp54_ != NULL) {
			{
				_data_->_tmp55_ = _data_->inbox;
				_data_->_state_ = 1;
				geary_folder_close_async (_data_->_tmp55_, NULL, application_controller_close_account_ready, _data_);
				return FALSE;
				_state_1:
				geary_folder_close_finish (_data_->_tmp55_, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
			}
			goto __finally0;
			__catch0_g_error:
			{
				_data_->close_inbox_err = _data_->_inner_error0_;
				_data_->_inner_error0_ = NULL;
				_data_->_tmp56_ = _data_->close_inbox_err;
				_data_->_tmp57_ = _data_->_tmp56_->message;
				g_debug ("application-controller.vala:1103: Unable to close monitored inbox: %s", _data_->_tmp57_);
				_g_error_free0 (_data_->close_inbox_err);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->inbox);
				_g_object_unref0 (_data_->smtp);
				_g_object_unref0 (_data_->account);
				_g_object_unref0 (_data_->context);
				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_->_tmp58_ = _data_->context;
			_g_object_unref0 (_data_->_tmp58_->inbox);
			_data_->_tmp58_->inbox = NULL;
		}
		{
			_data_->_tmp59_ = _data_->account;
			_data_->_state_ = 2;
			geary_account_close_async (_data_->_tmp59_, NULL, application_controller_close_account_ready, _data_);
			return FALSE;
			_state_2:
			geary_account_close_finish (_data_->_tmp59_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
		}
		goto __finally1;
		__catch1_g_error:
		{
			_data_->close_err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp60_ = _data_->account;
			_data_->_tmp61_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp60_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
			_data_->_tmp62_ = _data_->_tmp61_;
			_data_->_tmp63_ = _data_->close_err;
			_data_->_tmp64_ = _data_->_tmp63_->message;
			g_debug ("application-controller.vala:1111: Unable to close account %s: %s", _data_->_tmp62_, _data_->_tmp64_);
			_g_free0 (_data_->_tmp62_);
			_g_error_free0 (_data_->close_err);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->inbox);
			_g_object_unref0 (_data_->smtp);
			_g_object_unref0 (_data_->account);
			_g_object_unref0 (_data_->context);
			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_->_tmp65_ = _data_->account;
		_data_->_tmp66_ = geary_logging_source_to_string (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp65_, GEARY_LOGGING_TYPE_SOURCE, GearyLoggingSource));
		_data_->_tmp67_ = _data_->_tmp66_;
		g_debug ("application-controller.vala:1114: Account closed: %s", _data_->_tmp67_);
		_g_free0 (_data_->_tmp67_);
		_g_object_unref0 (_data_->inbox);
		_g_object_unref0 (_data_->smtp);
		_g_object_unref0 (_data_->account);
	}
	_g_object_unref0 (_data_->context);
	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
application_controller_update_account_status (ApplicationController* self)
{
	GearyAccountStatus effective_status = 0U;
	gboolean has_auth_error = FALSE;
	gboolean has_cert_error = FALSE;
	GearyAccount* service_problem_source = NULL;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	effective_status = GEARY_ACCOUNT_STATUS_ONLINE;
	has_auth_error = FALSE;
	has_cert_error = FALSE;
	service_problem_source = NULL;
	{
		GeeIterator* _context_it = NULL;
		GeeMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->accounts;
		_tmp1_ = gee_map_get_values (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_context_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			ApplicationAccountContext* context = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GearyAccountStatus status = 0U;
			ApplicationAccountContext* _tmp9_;
			ApplicationAccountContext* _tmp15_;
			gboolean _tmp16_;
			gboolean _tmp17_;
			ApplicationAccountContext* _tmp18_;
			gboolean _tmp19_;
			gboolean _tmp20_;
			_tmp6_ = _context_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _context_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			context = (ApplicationAccountContext*) _tmp8_;
			_tmp9_ = context;
			status = application_account_context_get_effective_status (_tmp9_);
			if (!geary_account_status_is_online (status)) {
				effective_status &= ~GEARY_ACCOUNT_STATUS_ONLINE;
			}
			if (geary_account_status_has_service_problem (status)) {
				GearyAccount* _tmp10_;
				effective_status |= GEARY_ACCOUNT_STATUS_SERVICE_PROBLEM;
				_tmp10_ = service_problem_source;
				if (_tmp10_ == NULL) {
					ApplicationAccountContext* _tmp11_;
					GearyAccount* _tmp12_;
					GearyAccount* _tmp13_;
					GearyAccount* _tmp14_;
					_tmp11_ = context;
					_tmp12_ = application_account_context_get_account (_tmp11_);
					_tmp13_ = _tmp12_;
					_tmp14_ = _g_object_ref0 (_tmp13_);
					_g_object_unref0 (service_problem_source);
					service_problem_source = _tmp14_;
				}
			}
			_tmp15_ = context;
			_tmp16_ = application_account_context_get_authentication_failed (_tmp15_);
			_tmp17_ = _tmp16_;
			has_auth_error |= _tmp17_;
			_tmp18_ = context;
			_tmp19_ = application_account_context_get_tls_validation_failed (_tmp18_);
			_tmp20_ = _tmp19_;
			has_cert_error |= _tmp20_;
			_g_object_unref0 (context);
		}
		_g_object_unref0 (_context_it);
	}
	{
		GeeIterator* _window_it = NULL;
		ApplicationClient* _tmp21_;
		GeeCollection* _tmp22_;
		GeeCollection* _tmp23_;
		GeeIterator* _tmp24_;
		GeeIterator* _tmp25_;
		_tmp21_ = self->priv->_application;
		_tmp22_ = application_client_get_main_windows (_tmp21_);
		_tmp23_ = _tmp22_;
		_tmp24_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp25_ = _tmp24_;
		_g_object_unref0 (_tmp23_);
		_window_it = _tmp25_;
		while (TRUE) {
			GeeIterator* _tmp26_;
			ApplicationMainWindow* window = NULL;
			GeeIterator* _tmp27_;
			gpointer _tmp28_;
			ApplicationMainWindow* _tmp29_;
			GearyAccount* _tmp30_;
			_tmp26_ = _window_it;
			if (!gee_iterator_next (_tmp26_)) {
				break;
			}
			_tmp27_ = _window_it;
			_tmp28_ = gee_iterator_get (_tmp27_);
			window = (ApplicationMainWindow*) _tmp28_;
			_tmp29_ = window;
			_tmp30_ = service_problem_source;
			application_main_window_update_account_status (_tmp29_, effective_status, has_auth_error, has_cert_error, _tmp30_);
			_g_object_unref0 (window);
		}
		_g_object_unref0 (_window_it);
	}
	_g_object_unref0 (service_problem_source);
}

static gboolean
__lambda151_ (ApplicationController* self,
              ApplicationAccountContext* ctx,
              gboolean seed)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gboolean result;
	g_return_val_if_fail (APPLICATION_IS_ACCOUNT_CONTEXT (ctx), FALSE);
	_tmp0_ = application_account_context_get_authentication_prompting (ctx);
	_tmp1_ = _tmp0_;
	_tmp2_ = application_account_context_get_tls_validation_prompting (ctx);
	_tmp3_ = _tmp2_;
	result = (_tmp1_ | _tmp3_) | seed;
	_g_object_unref0 (ctx);
	return result;
}

static gpointer
___lambda151__gee_fold_func (gpointer g,
                             gpointer a,
                             gpointer self)
{
	gpointer result;
	result = (gpointer) ((gintptr) __lambda151_ ((ApplicationController*) self, (ApplicationAccountContext*) g, (gboolean) ((gintptr) a)));
	return result;
}

static gboolean
application_controller_is_currently_prompting (ApplicationController* self)
{
	GeeMap* _tmp0_;
	GeeCollection* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	gpointer _tmp4_;
	gboolean _tmp5_;
	gboolean result;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), FALSE);
	_tmp0_ = self->priv->accounts;
	_tmp1_ = gee_map_get_values (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = gee_traversable_fold (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_TRAVERSABLE, GeeTraversable), G_TYPE_BOOLEAN, NULL, NULL, ___lambda151__gee_fold_func, self, (gpointer) ((gintptr) FALSE));
	_tmp5_ = (gboolean) ((gintptr) _tmp4_);
	_g_object_unref0 (_tmp3_);
	result = _tmp5_;
	return result;
}

static void
application_controller_prompt_for_password_data_free (gpointer _data)
{
	ApplicationControllerPromptForPasswordData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->context);
	_g_object_unref0 (_data_->service);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerPromptForPasswordData, _data_);
}

static void
application_controller_prompt_for_password (ApplicationController* self,
                                            ApplicationAccountContext* context,
                                            GearyServiceInformation* service,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	ApplicationControllerPromptForPasswordData* _data_;
	ApplicationController* _tmp0_;
	ApplicationAccountContext* _tmp1_;
	GearyServiceInformation* _tmp2_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (APPLICATION_IS_ACCOUNT_CONTEXT (context));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (service, GEARY_TYPE_SERVICE_INFORMATION));
	_data_ = g_slice_new0 (ApplicationControllerPromptForPasswordData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_prompt_for_password_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (context);
	_g_object_unref0 (_data_->context);
	_data_->context = _tmp1_;
	_tmp2_ = _g_object_ref0 (service);
	_g_object_unref0 (_data_->service);
	_data_->service = _tmp2_;
	application_controller_prompt_for_password_co (_data_);
}

static void
application_controller_prompt_for_password_finish (ApplicationController* self,
                                                   GAsyncResult* _res_)
{
	ApplicationControllerPromptForPasswordData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
application_controller_prompt_for_password_ready (GObject* source_object,
                                                  GAsyncResult* _res_,
                                                  gpointer _user_data_)
{
	ApplicationControllerPromptForPasswordData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_prompt_for_password_co (_data_);
}

static gboolean
application_controller_prompt_for_password_co (ApplicationControllerPromptForPasswordData* _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:
	_data_->_tmp0_ = application_account_context_get_account (_data_->context);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = geary_account_get_information (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = _g_object_ref0 (_data_->_tmp3_);
	_data_->account = _data_->_tmp4_;
	_data_->_tmp5_ = _data_->account;
	_data_->_tmp6_ = geary_account_information_get_incoming (_data_->_tmp5_);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->is_incoming = _data_->service == _data_->_tmp7_;
	if (_data_->is_incoming) {
		_data_->_tmp9_ = _data_->account;
		_data_->_tmp10_ = geary_account_information_get_incoming (_data_->_tmp9_);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = geary_service_information_get_credentials (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = _g_object_ref0 (_data_->_tmp13_);
		_g_object_unref0 (_data_->_tmp8_);
		_data_->_tmp8_ = _data_->_tmp14_;
	} else {
		_data_->_tmp15_ = _data_->account;
		_data_->_tmp16_ = geary_account_information_get_outgoing_credentials (_data_->_tmp15_);
		_g_object_unref0 (_data_->_tmp8_);
		_data_->_tmp8_ = _data_->_tmp16_;
	}
	_data_->_tmp17_ = _data_->_tmp8_;
	_data_->_tmp8_ = NULL;
	_data_->credentials = _data_->_tmp17_;
	_data_->handled = TRUE;
	_data_->_tmp19_ = application_account_context_get_authentication_attempts (_data_->context);
	_data_->_tmp20_ = _data_->_tmp19_;
	if (_data_->_tmp20_ > APPLICATION_CONTROLLER_MAX_AUTH_ATTEMPTS) {
		_data_->_tmp18_ = TRUE;
	} else {
		_data_->_tmp21_ = _data_->credentials;
		_data_->_tmp18_ = _data_->_tmp21_ == NULL;
	}
	if (_data_->_tmp18_) {
		_data_->handled = FALSE;
	} else {
		_data_->_tmp22_ = _data_->self->priv->_account_manager;
		_data_->_tmp23_ = _data_->account;
		if (accounts_manager_is_goa_account (_data_->_tmp22_, _data_->_tmp23_)) {
			application_account_context_set_authentication_prompting (_data_->context, TRUE);
			{
				_data_->_tmp24_ = _data_->account;
				_data_->_tmp25_ = application_account_context_get_cancellable (_data_->context);
				_data_->_tmp26_ = _data_->_tmp25_;
				_data_->_state_ = 1;
				geary_account_information_load_incoming_credentials (_data_->_tmp24_, _data_->_tmp26_, application_controller_prompt_for_password_ready, _data_);
				return FALSE;
				_state_1:
				geary_account_information_load_incoming_credentials_finish (_data_->_tmp24_, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_data_->_tmp27_ = _data_->account;
				_data_->_tmp28_ = application_account_context_get_cancellable (_data_->context);
				_data_->_tmp29_ = _data_->_tmp28_;
				_data_->_state_ = 2;
				geary_account_information_load_outgoing_credentials (_data_->_tmp27_, _data_->_tmp29_, application_controller_prompt_for_password_ready, _data_);
				return FALSE;
				_state_2:
				geary_account_information_load_outgoing_credentials_finish (_data_->_tmp27_, _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_->handled = FALSE;
				_data_->_tmp30_ = _data_->account;
				_data_->_tmp31_ = _data_->err;
				_data_->_tmp32_ = geary_account_problem_report_new (_data_->_tmp30_, _data_->_tmp31_);
				_data_->_tmp33_ = _data_->_tmp32_;
				composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp33_, GEARY_TYPE_PROBLEM_REPORT, GearyProblemReport));
				_g_object_unref0 (_data_->_tmp33_);
				_g_error_free0 (_data_->err);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->credentials);
				_g_object_unref0 (_data_->_tmp8_);
				_g_object_unref0 (_data_->account);
				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;
			}
			application_account_context_set_authentication_prompting (_data_->context, FALSE);
		} else {
			application_account_context_set_authentication_prompting (_data_->context, TRUE);
			_data_->_tmp34_ = _data_->self->priv->_application;
			_data_->_tmp35_ = gtk_application_get_active_window (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp34_, gtk_application_get_type (), GtkApplication));
			_data_->_tmp36_ = _data_->account;
			_data_->_tmp37_ = _data_->credentials;
			_data_->_tmp38_ = password_dialog_new (_data_->_tmp35_, _data_->_tmp36_, _data_->service, _data_->_tmp37_);
			_data_->password_dialog = _data_->_tmp38_;
			_data_->_tmp39_ = _data_->password_dialog;
			if (password_dialog_run (_data_->_tmp39_)) {
				_data_->_tmp41_ = _data_->credentials;
				_data_->_tmp42_ = _data_->account;
				_data_->_tmp43_ = geary_account_information_get_incoming (_data_->_tmp42_);
				_data_->_tmp44_ = _data_->_tmp43_;
				_data_->_tmp45_ = geary_service_information_get_credentials (_data_->_tmp44_);
				_data_->_tmp46_ = _data_->_tmp45_;
				if (_data_->_tmp41_ == _data_->_tmp46_) {
					_data_->_tmp47_ = _data_->account;
					_data_->_tmp48_ = geary_account_information_get_incoming (_data_->_tmp47_);
					_data_->_tmp49_ = _data_->_tmp48_;
					_data_->_tmp40_ = _data_->_tmp49_;
				} else {
					_data_->_tmp50_ = _data_->account;
					_data_->_tmp51_ = geary_account_information_get_outgoing (_data_->_tmp50_);
					_data_->_tmp52_ = _data_->_tmp51_;
					_data_->_tmp40_ = _data_->_tmp52_;
				}
				_data_->_tmp53_ = _g_object_ref0 (_data_->_tmp40_);
				_data_->creds_service = _data_->_tmp53_;
				_data_->_tmp54_ = _data_->creds_service;
				_data_->_tmp55_ = _data_->credentials;
				_data_->_tmp56_ = _data_->password_dialog;
				_data_->_tmp57_ = password_dialog_get_password (_data_->_tmp56_);
				_data_->_tmp58_ = _data_->_tmp57_;
				_data_->_tmp59_ = geary_credentials_copy_with_token (_data_->_tmp55_, _data_->_tmp58_);
				_data_->_tmp60_ = _data_->_tmp59_;
				geary_service_information_set_credentials (_data_->_tmp54_, _data_->_tmp60_);
				_g_object_unref0 (_data_->_tmp60_);
				_data_->_tmp61_ = _data_->password_dialog;
				_data_->_tmp62_ = password_dialog_get_remember_password (_data_->_tmp61_);
				_data_->_tmp63_ = _data_->_tmp62_;
				_data_->remember = _data_->_tmp63_;
				_data_->_tmp64_ = _data_->creds_service;
				_data_->_tmp65_ = geary_service_information_get_remember_password (_data_->_tmp64_);
				_data_->_tmp66_ = _data_->_tmp65_;
				if (_data_->_tmp66_ != _data_->remember) {
					_data_->_tmp67_ = _data_->creds_service;
					geary_service_information_set_remember_password (_data_->_tmp67_, _data_->remember);
					_data_->_tmp68_ = _data_->account;
					g_signal_emit_by_name (_data_->_tmp68_, "changed");
				}
				_data_->_tmp69_ = _data_->account;
				_data_->_tmp70_ = geary_account_information_get_mediator (_data_->_tmp69_);
				_data_->_tmp71_ = _data_->_tmp70_;
				_data_->_tmp72_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp71_, TYPE_SECRET_MEDIATOR, SecretMediator));
				_data_->libsecret = _data_->_tmp72_;
				{
					_data_->_tmp73_ = _data_->creds_service;
					_data_->_tmp74_ = geary_service_information_get_remember_password (_data_->_tmp73_);
					_data_->_tmp75_ = _data_->_tmp74_;
					if (_data_->_tmp75_) {
						_data_->_tmp76_ = _data_->libsecret;
						_data_->_tmp77_ = _data_->account;
						_data_->_tmp78_ = _data_->creds_service;
						_data_->_tmp79_ = application_account_context_get_cancellable (_data_->context);
						_data_->_tmp80_ = _data_->_tmp79_;
						_data_->_state_ = 3;
						secret_mediator_update_token (_data_->_tmp76_, _data_->_tmp77_, _data_->_tmp78_, _data_->_tmp80_, application_controller_prompt_for_password_ready, _data_);
						return FALSE;
						_state_3:
						secret_mediator_update_token_finish (_data_->_tmp76_, _data_->_res_, &_data_->_inner_error0_);
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
								goto __catch1_g_io_error_cancelled;
							}
							goto __catch1_g_error;
						}
					} else {
						_data_->_tmp81_ = _data_->libsecret;
						_data_->_tmp82_ = _data_->account;
						_data_->_tmp83_ = _data_->creds_service;
						_data_->_tmp84_ = application_account_context_get_cancellable (_data_->context);
						_data_->_tmp85_ = _data_->_tmp84_;
						_data_->_state_ = 4;
						secret_mediator_clear_token (_data_->_tmp81_, _data_->_tmp82_, _data_->_tmp83_, _data_->_tmp85_, application_controller_prompt_for_password_ready, _data_);
						return FALSE;
						_state_4:
						secret_mediator_clear_token_finish (_data_->_tmp81_, _data_->_res_, &_data_->_inner_error0_);
						if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
							if (g_error_matches (_data_->_inner_error0_, G_IO_ERROR, G_IO_ERROR_CANCELLED)) {
								goto __catch1_g_io_error_cancelled;
							}
							goto __catch1_g_error;
						}
					}
				}
				goto __finally1;
				__catch1_g_io_error_cancelled:
				{
					g_clear_error (&_data_->_inner_error0_);
				}
				goto __finally1;
				__catch1_g_error:
				{
					_data_->_vala1_err = _data_->_inner_error0_;
					_data_->_inner_error0_ = NULL;
					_data_->_tmp86_ = _data_->account;
					_data_->_tmp87_ = _data_->_vala1_err;
					_data_->_tmp88_ = geary_service_problem_report_new (_data_->_tmp86_, _data_->service, _data_->_tmp87_);
					_data_->_tmp89_ = _data_->_tmp88_;
					composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp89_, GEARY_TYPE_PROBLEM_REPORT, GearyProblemReport));
					_g_object_unref0 (_data_->_tmp89_);
					_g_error_free0 (_data_->_vala1_err);
				}
				__finally1:
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->libsecret);
					_g_object_unref0 (_data_->creds_service);
					_password_dialog_unref0 (_data_->password_dialog);
					_g_object_unref0 (_data_->credentials);
					_g_object_unref0 (_data_->_tmp8_);
					_g_object_unref0 (_data_->account);
					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_->_tmp90_ = application_account_context_get_authentication_attempts (_data_->context);
				_data_->_tmp91_ = _data_->_tmp90_;
				application_account_context_set_authentication_attempts (_data_->context, _data_->_tmp91_ + 1);
				_g_object_unref0 (_data_->libsecret);
				_g_object_unref0 (_data_->creds_service);
			} else {
				_data_->handled = FALSE;
			}
			application_account_context_set_authentication_prompting (_data_->context, FALSE);
			_password_dialog_unref0 (_data_->password_dialog);
		}
	}
	if (_data_->handled) {
		{
			_data_->_tmp92_ = _data_->self->priv->_application;
			_data_->_tmp93_ = application_client_get_engine (_data_->_tmp92_);
			_data_->_tmp94_ = _data_->_tmp93_;
			_data_->_tmp95_ = _data_->account;
			_data_->_tmp96_ = application_account_context_get_cancellable (_data_->context);
			_data_->_tmp97_ = _data_->_tmp96_;
			_data_->_state_ = 5;
			geary_engine_update_account_service (_data_->_tmp94_, _data_->_tmp95_, _data_->service, _data_->_tmp97_, application_controller_prompt_for_password_ready, _data_);
			return FALSE;
			_state_5:
			geary_engine_update_account_service_finish (_data_->_tmp94_, _data_->_res_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch2_g_error;
			}
		}
		goto __finally2;
		__catch2_g_error:
		{
			_data_->_vala2_err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp98_ = _data_->account;
			_data_->_tmp99_ = _data_->_vala2_err;
			_data_->_tmp100_ = geary_service_problem_report_new (_data_->_tmp98_, _data_->service, _data_->_tmp99_);
			_data_->_tmp101_ = _data_->_tmp100_;
			composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp101_, GEARY_TYPE_PROBLEM_REPORT, GearyProblemReport));
			_g_object_unref0 (_data_->_tmp101_);
			_g_error_free0 (_data_->_vala2_err);
		}
		__finally2:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->credentials);
			_g_object_unref0 (_data_->_tmp8_);
			_g_object_unref0 (_data_->account);
			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;
		}
	} else {
		application_account_context_set_authentication_attempts (_data_->context, (guint) 0);
		application_account_context_set_authentication_failed (_data_->context, TRUE);
		application_controller_update_account_status (_data_->self);
	}
	_g_object_unref0 (_data_->credentials);
	_g_object_unref0 (_data_->_tmp8_);
	_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
application_controller_prompt_untrusted_host_data_free (gpointer _data)
{
	ApplicationControllerPromptUntrustedHostData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->context);
	_g_object_unref0 (_data_->service);
	_g_object_unref0 (_data_->endpoint);
	_g_object_unref0 (_data_->cx);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerPromptUntrustedHostData, _data_);
}

static void
application_controller_prompt_untrusted_host (ApplicationController* self,
                                              ApplicationAccountContext* context,
                                              GearyServiceInformation* service,
                                              GearyEndpoint* endpoint,
                                              GTlsConnection* cx,
                                              GAsyncReadyCallback _callback_,
                                              gpointer _user_data_)
{
	ApplicationControllerPromptUntrustedHostData* _data_;
	ApplicationController* _tmp0_;
	ApplicationAccountContext* _tmp1_;
	GearyServiceInformation* _tmp2_;
	GearyEndpoint* _tmp3_;
	GTlsConnection* _tmp4_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (APPLICATION_IS_ACCOUNT_CONTEXT (context));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (service, GEARY_TYPE_SERVICE_INFORMATION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (endpoint, GEARY_TYPE_ENDPOINT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cx, g_tls_connection_get_type ()));
	_data_ = g_slice_new0 (ApplicationControllerPromptUntrustedHostData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_prompt_untrusted_host_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (context);
	_g_object_unref0 (_data_->context);
	_data_->context = _tmp1_;
	_tmp2_ = _g_object_ref0 (service);
	_g_object_unref0 (_data_->service);
	_data_->service = _tmp2_;
	_tmp3_ = _g_object_ref0 (endpoint);
	_g_object_unref0 (_data_->endpoint);
	_data_->endpoint = _tmp3_;
	_tmp4_ = _g_object_ref0 (cx);
	_g_object_unref0 (_data_->cx);
	_data_->cx = _tmp4_;
	application_controller_prompt_untrusted_host_co (_data_);
}

static void
application_controller_prompt_untrusted_host_finish (ApplicationController* self,
                                                     GAsyncResult* _res_)
{
	ApplicationControllerPromptUntrustedHostData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
application_controller_prompt_untrusted_host_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	ApplicationControllerPromptUntrustedHostData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_prompt_untrusted_host_co (_data_);
}

static gboolean
application_controller_prompt_untrusted_host_co (ApplicationControllerPromptUntrustedHostData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->_application;
	_data_->_tmp1_ = application_client_get_config (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = application_configuration_get_revoke_certs (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	if (_data_->_tmp4_) {
	}
	application_account_context_set_tls_validation_prompting (_data_->context, TRUE);
	{
		_data_->_tmp5_ = _data_->self->priv->_certificate_manager;
		_data_->_tmp6_ = _data_->self->priv->_application;
		_data_->_tmp7_ = application_client_get_active_main_window (_data_->_tmp6_);
		_data_->_tmp8_ = _data_->_tmp7_;
		_data_->_tmp9_ = application_account_context_get_account (_data_->context);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_tmp11_ = geary_account_get_information (_data_->_tmp10_);
		_data_->_tmp12_ = _data_->_tmp11_;
		_data_->_tmp13_ = application_account_context_get_cancellable (_data_->context);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->_state_ = 1;
		application_certificate_manager_prompt_pin_certificate (_data_->_tmp5_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, gtk_window_get_type (), GtkWindow), _data_->_tmp12_, _data_->service, _data_->endpoint, FALSE, _data_->_tmp14_, application_controller_prompt_untrusted_host_ready, _data_);
		return FALSE;
		_state_1:
		application_certificate_manager_prompt_pin_certificate_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp8_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (g_error_matches (_data_->_inner_error0_, APPLICATION_CERTIFICATE_MANAGER_ERROR, APPLICATION_CERTIFICATE_MANAGER_ERROR_UNTRUSTED)) {
				goto __catch0_application_certificate_manager_error_untrusted;
			}
			if (_data_->_inner_error0_->domain == APPLICATION_CERTIFICATE_MANAGER_ERROR) {
				goto __catch0_application_certificate_manager_error;
			}
			g_critical ("file %s: line %d: unexpected 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;
		}
		application_account_context_set_tls_validation_failed (_data_->context, FALSE);
	}
	goto __finally0;
	__catch0_application_certificate_manager_error_untrusted:
	{
		g_clear_error (&_data_->_inner_error0_);
		application_account_context_set_tls_validation_failed (_data_->context, TRUE);
	}
	goto __finally0;
	__catch0_application_certificate_manager_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		application_account_context_set_tls_validation_failed (_data_->context, FALSE);
		_data_->_tmp15_ = application_account_context_get_account (_data_->context);
		_data_->_tmp16_ = _data_->_tmp15_;
		_data_->_tmp17_ = geary_account_get_information (_data_->_tmp16_);
		_data_->_tmp18_ = _data_->_tmp17_;
		_data_->_tmp19_ = _data_->err;
		_data_->_tmp20_ = geary_service_problem_report_new (_data_->_tmp18_, _data_->service, _data_->_tmp19_);
		_data_->_tmp21_ = _data_->_tmp20_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp21_, GEARY_TYPE_PROBLEM_REPORT, GearyProblemReport));
		_g_object_unref0 (_data_->_tmp21_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	application_account_context_set_tls_validation_prompting (_data_->context, FALSE);
	application_controller_update_account_status (_data_->self);
	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
application_controller_account_database_error_async_data_free (gpointer _data)
{
	ApplicationControllerAccountDatabaseErrorAsyncData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerAccountDatabaseErrorAsyncData, _data_);
}

static void
application_controller_account_database_error_async (ApplicationController* self,
                                                     GearyAccount* account,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_)
{
	ApplicationControllerAccountDatabaseErrorAsyncData* _data_;
	ApplicationController* _tmp0_;
	GearyAccount* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT));
	_data_ = g_slice_new0 (ApplicationControllerAccountDatabaseErrorAsyncData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_account_database_error_async_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	application_controller_account_database_error_async_co (_data_);
}

static gboolean
application_controller_account_database_error_finish (ApplicationController* self,
                                                      GAsyncResult* _res_)
{
	gboolean result;
	ApplicationControllerAccountDatabaseErrorAsyncData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
application_controller_account_database_error_async_ready (GObject* source_object,
                                                           GAsyncResult* _res_,
                                                           gpointer _user_data_)
{
	ApplicationControllerAccountDatabaseErrorAsyncData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_account_database_error_async_co (_data_);
}

static gboolean
application_controller_account_database_error_async_co (ApplicationControllerAccountDatabaseErrorAsyncData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->retry = TRUE;
	_data_->_tmp0_ = _data_->self->priv->_application;
	_data_->_tmp1_ = application_client_get_active_main_window (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_account_get_information (_data_->account);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = geary_account_information_get_id (_data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = g_strdup_printf (_ ("Unable to open the database for %s"), _data_->_tmp6_);
	_data_->_tmp8_ = _data_->_tmp7_;
	_data_->_tmp9_ = geary_account_get_information (_data_->account);
	_data_->_tmp10_ = _data_->_tmp9_;
	_data_->_tmp11_ = geary_account_information_get_data_dir (_data_->_tmp10_);
	_data_->_tmp12_ = _data_->_tmp11_;
	_data_->_tmp13_ = g_file_get_path (_data_->_tmp12_);
	_data_->_tmp14_ = _data_->_tmp13_;
	_data_->_tmp15_ = g_strdup_printf (_ ("There was an error opening the local mail database for this account. T" \
"his is possibly due to corruption of the database file in this directo" \
"ry:\n" \
"\n" \
"%s\n" \
"\n" \
"Geary can rebuild the database and re-synchronize with the server or e" \
"xit.\n" \
"\n" \
"Rebuilding the database will destroy all local email and its attachmen" \
"ts. <b>The mail on the your server will not be affected.</b>"), _data_->_tmp14_);
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = question_dialog_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, gtk_window_get_type (), GtkWindow), _data_->_tmp8_, _data_->_tmp16_, _ ("_Rebuild"), _ ("E_xit"));
	_data_->_tmp18_ = _data_->_tmp17_;
	_g_free0 (_data_->_tmp16_);
	_g_free0 (_data_->_tmp14_);
	_g_free0 (_data_->_tmp8_);
	_g_object_unref0 (_data_->_tmp2_);
	_data_->dialog = _data_->_tmp18_;
	_data_->_tmp19_ = _data_->dialog;
	alert_dialog_use_secondary_markup (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp19_, TYPE_ALERT_DIALOG, AlertDialog), TRUE);
	_data_->_tmp20_ = _data_->dialog;
	switch (alert_dialog_run (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp20_, TYPE_ALERT_DIALOG, AlertDialog))) {
		case GTK_RESPONSE_OK:
		{
			{
				_data_->_state_ = 1;
				geary_account_rebuild_async (_data_->account, NULL, application_controller_account_database_error_async_ready, _data_);
				return FALSE;
				_state_1:
				geary_account_rebuild_finish (_data_->account, _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_->_tmp21_ = _data_->self->priv->_application;
				_data_->_tmp22_ = application_client_get_active_main_window (_data_->_tmp21_);
				_data_->_tmp23_ = _data_->_tmp22_;
				_data_->_tmp24_ = geary_account_get_information (_data_->account);
				_data_->_tmp25_ = _data_->_tmp24_;
				_data_->_tmp26_ = geary_account_information_get_id (_data_->_tmp25_);
				_data_->_tmp27_ = _data_->_tmp26_;
				_data_->_tmp28_ = g_strdup_printf (_ ("Unable to rebuild database for “%s”"), _data_->_tmp27_);
				_data_->_tmp29_ = _data_->_tmp28_;
				_data_->_tmp30_ = _data_->err;
				_data_->_tmp31_ = _data_->_tmp30_->message;
				_data_->_tmp32_ = g_strdup_printf (_ ("Error during rebuild:\n\n%s"), _data_->_tmp31_);
				_data_->_tmp33_ = _data_->_tmp32_;
				_data_->_tmp34_ = error_dialog_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp23_, gtk_window_get_type (), GtkWindow), _data_->_tmp29_, _data_->_tmp33_);
				_data_->_tmp35_ = _data_->_tmp34_;
				_g_free0 (_data_->_tmp33_);
				_g_free0 (_data_->_tmp29_);
				_g_object_unref0 (_data_->_tmp23_);
				_data_->errdialog = _data_->_tmp35_;
				_data_->_tmp36_ = _data_->errdialog;
				alert_dialog_run (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp36_, TYPE_ALERT_DIALOG, AlertDialog));
				_data_->retry = FALSE;
				_g_object_unref0 (_data_->errdialog);
				_g_error_free0 (_data_->err);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->dialog);
				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;
			}
			break;
		}
		default:
		{
			_data_->retry = FALSE;
			break;
		}
	}
	_data_->result = _data_->retry;
	_g_object_unref0 (_data_->dialog);
	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
application_controller_on_folders_available_unavailable (ApplicationController* self,
                                                         GearyAccount* account,
                                                         GeeBidirSortedSet* available,
                                                         GeeBidirSortedSet* unavailable)
{
	ApplicationAccountContext* account_context = NULL;
	GeeMap* _tmp0_;
	GearyAccountInformation* _tmp1_;
	GearyAccountInformation* _tmp2_;
	gpointer _tmp3_;
	gboolean _tmp4_ = FALSE;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT));
	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));
	_tmp0_ = self->priv->accounts;
	_tmp1_ = geary_account_get_information (account);
	_tmp2_ = _tmp1_;
	_tmp3_ = gee_map_get (_tmp0_, _tmp2_);
	account_context = (ApplicationAccountContext*) _tmp3_;
	if (available != NULL) {
		gint _tmp5_;
		gint _tmp6_;
		_tmp5_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (available, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp6_ = _tmp5_;
		_tmp4_ = _tmp6_ > 0;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		GeeLinkedList* added_contexts = NULL;
		GeeLinkedList* _tmp7_;
		GeeLinkedList* _tmp29_;
		gboolean _tmp30_;
		gboolean _tmp31_;
		_tmp7_ = gee_linked_list_new (APPLICATION_TYPE_FOLDER_CONTEXT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		added_contexts = _tmp7_;
		{
			GeeIterator* _folder_it = NULL;
			GeeIterator* _tmp8_;
			_tmp8_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (available, GEE_TYPE_ITERABLE, GeeIterable));
			_folder_it = _tmp8_;
			while (TRUE) {
				GeeIterator* _tmp9_;
				GearyFolder* folder = NULL;
				GeeIterator* _tmp10_;
				gpointer _tmp11_;
				GearyFolder* _tmp12_;
				_tmp9_ = _folder_it;
				if (!gee_iterator_next (_tmp9_)) {
					break;
				}
				_tmp10_ = _folder_it;
				_tmp11_ = gee_iterator_get (_tmp10_);
				folder = (GearyFolder*) _tmp11_;
				_tmp12_ = folder;
				if (application_controller_should_add_folder (G_TYPE_CHECK_INSTANCE_CAST (available, GEE_TYPE_COLLECTION, GeeCollection), _tmp12_)) {
					GearyFolder* _tmp13_;
					GearyFolderSpecialUse _tmp14_;
					GearyFolderSpecialUse _tmp15_;
					ApplicationFolderContext* folder_context = NULL;
					GearyFolder* _tmp25_;
					ApplicationFolderContext* _tmp26_;
					GeeLinkedList* _tmp27_;
					ApplicationFolderContext* _tmp28_;
					_tmp13_ = folder;
					_tmp14_ = geary_folder_get_used_as (_tmp13_);
					_tmp15_ = _tmp14_;
					if (_tmp15_ == GEARY_FOLDER_SPECIAL_USE_INBOX) {
						ApplicationAccountContext* _tmp16_;
						GearyFolder* _tmp17_;
						GearyFolder* _tmp21_;
						ApplicationAccountContext* _tmp22_;
						GCancellable* _tmp23_;
						GCancellable* _tmp24_;
						_tmp16_ = account_context;
						_tmp17_ = _tmp16_->inbox;
						if (_tmp17_ == NULL) {
							ApplicationAccountContext* _tmp18_;
							GearyFolder* _tmp19_;
							GearyFolder* _tmp20_;
							_tmp18_ = account_context;
							_tmp19_ = folder;
							_tmp20_ = _g_object_ref0 (_tmp19_);
							_g_object_unref0 (_tmp18_->inbox);
							_tmp18_->inbox = _tmp20_;
						}
						_tmp21_ = folder;
						_tmp22_ = account_context;
						_tmp23_ = application_account_context_get_cancellable (_tmp22_);
						_tmp24_ = _tmp23_;
						geary_folder_open_async (_tmp21_, GEARY_FOLDER_OPEN_FLAGS_NO_DELAY, _tmp24_, NULL, NULL);
					}
					_tmp25_ = folder;
					_tmp26_ = application_folder_context_new (_tmp25_);
					folder_context = _tmp26_;
					_tmp27_ = added_contexts;
					_tmp28_ = folder_context;
					gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp27_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp28_);
					_g_object_unref0 (folder_context);
				}
				_g_object_unref0 (folder);
			}
			_g_object_unref0 (_folder_it);
		}
		_tmp29_ = added_contexts;
		_tmp30_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_tmp29_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp31_ = _tmp30_;
		if (!_tmp31_) {
			ApplicationAccountContext* _tmp32_;
			GeeLinkedList* _tmp33_;
			_tmp32_ = account_context;
			_tmp33_ = added_contexts;
			application_account_context_add_folders (_tmp32_, G_TYPE_CHECK_INSTANCE_CAST (_tmp33_, GEE_TYPE_COLLECTION, GeeCollection));
		}
		_g_object_unref0 (added_contexts);
	}
	if (unavailable != NULL) {
		GeeBidirIterator* unavailable_iterator = NULL;
		GeeBidirIterator* _tmp34_;
		gboolean has_prev = FALSE;
		GeeBidirIterator* _tmp35_;
		GeeLinkedList* removed_contexts = NULL;
		GeeLinkedList* _tmp36_;
		GeeLinkedList* _tmp50_;
		gboolean _tmp51_;
		gboolean _tmp52_;
		ApplicationAccountContext* _tmp55_;
		ApplicationControllerCommandStack* _tmp56_;
		ApplicationControllerCommandStack* _tmp57_;
		_tmp34_ = gee_bidir_sorted_set_bidir_iterator (unavailable);
		unavailable_iterator = _tmp34_;
		_tmp35_ = unavailable_iterator;
		has_prev = gee_bidir_iterator_last (_tmp35_);
		_tmp36_ = gee_linked_list_new (APPLICATION_TYPE_FOLDER_CONTEXT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
		removed_contexts = _tmp36_;
		while (TRUE) {
			GearyFolder* folder = NULL;
			GeeBidirIterator* _tmp37_;
			gpointer _tmp38_;
			GearyFolder* _tmp39_;
			GearyFolderSpecialUse _tmp40_;
			GearyFolderSpecialUse _tmp41_;
			ApplicationFolderContext* folder_context = NULL;
			ApplicationAccountContext* _tmp43_;
			GearyFolder* _tmp44_;
			ApplicationFolderContext* _tmp45_;
			ApplicationFolderContext* _tmp46_;
			GeeBidirIterator* _tmp49_;
			if (!has_prev) {
				break;
			}
			_tmp37_ = unavailable_iterator;
			_tmp38_ = gee_iterator_get (G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, GEE_TYPE_ITERATOR, GeeIterator));
			folder = (GearyFolder*) _tmp38_;
			_tmp39_ = folder;
			_tmp40_ = geary_folder_get_used_as (_tmp39_);
			_tmp41_ = _tmp40_;
			if (_tmp41_ == GEARY_FOLDER_SPECIAL_USE_INBOX) {
				ApplicationAccountContext* _tmp42_;
				_tmp42_ = account_context;
				_g_object_unref0 (_tmp42_->inbox);
				_tmp42_->inbox = NULL;
			}
			_tmp43_ = account_context;
			_tmp44_ = folder;
			_tmp45_ = application_account_context_get_folder (_tmp43_, _tmp44_);
			folder_context = _tmp45_;
			_tmp46_ = folder_context;
			if (_tmp46_ != NULL) {
				GeeLinkedList* _tmp47_;
				ApplicationFolderContext* _tmp48_;
				_tmp47_ = removed_contexts;
				_tmp48_ = folder_context;
				gee_abstract_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection), _tmp48_);
			}
			_tmp49_ = unavailable_iterator;
			has_prev = gee_bidir_iterator_previous (_tmp49_);
			_g_object_unref0 (folder_context);
			_g_object_unref0 (folder);
		}
		_tmp50_ = removed_contexts;
		_tmp51_ = gee_collection_get_is_empty (G_TYPE_CHECK_INSTANCE_CAST (_tmp50_, GEE_TYPE_COLLECTION, GeeCollection));
		_tmp52_ = _tmp51_;
		if (!_tmp52_) {
			ApplicationAccountContext* _tmp53_;
			GeeLinkedList* _tmp54_;
			_tmp53_ = account_context;
			_tmp54_ = removed_contexts;
			application_account_context_remove_folders (_tmp53_, G_TYPE_CHECK_INSTANCE_CAST (_tmp54_, GEE_TYPE_COLLECTION, GeeCollection));
		}
		_tmp55_ = account_context;
		_tmp56_ = application_account_context_get_controller_stack (_tmp55_);
		_tmp57_ = _tmp56_;
		application_controller_command_stack_folders_removed (_tmp57_, G_TYPE_CHECK_INSTANCE_CAST (unavailable, GEE_TYPE_COLLECTION, GeeCollection));
		_g_object_unref0 (removed_contexts);
		_g_object_unref0 (unavailable_iterator);
	}
	_g_object_unref0 (account_context);
}

/** Clears new message counts in notification plugin contexts. */
void
application_controller_clear_new_messages (ApplicationController* self,
                                           GearyFolder* source,
                                           GeeSet* visible)
{
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, GEARY_TYPE_FOLDER));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (visible, GEE_TYPE_SET));
	{
		GeeIterator* _window_it = NULL;
		ApplicationClient* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeIterator* _tmp3_;
		GeeIterator* _tmp4_;
		_tmp0_ = self->priv->_application;
		_tmp1_ = application_client_get_main_windows (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp4_ = _tmp3_;
		_g_object_unref0 (_tmp2_);
		_window_it = _tmp4_;
		while (TRUE) {
			GeeIterator* _tmp5_;
			ApplicationMainWindow* window = NULL;
			GeeIterator* _tmp6_;
			gpointer _tmp7_;
			ApplicationMainWindow* _tmp8_;
			FolderListTree* _tmp9_;
			FolderListTree* _tmp10_;
			_tmp5_ = _window_it;
			if (!gee_iterator_next (_tmp5_)) {
				break;
			}
			_tmp6_ = _window_it;
			_tmp7_ = gee_iterator_get (_tmp6_);
			window = (ApplicationMainWindow*) _tmp7_;
			_tmp8_ = window;
			_tmp9_ = application_main_window_get_folder_list (_tmp8_);
			_tmp10_ = _tmp9_;
			folder_list_tree_set_has_new (_tmp10_, source, FALSE);
			_g_object_unref0 (window);
		}
		_g_object_unref0 (_window_it);
	}
	{
		GeeIterator* _context_it = NULL;
		ApplicationPluginManager* _tmp11_;
		GeeCollection* _tmp12_;
		GeeCollection* _tmp13_;
		GeeIterator* _tmp14_;
		GeeIterator* _tmp15_;
		_tmp11_ = self->priv->_plugins;
		_tmp12_ = application_plugin_manager_get_notification_contexts (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp15_ = _tmp14_;
		_g_object_unref0 (_tmp13_);
		_context_it = _tmp15_;
		while (TRUE) {
			GeeIterator* _tmp16_;
			ApplicationNotificationPluginContext* context = NULL;
			GeeIterator* _tmp17_;
			gpointer _tmp18_;
			ApplicationNotificationPluginContext* _tmp19_;
			_tmp16_ = _context_it;
			if (!gee_iterator_next (_tmp16_)) {
				break;
			}
			_tmp17_ = _context_it;
			_tmp18_ = gee_iterator_get (_tmp17_);
			context = (ApplicationNotificationPluginContext*) _tmp18_;
			_tmp19_ = context;
			application_notification_plugin_context_clear_new_messages (_tmp19_, source, visible);
			_g_object_unref0 (context);
		}
		_g_object_unref0 (_context_it);
	}
}

/** Notifies plugins of new email being displayed. */
void
application_controller_email_loaded (ApplicationController* self,
                                     GearyAccountInformation* account,
                                     GearyEmail* loaded)
{
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT_INFORMATION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (loaded, GEARY_TYPE_EMAIL));
	{
		GeeIterator* _plugin_it = NULL;
		ApplicationPluginManager* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeIterator* _tmp3_;
		GeeIterator* _tmp4_;
		_tmp0_ = self->priv->_plugins;
		_tmp1_ = application_plugin_manager_get_email_contexts (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp4_ = _tmp3_;
		_g_object_unref0 (_tmp2_);
		_plugin_it = _tmp4_;
		while (TRUE) {
			GeeIterator* _tmp5_;
			ApplicationEmailPluginContext* plugin = NULL;
			GeeIterator* _tmp6_;
			gpointer _tmp7_;
			ApplicationEmailPluginContext* _tmp8_;
			_tmp5_ = _plugin_it;
			if (!gee_iterator_next (_tmp5_)) {
				break;
			}
			_tmp6_ = _plugin_it;
			_tmp7_ = gee_iterator_get (_tmp6_);
			plugin = (ApplicationEmailPluginContext*) _tmp7_;
			_tmp8_ = plugin;
			application_email_plugin_context_email_displayed (_tmp8_, account, loaded);
			_g_object_unref0 (plugin);
		}
		_g_object_unref0 (_plugin_it);
	}
}

/**
     * Track a window receiving focus, for idle background work.
     */
static void
_g_cancellable_cancel_g_cancellable_cancelled (GCancellable* _sender,
                                               gpointer self)
{
	g_cancellable_cancel ((GCancellable*) self);
}

void
application_controller_window_focus_in (ApplicationController* self)
{
	GearyTimeoutManager* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	_tmp0_ = self->priv->all_windows_backgrounded_timeout;
	geary_timeout_manager_reset (_tmp0_);
	_tmp1_ = self->priv->storage_cleanup_cancellable;
	if (_tmp1_ != NULL) {
		GCancellable* _tmp2_;
		_tmp2_ = self->priv->storage_cleanup_cancellable;
		g_cancellable_cancel (_tmp2_);
		{
			GeeIterator* _context_it = NULL;
			GeeMap* _tmp3_;
			GeeCollection* _tmp4_;
			GeeCollection* _tmp5_;
			GeeCollection* _tmp6_;
			GeeIterator* _tmp7_;
			GeeIterator* _tmp8_;
			_tmp3_ = self->priv->accounts;
			_tmp4_ = gee_map_get_values (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = _tmp5_;
			_tmp7_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, GEE_TYPE_ITERABLE, GeeIterable));
			_tmp8_ = _tmp7_;
			_g_object_unref0 (_tmp6_);
			_context_it = _tmp8_;
			while (TRUE) {
				GeeIterator* _tmp9_;
				ApplicationAccountContext* context = NULL;
				GeeIterator* _tmp10_;
				gpointer _tmp11_;
				ApplicationAccountContext* _tmp12_;
				GCancellable* _tmp13_;
				GCancellable* _tmp14_;
				GCancellable* _tmp15_;
				guint _tmp16_;
				GearyAccount* account = NULL;
				ApplicationAccountContext* _tmp17_;
				GearyAccount* _tmp18_;
				GearyAccount* _tmp19_;
				GearyAccount* _tmp20_;
				GearyAccount* _tmp21_;
				_tmp9_ = _context_it;
				if (!gee_iterator_next (_tmp9_)) {
					break;
				}
				_tmp10_ = _context_it;
				_tmp11_ = gee_iterator_get (_tmp10_);
				context = (ApplicationAccountContext*) _tmp11_;
				_tmp12_ = context;
				_tmp13_ = application_account_context_get_cancellable (_tmp12_);
				_tmp14_ = _tmp13_;
				_tmp15_ = self->priv->storage_cleanup_cancellable;
				g_signal_parse_name ("cancelled", g_cancellable_get_type (), &_tmp16_, NULL, FALSE);
				g_signal_handlers_disconnect_matched (_tmp14_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp16_, 0, NULL, (GCallback) _g_cancellable_cancel_g_cancellable_cancelled, _tmp15_);
				_tmp17_ = context;
				_tmp18_ = application_account_context_get_account (_tmp17_);
				_tmp19_ = _tmp18_;
				_tmp20_ = _g_object_ref0 (_tmp19_);
				account = _tmp20_;
				_tmp21_ = account;
				geary_account_set_last_storage_cleanup (_tmp21_, NULL);
				_g_object_unref0 (account);
				_g_object_unref0 (context);
			}
			_g_object_unref0 (_context_it);
		}
		_g_object_unref0 (self->priv->storage_cleanup_cancellable);
		self->priv->storage_cleanup_cancellable = NULL;
	}
}

/**
     * Track a window going unfocused, for idle background work.
     */
void
application_controller_window_focus_out (ApplicationController* self)
{
	GearyTimeoutManager* _tmp0_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	_tmp0_ = self->priv->all_windows_backgrounded_timeout;
	geary_timeout_manager_start (_tmp0_);
}

/** Attempts to make the composer visible on the active monitor. */
void
application_controller_present_composer (ApplicationController* self,
                                         ComposerWidget* composer)
{
	gboolean _tmp0_ = FALSE;
	ComposerWidgetPresentationMode _tmp1_;
	ComposerWidgetPresentationMode _tmp2_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (COMPOSER_IS_WIDGET (composer));
	_tmp1_ = composer_widget_get_current_mode (composer);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == COMPOSER_WIDGET_PRESENTATION_MODE_CLOSED) {
		_tmp0_ = TRUE;
	} else {
		ComposerWidgetPresentationMode _tmp3_;
		ComposerWidgetPresentationMode _tmp4_;
		_tmp3_ = composer_widget_get_current_mode (composer);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ == COMPOSER_WIDGET_PRESENTATION_MODE_NONE;
	}
	if (_tmp0_) {
		ApplicationMainWindow* target = NULL;
		ApplicationClient* _tmp5_;
		ApplicationMainWindow* _tmp6_;
		ApplicationMainWindow* _tmp7_;
		_tmp5_ = self->priv->_application;
		_tmp6_ = application_client_get_active_main_window (_tmp5_);
		target = _tmp6_;
		_tmp7_ = target;
		application_main_window_show_composer (_tmp7_, composer);
		_g_object_unref0 (target);
	}
	composer_widget_set_focus (composer);
	composer_widget_present (composer);
}

gboolean
application_controller_check_open_composers (ApplicationController* self)
{
	gboolean do_quit = FALSE;
	gboolean result;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), FALSE);
	do_quit = TRUE;
	{
		GeeIterator* _composer_it = NULL;
		GeeCollection* _tmp0_;
		GeeIterator* _tmp1_;
		_tmp0_ = self->priv->composer_widgets;
		_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ITERABLE, GeeIterable));
		_composer_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			ComposerWidget* composer = NULL;
			GeeIterator* _tmp3_;
			gpointer _tmp4_;
			ComposerWidget* _tmp5_;
			_tmp2_ = _composer_it;
			if (!gee_iterator_next (_tmp2_)) {
				break;
			}
			_tmp3_ = _composer_it;
			_tmp4_ = gee_iterator_get (_tmp3_);
			composer = (ComposerWidget*) _tmp4_;
			_tmp5_ = composer;
			if (composer_widget_conditional_close (_tmp5_, TRUE, TRUE) == COMPOSER_WIDGET_CLOSE_STATUS_CANCELLED) {
				do_quit = FALSE;
				_g_object_unref0 (composer);
				break;
			}
			_g_object_unref0 (composer);
		}
		_g_object_unref0 (_composer_it);
	}
	result = do_quit;
	return result;
}

static void
_application_controller_on_composer_widget_destroy_gtk_widget_destroy (GtkWidget* _sender,
                                                                       gpointer self)
{
	application_controller_on_composer_widget_destroy ((ApplicationController*) self, _sender);
}

void
application_controller_register_composer (ApplicationController* self,
                                          ComposerWidget* widget)
{
	GeeCollection* _tmp0_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (COMPOSER_IS_WIDGET (widget));
	_tmp0_ = self->priv->composer_widgets;
	if (!gee_collection_contains (_tmp0_, widget)) {
		ComposerWidgetContextType _tmp1_;
		ComposerWidgetContextType _tmp2_;
		GEnumValue* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		GeeCollection* _tmp6_;
		gint _tmp7_;
		gint _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		gchar* _tmp13_;
		gchar* _tmp14_;
		GeeCollection* _tmp15_;
		_tmp1_ = composer_widget_get_context_type (widget);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_enum_get_value (g_type_class_ref (COMPOSER_WIDGET_TYPE_CONTEXT_TYPE), _tmp2_);
		_tmp4_ = g_strconcat ("Registered composer of type ", (_tmp3_ != NULL) ? _tmp3_->value_name : NULL, "; ", NULL);
		_tmp5_ = _tmp4_;
		_tmp6_ = self->priv->composer_widgets;
		_tmp7_ = gee_collection_get_size (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strdup_printf ("%i", _tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = g_strconcat (_tmp10_, " composers total", NULL);
		_tmp12_ = _tmp11_;
		_tmp13_ = g_strconcat (_tmp5_, _tmp12_, NULL);
		_tmp14_ = _tmp13_;
		g_debug ("application-controller.vala:1470: %s", _tmp14_);
		_g_free0 (_tmp14_);
		_g_free0 (_tmp12_);
		_g_free0 (_tmp10_);
		_g_free0 (_tmp5_);
		g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (widget, gtk_widget_get_type (), GtkWidget), "destroy", (GCallback) _application_controller_on_composer_widget_destroy_gtk_widget_destroy, self, G_CONNECT_AFTER);
		_tmp15_ = self->priv->composer_widgets;
		gee_collection_add (_tmp15_, widget);
		g_signal_emit (self, application_controller_signals[APPLICATION_CONTROLLER_COMPOSER_REGISTERED_SIGNAL], 0, widget);
	}
}

static void
application_controller_on_composer_widget_destroy (ApplicationController* self,
                                                   GtkWidget* sender)
{
	ComposerWidget* composer = NULL;
	ComposerWidget* _tmp0_;
	gboolean _tmp1_ = FALSE;
	ComposerWidget* _tmp2_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (sender, gtk_widget_get_type ()));
	_tmp0_ = _g_object_ref0 (COMPOSER_IS_WIDGET (sender) ? ((ComposerWidget*) sender) : NULL);
	composer = _tmp0_;
	_tmp2_ = composer;
	if (_tmp2_ != NULL) {
		GeeCollection* _tmp3_;
		ComposerWidget* _tmp4_;
		_tmp3_ = self->priv->composer_widgets;
		_tmp4_ = composer;
		_tmp1_ = gee_collection_remove (_tmp3_, _tmp4_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		ComposerWidget* _tmp5_;
		ComposerWidgetContextType _tmp6_;
		ComposerWidgetContextType _tmp7_;
		GEnumValue* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		GeeCollection* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		gchar* _tmp18_;
		gchar* _tmp19_;
		ComposerWidget* _tmp20_;
		_tmp5_ = composer;
		_tmp6_ = composer_widget_get_context_type (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = g_enum_get_value (g_type_class_ref (COMPOSER_WIDGET_TYPE_CONTEXT_TYPE), _tmp7_);
		_tmp9_ = g_strconcat ("Composer type ", (_tmp8_ != NULL) ? _tmp8_->value_name : NULL, " destroyed; ", NULL);
		_tmp10_ = _tmp9_;
		_tmp11_ = self->priv->composer_widgets;
		_tmp12_ = gee_collection_get_size (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = g_strdup_printf ("%i", _tmp13_);
		_tmp15_ = _tmp14_;
		_tmp16_ = g_strconcat (_tmp15_, " composers remaining", NULL);
		_tmp17_ = _tmp16_;
		_tmp18_ = g_strconcat (_tmp10_, _tmp17_, NULL);
		_tmp19_ = _tmp18_;
		g_debug ("application-controller.vala:1481: %s", _tmp19_);
		_g_free0 (_tmp19_);
		_g_free0 (_tmp17_);
		_g_free0 (_tmp15_);
		_g_free0 (_tmp10_);
		_tmp20_ = composer;
		g_signal_emit (self, application_controller_signals[APPLICATION_CONTROLLER_COMPOSER_DEREGISTERED_SIGNAL], 0, _tmp20_);
	}
	_g_object_unref0 (composer);
}

static void
application_controller_on_sent (ApplicationController* self,
                                GearySmtpClientService* service,
                                GearyEmail* sent)
{
	gchar* message = NULL;
	gchar* _tmp0_;
	ComponentsInAppNotification* notification = NULL;
	const gchar* _tmp1_;
	ApplicationClient* _tmp2_;
	ApplicationConfiguration* _tmp3_;
	ApplicationConfiguration* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	ComponentsInAppNotification* _tmp7_;
	ApplicationAccountContext* context = NULL;
	GeeMap* _tmp18_;
	GearyAccountInformation* _tmp19_;
	GearyAccountInformation* _tmp20_;
	gpointer _tmp21_;
	ApplicationAccountContext* _tmp22_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (service, GEARY_SMTP_TYPE_CLIENT_SERVICE));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (sent, GEARY_TYPE_EMAIL));
	_tmp0_ = g_strdup (_ ("Email sent"));
	message = _tmp0_;
	_tmp1_ = message;
	_tmp2_ = self->priv->_application;
	_tmp3_ = application_client_get_config (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = application_configuration_get_brief_notification_duration (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = components_in_app_notification_new (_tmp1_, (guint) _tmp6_);
	g_object_ref_sink (_tmp7_);
	notification = _tmp7_;
	{
		GeeIterator* _window_it = NULL;
		ApplicationClient* _tmp8_;
		GeeCollection* _tmp9_;
		GeeCollection* _tmp10_;
		GeeIterator* _tmp11_;
		GeeIterator* _tmp12_;
		_tmp8_ = self->priv->_application;
		_tmp9_ = application_client_get_main_windows (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp12_ = _tmp11_;
		_g_object_unref0 (_tmp10_);
		_window_it = _tmp12_;
		while (TRUE) {
			GeeIterator* _tmp13_;
			ApplicationMainWindow* window = NULL;
			GeeIterator* _tmp14_;
			gpointer _tmp15_;
			ApplicationMainWindow* _tmp16_;
			ComponentsInAppNotification* _tmp17_;
			_tmp13_ = _window_it;
			if (!gee_iterator_next (_tmp13_)) {
				break;
			}
			_tmp14_ = _window_it;
			_tmp15_ = gee_iterator_get (_tmp14_);
			window = (ApplicationMainWindow*) _tmp15_;
			_tmp16_ = window;
			_tmp17_ = notification;
			application_main_window_add_notification (_tmp16_, _tmp17_);
			_g_object_unref0 (window);
		}
		_g_object_unref0 (_window_it);
	}
	_tmp18_ = self->priv->accounts;
	_tmp19_ = geary_client_service_get_account (G_TYPE_CHECK_INSTANCE_CAST (service, GEARY_TYPE_CLIENT_SERVICE, GearyClientService));
	_tmp20_ = _tmp19_;
	_tmp21_ = gee_map_get (_tmp18_, _tmp20_);
	context = (ApplicationAccountContext*) _tmp21_;
	_tmp22_ = context;
	if (_tmp22_ != NULL) {
		{
			GeeIterator* _plugin_it = NULL;
			ApplicationPluginManager* _tmp23_;
			GeeCollection* _tmp24_;
			GeeCollection* _tmp25_;
			GeeIterator* _tmp26_;
			GeeIterator* _tmp27_;
			_tmp23_ = self->priv->_plugins;
			_tmp24_ = application_plugin_manager_get_email_contexts (_tmp23_);
			_tmp25_ = _tmp24_;
			_tmp26_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, GEE_TYPE_ITERABLE, GeeIterable));
			_tmp27_ = _tmp26_;
			_g_object_unref0 (_tmp25_);
			_plugin_it = _tmp27_;
			while (TRUE) {
				GeeIterator* _tmp28_;
				ApplicationEmailPluginContext* plugin = NULL;
				GeeIterator* _tmp29_;
				gpointer _tmp30_;
				ApplicationEmailPluginContext* _tmp31_;
				ApplicationAccountContext* _tmp32_;
				GearyAccount* _tmp33_;
				GearyAccount* _tmp34_;
				GearyAccountInformation* _tmp35_;
				GearyAccountInformation* _tmp36_;
				_tmp28_ = _plugin_it;
				if (!gee_iterator_next (_tmp28_)) {
					break;
				}
				_tmp29_ = _plugin_it;
				_tmp30_ = gee_iterator_get (_tmp29_);
				plugin = (ApplicationEmailPluginContext*) _tmp30_;
				_tmp31_ = plugin;
				_tmp32_ = context;
				_tmp33_ = application_account_context_get_account (_tmp32_);
				_tmp34_ = _tmp33_;
				_tmp35_ = geary_account_get_information (_tmp34_);
				_tmp36_ = _tmp35_;
				application_email_plugin_context_email_sent (_tmp31_, _tmp36_, sent);
				_g_object_unref0 (plugin);
			}
			_g_object_unref0 (_plugin_it);
		}
	}
	_g_object_unref0 (context);
	_g_object_unref0 (notification);
	_g_free0 (message);
}

static GeeCollection*
application_controller_to_in_folder_email_ids (ApplicationController* self,
                                               GeeCollection* conversations)
{
	GeeCollection* messages = NULL;
	GeeLinkedList* _tmp0_;
	GeeCollection* result;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	_tmp0_ = gee_linked_list_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	messages = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection);
	{
		GeeIterator* _conversation_it = NULL;
		GeeIterator* _tmp1_;
		_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (conversations, GEE_TYPE_ITERABLE, GeeIterable));
		_conversation_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			GearyAppConversation* conversation = NULL;
			GeeIterator* _tmp3_;
			gpointer _tmp4_;
			_tmp2_ = _conversation_it;
			if (!gee_iterator_next (_tmp2_)) {
				break;
			}
			_tmp3_ = _conversation_it;
			_tmp4_ = gee_iterator_get (_tmp3_);
			conversation = (GearyAppConversation*) _tmp4_;
			{
				GeeList* _email_list = NULL;
				GearyAppConversation* _tmp5_;
				GeeList* _tmp6_;
				gint _email_size = 0;
				GeeList* _tmp7_;
				gint _tmp8_;
				gint _tmp9_;
				gint _email_index = 0;
				_tmp5_ = conversation;
				_tmp6_ = geary_app_conversation_get_emails (_tmp5_, GEARY_APP_CONVERSATION_ORDERING_RECV_DATE_ASCENDING, GEARY_APP_CONVERSATION_LOCATION_IN_FOLDER, NULL, TRUE);
				_email_list = _tmp6_;
				_tmp7_ = _email_list;
				_tmp8_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_COLLECTION, GeeCollection));
				_tmp9_ = _tmp8_;
				_email_size = _tmp9_;
				_email_index = -1;
				while (TRUE) {
					gint _tmp10_;
					gint _tmp11_;
					GearyEmail* email = NULL;
					GeeList* _tmp12_;
					gpointer _tmp13_;
					GeeCollection* _tmp14_;
					GearyEmail* _tmp15_;
					GearyEmailIdentifier* _tmp16_;
					GearyEmailIdentifier* _tmp17_;
					_email_index = _email_index + 1;
					_tmp10_ = _email_index;
					_tmp11_ = _email_size;
					if (!(_tmp10_ < _tmp11_)) {
						break;
					}
					_tmp12_ = _email_list;
					_tmp13_ = gee_list_get (_tmp12_, _email_index);
					email = (GearyEmail*) _tmp13_;
					_tmp14_ = messages;
					_tmp15_ = email;
					_tmp16_ = geary_email_get_id (_tmp15_);
					_tmp17_ = _tmp16_;
					gee_collection_add (_tmp14_, _tmp17_);
					_g_object_unref0 (email);
				}
				_g_object_unref0 (_email_list);
			}
			_g_object_unref0 (conversation);
		}
		_g_object_unref0 (_conversation_it);
	}
	result = messages;
	return result;
}

static GeeCollection*
application_controller_to_all_email_ids (ApplicationController* self,
                                         GeeCollection* conversations)
{
	GeeCollection* messages = NULL;
	GeeLinkedList* _tmp0_;
	GeeCollection* result;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (self), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	_tmp0_ = gee_linked_list_new (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	messages = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection);
	{
		GeeIterator* _conversation_it = NULL;
		GeeIterator* _tmp1_;
		_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (conversations, GEE_TYPE_ITERABLE, GeeIterable));
		_conversation_it = _tmp1_;
		while (TRUE) {
			GeeIterator* _tmp2_;
			GearyAppConversation* conversation = NULL;
			GeeIterator* _tmp3_;
			gpointer _tmp4_;
			_tmp2_ = _conversation_it;
			if (!gee_iterator_next (_tmp2_)) {
				break;
			}
			_tmp3_ = _conversation_it;
			_tmp4_ = gee_iterator_get (_tmp3_);
			conversation = (GearyAppConversation*) _tmp4_;
			{
				GeeList* _email_list = NULL;
				GearyAppConversation* _tmp5_;
				GeeList* _tmp6_;
				gint _email_size = 0;
				GeeList* _tmp7_;
				gint _tmp8_;
				gint _tmp9_;
				gint _email_index = 0;
				_tmp5_ = conversation;
				_tmp6_ = geary_app_conversation_get_emails (_tmp5_, GEARY_APP_CONVERSATION_ORDERING_NONE, GEARY_APP_CONVERSATION_LOCATION_ANYWHERE, NULL, TRUE);
				_email_list = _tmp6_;
				_tmp7_ = _email_list;
				_tmp8_ = gee_collection_get_size (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_COLLECTION, GeeCollection));
				_tmp9_ = _tmp8_;
				_email_size = _tmp9_;
				_email_index = -1;
				while (TRUE) {
					gint _tmp10_;
					gint _tmp11_;
					GearyEmail* email = NULL;
					GeeList* _tmp12_;
					gpointer _tmp13_;
					GeeCollection* _tmp14_;
					GearyEmail* _tmp15_;
					GearyEmailIdentifier* _tmp16_;
					GearyEmailIdentifier* _tmp17_;
					_email_index = _email_index + 1;
					_tmp10_ = _email_index;
					_tmp11_ = _email_size;
					if (!(_tmp10_ < _tmp11_)) {
						break;
					}
					_tmp12_ = _email_list;
					_tmp13_ = gee_list_get (_tmp12_, _email_index);
					email = (GearyEmail*) _tmp13_;
					_tmp14_ = messages;
					_tmp15_ = email;
					_tmp16_ = geary_email_get_id (_tmp15_);
					_tmp17_ = _tmp16_;
					gee_collection_add (_tmp14_, _tmp17_);
					_g_object_unref0 (email);
				}
				_g_object_unref0 (_email_list);
			}
			_g_object_unref0 (conversation);
		}
		_g_object_unref0 (_conversation_it);
	}
	result = messages;
	return result;
}

static void
application_controller_on_account_available (ApplicationController* self,
                                             GearyAccountInformation* info)
{
	GearyAccount* account = NULL;
	GearyAccount* _tmp13_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (info, GEARY_TYPE_ACCOUNT_INFORMATION));
	account = NULL;
	{
		GearyAccount* _tmp0_ = NULL;
		ApplicationClient* _tmp1_;
		GearyEngine* _tmp2_;
		GearyEngine* _tmp3_;
		GearyAccount* _tmp4_;
		GearyAccount* _tmp5_;
		_tmp1_ = self->priv->_application;
		_tmp2_ = application_client_get_engine (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = geary_engine_get_account (_tmp3_, info, &_inner_error0_);
		_tmp0_ = _tmp4_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp5_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (account);
		account = _tmp5_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* _error_ = NULL;
		GError* _tmp6_;
		GearyProblemReport* _tmp7_;
		GearyProblemReport* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		GError* _tmp11_;
		const gchar* _tmp12_;
		_error_ = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp6_ = _error_;
		_tmp7_ = geary_problem_report_new (_tmp6_);
		_tmp8_ = _tmp7_;
		composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _tmp8_);
		_g_object_unref0 (_tmp8_);
		_tmp9_ = geary_account_information_get_id (info);
		_tmp10_ = _tmp9_;
		_tmp11_ = _error_;
		_tmp12_ = _tmp11_->message;
		g_warning ("application-controller.vala:1539: Error creating account %s instance: " \
"%s", _tmp10_, _tmp12_);
		_g_error_free0 (_error_);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (account);
		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;
	}
	_tmp13_ = account;
	if (_tmp13_ != NULL) {
		GearyAccount* _tmp14_;
		_tmp14_ = account;
		application_controller_open_account (self, _tmp14_, NULL, NULL);
	}
	_g_object_unref0 (account);
}

static void
application_controller_on_account_added (ApplicationController* self,
                                         GearyAccountInformation* added,
                                         AccountsManagerStatus status)
{
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (added, GEARY_TYPE_ACCOUNT_INFORMATION));
	if (status == ACCOUNTS_MANAGER_STATUS_ENABLED) {
		application_controller_add_account (self, added);
	}
}

static void
application_controller_on_account_status_changed (ApplicationController* self,
                                                  GearyAccountInformation* changed,
                                                  AccountsManagerStatus status)
{
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (changed, GEARY_TYPE_ACCOUNT_INFORMATION));
	switch (status) {
		case ACCOUNTS_MANAGER_STATUS_ENABLED:
		{
			application_controller_add_account (self, changed);
			break;
		}
		case ACCOUNTS_MANAGER_STATUS_UNAVAILABLE:
		case ACCOUNTS_MANAGER_STATUS_DISABLED:
		{
			application_controller_remove_account (self, changed, NULL, NULL);
			break;
		}
		case ACCOUNTS_MANAGER_STATUS_REMOVED:
		{
			break;
		}
		default:
		break;
	}
}

static void
application_controller_on_account_removed (ApplicationController* self,
                                           GearyAccountInformation* removed)
{
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEARY_TYPE_ACCOUNT_INFORMATION));
	application_controller_remove_account (self, removed, NULL, NULL);
}

static void
application_controller_on_report_problem (ApplicationController* self,
                                          GearyProblemReport* problem)
{
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (problem, GEARY_TYPE_PROBLEM_REPORT));
	composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), problem);
}

static void
application_controller_on_retry_problem (ApplicationController* self,
                                         ComponentsProblemReportInfoBar* info_bar)
{
	GearyServiceProblemReport* service_report = NULL;
	GearyProblemReport* _tmp0_;
	GearyProblemReport* _tmp1_;
	GearyServiceProblemReport* _tmp2_;
	GearyServiceProblemReport* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (COMPONENTS_IS_PROBLEM_REPORT_INFO_BAR (info_bar));
	_tmp0_ = components_problem_report_info_bar_get_report (info_bar);
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp1_, GEARY_TYPE_SERVICE_PROBLEM_REPORT) ? ((GearyServiceProblemReport*) _tmp1_) : NULL);
	service_report = _tmp2_;
	_tmp3_ = service_report;
	if (_tmp3_ != NULL) {
		ApplicationAccountContext* context = NULL;
		GeeMap* _tmp4_;
		GearyServiceProblemReport* _tmp5_;
		GearyAccountInformation* _tmp6_;
		GearyAccountInformation* _tmp7_;
		gpointer _tmp8_;
		gboolean _tmp9_ = FALSE;
		ApplicationAccountContext* _tmp10_;
		_tmp4_ = self->priv->accounts;
		_tmp5_ = service_report;
		_tmp6_ = geary_account_problem_report_get_account (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEARY_TYPE_ACCOUNT_PROBLEM_REPORT, GearyAccountProblemReport));
		_tmp7_ = _tmp6_;
		_tmp8_ = gee_map_get (_tmp4_, _tmp7_);
		context = (ApplicationAccountContext*) _tmp8_;
		_tmp10_ = context;
		if (_tmp10_ != NULL) {
			ApplicationAccountContext* _tmp11_;
			GearyAccount* _tmp12_;
			GearyAccount* _tmp13_;
			_tmp11_ = context;
			_tmp12_ = application_account_context_get_account (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp9_ = geary_account_is_open (_tmp13_);
		} else {
			_tmp9_ = FALSE;
		}
		if (_tmp9_) {
			GearyServiceProblemReport* _tmp14_;
			GearyServiceInformation* _tmp15_;
			GearyServiceInformation* _tmp16_;
			GearyProtocol _tmp17_;
			GearyProtocol _tmp18_;
			_tmp14_ = service_report;
			_tmp15_ = geary_service_problem_report_get_service (_tmp14_);
			_tmp16_ = _tmp15_;
			_tmp17_ = geary_service_information_get_protocol (_tmp16_);
			_tmp18_ = _tmp17_;
			switch (_tmp18_) {
				case GEARY_PROTOCOL_IMAP:
				{
					ApplicationAccountContext* _tmp19_;
					GearyAccount* _tmp20_;
					GearyAccount* _tmp21_;
					GearyClientService* _tmp22_;
					GearyClientService* _tmp23_;
					ApplicationAccountContext* _tmp24_;
					GCancellable* _tmp25_;
					GCancellable* _tmp26_;
					_tmp19_ = context;
					_tmp20_ = application_account_context_get_account (_tmp19_);
					_tmp21_ = _tmp20_;
					_tmp22_ = geary_account_get_incoming (_tmp21_);
					_tmp23_ = _tmp22_;
					_tmp24_ = context;
					_tmp25_ = application_account_context_get_cancellable (_tmp24_);
					_tmp26_ = _tmp25_;
					geary_client_service_restart (_tmp23_, _tmp26_, NULL, NULL);
					break;
				}
				case GEARY_PROTOCOL_SMTP:
				{
					ApplicationAccountContext* _tmp27_;
					GearyAccount* _tmp28_;
					GearyAccount* _tmp29_;
					GearyClientService* _tmp30_;
					GearyClientService* _tmp31_;
					ApplicationAccountContext* _tmp32_;
					GCancellable* _tmp33_;
					GCancellable* _tmp34_;
					_tmp27_ = context;
					_tmp28_ = application_account_context_get_account (_tmp27_);
					_tmp29_ = _tmp28_;
					_tmp30_ = geary_account_get_outgoing (_tmp29_);
					_tmp31_ = _tmp30_;
					_tmp32_ = context;
					_tmp33_ = application_account_context_get_cancellable (_tmp32_);
					_tmp34_ = _tmp33_;
					geary_client_service_restart (_tmp31_, _tmp34_, NULL, NULL);
					break;
				}
				default:
				break;
			}
		}
		_g_object_unref0 (context);
	}
	_g_object_unref0 (service_report);
}

static void
application_controller_on_account_status_notify (ApplicationController* self)
{
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	application_controller_update_account_status (self);
}

static void
application_controller_on_authentication_failure (ApplicationController* self,
                                                  GearyAccountInformation* account,
                                                  GearyServiceInformation* service)
{
	ApplicationAccountContext* context = NULL;
	GeeMap* _tmp0_;
	gpointer _tmp1_;
	gboolean _tmp2_ = FALSE;
	ApplicationAccountContext* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT_INFORMATION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (service, GEARY_TYPE_SERVICE_INFORMATION));
	_tmp0_ = self->priv->accounts;
	_tmp1_ = gee_map_get (_tmp0_, account);
	context = (ApplicationAccountContext*) _tmp1_;
	_tmp3_ = context;
	if (_tmp3_ != NULL) {
		_tmp2_ = !application_controller_is_currently_prompting (self);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		ApplicationAccountContext* _tmp4_;
		_tmp4_ = context;
		application_controller_prompt_for_password (self, _tmp4_, service, NULL, NULL);
	}
	_g_object_unref0 (context);
}

static void
application_controller_on_untrusted_host (ApplicationController* self,
                                          GearyAccountInformation* account,
                                          GearyServiceInformation* service,
                                          GearyEndpoint* endpoint,
                                          GTlsConnection* cx)
{
	ApplicationAccountContext* context = NULL;
	GeeMap* _tmp0_;
	gpointer _tmp1_;
	gboolean _tmp2_ = FALSE;
	ApplicationAccountContext* _tmp3_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT_INFORMATION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (service, GEARY_TYPE_SERVICE_INFORMATION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (endpoint, GEARY_TYPE_ENDPOINT));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cx, g_tls_connection_get_type ()));
	_tmp0_ = self->priv->accounts;
	_tmp1_ = gee_map_get (_tmp0_, account);
	context = (ApplicationAccountContext*) _tmp1_;
	_tmp3_ = context;
	if (_tmp3_ != NULL) {
		_tmp2_ = !application_controller_is_currently_prompting (self);
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		ApplicationAccountContext* _tmp4_;
		_tmp4_ = context;
		application_controller_prompt_untrusted_host (self, _tmp4_, service, endpoint, cx, NULL, NULL);
	}
	_g_object_unref0 (context);
}

static void
application_controller_on_retry_service_problem (ApplicationController* self,
                                                 GearyClientServiceStatus type)
{
	gboolean has_restarted = FALSE;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	has_restarted = FALSE;
	{
		GeeIterator* _context_it = NULL;
		GeeMap* _tmp0_;
		GeeCollection* _tmp1_;
		GeeCollection* _tmp2_;
		GeeCollection* _tmp3_;
		GeeIterator* _tmp4_;
		GeeIterator* _tmp5_;
		_tmp0_ = self->priv->accounts;
		_tmp1_ = gee_map_get_values (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = _tmp2_;
		_tmp4_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEE_TYPE_ITERABLE, GeeIterable));
		_tmp5_ = _tmp4_;
		_g_object_unref0 (_tmp3_);
		_context_it = _tmp5_;
		while (TRUE) {
			GeeIterator* _tmp6_;
			ApplicationAccountContext* context = NULL;
			GeeIterator* _tmp7_;
			gpointer _tmp8_;
			GearyAccount* account = NULL;
			ApplicationAccountContext* _tmp9_;
			GearyAccount* _tmp10_;
			GearyAccount* _tmp11_;
			GearyAccount* _tmp12_;
			gboolean _tmp13_ = FALSE;
			GearyAccount* _tmp14_;
			GearyAccountStatus _tmp15_;
			GearyAccountStatus _tmp16_;
			_tmp6_ = _context_it;
			if (!gee_iterator_next (_tmp6_)) {
				break;
			}
			_tmp7_ = _context_it;
			_tmp8_ = gee_iterator_get (_tmp7_);
			context = (ApplicationAccountContext*) _tmp8_;
			_tmp9_ = context;
			_tmp10_ = application_account_context_get_account (_tmp9_);
			_tmp11_ = _tmp10_;
			_tmp12_ = _g_object_ref0 (_tmp11_);
			account = _tmp12_;
			_tmp14_ = account;
			_tmp15_ = geary_account_get_current_status (_tmp14_);
			_tmp16_ = _tmp15_;
			if (geary_account_status_has_service_problem (_tmp16_)) {
				gboolean _tmp17_ = FALSE;
				GearyAccount* _tmp18_;
				GearyClientService* _tmp19_;
				GearyClientService* _tmp20_;
				GearyClientServiceStatus _tmp21_;
				GearyClientServiceStatus _tmp22_;
				_tmp18_ = account;
				_tmp19_ = geary_account_get_incoming (_tmp18_);
				_tmp20_ = _tmp19_;
				_tmp21_ = geary_client_service_get_current_status (_tmp20_);
				_tmp22_ = _tmp21_;
				if (_tmp22_ == type) {
					_tmp17_ = TRUE;
				} else {
					GearyAccount* _tmp23_;
					GearyClientService* _tmp24_;
					GearyClientService* _tmp25_;
					GearyClientServiceStatus _tmp26_;
					GearyClientServiceStatus _tmp27_;
					_tmp23_ = account;
					_tmp24_ = geary_account_get_outgoing (_tmp23_);
					_tmp25_ = _tmp24_;
					_tmp26_ = geary_client_service_get_current_status (_tmp25_);
					_tmp27_ = _tmp26_;
					_tmp17_ = _tmp27_ == type;
				}
				_tmp13_ = _tmp17_;
			} else {
				_tmp13_ = FALSE;
			}
			if (_tmp13_) {
				GearyClientService* _tmp28_ = NULL;
				GearyAccount* _tmp29_;
				GearyClientService* _tmp30_;
				GearyClientService* _tmp31_;
				GearyClientServiceStatus _tmp32_;
				GearyClientServiceStatus _tmp33_;
				GearyClientService* service = NULL;
				GearyClientService* _tmp40_;
				gboolean do_restart = FALSE;
				_tmp29_ = account;
				_tmp30_ = geary_account_get_incoming (_tmp29_);
				_tmp31_ = _tmp30_;
				_tmp32_ = geary_client_service_get_current_status (_tmp31_);
				_tmp33_ = _tmp32_;
				if (_tmp33_ == type) {
					GearyAccount* _tmp34_;
					GearyClientService* _tmp35_;
					GearyClientService* _tmp36_;
					_tmp34_ = account;
					_tmp35_ = geary_account_get_incoming (_tmp34_);
					_tmp36_ = _tmp35_;
					_tmp28_ = _tmp36_;
				} else {
					GearyAccount* _tmp37_;
					GearyClientService* _tmp38_;
					GearyClientService* _tmp39_;
					_tmp37_ = account;
					_tmp38_ = geary_account_get_outgoing (_tmp37_);
					_tmp39_ = _tmp38_;
					_tmp28_ = _tmp39_;
				}
				_tmp40_ = _g_object_ref0 (_tmp28_);
				service = _tmp40_;
				do_restart = TRUE;
				switch (type) {
					case GEARY_CLIENT_SERVICE_STATUS_AUTHENTICATION_FAILED:
					{
						if (has_restarted) {
							do_restart = FALSE;
						} else {
							ApplicationAccountContext* _tmp41_;
							_tmp41_ = context;
							application_account_context_set_authentication_failed (_tmp41_, FALSE);
						}
						break;
					}
					case GEARY_CLIENT_SERVICE_STATUS_TLS_VALIDATION_FAILED:
					{
						if (has_restarted) {
							do_restart = FALSE;
						} else {
							ApplicationAccountContext* _tmp42_;
							_tmp42_ = context;
							application_account_context_set_tls_validation_failed (_tmp42_, FALSE);
						}
						break;
					}
					default:
					{
						break;
					}
				}
				if (do_restart) {
					GearyClientService* _tmp43_;
					ApplicationAccountContext* _tmp44_;
					GCancellable* _tmp45_;
					GCancellable* _tmp46_;
					has_restarted = TRUE;
					_tmp43_ = service;
					_tmp44_ = context;
					_tmp45_ = application_account_context_get_cancellable (_tmp44_);
					_tmp46_ = _tmp45_;
					geary_client_service_restart (_tmp43_, _tmp46_, NULL, NULL);
				}
				_g_object_unref0 (service);
			}
			_g_object_unref0 (account);
			_g_object_unref0 (context);
		}
		_g_object_unref0 (_context_it);
	}
}

static void
application_controller_on_unfocused_idle (ApplicationController* self)
{
	GearyTimeoutManager* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	_tmp0_ = self->priv->all_windows_backgrounded_timeout;
	geary_timeout_manager_reset (_tmp0_);
	application_controller_window_focus_out (self);
	_tmp1_ = self->priv->storage_cleanup_cancellable;
	if (_tmp1_ == NULL) {
		application_controller_do_background_storage_cleanup (self, NULL, NULL);
	}
}

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

static void
application_controller_do_background_storage_cleanup (ApplicationController* self,
                                                      GAsyncReadyCallback _callback_,
                                                      gpointer _user_data_)
{
	ApplicationControllerDoBackgroundStorageCleanupData* _data_;
	ApplicationController* _tmp0_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER (self));
	_data_ = g_slice_new0 (ApplicationControllerDoBackgroundStorageCleanupData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_do_background_storage_cleanup_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	application_controller_do_background_storage_cleanup_co (_data_);
}

static void
application_controller_do_background_storage_cleanup_finish (ApplicationController* self,
                                                             GAsyncResult* _res_)
{
	ApplicationControllerDoBackgroundStorageCleanupData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
application_controller_do_background_storage_cleanup_ready (GObject* source_object,
                                                            GAsyncResult* _res_,
                                                            gpointer _user_data_)
{
	ApplicationControllerDoBackgroundStorageCleanupData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_do_background_storage_cleanup_co (_data_);
}

static gboolean
application_controller_do_background_storage_cleanup_co (ApplicationControllerDoBackgroundStorageCleanupData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	g_debug ("application-controller.vala:1687: Checking for backgrounded idle work");
	_data_->_tmp0_ = g_cancellable_new ();
	_g_object_unref0 (_data_->self->priv->storage_cleanup_cancellable);
	_data_->self->priv->storage_cleanup_cancellable = _data_->_tmp0_;
	{
		_data_->_tmp1_ = _data_->self->priv->accounts;
		_data_->_tmp2_ = gee_map_get_values (_data_->_tmp1_);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, GEE_TYPE_ITERABLE, GeeIterable));
		_data_->_tmp6_ = _data_->_tmp5_;
		_g_object_unref0 (_data_->_tmp4_);
		_data_->_context_it = _data_->_tmp6_;
		while (TRUE) {
			_data_->_tmp7_ = _data_->_context_it;
			if (!gee_iterator_next (_data_->_tmp7_)) {
				break;
			}
			_data_->_tmp8_ = _data_->_context_it;
			_data_->_tmp9_ = gee_iterator_get (_data_->_tmp8_);
			_data_->context = (ApplicationAccountContext*) _data_->_tmp9_;
			_data_->_tmp10_ = _data_->context;
			_data_->_tmp11_ = application_account_context_get_account (_data_->_tmp10_);
			_data_->_tmp12_ = _data_->_tmp11_;
			_data_->_tmp13_ = _g_object_ref0 (_data_->_tmp12_);
			_data_->account = _data_->_tmp13_;
			_data_->_tmp14_ = _data_->context;
			_data_->_tmp15_ = application_account_context_get_cancellable (_data_->_tmp14_);
			_data_->_tmp16_ = _data_->_tmp15_;
			_data_->_tmp17_ = _data_->self->priv->storage_cleanup_cancellable;
			g_signal_connect_object (_data_->_tmp16_, "cancelled", (GCallback) _g_cancellable_cancel_g_cancellable_cancelled, _data_->_tmp17_, 0);
			{
				_data_->_tmp18_ = _data_->account;
				_data_->_tmp19_ = _data_->self->priv->storage_cleanup_cancellable;
				_data_->_state_ = 1;
				geary_account_cleanup_storage (_data_->_tmp18_, _data_->_tmp19_, application_controller_do_background_storage_cleanup_ready, _data_);
				return FALSE;
				_state_1:
				geary_account_cleanup_storage_finish (_data_->_tmp18_, _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_->_tmp20_ = _data_->err;
				_data_->_tmp21_ = geary_problem_report_new (_data_->_tmp20_);
				_data_->_tmp22_ = _data_->_tmp21_;
				composer_application_interface_report_problem (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, COMPOSER_TYPE_APPLICATION_INTERFACE, ComposerApplicationInterface), _data_->_tmp22_);
				_g_object_unref0 (_data_->_tmp22_);
				_g_error_free0 (_data_->err);
			}
			__finally0:
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->account);
				_g_object_unref0 (_data_->context);
				_g_object_unref0 (_data_->_context_it);
				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_->_tmp23_ = _data_->context;
			_data_->_tmp24_ = application_account_context_get_cancellable (_data_->_tmp23_);
			_data_->_tmp25_ = _data_->_tmp24_;
			_data_->_tmp26_ = _data_->self->priv->storage_cleanup_cancellable;
			g_signal_parse_name ("cancelled", g_cancellable_get_type (), &_data_->_tmp27_, NULL, FALSE);
			g_signal_handlers_disconnect_matched (_data_->_tmp25_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp27_, 0, NULL, (GCallback) _g_cancellable_cancel_g_cancellable_cancelled, _data_->_tmp26_);
			_data_->_tmp28_ = _data_->self->priv->storage_cleanup_cancellable;
			if (g_cancellable_is_cancelled (_data_->_tmp28_)) {
				_g_object_unref0 (_data_->account);
				_g_object_unref0 (_data_->context);
				break;
			}
			_g_object_unref0 (_data_->account);
			_g_object_unref0 (_data_->context);
		}
		_g_object_unref0 (_data_->_context_it);
	}
	_g_object_unref0 (_data_->self->priv->storage_cleanup_cancellable);
	_data_->self->priv->storage_cleanup_cancellable = 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
application_controller_class_init (ApplicationControllerClass * klass,
                                   gpointer klass_data)
{
	application_controller_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationController_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_application_controller_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_application_controller_set_property;
	G_OBJECT_CLASS (klass)->finalize = application_controller_finalize;
	/** Determines if the controller is open. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_CONTROLLER_IS_OPEN_PROPERTY, application_controller_properties[APPLICATION_CONTROLLER_IS_OPEN_PROPERTY] = g_param_spec_boolean ("is-open", "is-open", "is-open", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** The primary application instance that owns this controller. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_CONTROLLER_APPLICATION_PROPERTY, application_controller_properties[APPLICATION_CONTROLLER_APPLICATION_PROPERTY] = g_param_spec_object ("application", "application", "application", APPLICATION_TYPE_CLIENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Account management for the application. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_CONTROLLER_ACCOUNT_MANAGER_PROPERTY, application_controller_properties[APPLICATION_CONTROLLER_ACCOUNT_MANAGER_PROPERTY] = g_param_spec_object ("account-manager", "account-manager", "account-manager", ACCOUNTS_TYPE_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Plugin manager for the application. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_CONTROLLER_PLUGINS_PROPERTY, application_controller_properties[APPLICATION_CONTROLLER_PLUGINS_PROPERTY] = g_param_spec_object ("plugins", "plugins", "plugins", APPLICATION_TYPE_PLUGIN_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/** Certificate management for the application. */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_CONTROLLER_CERTIFICATE_MANAGER_PROPERTY, application_controller_properties[APPLICATION_CONTROLLER_CERTIFICATE_MANAGER_PROPERTY] = g_param_spec_object ("certificate-manager", "certificate-manager", "certificate-manager", APPLICATION_TYPE_CERTIFICATE_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	     * Emitted when a composer is registered.
	     *
	     * This will be emitted after a composer is constructed, but
	     * before it is shown.
	     */
	application_controller_signals[APPLICATION_CONTROLLER_COMPOSER_REGISTERED_SIGNAL] = g_signal_new ("composer-registered", APPLICATION_TYPE_CONTROLLER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, COMPOSER_TYPE_WIDGET);
	/**
	     * Emitted when a composer is deregistered.
	     *
	     * This will be emitted when a composer has been closed and is
	     * about to be destroyed.
	     */
	application_controller_signals[APPLICATION_CONTROLLER_COMPOSER_DEREGISTERED_SIGNAL] = g_signal_new ("composer-deregistered", APPLICATION_TYPE_CONTROLLER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, COMPOSER_TYPE_WIDGET);
}

static void
application_controller_application_account_interface_interface_init (ApplicationAccountInterfaceIface * iface,
                                                                     gpointer iface_data)
{
	application_controller_application_account_interface_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_context_for_account = (ApplicationAccountContext* (*) (ApplicationAccountInterface*, GearyAccountInformation*)) application_controller_real_get_context_for_account;
	iface->get_account_contexts = (GeeCollection* (*) (ApplicationAccountInterface*)) application_controller_real_get_account_contexts;
}

static void
application_controller_composer_application_interface_interface_init (ComposerApplicationInterfaceIface * iface,
                                                                      gpointer iface_data)
{
	application_controller_composer_application_interface_parent_iface = g_type_interface_peek_parent (iface);
	iface->report_problem = (void (*) (ComposerApplicationInterface*, GearyProblemReport*)) application_controller_real_report_problem;
	iface->send_composed_email = (void (*) (ComposerApplicationInterface*, ComposerWidget*, GAsyncReadyCallback, gpointer)) application_controller_real_send_composed_email;
	iface->send_composed_email_finish = (void (*) (ComposerApplicationInterface*, GAsyncResult*)) application_controller_send_composed_email_finish;
	iface->save_composed_email = (void (*) (ComposerApplicationInterface*, ComposerWidget*, GAsyncReadyCallback, gpointer)) application_controller_real_save_composed_email;
	iface->save_composed_email_finish = (void (*) (ComposerApplicationInterface*, GAsyncResult*)) application_controller_save_composed_email_finish;
	iface->discard_composed_email = (void (*) (ComposerApplicationInterface*, ComposerWidget*, GAsyncReadyCallback, gpointer)) application_controller_real_discard_composed_email;
	iface->discard_composed_email_finish = (void (*) (ComposerApplicationInterface*, GAsyncResult*)) application_controller_discard_composed_email_finish;
}

static void
application_controller_instance_init (ApplicationController * self,
                                      gpointer klass)
{
	GeeHashMap* _tmp0_;
	GeeLinkedList* _tmp1_;
	GeeArrayList* _tmp2_;
	self->priv = application_controller_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (GEARY_TYPE_ACCOUNT_INFORMATION, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, APPLICATION_TYPE_ACCOUNT_CONTEXT, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->accounts = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_MAP, GeeMap);
	self->priv->is_loading_accounts = TRUE;
	_tmp1_ = gee_linked_list_new (COMPOSER_TYPE_WIDGET, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	self->priv->composer_widgets = G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_COLLECTION, GeeCollection);
	_tmp2_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	self->priv->pending_mailtos = G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, GEE_TYPE_LIST, GeeList);
}

static void
application_controller_finalize (GObject * obj)
{
	ApplicationController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	_g_object_unref0 (self->priv->_account_manager);
	_g_object_unref0 (self->priv->_plugins);
	_g_object_unref0 (self->priv->_certificate_manager);
	_g_object_unref0 (self->priv->accounts);
	_g_object_unref0 (self->priv->controller_open);
	_g_object_unref0 (self->priv->database_manager);
	_g_object_unref0 (self->priv->folks);
	_g_object_unref0 (self->priv->composer_widgets);
	_g_object_unref0 (self->priv->pending_mailtos);
	_g_object_unref0 (self->priv->all_windows_backgrounded_timeout);
	_g_object_unref0 (self->priv->storage_cleanup_cancellable);
	G_OBJECT_CLASS (application_controller_parent_class)->finalize (obj);
}

/**
 * Primary controller for an application instance.
 *
 * A single instance of this class is constructed by {@link Client}
 * when the primary application instance is started.
 */
static GType
application_controller_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationControllerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_controller_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationController), 0, (GInstanceInitFunc) application_controller_instance_init, NULL };
	static const GInterfaceInfo application_account_interface_info = { (GInterfaceInitFunc) application_controller_application_account_interface_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo composer_application_interface_info = { (GInterfaceInitFunc) application_controller_composer_application_interface_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType application_controller_type_id;
	application_controller_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "ApplicationController", &g_define_type_info, 0);
	g_type_add_interface_static (application_controller_type_id, APPLICATION_TYPE_ACCOUNT_INTERFACE, &application_account_interface_info);
	g_type_add_interface_static (application_controller_type_id, COMPOSER_TYPE_APPLICATION_INTERFACE, &composer_application_interface_info);
	ApplicationController_private_offset = g_type_add_instance_private (application_controller_type_id, sizeof (ApplicationControllerPrivate));
	return application_controller_type_id;
}

GType
application_controller_get_type (void)
{
	static volatile gsize application_controller_type_id__once = 0;
	if (g_once_init_enter (&application_controller_type_id__once)) {
		GType application_controller_type_id;
		application_controller_type_id = application_controller_get_type_once ();
		g_once_init_leave (&application_controller_type_id__once, application_controller_type_id);
	}
	return application_controller_type_id__once;
}

static void
_vala_application_controller_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	ApplicationController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	switch (property_id) {
		case APPLICATION_CONTROLLER_IS_OPEN_PROPERTY:
		g_value_set_boolean (value, application_controller_get_is_open (self));
		break;
		case APPLICATION_CONTROLLER_APPLICATION_PROPERTY:
		g_value_set_object (value, application_controller_get_application (self));
		break;
		case APPLICATION_CONTROLLER_ACCOUNT_MANAGER_PROPERTY:
		g_value_set_object (value, application_controller_get_account_manager (self));
		break;
		case APPLICATION_CONTROLLER_PLUGINS_PROPERTY:
		g_value_set_object (value, application_controller_get_plugins (self));
		break;
		case APPLICATION_CONTROLLER_CERTIFICATE_MANAGER_PROPERTY:
		g_value_set_object (value, application_controller_get_certificate_manager (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_application_controller_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	ApplicationController * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_CONTROLLER, ApplicationController);
	switch (property_id) {
		case APPLICATION_CONTROLLER_APPLICATION_PROPERTY:
		application_controller_set_application (self, g_value_get_object (value));
		break;
		case APPLICATION_CONTROLLER_ACCOUNT_MANAGER_PROPERTY:
		application_controller_set_account_manager (self, g_value_get_object (value));
		break;
		case APPLICATION_CONTROLLER_PLUGINS_PROPERTY:
		application_controller_set_plugins (self, g_value_get_object (value));
		break;
		case APPLICATION_CONTROLLER_CERTIFICATE_MANAGER_PROPERTY:
		application_controller_set_certificate_manager (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_controller_command_stack_get_instance_private (ApplicationControllerCommandStack* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationControllerCommandStack_private_offset);
}

static void
__lambda4_ (ApplicationControllerCommandStack* self)
{
	_g_object_unref0 (self->priv->last_executed);
	self->priv->last_executed = NULL;
}

static void
___lambda4__geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                gpointer self)
{
	__lambda4_ ((ApplicationControllerCommandStack*) self);
}

ApplicationControllerCommandStack*
application_controller_command_stack_construct (GType object_type)
{
	ApplicationControllerCommandStack * self = NULL;
	GearyTimeoutManager* _tmp0_;
	self = (ApplicationControllerCommandStack*) application_command_stack_construct (object_type);
	_tmp0_ = geary_timeout_manager_new_milliseconds ((guint) 250, ___lambda4__geary_timeout_manager_timeout_func, self);
	_g_object_unref0 (self->priv->last_executed_timeout);
	self->priv->last_executed_timeout = _tmp0_;
	return self;
}

ApplicationControllerCommandStack*
application_controller_command_stack_new (void)
{
	return application_controller_command_stack_construct (APPLICATION_TYPE_CONTROLLER_COMMAND_STACK);
}

static void
application_controller_command_stack_real_execute_data_free (gpointer _data)
{
	ApplicationControllerCommandStackExecuteData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->target);
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerCommandStackExecuteData, _data_);
}

static void
application_controller_command_stack_real_execute (ApplicationCommandStack* base,
                                                   ApplicationCommand* target,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	ApplicationControllerCommandStack * self;
	ApplicationControllerCommandStackExecuteData* _data_;
	ApplicationControllerCommandStack* _tmp0_;
	ApplicationCommand* _tmp1_;
	GCancellable* _tmp2_;
	g_return_if_fail (APPLICATION_IS_COMMAND (target));
	g_return_if_fail ((cancellable == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_CONTROLLER_COMMAND_STACK, ApplicationControllerCommandStack);
	_data_ = g_slice_new0 (ApplicationControllerCommandStackExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_command_stack_real_execute_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (target);
	_g_object_unref0 (_data_->target);
	_data_->target = _tmp1_;
	_tmp2_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp2_;
	application_controller_command_stack_real_execute_co (_data_);
}

static void
application_controller_command_stack_execute_finish (ApplicationCommandStack* base,
                                                     GAsyncResult* _res_,
                                                     GError** error)
{
	ApplicationControllerCommandStackExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** {@inheritDoc} */
static void
application_controller_command_stack_execute_ready (GObject* source_object,
                                                    GAsyncResult* _res_,
                                                    gpointer _user_data_)
{
	ApplicationControllerCommandStackExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_command_stack_real_execute_co (_data_);
}

static gboolean
application_controller_command_stack_real_execute_co (ApplicationControllerCommandStackExecuteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->last_executed_timeout;
	geary_timeout_manager_reset (_data_->_tmp0_);
	_data_->_tmp2_ = _data_->self->priv->last_executed;
	if (_data_->_tmp2_ == NULL) {
		_data_->_tmp1_ = TRUE;
	} else {
		_data_->_tmp3_ = _data_->self->priv->last_executed;
		_data_->_tmp1_ = !application_command_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, APPLICATION_TYPE_COMMAND, ApplicationCommand), _data_->target);
	}
	if (_data_->_tmp1_) {
		_data_->_tmp4_ = _g_object_ref0 (APPLICATION_IS_EMAIL_COMMAND (_data_->target) ? ((ApplicationEmailCommand*) _data_->target) : NULL);
		_g_object_unref0 (_data_->self->priv->last_executed);
		_data_->self->priv->last_executed = _data_->_tmp4_;
		_data_->_tmp5_ = _data_->self->priv->last_executed_timeout;
		geary_timeout_manager_start (_data_->_tmp5_);
		_data_->_state_ = 1;
		APPLICATION_COMMAND_STACK_CLASS (application_controller_command_stack_parent_class)->execute (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND_STACK, ApplicationCommandStack), _data_->target, _data_->cancellable, application_controller_command_stack_execute_ready, _data_);
		return FALSE;
		_state_1:
		APPLICATION_COMMAND_STACK_CLASS (application_controller_command_stack_parent_class)->execute_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND_STACK, ApplicationCommandStack), _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
application_controller_command_stack_real_undo_data_free (gpointer _data)
{
	ApplicationControllerCommandStackUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerCommandStackUndoData, _data_);
}

static void
application_controller_command_stack_real_undo (ApplicationCommandStack* base,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	ApplicationControllerCommandStack * self;
	ApplicationControllerCommandStackUndoData* _data_;
	ApplicationControllerCommandStack* _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, APPLICATION_TYPE_CONTROLLER_COMMAND_STACK, ApplicationControllerCommandStack);
	_data_ = g_slice_new0 (ApplicationControllerCommandStackUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_command_stack_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_controller_command_stack_real_undo_co (_data_);
}

static void
application_controller_command_stack_undo_finish (ApplicationCommandStack* base,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	ApplicationControllerCommandStackUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** {@inheritDoc} */
static void
application_controller_command_stack_undo_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	ApplicationControllerCommandStackUndoData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_command_stack_real_undo_co (_data_);
}

static gboolean
application_controller_command_stack_real_undo_co (ApplicationControllerCommandStackUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_g_object_unref0 (_data_->self->priv->last_executed);
	_data_->self->priv->last_executed = NULL;
	_data_->_state_ = 1;
	APPLICATION_COMMAND_STACK_CLASS (application_controller_command_stack_parent_class)->undo (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND_STACK, ApplicationCommandStack), _data_->cancellable, application_controller_command_stack_undo_ready, _data_);
	return FALSE;
	_state_1:
	APPLICATION_COMMAND_STACK_CLASS (application_controller_command_stack_parent_class)->undo_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND_STACK, ApplicationCommandStack), _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
application_controller_command_stack_real_redo_data_free (gpointer _data)
{
	ApplicationControllerCommandStackRedoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationControllerCommandStackRedoData, _data_);
}

static void
application_controller_command_stack_real_redo (ApplicationCommandStack* base,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	ApplicationControllerCommandStack * self;
	ApplicationControllerCommandStackRedoData* _data_;
	ApplicationControllerCommandStack* _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, APPLICATION_TYPE_CONTROLLER_COMMAND_STACK, ApplicationControllerCommandStack);
	_data_ = g_slice_new0 (ApplicationControllerCommandStackRedoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_controller_command_stack_real_redo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_controller_command_stack_real_redo_co (_data_);
}

static void
application_controller_command_stack_redo_finish (ApplicationCommandStack* base,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	ApplicationControllerCommandStackRedoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

/** {@inheritDoc} */
static void
application_controller_command_stack_redo_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	ApplicationControllerCommandStackRedoData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_controller_command_stack_real_redo_co (_data_);
}

static gboolean
application_controller_command_stack_real_redo_co (ApplicationControllerCommandStackRedoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_g_object_unref0 (_data_->self->priv->last_executed);
	_data_->self->priv->last_executed = NULL;
	_data_->_state_ = 1;
	APPLICATION_COMMAND_STACK_CLASS (application_controller_command_stack_parent_class)->redo (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND_STACK, ApplicationCommandStack), _data_->cancellable, application_controller_command_stack_redo_ready, _data_);
	return FALSE;
	_state_1:
	APPLICATION_COMMAND_STACK_CLASS (application_controller_command_stack_parent_class)->redo_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND_STACK, ApplicationCommandStack), _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;
}

/**
     * Notifies the stack that one or more folders were removed.
     *
     * This will cause any commands involving the given folder to be
     * removed from the stack. It should only be called as a response
     * to un-recoverable changes, e.g. when the server notifies that a
     * folder has been removed.
     */
void
application_controller_command_stack_folders_removed (ApplicationControllerCommandStack* self,
                                                      GeeCollection* removed)
{
	GeeIterator* commands = NULL;
	GeeDeque* _tmp0_;
	GeeIterator* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER_COMMAND_STACK (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND_STACK, ApplicationCommandStack)->undo_stack;
	_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ITERABLE, GeeIterable));
	commands = _tmp1_;
	while (TRUE) {
		GeeIterator* _tmp2_;
		ApplicationEmailCommand* email = NULL;
		GeeIterator* _tmp3_;
		gpointer _tmp4_;
		ApplicationCommand* _tmp5_;
		ApplicationEmailCommand* _tmp6_;
		ApplicationEmailCommand* _tmp7_;
		_tmp2_ = commands;
		if (!gee_iterator_next (_tmp2_)) {
			break;
		}
		_tmp3_ = commands;
		_tmp4_ = gee_iterator_get (_tmp3_);
		_tmp5_ = (ApplicationCommand*) _tmp4_;
		_tmp6_ = APPLICATION_IS_EMAIL_COMMAND (_tmp5_) ? ((ApplicationEmailCommand*) _tmp5_) : NULL;
		if (_tmp6_ == NULL) {
			_g_object_unref0 (_tmp5_);
		}
		email = _tmp6_;
		_tmp7_ = email;
		if (_tmp7_ != NULL) {
			ApplicationEmailCommand* _tmp8_;
			_tmp8_ = email;
			if (application_email_command_folders_removed (_tmp8_, removed) == APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE) {
				GeeIterator* _tmp9_;
				_tmp9_ = commands;
				gee_iterator_remove (_tmp9_);
			}
		}
		_g_object_unref0 (email);
	}
	_g_object_unref0 (commands);
}

/**
     * Notifies the stack that email was removed from a folder.
     *
     * This will cause any commands involving the given email
     * identifiers to be removed from commands where they are present,
     * potentially also causing the command to be removed from the
     * stack. It should only be called as a response to un-recoverable
     * changes, e.g. when the server notifies that an email has been
     * removed as a result of some other client removing it, or the
     * message being deleted completely.
     */
void
application_controller_command_stack_email_removed (ApplicationControllerCommandStack* self,
                                                    GearyFolder* location,
                                                    GeeCollection* targets)
{
	GeeIterator* commands = NULL;
	GeeDeque* _tmp0_;
	GeeIterator* _tmp1_;
	g_return_if_fail (APPLICATION_IS_CONTROLLER_COMMAND_STACK (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (targets, GEE_TYPE_COLLECTION));
	_tmp0_ = G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND_STACK, ApplicationCommandStack)->undo_stack;
	_tmp1_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_ITERABLE, GeeIterable));
	commands = _tmp1_;
	while (TRUE) {
		GeeIterator* _tmp2_;
		ApplicationEmailCommand* email = NULL;
		GeeIterator* _tmp3_;
		gpointer _tmp4_;
		ApplicationCommand* _tmp5_;
		ApplicationEmailCommand* _tmp6_;
		ApplicationEmailCommand* _tmp7_;
		_tmp2_ = commands;
		if (!gee_iterator_next (_tmp2_)) {
			break;
		}
		_tmp3_ = commands;
		_tmp4_ = gee_iterator_get (_tmp3_);
		_tmp5_ = (ApplicationCommand*) _tmp4_;
		_tmp6_ = APPLICATION_IS_EMAIL_COMMAND (_tmp5_) ? ((ApplicationEmailCommand*) _tmp5_) : NULL;
		if (_tmp6_ == NULL) {
			_g_object_unref0 (_tmp5_);
		}
		email = _tmp6_;
		_tmp7_ = email;
		if (_tmp7_ != NULL) {
			ApplicationEmailCommand* _tmp8_;
			_tmp8_ = email;
			if (application_email_command_email_removed (_tmp8_, location, targets) == APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE) {
				GeeIterator* _tmp9_;
				_tmp9_ = commands;
				gee_iterator_remove (_tmp9_);
			}
		}
		_g_object_unref0 (email);
	}
	_g_object_unref0 (commands);
}

static void
application_controller_command_stack_class_init (ApplicationControllerCommandStackClass * klass,
                                                 gpointer klass_data)
{
	application_controller_command_stack_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationControllerCommandStack_private_offset);
	((ApplicationCommandStackClass *) klass)->execute = (void (*) (ApplicationCommandStack*, ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_controller_command_stack_real_execute;
	((ApplicationCommandStackClass *) klass)->execute_finish = (void (*) (ApplicationCommandStack*, GAsyncResult*, GError**)) application_controller_command_stack_execute_finish;
	((ApplicationCommandStackClass *) klass)->undo = (void (*) (ApplicationCommandStack*, GCancellable*, GAsyncReadyCallback, gpointer)) application_controller_command_stack_real_undo;
	((ApplicationCommandStackClass *) klass)->undo_finish = (void (*) (ApplicationCommandStack*, GAsyncResult*, GError**)) application_controller_command_stack_undo_finish;
	((ApplicationCommandStackClass *) klass)->redo = (void (*) (ApplicationCommandStack*, GCancellable*, GAsyncReadyCallback, gpointer)) application_controller_command_stack_real_redo;
	((ApplicationCommandStackClass *) klass)->redo_finish = (void (*) (ApplicationCommandStack*, GAsyncResult*, GError**)) application_controller_command_stack_redo_finish;
	G_OBJECT_CLASS (klass)->finalize = application_controller_command_stack_finalize;
}

static void
application_controller_command_stack_instance_init (ApplicationControllerCommandStack * self,
                                                    gpointer klass)
{
	self->priv = application_controller_command_stack_get_instance_private (self);
	self->priv->last_executed = NULL;
}

static void
application_controller_command_stack_finalize (GObject * obj)
{
	ApplicationControllerCommandStack * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_CONTROLLER_COMMAND_STACK, ApplicationControllerCommandStack);
	_g_object_unref0 (self->priv->last_executed);
	_g_object_unref0 (self->priv->last_executed_timeout);
	G_OBJECT_CLASS (application_controller_command_stack_parent_class)->finalize (obj);
}

/** Base class for all application controller commands. */
static GType
application_controller_command_stack_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationControllerCommandStackClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_controller_command_stack_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationControllerCommandStack), 0, (GInstanceInitFunc) application_controller_command_stack_instance_init, NULL };
	GType application_controller_command_stack_type_id;
	application_controller_command_stack_type_id = g_type_register_static (APPLICATION_TYPE_COMMAND_STACK, "ApplicationControllerCommandStack", &g_define_type_info, 0);
	ApplicationControllerCommandStack_private_offset = g_type_add_instance_private (application_controller_command_stack_type_id, sizeof (ApplicationControllerCommandStackPrivate));
	return application_controller_command_stack_type_id;
}

GType
application_controller_command_stack_get_type (void)
{
	static volatile gsize application_controller_command_stack_type_id__once = 0;
	if (g_once_init_enter (&application_controller_command_stack_type_id__once)) {
		GType application_controller_command_stack_type_id;
		application_controller_command_stack_type_id = application_controller_command_stack_get_type_once ();
		g_once_init_leave (&application_controller_command_stack_type_id__once, application_controller_command_stack_type_id);
	}
	return application_controller_command_stack_type_id__once;
}

static inline gpointer
application_email_command_get_instance_private (ApplicationEmailCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationEmailCommand_private_offset);
}

/** Specifies a command's response to external mail state changes. */
static GType
application_email_command_state_change_policy_get_type_once (void)
{
	static const GEnumValue values[] = {{APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_IGNORE, "APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_IGNORE", "ignore"}, {APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE, "APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE", "remove"}, {0, NULL, NULL}};
	GType application_email_command_state_change_policy_type_id;
	application_email_command_state_change_policy_type_id = g_enum_register_static ("ApplicationEmailCommandStateChangePolicy", values);
	return application_email_command_state_change_policy_type_id;
}

GType
application_email_command_state_change_policy_get_type (void)
{
	static volatile gsize application_email_command_state_change_policy_type_id__once = 0;
	if (g_once_init_enter (&application_email_command_state_change_policy_type_id__once)) {
		GType application_email_command_state_change_policy_type_id;
		application_email_command_state_change_policy_type_id = application_email_command_state_change_policy_get_type_once ();
		g_once_init_leave (&application_email_command_state_change_policy_type_id__once, application_email_command_state_change_policy_type_id);
	}
	return application_email_command_state_change_policy_type_id__once;
}

GearyFolder*
application_email_command_get_location (ApplicationEmailCommand* self)
{
	GearyFolder* result;
	GearyFolder* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_EMAIL_COMMAND (self), NULL);
	_tmp0_ = self->priv->_location;
	result = _tmp0_;
	return result;
}

void
application_email_command_set_location (ApplicationEmailCommand* self,
                                        GearyFolder* value)
{
	GearyFolder* old_value;
	g_return_if_fail (APPLICATION_IS_EMAIL_COMMAND (self));
	old_value = application_email_command_get_location (self);
	if (old_value != value) {
		GearyFolder* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_location);
		self->priv->_location = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_email_command_properties[APPLICATION_EMAIL_COMMAND_LOCATION_PROPERTY]);
	}
}

GeeCollection*
application_email_command_get_conversations (ApplicationEmailCommand* self)
{
	GeeCollection* result;
	GeeCollection* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_EMAIL_COMMAND (self), NULL);
	_tmp0_ = self->priv->_conversations;
	result = _tmp0_;
	return result;
}

static void
application_email_command_set_conversations (ApplicationEmailCommand* self,
                                             GeeCollection* value)
{
	GeeCollection* old_value;
	g_return_if_fail (APPLICATION_IS_EMAIL_COMMAND (self));
	old_value = application_email_command_get_conversations (self);
	if (old_value != value) {
		GeeCollection* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_conversations);
		self->priv->_conversations = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_email_command_properties[APPLICATION_EMAIL_COMMAND_CONVERSATIONS_PROPERTY]);
	}
}

GeeCollection*
application_email_command_get_email (ApplicationEmailCommand* self)
{
	GeeCollection* result;
	GeeCollection* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_EMAIL_COMMAND (self), NULL);
	_tmp0_ = self->priv->_email;
	result = _tmp0_;
	return result;
}

static void
application_email_command_set_email (ApplicationEmailCommand* self,
                                     GeeCollection* value)
{
	GeeCollection* old_value;
	g_return_if_fail (APPLICATION_IS_EMAIL_COMMAND (self));
	old_value = application_email_command_get_email (self);
	if (old_value != value) {
		GeeCollection* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_email);
		self->priv->_email = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_email_command_properties[APPLICATION_EMAIL_COMMAND_EMAIL_PROPERTY]);
	}
}

ApplicationEmailCommand*
application_email_command_construct (GType object_type,
                                     GearyFolder* location,
                                     GeeCollection* conversations,
                                     GeeCollection* email)
{
	ApplicationEmailCommand * self = NULL;
	GeeCollection* _tmp0_;
	GeeCollection* _tmp1_;
	GeeCollection* _tmp2_;
	GeeCollection* _tmp3_;
	GeeCollection* _tmp4_;
	GeeCollection* _tmp5_;
	GeeCollection* _tmp6_;
	GeeCollection* _tmp7_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email, GEE_TYPE_COLLECTION), NULL);
	self = (ApplicationEmailCommand*) application_command_construct (object_type);
	application_email_command_set_location (self, location);
	_tmp0_ = gee_collection_get_read_only_view (conversations);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	application_email_command_set_conversations (self, _tmp2_);
	_g_object_unref0 (_tmp2_);
	_tmp3_ = gee_collection_get_read_only_view (email);
	_tmp4_ = _tmp3_;
	_tmp5_ = _tmp4_;
	application_email_command_set_email (self, _tmp5_);
	_g_object_unref0 (_tmp5_);
	_tmp6_ = _g_object_ref0 (conversations);
	_g_object_unref0 (self->priv->mutable_conversations);
	self->priv->mutable_conversations = _tmp6_;
	_tmp7_ = _g_object_ref0 (email);
	_g_object_unref0 (self->priv->mutable_email);
	self->priv->mutable_email = _tmp7_;
	return self;
}

static gboolean
application_email_command_real_equal_to (ApplicationCommand* base,
                                         ApplicationCommand* other)
{
	ApplicationEmailCommand * self;
	ApplicationEmailCommand* other_email = NULL;
	ApplicationEmailCommand* _tmp0_;
	ApplicationEmailCommand* _tmp1_;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	GearyFolder* _tmp6_;
	ApplicationEmailCommand* _tmp7_;
	GearyFolder* _tmp8_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand);
	g_return_val_if_fail (APPLICATION_IS_COMMAND (other), FALSE);
	if (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand) == other) {
		result = TRUE;
		return result;
	}
	if (G_TYPE_FROM_INSTANCE (G_TYPE_CHECK_INSTANCE_CAST (self, G_TYPE_OBJECT, GObject)) != G_TYPE_FROM_INSTANCE (G_TYPE_CHECK_INSTANCE_CAST (other, G_TYPE_OBJECT, GObject))) {
		result = FALSE;
		return result;
	}
	_tmp0_ = _g_object_ref0 (APPLICATION_IS_EMAIL_COMMAND (other) ? ((ApplicationEmailCommand*) other) : NULL);
	other_email = _tmp0_;
	_tmp1_ = other_email;
	if (_tmp1_ == NULL) {
		result = FALSE;
		_g_object_unref0 (other_email);
		return result;
	}
	_tmp6_ = self->priv->_location;
	_tmp7_ = other_email;
	_tmp8_ = _tmp7_->priv->_location;
	if (_tmp6_ == _tmp8_) {
		GeeCollection* _tmp9_;
		gint _tmp10_;
		gint _tmp11_;
		ApplicationEmailCommand* _tmp12_;
		GeeCollection* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		_tmp9_ = self->priv->_conversations;
		_tmp10_ = gee_collection_get_size (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = other_email;
		_tmp13_ = _tmp12_->priv->_conversations;
		_tmp14_ = gee_collection_get_size (_tmp13_);
		_tmp15_ = _tmp14_;
		_tmp5_ = _tmp11_ == _tmp15_;
	} else {
		_tmp5_ = FALSE;
	}
	if (_tmp5_) {
		GeeCollection* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		ApplicationEmailCommand* _tmp19_;
		GeeCollection* _tmp20_;
		gint _tmp21_;
		gint _tmp22_;
		_tmp16_ = self->priv->_email;
		_tmp17_ = gee_collection_get_size (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = other_email;
		_tmp20_ = _tmp19_->priv->_email;
		_tmp21_ = gee_collection_get_size (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp4_ = _tmp18_ == _tmp22_;
	} else {
		_tmp4_ = FALSE;
	}
	if (_tmp4_) {
		GeeCollection* _tmp23_;
		ApplicationEmailCommand* _tmp24_;
		GeeCollection* _tmp25_;
		_tmp23_ = self->priv->_conversations;
		_tmp24_ = other_email;
		_tmp25_ = _tmp24_->priv->_conversations;
		_tmp3_ = gee_collection_contains_all (_tmp23_, _tmp25_);
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		GeeCollection* _tmp26_;
		ApplicationEmailCommand* _tmp27_;
		GeeCollection* _tmp28_;
		_tmp26_ = self->priv->_email;
		_tmp27_ = other_email;
		_tmp28_ = _tmp27_->priv->_email;
		_tmp2_ = gee_collection_contains_all (_tmp26_, _tmp28_);
	} else {
		_tmp2_ = FALSE;
	}
	result = _tmp2_;
	_g_object_unref0 (other_email);
	return result;
}

/**
     * Determines the command's response when a folder is removed.
     *
     * This is called when some external means (such as another
     * command, or another email client altogether) has caused a
     * folder to be removed.
     *
     * The returned policy will determine if the command is unaffected
     * by the change and hence can remain on the stack, or is no
     * longer valid and hence must be removed.
     */
static ApplicationEmailCommandStateChangePolicy
application_email_command_real_folders_removed (ApplicationEmailCommand* self,
                                                GeeCollection* removed)
{
	ApplicationEmailCommandStateChangePolicy _tmp0_ = 0;
	GearyFolder* _tmp1_;
	ApplicationEmailCommandStateChangePolicy result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION), 0);
	_tmp1_ = self->priv->_location;
	if (gee_collection_contains (removed, _tmp1_)) {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE;
	} else {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_IGNORE;
	}
	result = _tmp0_;
	return result;
}

ApplicationEmailCommandStateChangePolicy
application_email_command_folders_removed (ApplicationEmailCommand* self,
                                           GeeCollection* removed)
{
	ApplicationEmailCommandClass* _klass_;
	g_return_val_if_fail (APPLICATION_IS_EMAIL_COMMAND (self), 0);
	_klass_ = APPLICATION_EMAIL_COMMAND_GET_CLASS (self);
	if (_klass_->folders_removed) {
		return _klass_->folders_removed (self, removed);
	}
	return 0;
}

/**
     * Determines the command's response when email is removed.
     *
     * This is called when some external means (such as another
     * command, or another email client altogether) has caused a
     * email in a folder to be removed.
     *
     * The returned policy will determine if the command is unaffected
     * by the change and hence can remain on the stack, or is no
     * longer valid and hence must be removed.
     */
static ApplicationEmailCommandStateChangePolicy
application_email_command_real_email_removed (ApplicationEmailCommand* self,
                                              GearyFolder* location,
                                              GeeCollection* targets)
{
	ApplicationEmailCommandStateChangePolicy ret = 0;
	GearyFolder* _tmp0_;
	ApplicationEmailCommandStateChangePolicy result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER), 0);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (targets, GEE_TYPE_COLLECTION), 0);
	ret = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_IGNORE;
	_tmp0_ = self->priv->_location;
	if (_tmp0_ == location) {
		GeeIterator* conversations = NULL;
		GeeCollection* _tmp1_;
		GeeIterator* _tmp2_;
		GeeCollection* _tmp8_;
		gboolean _tmp9_ = FALSE;
		GeeCollection* _tmp10_;
		gboolean _tmp11_;
		gboolean _tmp12_;
		_tmp1_ = self->priv->mutable_conversations;
		_tmp2_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ITERABLE, GeeIterable));
		conversations = _tmp2_;
		while (TRUE) {
			GeeIterator* _tmp3_;
			GearyAppConversation* conversation = NULL;
			GeeIterator* _tmp4_;
			gpointer _tmp5_;
			GearyAppConversation* _tmp6_;
			_tmp3_ = conversations;
			if (!gee_iterator_next (_tmp3_)) {
				break;
			}
			_tmp4_ = conversations;
			_tmp5_ = gee_iterator_get (_tmp4_);
			conversation = (GearyAppConversation*) _tmp5_;
			_tmp6_ = conversation;
			if (!geary_app_conversation_has_any_non_deleted_email (_tmp6_)) {
				GeeIterator* _tmp7_;
				_tmp7_ = conversations;
				gee_iterator_remove (_tmp7_);
			}
			_g_object_unref0 (conversation);
		}
		_tmp8_ = self->priv->mutable_email;
		gee_collection_remove_all (_tmp8_, targets);
		_tmp10_ = self->priv->mutable_conversations;
		_tmp11_ = gee_collection_get_is_empty (_tmp10_);
		_tmp12_ = _tmp11_;
		if (_tmp12_) {
			_tmp9_ = TRUE;
		} else {
			GeeCollection* _tmp13_;
			gboolean _tmp14_;
			gboolean _tmp15_;
			_tmp13_ = self->priv->mutable_email;
			_tmp14_ = gee_collection_get_is_empty (_tmp13_);
			_tmp15_ = _tmp14_;
			_tmp9_ = _tmp15_;
		}
		if (_tmp9_) {
			ret = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE;
		}
		_g_object_unref0 (conversations);
	}
	result = ret;
	return result;
}

ApplicationEmailCommandStateChangePolicy
application_email_command_email_removed (ApplicationEmailCommand* self,
                                         GearyFolder* location,
                                         GeeCollection* targets)
{
	ApplicationEmailCommandClass* _klass_;
	g_return_val_if_fail (APPLICATION_IS_EMAIL_COMMAND (self), 0);
	_klass_ = APPLICATION_EMAIL_COMMAND_GET_CLASS (self);
	if (_klass_->email_removed) {
		return _klass_->email_removed (self, location, targets);
	}
	return 0;
}

static void
application_email_command_class_init (ApplicationEmailCommandClass * klass,
                                      gpointer klass_data)
{
	application_email_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationEmailCommand_private_offset);
	((ApplicationCommandClass *) klass)->equal_to = (gboolean (*) (ApplicationCommand*, ApplicationCommand*)) application_email_command_real_equal_to;
	((ApplicationEmailCommandClass *) klass)->folders_removed = (ApplicationEmailCommandStateChangePolicy (*) (ApplicationEmailCommand*, GeeCollection*)) application_email_command_real_folders_removed;
	((ApplicationEmailCommandClass *) klass)->email_removed = (ApplicationEmailCommandStateChangePolicy (*) (ApplicationEmailCommand*, GearyFolder*, GeeCollection*)) application_email_command_real_email_removed;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_email_command_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_application_email_command_set_property;
	G_OBJECT_CLASS (klass)->finalize = application_email_command_finalize;
	/**
	     * Returns the folder where the command was initially executed.
	     *
	     * This is used by the main window to return to the folder where
	     * the command was first carried out.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_EMAIL_COMMAND_LOCATION_PROPERTY, application_email_command_properties[APPLICATION_EMAIL_COMMAND_LOCATION_PROPERTY] = g_param_spec_object ("location", "location", "location", GEARY_TYPE_FOLDER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/**
	     * Returns the conversations which the command was initially applied to.
	     *
	     * This is used by the main window to return to the conversation where
	     * the command was first carried out.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_EMAIL_COMMAND_CONVERSATIONS_PROPERTY, application_email_command_properties[APPLICATION_EMAIL_COMMAND_CONVERSATIONS_PROPERTY] = g_param_spec_object ("conversations", "conversations", "conversations", GEE_TYPE_COLLECTION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	/**
	     * Returns the email which the command was initially applied to.
	     *
	     * This is used by the main window to return to the conversation where
	     * the command was first carried out.
	     */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_EMAIL_COMMAND_EMAIL_PROPERTY, application_email_command_properties[APPLICATION_EMAIL_COMMAND_EMAIL_PROPERTY] = g_param_spec_object ("email", "email", "email", GEE_TYPE_COLLECTION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_email_command_instance_init (ApplicationEmailCommand * self,
                                         gpointer klass)
{
	self->priv = application_email_command_get_instance_private (self);
}

static void
application_email_command_finalize (GObject * obj)
{
	ApplicationEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand);
	_g_object_unref0 (self->priv->_location);
	_g_object_unref0 (self->priv->_conversations);
	_g_object_unref0 (self->priv->_email);
	_g_object_unref0 (self->priv->mutable_conversations);
	_g_object_unref0 (self->priv->mutable_email);
	G_OBJECT_CLASS (application_email_command_parent_class)->finalize (obj);
}

/** Base class for email-related commands. */
static GType
application_email_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationEmailCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_email_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationEmailCommand), 0, (GInstanceInitFunc) application_email_command_instance_init, NULL };
	GType application_email_command_type_id;
	application_email_command_type_id = g_type_register_static (APPLICATION_TYPE_COMMAND, "ApplicationEmailCommand", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	ApplicationEmailCommand_private_offset = g_type_add_instance_private (application_email_command_type_id, sizeof (ApplicationEmailCommandPrivate));
	return application_email_command_type_id;
}

GType
application_email_command_get_type (void)
{
	static volatile gsize application_email_command_type_id__once = 0;
	if (g_once_init_enter (&application_email_command_type_id__once)) {
		GType application_email_command_type_id;
		application_email_command_type_id = application_email_command_get_type_once ();
		g_once_init_leave (&application_email_command_type_id__once, application_email_command_type_id);
	}
	return application_email_command_type_id__once;
}

static void
_vala_application_email_command_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	ApplicationEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand);
	switch (property_id) {
		case APPLICATION_EMAIL_COMMAND_LOCATION_PROPERTY:
		g_value_set_object (value, application_email_command_get_location (self));
		break;
		case APPLICATION_EMAIL_COMMAND_CONVERSATIONS_PROPERTY:
		g_value_set_object (value, application_email_command_get_conversations (self));
		break;
		case APPLICATION_EMAIL_COMMAND_EMAIL_PROPERTY:
		g_value_set_object (value, application_email_command_get_email (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_application_email_command_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	ApplicationEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand);
	switch (property_id) {
		case APPLICATION_EMAIL_COMMAND_LOCATION_PROPERTY:
		application_email_command_set_location (self, g_value_get_object (value));
		break;
		case APPLICATION_EMAIL_COMMAND_CONVERSATIONS_PROPERTY:
		application_email_command_set_conversations (self, g_value_get_object (value));
		break;
		case APPLICATION_EMAIL_COMMAND_EMAIL_PROPERTY:
		application_email_command_set_email (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
application_trivial_command_default_init (ApplicationTrivialCommandIface * iface,
                                          gpointer iface_data)
{
}

/**
 * Mixin for trivial application commands.
 *
 * Trivial commands should not cause a notification to be shown when
 * initially executed.
 */
static GType
application_trivial_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationTrivialCommandIface), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_trivial_command_default_init, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL, NULL };
	GType application_trivial_command_type_id;
	application_trivial_command_type_id = g_type_register_static (G_TYPE_INTERFACE, "ApplicationTrivialCommand", &g_define_type_info, 0);
	g_type_interface_add_prerequisite (application_trivial_command_type_id, APPLICATION_TYPE_COMMAND);
	return application_trivial_command_type_id;
}

GType
application_trivial_command_get_type (void)
{
	static volatile gsize application_trivial_command_type_id__once = 0;
	if (g_once_init_enter (&application_trivial_command_type_id__once)) {
		GType application_trivial_command_type_id;
		application_trivial_command_type_id = application_trivial_command_get_type_once ();
		g_once_init_leave (&application_trivial_command_type_id__once, application_trivial_command_type_id);
	}
	return application_trivial_command_type_id__once;
}

static inline gpointer
application_mark_email_command_get_instance_private (ApplicationMarkEmailCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationMarkEmailCommand_private_offset);
}

ApplicationMarkEmailCommand*
application_mark_email_command_construct (GType object_type,
                                          GearyFolder* location,
                                          GeeCollection* conversations,
                                          GeeCollection* messages,
                                          GearyAppEmailStore* store,
                                          GearyEmailFlags* to_add,
                                          GearyEmailFlags* to_remove,
                                          const gchar* executed_label,
                                          const gchar* undone_label)
{
	ApplicationMarkEmailCommand * self = NULL;
	GearyAppEmailStore* _tmp0_;
	GearyEmailFlags* _tmp1_;
	GearyEmailFlags* _tmp2_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (messages, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (store, GEARY_APP_TYPE_EMAIL_STORE), NULL);
	g_return_val_if_fail ((to_add == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (to_add, GEARY_TYPE_EMAIL_FLAGS), NULL);
	g_return_val_if_fail ((to_remove == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (to_remove, GEARY_TYPE_EMAIL_FLAGS), NULL);
	self = (ApplicationMarkEmailCommand*) application_email_command_construct (object_type, location, conversations, messages);
	_tmp0_ = _g_object_ref0 (store);
	_g_object_unref0 (self->priv->store);
	self->priv->store = _tmp0_;
	_tmp1_ = _g_object_ref0 (to_add);
	_g_object_unref0 (self->priv->to_add);
	self->priv->to_add = _tmp1_;
	_tmp2_ = _g_object_ref0 (to_remove);
	_g_object_unref0 (self->priv->to_remove);
	self->priv->to_remove = _tmp2_;
	application_command_set_executed_label (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), executed_label);
	application_command_set_undone_label (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), undone_label);
	return self;
}

ApplicationMarkEmailCommand*
application_mark_email_command_new (GearyFolder* location,
                                    GeeCollection* conversations,
                                    GeeCollection* messages,
                                    GearyAppEmailStore* store,
                                    GearyEmailFlags* to_add,
                                    GearyEmailFlags* to_remove,
                                    const gchar* executed_label,
                                    const gchar* undone_label)
{
	return application_mark_email_command_construct (APPLICATION_TYPE_MARK_EMAIL_COMMAND, location, conversations, messages, store, to_add, to_remove, executed_label, undone_label);
}

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

static void
application_mark_email_command_real_execute (ApplicationCommand* base,
                                             GCancellable* cancellable,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	ApplicationMarkEmailCommand * self;
	ApplicationMarkEmailCommandExecuteData* _data_;
	ApplicationMarkEmailCommand* _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, APPLICATION_TYPE_MARK_EMAIL_COMMAND, ApplicationMarkEmailCommand);
	_data_ = g_slice_new0 (ApplicationMarkEmailCommandExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_mark_email_command_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_;
	application_mark_email_command_real_execute_co (_data_);
}

static void
application_mark_email_command_execute_finish (ApplicationCommand* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	ApplicationMarkEmailCommandExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_mark_email_command_execute_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	ApplicationMarkEmailCommandExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_mark_email_command_real_execute_co (_data_);
}

static gboolean
application_mark_email_command_real_execute_co (ApplicationMarkEmailCommandExecuteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = application_email_command_get_location (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand));
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = geary_folder_get_account (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	geary_account_cancel_remote_update (_data_->_tmp3_);
	_data_->_tmp4_ = _data_->self->priv->store;
	_data_->_tmp5_ = application_email_command_get_email (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand));
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = _data_->self->priv->to_add;
	_data_->_tmp8_ = _data_->self->priv->to_remove;
	_data_->_state_ = 1;
	geary_app_email_store_mark_email_async (_data_->_tmp4_, _data_->_tmp6_, _data_->_tmp7_, _data_->_tmp8_, _data_->cancellable, application_mark_email_command_execute_ready, _data_);
	return FALSE;
	_state_1:
	geary_app_email_store_mark_email_finish (_data_->_tmp4_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_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
application_mark_email_command_real_undo_data_free (gpointer _data)
{
	ApplicationMarkEmailCommandUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationMarkEmailCommandUndoData, _data_);
}

static void
application_mark_email_command_real_undo (ApplicationCommand* base,
                                          GCancellable* cancellable,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	ApplicationMarkEmailCommand * self;
	ApplicationMarkEmailCommandUndoData* _data_;
	ApplicationMarkEmailCommand* _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, APPLICATION_TYPE_MARK_EMAIL_COMMAND, ApplicationMarkEmailCommand);
	_data_ = g_slice_new0 (ApplicationMarkEmailCommandUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_mark_email_command_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_mark_email_command_real_undo_co (_data_);
}

static void
application_mark_email_command_undo_finish (ApplicationCommand* base,
                                            GAsyncResult* _res_,
                                            GError** error)
{
	ApplicationMarkEmailCommandUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_mark_email_command_undo_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	ApplicationMarkEmailCommandUndoData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_mark_email_command_real_undo_co (_data_);
}

static gboolean
application_mark_email_command_real_undo_co (ApplicationMarkEmailCommandUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->store;
	_data_->_tmp1_ = application_email_command_get_email (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand));
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = _data_->self->priv->to_remove;
	_data_->_tmp4_ = _data_->self->priv->to_add;
	_data_->_state_ = 1;
	geary_app_email_store_mark_email_async (_data_->_tmp0_, _data_->_tmp2_, _data_->_tmp3_, _data_->_tmp4_, _data_->cancellable, application_mark_email_command_undo_ready, _data_);
	return FALSE;
	_state_1:
	geary_app_email_store_mark_email_finish (_data_->_tmp0_, _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 gboolean
application_mark_email_command_real_equal_to (ApplicationCommand* base,
                                              ApplicationCommand* other)
{
	ApplicationMarkEmailCommand * self;
	ApplicationMarkEmailCommand* other_mark = NULL;
	ApplicationMarkEmailCommand* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	GearyEmailFlags* _tmp3_;
	ApplicationMarkEmailCommand* _tmp4_;
	GearyEmailFlags* _tmp5_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_MARK_EMAIL_COMMAND, ApplicationMarkEmailCommand);
	g_return_val_if_fail (APPLICATION_IS_COMMAND (other), FALSE);
	if (!APPLICATION_COMMAND_CLASS (application_mark_email_command_parent_class)->equal_to (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand), APPLICATION_TYPE_COMMAND, ApplicationCommand), other)) {
		result = FALSE;
		return result;
	}
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (other, APPLICATION_TYPE_MARK_EMAIL_COMMAND, ApplicationMarkEmailCommand));
	other_mark = _tmp0_;
	_tmp3_ = self->priv->to_add;
	_tmp4_ = other_mark;
	_tmp5_ = _tmp4_->priv->to_add;
	if (_tmp3_ == _tmp5_) {
		_tmp2_ = TRUE;
	} else {
		gboolean _tmp6_ = FALSE;
		gboolean _tmp7_ = FALSE;
		GearyEmailFlags* _tmp8_;
		_tmp8_ = self->priv->to_add;
		if (_tmp8_ != NULL) {
			ApplicationMarkEmailCommand* _tmp9_;
			GearyEmailFlags* _tmp10_;
			_tmp9_ = other_mark;
			_tmp10_ = _tmp9_->priv->to_add;
			_tmp7_ = _tmp10_ != NULL;
		} else {
			_tmp7_ = FALSE;
		}
		if (_tmp7_) {
			GearyEmailFlags* _tmp11_;
			ApplicationMarkEmailCommand* _tmp12_;
			GearyEmailFlags* _tmp13_;
			_tmp11_ = self->priv->to_add;
			_tmp12_ = other_mark;
			_tmp13_ = _tmp12_->priv->to_add;
			_tmp6_ = gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags));
		} else {
			_tmp6_ = FALSE;
		}
		_tmp2_ = _tmp6_;
	}
	if (_tmp2_) {
		gboolean _tmp14_ = FALSE;
		GearyEmailFlags* _tmp15_;
		ApplicationMarkEmailCommand* _tmp16_;
		GearyEmailFlags* _tmp17_;
		_tmp15_ = self->priv->to_remove;
		_tmp16_ = other_mark;
		_tmp17_ = _tmp16_->priv->to_remove;
		if (_tmp15_ == _tmp17_) {
			_tmp14_ = TRUE;
		} else {
			gboolean _tmp18_ = FALSE;
			gboolean _tmp19_ = FALSE;
			GearyEmailFlags* _tmp20_;
			_tmp20_ = self->priv->to_remove;
			if (_tmp20_ != NULL) {
				ApplicationMarkEmailCommand* _tmp21_;
				GearyEmailFlags* _tmp22_;
				_tmp21_ = other_mark;
				_tmp22_ = _tmp21_->priv->to_remove;
				_tmp19_ = _tmp22_ != NULL;
			} else {
				_tmp19_ = FALSE;
			}
			if (_tmp19_) {
				GearyEmailFlags* _tmp23_;
				ApplicationMarkEmailCommand* _tmp24_;
				GearyEmailFlags* _tmp25_;
				_tmp23_ = self->priv->to_remove;
				_tmp24_ = other_mark;
				_tmp25_ = _tmp24_->priv->to_remove;
				_tmp18_ = gee_hashable_equal_to (G_TYPE_CHECK_INSTANCE_CAST (_tmp23_, GEE_TYPE_HASHABLE, GeeHashable), G_TYPE_CHECK_INSTANCE_CAST (_tmp25_, GEARY_TYPE_NAMED_FLAGS, GearyNamedFlags));
			} else {
				_tmp18_ = FALSE;
			}
			_tmp14_ = _tmp18_;
		}
		_tmp1_ = _tmp14_;
	} else {
		_tmp1_ = FALSE;
	}
	result = _tmp1_;
	_g_object_unref0 (other_mark);
	return result;
}

static void
application_mark_email_command_class_init (ApplicationMarkEmailCommandClass * klass,
                                           gpointer klass_data)
{
	application_mark_email_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationMarkEmailCommand_private_offset);
	((ApplicationCommandClass *) klass)->execute = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_mark_email_command_real_execute;
	((ApplicationCommandClass *) klass)->execute_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_mark_email_command_execute_finish;
	((ApplicationCommandClass *) klass)->undo = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_mark_email_command_real_undo;
	((ApplicationCommandClass *) klass)->undo_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_mark_email_command_undo_finish;
	((ApplicationCommandClass *) klass)->equal_to = (gboolean (*) (ApplicationCommand*, ApplicationCommand*)) application_mark_email_command_real_equal_to;
	G_OBJECT_CLASS (klass)->finalize = application_mark_email_command_finalize;
}

static void
application_mark_email_command_application_trivial_command_interface_init (ApplicationTrivialCommandIface * iface,
                                                                           gpointer iface_data)
{
	application_mark_email_command_application_trivial_command_parent_iface = g_type_interface_peek_parent (iface);
}

static void
application_mark_email_command_instance_init (ApplicationMarkEmailCommand * self,
                                              gpointer klass)
{
	self->priv = application_mark_email_command_get_instance_private (self);
}

static void
application_mark_email_command_finalize (GObject * obj)
{
	ApplicationMarkEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_MARK_EMAIL_COMMAND, ApplicationMarkEmailCommand);
	_g_object_unref0 (self->priv->store);
	_g_object_unref0 (self->priv->to_add);
	_g_object_unref0 (self->priv->to_remove);
	G_OBJECT_CLASS (application_mark_email_command_parent_class)->finalize (obj);
}

static GType
application_mark_email_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationMarkEmailCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_mark_email_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationMarkEmailCommand), 0, (GInstanceInitFunc) application_mark_email_command_instance_init, NULL };
	static const GInterfaceInfo application_trivial_command_info = { (GInterfaceInitFunc) application_mark_email_command_application_trivial_command_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType application_mark_email_command_type_id;
	application_mark_email_command_type_id = g_type_register_static (APPLICATION_TYPE_EMAIL_COMMAND, "ApplicationMarkEmailCommand", &g_define_type_info, 0);
	g_type_add_interface_static (application_mark_email_command_type_id, APPLICATION_TYPE_TRIVIAL_COMMAND, &application_trivial_command_info);
	ApplicationMarkEmailCommand_private_offset = g_type_add_instance_private (application_mark_email_command_type_id, sizeof (ApplicationMarkEmailCommandPrivate));
	return application_mark_email_command_type_id;
}

GType
application_mark_email_command_get_type (void)
{
	static volatile gsize application_mark_email_command_type_id__once = 0;
	if (g_once_init_enter (&application_mark_email_command_type_id__once)) {
		GType application_mark_email_command_type_id;
		application_mark_email_command_type_id = application_mark_email_command_get_type_once ();
		g_once_init_leave (&application_mark_email_command_type_id__once, application_mark_email_command_type_id);
	}
	return application_mark_email_command_type_id__once;
}

static inline gpointer
application_revokable_command_get_instance_private (ApplicationRevokableCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationRevokableCommand_private_offset);
}

static gboolean
application_revokable_command_real_get_can_undo (ApplicationCommand* base)
{
	gboolean result;
	ApplicationRevokableCommand* self;
	gboolean _tmp0_ = FALSE;
	GearyRevokable* _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand);
	_tmp1_ = self->priv->revokable;
	if (_tmp1_ != NULL) {
		GearyRevokable* _tmp2_;
		gboolean _tmp3_;
		gboolean _tmp4_;
		_tmp2_ = self->priv->revokable;
		_tmp3_ = geary_revokable_get_valid (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

ApplicationRevokableCommand*
application_revokable_command_construct (GType object_type,
                                         GearyFolder* location,
                                         GeeCollection* conversations,
                                         GeeCollection* email)
{
	ApplicationRevokableCommand * self = NULL;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email, GEE_TYPE_COLLECTION), NULL);
	self = (ApplicationRevokableCommand*) application_email_command_construct (object_type, location, conversations, email);
	return self;
}

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

static void
application_revokable_command_real_execute (ApplicationCommand* base,
                                            GCancellable* cancellable,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	ApplicationRevokableCommand * self;
	ApplicationRevokableCommandExecuteData* _data_;
	ApplicationRevokableCommand* _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, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand);
	_data_ = g_slice_new0 (ApplicationRevokableCommandExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_revokable_command_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_;
	application_revokable_command_real_execute_co (_data_);
}

static void
application_revokable_command_execute_finish (ApplicationCommand* base,
                                              GAsyncResult* _res_,
                                              GError** error)
{
	ApplicationRevokableCommandExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_revokable_command_execute_ready (GObject* source_object,
                                             GAsyncResult* _res_,
                                             gpointer _user_data_)
{
	ApplicationRevokableCommandExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_revokable_command_real_execute_co (_data_);
}

static gboolean
application_revokable_command_real_execute_co (ApplicationRevokableCommandExecuteData* _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_->_state_ = 1;
	application_revokable_command_execute_impl (_data_->self, _data_->cancellable, application_revokable_command_execute_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = application_revokable_command_execute_impl_finish (_data_->self, _data_->_res_, &_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;
	}
	application_revokable_command_set_revokable (_data_->self, _data_->_tmp0_);
	_data_->_tmp3_ = _data_->self->priv->revokable;
	if (_data_->_tmp3_ != NULL) {
		_data_->_tmp4_ = _data_->self->priv->revokable;
		_data_->_tmp5_ = geary_revokable_get_valid (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp2_ = _data_->_tmp6_;
	} else {
		_data_->_tmp2_ = FALSE;
	}
	if (_data_->_tmp2_) {
		_data_->_tmp7_ = _data_->self->priv->revokable;
		_data_->_state_ = 2;
		geary_revokable_commit_async (_data_->_tmp7_, _data_->cancellable, application_revokable_command_execute_ready, _data_);
		return FALSE;
		_state_2:
		geary_revokable_commit_finish (_data_->_tmp7_, _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_->_tmp0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_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
application_revokable_command_real_undo_data_free (gpointer _data)
{
	ApplicationRevokableCommandUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationRevokableCommandUndoData, _data_);
}

static void
application_revokable_command_real_undo (ApplicationCommand* base,
                                         GCancellable* cancellable,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_)
{
	ApplicationRevokableCommand * self;
	ApplicationRevokableCommandUndoData* _data_;
	ApplicationRevokableCommand* _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, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand);
	_data_ = g_slice_new0 (ApplicationRevokableCommandUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_revokable_command_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_revokable_command_real_undo_co (_data_);
}

static void
application_revokable_command_undo_finish (ApplicationCommand* base,
                                           GAsyncResult* _res_,
                                           GError** error)
{
	ApplicationRevokableCommandUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_revokable_command_undo_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	ApplicationRevokableCommandUndoData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_revokable_command_real_undo_co (_data_);
}

static gboolean
application_revokable_command_real_undo_co (ApplicationRevokableCommandUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->revokable;
	if (_data_->_tmp0_ == NULL) {
		_data_->_tmp1_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Cannot undo command, no revokable available");
		_data_->_inner_error0_ = _data_->_tmp1_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp2_ = _data_->self->priv->revokable;
	_data_->_state_ = 1;
	geary_revokable_revoke_async (_data_->_tmp2_, _data_->cancellable, application_revokable_command_undo_ready, _data_);
	return FALSE;
	_state_1:
	geary_revokable_revoke_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	application_revokable_command_set_revokable (_data_->self, 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;
}

void
application_revokable_command_execute_impl (ApplicationRevokableCommand* self,
                                            GCancellable* cancellable,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	ApplicationRevokableCommandClass* _klass_;
	_klass_ = APPLICATION_REVOKABLE_COMMAND_GET_CLASS (self);
	if (_klass_->execute_impl) {
		_klass_->execute_impl (self, cancellable, _callback_, _user_data_);
	}
}

GearyRevokable*
application_revokable_command_execute_impl_finish (ApplicationRevokableCommand* self,
                                                   GAsyncResult* _res_,
                                                   GError** error)
{
	ApplicationRevokableCommandClass* _klass_;
	_klass_ = APPLICATION_REVOKABLE_COMMAND_GET_CLASS (self);
	if (_klass_->execute_impl_finish) {
		return _klass_->execute_impl_finish (self, _res_, error);
	}
	return NULL;
}

static void
_application_revokable_command_on_revokable_committed_geary_revokable_committed (GearyRevokable* _sender,
                                                                                 GearyRevokable* commit_revokable,
                                                                                 gpointer self)
{
	application_revokable_command_on_revokable_committed ((ApplicationRevokableCommand*) self, commit_revokable);
}

static void
application_revokable_command_set_revokable (ApplicationRevokableCommand* self,
                                             GearyRevokable* updated)
{
	GearyRevokable* _tmp0_;
	GearyRevokable* _tmp3_;
	GearyRevokable* _tmp4_;
	g_return_if_fail (APPLICATION_IS_REVOKABLE_COMMAND (self));
	g_return_if_fail ((updated == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (updated, GEARY_TYPE_REVOKABLE));
	_tmp0_ = self->priv->revokable;
	if (_tmp0_ != NULL) {
		GearyRevokable* _tmp1_;
		guint _tmp2_;
		_tmp1_ = self->priv->revokable;
		g_signal_parse_name ("committed", GEARY_TYPE_REVOKABLE, &_tmp2_, NULL, FALSE);
		g_signal_handlers_disconnect_matched (_tmp1_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _tmp2_, 0, NULL, (GCallback) _application_revokable_command_on_revokable_committed_geary_revokable_committed, self);
	}
	_tmp3_ = _g_object_ref0 (updated);
	_g_object_unref0 (self->priv->revokable);
	self->priv->revokable = _tmp3_;
	_tmp4_ = self->priv->revokable;
	if (_tmp4_ != NULL) {
		GearyRevokable* _tmp5_;
		_tmp5_ = self->priv->revokable;
		g_signal_connect_object (_tmp5_, "committed", (GCallback) _application_revokable_command_on_revokable_committed_geary_revokable_committed, self, 0);
	}
}

static void
application_revokable_command_on_revokable_committed (ApplicationRevokableCommand* self,
                                                      GearyRevokable* updated)
{
	g_return_if_fail (APPLICATION_IS_REVOKABLE_COMMAND (self));
	g_return_if_fail ((updated == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (updated, GEARY_TYPE_REVOKABLE));
	application_revokable_command_set_revokable (self, updated);
}

static void
application_revokable_command_class_init (ApplicationRevokableCommandClass * klass,
                                          gpointer klass_data)
{
	application_revokable_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationRevokableCommand_private_offset);
	((ApplicationCommandClass *) klass)->execute = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_revokable_command_real_execute;
	((ApplicationCommandClass *) klass)->execute_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_revokable_command_execute_finish;
	((ApplicationCommandClass *) klass)->undo = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_revokable_command_real_undo;
	((ApplicationCommandClass *) klass)->undo_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_revokable_command_undo_finish;
	APPLICATION_COMMAND_CLASS (klass)->get_can_undo = (gboolean (*) (ApplicationCommand*)) application_revokable_command_real_get_can_undo;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_revokable_command_get_property;
	G_OBJECT_CLASS (klass)->finalize = application_revokable_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_REVOKABLE_COMMAND_CAN_UNDO_PROPERTY, application_revokable_command_properties[APPLICATION_REVOKABLE_COMMAND_CAN_UNDO_PROPERTY] = g_param_spec_boolean ("can-undo", "can-undo", "can-undo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_revokable_command_instance_init (ApplicationRevokableCommand * self,
                                             gpointer klass)
{
	self->priv = application_revokable_command_get_instance_private (self);
	self->priv->revokable = NULL;
}

static void
application_revokable_command_finalize (GObject * obj)
{
	ApplicationRevokableCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand);
	_g_object_unref0 (self->priv->revokable);
	G_OBJECT_CLASS (application_revokable_command_parent_class)->finalize (obj);
}

static GType
application_revokable_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationRevokableCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_revokable_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationRevokableCommand), 0, (GInstanceInitFunc) application_revokable_command_instance_init, NULL };
	GType application_revokable_command_type_id;
	application_revokable_command_type_id = g_type_register_static (APPLICATION_TYPE_EMAIL_COMMAND, "ApplicationRevokableCommand", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	ApplicationRevokableCommand_private_offset = g_type_add_instance_private (application_revokable_command_type_id, sizeof (ApplicationRevokableCommandPrivate));
	return application_revokable_command_type_id;
}

GType
application_revokable_command_get_type (void)
{
	static volatile gsize application_revokable_command_type_id__once = 0;
	if (g_once_init_enter (&application_revokable_command_type_id__once)) {
		GType application_revokable_command_type_id;
		application_revokable_command_type_id = application_revokable_command_get_type_once ();
		g_once_init_leave (&application_revokable_command_type_id__once, application_revokable_command_type_id);
	}
	return application_revokable_command_type_id__once;
}

static void
_vala_application_revokable_command_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec)
{
	ApplicationRevokableCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand);
	switch (property_id) {
		case APPLICATION_REVOKABLE_COMMAND_CAN_UNDO_PROPERTY:
		g_value_set_boolean (value, application_command_get_can_undo (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand)));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_move_email_command_get_instance_private (ApplicationMoveEmailCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationMoveEmailCommand_private_offset);
}

ApplicationMoveEmailCommand*
application_move_email_command_construct (GType object_type,
                                          GearyFolderSupportMove* source,
                                          GearyFolder* destination,
                                          GeeCollection* conversations,
                                          GeeCollection* messages,
                                          const gchar* executed_label,
                                          const gchar* undone_label)
{
	ApplicationMoveEmailCommand * self = NULL;
	GearyFolderSupportMove* _tmp0_;
	GearyFolder* _tmp1_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, GEARY_FOLDER_SUPPORT_TYPE_MOVE), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (destination, GEARY_TYPE_FOLDER), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (messages, GEE_TYPE_COLLECTION), NULL);
	self = (ApplicationMoveEmailCommand*) application_revokable_command_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (source, GEARY_TYPE_FOLDER, GearyFolder), conversations, messages);
	_tmp0_ = _g_object_ref0 (source);
	_g_object_unref0 (self->priv->source);
	self->priv->source = _tmp0_;
	_tmp1_ = _g_object_ref0 (destination);
	_g_object_unref0 (self->priv->destination);
	self->priv->destination = _tmp1_;
	application_command_set_executed_label (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), executed_label);
	application_command_set_undone_label (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), undone_label);
	return self;
}

ApplicationMoveEmailCommand*
application_move_email_command_new (GearyFolderSupportMove* source,
                                    GearyFolder* destination,
                                    GeeCollection* conversations,
                                    GeeCollection* messages,
                                    const gchar* executed_label,
                                    const gchar* undone_label)
{
	return application_move_email_command_construct (APPLICATION_TYPE_MOVE_EMAIL_COMMAND, source, destination, conversations, messages, executed_label, undone_label);
}

static ApplicationEmailCommandStateChangePolicy
application_move_email_command_real_folders_removed (ApplicationEmailCommand* base,
                                                     GeeCollection* removed)
{
	ApplicationMoveEmailCommand * self;
	ApplicationEmailCommandStateChangePolicy _tmp0_ = 0;
	GearyFolder* _tmp1_;
	ApplicationEmailCommandStateChangePolicy result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_MOVE_EMAIL_COMMAND, ApplicationMoveEmailCommand);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION), 0);
	_tmp1_ = self->priv->destination;
	if (gee_collection_contains (removed, _tmp1_)) {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE;
	} else {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_CLASS (application_move_email_command_parent_class)->folders_removed (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand), APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand), removed);
	}
	result = _tmp0_;
	return result;
}

static ApplicationEmailCommandStateChangePolicy
application_move_email_command_real_email_removed (ApplicationEmailCommand* base,
                                                   GearyFolder* location,
                                                   GeeCollection* targets)
{
	ApplicationMoveEmailCommand * self;
	ApplicationEmailCommandStateChangePolicy _tmp0_ = 0;
	GearyFolder* _tmp1_;
	ApplicationEmailCommandStateChangePolicy result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_MOVE_EMAIL_COMMAND, ApplicationMoveEmailCommand);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER), 0);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (targets, GEE_TYPE_COLLECTION), 0);
	_tmp1_ = self->priv->destination;
	if (location == _tmp1_) {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE;
	} else {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_CLASS (application_move_email_command_parent_class)->email_removed (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand), APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand), location, targets);
	}
	result = _tmp0_;
	return result;
}

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

static void
application_move_email_command_real_execute_impl (ApplicationRevokableCommand* base,
                                                  GCancellable* cancellable,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	ApplicationMoveEmailCommand * self;
	ApplicationMoveEmailCommandExecuteImplData* _data_;
	ApplicationMoveEmailCommand* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_MOVE_EMAIL_COMMAND, ApplicationMoveEmailCommand);
	_data_ = g_slice_new0 (ApplicationMoveEmailCommandExecuteImplData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_move_email_command_real_execute_impl_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_move_email_command_real_execute_impl_co (_data_);
}

static GearyRevokable*
application_move_email_command_execute_impl_finish (ApplicationRevokableCommand* base,
                                                    GAsyncResult* _res_,
                                                    GError** error)
{
	GearyRevokable* result;
	ApplicationMoveEmailCommandExecuteImplData* _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
application_move_email_command_execute_impl_ready (GObject* source_object,
                                                   GAsyncResult* _res_,
                                                   gpointer _user_data_)
{
	ApplicationMoveEmailCommandExecuteImplData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_move_email_command_real_execute_impl_co (_data_);
}

static gboolean
application_move_email_command_real_execute_impl_co (ApplicationMoveEmailCommandExecuteImplData* _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_->open = FALSE;
	{
		_data_->_tmp0_ = _data_->self->priv->source;
		_data_->_state_ = 1;
		geary_folder_open_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FLAGS_NO_DELAY, _data_->cancellable, application_move_email_command_execute_impl_ready, _data_);
		return FALSE;
		_state_1:
		geary_folder_open_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_data_->open = TRUE;
		_data_->_tmp2_ = _data_->self->priv->source;
		_data_->_tmp3_ = application_email_command_get_email (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand));
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = _data_->self->priv->destination;
		_data_->_tmp6_ = geary_folder_get_path (_data_->_tmp5_);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_state_ = 2;
		geary_folder_support_move_move_email_async (_data_->_tmp2_, _data_->_tmp4_, _data_->_tmp7_, _data_->cancellable, application_move_email_command_execute_impl_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp8_ = geary_folder_support_move_move_email_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp8_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_data_->_tmp9_ = _data_->_tmp1_;
		_data_->_tmp1_ = NULL;
		_data_->result = _data_->_tmp9_;
		_g_object_unref0 (_data_->_tmp1_);
		{
			if (_data_->open) {
				{
					_data_->_tmp10_ = _data_->self->priv->source;
					_data_->_state_ = 3;
					geary_folder_close_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp10_, GEARY_TYPE_FOLDER, GearyFolder), NULL, application_move_email_command_execute_impl_ready, _data_);
					return FALSE;
					_state_3:
					geary_folder_close_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp10_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						goto __catch1_g_error;
					}
				}
				goto __finally1;
				__catch1_g_error:
				{
					g_clear_error (&_data_->_inner_error0_);
				}
				__finally1:
				if (G_UNLIKELY (_data_->_inner_error0_ != 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;
	}
	__finally0:
	{
		if (_data_->open) {
			{
				_data_->_tmp11_ = _data_->self->priv->source;
				_data_->_state_ = 4;
				geary_folder_close_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GEARY_TYPE_FOLDER, GearyFolder), NULL, application_move_email_command_execute_impl_ready, _data_);
				return FALSE;
				_state_4:
				geary_folder_close_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp11_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error1_);
				if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
					goto __catch2_g_error;
				}
			}
			goto __finally2;
			__catch2_g_error:
			{
				g_clear_error (&_data_->_inner_error1_);
			}
			__finally2:
			if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error1_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
	}
	g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
application_move_email_command_class_init (ApplicationMoveEmailCommandClass * klass,
                                           gpointer klass_data)
{
	application_move_email_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationMoveEmailCommand_private_offset);
	((ApplicationEmailCommandClass *) klass)->folders_removed = (ApplicationEmailCommandStateChangePolicy (*) (ApplicationEmailCommand*, GeeCollection*)) application_move_email_command_real_folders_removed;
	((ApplicationEmailCommandClass *) klass)->email_removed = (ApplicationEmailCommandStateChangePolicy (*) (ApplicationEmailCommand*, GearyFolder*, GeeCollection*)) application_move_email_command_real_email_removed;
	((ApplicationRevokableCommandClass *) klass)->execute_impl = (void (*) (ApplicationRevokableCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_move_email_command_real_execute_impl;
	((ApplicationRevokableCommandClass *) klass)->execute_impl_finish = (GearyRevokable* (*) (ApplicationRevokableCommand*, GAsyncResult*, GError**)) application_move_email_command_execute_impl_finish;
	G_OBJECT_CLASS (klass)->finalize = application_move_email_command_finalize;
}

static void
application_move_email_command_instance_init (ApplicationMoveEmailCommand * self,
                                              gpointer klass)
{
	self->priv = application_move_email_command_get_instance_private (self);
}

static void
application_move_email_command_finalize (GObject * obj)
{
	ApplicationMoveEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_MOVE_EMAIL_COMMAND, ApplicationMoveEmailCommand);
	_g_object_unref0 (self->priv->source);
	_g_object_unref0 (self->priv->destination);
	G_OBJECT_CLASS (application_move_email_command_parent_class)->finalize (obj);
}

static GType
application_move_email_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationMoveEmailCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_move_email_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationMoveEmailCommand), 0, (GInstanceInitFunc) application_move_email_command_instance_init, NULL };
	GType application_move_email_command_type_id;
	application_move_email_command_type_id = g_type_register_static (APPLICATION_TYPE_REVOKABLE_COMMAND, "ApplicationMoveEmailCommand", &g_define_type_info, 0);
	ApplicationMoveEmailCommand_private_offset = g_type_add_instance_private (application_move_email_command_type_id, sizeof (ApplicationMoveEmailCommandPrivate));
	return application_move_email_command_type_id;
}

GType
application_move_email_command_get_type (void)
{
	static volatile gsize application_move_email_command_type_id__once = 0;
	if (g_once_init_enter (&application_move_email_command_type_id__once)) {
		GType application_move_email_command_type_id;
		application_move_email_command_type_id = application_move_email_command_get_type_once ();
		g_once_init_leave (&application_move_email_command_type_id__once, application_move_email_command_type_id);
	}
	return application_move_email_command_type_id__once;
}

static inline gpointer
application_archive_email_command_get_instance_private (ApplicationArchiveEmailCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationArchiveEmailCommand_private_offset);
}

GearyFolder*
application_archive_email_command_get_command_location (ApplicationArchiveEmailCommand* self)
{
	GearyFolder* result;
	GearyFolder* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_ARCHIVE_EMAIL_COMMAND (self), NULL);
	_tmp0_ = self->priv->_command_location;
	result = _tmp0_;
	return result;
}

void
application_archive_email_command_set_command_location (ApplicationArchiveEmailCommand* self,
                                                        GearyFolder* value)
{
	GearyFolder* old_value;
	g_return_if_fail (APPLICATION_IS_ARCHIVE_EMAIL_COMMAND (self));
	old_value = application_archive_email_command_get_command_location (self);
	if (old_value != value) {
		GearyFolder* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_command_location);
		self->priv->_command_location = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_archive_email_command_properties[APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_LOCATION_PROPERTY]);
	}
}

GeeCollection*
application_archive_email_command_get_command_conversations (ApplicationArchiveEmailCommand* self)
{
	GeeCollection* result;
	GeeCollection* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_ARCHIVE_EMAIL_COMMAND (self), NULL);
	_tmp0_ = self->priv->_command_conversations;
	result = _tmp0_;
	return result;
}

void
application_archive_email_command_set_command_conversations (ApplicationArchiveEmailCommand* self,
                                                             GeeCollection* value)
{
	GeeCollection* old_value;
	g_return_if_fail (APPLICATION_IS_ARCHIVE_EMAIL_COMMAND (self));
	old_value = application_archive_email_command_get_command_conversations (self);
	if (old_value != value) {
		GeeCollection* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_command_conversations);
		self->priv->_command_conversations = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_archive_email_command_properties[APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_CONVERSATIONS_PROPERTY]);
	}
}

GeeCollection*
application_archive_email_command_get_command_email (ApplicationArchiveEmailCommand* self)
{
	GeeCollection* result;
	GeeCollection* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_ARCHIVE_EMAIL_COMMAND (self), NULL);
	_tmp0_ = self->priv->_command_email;
	result = _tmp0_;
	return result;
}

void
application_archive_email_command_set_command_email (ApplicationArchiveEmailCommand* self,
                                                     GeeCollection* value)
{
	GeeCollection* old_value;
	g_return_if_fail (APPLICATION_IS_ARCHIVE_EMAIL_COMMAND (self));
	old_value = application_archive_email_command_get_command_email (self);
	if (old_value != value) {
		GeeCollection* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_command_email);
		self->priv->_command_email = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_archive_email_command_properties[APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_EMAIL_PROPERTY]);
	}
}

ApplicationArchiveEmailCommand*
application_archive_email_command_construct (GType object_type,
                                             GearyFolderSupportArchive* source,
                                             GeeCollection* conversations,
                                             GeeCollection* messages,
                                             const gchar* executed_label,
                                             const gchar* undone_label)
{
	ApplicationArchiveEmailCommand * self = NULL;
	GearyFolderSupportArchive* _tmp0_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, GEARY_FOLDER_SUPPORT_TYPE_ARCHIVE), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (messages, GEE_TYPE_COLLECTION), NULL);
	self = (ApplicationArchiveEmailCommand*) application_revokable_command_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (source, GEARY_TYPE_FOLDER, GearyFolder), conversations, messages);
	_tmp0_ = _g_object_ref0 (source);
	_g_object_unref0 (self->priv->source);
	self->priv->source = _tmp0_;
	application_command_set_executed_label (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), executed_label);
	application_command_set_executed_notification_brief (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), TRUE);
	application_command_set_undone_label (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), undone_label);
	return self;
}

ApplicationArchiveEmailCommand*
application_archive_email_command_new (GearyFolderSupportArchive* source,
                                       GeeCollection* conversations,
                                       GeeCollection* messages,
                                       const gchar* executed_label,
                                       const gchar* undone_label)
{
	return application_archive_email_command_construct (APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, source, conversations, messages, executed_label, undone_label);
}

static ApplicationEmailCommandStateChangePolicy
application_archive_email_command_real_folders_removed (ApplicationEmailCommand* base,
                                                        GeeCollection* removed)
{
	ApplicationArchiveEmailCommand * self;
	ApplicationEmailCommandStateChangePolicy ret = 0;
	ApplicationEmailCommandStateChangePolicy result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommand);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION), 0);
	ret = APPLICATION_EMAIL_COMMAND_CLASS (application_archive_email_command_parent_class)->folders_removed (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand), APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand), removed);
	if (ret == APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_IGNORE) {
		{
			GeeIterator* _folder_it = NULL;
			GeeIterator* _tmp0_;
			_tmp0_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (removed, GEE_TYPE_ITERABLE, GeeIterable));
			_folder_it = _tmp0_;
			while (TRUE) {
				GeeIterator* _tmp1_;
				GearyFolder* folder = NULL;
				GeeIterator* _tmp2_;
				gpointer _tmp3_;
				GearyFolder* _tmp4_;
				GearyFolderSpecialUse _tmp5_;
				GearyFolderSpecialUse _tmp6_;
				_tmp1_ = _folder_it;
				if (!gee_iterator_next (_tmp1_)) {
					break;
				}
				_tmp2_ = _folder_it;
				_tmp3_ = gee_iterator_get (_tmp2_);
				folder = (GearyFolder*) _tmp3_;
				_tmp4_ = folder;
				_tmp5_ = geary_folder_get_used_as (_tmp4_);
				_tmp6_ = _tmp5_;
				if (_tmp6_ == GEARY_FOLDER_SPECIAL_USE_ARCHIVE) {
					ret = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE;
					_g_object_unref0 (folder);
					break;
				}
				_g_object_unref0 (folder);
			}
			_g_object_unref0 (_folder_it);
		}
	}
	result = ret;
	return result;
}

static ApplicationEmailCommandStateChangePolicy
application_archive_email_command_real_email_removed (ApplicationEmailCommand* base,
                                                      GearyFolder* location,
                                                      GeeCollection* targets)
{
	ApplicationArchiveEmailCommand * self;
	ApplicationEmailCommandStateChangePolicy _tmp0_ = 0;
	GearyFolderSpecialUse _tmp1_;
	GearyFolderSpecialUse _tmp2_;
	ApplicationEmailCommandStateChangePolicy result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommand);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER), 0);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (targets, GEE_TYPE_COLLECTION), 0);
	_tmp1_ = geary_folder_get_used_as (location);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == GEARY_FOLDER_SPECIAL_USE_ARCHIVE) {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE;
	} else {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_CLASS (application_archive_email_command_parent_class)->email_removed (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_REVOKABLE_COMMAND, ApplicationRevokableCommand), APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand), location, targets);
	}
	result = _tmp0_;
	return result;
}

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

static void
application_archive_email_command_real_execute_impl (ApplicationRevokableCommand* base,
                                                     GCancellable* cancellable,
                                                     GAsyncReadyCallback _callback_,
                                                     gpointer _user_data_)
{
	ApplicationArchiveEmailCommand * self;
	ApplicationArchiveEmailCommandExecuteImplData* _data_;
	ApplicationArchiveEmailCommand* _tmp0_;
	GCancellable* _tmp1_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (cancellable, g_cancellable_get_type ()));
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommand);
	_data_ = g_slice_new0 (ApplicationArchiveEmailCommandExecuteImplData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_archive_email_command_real_execute_impl_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_archive_email_command_real_execute_impl_co (_data_);
}

static GearyRevokable*
application_archive_email_command_execute_impl_finish (ApplicationRevokableCommand* base,
                                                       GAsyncResult* _res_,
                                                       GError** error)
{
	GearyRevokable* result;
	ApplicationArchiveEmailCommandExecuteImplData* _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
application_archive_email_command_execute_impl_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_)
{
	ApplicationArchiveEmailCommandExecuteImplData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_archive_email_command_real_execute_impl_co (_data_);
}

static gboolean
application_archive_email_command_real_execute_impl_co (ApplicationArchiveEmailCommandExecuteImplData* _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_->open = FALSE;
	{
		_data_->_tmp0_ = _data_->self->priv->source;
		_data_->_state_ = 1;
		geary_folder_open_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FLAGS_NO_DELAY, _data_->cancellable, application_archive_email_command_execute_impl_ready, _data_);
		return FALSE;
		_state_1:
		geary_folder_open_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_data_->open = TRUE;
		_data_->_tmp2_ = _data_->self->priv->source;
		_data_->_tmp3_ = application_email_command_get_email (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand));
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_state_ = 2;
		geary_folder_support_archive_archive_email_async (_data_->_tmp2_, _data_->_tmp4_, _data_->cancellable, application_archive_email_command_execute_impl_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp5_ = geary_folder_support_archive_archive_email_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp5_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_data_->_tmp6_ = _data_->_tmp1_;
		_data_->_tmp1_ = NULL;
		_data_->result = _data_->_tmp6_;
		_g_object_unref0 (_data_->_tmp1_);
		{
			if (_data_->open) {
				{
					_data_->_tmp7_ = _data_->self->priv->source;
					_data_->_state_ = 3;
					geary_folder_close_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEARY_TYPE_FOLDER, GearyFolder), NULL, application_archive_email_command_execute_impl_ready, _data_);
					return FALSE;
					_state_3:
					geary_folder_close_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
					if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
						goto __catch1_g_error;
					}
				}
				goto __finally1;
				__catch1_g_error:
				{
					g_clear_error (&_data_->_inner_error0_);
				}
				__finally1:
				if (G_UNLIKELY (_data_->_inner_error0_ != 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;
	}
	__finally0:
	{
		if (_data_->open) {
			{
				_data_->_tmp8_ = _data_->self->priv->source;
				_data_->_state_ = 4;
				geary_folder_close_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEARY_TYPE_FOLDER, GearyFolder), NULL, application_archive_email_command_execute_impl_ready, _data_);
				return FALSE;
				_state_4:
				geary_folder_close_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error1_);
				if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
					goto __catch2_g_error;
				}
			}
			goto __finally2;
			__catch2_g_error:
			{
				g_clear_error (&_data_->_inner_error1_);
			}
			__finally2:
			if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error1_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
	}
	g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
application_archive_email_command_class_init (ApplicationArchiveEmailCommandClass * klass,
                                              gpointer klass_data)
{
	application_archive_email_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationArchiveEmailCommand_private_offset);
	((ApplicationEmailCommandClass *) klass)->folders_removed = (ApplicationEmailCommandStateChangePolicy (*) (ApplicationEmailCommand*, GeeCollection*)) application_archive_email_command_real_folders_removed;
	((ApplicationEmailCommandClass *) klass)->email_removed = (ApplicationEmailCommandStateChangePolicy (*) (ApplicationEmailCommand*, GearyFolder*, GeeCollection*)) application_archive_email_command_real_email_removed;
	((ApplicationRevokableCommandClass *) klass)->execute_impl = (void (*) (ApplicationRevokableCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_archive_email_command_real_execute_impl;
	((ApplicationRevokableCommandClass *) klass)->execute_impl_finish = (GearyRevokable* (*) (ApplicationRevokableCommand*, GAsyncResult*, GError**)) application_archive_email_command_execute_impl_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_archive_email_command_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_application_archive_email_command_set_property;
	G_OBJECT_CLASS (klass)->finalize = application_archive_email_command_finalize;
	/** {@inheritDoc} */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_LOCATION_PROPERTY, application_archive_email_command_properties[APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_LOCATION_PROPERTY] = g_param_spec_object ("command-location", "command-location", "command-location", GEARY_TYPE_FOLDER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** {@inheritDoc} */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_CONVERSATIONS_PROPERTY, application_archive_email_command_properties[APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_CONVERSATIONS_PROPERTY] = g_param_spec_object ("command-conversations", "command-conversations", "command-conversations", GEE_TYPE_COLLECTION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	/** {@inheritDoc} */
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_EMAIL_PROPERTY, application_archive_email_command_properties[APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_EMAIL_PROPERTY] = g_param_spec_object ("command-email", "command-email", "command-email", GEE_TYPE_COLLECTION, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
application_archive_email_command_instance_init (ApplicationArchiveEmailCommand * self,
                                                 gpointer klass)
{
	self->priv = application_archive_email_command_get_instance_private (self);
}

static void
application_archive_email_command_finalize (GObject * obj)
{
	ApplicationArchiveEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommand);
	_g_object_unref0 (self->priv->_command_location);
	_g_object_unref0 (self->priv->_command_conversations);
	_g_object_unref0 (self->priv->_command_email);
	_g_object_unref0 (self->priv->source);
	G_OBJECT_CLASS (application_archive_email_command_parent_class)->finalize (obj);
}

static GType
application_archive_email_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationArchiveEmailCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_archive_email_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationArchiveEmailCommand), 0, (GInstanceInitFunc) application_archive_email_command_instance_init, NULL };
	GType application_archive_email_command_type_id;
	application_archive_email_command_type_id = g_type_register_static (APPLICATION_TYPE_REVOKABLE_COMMAND, "ApplicationArchiveEmailCommand", &g_define_type_info, 0);
	ApplicationArchiveEmailCommand_private_offset = g_type_add_instance_private (application_archive_email_command_type_id, sizeof (ApplicationArchiveEmailCommandPrivate));
	return application_archive_email_command_type_id;
}

GType
application_archive_email_command_get_type (void)
{
	static volatile gsize application_archive_email_command_type_id__once = 0;
	if (g_once_init_enter (&application_archive_email_command_type_id__once)) {
		GType application_archive_email_command_type_id;
		application_archive_email_command_type_id = application_archive_email_command_get_type_once ();
		g_once_init_leave (&application_archive_email_command_type_id__once, application_archive_email_command_type_id);
	}
	return application_archive_email_command_type_id__once;
}

static void
_vala_application_archive_email_command_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec)
{
	ApplicationArchiveEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommand);
	switch (property_id) {
		case APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_LOCATION_PROPERTY:
		g_value_set_object (value, application_archive_email_command_get_command_location (self));
		break;
		case APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_CONVERSATIONS_PROPERTY:
		g_value_set_object (value, application_archive_email_command_get_command_conversations (self));
		break;
		case APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_EMAIL_PROPERTY:
		g_value_set_object (value, application_archive_email_command_get_command_email (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_application_archive_email_command_set_property (GObject * object,
                                                      guint property_id,
                                                      const GValue * value,
                                                      GParamSpec * pspec)
{
	ApplicationArchiveEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_ARCHIVE_EMAIL_COMMAND, ApplicationArchiveEmailCommand);
	switch (property_id) {
		case APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_LOCATION_PROPERTY:
		application_archive_email_command_set_command_location (self, g_value_get_object (value));
		break;
		case APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_CONVERSATIONS_PROPERTY:
		application_archive_email_command_set_command_conversations (self, g_value_get_object (value));
		break;
		case APPLICATION_ARCHIVE_EMAIL_COMMAND_COMMAND_EMAIL_PROPERTY:
		application_archive_email_command_set_command_email (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_copy_email_command_get_instance_private (ApplicationCopyEmailCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationCopyEmailCommand_private_offset);
}

static gboolean
application_copy_email_command_real_get_can_undo (ApplicationCommand* base)
{
	gboolean result;
	ApplicationCopyEmailCommand* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommand);
	result = FALSE;
	return result;
}

ApplicationCopyEmailCommand*
application_copy_email_command_construct (GType object_type,
                                          GearyFolderSupportCopy* source,
                                          GearyFolder* destination,
                                          GeeCollection* conversations,
                                          GeeCollection* messages,
                                          const gchar* executed_label,
                                          const gchar* undone_label)
{
	ApplicationCopyEmailCommand * self = NULL;
	GearyFolderSupportCopy* _tmp0_;
	GearyFolder* _tmp1_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (source, GEARY_FOLDER_SUPPORT_TYPE_COPY), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (destination, GEARY_TYPE_FOLDER), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (messages, GEE_TYPE_COLLECTION), NULL);
	self = (ApplicationCopyEmailCommand*) application_email_command_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (source, GEARY_TYPE_FOLDER, GearyFolder), conversations, messages);
	_tmp0_ = _g_object_ref0 (source);
	_g_object_unref0 (self->priv->source);
	self->priv->source = _tmp0_;
	_tmp1_ = _g_object_ref0 (destination);
	_g_object_unref0 (self->priv->destination);
	self->priv->destination = _tmp1_;
	application_command_set_executed_label (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), executed_label);
	application_command_set_undone_label (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand), undone_label);
	return self;
}

ApplicationCopyEmailCommand*
application_copy_email_command_new (GearyFolderSupportCopy* source,
                                    GearyFolder* destination,
                                    GeeCollection* conversations,
                                    GeeCollection* messages,
                                    const gchar* executed_label,
                                    const gchar* undone_label)
{
	return application_copy_email_command_construct (APPLICATION_TYPE_COPY_EMAIL_COMMAND, source, destination, conversations, messages, executed_label, undone_label);
}

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

static void
application_copy_email_command_real_execute (ApplicationCommand* base,
                                             GCancellable* cancellable,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	ApplicationCopyEmailCommand * self;
	ApplicationCopyEmailCommandExecuteData* _data_;
	ApplicationCopyEmailCommand* _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, APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommand);
	_data_ = g_slice_new0 (ApplicationCopyEmailCommandExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_copy_email_command_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_;
	application_copy_email_command_real_execute_co (_data_);
}

static void
application_copy_email_command_execute_finish (ApplicationCommand* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	ApplicationCopyEmailCommandExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_copy_email_command_execute_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	ApplicationCopyEmailCommandExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_copy_email_command_real_execute_co (_data_);
}

static gboolean
application_copy_email_command_real_execute_co (ApplicationCopyEmailCommandExecuteData* _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_->open = FALSE;
	{
		_data_->_tmp0_ = _data_->self->priv->source;
		_data_->_state_ = 1;
		geary_folder_open_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FLAGS_NO_DELAY, _data_->cancellable, application_copy_email_command_execute_ready, _data_);
		return FALSE;
		_state_1:
		geary_folder_open_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_data_->open = TRUE;
		_data_->_tmp1_ = _data_->self->priv->source;
		_data_->_tmp2_ = application_email_command_get_email (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand));
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_tmp4_ = _data_->self->priv->destination;
		_data_->_tmp5_ = geary_folder_get_path (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_state_ = 2;
		geary_folder_support_copy_copy_email_async (_data_->_tmp1_, _data_->_tmp3_, _data_->_tmp6_, _data_->cancellable, application_copy_email_command_execute_ready, _data_);
		return FALSE;
		_state_2:
		geary_folder_support_copy_copy_email_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
	}
	__finally0:
	{
		if (_data_->open) {
			{
				_data_->_tmp7_ = _data_->self->priv->source;
				_data_->_state_ = 3;
				geary_folder_close_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEARY_TYPE_FOLDER, GearyFolder), NULL, application_copy_email_command_execute_ready, _data_);
				return FALSE;
				_state_3:
				geary_folder_close_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error1_);
				if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
					goto __catch1_g_error;
				}
			}
			goto __finally1;
			__catch1_g_error:
			{
				g_clear_error (&_data_->_inner_error1_);
			}
			__finally1:
			if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error1_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
	}
	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
application_copy_email_command_real_undo_data_free (gpointer _data)
{
	ApplicationCopyEmailCommandUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationCopyEmailCommandUndoData, _data_);
}

static void
application_copy_email_command_real_undo (ApplicationCommand* base,
                                          GCancellable* cancellable,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	ApplicationCopyEmailCommand * self;
	ApplicationCopyEmailCommandUndoData* _data_;
	ApplicationCopyEmailCommand* _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, APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommand);
	_data_ = g_slice_new0 (ApplicationCopyEmailCommandUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_copy_email_command_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_copy_email_command_real_undo_co (_data_);
}

static void
application_copy_email_command_undo_finish (ApplicationCommand* base,
                                            GAsyncResult* _res_,
                                            GError** error)
{
	ApplicationCopyEmailCommandUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
application_copy_email_command_real_undo_co (ApplicationCopyEmailCommandUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Cannot undo copy, not yet supported");
	_data_->_inner_error0_ = _data_->_tmp0_;
	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 ApplicationEmailCommandStateChangePolicy
application_copy_email_command_real_folders_removed (ApplicationEmailCommand* base,
                                                     GeeCollection* removed)
{
	ApplicationCopyEmailCommand * self;
	ApplicationEmailCommandStateChangePolicy _tmp0_ = 0;
	GearyFolder* _tmp1_;
	ApplicationEmailCommandStateChangePolicy result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommand);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (removed, GEE_TYPE_COLLECTION), 0);
	_tmp1_ = self->priv->destination;
	if (gee_collection_contains (removed, _tmp1_)) {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE;
	} else {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_CLASS (application_copy_email_command_parent_class)->folders_removed (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand), removed);
	}
	result = _tmp0_;
	return result;
}

static ApplicationEmailCommandStateChangePolicy
application_copy_email_command_real_email_removed (ApplicationEmailCommand* base,
                                                   GearyFolder* location,
                                                   GeeCollection* targets)
{
	ApplicationCopyEmailCommand * self;
	ApplicationEmailCommandStateChangePolicy _tmp0_ = 0;
	GearyFolder* _tmp1_;
	ApplicationEmailCommandStateChangePolicy result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommand);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (location, GEARY_TYPE_FOLDER), 0);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (targets, GEE_TYPE_COLLECTION), 0);
	_tmp1_ = self->priv->destination;
	if (location == _tmp1_) {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_STATE_CHANGE_POLICY_REMOVE;
	} else {
		_tmp0_ = APPLICATION_EMAIL_COMMAND_CLASS (application_copy_email_command_parent_class)->email_removed (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand), location, targets);
	}
	result = _tmp0_;
	return result;
}

static void
application_copy_email_command_class_init (ApplicationCopyEmailCommandClass * klass,
                                           gpointer klass_data)
{
	application_copy_email_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationCopyEmailCommand_private_offset);
	((ApplicationCommandClass *) klass)->execute = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_copy_email_command_real_execute;
	((ApplicationCommandClass *) klass)->execute_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_copy_email_command_execute_finish;
	((ApplicationCommandClass *) klass)->undo = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_copy_email_command_real_undo;
	((ApplicationCommandClass *) klass)->undo_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_copy_email_command_undo_finish;
	((ApplicationEmailCommandClass *) klass)->folders_removed = (ApplicationEmailCommandStateChangePolicy (*) (ApplicationEmailCommand*, GeeCollection*)) application_copy_email_command_real_folders_removed;
	((ApplicationEmailCommandClass *) klass)->email_removed = (ApplicationEmailCommandStateChangePolicy (*) (ApplicationEmailCommand*, GearyFolder*, GeeCollection*)) application_copy_email_command_real_email_removed;
	APPLICATION_COMMAND_CLASS (klass)->get_can_undo = (gboolean (*) (ApplicationCommand*)) application_copy_email_command_real_get_can_undo;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_copy_email_command_get_property;
	G_OBJECT_CLASS (klass)->finalize = application_copy_email_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_COPY_EMAIL_COMMAND_CAN_UNDO_PROPERTY, application_copy_email_command_properties[APPLICATION_COPY_EMAIL_COMMAND_CAN_UNDO_PROPERTY] = g_param_spec_boolean ("can-undo", "can-undo", "can-undo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_copy_email_command_instance_init (ApplicationCopyEmailCommand * self,
                                              gpointer klass)
{
	self->priv = application_copy_email_command_get_instance_private (self);
}

static void
application_copy_email_command_finalize (GObject * obj)
{
	ApplicationCopyEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommand);
	_g_object_unref0 (self->priv->source);
	_g_object_unref0 (self->priv->destination);
	G_OBJECT_CLASS (application_copy_email_command_parent_class)->finalize (obj);
}

static GType
application_copy_email_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationCopyEmailCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_copy_email_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationCopyEmailCommand), 0, (GInstanceInitFunc) application_copy_email_command_instance_init, NULL };
	GType application_copy_email_command_type_id;
	application_copy_email_command_type_id = g_type_register_static (APPLICATION_TYPE_EMAIL_COMMAND, "ApplicationCopyEmailCommand", &g_define_type_info, 0);
	ApplicationCopyEmailCommand_private_offset = g_type_add_instance_private (application_copy_email_command_type_id, sizeof (ApplicationCopyEmailCommandPrivate));
	return application_copy_email_command_type_id;
}

GType
application_copy_email_command_get_type (void)
{
	static volatile gsize application_copy_email_command_type_id__once = 0;
	if (g_once_init_enter (&application_copy_email_command_type_id__once)) {
		GType application_copy_email_command_type_id;
		application_copy_email_command_type_id = application_copy_email_command_get_type_once ();
		g_once_init_leave (&application_copy_email_command_type_id__once, application_copy_email_command_type_id);
	}
	return application_copy_email_command_type_id__once;
}

static void
_vala_application_copy_email_command_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec)
{
	ApplicationCopyEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_COPY_EMAIL_COMMAND, ApplicationCopyEmailCommand);
	switch (property_id) {
		case APPLICATION_COPY_EMAIL_COMMAND_CAN_UNDO_PROPERTY:
		g_value_set_boolean (value, application_command_get_can_undo (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand)));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_delete_email_command_get_instance_private (ApplicationDeleteEmailCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationDeleteEmailCommand_private_offset);
}

static gboolean
application_delete_email_command_real_get_can_undo (ApplicationCommand* base)
{
	gboolean result;
	ApplicationDeleteEmailCommand* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_DELETE_EMAIL_COMMAND, ApplicationDeleteEmailCommand);
	result = FALSE;
	return result;
}

ApplicationDeleteEmailCommand*
application_delete_email_command_construct (GType object_type,
                                            GearyFolderSupportRemove* target,
                                            GeeCollection* conversations,
                                            GeeCollection* email)
{
	ApplicationDeleteEmailCommand * self = NULL;
	GearyFolderSupportRemove* _tmp0_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (target, GEARY_FOLDER_SUPPORT_TYPE_REMOVE), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (conversations, GEE_TYPE_COLLECTION), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email, GEE_TYPE_COLLECTION), NULL);
	self = (ApplicationDeleteEmailCommand*) application_email_command_construct (object_type, G_TYPE_CHECK_INSTANCE_CAST (target, GEARY_TYPE_FOLDER, GearyFolder), conversations, email);
	_tmp0_ = _g_object_ref0 (target);
	_g_object_unref0 (self->priv->target);
	self->priv->target = _tmp0_;
	return self;
}

ApplicationDeleteEmailCommand*
application_delete_email_command_new (GearyFolderSupportRemove* target,
                                      GeeCollection* conversations,
                                      GeeCollection* email)
{
	return application_delete_email_command_construct (APPLICATION_TYPE_DELETE_EMAIL_COMMAND, target, conversations, email);
}

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

static void
application_delete_email_command_real_execute (ApplicationCommand* base,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	ApplicationDeleteEmailCommand * self;
	ApplicationDeleteEmailCommandExecuteData* _data_;
	ApplicationDeleteEmailCommand* _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, APPLICATION_TYPE_DELETE_EMAIL_COMMAND, ApplicationDeleteEmailCommand);
	_data_ = g_slice_new0 (ApplicationDeleteEmailCommandExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_delete_email_command_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_;
	application_delete_email_command_real_execute_co (_data_);
}

static void
application_delete_email_command_execute_finish (ApplicationCommand* base,
                                                 GAsyncResult* _res_,
                                                 GError** error)
{
	ApplicationDeleteEmailCommandExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_delete_email_command_execute_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	ApplicationDeleteEmailCommandExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_delete_email_command_real_execute_co (_data_);
}

static gboolean
application_delete_email_command_real_execute_co (ApplicationDeleteEmailCommandExecuteData* _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_->open = FALSE;
	{
		_data_->_tmp0_ = _data_->self->priv->target;
		_data_->_state_ = 1;
		geary_folder_open_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FLAGS_NO_DELAY, _data_->cancellable, application_delete_email_command_execute_ready, _data_);
		return FALSE;
		_state_1:
		geary_folder_open_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_data_->open = TRUE;
		_data_->_tmp1_ = _data_->self->priv->target;
		_data_->_tmp2_ = application_email_command_get_email (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_EMAIL_COMMAND, ApplicationEmailCommand));
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_state_ = 2;
		geary_folder_support_remove_remove_email_async (_data_->_tmp1_, _data_->_tmp3_, _data_->cancellable, application_delete_email_command_execute_ready, _data_);
		return FALSE;
		_state_2:
		geary_folder_support_remove_remove_email_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
	}
	__finally0:
	{
		if (_data_->open) {
			{
				_data_->_tmp4_ = _data_->self->priv->target;
				_data_->_state_ = 3;
				geary_folder_close_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, GEARY_TYPE_FOLDER, GearyFolder), NULL, application_delete_email_command_execute_ready, _data_);
				return FALSE;
				_state_3:
				geary_folder_close_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error1_);
				if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
					goto __catch1_g_error;
				}
			}
			goto __finally1;
			__catch1_g_error:
			{
				g_clear_error (&_data_->_inner_error1_);
			}
			__finally1:
			if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error1_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
	}
	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
application_delete_email_command_real_undo_data_free (gpointer _data)
{
	ApplicationDeleteEmailCommandUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationDeleteEmailCommandUndoData, _data_);
}

static void
application_delete_email_command_real_undo (ApplicationCommand* base,
                                            GCancellable* cancellable,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	ApplicationDeleteEmailCommand * self;
	ApplicationDeleteEmailCommandUndoData* _data_;
	ApplicationDeleteEmailCommand* _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, APPLICATION_TYPE_DELETE_EMAIL_COMMAND, ApplicationDeleteEmailCommand);
	_data_ = g_slice_new0 (ApplicationDeleteEmailCommandUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_delete_email_command_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_delete_email_command_real_undo_co (_data_);
}

static void
application_delete_email_command_undo_finish (ApplicationCommand* base,
                                              GAsyncResult* _res_,
                                              GError** error)
{
	ApplicationDeleteEmailCommandUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
application_delete_email_command_real_undo_co (ApplicationDeleteEmailCommandUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->target;
	_data_->_tmp1_ = geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_folder_path_to_string (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Cannot undo emptying a folder: %s", _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;
	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
application_delete_email_command_class_init (ApplicationDeleteEmailCommandClass * klass,
                                             gpointer klass_data)
{
	application_delete_email_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationDeleteEmailCommand_private_offset);
	((ApplicationCommandClass *) klass)->execute = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_delete_email_command_real_execute;
	((ApplicationCommandClass *) klass)->execute_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_delete_email_command_execute_finish;
	((ApplicationCommandClass *) klass)->undo = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_delete_email_command_real_undo;
	((ApplicationCommandClass *) klass)->undo_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_delete_email_command_undo_finish;
	APPLICATION_COMMAND_CLASS (klass)->get_can_undo = (gboolean (*) (ApplicationCommand*)) application_delete_email_command_real_get_can_undo;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_delete_email_command_get_property;
	G_OBJECT_CLASS (klass)->finalize = application_delete_email_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_DELETE_EMAIL_COMMAND_CAN_UNDO_PROPERTY, application_delete_email_command_properties[APPLICATION_DELETE_EMAIL_COMMAND_CAN_UNDO_PROPERTY] = g_param_spec_boolean ("can-undo", "can-undo", "can-undo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_delete_email_command_instance_init (ApplicationDeleteEmailCommand * self,
                                                gpointer klass)
{
	self->priv = application_delete_email_command_get_instance_private (self);
}

static void
application_delete_email_command_finalize (GObject * obj)
{
	ApplicationDeleteEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_DELETE_EMAIL_COMMAND, ApplicationDeleteEmailCommand);
	_g_object_unref0 (self->priv->target);
	G_OBJECT_CLASS (application_delete_email_command_parent_class)->finalize (obj);
}

static GType
application_delete_email_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationDeleteEmailCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_delete_email_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationDeleteEmailCommand), 0, (GInstanceInitFunc) application_delete_email_command_instance_init, NULL };
	GType application_delete_email_command_type_id;
	application_delete_email_command_type_id = g_type_register_static (APPLICATION_TYPE_EMAIL_COMMAND, "ApplicationDeleteEmailCommand", &g_define_type_info, 0);
	ApplicationDeleteEmailCommand_private_offset = g_type_add_instance_private (application_delete_email_command_type_id, sizeof (ApplicationDeleteEmailCommandPrivate));
	return application_delete_email_command_type_id;
}

GType
application_delete_email_command_get_type (void)
{
	static volatile gsize application_delete_email_command_type_id__once = 0;
	if (g_once_init_enter (&application_delete_email_command_type_id__once)) {
		GType application_delete_email_command_type_id;
		application_delete_email_command_type_id = application_delete_email_command_get_type_once ();
		g_once_init_leave (&application_delete_email_command_type_id__once, application_delete_email_command_type_id);
	}
	return application_delete_email_command_type_id__once;
}

static void
_vala_application_delete_email_command_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	ApplicationDeleteEmailCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_DELETE_EMAIL_COMMAND, ApplicationDeleteEmailCommand);
	switch (property_id) {
		case APPLICATION_DELETE_EMAIL_COMMAND_CAN_UNDO_PROPERTY:
		g_value_set_boolean (value, application_command_get_can_undo (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand)));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_empty_folder_command_get_instance_private (ApplicationEmptyFolderCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationEmptyFolderCommand_private_offset);
}

static gboolean
application_empty_folder_command_real_get_can_undo (ApplicationCommand* base)
{
	gboolean result;
	ApplicationEmptyFolderCommand* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommand);
	result = FALSE;
	return result;
}

ApplicationEmptyFolderCommand*
application_empty_folder_command_construct (GType object_type,
                                            GearyFolderSupportEmpty* target)
{
	ApplicationEmptyFolderCommand * self = NULL;
	GearyFolderSupportEmpty* _tmp0_;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (target, GEARY_FOLDER_SUPPORT_TYPE_EMPTY), NULL);
	self = (ApplicationEmptyFolderCommand*) application_command_construct (object_type);
	_tmp0_ = _g_object_ref0 (target);
	_g_object_unref0 (self->priv->target);
	self->priv->target = _tmp0_;
	return self;
}

ApplicationEmptyFolderCommand*
application_empty_folder_command_new (GearyFolderSupportEmpty* target)
{
	return application_empty_folder_command_construct (APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, target);
}

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

static void
application_empty_folder_command_real_execute (ApplicationCommand* base,
                                               GCancellable* cancellable,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	ApplicationEmptyFolderCommand * self;
	ApplicationEmptyFolderCommandExecuteData* _data_;
	ApplicationEmptyFolderCommand* _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, APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommand);
	_data_ = g_slice_new0 (ApplicationEmptyFolderCommandExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_empty_folder_command_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_;
	application_empty_folder_command_real_execute_co (_data_);
}

static void
application_empty_folder_command_execute_finish (ApplicationCommand* base,
                                                 GAsyncResult* _res_,
                                                 GError** error)
{
	ApplicationEmptyFolderCommandExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_empty_folder_command_execute_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_)
{
	ApplicationEmptyFolderCommandExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_empty_folder_command_real_execute_co (_data_);
}

static gboolean
application_empty_folder_command_real_execute_co (ApplicationEmptyFolderCommandExecuteData* _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_->open = FALSE;
	{
		_data_->_tmp0_ = _data_->self->priv->target;
		_data_->_state_ = 1;
		geary_folder_open_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), GEARY_FOLDER_OPEN_FLAGS_NO_DELAY, _data_->cancellable, application_empty_folder_command_execute_ready, _data_);
		return FALSE;
		_state_1:
		geary_folder_open_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
		_data_->open = TRUE;
		_data_->_tmp1_ = _data_->self->priv->target;
		_data_->_state_ = 2;
		geary_folder_support_empty_empty_folder_async (_data_->_tmp1_, _data_->cancellable, application_empty_folder_command_execute_ready, _data_);
		return FALSE;
		_state_2:
		geary_folder_support_empty_empty_folder_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __finally0;
		}
	}
	__finally0:
	{
		if (_data_->open) {
			{
				_data_->_tmp2_ = _data_->self->priv->target;
				_data_->_state_ = 3;
				geary_folder_close_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_TYPE_FOLDER, GearyFolder), NULL, application_empty_folder_command_execute_ready, _data_);
				return FALSE;
				_state_3:
				geary_folder_close_finish (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp2_, GEARY_TYPE_FOLDER, GearyFolder), _data_->_res_, &_data_->_inner_error1_);
				if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
					goto __catch1_g_error;
				}
			}
			goto __finally1;
			__catch1_g_error:
			{
				g_clear_error (&_data_->_inner_error1_);
			}
			__finally1:
			if (G_UNLIKELY (_data_->_inner_error1_ != NULL)) {
				g_task_return_error (_data_->_async_result, _data_->_inner_error1_);
				g_object_unref (_data_->_async_result);
				return FALSE;
			}
		}
	}
	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
application_empty_folder_command_real_undo_data_free (gpointer _data)
{
	ApplicationEmptyFolderCommandUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationEmptyFolderCommandUndoData, _data_);
}

static void
application_empty_folder_command_real_undo (ApplicationCommand* base,
                                            GCancellable* cancellable,
                                            GAsyncReadyCallback _callback_,
                                            gpointer _user_data_)
{
	ApplicationEmptyFolderCommand * self;
	ApplicationEmptyFolderCommandUndoData* _data_;
	ApplicationEmptyFolderCommand* _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, APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommand);
	_data_ = g_slice_new0 (ApplicationEmptyFolderCommandUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_empty_folder_command_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_empty_folder_command_real_undo_co (_data_);
}

static void
application_empty_folder_command_undo_finish (ApplicationCommand* base,
                                              GAsyncResult* _res_,
                                              GError** error)
{
	ApplicationEmptyFolderCommandUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
application_empty_folder_command_real_undo_co (ApplicationEmptyFolderCommandUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->target;
	_data_->_tmp1_ = geary_folder_get_path (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp0_, GEARY_TYPE_FOLDER, GearyFolder));
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = geary_folder_path_to_string (_data_->_tmp2_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = g_error_new (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_UNSUPPORTED, "Cannot undo emptying a folder: %s", _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;
	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;
}

/** Determines if this command is equal to another. */
static gboolean
application_empty_folder_command_real_equal_to (ApplicationCommand* base,
                                                ApplicationCommand* other)
{
	ApplicationEmptyFolderCommand * self;
	ApplicationEmptyFolderCommand* other_type = NULL;
	ApplicationEmptyFolderCommand* _tmp0_;
	gboolean _tmp1_ = FALSE;
	ApplicationEmptyFolderCommand* _tmp2_;
	gboolean result;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommand);
	g_return_val_if_fail (APPLICATION_IS_COMMAND (other), FALSE);
	_tmp0_ = _g_object_ref0 (APPLICATION_IS_EMPTY_FOLDER_COMMAND (other) ? ((ApplicationEmptyFolderCommand*) other) : NULL);
	other_type = _tmp0_;
	_tmp2_ = other_type;
	if (_tmp2_ != NULL) {
		GearyFolderSupportEmpty* _tmp3_;
		ApplicationEmptyFolderCommand* _tmp4_;
		GearyFolderSupportEmpty* _tmp5_;
		_tmp3_ = self->priv->target;
		_tmp4_ = other_type;
		_tmp5_ = _tmp4_->priv->target;
		_tmp1_ = _tmp3_ == _tmp5_;
	} else {
		_tmp1_ = FALSE;
	}
	result = _tmp1_;
	_g_object_unref0 (other_type);
	return result;
}

static void
application_empty_folder_command_class_init (ApplicationEmptyFolderCommandClass * klass,
                                             gpointer klass_data)
{
	application_empty_folder_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationEmptyFolderCommand_private_offset);
	((ApplicationCommandClass *) klass)->execute = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_empty_folder_command_real_execute;
	((ApplicationCommandClass *) klass)->execute_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_empty_folder_command_execute_finish;
	((ApplicationCommandClass *) klass)->undo = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_empty_folder_command_real_undo;
	((ApplicationCommandClass *) klass)->undo_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_empty_folder_command_undo_finish;
	((ApplicationCommandClass *) klass)->equal_to = (gboolean (*) (ApplicationCommand*, ApplicationCommand*)) application_empty_folder_command_real_equal_to;
	APPLICATION_COMMAND_CLASS (klass)->get_can_undo = (gboolean (*) (ApplicationCommand*)) application_empty_folder_command_real_get_can_undo;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_empty_folder_command_get_property;
	G_OBJECT_CLASS (klass)->finalize = application_empty_folder_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_EMPTY_FOLDER_COMMAND_CAN_UNDO_PROPERTY, application_empty_folder_command_properties[APPLICATION_EMPTY_FOLDER_COMMAND_CAN_UNDO_PROPERTY] = g_param_spec_boolean ("can-undo", "can-undo", "can-undo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_empty_folder_command_instance_init (ApplicationEmptyFolderCommand * self,
                                                gpointer klass)
{
	self->priv = application_empty_folder_command_get_instance_private (self);
}

static void
application_empty_folder_command_finalize (GObject * obj)
{
	ApplicationEmptyFolderCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommand);
	_g_object_unref0 (self->priv->target);
	G_OBJECT_CLASS (application_empty_folder_command_parent_class)->finalize (obj);
}

static GType
application_empty_folder_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationEmptyFolderCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_empty_folder_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationEmptyFolderCommand), 0, (GInstanceInitFunc) application_empty_folder_command_instance_init, NULL };
	GType application_empty_folder_command_type_id;
	application_empty_folder_command_type_id = g_type_register_static (APPLICATION_TYPE_COMMAND, "ApplicationEmptyFolderCommand", &g_define_type_info, 0);
	ApplicationEmptyFolderCommand_private_offset = g_type_add_instance_private (application_empty_folder_command_type_id, sizeof (ApplicationEmptyFolderCommandPrivate));
	return application_empty_folder_command_type_id;
}

GType
application_empty_folder_command_get_type (void)
{
	static volatile gsize application_empty_folder_command_type_id__once = 0;
	if (g_once_init_enter (&application_empty_folder_command_type_id__once)) {
		GType application_empty_folder_command_type_id;
		application_empty_folder_command_type_id = application_empty_folder_command_get_type_once ();
		g_once_init_leave (&application_empty_folder_command_type_id__once, application_empty_folder_command_type_id);
	}
	return application_empty_folder_command_type_id__once;
}

static void
_vala_application_empty_folder_command_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	ApplicationEmptyFolderCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_EMPTY_FOLDER_COMMAND, ApplicationEmptyFolderCommand);
	switch (property_id) {
		case APPLICATION_EMPTY_FOLDER_COMMAND_CAN_UNDO_PROPERTY:
		g_value_set_boolean (value, application_command_get_can_undo (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand)));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_composer_command_get_instance_private (ApplicationComposerCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationComposerCommand_private_offset);
}

static gboolean
application_composer_command_real_get_can_redo (ApplicationCommand* base)
{
	gboolean result;
	ApplicationComposerCommand* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand);
	result = FALSE;
	return result;
}

ComposerWidget*
application_composer_command_get_composer (ApplicationComposerCommand* self)
{
	ComposerWidget* result;
	ComposerWidget* _tmp0_;
	g_return_val_if_fail (APPLICATION_IS_COMPOSER_COMMAND (self), NULL);
	_tmp0_ = self->priv->_composer;
	result = _tmp0_;
	return result;
}

static void
application_composer_command_set_composer (ApplicationComposerCommand* self,
                                           ComposerWidget* value)
{
	ComposerWidget* old_value;
	g_return_if_fail (APPLICATION_IS_COMPOSER_COMMAND (self));
	old_value = application_composer_command_get_composer (self);
	if (old_value != value) {
		ComposerWidget* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_composer);
		self->priv->_composer = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, application_composer_command_properties[APPLICATION_COMPOSER_COMMAND_COMPOSER_PROPERTY]);
	}
}

ApplicationComposerCommand*
application_composer_command_construct (GType object_type,
                                        ComposerWidget* composer)
{
	ApplicationComposerCommand * self = NULL;
	g_return_val_if_fail (COMPOSER_IS_WIDGET (composer), NULL);
	self = (ApplicationComposerCommand*) application_command_construct (object_type);
	application_composer_command_set_composer (self, composer);
	return self;
}

void
application_composer_command_clear_composer (ApplicationComposerCommand* self)
{
	g_return_if_fail (APPLICATION_IS_COMPOSER_COMMAND (self));
	application_composer_command_set_composer (self, NULL);
}

void
application_composer_command_close_composer (ApplicationComposerCommand* self)
{
	ComposerWidget* _tmp0_;
	g_return_if_fail (APPLICATION_IS_COMPOSER_COMMAND (self));
	_tmp0_ = self->priv->_composer;
	composer_widget_close (_tmp0_, NULL, NULL);
	application_composer_command_set_composer (self, NULL);
}

static void
application_composer_command_class_init (ApplicationComposerCommandClass * klass,
                                         gpointer klass_data)
{
	application_composer_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationComposerCommand_private_offset);
	APPLICATION_COMMAND_CLASS (klass)->get_can_redo = (gboolean (*) (ApplicationCommand*)) application_composer_command_real_get_can_redo;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_composer_command_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_application_composer_command_set_property;
	G_OBJECT_CLASS (klass)->finalize = application_composer_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_COMPOSER_COMMAND_CAN_REDO_PROPERTY, application_composer_command_properties[APPLICATION_COMPOSER_COMMAND_CAN_REDO_PROPERTY] = g_param_spec_boolean ("can-redo", "can-redo", "can-redo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_COMPOSER_COMMAND_COMPOSER_PROPERTY, application_composer_command_properties[APPLICATION_COMPOSER_COMMAND_COMPOSER_PROPERTY] = g_param_spec_object ("composer", "composer", "composer", COMPOSER_TYPE_WIDGET, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_composer_command_instance_init (ApplicationComposerCommand * self,
                                            gpointer klass)
{
	self->priv = application_composer_command_get_instance_private (self);
}

static void
application_composer_command_finalize (GObject * obj)
{
	ApplicationComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand);
	_g_object_unref0 (self->priv->_composer);
	G_OBJECT_CLASS (application_composer_command_parent_class)->finalize (obj);
}

static GType
application_composer_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationComposerCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_composer_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationComposerCommand), 0, (GInstanceInitFunc) application_composer_command_instance_init, NULL };
	GType application_composer_command_type_id;
	application_composer_command_type_id = g_type_register_static (APPLICATION_TYPE_COMMAND, "ApplicationComposerCommand", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	ApplicationComposerCommand_private_offset = g_type_add_instance_private (application_composer_command_type_id, sizeof (ApplicationComposerCommandPrivate));
	return application_composer_command_type_id;
}

GType
application_composer_command_get_type (void)
{
	static volatile gsize application_composer_command_type_id__once = 0;
	if (g_once_init_enter (&application_composer_command_type_id__once)) {
		GType application_composer_command_type_id;
		application_composer_command_type_id = application_composer_command_get_type_once ();
		g_once_init_leave (&application_composer_command_type_id__once, application_composer_command_type_id);
	}
	return application_composer_command_type_id__once;
}

static void
_vala_application_composer_command_get_property (GObject * object,
                                                 guint property_id,
                                                 GValue * value,
                                                 GParamSpec * pspec)
{
	ApplicationComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand);
	switch (property_id) {
		case APPLICATION_COMPOSER_COMMAND_CAN_REDO_PROPERTY:
		g_value_set_boolean (value, application_command_get_can_redo (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand)));
		break;
		case APPLICATION_COMPOSER_COMMAND_COMPOSER_PROPERTY:
		g_value_set_object (value, application_composer_command_get_composer (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_application_composer_command_set_property (GObject * object,
                                                 guint property_id,
                                                 const GValue * value,
                                                 GParamSpec * pspec)
{
	ApplicationComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand);
	switch (property_id) {
		case APPLICATION_COMPOSER_COMMAND_COMPOSER_PROPERTY:
		application_composer_command_set_composer (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_send_composer_command_get_instance_private (ApplicationSendComposerCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationSendComposerCommand_private_offset);
}

static gboolean
application_send_composer_command_real_get_can_undo (ApplicationCommand* base)
{
	gboolean result;
	ApplicationSendComposerCommand* self;
	ApplicationClient* _tmp0_;
	ApplicationConfiguration* _tmp1_;
	ApplicationConfiguration* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_SEND_COMPOSER_COMMAND, ApplicationSendComposerCommand);
	_tmp0_ = self->priv->application;
	_tmp1_ = application_client_get_config (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = application_configuration_get_undo_send_delay (_tmp2_);
	_tmp4_ = _tmp3_;
	result = _tmp4_ > 0;
	return result;
}

static void
_application_send_composer_command_on_commit_timeout_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                         gpointer self)
{
	application_send_composer_command_on_commit_timeout ((ApplicationSendComposerCommand*) self);
}

ApplicationSendComposerCommand*
application_send_composer_command_construct (GType object_type,
                                             ApplicationClient* application,
                                             ApplicationAccountContext* context,
                                             ComposerWidget* composer)
{
	ApplicationSendComposerCommand * self = NULL;
	ApplicationClient* _tmp0_;
	ApplicationAccountContext* _tmp1_;
	GearyAccount* _tmp2_;
	GearyAccount* _tmp3_;
	GearyClientService* _tmp4_;
	GearyClientService* _tmp5_;
	GearySmtpClientService* _tmp6_;
	gint send_delay = 0;
	ApplicationClient* _tmp7_;
	ApplicationConfiguration* _tmp8_;
	ApplicationConfiguration* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	gint _tmp12_ = 0;
	GearyTimeoutManager* _tmp13_;
	g_return_val_if_fail (APPLICATION_IS_CLIENT (application), NULL);
	g_return_val_if_fail (APPLICATION_IS_ACCOUNT_CONTEXT (context), NULL);
	g_return_val_if_fail (COMPOSER_IS_WIDGET (composer), NULL);
	self = (ApplicationSendComposerCommand*) application_composer_command_construct (object_type, composer);
	_tmp0_ = _g_object_ref0 (application);
	_g_object_unref0 (self->priv->application);
	self->priv->application = _tmp0_;
	_tmp1_ = _g_object_ref0 (context);
	_g_object_unref0 (self->priv->context);
	self->priv->context = _tmp1_;
	_tmp2_ = application_account_context_get_account (context);
	_tmp3_ = _tmp2_;
	_tmp4_ = geary_account_get_outgoing (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, GEARY_SMTP_TYPE_CLIENT_SERVICE, GearySmtpClientService));
	_g_object_unref0 (self->priv->smtp);
	self->priv->smtp = _tmp6_;
	_tmp7_ = self->priv->application;
	_tmp8_ = application_client_get_config (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = application_configuration_get_undo_send_delay (_tmp9_);
	_tmp11_ = _tmp10_;
	send_delay = _tmp11_;
	if (send_delay > 0) {
		_tmp12_ = send_delay;
	} else {
		_tmp12_ = 0;
	}
	_tmp13_ = geary_timeout_manager_new_seconds ((guint) _tmp12_, _application_send_composer_command_on_commit_timeout_geary_timeout_manager_timeout_func, self);
	_g_object_unref0 (self->priv->commit_timer);
	self->priv->commit_timer = _tmp13_;
	return self;
}

ApplicationSendComposerCommand*
application_send_composer_command_new (ApplicationClient* application,
                                       ApplicationAccountContext* context,
                                       ComposerWidget* composer)
{
	return application_send_composer_command_construct (APPLICATION_TYPE_SEND_COMPOSER_COMMAND, application, context, composer);
}

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

static void
application_send_composer_command_real_execute (ApplicationCommand* base,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	ApplicationSendComposerCommand * self;
	ApplicationSendComposerCommandExecuteData* _data_;
	ApplicationSendComposerCommand* _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, APPLICATION_TYPE_SEND_COMPOSER_COMMAND, ApplicationSendComposerCommand);
	_data_ = g_slice_new0 (ApplicationSendComposerCommandExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_send_composer_command_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_;
	application_send_composer_command_real_execute_co (_data_);
}

static void
application_send_composer_command_execute_finish (ApplicationCommand* base,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	ApplicationSendComposerCommandExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_send_composer_command_execute_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	ApplicationSendComposerCommandExecuteData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_send_composer_command_real_execute_co (_data_);
}

static gboolean
application_send_composer_command_real_execute_co (ApplicationSendComposerCommandExecuteData* _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_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_state_ = 1;
	composer_widget_to_composed_email (_data_->_tmp1_, NULL, FALSE, application_send_composer_command_execute_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp2_ = composer_widget_to_composed_email_finish (_data_->_tmp1_, _data_->_res_);
	_data_->email = _data_->_tmp2_;
	_data_->_tmp3_ = application_command_get_can_undo (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND, ApplicationCommand));
	_data_->_tmp4_ = _data_->_tmp3_;
	if (_data_->_tmp4_) {
		_data_->_tmp5_ = _data_->email;
		_data_->_tmp6_ = util_email_to_short_recipient_display (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GEARY_TYPE_EMAIL_HEADER_SET, GearyEmailHeaderSet));
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp8_ = g_strdup_printf (_ ("Email to %s queued for delivery"), _data_->_tmp7_);
		_data_->_tmp9_ = _data_->_tmp8_;
		application_command_set_executed_label (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND, ApplicationCommand), _data_->_tmp9_);
		_g_free0 (_data_->_tmp9_);
		_g_free0 (_data_->_tmp7_);
		_data_->_tmp11_ = _data_->self->priv->smtp;
		_data_->_tmp12_ = _data_->email;
		_data_->_state_ = 2;
		geary_smtp_client_service_save_email (_data_->_tmp11_, _data_->_tmp12_, _data_->cancellable, application_send_composer_command_execute_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp13_ = geary_smtp_client_service_save_email_finish (_data_->_tmp11_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp10_ = _data_->_tmp13_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->email);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp14_ = _data_->_tmp10_;
		_data_->_tmp10_ = NULL;
		_g_object_unref0 (_data_->self->priv->saved);
		_data_->self->priv->saved = _data_->_tmp14_;
		_data_->_tmp15_ = _data_->self->priv->commit_timer;
		geary_timeout_manager_start (_data_->_tmp15_);
		_g_object_unref0 (_data_->_tmp10_);
	} else {
		_data_->_tmp16_ = _data_->self->priv->smtp;
		_data_->_tmp17_ = _data_->email;
		_data_->_state_ = 3;
		geary_smtp_client_service_send_email (_data_->_tmp16_, _data_->_tmp17_, _data_->cancellable, application_send_composer_command_execute_ready, _data_);
		return FALSE;
		_state_3:
		geary_smtp_client_service_send_email_finish (_data_->_tmp16_, _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_->email);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	_g_object_unref0 (_data_->email);
	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
application_send_composer_command_real_undo_data_free (gpointer _data)
{
	ApplicationSendComposerCommandUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationSendComposerCommandUndoData, _data_);
}

static void
application_send_composer_command_real_undo (ApplicationCommand* base,
                                             GCancellable* cancellable,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	ApplicationSendComposerCommand * self;
	ApplicationSendComposerCommandUndoData* _data_;
	ApplicationSendComposerCommand* _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, APPLICATION_TYPE_SEND_COMPOSER_COMMAND, ApplicationSendComposerCommand);
	_data_ = g_slice_new0 (ApplicationSendComposerCommandUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_send_composer_command_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_send_composer_command_real_undo_co (_data_);
}

static void
application_send_composer_command_undo_finish (ApplicationCommand* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	ApplicationSendComposerCommandUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static void
application_send_composer_command_undo_ready (GObject* source_object,
                                              GAsyncResult* _res_,
                                              gpointer _user_data_)
{
	ApplicationSendComposerCommandUndoData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	application_send_composer_command_real_undo_co (_data_);
}

static gboolean
application_send_composer_command_real_undo_co (ApplicationSendComposerCommandUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->commit_timer;
	geary_timeout_manager_reset (_data_->_tmp0_);
	_data_->_tmp1_ = _data_->self->priv->smtp;
	_data_->_tmp2_ = geary_smtp_client_service_get_outbox (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = _data_->self->priv->saved;
	_data_->_tmp5_ = geary_collection_single (GEARY_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp4_);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_state_ = 1;
	geary_outbox_folder_remove_email_async (_data_->_tmp3_, _data_->_tmp6_, _data_->cancellable, application_send_composer_command_undo_ready, _data_);
	return FALSE;
	_state_1:
	geary_outbox_folder_remove_email_finish (_data_->_tmp3_, _data_->_res_, &_data_->_inner_error0_);
	_g_object_unref0 (_data_->_tmp6_);
	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_object_unref0 (_data_->self->priv->saved);
	_data_->self->priv->saved = NULL;
	_data_->_tmp7_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
	_data_->_tmp8_ = _data_->_tmp7_;
	composer_widget_set_enabled (_data_->_tmp8_, TRUE);
	_data_->_tmp9_ = _data_->self->priv->application;
	_data_->_tmp10_ = application_client_get_controller (_data_->_tmp9_);
	_data_->_tmp11_ = _data_->_tmp10_;
	_data_->_tmp12_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
	_data_->_tmp13_ = _data_->_tmp12_;
	application_controller_present_composer (_data_->_tmp11_, _data_->_tmp13_);
	application_composer_command_clear_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
	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
application_send_composer_command_on_commit_timeout (ApplicationSendComposerCommand* self)
{
	GearySmtpClientService* _tmp0_;
	GearyEmailIdentifier* _tmp1_;
	g_return_if_fail (APPLICATION_IS_SEND_COMPOSER_COMMAND (self));
	_tmp0_ = self->priv->smtp;
	_tmp1_ = self->priv->saved;
	geary_smtp_client_service_queue_email (_tmp0_, _tmp1_);
	_g_object_unref0 (self->priv->saved);
	self->priv->saved = NULL;
	application_composer_command_close_composer (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
}

static void
application_send_composer_command_class_init (ApplicationSendComposerCommandClass * klass,
                                              gpointer klass_data)
{
	application_send_composer_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationSendComposerCommand_private_offset);
	((ApplicationCommandClass *) klass)->execute = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_send_composer_command_real_execute;
	((ApplicationCommandClass *) klass)->execute_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_send_composer_command_execute_finish;
	((ApplicationCommandClass *) klass)->undo = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_send_composer_command_real_undo;
	((ApplicationCommandClass *) klass)->undo_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_send_composer_command_undo_finish;
	APPLICATION_COMMAND_CLASS (klass)->get_can_undo = (gboolean (*) (ApplicationCommand*)) application_send_composer_command_real_get_can_undo;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_send_composer_command_get_property;
	G_OBJECT_CLASS (klass)->finalize = application_send_composer_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_SEND_COMPOSER_COMMAND_CAN_UNDO_PROPERTY, application_send_composer_command_properties[APPLICATION_SEND_COMPOSER_COMMAND_CAN_UNDO_PROPERTY] = g_param_spec_boolean ("can-undo", "can-undo", "can-undo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_send_composer_command_instance_init (ApplicationSendComposerCommand * self,
                                                 gpointer klass)
{
	self->priv = application_send_composer_command_get_instance_private (self);
	self->priv->saved = NULL;
}

static void
application_send_composer_command_finalize (GObject * obj)
{
	ApplicationSendComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_SEND_COMPOSER_COMMAND, ApplicationSendComposerCommand);
	_g_object_unref0 (self->priv->application);
	_g_object_unref0 (self->priv->context);
	_g_object_unref0 (self->priv->smtp);
	_g_object_unref0 (self->priv->commit_timer);
	_g_object_unref0 (self->priv->saved);
	G_OBJECT_CLASS (application_send_composer_command_parent_class)->finalize (obj);
}

static GType
application_send_composer_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationSendComposerCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_send_composer_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationSendComposerCommand), 0, (GInstanceInitFunc) application_send_composer_command_instance_init, NULL };
	GType application_send_composer_command_type_id;
	application_send_composer_command_type_id = g_type_register_static (APPLICATION_TYPE_COMPOSER_COMMAND, "ApplicationSendComposerCommand", &g_define_type_info, 0);
	ApplicationSendComposerCommand_private_offset = g_type_add_instance_private (application_send_composer_command_type_id, sizeof (ApplicationSendComposerCommandPrivate));
	return application_send_composer_command_type_id;
}

GType
application_send_composer_command_get_type (void)
{
	static volatile gsize application_send_composer_command_type_id__once = 0;
	if (g_once_init_enter (&application_send_composer_command_type_id__once)) {
		GType application_send_composer_command_type_id;
		application_send_composer_command_type_id = application_send_composer_command_get_type_once ();
		g_once_init_leave (&application_send_composer_command_type_id__once, application_send_composer_command_type_id);
	}
	return application_send_composer_command_type_id__once;
}

static void
_vala_application_send_composer_command_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec)
{
	ApplicationSendComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_SEND_COMPOSER_COMMAND, ApplicationSendComposerCommand);
	switch (property_id) {
		case APPLICATION_SEND_COMPOSER_COMMAND_CAN_UNDO_PROPERTY:
		g_value_set_boolean (value, application_command_get_can_undo (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand)));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_save_composer_command_get_instance_private (ApplicationSaveComposerCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationSaveComposerCommand_private_offset);
}

static gboolean
application_save_composer_command_real_get_can_redo (ApplicationCommand* base)
{
	gboolean result;
	ApplicationSaveComposerCommand* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, ApplicationSaveComposerCommand);
	result = FALSE;
	return result;
}

static void
_application_save_composer_command_on_destroy_timeout_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                          gpointer self)
{
	application_save_composer_command_on_destroy_timeout ((ApplicationSaveComposerCommand*) self);
}

ApplicationSaveComposerCommand*
application_save_composer_command_construct (GType object_type,
                                             ApplicationController* controller,
                                             ComposerWidget* composer)
{
	ApplicationSaveComposerCommand * self = NULL;
	ApplicationController* _tmp0_;
	GearyTimeoutManager* _tmp1_;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (controller), NULL);
	g_return_val_if_fail (COMPOSER_IS_WIDGET (composer), NULL);
	self = (ApplicationSaveComposerCommand*) application_composer_command_construct (object_type, composer);
	_tmp0_ = _g_object_ref0 (controller);
	_g_object_unref0 (self->priv->controller);
	self->priv->controller = _tmp0_;
	_tmp1_ = geary_timeout_manager_new_seconds ((guint) APPLICATION_SAVE_COMPOSER_COMMAND_DESTROY_TIMEOUT_SEC, _application_save_composer_command_on_destroy_timeout_geary_timeout_manager_timeout_func, self);
	_g_object_unref0 (self->priv->destroy_timer);
	self->priv->destroy_timer = _tmp1_;
	return self;
}

ApplicationSaveComposerCommand*
application_save_composer_command_new (ApplicationController* controller,
                                       ComposerWidget* composer)
{
	return application_save_composer_command_construct (APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, controller, composer);
}

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

static void
application_save_composer_command_real_execute (ApplicationCommand* base,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	ApplicationSaveComposerCommand * self;
	ApplicationSaveComposerCommandExecuteData* _data_;
	ApplicationSaveComposerCommand* _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, APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, ApplicationSaveComposerCommand);
	_data_ = g_slice_new0 (ApplicationSaveComposerCommandExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_save_composer_command_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_;
	application_save_composer_command_real_execute_co (_data_);
}

static void
application_save_composer_command_execute_finish (ApplicationCommand* base,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	ApplicationSaveComposerCommandExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
application_save_composer_command_real_execute_co (ApplicationSaveComposerCommandExecuteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	application_command_set_executed_label (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND, ApplicationCommand), _ ("Email saved as draft"));
	_data_->_tmp0_ = _data_->self->priv->destroy_timer;
	geary_timeout_manager_start (_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
application_save_composer_command_real_undo_data_free (gpointer _data)
{
	ApplicationSaveComposerCommandUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationSaveComposerCommandUndoData, _data_);
}

static void
application_save_composer_command_real_undo (ApplicationCommand* base,
                                             GCancellable* cancellable,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	ApplicationSaveComposerCommand * self;
	ApplicationSaveComposerCommandUndoData* _data_;
	ApplicationSaveComposerCommand* _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, APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, ApplicationSaveComposerCommand);
	_data_ = g_slice_new0 (ApplicationSaveComposerCommandUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_save_composer_command_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_save_composer_command_real_undo_co (_data_);
}

static void
application_save_composer_command_undo_finish (ApplicationCommand* base,
                                               GAsyncResult* _res_,
                                               GError** error)
{
	ApplicationSaveComposerCommandUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
application_save_composer_command_real_undo_co (ApplicationSaveComposerCommandUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
	_data_->_tmp1_ = _data_->_tmp0_;
	if (_data_->_tmp1_ != NULL) {
		_data_->_tmp2_ = _data_->self->priv->destroy_timer;
		geary_timeout_manager_reset (_data_->_tmp2_);
		_data_->_tmp3_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
		_data_->_tmp4_ = _data_->_tmp3_;
		composer_widget_set_enabled (_data_->_tmp4_, TRUE);
		_data_->_tmp5_ = _data_->self->priv->controller;
		_data_->_tmp6_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
		_data_->_tmp7_ = _data_->_tmp6_;
		application_controller_present_composer (_data_->_tmp5_, _data_->_tmp7_);
		application_composer_command_clear_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
	} else {
		application_command_set_undone_label (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND, ApplicationCommand), _ ("Composer could not be restored"));
	}
	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
application_save_composer_command_on_destroy_timeout (ApplicationSaveComposerCommand* self)
{
	g_return_if_fail (APPLICATION_IS_SAVE_COMPOSER_COMMAND (self));
	application_composer_command_close_composer (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
}

static void
application_save_composer_command_class_init (ApplicationSaveComposerCommandClass * klass,
                                              gpointer klass_data)
{
	application_save_composer_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationSaveComposerCommand_private_offset);
	((ApplicationCommandClass *) klass)->execute = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_save_composer_command_real_execute;
	((ApplicationCommandClass *) klass)->execute_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_save_composer_command_execute_finish;
	((ApplicationCommandClass *) klass)->undo = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_save_composer_command_real_undo;
	((ApplicationCommandClass *) klass)->undo_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_save_composer_command_undo_finish;
	APPLICATION_COMMAND_CLASS (klass)->get_can_redo = (gboolean (*) (ApplicationCommand*)) application_save_composer_command_real_get_can_redo;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_save_composer_command_get_property;
	G_OBJECT_CLASS (klass)->finalize = application_save_composer_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_SAVE_COMPOSER_COMMAND_CAN_REDO_PROPERTY, application_save_composer_command_properties[APPLICATION_SAVE_COMPOSER_COMMAND_CAN_REDO_PROPERTY] = g_param_spec_boolean ("can-redo", "can-redo", "can-redo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_save_composer_command_instance_init (ApplicationSaveComposerCommand * self,
                                                 gpointer klass)
{
	self->priv = application_save_composer_command_get_instance_private (self);
}

static void
application_save_composer_command_finalize (GObject * obj)
{
	ApplicationSaveComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, ApplicationSaveComposerCommand);
	_g_object_unref0 (self->priv->controller);
	_g_object_unref0 (self->priv->destroy_timer);
	G_OBJECT_CLASS (application_save_composer_command_parent_class)->finalize (obj);
}

static GType
application_save_composer_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationSaveComposerCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_save_composer_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationSaveComposerCommand), 0, (GInstanceInitFunc) application_save_composer_command_instance_init, NULL };
	GType application_save_composer_command_type_id;
	application_save_composer_command_type_id = g_type_register_static (APPLICATION_TYPE_COMPOSER_COMMAND, "ApplicationSaveComposerCommand", &g_define_type_info, 0);
	ApplicationSaveComposerCommand_private_offset = g_type_add_instance_private (application_save_composer_command_type_id, sizeof (ApplicationSaveComposerCommandPrivate));
	return application_save_composer_command_type_id;
}

GType
application_save_composer_command_get_type (void)
{
	static volatile gsize application_save_composer_command_type_id__once = 0;
	if (g_once_init_enter (&application_save_composer_command_type_id__once)) {
		GType application_save_composer_command_type_id;
		application_save_composer_command_type_id = application_save_composer_command_get_type_once ();
		g_once_init_leave (&application_save_composer_command_type_id__once, application_save_composer_command_type_id);
	}
	return application_save_composer_command_type_id__once;
}

static void
_vala_application_save_composer_command_get_property (GObject * object,
                                                      guint property_id,
                                                      GValue * value,
                                                      GParamSpec * pspec)
{
	ApplicationSaveComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_SAVE_COMPOSER_COMMAND, ApplicationSaveComposerCommand);
	switch (property_id) {
		case APPLICATION_SAVE_COMPOSER_COMMAND_CAN_REDO_PROPERTY:
		g_value_set_boolean (value, application_command_get_can_redo (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand)));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static inline gpointer
application_discard_composer_command_get_instance_private (ApplicationDiscardComposerCommand* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationDiscardComposerCommand_private_offset);
}

static gboolean
application_discard_composer_command_real_get_can_redo (ApplicationCommand* base)
{
	gboolean result;
	ApplicationDiscardComposerCommand* self;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, ApplicationDiscardComposerCommand);
	result = FALSE;
	return result;
}

static void
_application_discard_composer_command_on_destroy_timeout_geary_timeout_manager_timeout_func (GearyTimeoutManager* manager,
                                                                                             gpointer self)
{
	application_discard_composer_command_on_destroy_timeout ((ApplicationDiscardComposerCommand*) self);
}

ApplicationDiscardComposerCommand*
application_discard_composer_command_construct (GType object_type,
                                                ApplicationController* controller,
                                                ComposerWidget* composer)
{
	ApplicationDiscardComposerCommand * self = NULL;
	ApplicationController* _tmp0_;
	GearyTimeoutManager* _tmp1_;
	g_return_val_if_fail (APPLICATION_IS_CONTROLLER (controller), NULL);
	g_return_val_if_fail (COMPOSER_IS_WIDGET (composer), NULL);
	self = (ApplicationDiscardComposerCommand*) application_composer_command_construct (object_type, composer);
	_tmp0_ = _g_object_ref0 (controller);
	_g_object_unref0 (self->priv->controller);
	self->priv->controller = _tmp0_;
	_tmp1_ = geary_timeout_manager_new_seconds ((guint) APPLICATION_DISCARD_COMPOSER_COMMAND_DESTROY_TIMEOUT_SEC, _application_discard_composer_command_on_destroy_timeout_geary_timeout_manager_timeout_func, self);
	_g_object_unref0 (self->priv->destroy_timer);
	self->priv->destroy_timer = _tmp1_;
	return self;
}

ApplicationDiscardComposerCommand*
application_discard_composer_command_new (ApplicationController* controller,
                                          ComposerWidget* composer)
{
	return application_discard_composer_command_construct (APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, controller, composer);
}

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

static void
application_discard_composer_command_real_execute (ApplicationCommand* base,
                                                   GCancellable* cancellable,
                                                   GAsyncReadyCallback _callback_,
                                                   gpointer _user_data_)
{
	ApplicationDiscardComposerCommand * self;
	ApplicationDiscardComposerCommandExecuteData* _data_;
	ApplicationDiscardComposerCommand* _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, APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, ApplicationDiscardComposerCommand);
	_data_ = g_slice_new0 (ApplicationDiscardComposerCommandExecuteData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_discard_composer_command_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_;
	application_discard_composer_command_real_execute_co (_data_);
}

static void
application_discard_composer_command_execute_finish (ApplicationCommand* base,
                                                     GAsyncResult* _res_,
                                                     GError** error)
{
	ApplicationDiscardComposerCommandExecuteData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
application_discard_composer_command_real_execute_co (ApplicationDiscardComposerCommandExecuteData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	application_command_set_executed_label (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND, ApplicationCommand), _ ("Email discarded"));
	_data_->_tmp0_ = _data_->self->priv->destroy_timer;
	geary_timeout_manager_start (_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
application_discard_composer_command_real_undo_data_free (gpointer _data)
{
	ApplicationDiscardComposerCommandUndoData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->cancellable);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationDiscardComposerCommandUndoData, _data_);
}

static void
application_discard_composer_command_real_undo (ApplicationCommand* base,
                                                GCancellable* cancellable,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_)
{
	ApplicationDiscardComposerCommand * self;
	ApplicationDiscardComposerCommandUndoData* _data_;
	ApplicationDiscardComposerCommand* _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, APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, ApplicationDiscardComposerCommand);
	_data_ = g_slice_new0 (ApplicationDiscardComposerCommandUndoData);
	_data_->_async_result = g_task_new (G_OBJECT (self), cancellable, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_discard_composer_command_real_undo_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (cancellable);
	_g_object_unref0 (_data_->cancellable);
	_data_->cancellable = _tmp1_;
	application_discard_composer_command_real_undo_co (_data_);
}

static void
application_discard_composer_command_undo_finish (ApplicationCommand* base,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	ApplicationDiscardComposerCommandUndoData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
application_discard_composer_command_real_undo_co (ApplicationDiscardComposerCommandUndoData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
	_data_->_tmp1_ = _data_->_tmp0_;
	if (_data_->_tmp1_ != NULL) {
		_data_->_tmp2_ = _data_->self->priv->destroy_timer;
		geary_timeout_manager_reset (_data_->_tmp2_);
		_data_->_tmp3_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
		_data_->_tmp4_ = _data_->_tmp3_;
		composer_widget_set_enabled (_data_->_tmp4_, TRUE);
		_data_->_tmp5_ = _data_->self->priv->controller;
		_data_->_tmp6_ = application_composer_command_get_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
		_data_->_tmp7_ = _data_->_tmp6_;
		application_controller_present_composer (_data_->_tmp5_, _data_->_tmp7_);
		application_composer_command_clear_composer (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
	} else {
		application_command_set_undone_label (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, APPLICATION_TYPE_COMMAND, ApplicationCommand), _ ("Composer could not be restored"));
	}
	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
application_discard_composer_command_on_destroy_timeout (ApplicationDiscardComposerCommand* self)
{
	g_return_if_fail (APPLICATION_IS_DISCARD_COMPOSER_COMMAND (self));
	application_composer_command_close_composer (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMPOSER_COMMAND, ApplicationComposerCommand));
}

static void
application_discard_composer_command_class_init (ApplicationDiscardComposerCommandClass * klass,
                                                 gpointer klass_data)
{
	application_discard_composer_command_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationDiscardComposerCommand_private_offset);
	((ApplicationCommandClass *) klass)->execute = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_discard_composer_command_real_execute;
	((ApplicationCommandClass *) klass)->execute_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_discard_composer_command_execute_finish;
	((ApplicationCommandClass *) klass)->undo = (void (*) (ApplicationCommand*, GCancellable*, GAsyncReadyCallback, gpointer)) application_discard_composer_command_real_undo;
	((ApplicationCommandClass *) klass)->undo_finish = (void (*) (ApplicationCommand*, GAsyncResult*, GError**)) application_discard_composer_command_undo_finish;
	APPLICATION_COMMAND_CLASS (klass)->get_can_redo = (gboolean (*) (ApplicationCommand*)) application_discard_composer_command_real_get_can_redo;
	G_OBJECT_CLASS (klass)->get_property = _vala_application_discard_composer_command_get_property;
	G_OBJECT_CLASS (klass)->finalize = application_discard_composer_command_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), APPLICATION_DISCARD_COMPOSER_COMMAND_CAN_REDO_PROPERTY, application_discard_composer_command_properties[APPLICATION_DISCARD_COMPOSER_COMMAND_CAN_REDO_PROPERTY] = g_param_spec_boolean ("can-redo", "can-redo", "can-redo", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
application_discard_composer_command_instance_init (ApplicationDiscardComposerCommand * self,
                                                    gpointer klass)
{
	self->priv = application_discard_composer_command_get_instance_private (self);
}

static void
application_discard_composer_command_finalize (GObject * obj)
{
	ApplicationDiscardComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, ApplicationDiscardComposerCommand);
	_g_object_unref0 (self->priv->controller);
	_g_object_unref0 (self->priv->destroy_timer);
	G_OBJECT_CLASS (application_discard_composer_command_parent_class)->finalize (obj);
}

static GType
application_discard_composer_command_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationDiscardComposerCommandClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_discard_composer_command_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationDiscardComposerCommand), 0, (GInstanceInitFunc) application_discard_composer_command_instance_init, NULL };
	GType application_discard_composer_command_type_id;
	application_discard_composer_command_type_id = g_type_register_static (APPLICATION_TYPE_COMPOSER_COMMAND, "ApplicationDiscardComposerCommand", &g_define_type_info, 0);
	ApplicationDiscardComposerCommand_private_offset = g_type_add_instance_private (application_discard_composer_command_type_id, sizeof (ApplicationDiscardComposerCommandPrivate));
	return application_discard_composer_command_type_id;
}

GType
application_discard_composer_command_get_type (void)
{
	static volatile gsize application_discard_composer_command_type_id__once = 0;
	if (g_once_init_enter (&application_discard_composer_command_type_id__once)) {
		GType application_discard_composer_command_type_id;
		application_discard_composer_command_type_id = application_discard_composer_command_get_type_once ();
		g_once_init_leave (&application_discard_composer_command_type_id__once, application_discard_composer_command_type_id);
	}
	return application_discard_composer_command_type_id__once;
}

static void
_vala_application_discard_composer_command_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec)
{
	ApplicationDiscardComposerCommand * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, APPLICATION_TYPE_DISCARD_COMPOSER_COMMAND, ApplicationDiscardComposerCommand);
	switch (property_id) {
		case APPLICATION_DISCARD_COMPOSER_COMMAND_CAN_REDO_PROPERTY:
		g_value_set_boolean (value, application_command_get_can_redo (G_TYPE_CHECK_INSTANCE_CAST (self, APPLICATION_TYPE_COMMAND, ApplicationCommand)));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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);
}

