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

/*
 * Copyright © 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 "mail-merge.h"
#include <glib-object.h>
#include <glib.h>
#include <libpeas.h>
#include "geary-client-46.0.h"
#include "util.h"
#include <gio/gio.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gi18n-lib.h>
#include "geary-engine.h"
#include <gtk/gtk.h>

#define PLUGIN_MAIL_MERGE_LOC_NAMES _ ("Templates | Template Mail | Template Email | Template E-Mail")
#define PLUGIN_MAIL_MERGE_UNLOC_NAMES "Templates | Template Mail | Template Email | Template E-Mail"
#define PLUGIN_MAIL_MERGE_ACTION_EDIT "edit-template"
#define PLUGIN_MAIL_MERGE_ACTION_INSERT_FIELD "insert-field"
#define PLUGIN_MAIL_MERGE_ACTION_MERGE "merge-template"
#define PLUGIN_MAIL_MERGE_ACTION_LOAD "load-merge-data"
#define PLUGIN_MAIL_MERGE_ACTION_START "start-send"
#define PLUGIN_MAIL_MERGE_ACTION_PAUSE "pause-send"
#define PLUGIN_MAIL_MERGE_INFO_BAR_PRIORITY 10
#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 _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	PLUGIN_MAIL_MERGE_0_PROPERTY,
	PLUGIN_MAIL_MERGE_FOLDERS_PROPERTY,
	PLUGIN_MAIL_MERGE_EMAIL_PROPERTY,
	PLUGIN_MAIL_MERGE_CLIENT_APPLICATION_PROPERTY,
	PLUGIN_MAIL_MERGE_CLIENT_PLUGINS_PROPERTY,
	PLUGIN_MAIL_MERGE_NUM_PROPERTIES
};
static GParamSpec* plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _PluginMailMergeActivateData PluginMailMergeActivateData;
typedef struct _PluginMailMergeDeactivateData PluginMailMergeDeactivateData;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _PluginMailMergeEditEmailData PluginMailMergeEditEmailData;
typedef struct _PluginMailMergeMergeEmailData PluginMailMergeMergeEmailData;
typedef struct _PluginMailMergeUpdateEmailData PluginMailMergeUpdateEmailData;
typedef struct _Block1Data Block1Data;
typedef struct _PluginMailMergeUpdateComposerData PluginMailMergeUpdateComposerData;
typedef struct _Block2Data Block2Data;
typedef struct _PluginMailMergeLoadComposerDataData PluginMailMergeLoadComposerDataData;
#define _g_variant_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_unref (var), NULL)))
typedef struct _PluginMailMergeNewComposerActionBarData PluginMailMergeNewComposerActionBarData;
typedef struct _PluginMailMergeLoadMergeEmailData PluginMailMergeLoadMergeEmailData;

struct _PluginMailMergePrivate {
	PluginFolderContext* _folders;
	PluginEmailContext* _email;
	ApplicationClient* _client_application;
	ApplicationPluginManager* _client_plugins;
	PluginFolderStore* folder_store;
	PluginEmailStore* email_store;
	MailMergeFolder* merge_folder;
	PluginInfoBar* merge_bar;
	GSimpleAction* edit_action;
	GSimpleAction* merge_action;
	GSimpleAction* start_action;
	GSimpleAction* pause_action;
	PluginActionable* start_ui;
	PluginActionable* pause_ui;
	GeeList* folder_names;
	GCancellable* cancellable;
};

struct _PluginMailMergeActivateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	gboolean is_startup;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint _tmp2__length1;
	GearyIterable* _tmp3_;
	GearyIterable* _tmp4_;
	GearyIterable* _tmp5_;
	GearyIterable* _tmp6_;
	GeeList* _tmp7_;
	GeeCollection* _tmp8_;
	GeeCollection* _tmp9_;
	gchar** _tmp10_;
	gchar** _tmp11_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	GearyIterable* _tmp13_;
	GearyIterable* _tmp14_;
	GearyIterable* _tmp15_;
	GearyIterable* _tmp16_;
	GeeList* _tmp17_;
	GeeCollection* _tmp18_;
	GeeCollection* _tmp19_;
	PluginFolderStore* _tmp20_;
	PluginFolderContext* _tmp21_;
	PluginFolderContext* _tmp22_;
	PluginFolderStore* _tmp23_;
	PluginFolderStore* _tmp24_;
	PluginFolderStore* _tmp25_;
	PluginFolderStore* _tmp26_;
	PluginEmailStore* _tmp27_;
	PluginEmailContext* _tmp28_;
	PluginEmailContext* _tmp29_;
	PluginEmailStore* _tmp30_;
	PluginEmailStore* _tmp31_;
	PluginEmailStore* _tmp32_;
	PluginEmailStore* _tmp33_;
	const GVariantType* _tmp34_;
	const GVariantType* _tmp35_;
	GSimpleAction* _tmp36_;
	GSimpleAction* _tmp37_;
	PluginApplication* _tmp38_;
	PluginApplication* _tmp39_;
	GSimpleAction* _tmp40_;
	PluginEmailStore* _tmp41_;
	const GVariantType* _tmp42_;
	const GVariantType* _tmp43_;
	GSimpleAction* _tmp44_;
	GSimpleAction* _tmp45_;
	PluginApplication* _tmp46_;
	PluginApplication* _tmp47_;
	GSimpleAction* _tmp48_;
	GSimpleAction* _tmp49_;
	GSimpleAction* _tmp50_;
	PluginApplication* _tmp51_;
	PluginApplication* _tmp52_;
	GSimpleAction* _tmp53_;
	GSimpleAction* _tmp54_;
	PluginActionable* _tmp55_;
	GSimpleAction* _tmp56_;
	GSimpleAction* _tmp57_;
	PluginApplication* _tmp58_;
	PluginApplication* _tmp59_;
	GSimpleAction* _tmp60_;
	GSimpleAction* _tmp61_;
	PluginActionable* _tmp62_;
	PluginApplication* _tmp63_;
	PluginApplication* _tmp64_;
	GError* _inner_error0_;
};

struct _PluginMailMergeDeactivateData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	gboolean is_shutdown;
	GCancellable* _tmp0_;
	PluginApplication* _tmp1_;
	PluginApplication* _tmp2_;
	GSimpleAction* _tmp3_;
	PluginApplication* _tmp4_;
	PluginApplication* _tmp5_;
	GSimpleAction* _tmp6_;
	PluginEmailStore* _tmp7_;
	guint _tmp8_;
	GeeList* _tmp9_;
};

struct _PluginMailMergeEditEmailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	PluginEmailIdentifier* id;
	PluginComposer* composer;
	PluginApplication* _tmp0_;
	PluginApplication* _tmp1_;
	PluginAccount* _tmp2_;
	PluginAccount* _tmp3_;
	PluginComposer* _tmp4_;
	GeeCollection* containing;
	PluginFolderStore* _tmp5_;
	GCancellable* _tmp6_;
	GeeCollection* _tmp7_;
	PluginFolder* folder;
	GeeCollection* _tmp8_;
	gpointer _tmp9_;
	PluginComposer* _tmp10_;
	PluginFolder* _tmp11_;
	PluginComposer* _tmp12_;
	PluginComposer* _tmp13_;
	GError* err;
	GError* _tmp14_;
	const gchar* _tmp15_;
	GError* _inner_error0_;
};

struct _PluginMailMergeMergeEmailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	PluginEmailIdentifier* id;
	GFile* default_csv_file;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFile* csv_file;
	GFile* _tmp3_;
	GFile* _tmp4_;
	GFileInputStream* csv_input;
	GFile* _tmp5_;
	GCancellable* _tmp6_;
	GFileInputStream* _tmp7_;
	MailMergeCsvReader* csv;
	GFileInputStream* _tmp8_;
	GCancellable* _tmp9_;
	MailMergeCsvReader* _tmp10_;
	GeeCollection* emails;
	PluginEmailStore* _tmp11_;
	GeeCollection* _tmp12_;
	GeeCollection* _tmp13_;
	GCancellable* _tmp14_;
	GeeCollection* _tmp15_;
	GeeCollection* _tmp16_;
	GeeCollection* _tmp17_;
	gboolean _tmp18_;
	gboolean _tmp19_;
	ApplicationAccountContext* account_context;
	ApplicationPluginManager* _tmp20_;
	ApplicationPluginManager* _tmp21_;
	PluginAccount* _tmp22_;
	PluginAccount* _tmp23_;
	ApplicationAccountContext* _tmp24_;
	PluginEmail* email;
	GeeCollection* _tmp25_;
	gpointer _tmp26_;
	GearyEmail* _tmp27_;
	PluginEmail* _tmp28_;
	GearyEmail* _tmp29_;
	MailMergeFolder* _tmp30_;
	ApplicationAccountContext* _tmp31_;
	GearyAccount* _tmp32_;
	GearyAccount* _tmp33_;
	ApplicationAccountContext* _tmp34_;
	GearyAccount* _tmp35_;
	GearyAccount* _tmp36_;
	GearyFolderRoot* _tmp37_;
	GearyFolderRoot* _tmp38_;
	GFile* _tmp39_;
	MailMergeCsvReader* _tmp40_;
	MailMergeFolder* _tmp41_;
	MailMergeFolder* _tmp42_;
	MailMergeFolder* _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	PluginInfoBar* _tmp46_;
	PluginInfoBar* _tmp47_;
	PluginInfoBar* _tmp48_;
	MailMergeFolder* _tmp49_;
	MailMergeFolder* _tmp50_;
	ApplicationAccountContext* _tmp51_;
	GearyAccount* _tmp52_;
	GearyAccount* _tmp53_;
	MailMergeFolder* _tmp54_;
	ApplicationMainWindow* main;
	ApplicationClient* _tmp55_;
	ApplicationClient* _tmp56_;
	ApplicationMainWindow* _tmp57_;
	ApplicationMainWindow* _tmp58_;
	MailMergeFolder* _tmp59_;
	GError* err;
	GError* _tmp60_;
	const gchar* _tmp61_;
	GError* _inner_error0_;
};

struct _PluginMailMergeUpdateEmailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	PluginEmail* target;
	GeeCollection* containing;
	GeeCollection* _tmp0_;
	GeeCollection* _tmp1_;
	PluginFolderStore* _tmp2_;
	PluginEmailIdentifier* _tmp3_;
	PluginEmailIdentifier* _tmp4_;
	GCancellable* _tmp5_;
	GeeCollection* _tmp6_;
	GeeCollection* _tmp7_;
	GError* err;
	GError* _tmp8_;
	const gchar* _tmp9_;
	GeeCollection* _tmp10_;
	GearyEmail* email;
	GearyEmail* _tmp11_;
	gboolean _tmp12_;
	GearyEmail* _tmp13_;
	PluginEmailContext* _tmp14_;
	PluginEmailContext* _tmp15_;
	PluginEmailIdentifier* _tmp16_;
	PluginEmailIdentifier* _tmp17_;
	PluginEmailIdentifier* _tmp18_;
	PluginEmailIdentifier* _tmp19_;
	PluginInfoBar* _tmp20_;
	PluginInfoBar* _tmp21_;
	GError* _vala1_err;
	GError* _tmp22_;
	const gchar* _tmp23_;
	GError* _inner_error0_;
};

struct _Block1Data {
	int _ref_count_;
	PluginMailMerge* self;
	PluginComposer* composer;
	gpointer _async_data_;
};

struct _PluginMailMergeUpdateComposerData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	PluginComposer* composer;
	Block1Data* _data1_;
	GSimpleAction* load_action;
	GSimpleAction* _tmp0_;
	PluginActionable* _tmp1_;
	PluginActionable* _tmp2_;
};

struct _Block2Data {
	int _ref_count_;
	PluginMailMerge* self;
	PluginComposer* composer;
	gpointer _async_data_;
};

struct _PluginMailMergeLoadComposerDataData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	PluginComposer* composer;
	Block2Data* _data2_;
	GFile* data;
	GFile* _tmp0_;
	GFile* _tmp1_;
	GSimpleAction* insert_field_action;
	const GVariantType* _tmp2_;
	GSimpleAction* _tmp3_;
	GSimpleAction* _tmp4_;
	GSimpleAction* _tmp5_;
	PluginActionBar* _tmp6_;
	GFile* _tmp7_;
	const gchar* _tmp8_;
	const gchar* _tmp9_;
	PluginActionBar* _tmp10_;
	GError* err;
	GError* _tmp11_;
	const gchar* _tmp12_;
	GError* _inner_error0_;
};

struct _PluginMailMergeNewComposerActionBarData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	GFile* csv_file;
	gchar* action_group_name;
	PluginActionBar* result;
	GFileInfo* info;
	GCancellable* _tmp0_;
	GFileInfo* _tmp1_;
	GFileInputStream* input;
	GCancellable* _tmp2_;
	GFileInputStream* _tmp3_;
	MailMergeCsvReader* csv;
	GFileInputStream* _tmp4_;
	GCancellable* _tmp5_;
	MailMergeCsvReader* _tmp6_;
	gchar** record;
	MailMergeCsvReader* _tmp7_;
	gint _tmp8_;
	gchar** _tmp9_;
	gint record_length1;
	gint _record_size_;
	GMenu* text_fields_menu;
	GMenu* _tmp10_;
	gchar** _tmp11_;
	gint _tmp11__length1;
	gchar** field_collection;
	gint field_collection_length1;
	gint _field_collection_size_;
	gint field_it;
	gchar* _tmp12_;
	gchar* field;
	GMenu* _tmp13_;
	const gchar* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gchar* _tmp18_;
	const gchar* _tmp19_;
	GVariant* _tmp20_;
	gchar* _tmp21_;
	gchar* _tmp22_;
	PluginActionBar* action_bar;
	PluginActionBar* _tmp23_;
	PluginActionBar* _tmp24_;
	GMenu* _tmp25_;
	PluginActionBarMenuItem* _tmp26_;
	PluginActionBarMenuItem* _tmp27_;
	PluginActionBar* _tmp28_;
	GFileInfo* _tmp29_;
	const gchar* _tmp30_;
	PluginActionBarLabelItem* _tmp31_;
	PluginActionBarLabelItem* _tmp32_;
	GError* _inner_error0_;
};

struct _PluginMailMergeLoadMergeEmailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	PluginMailMerge* self;
	PluginEmail* plugin;
	GearyEmail* result;
	GearyEmail* engine;
	ApplicationPluginManager* _tmp0_;
	ApplicationPluginManager* _tmp1_;
	GearyEmail* _tmp2_;
	gboolean _tmp3_;
	GearyEmail* _tmp4_;
	GearyEmail* _tmp5_;
	GearyEmailField _tmp6_;
	GearyEmailField _tmp7_;
	ApplicationAccountContext* account_context;
	ApplicationPluginManager* _tmp8_;
	ApplicationPluginManager* _tmp9_;
	PluginEmailIdentifier* _tmp10_;
	PluginEmailIdentifier* _tmp11_;
	PluginAccount* _tmp12_;
	PluginAccount* _tmp13_;
	ApplicationAccountContext* _tmp14_;
	GearyEmail* _tmp15_;
	ApplicationAccountContext* _tmp16_;
	GearyAppEmailStore* _tmp17_;
	GearyAppEmailStore* _tmp18_;
	GearyEmail* _tmp19_;
	GearyEmailIdentifier* _tmp20_;
	GearyEmailIdentifier* _tmp21_;
	GCancellable* _tmp22_;
	GearyEmail* _tmp23_;
	GearyEmail* _tmp24_;
	GearyEmail* _tmp25_;
	GError* _tmp26_;
	GError* _inner_error0_;
};

static gint PluginMailMerge_private_offset;
static gpointer plugin_mail_merge_parent_class = NULL;
static PluginFolderExtensionIface * plugin_mail_merge_plugin_folder_extension_parent_iface = NULL;
static PluginEmailExtensionIface * plugin_mail_merge_plugin_email_extension_parent_iface = NULL;
static PluginTrustedExtensionIface * plugin_mail_merge_plugin_trusted_extension_parent_iface = NULL;
static GType plugin_mail_merge_type_id = 0;

static void plugin_mail_merge_real_activate_data_free (gpointer _data);
static void plugin_mail_merge_real_activate (PluginPluginBase* base,
                                      gboolean is_startup,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_);
static gboolean plugin_mail_merge_real_activate_co (PluginMailMergeActivateData* _data_);
static gchar* __lambda4_ (PluginMailMerge* self,
                   gchar* name);
static gpointer ___lambda4__gee_map_func (gpointer g,
                                   gpointer self);
static gchar* __lambda5_ (PluginMailMerge* self,
                   gchar* name);
static gpointer ___lambda5__gee_map_func (gpointer g,
                                   gpointer self);
static void plugin_mail_merge_activate_ready (GObject* source_object,
                                       GAsyncResult* _res_,
                                       gpointer _user_data_);
static void plugin_mail_merge_on_folders_available (PluginMailMerge* self,
                                             GeeCollection* available);
static void _plugin_mail_merge_on_folders_available_plugin_folder_store_folders_available (PluginFolderStore* _sender,
                                                                                    GeeCollection* available,
                                                                                    gpointer self);
static void plugin_mail_merge_on_folder_selected (PluginMailMerge* self,
                                           PluginFolder* selected);
static void _plugin_mail_merge_on_folder_selected_plugin_folder_store_folder_selected (PluginFolderStore* _sender,
                                                                                PluginFolder* selected,
                                                                                gpointer self);
static void plugin_mail_merge_on_email_displayed (PluginMailMerge* self,
                                           PluginEmail* email);
static void _plugin_mail_merge_on_email_displayed_plugin_email_store_email_displayed (PluginEmailStore* _sender,
                                                                               PluginEmail* sent,
                                                                               gpointer self);
static void plugin_mail_merge_on_edit_activated (PluginMailMerge* self,
                                          GAction* action,
                                          GVariant* target);
static void _plugin_mail_merge_on_edit_activated_g_simple_action_activate (GSimpleAction* _sender,
                                                                    GVariant* parameter,
                                                                    gpointer self);
static void plugin_mail_merge_on_merge_activated (PluginMailMerge* self,
                                           GAction* action,
                                           GVariant* target);
static void _plugin_mail_merge_on_merge_activated_g_simple_action_activate (GSimpleAction* _sender,
                                                                     GVariant* parameter,
                                                                     gpointer self);
static void plugin_mail_merge_on_start_activated (PluginMailMerge* self,
                                           GAction* action,
                                           GVariant* target);
static void _plugin_mail_merge_on_start_activated_g_simple_action_activate (GSimpleAction* _sender,
                                                                     GVariant* parameter,
                                                                     gpointer self);
static void plugin_mail_merge_on_pause_activated (PluginMailMerge* self,
                                           GAction* action,
                                           GVariant* target);
static void _plugin_mail_merge_on_pause_activated_g_simple_action_activate (GSimpleAction* _sender,
                                                                     GVariant* parameter,
                                                                     gpointer self);
static void plugin_mail_merge_on_composer_registered (PluginMailMerge* self,
                                               PluginComposer* registered);
static void _plugin_mail_merge_on_composer_registered_plugin_application_composer_registered (PluginApplication* _sender,
                                                                                       PluginComposer* composer,
                                                                                       gpointer self);
static void plugin_mail_merge_real_deactivate_data_free (gpointer _data);
static void plugin_mail_merge_real_deactivate (PluginPluginBase* base,
                                        gboolean is_shutdown,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
static gboolean plugin_mail_merge_real_deactivate_co (PluginMailMergeDeactivateData* _data_);
static void plugin_mail_merge_edit_email_data_free (gpointer _data);
static void plugin_mail_merge_edit_email (PluginMailMerge* self,
                                   PluginEmailIdentifier* id,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_);
static void plugin_mail_merge_edit_email_finish (PluginMailMerge* self,
                                          GAsyncResult* _res_);
static gboolean plugin_mail_merge_edit_email_co (PluginMailMergeEditEmailData* _data_);
static void plugin_mail_merge_edit_email_ready (GObject* source_object,
                                         GAsyncResult* _res_,
                                         gpointer _user_data_);
static gboolean ___lambda7_ (PluginMailMerge* self,
                      PluginFolder* f);
static gboolean ____lambda7__gee_predicate (gconstpointer g,
                                     gpointer self);
static void plugin_mail_merge_merge_email_data_free (gpointer _data);
static void plugin_mail_merge_merge_email (PluginMailMerge* self,
                                    PluginEmailIdentifier* id,
                                    GFile* default_csv_file,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void plugin_mail_merge_merge_email_finish (PluginMailMerge* self,
                                           GAsyncResult* _res_);
static gboolean plugin_mail_merge_merge_email_co (PluginMailMergeMergeEmailData* _data_);
static GFile* plugin_mail_merge_show_merge_data_chooser (PluginMailMerge* self);
static void plugin_mail_merge_merge_email_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static void plugin_mail_merge_load_merge_email (PluginMailMerge* self,
                                         PluginEmail* plugin,
                                         GAsyncReadyCallback _callback_,
                                         gpointer _user_data_);
static GearyEmail* plugin_mail_merge_load_merge_email_finish (PluginMailMerge* self,
                                                       GAsyncResult* _res_,
                                                       GError** error);
static void plugin_mail_merge_update_merge_folder_info_bar (PluginMailMerge* self);
static void plugin_mail_merge_on_merge_closed (PluginMailMerge* self);
static void _plugin_mail_merge_on_merge_closed_plugin_info_bar_close_activated (PluginInfoBar* _sender,
                                                                         gpointer self);
static void _____lambda8_ (PluginMailMerge* self);
static void ______lambda8__g_object_notify (GObject* _sender,
                                     GParamSpec* pspec,
                                     gpointer self);
static void _____lambda9_ (PluginMailMerge* self);
static void ______lambda9__g_object_notify (GObject* _sender,
                                     GParamSpec* pspec,
                                     gpointer self);
static void plugin_mail_merge_update_email_data_free (gpointer _data);
static void plugin_mail_merge_update_email (PluginMailMerge* self,
                                     PluginEmail* target,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_);
static void plugin_mail_merge_update_email_finish (PluginMailMerge* self,
                                            GAsyncResult* _res_);
static gboolean plugin_mail_merge_update_email_co (PluginMailMergeUpdateEmailData* _data_);
static void plugin_mail_merge_update_email_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_);
static gboolean __lambda6_ (PluginMailMerge* self,
                     PluginFolder* f);
static gboolean ___lambda6__gee_predicate (gconstpointer g,
                                    gpointer self);
static PluginInfoBar* plugin_mail_merge_new_template_email_info_bar (PluginMailMerge* self,
                                                              PluginEmailIdentifier* target);
static void plugin_mail_merge_update_composer_data_free (gpointer _data);
static void plugin_mail_merge_update_composer (PluginMailMerge* self,
                                        PluginComposer* composer,
                                        GAsyncReadyCallback _callback_,
                                        gpointer _user_data_);
static void plugin_mail_merge_update_composer_finish (PluginMailMerge* self,
                                               GAsyncResult* _res_);
static gboolean plugin_mail_merge_update_composer_co (PluginMailMergeUpdateComposerData* _data_);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void ___lambda10_ (Block1Data* _data1_);
static void plugin_mail_merge_load_composer_data (PluginMailMerge* self,
                                           PluginComposer* composer,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_);
static void plugin_mail_merge_load_composer_data_finish (PluginMailMerge* self,
                                                  GAsyncResult* _res_);
static void ____lambda10__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void plugin_mail_merge_load_composer_data_data_free (gpointer _data);
static gboolean plugin_mail_merge_load_composer_data_co (PluginMailMergeLoadComposerDataData* _data_);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static void ___lambda11_ (Block2Data* _data2_,
                   GVariant* param);
static void plugin_mail_merge_insert_field (PluginMailMerge* self,
                                     PluginComposer* composer,
                                     const gchar* field);
static gchar* _variant_get1 (GVariant* value);
static void ____lambda11__g_simple_action_activate (GSimpleAction* _sender,
                                             GVariant* parameter,
                                             gpointer self);
static void plugin_mail_merge_new_composer_action_bar (PluginMailMerge* self,
                                                GFile* csv_file,
                                                const gchar* action_group_name,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
static PluginActionBar* plugin_mail_merge_new_composer_action_bar_finish (PluginMailMerge* self,
                                                                   GAsyncResult* _res_,
                                                                   GError** error);
static void plugin_mail_merge_load_composer_data_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_);
static void plugin_mail_merge_new_composer_action_bar_data_free (gpointer _data);
static gboolean plugin_mail_merge_new_composer_action_bar_co (PluginMailMergeNewComposerActionBarData* _data_);
static void plugin_mail_merge_new_composer_action_bar_ready (GObject* source_object,
                                                      GAsyncResult* _res_,
                                                      gpointer _user_data_);
static GVariant* _variant_new1 (const gchar* value);
static void plugin_mail_merge_load_merge_email_data_free (gpointer _data);
static gboolean plugin_mail_merge_load_merge_email_co (PluginMailMergeLoadMergeEmailData* _data_);
static void plugin_mail_merge_load_merge_email_ready (GObject* source_object,
                                               GAsyncResult* _res_,
                                               gpointer _user_data_);
static void plugin_mail_merge_finalize (GObject * obj);
static void _vala_plugin_mail_merge_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_plugin_mail_merge_set_property (GObject * object,
                                           guint property_id,
                                           const 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 gssize _vala_array_length (gpointer array);

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

void
peas_register_types (GTypeModule* module)
{
	PeasObjectModule* obj = NULL;
	PeasObjectModule* _tmp0_;
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (module, g_type_module_get_type ()));
	plugin_mail_merge_register_type (module);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (module, peas_object_module_get_type ()) ? ((PeasObjectModule*) module) : NULL);
	obj = _tmp0_;
	peas_object_module_register_extension_type (obj, PLUGIN_TYPE_PLUGIN_BASE, PLUGIN_TYPE_MAIL_MERGE);
	_g_object_unref0 (obj);
}

static inline gpointer
plugin_mail_merge_get_instance_private (PluginMailMerge* self)
{
	return G_STRUCT_MEMBER_P (self, PluginMailMerge_private_offset);
}

static PluginFolderContext*
plugin_mail_merge_real_get_folders (PluginFolderExtension* base)
{
	PluginFolderContext* result;
	PluginMailMerge* self;
	PluginFolderContext* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	_tmp0_ = self->priv->_folders;
	result = _tmp0_;
	return result;
}

static void
plugin_mail_merge_real_set_folders (PluginFolderExtension* base,
                                    PluginFolderContext* value)
{
	PluginMailMerge* self;
	PluginFolderContext* old_value;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	old_value = plugin_mail_merge_real_get_folders (base);
	if (old_value != value) {
		PluginFolderContext* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_folders);
		self->priv->_folders = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_FOLDERS_PROPERTY]);
	}
}

static PluginEmailContext*
plugin_mail_merge_real_get_email (PluginEmailExtension* base)
{
	PluginEmailContext* result;
	PluginMailMerge* self;
	PluginEmailContext* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	_tmp0_ = self->priv->_email;
	result = _tmp0_;
	return result;
}

static void
plugin_mail_merge_real_set_email (PluginEmailExtension* base,
                                  PluginEmailContext* value)
{
	PluginMailMerge* self;
	PluginEmailContext* old_value;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	old_value = plugin_mail_merge_real_get_email (base);
	if (old_value != value) {
		PluginEmailContext* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_email);
		self->priv->_email = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_EMAIL_PROPERTY]);
	}
}

static ApplicationClient*
plugin_mail_merge_real_get_client_application (PluginTrustedExtension* base)
{
	ApplicationClient* result;
	PluginMailMerge* self;
	ApplicationClient* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	_tmp0_ = self->priv->_client_application;
	result = _tmp0_;
	return result;
}

static void
plugin_mail_merge_real_set_client_application (PluginTrustedExtension* base,
                                               ApplicationClient* value)
{
	PluginMailMerge* self;
	ApplicationClient* old_value;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	old_value = plugin_mail_merge_real_get_client_application (base);
	if (old_value != value) {
		ApplicationClient* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_client_application);
		self->priv->_client_application = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_CLIENT_APPLICATION_PROPERTY]);
	}
}

static ApplicationPluginManager*
plugin_mail_merge_real_get_client_plugins (PluginTrustedExtension* base)
{
	ApplicationPluginManager* result;
	PluginMailMerge* self;
	ApplicationPluginManager* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	_tmp0_ = self->priv->_client_plugins;
	result = _tmp0_;
	return result;
}

static void
plugin_mail_merge_real_set_client_plugins (PluginTrustedExtension* base,
                                           ApplicationPluginManager* value)
{
	PluginMailMerge* self;
	ApplicationPluginManager* old_value;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	old_value = plugin_mail_merge_real_get_client_plugins (base);
	if (old_value != value) {
		ApplicationPluginManager* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_client_plugins);
		self->priv->_client_plugins = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_CLIENT_PLUGINS_PROPERTY]);
	}
}

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

static void
plugin_mail_merge_real_activate (PluginPluginBase* base,
                                 gboolean is_startup,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_)
{
	PluginMailMerge * self;
	PluginMailMergeActivateData* _data_;
	PluginMailMerge* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	_data_ = g_slice_new0 (PluginMailMergeActivateData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_real_activate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->is_startup = is_startup;
	plugin_mail_merge_real_activate_co (_data_);
}

static void
plugin_mail_merge_activate_finish (PluginPluginBase* base,
                                   GAsyncResult* _res_,
                                   GError** error)
{
	PluginMailMergeActivateData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

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

static gchar*
__lambda4_ (PluginMailMerge* self,
            gchar* name)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = string_strip (name);
	result = _tmp0_;
	_g_free0 (name);
	return result;
}

static gpointer
___lambda4__gee_map_func (gpointer g,
                          gpointer self)
{
	gpointer result;
	result = __lambda4_ ((PluginMailMerge*) self, (gchar*) g);
	return result;
}

static gchar*
__lambda5_ (PluginMailMerge* self,
            gchar* name)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = string_strip (name);
	result = _tmp0_;
	_g_free0 (name);
	return result;
}

static gpointer
___lambda5__gee_map_func (gpointer g,
                          gpointer self)
{
	gpointer result;
	result = __lambda5_ ((PluginMailMerge*) self, (gchar*) g);
	return result;
}

static void
plugin_mail_merge_activate_ready (GObject* source_object,
                                  GAsyncResult* _res_,
                                  gpointer _user_data_)
{
	PluginMailMergeActivateData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	plugin_mail_merge_real_activate_co (_data_);
}

static void
_plugin_mail_merge_on_folders_available_plugin_folder_store_folders_available (PluginFolderStore* _sender,
                                                                               GeeCollection* available,
                                                                               gpointer self)
{
	plugin_mail_merge_on_folders_available ((PluginMailMerge*) self, available);
}

static void
_plugin_mail_merge_on_folder_selected_plugin_folder_store_folder_selected (PluginFolderStore* _sender,
                                                                           PluginFolder* selected,
                                                                           gpointer self)
{
	plugin_mail_merge_on_folder_selected ((PluginMailMerge*) self, selected);
}

static void
_plugin_mail_merge_on_email_displayed_plugin_email_store_email_displayed (PluginEmailStore* _sender,
                                                                          PluginEmail* sent,
                                                                          gpointer self)
{
	plugin_mail_merge_on_email_displayed ((PluginMailMerge*) self, sent);
}

static void
_plugin_mail_merge_on_edit_activated_g_simple_action_activate (GSimpleAction* _sender,
                                                               GVariant* parameter,
                                                               gpointer self)
{
	plugin_mail_merge_on_edit_activated ((PluginMailMerge*) self, _sender, parameter);
}

static void
_plugin_mail_merge_on_merge_activated_g_simple_action_activate (GSimpleAction* _sender,
                                                                GVariant* parameter,
                                                                gpointer self)
{
	plugin_mail_merge_on_merge_activated ((PluginMailMerge*) self, _sender, parameter);
}

static void
_plugin_mail_merge_on_start_activated_g_simple_action_activate (GSimpleAction* _sender,
                                                                GVariant* parameter,
                                                                gpointer self)
{
	plugin_mail_merge_on_start_activated ((PluginMailMerge*) self, _sender, parameter);
}

static void
_plugin_mail_merge_on_pause_activated_g_simple_action_activate (GSimpleAction* _sender,
                                                                GVariant* parameter,
                                                                gpointer self)
{
	plugin_mail_merge_on_pause_activated ((PluginMailMerge*) self, _sender, parameter);
}

static void
_plugin_mail_merge_on_composer_registered_plugin_application_composer_registered (PluginApplication* _sender,
                                                                                  PluginComposer* composer,
                                                                                  gpointer self)
{
	plugin_mail_merge_on_composer_registered ((PluginMailMerge*) self, composer);
}

static gboolean
plugin_mail_merge_real_activate_co (PluginMailMergeActivateData* _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_->_tmp1_ = _data_->_tmp0_ = g_strsplit (PLUGIN_MAIL_MERGE_LOC_NAMES, "|", 0);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp2__length1 = _vala_array_length (_data_->_tmp0_);
	_data_->_tmp3_ = geary_iterate_array (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp2_, (gint) _vala_array_length (_data_->_tmp0_), NULL, NULL, NULL);
	_data_->_tmp4_ = _data_->_tmp3_;
	_data_->_tmp5_ = geary_iterable_map (_data_->_tmp4_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, ___lambda4__gee_map_func, _data_->self);
	_data_->_tmp6_ = _data_->_tmp5_;
	_data_->_tmp7_ = _data_->self->priv->folder_names;
	_data_->_tmp8_ = geary_iterable_add_all_to (_data_->_tmp6_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp9_ = _data_->_tmp8_;
	_g_object_unref0 (_data_->_tmp9_);
	_g_object_unref0 (_data_->_tmp6_);
	_g_object_unref0 (_data_->_tmp4_);
	_data_->_tmp2_ = (_vala_array_free (_data_->_tmp2_, _data_->_tmp2__length1, (GDestroyNotify) g_free), NULL);
	_data_->_tmp11_ = _data_->_tmp10_ = g_strsplit (PLUGIN_MAIL_MERGE_UNLOC_NAMES, "|", 0);
	_data_->_tmp12_ = _data_->_tmp11_;
	_data_->_tmp12__length1 = _vala_array_length (_data_->_tmp10_);
	_data_->_tmp13_ = geary_iterate_array (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp12_, (gint) _vala_array_length (_data_->_tmp10_), NULL, NULL, NULL);
	_data_->_tmp14_ = _data_->_tmp13_;
	_data_->_tmp15_ = geary_iterable_map (_data_->_tmp14_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, ___lambda5__gee_map_func, _data_->self);
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = _data_->self->priv->folder_names;
	_data_->_tmp18_ = geary_iterable_add_all_to (_data_->_tmp16_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp17_, GEE_TYPE_COLLECTION, GeeCollection));
	_data_->_tmp19_ = _data_->_tmp18_;
	_g_object_unref0 (_data_->_tmp19_);
	_g_object_unref0 (_data_->_tmp16_);
	_g_object_unref0 (_data_->_tmp14_);
	_data_->_tmp12_ = (_vala_array_free (_data_->_tmp12_, _data_->_tmp12__length1, (GDestroyNotify) g_free), NULL);
	_data_->_tmp21_ = plugin_folder_extension_get_folders (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_FOLDER_EXTENSION, PluginFolderExtension));
	_data_->_tmp22_ = _data_->_tmp21_;
	_data_->_state_ = 1;
	plugin_folder_context_get_folder_store (_data_->_tmp22_, plugin_mail_merge_activate_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp23_ = plugin_folder_context_get_folder_store_finish (_data_->_tmp22_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp20_ = _data_->_tmp23_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp24_ = _data_->_tmp20_;
	_data_->_tmp20_ = NULL;
	_g_object_unref0 (_data_->self->priv->folder_store);
	_data_->self->priv->folder_store = _data_->_tmp24_;
	_data_->_tmp25_ = _data_->self->priv->folder_store;
	g_signal_connect_object (_data_->_tmp25_, "folders-available", (GCallback) _plugin_mail_merge_on_folders_available_plugin_folder_store_folders_available, _data_->self, 0);
	_data_->_tmp26_ = _data_->self->priv->folder_store;
	g_signal_connect_object (_data_->_tmp26_, "folder-selected", (GCallback) _plugin_mail_merge_on_folder_selected_plugin_folder_store_folder_selected, _data_->self, 0);
	_data_->_tmp28_ = plugin_email_extension_get_email (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_EMAIL_EXTENSION, PluginEmailExtension));
	_data_->_tmp29_ = _data_->_tmp28_;
	_data_->_state_ = 2;
	plugin_email_context_get_email_store (_data_->_tmp29_, plugin_mail_merge_activate_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp30_ = plugin_email_context_get_email_store_finish (_data_->_tmp29_, _data_->_res_, &_data_->_inner_error0_);
	_data_->_tmp27_ = _data_->_tmp30_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->_tmp20_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp31_ = _data_->_tmp27_;
	_data_->_tmp27_ = NULL;
	_g_object_unref0 (_data_->self->priv->email_store);
	_data_->self->priv->email_store = _data_->_tmp31_;
	_data_->_tmp32_ = _data_->self->priv->email_store;
	g_signal_connect_object (_data_->_tmp32_, "email-displayed", (GCallback) _plugin_mail_merge_on_email_displayed_plugin_email_store_email_displayed, _data_->self, 0);
	_data_->_tmp33_ = _data_->self->priv->email_store;
	_data_->_tmp34_ = plugin_email_store_get_email_identifier_variant_type (_data_->_tmp33_);
	_data_->_tmp35_ = _data_->_tmp34_;
	_data_->_tmp36_ = g_simple_action_new (PLUGIN_MAIL_MERGE_ACTION_EDIT, _data_->_tmp35_);
	_g_object_unref0 (_data_->self->priv->edit_action);
	_data_->self->priv->edit_action = _data_->_tmp36_;
	_data_->_tmp37_ = _data_->self->priv->edit_action;
	g_signal_connect_object (_data_->_tmp37_, "activate", (GCallback) _plugin_mail_merge_on_edit_activated_g_simple_action_activate, _data_->self, 0);
	_data_->_tmp38_ = plugin_plugin_base_get_plugin_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase));
	_data_->_tmp39_ = _data_->_tmp38_;
	_data_->_tmp40_ = _data_->self->priv->edit_action;
	plugin_application_register_action (_data_->_tmp39_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp40_, g_action_get_type (), GAction));
	_data_->_tmp41_ = _data_->self->priv->email_store;
	_data_->_tmp42_ = plugin_email_store_get_email_identifier_variant_type (_data_->_tmp41_);
	_data_->_tmp43_ = _data_->_tmp42_;
	_data_->_tmp44_ = g_simple_action_new (PLUGIN_MAIL_MERGE_ACTION_MERGE, _data_->_tmp43_);
	_g_object_unref0 (_data_->self->priv->merge_action);
	_data_->self->priv->merge_action = _data_->_tmp44_;
	_data_->_tmp45_ = _data_->self->priv->merge_action;
	g_signal_connect_object (_data_->_tmp45_, "activate", (GCallback) _plugin_mail_merge_on_merge_activated_g_simple_action_activate, _data_->self, 0);
	_data_->_tmp46_ = plugin_plugin_base_get_plugin_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase));
	_data_->_tmp47_ = _data_->_tmp46_;
	_data_->_tmp48_ = _data_->self->priv->merge_action;
	plugin_application_register_action (_data_->_tmp47_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp48_, g_action_get_type (), GAction));
	_data_->_tmp49_ = g_simple_action_new (PLUGIN_MAIL_MERGE_ACTION_START, NULL);
	_g_object_unref0 (_data_->self->priv->start_action);
	_data_->self->priv->start_action = _data_->_tmp49_;
	_data_->_tmp50_ = _data_->self->priv->start_action;
	g_signal_connect_object (_data_->_tmp50_, "activate", (GCallback) _plugin_mail_merge_on_start_activated_g_simple_action_activate, _data_->self, 0);
	_data_->_tmp51_ = plugin_plugin_base_get_plugin_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase));
	_data_->_tmp52_ = _data_->_tmp51_;
	_data_->_tmp53_ = _data_->self->priv->start_action;
	plugin_application_register_action (_data_->_tmp52_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp53_, g_action_get_type (), GAction));
	_data_->_tmp54_ = _data_->self->priv->start_action;
	_data_->_tmp55_ = plugin_actionable_new_with_icon (_ ("Start"), "media-playback-start-symbolic", G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp54_, g_action_get_type (), GAction), NULL);
	_g_object_unref0 (_data_->self->priv->start_ui);
	_data_->self->priv->start_ui = _data_->_tmp55_;
	_data_->_tmp56_ = g_simple_action_new (PLUGIN_MAIL_MERGE_ACTION_PAUSE, NULL);
	_g_object_unref0 (_data_->self->priv->pause_action);
	_data_->self->priv->pause_action = _data_->_tmp56_;
	_data_->_tmp57_ = _data_->self->priv->pause_action;
	g_signal_connect_object (_data_->_tmp57_, "activate", (GCallback) _plugin_mail_merge_on_pause_activated_g_simple_action_activate, _data_->self, 0);
	_data_->_tmp58_ = plugin_plugin_base_get_plugin_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase));
	_data_->_tmp59_ = _data_->_tmp58_;
	_data_->_tmp60_ = _data_->self->priv->pause_action;
	plugin_application_register_action (_data_->_tmp59_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp60_, g_action_get_type (), GAction));
	_data_->_tmp61_ = _data_->self->priv->pause_action;
	_data_->_tmp62_ = plugin_actionable_new_with_icon (_ ("Pause"), "media-playback-pause-symbolic", G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp61_, g_action_get_type (), GAction), NULL);
	_g_object_unref0 (_data_->self->priv->pause_ui);
	_data_->self->priv->pause_ui = _data_->_tmp62_;
	_data_->_tmp63_ = plugin_plugin_base_get_plugin_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase));
	_data_->_tmp64_ = _data_->_tmp63_;
	g_signal_connect_object (_data_->_tmp64_, "composer-registered", (GCallback) _plugin_mail_merge_on_composer_registered_plugin_application_composer_registered, _data_->self, 0);
	_g_object_unref0 (_data_->_tmp27_);
	_g_object_unref0 (_data_->_tmp20_);
	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
plugin_mail_merge_real_deactivate_data_free (gpointer _data)
{
	PluginMailMergeDeactivateData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (PluginMailMergeDeactivateData, _data_);
}

static void
plugin_mail_merge_real_deactivate (PluginPluginBase* base,
                                   gboolean is_shutdown,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_)
{
	PluginMailMerge * self;
	PluginMailMergeDeactivateData* _data_;
	PluginMailMerge* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	_data_ = g_slice_new0 (PluginMailMergeDeactivateData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_real_deactivate_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_data_->is_shutdown = is_shutdown;
	plugin_mail_merge_real_deactivate_co (_data_);
}

static void
plugin_mail_merge_deactivate_finish (PluginPluginBase* base,
                                     GAsyncResult* _res_,
                                     GError** error)
{
	PluginMailMergeDeactivateData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
plugin_mail_merge_real_deactivate_co (PluginMailMergeDeactivateData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->cancellable;
	g_cancellable_cancel (_data_->_tmp0_);
	_data_->_tmp1_ = plugin_plugin_base_get_plugin_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase));
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = _data_->self->priv->edit_action;
	plugin_application_deregister_action (_data_->_tmp2_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp3_, g_action_get_type (), GAction));
	_g_object_unref0 (_data_->self->priv->edit_action);
	_data_->self->priv->edit_action = NULL;
	_data_->_tmp4_ = plugin_plugin_base_get_plugin_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase));
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = _data_->self->priv->merge_action;
	plugin_application_deregister_action (_data_->_tmp5_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp6_, g_action_get_type (), GAction));
	_g_object_unref0 (_data_->self->priv->merge_action);
	_data_->self->priv->merge_action = NULL;
	_g_object_unref0 (_data_->self->priv->folder_store);
	_data_->self->priv->folder_store = NULL;
	_data_->_tmp7_ = _data_->self->priv->email_store;
	g_signal_parse_name ("email-displayed", PLUGIN_TYPE_EMAIL_STORE, &_data_->_tmp8_, NULL, FALSE);
	g_signal_handlers_disconnect_matched (_data_->_tmp7_, G_SIGNAL_MATCH_ID | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, _data_->_tmp8_, 0, NULL, (GCallback) _plugin_mail_merge_on_email_displayed_plugin_email_store_email_displayed, _data_->self);
	_g_object_unref0 (_data_->self->priv->email_store);
	_data_->self->priv->email_store = NULL;
	_data_->_tmp9_ = _data_->self->priv->folder_names;
	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
plugin_mail_merge_edit_email_data_free (gpointer _data)
{
	PluginMailMergeEditEmailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->id);
	_g_object_unref0 (_data_->self);
	g_slice_free (PluginMailMergeEditEmailData, _data_);
}

static void
plugin_mail_merge_edit_email (PluginMailMerge* self,
                              PluginEmailIdentifier* id,
                              GAsyncReadyCallback _callback_,
                              gpointer _user_data_)
{
	PluginMailMergeEditEmailData* _data_;
	PluginMailMerge* _tmp0_;
	PluginEmailIdentifier* _tmp1_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (id, PLUGIN_TYPE_EMAIL_IDENTIFIER));
	_data_ = g_slice_new0 (PluginMailMergeEditEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_edit_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (id);
	_g_object_unref0 (_data_->id);
	_data_->id = _tmp1_;
	plugin_mail_merge_edit_email_co (_data_);
}

static void
plugin_mail_merge_edit_email_finish (PluginMailMerge* self,
                                     GAsyncResult* _res_)
{
	PluginMailMergeEditEmailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
plugin_mail_merge_edit_email_ready (GObject* source_object,
                                    GAsyncResult* _res_,
                                    gpointer _user_data_)
{
	PluginMailMergeEditEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	plugin_mail_merge_edit_email_co (_data_);
}

static gboolean
___lambda7_ (PluginMailMerge* self,
             PluginFolder* f)
{
	GeeList* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (f, PLUGIN_TYPE_FOLDER), FALSE);
	_tmp0_ = self->priv->folder_names;
	_tmp1_ = plugin_folder_get_display_name (f);
	_tmp2_ = _tmp1_;
	result = gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection), _tmp2_);
	return result;
}

static gboolean
____lambda7__gee_predicate (gconstpointer g,
                            gpointer self)
{
	gboolean result;
	result = ___lambda7_ ((PluginMailMerge*) self, (PluginFolder*) g);
	return result;
}

static gboolean
plugin_mail_merge_edit_email_co (PluginMailMergeEditEmailData* _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_ = plugin_plugin_base_get_plugin_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_PLUGIN_BASE, PluginPluginBase));
		_data_->_tmp1_ = _data_->_tmp0_;
		_data_->_tmp2_ = plugin_email_identifier_get_account (_data_->id);
		_data_->_tmp3_ = _data_->_tmp2_;
		_data_->_state_ = 1;
		plugin_application_compose_with_context (_data_->_tmp1_, _data_->_tmp3_, PLUGIN_COMPOSER_CONTEXT_TYPE_EDIT, _data_->id, NULL, plugin_mail_merge_edit_email_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp4_ = plugin_application_compose_with_context_finish (_data_->_tmp1_, _data_->_res_, &_data_->_inner_error0_);
		_data_->composer = _data_->_tmp4_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp5_ = _data_->self->priv->folder_store;
		_data_->_tmp6_ = _data_->self->priv->cancellable;
		_data_->_state_ = 2;
		plugin_folder_store_list_containing_folders (_data_->_tmp5_, _data_->id, _data_->_tmp6_, plugin_mail_merge_edit_email_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp7_ = plugin_folder_store_list_containing_folders_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
		_data_->containing = _data_->_tmp7_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->composer);
			goto __catch0_g_error;
		}
		_data_->_tmp8_ = _data_->containing;
		_data_->_tmp9_ = gee_traversable_first_match (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, GEE_TYPE_TRAVERSABLE, GeeTraversable), ____lambda7__gee_predicate, g_object_ref (_data_->self), g_object_unref);
		_data_->folder = (PluginFolder*) _data_->_tmp9_;
		_data_->_tmp10_ = _data_->composer;
		_data_->_tmp11_ = _data_->folder;
		plugin_composer_save_to_folder (_data_->_tmp10_, _data_->_tmp11_);
		_data_->_tmp12_ = _data_->composer;
		plugin_composer_set_can_send (_data_->_tmp12_, FALSE);
		_data_->_tmp13_ = _data_->composer;
		plugin_composer_present (_data_->_tmp13_);
		_g_object_unref0 (_data_->folder);
		_g_object_unref0 (_data_->containing);
		_g_object_unref0 (_data_->composer);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp14_ = _data_->err;
		_data_->_tmp15_ = _data_->_tmp14_->message;
		g_warning ("mail-merge.vala:175: Unable to construct composer: %s", _data_->_tmp15_);
		_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
plugin_mail_merge_merge_email_data_free (gpointer _data)
{
	PluginMailMergeMergeEmailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->id);
	_g_object_unref0 (_data_->default_csv_file);
	_g_object_unref0 (_data_->self);
	g_slice_free (PluginMailMergeMergeEmailData, _data_);
}

static void
plugin_mail_merge_merge_email (PluginMailMerge* self,
                               PluginEmailIdentifier* id,
                               GFile* default_csv_file,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	PluginMailMergeMergeEmailData* _data_;
	PluginMailMerge* _tmp0_;
	PluginEmailIdentifier* _tmp1_;
	GFile* _tmp2_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (id, PLUGIN_TYPE_EMAIL_IDENTIFIER));
	g_return_if_fail ((default_csv_file == NULL) || G_TYPE_CHECK_INSTANCE_TYPE (default_csv_file, g_file_get_type ()));
	_data_ = g_slice_new0 (PluginMailMergeMergeEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_merge_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (id);
	_g_object_unref0 (_data_->id);
	_data_->id = _tmp1_;
	_tmp2_ = _g_object_ref0 (default_csv_file);
	_g_object_unref0 (_data_->default_csv_file);
	_data_->default_csv_file = _tmp2_;
	plugin_mail_merge_merge_email_co (_data_);
}

static void
plugin_mail_merge_merge_email_finish (PluginMailMerge* self,
                                      GAsyncResult* _res_)
{
	PluginMailMergeMergeEmailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
plugin_mail_merge_merge_email_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	PluginMailMergeMergeEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	plugin_mail_merge_merge_email_co (_data_);
}

static void
_plugin_mail_merge_on_merge_closed_plugin_info_bar_close_activated (PluginInfoBar* _sender,
                                                                    gpointer self)
{
	plugin_mail_merge_on_merge_closed ((PluginMailMerge*) self);
}

static void
_____lambda8_ (PluginMailMerge* self)
{
	plugin_mail_merge_update_merge_folder_info_bar (self);
}

static void
______lambda8__g_object_notify (GObject* _sender,
                                GParamSpec* pspec,
                                gpointer self)
{
	_____lambda8_ ((PluginMailMerge*) self);
}

static void
_____lambda9_ (PluginMailMerge* self)
{
	plugin_mail_merge_update_merge_folder_info_bar (self);
}

static void
______lambda9__g_object_notify (GObject* _sender,
                                GParamSpec* pspec,
                                gpointer self)
{
	_____lambda9_ ((PluginMailMerge*) self);
}

static gboolean
plugin_mail_merge_merge_email_co (PluginMailMergeMergeEmailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		case 3:
		goto _state_3;
		case 4:
		goto _state_4;
		case 5:
		goto _state_5;
		case 6:
		goto _state_6;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp1_ = _g_object_ref0 (_data_->default_csv_file);
	_data_->_tmp0_ = _data_->_tmp1_;
	if (_data_->_tmp0_ == NULL) {
		_data_->_tmp2_ = plugin_mail_merge_show_merge_data_chooser (_data_->self);
		_g_object_unref0 (_data_->_tmp0_);
		_data_->_tmp0_ = _data_->_tmp2_;
	}
	_data_->_tmp3_ = _data_->_tmp0_;
	_data_->_tmp0_ = NULL;
	_data_->csv_file = _data_->_tmp3_;
	_data_->_tmp4_ = _data_->csv_file;
	if (_data_->_tmp4_ != NULL) {
		{
			_data_->_tmp5_ = _data_->csv_file;
			_data_->_tmp6_ = _data_->self->priv->cancellable;
			_data_->_state_ = 1;
			g_file_read_async (_data_->_tmp5_, G_PRIORITY_DEFAULT, _data_->_tmp6_, plugin_mail_merge_merge_email_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp7_ = g_file_read_finish (_data_->_tmp5_, _data_->_res_, &_data_->_inner_error0_);
			_data_->csv_input = _data_->_tmp7_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->_tmp8_ = _data_->csv_input;
			_data_->_tmp9_ = _data_->self->priv->cancellable;
			_data_->_state_ = 2;
			mail_merge_csv_reader_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp8_, g_input_stream_get_type (), GInputStream), _data_->_tmp9_, plugin_mail_merge_merge_email_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp10_ = mail_merge_csv_reader_new_finish (_data_->_res_, &_data_->_inner_error0_);
			_data_->csv = _data_->_tmp10_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->csv_input);
				goto __catch0_g_error;
			}
			_data_->_tmp11_ = _data_->self->priv->email_store;
			_data_->_tmp12_ = geary_collection_single (PLUGIN_TYPE_EMAIL_IDENTIFIER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->id);
			_data_->_tmp13_ = _data_->_tmp12_;
			_data_->_tmp14_ = _data_->self->priv->cancellable;
			_data_->_state_ = 3;
			plugin_email_store_get_email (_data_->_tmp11_, _data_->_tmp13_, _data_->_tmp14_, plugin_mail_merge_merge_email_ready, _data_);
			return FALSE;
			_state_3:
			_data_->_tmp15_ = plugin_email_store_get_email_finish (_data_->_tmp11_, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp16_ = _data_->_tmp15_;
			_g_object_unref0 (_data_->_tmp13_);
			_data_->emails = _data_->_tmp16_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->csv);
				_g_object_unref0 (_data_->csv_input);
				goto __catch0_g_error;
			}
			_data_->_tmp17_ = _data_->emails;
			_data_->_tmp18_ = gee_collection_get_is_empty (_data_->_tmp17_);
			_data_->_tmp19_ = _data_->_tmp18_;
			if (!_data_->_tmp19_) {
				_data_->_tmp20_ = plugin_trusted_extension_get_client_plugins (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension));
				_data_->_tmp21_ = _data_->_tmp20_;
				_data_->_tmp22_ = plugin_email_identifier_get_account (_data_->id);
				_data_->_tmp23_ = _data_->_tmp22_;
				_data_->_tmp24_ = application_plugin_manager_to_client_account (_data_->_tmp21_, _data_->_tmp23_);
				_data_->account_context = _data_->_tmp24_;
				_data_->_tmp25_ = _data_->emails;
				_data_->_tmp26_ = geary_collection_first (PLUGIN_TYPE_EMAIL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp25_);
				_data_->email = (PluginEmail*) _data_->_tmp26_;
				_data_->_tmp28_ = _data_->email;
				_data_->_state_ = 4;
				plugin_mail_merge_load_merge_email (_data_->self, _data_->_tmp28_, plugin_mail_merge_merge_email_ready, _data_);
				return FALSE;
				_state_4:
				_data_->_tmp29_ = plugin_mail_merge_load_merge_email_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
				_data_->_tmp27_ = _data_->_tmp29_;
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->email);
					_g_object_unref0 (_data_->account_context);
					_g_object_unref0 (_data_->emails);
					_g_object_unref0 (_data_->csv);
					_g_object_unref0 (_data_->csv_input);
					goto __catch0_g_error;
				}
				_data_->_tmp31_ = _data_->account_context;
				_data_->_tmp32_ = application_account_context_get_account (_data_->_tmp31_);
				_data_->_tmp33_ = _data_->_tmp32_;
				_data_->_tmp34_ = _data_->account_context;
				_data_->_tmp35_ = application_account_context_get_account (_data_->_tmp34_);
				_data_->_tmp36_ = _data_->_tmp35_;
				_data_->_tmp37_ = geary_account_get_local_folder_root (_data_->_tmp36_);
				_data_->_tmp38_ = _data_->_tmp37_;
				_data_->_tmp39_ = _data_->csv_file;
				_data_->_tmp40_ = _data_->csv;
				_data_->_state_ = 5;
				mail_merge_folder_new (_data_->_tmp33_, _data_->_tmp38_, _data_->_tmp27_, _data_->_tmp39_, _data_->_tmp40_, plugin_mail_merge_merge_email_ready, _data_);
				return FALSE;
				_state_5:
				_data_->_tmp41_ = mail_merge_folder_new_finish (_data_->_res_, &_data_->_inner_error0_);
				_data_->_tmp30_ = _data_->_tmp41_;
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->_tmp27_);
					_g_object_unref0 (_data_->email);
					_g_object_unref0 (_data_->account_context);
					_g_object_unref0 (_data_->emails);
					_g_object_unref0 (_data_->csv);
					_g_object_unref0 (_data_->csv_input);
					goto __catch0_g_error;
				}
				_data_->_tmp42_ = _data_->_tmp30_;
				_data_->_tmp30_ = NULL;
				_g_object_unref0 (_data_->self->priv->merge_folder);
				_data_->self->priv->merge_folder = _data_->_tmp42_;
				_data_->_tmp43_ = _data_->self->priv->merge_folder;
				_data_->_tmp44_ = mail_merge_folder_get_data_display_name (_data_->_tmp43_);
				_data_->_tmp45_ = _data_->_tmp44_;
				_data_->_tmp46_ = plugin_info_bar_new (_data_->_tmp45_, "");
				_g_object_unref0 (_data_->self->priv->merge_bar);
				_data_->self->priv->merge_bar = _data_->_tmp46_;
				plugin_mail_merge_update_merge_folder_info_bar (_data_->self);
				_data_->_tmp47_ = _data_->self->priv->merge_bar;
				plugin_info_bar_set_show_close_button (_data_->_tmp47_, TRUE);
				_data_->_tmp48_ = _data_->self->priv->merge_bar;
				g_signal_connect_object (_data_->_tmp48_, "close-activated", (GCallback) _plugin_mail_merge_on_merge_closed_plugin_info_bar_close_activated, _data_->self, 0);
				_data_->_tmp49_ = _data_->self->priv->merge_folder;
				g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp49_, G_TYPE_OBJECT, GObject), "notify::email-sent", (GCallback) ______lambda8__g_object_notify, _data_->self, 0);
				_data_->_tmp50_ = _data_->self->priv->merge_folder;
				g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp50_, G_TYPE_OBJECT, GObject), "notify::email-total", (GCallback) ______lambda9__g_object_notify, _data_->self, 0);
				_data_->_tmp51_ = _data_->account_context;
				_data_->_tmp52_ = application_account_context_get_account (_data_->_tmp51_);
				_data_->_tmp53_ = _data_->_tmp52_;
				_data_->_tmp54_ = _data_->self->priv->merge_folder;
				geary_account_register_local_folder (_data_->_tmp53_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp54_, GEARY_TYPE_FOLDER, GearyFolder), &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_object_unref0 (_data_->_tmp30_);
					_g_object_unref0 (_data_->_tmp27_);
					_g_object_unref0 (_data_->email);
					_g_object_unref0 (_data_->account_context);
					_g_object_unref0 (_data_->emails);
					_g_object_unref0 (_data_->csv);
					_g_object_unref0 (_data_->csv_input);
					goto __catch0_g_error;
				}
				_data_->_tmp55_ = plugin_trusted_extension_get_client_application (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension));
				_data_->_tmp56_ = _data_->_tmp55_;
				_data_->_tmp57_ = application_client_get_active_main_window (_data_->_tmp56_);
				_data_->main = _data_->_tmp57_;
				_data_->_tmp58_ = _data_->main;
				_data_->_tmp59_ = _data_->self->priv->merge_folder;
				_data_->_state_ = 6;
				application_main_window_select_folder (_data_->_tmp58_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp59_, GEARY_TYPE_FOLDER, GearyFolder), TRUE, FALSE, plugin_mail_merge_merge_email_ready, _data_);
				return FALSE;
				_state_6:
				application_main_window_select_folder_finish (_data_->_tmp58_, _data_->_res_);
				_g_object_unref0 (_data_->main);
				_g_object_unref0 (_data_->_tmp30_);
				_g_object_unref0 (_data_->_tmp27_);
				_g_object_unref0 (_data_->email);
				_g_object_unref0 (_data_->account_context);
			}
			_g_object_unref0 (_data_->emails);
			_g_object_unref0 (_data_->csv);
			_g_object_unref0 (_data_->csv_input);
		}
		goto __finally0;
		__catch0_g_error:
		{
			_data_->err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp60_ = _data_->err;
			_data_->_tmp61_ = _data_->_tmp60_->message;
			g_debug ("mail-merge.vala:230: Displaying merge folder failed: %s", _data_->_tmp61_);
			_g_error_free0 (_data_->err);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->csv_file);
			_g_object_unref0 (_data_->_tmp0_);
			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_->csv_file);
	_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
plugin_mail_merge_update_merge_folder_info_bar (PluginMailMerge* self)
{
	PluginInfoBar* _tmp0_;
	MailMergeFolder* _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	MailMergeFolder* _tmp4_;
	guint _tmp5_;
	guint _tmp6_;
	MailMergeFolder* _tmp7_;
	guint _tmp8_;
	guint _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	PluginActionable* _tmp12_ = NULL;
	MailMergeFolder* _tmp13_;
	gboolean _tmp14_;
	gboolean _tmp15_;
	PluginInfoBar* _tmp18_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	_tmp0_ = self->priv->merge_bar;
	_tmp1_ = self->priv->merge_folder;
	_tmp2_ = mail_merge_folder_get_email_total (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = self->priv->merge_folder;
	_tmp5_ = mail_merge_folder_get_email_sent (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->merge_folder;
	_tmp8_ = mail_merge_folder_get_email_total (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strdup_printf (ngettext ("Sent %u of %u", "Sent %u of %u", (gulong) _tmp3_), _tmp6_, _tmp9_);
	_tmp11_ = _tmp10_;
	plugin_info_bar_set_description (_tmp0_, _tmp11_);
	_g_free0 (_tmp11_);
	_tmp13_ = self->priv->merge_folder;
	_tmp14_ = mail_merge_folder_get_is_sending (_tmp13_);
	_tmp15_ = _tmp14_;
	if (_tmp15_) {
		PluginActionable* _tmp16_;
		_tmp16_ = self->priv->pause_ui;
		_tmp12_ = _tmp16_;
	} else {
		PluginActionable* _tmp17_;
		_tmp17_ = self->priv->start_ui;
		_tmp12_ = _tmp17_;
	}
	_tmp18_ = self->priv->merge_bar;
	plugin_info_bar_set_primary_button (_tmp18_, _tmp12_);
}

static void
plugin_mail_merge_update_email_data_free (gpointer _data)
{
	PluginMailMergeUpdateEmailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->target);
	_g_object_unref0 (_data_->self);
	g_slice_free (PluginMailMergeUpdateEmailData, _data_);
}

static void
plugin_mail_merge_update_email (PluginMailMerge* self,
                                PluginEmail* target,
                                GAsyncReadyCallback _callback_,
                                gpointer _user_data_)
{
	PluginMailMergeUpdateEmailData* _data_;
	PluginMailMerge* _tmp0_;
	PluginEmail* _tmp1_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (target, PLUGIN_TYPE_EMAIL));
	_data_ = g_slice_new0 (PluginMailMergeUpdateEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_update_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (target);
	_g_object_unref0 (_data_->target);
	_data_->target = _tmp1_;
	plugin_mail_merge_update_email_co (_data_);
}

static void
plugin_mail_merge_update_email_finish (PluginMailMerge* self,
                                       GAsyncResult* _res_)
{
	PluginMailMergeUpdateEmailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
plugin_mail_merge_update_email_ready (GObject* source_object,
                                      GAsyncResult* _res_,
                                      gpointer _user_data_)
{
	PluginMailMergeUpdateEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	plugin_mail_merge_update_email_co (_data_);
}

static gboolean
__lambda6_ (PluginMailMerge* self,
            PluginFolder* f)
{
	GeeList* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean result;
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (f, PLUGIN_TYPE_FOLDER), FALSE);
	_tmp0_ = self->priv->folder_names;
	_tmp1_ = plugin_folder_get_display_name (f);
	_tmp2_ = _tmp1_;
	result = gee_collection_contains (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_COLLECTION, GeeCollection), _tmp2_);
	return result;
}

static gboolean
___lambda6__gee_predicate (gconstpointer g,
                           gpointer self)
{
	gboolean result;
	result = __lambda6_ ((PluginMailMerge*) self, (PluginFolder*) g);
	return result;
}

static gboolean
plugin_mail_merge_update_email_co (PluginMailMergeUpdateEmailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = gee_collection_empty (PLUGIN_TYPE_FOLDER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref);
	_data_->containing = _data_->_tmp0_;
	{
		_data_->_tmp2_ = _data_->self->priv->folder_store;
		_data_->_tmp3_ = plugin_email_get_identifier (_data_->target);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_tmp5_ = _data_->self->priv->cancellable;
		_data_->_state_ = 1;
		plugin_folder_store_list_containing_folders (_data_->_tmp2_, _data_->_tmp4_, _data_->_tmp5_, plugin_mail_merge_update_email_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp6_ = plugin_folder_store_list_containing_folders_finish (_data_->_tmp2_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp1_ = _data_->_tmp6_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp7_ = _data_->_tmp1_;
		_data_->_tmp1_ = NULL;
		_g_object_unref0 (_data_->containing);
		_data_->containing = _data_->_tmp7_;
		_g_object_unref0 (_data_->_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->err = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp8_ = _data_->err;
		_data_->_tmp9_ = _data_->_tmp8_->message;
		g_warning ("mail-merge.vala:259: Could not load folders for email: %s", _data_->_tmp9_);
		_g_error_free0 (_data_->err);
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		_g_object_unref0 (_data_->containing);
		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_->_tmp10_ = _data_->containing;
	if (gee_traversable_any_match (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp10_, GEE_TYPE_TRAVERSABLE, GeeTraversable), ___lambda6__gee_predicate, g_object_ref (_data_->self), g_object_unref)) {
		{
			_data_->_state_ = 2;
			plugin_mail_merge_load_merge_email (_data_->self, _data_->target, plugin_mail_merge_update_email_ready, _data_);
			return FALSE;
			_state_2:
			_data_->_tmp11_ = plugin_mail_merge_load_merge_email_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
			_data_->email = _data_->_tmp11_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch1_g_error;
			}
			_data_->_tmp13_ = _data_->email;
			_data_->_tmp12_ = mail_merge_processor_is_mail_merge_template (_data_->_tmp13_, &_data_->_inner_error0_);
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_g_object_unref0 (_data_->email);
				goto __catch1_g_error;
			}
			if (_data_->_tmp12_) {
				_data_->_tmp14_ = plugin_email_extension_get_email (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_EMAIL_EXTENSION, PluginEmailExtension));
				_data_->_tmp15_ = _data_->_tmp14_;
				_data_->_tmp16_ = plugin_email_get_identifier (_data_->target);
				_data_->_tmp17_ = _data_->_tmp16_;
				_data_->_tmp18_ = plugin_email_get_identifier (_data_->target);
				_data_->_tmp19_ = _data_->_tmp18_;
				_data_->_tmp20_ = plugin_mail_merge_new_template_email_info_bar (_data_->self, _data_->_tmp19_);
				_data_->_tmp21_ = _data_->_tmp20_;
				plugin_email_context_add_email_info_bar (_data_->_tmp15_, _data_->_tmp17_, _data_->_tmp21_, (guint) PLUGIN_MAIL_MERGE_INFO_BAR_PRIORITY);
				_g_object_unref0 (_data_->_tmp21_);
			}
			_g_object_unref0 (_data_->email);
		}
		goto __finally1;
		__catch1_g_error:
		{
			_data_->_vala1_err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp22_ = _data_->_vala1_err;
			_data_->_tmp23_ = _data_->_tmp22_->message;
			g_warning ("mail-merge.vala:272: Error checking email for merge templates: %s", _data_->_tmp23_);
			_g_error_free0 (_data_->_vala1_err);
		}
		__finally1:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->containing);
			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_->containing);
	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
plugin_mail_merge_update_composer_data_free (gpointer _data)
{
	PluginMailMergeUpdateComposerData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (PluginMailMergeUpdateComposerData, _data_);
}

static void
plugin_mail_merge_update_composer (PluginMailMerge* self,
                                   PluginComposer* composer,
                                   GAsyncReadyCallback _callback_,
                                   gpointer _user_data_)
{
	PluginMailMergeUpdateComposerData* _data_;
	PluginMailMerge* _tmp0_;
	PluginComposer* _tmp1_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (composer, PLUGIN_TYPE_COMPOSER));
	_data_ = g_slice_new0 (PluginMailMergeUpdateComposerData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_update_composer_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (composer);
	_g_object_unref0 (_data_->composer);
	_data_->composer = _tmp1_;
	plugin_mail_merge_update_composer_co (_data_);
}

static void
plugin_mail_merge_update_composer_finish (PluginMailMerge* self,
                                          GAsyncResult* _res_)
{
	PluginMailMergeUpdateComposerData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block1Data*
block1_data_ref (Block1Data* _data1_)
{
	g_atomic_int_inc (&_data1_->_ref_count_);
	return _data1_;
}

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		PluginMailMerge* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->composer);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
___lambda10_ (Block1Data* _data1_)
{
	PluginMailMerge* self;
	self = _data1_->self;
	plugin_mail_merge_load_composer_data (self, _data1_->composer, NULL, NULL);
}

static void
____lambda10__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	___lambda10_ (self);
}

static gboolean
plugin_mail_merge_update_composer_co (PluginMailMergeUpdateComposerData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data1_ = g_slice_new0 (Block1Data);
	_data_->_data1_->_ref_count_ = 1;
	_data_->_data1_->self = g_object_ref (_data_->self);
	_g_object_unref0 (_data_->_data1_->composer);
	_data_->_data1_->composer = _data_->composer;
	_data_->_data1_->_async_data_ = _data_;
	if (TRUE) {
		_data_->_tmp0_ = g_simple_action_new (PLUGIN_MAIL_MERGE_ACTION_LOAD, NULL);
		_data_->load_action = _data_->_tmp0_;
		g_signal_connect_data (_data_->load_action, "activate", (GCallback) ____lambda10__g_simple_action_activate, block1_data_ref (_data_->_data1_), (GClosureNotify) block1_data_unref, 0);
		plugin_composer_register_action (_data_->_data1_->composer, G_TYPE_CHECK_INSTANCE_CAST (_data_->load_action, g_action_get_type (), GAction));
		_data_->_tmp1_ = plugin_actionable_new (_ ("Mail Merge"), G_TYPE_CHECK_INSTANCE_CAST (_data_->load_action, g_action_get_type (), GAction), NULL);
		_data_->_tmp2_ = _data_->_tmp1_;
		plugin_composer_append_menu_item (_data_->_data1_->composer, _data_->_tmp2_);
		_g_object_unref0 (_data_->_tmp2_);
		g_object_bind_property_with_closures (G_TYPE_CHECK_INSTANCE_CAST (_data_->_data1_->composer, G_TYPE_OBJECT, GObject), "can-send", G_TYPE_CHECK_INSTANCE_CAST (_data_->load_action, G_TYPE_OBJECT, GObject), "enabled", G_BINDING_SYNC_CREATE | G_BINDING_INVERT_BOOLEAN, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
		_g_object_unref0 (_data_->load_action);
	}
	block1_data_unref (_data_->_data1_);
	_data_->_data1_ = 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
plugin_mail_merge_load_composer_data_data_free (gpointer _data)
{
	PluginMailMergeLoadComposerDataData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (PluginMailMergeLoadComposerDataData, _data_);
}

static void
plugin_mail_merge_load_composer_data (PluginMailMerge* self,
                                      PluginComposer* composer,
                                      GAsyncReadyCallback _callback_,
                                      gpointer _user_data_)
{
	PluginMailMergeLoadComposerDataData* _data_;
	PluginMailMerge* _tmp0_;
	PluginComposer* _tmp1_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (composer, PLUGIN_TYPE_COMPOSER));
	_data_ = g_slice_new0 (PluginMailMergeLoadComposerDataData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_load_composer_data_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (composer);
	_g_object_unref0 (_data_->composer);
	_data_->composer = _tmp1_;
	plugin_mail_merge_load_composer_data_co (_data_);
}

static void
plugin_mail_merge_load_composer_data_finish (PluginMailMerge* self,
                                             GAsyncResult* _res_)
{
	PluginMailMergeLoadComposerDataData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block2Data*
block2_data_ref (Block2Data* _data2_)
{
	g_atomic_int_inc (&_data2_->_ref_count_);
	return _data2_;
}

static void
block2_data_unref (void * _userdata_)
{
	Block2Data* _data2_;
	_data2_ = (Block2Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data2_->_ref_count_)) {
		PluginMailMerge* self;
		self = _data2_->self;
		_g_object_unref0 (_data2_->composer);
		_g_object_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static gchar*
_variant_get1 (GVariant* value)
{
	return g_variant_dup_string (value, NULL);
}

static void
___lambda11_ (Block2Data* _data2_,
              GVariant* param)
{
	PluginMailMerge* self;
	gchar* _tmp0_;
	gchar* _tmp1_;
	self = _data2_->self;
	_tmp0_ = _variant_get1 (param);
	_tmp1_ = _tmp0_;
	plugin_mail_merge_insert_field (self, _data2_->composer, _tmp1_);
	_g_free0 (_tmp1_);
}

static void
____lambda11__g_simple_action_activate (GSimpleAction* _sender,
                                        GVariant* parameter,
                                        gpointer self)
{
	___lambda11_ (self, parameter);
}

static void
plugin_mail_merge_load_composer_data_ready (GObject* source_object,
                                            GAsyncResult* _res_,
                                            gpointer _user_data_)
{
	PluginMailMergeLoadComposerDataData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	plugin_mail_merge_load_composer_data_co (_data_);
}

static gboolean
plugin_mail_merge_load_composer_data_co (PluginMailMergeLoadComposerDataData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data2_ = g_slice_new0 (Block2Data);
	_data_->_data2_->_ref_count_ = 1;
	_data_->_data2_->self = g_object_ref (_data_->self);
	_g_object_unref0 (_data_->_data2_->composer);
	_data_->_data2_->composer = _data_->composer;
	_data_->_data2_->_async_data_ = _data_;
	_data_->_tmp0_ = plugin_mail_merge_show_merge_data_chooser (_data_->self);
	_data_->data = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->data;
	if (_data_->_tmp1_ != NULL) {
		_data_->_tmp2_ = G_VARIANT_TYPE_STRING;
		_data_->_tmp3_ = g_simple_action_new (PLUGIN_MAIL_MERGE_ACTION_INSERT_FIELD, _data_->_tmp2_);
		_data_->insert_field_action = _data_->_tmp3_;
		_data_->_tmp4_ = _data_->insert_field_action;
		plugin_composer_register_action (_data_->_data2_->composer, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, g_action_get_type (), GAction));
		_data_->_tmp5_ = _data_->insert_field_action;
		g_signal_connect_data (_data_->_tmp5_, "activate", (GCallback) ____lambda11__g_simple_action_activate, block2_data_ref (_data_->_data2_), (GClosureNotify) block2_data_unref, 0);
		{
			_data_->_tmp7_ = _data_->data;
			_data_->_tmp8_ = plugin_composer_get_action_group_name (_data_->_data2_->composer);
			_data_->_tmp9_ = _data_->_tmp8_;
			_data_->_state_ = 1;
			plugin_mail_merge_new_composer_action_bar (_data_->self, _data_->_tmp7_, _data_->_tmp9_, plugin_mail_merge_load_composer_data_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp10_ = plugin_mail_merge_new_composer_action_bar_finish (_data_->self, _data_->_res_, &_data_->_inner_error0_);
			_data_->_tmp6_ = _data_->_tmp10_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			plugin_composer_set_action_bar (_data_->_data2_->composer, _data_->_tmp6_);
			_g_object_unref0 (_data_->_tmp6_);
		}
		goto __finally0;
		__catch0_g_error:
		{
			_data_->err = _data_->_inner_error0_;
			_data_->_inner_error0_ = NULL;
			_data_->_tmp11_ = _data_->err;
			_data_->_tmp12_ = _data_->_tmp11_->message;
			g_debug ("mail-merge.vala:321: Error loading CSV: %s", _data_->_tmp12_);
			_g_error_free0 (_data_->err);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->insert_field_action);
			_g_object_unref0 (_data_->data);
			block2_data_unref (_data_->_data2_);
			_data_->_data2_ = NULL;
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_g_object_unref0 (_data_->insert_field_action);
	}
	_g_object_unref0 (_data_->data);
	block2_data_unref (_data_->_data2_);
	_data_->_data2_ = 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 PluginInfoBar*
plugin_mail_merge_new_template_email_info_bar (PluginMailMerge* self,
                                               PluginEmailIdentifier* target)
{
	PluginInfoBar* bar = NULL;
	PluginInfoBar* _tmp0_;
	GSimpleAction* _tmp1_;
	GVariant* _tmp2_;
	GVariant* _tmp3_;
	PluginActionable* _tmp4_;
	PluginActionable* _tmp5_;
	GeeBidirList* _tmp6_;
	GeeBidirList* _tmp7_;
	GSimpleAction* _tmp8_;
	GVariant* _tmp9_;
	GVariant* _tmp10_;
	PluginActionable* _tmp11_;
	PluginActionable* _tmp12_;
	PluginInfoBar* result;
	g_return_val_if_fail (PLUGIN_IS_MAIL_MERGE (self), NULL);
	g_return_val_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (target, PLUGIN_TYPE_EMAIL_IDENTIFIER), NULL);
	_tmp0_ = plugin_info_bar_new (_ ("Mail merge template"), NULL);
	bar = _tmp0_;
	_tmp1_ = self->priv->merge_action;
	_tmp2_ = plugin_email_identifier_to_variant (target);
	_tmp3_ = _tmp2_;
	_tmp4_ = plugin_actionable_new (_ ("Merge"), G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, g_action_get_type (), GAction), _tmp3_);
	_tmp5_ = _tmp4_;
	plugin_info_bar_set_primary_button (bar, _tmp5_);
	_g_object_unref0 (_tmp5_);
	_g_variant_unref0 (_tmp3_);
	_tmp6_ = plugin_info_bar_get_secondary_buttons (bar);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->edit_action;
	_tmp9_ = plugin_email_identifier_to_variant (target);
	_tmp10_ = _tmp9_;
	_tmp11_ = plugin_actionable_new (_ ("Edit"), G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, g_action_get_type (), GAction), _tmp10_);
	_tmp12_ = _tmp11_;
	gee_collection_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_COLLECTION, GeeCollection), _tmp12_);
	_g_object_unref0 (_tmp12_);
	_g_variant_unref0 (_tmp10_);
	result = bar;
	return result;
}

static void
plugin_mail_merge_new_composer_action_bar_data_free (gpointer _data)
{
	PluginMailMergeNewComposerActionBarData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->csv_file);
	_g_free0 (_data_->action_group_name);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (PluginMailMergeNewComposerActionBarData, _data_);
}

static void
plugin_mail_merge_new_composer_action_bar (PluginMailMerge* self,
                                           GFile* csv_file,
                                           const gchar* action_group_name,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	PluginMailMergeNewComposerActionBarData* _data_;
	PluginMailMerge* _tmp0_;
	GFile* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (csv_file, g_file_get_type ()));
	g_return_if_fail (action_group_name != NULL);
	_data_ = g_slice_new0 (PluginMailMergeNewComposerActionBarData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_new_composer_action_bar_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (csv_file);
	_g_object_unref0 (_data_->csv_file);
	_data_->csv_file = _tmp1_;
	_tmp2_ = g_strdup (action_group_name);
	_g_free0 (_data_->action_group_name);
	_data_->action_group_name = _tmp2_;
	plugin_mail_merge_new_composer_action_bar_co (_data_);
}

static PluginActionBar*
plugin_mail_merge_new_composer_action_bar_finish (PluginMailMerge* self,
                                                  GAsyncResult* _res_,
                                                  GError** error)
{
	PluginActionBar* result;
	PluginMailMergeNewComposerActionBarData* _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
plugin_mail_merge_new_composer_action_bar_ready (GObject* source_object,
                                                 GAsyncResult* _res_,
                                                 gpointer _user_data_)
{
	PluginMailMergeNewComposerActionBarData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	plugin_mail_merge_new_composer_action_bar_co (_data_);
}

static GVariant*
_variant_new1 (const gchar* value)
{
	return g_variant_ref_sink (g_variant_new_string (value));
}

static gboolean
plugin_mail_merge_new_composer_action_bar_co (PluginMailMergeNewComposerActionBarData* _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_->_tmp0_ = _data_->self->priv->cancellable;
	_data_->_state_ = 1;
	g_file_query_info_async (_data_->csv_file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME, G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, _data_->_tmp0_, plugin_mail_merge_new_composer_action_bar_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp1_ = g_file_query_info_finish (_data_->csv_file, _data_->_res_, &_data_->_inner_error0_);
	_data_->info = _data_->_tmp1_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp2_ = _data_->self->priv->cancellable;
	_data_->_state_ = 2;
	g_file_read_async (_data_->csv_file, G_PRIORITY_DEFAULT, _data_->_tmp2_, plugin_mail_merge_new_composer_action_bar_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp3_ = g_file_read_finish (_data_->csv_file, _data_->_res_, &_data_->_inner_error0_);
	_data_->input = _data_->_tmp3_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->info);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp4_ = _data_->input;
	_data_->_tmp5_ = _data_->self->priv->cancellable;
	_data_->_state_ = 3;
	mail_merge_csv_reader_new (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp4_, g_input_stream_get_type (), GInputStream), _data_->_tmp5_, plugin_mail_merge_new_composer_action_bar_ready, _data_);
	return FALSE;
	_state_3:
	_data_->_tmp6_ = mail_merge_csv_reader_new_finish (_data_->_res_, &_data_->_inner_error0_);
	_data_->csv = _data_->_tmp6_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->input);
		_g_object_unref0 (_data_->info);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp7_ = _data_->csv;
	_data_->_tmp8_ = 0;
	_data_->_state_ = 4;
	mail_merge_csv_reader_read_record (_data_->_tmp7_, plugin_mail_merge_new_composer_action_bar_ready, _data_);
	return FALSE;
	_state_4:
	_data_->_tmp9_ = mail_merge_csv_reader_read_record_finish (_data_->_tmp7_, _data_->_res_, &_data_->_tmp8_, &_data_->_inner_error0_);
	_data_->record = _data_->_tmp9_;
	_data_->record_length1 = _data_->_tmp8_;
	_data_->_record_size_ = _data_->record_length1;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->csv);
		_g_object_unref0 (_data_->input);
		_g_object_unref0 (_data_->info);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp10_ = g_menu_new ();
	_data_->text_fields_menu = _data_->_tmp10_;
	_data_->_tmp11_ = _data_->record;
	_data_->_tmp11__length1 = _data_->record_length1;
	{
		_data_->field_collection_length1 = 0;
		_data_->_field_collection_size_ = 0;
		_data_->field_collection = _data_->_tmp11_;
		_data_->field_collection_length1 = _data_->_tmp11__length1;
		for (_data_->field_it = 0; _data_->field_it < _data_->field_collection_length1; _data_->field_it = _data_->field_it + 1) {
			_data_->_tmp12_ = g_strdup (_data_->field_collection[_data_->field_it]);
			_data_->field = _data_->_tmp12_;
			{
				_data_->_tmp13_ = _data_->text_fields_menu;
				_data_->_tmp14_ = _data_->field;
				_data_->_tmp15_ = g_strconcat (_data_->action_group_name, ".", NULL);
				_data_->_tmp16_ = _data_->_tmp15_;
				_data_->_tmp17_ = g_strconcat (_data_->_tmp16_, PLUGIN_MAIL_MERGE_ACTION_INSERT_FIELD, NULL);
				_data_->_tmp18_ = _data_->_tmp17_;
				_data_->_tmp19_ = _data_->field;
				_data_->_tmp20_ = _variant_new1 (_data_->_tmp19_);
				_data_->_tmp21_ = g_action_print_detailed_name (_data_->_tmp18_, _data_->_tmp20_);
				_data_->_tmp22_ = _data_->_tmp21_;
				g_menu_append (_data_->_tmp13_, _data_->_tmp14_, _data_->_tmp22_);
				_g_free0 (_data_->_tmp22_);
				_g_variant_unref0 (_data_->_tmp20_);
				_g_free0 (_data_->_tmp18_);
				_g_free0 (_data_->_tmp16_);
				_g_free0 (_data_->field);
			}
		}
	}
	_data_->_tmp23_ = plugin_action_bar_new ();
	_data_->action_bar = _data_->_tmp23_;
	_data_->_tmp24_ = _data_->action_bar;
	_data_->_tmp25_ = _data_->text_fields_menu;
	_data_->_tmp26_ = plugin_action_bar_menu_item_new (_ ("Insert field"), G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp25_, g_menu_model_get_type (), GMenuModel));
	_data_->_tmp27_ = _data_->_tmp26_;
	plugin_action_bar_append_item (_data_->_tmp24_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp27_, PLUGIN_ACTION_BAR_TYPE_ITEM, PluginActionBarItem), PLUGIN_ACTION_BAR_POSITION_START);
	_g_object_unref0 (_data_->_tmp27_);
	_data_->_tmp28_ = _data_->action_bar;
	_data_->_tmp29_ = _data_->info;
	_data_->_tmp30_ = g_file_info_get_display_name (_data_->_tmp29_);
	_data_->_tmp31_ = plugin_action_bar_label_item_new (_data_->_tmp30_);
	_data_->_tmp32_ = _data_->_tmp31_;
	plugin_action_bar_append_item (_data_->_tmp28_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp32_, PLUGIN_ACTION_BAR_TYPE_ITEM, PluginActionBarItem), PLUGIN_ACTION_BAR_POSITION_START);
	_g_object_unref0 (_data_->_tmp32_);
	_data_->result = _data_->action_bar;
	_g_object_unref0 (_data_->text_fields_menu);
	_data_->record = (_vala_array_free (_data_->record, _data_->record_length1, (GDestroyNotify) g_free), NULL);
	_g_object_unref0 (_data_->csv);
	_g_object_unref0 (_data_->input);
	_g_object_unref0 (_data_->info);
	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 GFile*
plugin_mail_merge_show_merge_data_chooser (PluginMailMerge* self)
{
	GtkFileChooserNative* chooser = NULL;
	GtkFileChooserNative* _tmp0_;
	GtkFileFilter* csv_filter = NULL;
	GtkFileFilter* _tmp1_;
	GtkFileFilter* _tmp2_;
	GtkFileFilter* _tmp3_;
	GtkFileChooserNative* _tmp4_;
	GtkFileFilter* _tmp5_;
	GtkFileFilter* _tmp6_;
	GFile* _tmp7_ = NULL;
	GtkFileChooserNative* _tmp8_;
	GFile* _tmp11_;
	GFile* result;
	g_return_val_if_fail (PLUGIN_IS_MAIL_MERGE (self), NULL);
	_tmp0_ = gtk_file_chooser_native_new (_ ("Mail Merge"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN, _ ("_Open"), _ ("_Cancel"));
	chooser = _tmp0_;
	_tmp1_ = gtk_file_filter_new ();
	g_object_ref_sink (_tmp1_);
	csv_filter = _tmp1_;
	_tmp2_ = csv_filter;
	gtk_file_filter_set_name (_tmp2_, _ ("Comma separated values (CSV)"));
	_tmp3_ = csv_filter;
	gtk_file_filter_add_mime_type (_tmp3_, "text/csv");
	_tmp4_ = chooser;
	_tmp5_ = csv_filter;
	_tmp6_ = _g_object_ref0 (_tmp5_);
	gtk_file_chooser_add_filter (G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, gtk_file_chooser_get_type (), GtkFileChooser), _tmp6_);
	_tmp8_ = chooser;
	if (gtk_native_dialog_run (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_native_dialog_get_type (), GtkNativeDialog)) == ((gint) GTK_RESPONSE_ACCEPT)) {
		GtkFileChooserNative* _tmp9_;
		GFile* _tmp10_;
		_tmp9_ = chooser;
		_tmp10_ = gtk_file_chooser_get_file (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_file_chooser_get_type (), GtkFileChooser));
		_g_object_unref0 (_tmp7_);
		_tmp7_ = _tmp10_;
	} else {
		_g_object_unref0 (_tmp7_);
		_tmp7_ = NULL;
	}
	_tmp11_ = _tmp7_;
	_tmp7_ = NULL;
	result = _tmp11_;
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (csv_filter);
	_g_object_unref0 (chooser);
	return result;
}

static void
plugin_mail_merge_insert_field (PluginMailMerge* self,
                                PluginComposer* composer,
                                const gchar* field)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (composer, PLUGIN_TYPE_COMPOSER));
	g_return_if_fail (field != NULL);
	_tmp0_ = mail_merge_processor_to_field (field);
	_tmp1_ = _tmp0_;
	plugin_composer_insert_text (composer, _tmp1_);
	_g_free0 (_tmp1_);
}

static void
plugin_mail_merge_load_merge_email_data_free (gpointer _data)
{
	PluginMailMergeLoadMergeEmailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->plugin);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (PluginMailMergeLoadMergeEmailData, _data_);
}

static void
plugin_mail_merge_load_merge_email (PluginMailMerge* self,
                                    PluginEmail* plugin,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_)
{
	PluginMailMergeLoadMergeEmailData* _data_;
	PluginMailMerge* _tmp0_;
	PluginEmail* _tmp1_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (plugin, PLUGIN_TYPE_EMAIL));
	_data_ = g_slice_new0 (PluginMailMergeLoadMergeEmailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, plugin_mail_merge_load_merge_email_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (plugin);
	_g_object_unref0 (_data_->plugin);
	_data_->plugin = _tmp1_;
	plugin_mail_merge_load_merge_email_co (_data_);
}

static GearyEmail*
plugin_mail_merge_load_merge_email_finish (PluginMailMerge* self,
                                           GAsyncResult* _res_,
                                           GError** error)
{
	GearyEmail* result;
	PluginMailMergeLoadMergeEmailData* _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
plugin_mail_merge_load_merge_email_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_)
{
	PluginMailMergeLoadMergeEmailData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	plugin_mail_merge_load_merge_email_co (_data_);
}

static gboolean
plugin_mail_merge_load_merge_email_co (PluginMailMergeLoadMergeEmailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = plugin_trusted_extension_get_client_plugins (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension));
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = application_plugin_manager_to_engine_email (_data_->_tmp1_, _data_->plugin);
	_data_->engine = _data_->_tmp2_;
	_data_->_tmp4_ = _data_->engine;
	if (_data_->_tmp4_ != NULL) {
		_data_->_tmp5_ = _data_->engine;
		_data_->_tmp6_ = geary_email_get_fields (_data_->_tmp5_);
		_data_->_tmp7_ = _data_->_tmp6_;
		_data_->_tmp3_ = !geary_email_field_fulfills (_data_->_tmp7_, MAIL_MERGE_PROCESSOR_REQUIRED_FIELDS);
	} else {
		_data_->_tmp3_ = FALSE;
	}
	if (_data_->_tmp3_) {
		_data_->_tmp8_ = plugin_trusted_extension_get_client_plugins (G_TYPE_CHECK_INSTANCE_CAST (_data_->self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension));
		_data_->_tmp9_ = _data_->_tmp8_;
		_data_->_tmp10_ = plugin_email_get_identifier (_data_->plugin);
		_data_->_tmp11_ = _data_->_tmp10_;
		_data_->_tmp12_ = plugin_email_identifier_get_account (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		_data_->_tmp14_ = application_plugin_manager_to_client_account (_data_->_tmp9_, _data_->_tmp13_);
		_data_->account_context = _data_->_tmp14_;
		_data_->_tmp16_ = _data_->account_context;
		_data_->_tmp17_ = application_account_context_get_emails (_data_->_tmp16_);
		_data_->_tmp18_ = _data_->_tmp17_;
		_data_->_tmp19_ = _data_->engine;
		_data_->_tmp20_ = geary_email_get_id (_data_->_tmp19_);
		_data_->_tmp21_ = _data_->_tmp20_;
		_data_->_tmp22_ = _data_->self->priv->cancellable;
		_data_->_state_ = 1;
		geary_app_email_store_fetch_email_async (_data_->_tmp18_, _data_->_tmp21_, MAIL_MERGE_PROCESSOR_REQUIRED_FIELDS, GEARY_FOLDER_LIST_FLAGS_LOCAL_ONLY, _data_->_tmp22_, plugin_mail_merge_load_merge_email_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp23_ = geary_app_email_store_fetch_email_finish (_data_->_tmp18_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp15_ = _data_->_tmp23_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
			_g_object_unref0 (_data_->account_context);
			_g_object_unref0 (_data_->engine);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
		_data_->_tmp24_ = _data_->_tmp15_;
		_data_->_tmp15_ = NULL;
		_g_object_unref0 (_data_->engine);
		_data_->engine = _data_->_tmp24_;
		_g_object_unref0 (_data_->_tmp15_);
		_g_object_unref0 (_data_->account_context);
	}
	_data_->_tmp25_ = _data_->engine;
	if (_data_->_tmp25_ == NULL) {
		_data_->_tmp26_ = g_error_new_literal (GEARY_ENGINE_ERROR, GEARY_ENGINE_ERROR_NOT_FOUND, "Plugin email not found");
		_data_->_inner_error0_ = _data_->_tmp26_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->engine);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->result = _data_->engine;
	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
plugin_mail_merge_on_edit_activated (PluginMailMerge* self,
                                     GAction* action,
                                     GVariant* target)
{
	gboolean _tmp0_ = FALSE;
	PluginEmailStore* _tmp1_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (action, g_action_get_type ()));
	_tmp1_ = self->priv->email_store;
	if (_tmp1_ != NULL) {
		_tmp0_ = target != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		PluginEmailIdentifier* id = NULL;
		PluginEmailStore* _tmp2_;
		PluginEmailIdentifier* _tmp3_;
		PluginEmailIdentifier* _tmp4_;
		_tmp2_ = self->priv->email_store;
		_tmp3_ = plugin_email_store_get_email_identifier_for_variant (_tmp2_, target);
		id = _tmp3_;
		_tmp4_ = id;
		if (_tmp4_ != NULL) {
			PluginEmailIdentifier* _tmp5_;
			_tmp5_ = id;
			plugin_mail_merge_edit_email (self, _tmp5_, NULL, NULL);
		}
		_g_object_unref0 (id);
	}
}

static void
plugin_mail_merge_on_merge_activated (PluginMailMerge* self,
                                      GAction* action,
                                      GVariant* target)
{
	gboolean _tmp0_ = FALSE;
	PluginEmailStore* _tmp1_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (action, g_action_get_type ()));
	_tmp1_ = self->priv->email_store;
	if (_tmp1_ != NULL) {
		_tmp0_ = target != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		PluginEmailIdentifier* id = NULL;
		PluginEmailStore* _tmp2_;
		PluginEmailIdentifier* _tmp3_;
		PluginEmailIdentifier* _tmp4_;
		_tmp2_ = self->priv->email_store;
		_tmp3_ = plugin_email_store_get_email_identifier_for_variant (_tmp2_, target);
		id = _tmp3_;
		_tmp4_ = id;
		if (_tmp4_ != NULL) {
			PluginEmailIdentifier* _tmp5_;
			_tmp5_ = id;
			plugin_mail_merge_merge_email (self, _tmp5_, NULL, NULL, NULL);
		}
		_g_object_unref0 (id);
	}
}

static void
plugin_mail_merge_on_start_activated (PluginMailMerge* self,
                                      GAction* action,
                                      GVariant* target)
{
	MailMergeFolder* _tmp0_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (action, g_action_get_type ()));
	_tmp0_ = self->priv->merge_folder;
	mail_merge_folder_set_sending (_tmp0_, TRUE);
	plugin_mail_merge_update_merge_folder_info_bar (self);
}

static void
plugin_mail_merge_on_pause_activated (PluginMailMerge* self,
                                      GAction* action,
                                      GVariant* target)
{
	MailMergeFolder* _tmp0_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (action, g_action_get_type ()));
	_tmp0_ = self->priv->merge_folder;
	mail_merge_folder_set_sending (_tmp0_, FALSE);
	plugin_mail_merge_update_merge_folder_info_bar (self);
}

static void
plugin_mail_merge_on_composer_registered (PluginMailMerge* self,
                                          PluginComposer* registered)
{
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (registered, PLUGIN_TYPE_COMPOSER));
	plugin_mail_merge_update_composer (self, registered, NULL, NULL);
}

static void
plugin_mail_merge_on_merge_closed (PluginMailMerge* self)
{
	MailMergeFolder* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	_tmp0_ = self->priv->merge_folder;
	if (_tmp0_ != NULL) {
		{
			MailMergeFolder* _tmp1_;
			GearyAccount* _tmp2_;
			GearyAccount* _tmp3_;
			MailMergeFolder* _tmp4_;
			_tmp1_ = self->priv->merge_folder;
			_tmp2_ = geary_folder_get_account (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEARY_TYPE_FOLDER, GearyFolder));
			_tmp3_ = _tmp2_;
			_tmp4_ = self->priv->merge_folder;
			geary_account_deregister_local_folder (_tmp3_, G_TYPE_CHECK_INSTANCE_CAST (_tmp4_, GEARY_TYPE_FOLDER, GearyFolder), &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* err = NULL;
			GError* _tmp5_;
			const gchar* _tmp6_;
			err = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp5_ = err;
			_tmp6_ = _tmp5_->message;
			g_warning ("mail-merge.vala:478: Error de-registering merge folder: %s", _tmp6_);
			_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;
		}
		_g_object_unref0 (self->priv->merge_folder);
		self->priv->merge_folder = NULL;
		_g_object_unref0 (self->priv->merge_bar);
		self->priv->merge_bar = NULL;
	}
}

static void
plugin_mail_merge_on_folders_available (PluginMailMerge* self,
                                        GeeCollection* available)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (available, GEE_TYPE_COLLECTION));
	{
		GeeIterator* _folder_it = NULL;
		GeeIterator* _tmp0_;
		_tmp0_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (available, GEE_TYPE_ITERABLE, GeeIterable));
		_folder_it = _tmp0_;
		while (TRUE) {
			GeeIterator* _tmp1_;
			PluginFolder* folder = NULL;
			GeeIterator* _tmp2_;
			gpointer _tmp3_;
			GearyFolder* engine_folder = NULL;
			ApplicationPluginManager* _tmp4_;
			ApplicationPluginManager* _tmp5_;
			PluginFolder* _tmp6_;
			GearyFolder* _tmp7_;
			MailMergeFolder* _tmp8_;
			GearyFolder* _tmp9_;
			_tmp1_ = _folder_it;
			if (!gee_iterator_next (_tmp1_)) {
				break;
			}
			_tmp2_ = _folder_it;
			_tmp3_ = gee_iterator_get (_tmp2_);
			folder = (PluginFolder*) _tmp3_;
			_tmp4_ = plugin_trusted_extension_get_client_plugins (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension));
			_tmp5_ = _tmp4_;
			_tmp6_ = folder;
			_tmp7_ = application_plugin_manager_to_engine_folder (_tmp5_, _tmp6_);
			engine_folder = _tmp7_;
			_tmp8_ = self->priv->merge_folder;
			_tmp9_ = engine_folder;
			if (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, GEARY_TYPE_FOLDER, GearyFolder) == _tmp9_) {
				{
					PluginFolderContext* _tmp10_;
					PluginFolderContext* _tmp11_;
					PluginFolder* _tmp12_;
					_tmp10_ = plugin_folder_extension_get_folders (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_FOLDER_EXTENSION, PluginFolderExtension));
					_tmp11_ = _tmp10_;
					_tmp12_ = folder;
					plugin_folder_context_register_folder_used_as (_tmp11_, _tmp12_, _ ("Mail Merge"), "mail-outbox-symbolic", &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
				}
				goto __finally0;
				__catch0_g_error:
				{
					GError* err = NULL;
					PluginFolder* _tmp13_;
					const gchar* _tmp14_;
					const gchar* _tmp15_;
					GError* _tmp16_;
					const gchar* _tmp17_;
					err = _inner_error0_;
					_inner_error0_ = NULL;
					_tmp13_ = folder;
					_tmp14_ = plugin_folder_get_persistent_id (_tmp13_);
					_tmp15_ = _tmp14_;
					_tmp16_ = err;
					_tmp17_ = _tmp16_->message;
					g_warning ("mail-merge.vala:498: Failed to register %s as merge folder: %s", _tmp15_, _tmp17_);
					_g_error_free0 (err);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (engine_folder);
					_g_object_unref0 (folder);
					_g_object_unref0 (_folder_it);
					g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
					g_clear_error (&_inner_error0_);
					return;
				}
			}
			_g_object_unref0 (engine_folder);
			_g_object_unref0 (folder);
		}
		_g_object_unref0 (_folder_it);
	}
}

static void
plugin_mail_merge_on_folder_selected (PluginMailMerge* self,
                                      PluginFolder* selected)
{
	GearyFolder* engine_folder = NULL;
	ApplicationPluginManager* _tmp0_;
	ApplicationPluginManager* _tmp1_;
	GearyFolder* _tmp2_;
	MailMergeFolder* _tmp3_;
	GearyFolder* _tmp4_;
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (selected, PLUGIN_TYPE_FOLDER));
	_tmp0_ = plugin_trusted_extension_get_client_plugins (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension));
	_tmp1_ = _tmp0_;
	_tmp2_ = application_plugin_manager_to_engine_folder (_tmp1_, selected);
	engine_folder = _tmp2_;
	_tmp3_ = self->priv->merge_folder;
	_tmp4_ = engine_folder;
	if (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, GEARY_TYPE_FOLDER, GearyFolder) == _tmp4_) {
		PluginFolderContext* _tmp5_;
		PluginFolderContext* _tmp6_;
		PluginInfoBar* _tmp7_;
		_tmp5_ = plugin_folder_extension_get_folders (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_FOLDER_EXTENSION, PluginFolderExtension));
		_tmp6_ = _tmp5_;
		_tmp7_ = self->priv->merge_bar;
		plugin_folder_context_add_folder_info_bar (_tmp6_, selected, _tmp7_, (guint) PLUGIN_MAIL_MERGE_INFO_BAR_PRIORITY);
	}
	_g_object_unref0 (engine_folder);
}

static void
plugin_mail_merge_on_email_displayed (PluginMailMerge* self,
                                      PluginEmail* email)
{
	g_return_if_fail (PLUGIN_IS_MAIL_MERGE (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email, PLUGIN_TYPE_EMAIL));
	plugin_mail_merge_update_email (self, email, NULL, NULL);
}

PluginMailMerge*
plugin_mail_merge_construct (GType object_type)
{
	PluginMailMerge * self = NULL;
	self = (PluginMailMerge*) plugin_plugin_base_construct (object_type);
	return self;
}

PluginMailMerge*
plugin_mail_merge_new (void)
{
	return plugin_mail_merge_construct (PLUGIN_TYPE_MAIL_MERGE);
}

static void
plugin_mail_merge_class_init (PluginMailMergeClass * klass,
                              gpointer klass_data)
{
	plugin_mail_merge_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &PluginMailMerge_private_offset);
	((PluginPluginBaseClass *) klass)->activate = (void (*) (PluginPluginBase*, gboolean, GAsyncReadyCallback, gpointer)) plugin_mail_merge_real_activate;
	((PluginPluginBaseClass *) klass)->activate_finish = (void (*) (PluginPluginBase*, GAsyncResult*, GError**)) plugin_mail_merge_activate_finish;
	((PluginPluginBaseClass *) klass)->deactivate = (void (*) (PluginPluginBase*, gboolean, GAsyncReadyCallback, gpointer)) plugin_mail_merge_real_deactivate;
	((PluginPluginBaseClass *) klass)->deactivate_finish = (void (*) (PluginPluginBase*, GAsyncResult*, GError**)) plugin_mail_merge_deactivate_finish;
	G_OBJECT_CLASS (klass)->get_property = _vala_plugin_mail_merge_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_plugin_mail_merge_set_property;
	G_OBJECT_CLASS (klass)->finalize = plugin_mail_merge_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLUGIN_MAIL_MERGE_FOLDERS_PROPERTY, plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_FOLDERS_PROPERTY] = g_param_spec_object ("folders", "folders", "folders", PLUGIN_TYPE_FOLDER_CONTEXT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLUGIN_MAIL_MERGE_EMAIL_PROPERTY, plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_EMAIL_PROPERTY] = g_param_spec_object ("email", "email", "email", PLUGIN_TYPE_EMAIL_CONTEXT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLUGIN_MAIL_MERGE_CLIENT_APPLICATION_PROPERTY, plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_CLIENT_APPLICATION_PROPERTY] = g_param_spec_object ("client-application", "client-application", "client-application", APPLICATION_TYPE_CLIENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PLUGIN_MAIL_MERGE_CLIENT_PLUGINS_PROPERTY, plugin_mail_merge_properties[PLUGIN_MAIL_MERGE_CLIENT_PLUGINS_PROPERTY] = g_param_spec_object ("client-plugins", "client-plugins", "client-plugins", APPLICATION_TYPE_PLUGIN_MANAGER, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT));
}

static void
plugin_mail_merge_plugin_folder_extension_interface_init (PluginFolderExtensionIface * iface,
                                                          gpointer iface_data)
{
	plugin_mail_merge_plugin_folder_extension_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_folders = plugin_mail_merge_real_get_folders;
	iface->set_folders = plugin_mail_merge_real_set_folders;
}

static void
plugin_mail_merge_plugin_email_extension_interface_init (PluginEmailExtensionIface * iface,
                                                         gpointer iface_data)
{
	plugin_mail_merge_plugin_email_extension_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_email = plugin_mail_merge_real_get_email;
	iface->set_email = plugin_mail_merge_real_set_email;
}

static void
plugin_mail_merge_plugin_trusted_extension_interface_init (PluginTrustedExtensionIface * iface,
                                                           gpointer iface_data)
{
	plugin_mail_merge_plugin_trusted_extension_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_client_application = plugin_mail_merge_real_get_client_application;
	iface->set_client_application = plugin_mail_merge_real_set_client_application;
	iface->get_client_plugins = plugin_mail_merge_real_get_client_plugins;
	iface->set_client_plugins = plugin_mail_merge_real_set_client_plugins;
}

static void
plugin_mail_merge_instance_init (PluginMailMerge * self,
                                 gpointer klass)
{
	GeeArrayList* _tmp0_;
	GCancellable* _tmp1_;
	self->priv = plugin_mail_merge_get_instance_private (self);
	self->priv->folder_store = NULL;
	self->priv->email_store = NULL;
	self->priv->merge_folder = NULL;
	self->priv->merge_bar = NULL;
	self->priv->edit_action = NULL;
	self->priv->merge_action = NULL;
	self->priv->start_action = NULL;
	self->priv->pause_action = NULL;
	self->priv->start_ui = NULL;
	self->priv->pause_ui = NULL;
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	self->priv->folder_names = G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, GEE_TYPE_LIST, GeeList);
	_tmp1_ = g_cancellable_new ();
	self->priv->cancellable = _tmp1_;
}

static void
plugin_mail_merge_finalize (GObject * obj)
{
	PluginMailMerge * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	_g_object_unref0 (self->priv->_folders);
	_g_object_unref0 (self->priv->_email);
	_g_object_unref0 (self->priv->_client_application);
	_g_object_unref0 (self->priv->_client_plugins);
	_g_object_unref0 (self->priv->folder_store);
	_g_object_unref0 (self->priv->email_store);
	_g_object_unref0 (self->priv->merge_folder);
	_g_object_unref0 (self->priv->merge_bar);
	_g_object_unref0 (self->priv->edit_action);
	_g_object_unref0 (self->priv->merge_action);
	_g_object_unref0 (self->priv->start_action);
	_g_object_unref0 (self->priv->pause_action);
	_g_object_unref0 (self->priv->start_ui);
	_g_object_unref0 (self->priv->pause_ui);
	_g_object_unref0 (self->priv->folder_names);
	_g_object_unref0 (self->priv->cancellable);
	G_OBJECT_CLASS (plugin_mail_merge_parent_class)->finalize (obj);
}

/**
 * Plugin to fill in and send email templates using a spreadsheet.
 */
GType
plugin_mail_merge_get_type (void)
{
	return plugin_mail_merge_type_id;
}

GType
plugin_mail_merge_register_type (GTypeModule * module)
{
	static const GTypeInfo g_define_type_info = { sizeof (PluginMailMergeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) plugin_mail_merge_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (PluginMailMerge), 0, (GInstanceInitFunc) plugin_mail_merge_instance_init, NULL };
	static const GInterfaceInfo plugin_folder_extension_info = { (GInterfaceInitFunc) plugin_mail_merge_plugin_folder_extension_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo plugin_email_extension_info = { (GInterfaceInitFunc) plugin_mail_merge_plugin_email_extension_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	static const GInterfaceInfo plugin_trusted_extension_info = { (GInterfaceInitFunc) plugin_mail_merge_plugin_trusted_extension_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	plugin_mail_merge_type_id = g_type_module_register_type (module, PLUGIN_TYPE_PLUGIN_BASE, "PluginMailMerge", &g_define_type_info, 0);
	g_type_module_add_interface (module, plugin_mail_merge_type_id, PLUGIN_TYPE_FOLDER_EXTENSION, &plugin_folder_extension_info);
	g_type_module_add_interface (module, plugin_mail_merge_type_id, PLUGIN_TYPE_EMAIL_EXTENSION, &plugin_email_extension_info);
	g_type_module_add_interface (module, plugin_mail_merge_type_id, PLUGIN_TYPE_TRUSTED_EXTENSION, &plugin_trusted_extension_info);
	PluginMailMerge_private_offset = sizeof (PluginMailMergePrivate);
	return plugin_mail_merge_type_id;
}

static void
_vala_plugin_mail_merge_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	PluginMailMerge * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	switch (property_id) {
		case PLUGIN_MAIL_MERGE_FOLDERS_PROPERTY:
		g_value_set_object (value, plugin_folder_extension_get_folders (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_FOLDER_EXTENSION, PluginFolderExtension)));
		break;
		case PLUGIN_MAIL_MERGE_EMAIL_PROPERTY:
		g_value_set_object (value, plugin_email_extension_get_email (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_EMAIL_EXTENSION, PluginEmailExtension)));
		break;
		case PLUGIN_MAIL_MERGE_CLIENT_APPLICATION_PROPERTY:
		g_value_set_object (value, plugin_trusted_extension_get_client_application (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension)));
		break;
		case PLUGIN_MAIL_MERGE_CLIENT_PLUGINS_PROPERTY:
		g_value_set_object (value, plugin_trusted_extension_get_client_plugins (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension)));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_plugin_mail_merge_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	PluginMailMerge * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PLUGIN_TYPE_MAIL_MERGE, PluginMailMerge);
	switch (property_id) {
		case PLUGIN_MAIL_MERGE_FOLDERS_PROPERTY:
		plugin_folder_extension_set_folders (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_FOLDER_EXTENSION, PluginFolderExtension), g_value_get_object (value));
		break;
		case PLUGIN_MAIL_MERGE_EMAIL_PROPERTY:
		plugin_email_extension_set_email (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_EMAIL_EXTENSION, PluginEmailExtension), g_value_get_object (value));
		break;
		case PLUGIN_MAIL_MERGE_CLIENT_APPLICATION_PROPERTY:
		plugin_trusted_extension_set_client_application (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension), g_value_get_object (value));
		break;
		case PLUGIN_MAIL_MERGE_CLIENT_PLUGINS_PROPERTY:
		plugin_trusted_extension_set_client_plugins (G_TYPE_CHECK_INSTANCE_CAST (self, PLUGIN_TYPE_TRUSTED_EXTENSION, PluginTrustedExtension), g_value_get_object (value));
		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);
}

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

