/* application-email-plugin-context.c generated by valac 0.56.19, the Vala compiler
 * generated from application-email-plugin-context.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 "geary-engine.h"
#include "geary-client-46.0.h"
#include <glib-object.h>
#include <glib.h>
#include <gio/gio.h>
#include <gee.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

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

typedef struct _ApplicationEmailPluginContext ApplicationEmailPluginContext;
typedef struct _ApplicationEmailPluginContextClass ApplicationEmailPluginContextClass;
typedef struct _ApplicationEmailPluginContextPrivate ApplicationEmailPluginContextPrivate;

#define APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_GLOBALS (application_plugin_manager_plugin_globals_get_type ())
#define APPLICATION_PLUGIN_MANAGER_PLUGIN_GLOBALS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_GLOBALS, ApplicationPluginManagerPluginGlobals))
#define APPLICATION_PLUGIN_MANAGER_PLUGIN_GLOBALS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_GLOBALS, ApplicationPluginManagerPluginGlobalsClass))
#define APPLICATION_PLUGIN_MANAGER_IS_PLUGIN_GLOBALS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_GLOBALS))
#define APPLICATION_PLUGIN_MANAGER_IS_PLUGIN_GLOBALS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_GLOBALS))
#define APPLICATION_PLUGIN_MANAGER_PLUGIN_GLOBALS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_GLOBALS, ApplicationPluginManagerPluginGlobalsClass))

typedef struct _ApplicationPluginManagerPluginGlobals ApplicationPluginManagerPluginGlobals;
typedef struct _ApplicationPluginManagerPluginGlobalsClass ApplicationPluginManagerPluginGlobalsClass;

#define APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_CONTEXT (application_plugin_manager_plugin_context_get_type ())
#define APPLICATION_PLUGIN_MANAGER_PLUGIN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_CONTEXT, ApplicationPluginManagerPluginContext))
#define APPLICATION_PLUGIN_MANAGER_PLUGIN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_CONTEXT, ApplicationPluginManagerPluginContextClass))
#define APPLICATION_PLUGIN_MANAGER_IS_PLUGIN_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_CONTEXT))
#define APPLICATION_PLUGIN_MANAGER_IS_PLUGIN_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_CONTEXT))
#define APPLICATION_PLUGIN_MANAGER_PLUGIN_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_PLUGIN_MANAGER_TYPE_PLUGIN_CONTEXT, ApplicationPluginManagerPluginContextClass))

typedef struct _ApplicationPluginManagerPluginContext ApplicationPluginManagerPluginContext;
typedef struct _ApplicationPluginManagerPluginContextClass ApplicationPluginManagerPluginContextClass;
enum  {
	APPLICATION_EMAIL_PLUGIN_CONTEXT_0_PROPERTY,
	APPLICATION_EMAIL_PLUGIN_CONTEXT_NUM_PROPERTIES
};
static GParamSpec* application_email_plugin_context_properties[APPLICATION_EMAIL_PLUGIN_CONTEXT_NUM_PROPERTIES];
#define _application_plugin_manager_plugin_globals_unref0(var) ((var == NULL) ? NULL : (var = (application_plugin_manager_plugin_globals_unref (var), NULL)))
#define _application_plugin_manager_plugin_context_unref0(var) ((var == NULL) ? NULL : (var = (application_plugin_manager_plugin_context_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define APPLICATION_TYPE_EMAIL_STORE_FACTORY (application_email_store_factory_get_type ())
#define APPLICATION_EMAIL_STORE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), APPLICATION_TYPE_EMAIL_STORE_FACTORY, ApplicationEmailStoreFactory))
#define APPLICATION_EMAIL_STORE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), APPLICATION_TYPE_EMAIL_STORE_FACTORY, ApplicationEmailStoreFactoryClass))
#define APPLICATION_IS_EMAIL_STORE_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), APPLICATION_TYPE_EMAIL_STORE_FACTORY))
#define APPLICATION_IS_EMAIL_STORE_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), APPLICATION_TYPE_EMAIL_STORE_FACTORY))
#define APPLICATION_EMAIL_STORE_FACTORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), APPLICATION_TYPE_EMAIL_STORE_FACTORY, ApplicationEmailStoreFactoryClass))

typedef struct _ApplicationEmailStoreFactory ApplicationEmailStoreFactory;
typedef struct _ApplicationEmailStoreFactoryClass ApplicationEmailStoreFactoryClass;
typedef struct _ApplicationEmailPluginContextGetEmailStoreData ApplicationEmailPluginContextGetEmailStoreData;

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

typedef struct _ApplicationController ApplicationController;
typedef struct _ApplicationControllerClass ApplicationControllerClass;

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

typedef struct _ApplicationAccountInterface ApplicationAccountInterface;
typedef struct _ApplicationAccountInterfaceIface ApplicationAccountInterfaceIface;

struct _ApplicationEmailPluginContext {
	GearyBaseObject parent_instance;
	ApplicationEmailPluginContextPrivate * priv;
};

struct _ApplicationEmailPluginContextClass {
	GearyBaseObjectClass parent_class;
};

struct _ApplicationEmailPluginContextPrivate {
	ApplicationClient* application;
	ApplicationPluginManagerPluginGlobals* globals;
	ApplicationPluginManagerPluginContext* plugin;
	PluginEmailStore* email;
};

struct _ApplicationEmailPluginContextGetEmailStoreData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	ApplicationEmailPluginContext* self;
	PluginEmailStore* result;
	PluginEmailStore* _tmp0_;
	PluginEmailStore* _tmp1_;
};

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

static gint ApplicationEmailPluginContext_private_offset;
static gpointer application_email_plugin_context_parent_class = NULL;
static PluginEmailContextIface * application_email_plugin_context_plugin_email_context_parent_iface = NULL;

VALA_EXTERN GType application_email_plugin_context_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gpointer application_plugin_manager_plugin_globals_ref (gpointer instance);
VALA_EXTERN void application_plugin_manager_plugin_globals_unref (gpointer instance);
VALA_EXTERN GParamSpec* application_plugin_manager_param_spec_plugin_globals (const gchar* name,
                                                                  const gchar* nick,
                                                                  const gchar* blurb,
                                                                  GType object_type,
                                                                  GParamFlags flags);
VALA_EXTERN void application_plugin_manager_value_set_plugin_globals (GValue* value,
                                                          gpointer v_object);
VALA_EXTERN void application_plugin_manager_value_take_plugin_globals (GValue* value,
                                                           gpointer v_object);
VALA_EXTERN gpointer application_plugin_manager_value_get_plugin_globals (const GValue* value);
VALA_EXTERN GType application_plugin_manager_plugin_globals_get_type (void) G_GNUC_CONST ;
VALA_EXTERN gpointer application_plugin_manager_plugin_context_ref (gpointer instance);
VALA_EXTERN void application_plugin_manager_plugin_context_unref (gpointer instance);
VALA_EXTERN GParamSpec* application_plugin_manager_param_spec_plugin_context (const gchar* name,
                                                                  const gchar* nick,
                                                                  const gchar* blurb,
                                                                  GType object_type,
                                                                  GParamFlags flags);
VALA_EXTERN void application_plugin_manager_value_set_plugin_context (GValue* value,
                                                          gpointer v_object);
VALA_EXTERN void application_plugin_manager_value_take_plugin_context (GValue* value,
                                                           gpointer v_object);
VALA_EXTERN gpointer application_plugin_manager_value_get_plugin_context (const GValue* value);
VALA_EXTERN GType application_plugin_manager_plugin_context_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ApplicationEmailPluginContext* application_email_plugin_context_new (ApplicationClient* application,
                                                                     ApplicationPluginManagerPluginGlobals* globals,
                                                                     ApplicationPluginManagerPluginContext* plugin);
VALA_EXTERN ApplicationEmailPluginContext* application_email_plugin_context_construct (GType object_type,
                                                                           ApplicationClient* application,
                                                                           ApplicationPluginManagerPluginGlobals* globals,
                                                                           ApplicationPluginManagerPluginContext* plugin);
VALA_EXTERN GType application_email_store_factory_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ApplicationEmailStoreFactory* application_plugin_manager_plugin_globals_get_email (ApplicationPluginManagerPluginGlobals* self);
VALA_EXTERN PluginEmailStore* application_email_store_factory_new_email_store (ApplicationEmailStoreFactory* self);
static void application_email_plugin_context_real_get_email_store_data_free (gpointer _data);
static void application_email_plugin_context_real_get_email_store (PluginEmailContext* base,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
static gboolean application_email_plugin_context_real_get_email_store_co (ApplicationEmailPluginContextGetEmailStoreData* _data_);
static void application_email_plugin_context_real_add_email_info_bar (PluginEmailContext* base,
                                                               PluginEmailIdentifier* displayed,
                                                               PluginInfoBar* info_bar,
                                                               guint priority);
VALA_EXTERN GearyEmailIdentifier* application_email_store_factory_to_engine_id (ApplicationEmailStoreFactory* self,
                                                                    PluginEmailIdentifier* plugin);
VALA_EXTERN const gchar* application_plugin_manager_plugin_context_get_action_group_name (ApplicationPluginManagerPluginContext* self);
static void application_email_plugin_context_real_remove_email_info_bar (PluginEmailContext* base,
                                                                  PluginEmailIdentifier* displayed,
                                                                  PluginInfoBar* info_bar);
VALA_EXTERN void application_email_plugin_context_email_displayed (ApplicationEmailPluginContext* self,
                                                       GearyAccountInformation* account,
                                                       GearyEmail* email);
VALA_EXTERN GType application_controller_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ApplicationController* application_client_get_controller (ApplicationClient* self);
VALA_EXTERN GType application_account_interface_get_type (void) G_GNUC_CONST ;
VALA_EXTERN ApplicationAccountContext* application_account_interface_get_context_for_account (ApplicationAccountInterface* self,
                                                                                  GearyAccountInformation* account);
VALA_EXTERN PluginEmail* application_email_store_factory_to_plugin_email (ApplicationEmailStoreFactory* self,
                                                              GearyEmail* engine,
                                                              ApplicationAccountContext* account);
VALA_EXTERN void application_email_plugin_context_email_sent (ApplicationEmailPluginContext* self,
                                                  GearyAccountInformation* account,
                                                  GearyEmail* email);
VALA_EXTERN void application_email_plugin_context_destroy (ApplicationEmailPluginContext* self);
VALA_EXTERN void application_email_store_factory_destroy_email_store (ApplicationEmailStoreFactory* self,
                                                          PluginEmailStore* plugin);
static void application_email_plugin_context_finalize (GObject * obj);
static GType application_email_plugin_context_get_type_once (void);

static inline gpointer
application_email_plugin_context_get_instance_private (ApplicationEmailPluginContext* self)
{
	return G_STRUCT_MEMBER_P (self, ApplicationEmailPluginContext_private_offset);
}

static gpointer
_application_plugin_manager_plugin_globals_ref0 (gpointer self)
{
	return self ? application_plugin_manager_plugin_globals_ref (self) : NULL;
}

static gpointer
_application_plugin_manager_plugin_context_ref0 (gpointer self)
{
	return self ? application_plugin_manager_plugin_context_ref (self) : NULL;
}

ApplicationEmailPluginContext*
application_email_plugin_context_construct (GType object_type,
                                            ApplicationClient* application,
                                            ApplicationPluginManagerPluginGlobals* globals,
                                            ApplicationPluginManagerPluginContext* plugin)
{
	ApplicationEmailPluginContext * self = NULL;
	ApplicationPluginManagerPluginGlobals* _tmp0_;
	ApplicationPluginManagerPluginContext* _tmp1_;
	ApplicationEmailStoreFactory* _tmp2_;
	ApplicationEmailStoreFactory* _tmp3_;
	PluginEmailStore* _tmp4_;
	g_return_val_if_fail (APPLICATION_IS_CLIENT (application), NULL);
	g_return_val_if_fail (APPLICATION_PLUGIN_MANAGER_IS_PLUGIN_GLOBALS (globals), NULL);
	g_return_val_if_fail (APPLICATION_PLUGIN_MANAGER_IS_PLUGIN_CONTEXT (plugin), NULL);
	self = (ApplicationEmailPluginContext*) geary_base_object_construct (object_type);
	self->priv->application = application;
	_tmp0_ = _application_plugin_manager_plugin_globals_ref0 (globals);
	_application_plugin_manager_plugin_globals_unref0 (self->priv->globals);
	self->priv->globals = _tmp0_;
	_tmp1_ = _application_plugin_manager_plugin_context_ref0 (plugin);
	_application_plugin_manager_plugin_context_unref0 (self->priv->plugin);
	self->priv->plugin = _tmp1_;
	_tmp2_ = application_plugin_manager_plugin_globals_get_email (globals);
	_tmp3_ = _tmp2_;
	_tmp4_ = application_email_store_factory_new_email_store (_tmp3_);
	_g_object_unref0 (self->priv->email);
	self->priv->email = _tmp4_;
	return self;
}

ApplicationEmailPluginContext*
application_email_plugin_context_new (ApplicationClient* application,
                                      ApplicationPluginManagerPluginGlobals* globals,
                                      ApplicationPluginManagerPluginContext* plugin)
{
	return application_email_plugin_context_construct (APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT, application, globals, plugin);
}

static void
application_email_plugin_context_real_get_email_store_data_free (gpointer _data)
{
	ApplicationEmailPluginContextGetEmailStoreData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (ApplicationEmailPluginContextGetEmailStoreData, _data_);
}

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

static void
application_email_plugin_context_real_get_email_store (PluginEmailContext* base,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	ApplicationEmailPluginContext * self;
	ApplicationEmailPluginContextGetEmailStoreData* _data_;
	ApplicationEmailPluginContext* _tmp0_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT, ApplicationEmailPluginContext);
	_data_ = g_slice_new0 (ApplicationEmailPluginContextGetEmailStoreData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, application_email_plugin_context_real_get_email_store_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	application_email_plugin_context_real_get_email_store_co (_data_);
}

static PluginEmailStore*
application_email_plugin_context_get_email_store_finish (PluginEmailContext* base,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	PluginEmailStore* result;
	ApplicationEmailPluginContextGetEmailStoreData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return NULL;
	}
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static gboolean
application_email_plugin_context_real_get_email_store_co (ApplicationEmailPluginContextGetEmailStoreData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->email;
	_data_->_tmp1_ = _g_object_ref0 (_data_->_tmp0_);
	_data_->result = _data_->_tmp1_;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
application_email_plugin_context_real_add_email_info_bar (PluginEmailContext* base,
                                                          PluginEmailIdentifier* displayed,
                                                          PluginInfoBar* info_bar,
                                                          guint priority)
{
	ApplicationEmailPluginContext * self;
	GearyEmailIdentifier* id = NULL;
	ApplicationPluginManagerPluginGlobals* _tmp0_;
	ApplicationEmailStoreFactory* _tmp1_;
	ApplicationEmailStoreFactory* _tmp2_;
	GearyEmailIdentifier* _tmp3_;
	GearyEmailIdentifier* _tmp4_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT, ApplicationEmailPluginContext);
	g_return_if_fail (PLUGIN_IS_EMAIL_IDENTIFIER (displayed));
	g_return_if_fail (PLUGIN_IS_INFO_BAR (info_bar));
	_tmp0_ = self->priv->globals;
	_tmp1_ = application_plugin_manager_plugin_globals_get_email (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = application_email_store_factory_to_engine_id (_tmp2_, displayed);
	id = _tmp3_;
	_tmp4_ = id;
	if (_tmp4_ != NULL) {
		{
			GeeIterator* _main_it = NULL;
			ApplicationClient* _tmp5_;
			GeeCollection* _tmp6_;
			GeeCollection* _tmp7_;
			GeeIterator* _tmp8_;
			GeeIterator* _tmp9_;
			_tmp5_ = self->priv->application;
			_tmp6_ = application_client_get_main_windows (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_ITERABLE, GeeIterable));
			_tmp9_ = _tmp8_;
			_g_object_unref0 (_tmp7_);
			_main_it = _tmp9_;
			while (TRUE) {
				GeeIterator* _tmp10_;
				ApplicationMainWindow* main = NULL;
				GeeIterator* _tmp11_;
				gpointer _tmp12_;
				ApplicationMainWindow* _tmp13_;
				ConversationViewer* _tmp14_;
				ConversationViewer* _tmp15_;
				ConversationListBox* _tmp16_;
				ConversationListBox* _tmp17_;
				_tmp10_ = _main_it;
				if (!gee_iterator_next (_tmp10_)) {
					break;
				}
				_tmp11_ = _main_it;
				_tmp12_ = gee_iterator_get (_tmp11_);
				main = (ApplicationMainWindow*) _tmp12_;
				_tmp13_ = main;
				_tmp14_ = application_main_window_get_conversation_viewer (_tmp13_);
				_tmp15_ = _tmp14_;
				_tmp16_ = conversation_viewer_get_current_list (_tmp15_);
				_tmp17_ = _tmp16_;
				if (_tmp17_ != NULL) {
					ApplicationMainWindow* _tmp18_;
					ConversationViewer* _tmp19_;
					ConversationViewer* _tmp20_;
					ConversationListBox* _tmp21_;
					ConversationListBox* _tmp22_;
					GearyEmailIdentifier* _tmp23_;
					ApplicationPluginManagerPluginContext* _tmp24_;
					const gchar* _tmp25_;
					const gchar* _tmp26_;
					ComponentsInfoBar* _tmp27_;
					ComponentsInfoBar* _tmp28_;
					_tmp18_ = main;
					_tmp19_ = application_main_window_get_conversation_viewer (_tmp18_);
					_tmp20_ = _tmp19_;
					_tmp21_ = conversation_viewer_get_current_list (_tmp20_);
					_tmp22_ = _tmp21_;
					_tmp23_ = id;
					_tmp24_ = self->priv->plugin;
					_tmp25_ = application_plugin_manager_plugin_context_get_action_group_name (_tmp24_);
					_tmp26_ = _tmp25_;
					_tmp27_ = components_info_bar_new_for_plugin (info_bar, _tmp26_, (gint) priority);
					g_object_ref_sink (_tmp27_);
					_tmp28_ = _tmp27_;
					conversation_list_box_add_email_info_bar (_tmp22_, _tmp23_, _tmp28_);
					_g_object_unref0 (_tmp28_);
				}
				_g_object_unref0 (main);
			}
			_g_object_unref0 (_main_it);
		}
	}
	_g_object_unref0 (id);
}

static void
application_email_plugin_context_real_remove_email_info_bar (PluginEmailContext* base,
                                                             PluginEmailIdentifier* displayed,
                                                             PluginInfoBar* info_bar)
{
	ApplicationEmailPluginContext * self;
	GearyEmailIdentifier* id = NULL;
	ApplicationPluginManagerPluginGlobals* _tmp0_;
	ApplicationEmailStoreFactory* _tmp1_;
	ApplicationEmailStoreFactory* _tmp2_;
	GearyEmailIdentifier* _tmp3_;
	GearyEmailIdentifier* _tmp4_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT, ApplicationEmailPluginContext);
	g_return_if_fail (PLUGIN_IS_EMAIL_IDENTIFIER (displayed));
	g_return_if_fail (PLUGIN_IS_INFO_BAR (info_bar));
	_tmp0_ = self->priv->globals;
	_tmp1_ = application_plugin_manager_plugin_globals_get_email (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = application_email_store_factory_to_engine_id (_tmp2_, displayed);
	id = _tmp3_;
	_tmp4_ = id;
	if (_tmp4_ != NULL) {
		{
			GeeIterator* _main_it = NULL;
			ApplicationClient* _tmp5_;
			GeeCollection* _tmp6_;
			GeeCollection* _tmp7_;
			GeeIterator* _tmp8_;
			GeeIterator* _tmp9_;
			_tmp5_ = self->priv->application;
			_tmp6_ = application_client_get_main_windows (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = gee_iterable_iterator (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, GEE_TYPE_ITERABLE, GeeIterable));
			_tmp9_ = _tmp8_;
			_g_object_unref0 (_tmp7_);
			_main_it = _tmp9_;
			while (TRUE) {
				GeeIterator* _tmp10_;
				ApplicationMainWindow* main = NULL;
				GeeIterator* _tmp11_;
				gpointer _tmp12_;
				ApplicationMainWindow* _tmp13_;
				ConversationViewer* _tmp14_;
				ConversationViewer* _tmp15_;
				ConversationListBox* _tmp16_;
				ConversationListBox* _tmp17_;
				_tmp10_ = _main_it;
				if (!gee_iterator_next (_tmp10_)) {
					break;
				}
				_tmp11_ = _main_it;
				_tmp12_ = gee_iterator_get (_tmp11_);
				main = (ApplicationMainWindow*) _tmp12_;
				_tmp13_ = main;
				_tmp14_ = application_main_window_get_conversation_viewer (_tmp13_);
				_tmp15_ = _tmp14_;
				_tmp16_ = conversation_viewer_get_current_list (_tmp15_);
				_tmp17_ = _tmp16_;
				if (_tmp17_ != NULL) {
				}
				_g_object_unref0 (main);
			}
			_g_object_unref0 (_main_it);
		}
	}
	_g_object_unref0 (id);
}

void
application_email_plugin_context_email_displayed (ApplicationEmailPluginContext* self,
                                                  GearyAccountInformation* account,
                                                  GearyEmail* email)
{
	ApplicationAccountContext* context = NULL;
	ApplicationClient* _tmp0_;
	ApplicationController* _tmp1_;
	ApplicationController* _tmp2_;
	ApplicationAccountContext* _tmp3_;
	ApplicationAccountContext* _tmp4_;
	g_return_if_fail (APPLICATION_IS_EMAIL_PLUGIN_CONTEXT (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT_INFORMATION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email, GEARY_TYPE_EMAIL));
	_tmp0_ = self->priv->application;
	_tmp1_ = application_client_get_controller (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = application_account_interface_get_context_for_account (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, APPLICATION_TYPE_ACCOUNT_INTERFACE, ApplicationAccountInterface), account);
	context = _tmp3_;
	_tmp4_ = context;
	if (_tmp4_ != NULL) {
		PluginEmailStore* _tmp5_;
		ApplicationPluginManagerPluginGlobals* _tmp6_;
		ApplicationEmailStoreFactory* _tmp7_;
		ApplicationEmailStoreFactory* _tmp8_;
		ApplicationAccountContext* _tmp9_;
		PluginEmail* _tmp10_;
		PluginEmail* _tmp11_;
		_tmp5_ = self->priv->email;
		_tmp6_ = self->priv->globals;
		_tmp7_ = application_plugin_manager_plugin_globals_get_email (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = context;
		_tmp10_ = application_email_store_factory_to_plugin_email (_tmp8_, email, _tmp9_);
		_tmp11_ = _tmp10_;
		g_signal_emit_by_name (_tmp5_, "email-displayed", _tmp11_);
		_g_object_unref0 (_tmp11_);
	}
	_g_object_unref0 (context);
}

void
application_email_plugin_context_email_sent (ApplicationEmailPluginContext* self,
                                             GearyAccountInformation* account,
                                             GearyEmail* email)
{
	ApplicationAccountContext* context = NULL;
	ApplicationClient* _tmp0_;
	ApplicationController* _tmp1_;
	ApplicationController* _tmp2_;
	ApplicationAccountContext* _tmp3_;
	ApplicationAccountContext* _tmp4_;
	g_return_if_fail (APPLICATION_IS_EMAIL_PLUGIN_CONTEXT (self));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (account, GEARY_TYPE_ACCOUNT_INFORMATION));
	g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (email, GEARY_TYPE_EMAIL));
	_tmp0_ = self->priv->application;
	_tmp1_ = application_client_get_controller (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = application_account_interface_get_context_for_account (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, APPLICATION_TYPE_ACCOUNT_INTERFACE, ApplicationAccountInterface), account);
	context = _tmp3_;
	_tmp4_ = context;
	if (_tmp4_ != NULL) {
		PluginEmailStore* _tmp5_;
		ApplicationPluginManagerPluginGlobals* _tmp6_;
		ApplicationEmailStoreFactory* _tmp7_;
		ApplicationEmailStoreFactory* _tmp8_;
		ApplicationAccountContext* _tmp9_;
		PluginEmail* _tmp10_;
		PluginEmail* _tmp11_;
		_tmp5_ = self->priv->email;
		_tmp6_ = self->priv->globals;
		_tmp7_ = application_plugin_manager_plugin_globals_get_email (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = context;
		_tmp10_ = application_email_store_factory_to_plugin_email (_tmp8_, email, _tmp9_);
		_tmp11_ = _tmp10_;
		g_signal_emit_by_name (_tmp5_, "email-sent", _tmp11_);
		_g_object_unref0 (_tmp11_);
	}
	_g_object_unref0 (context);
}

void
application_email_plugin_context_destroy (ApplicationEmailPluginContext* self)
{
	ApplicationPluginManagerPluginGlobals* _tmp0_;
	ApplicationEmailStoreFactory* _tmp1_;
	ApplicationEmailStoreFactory* _tmp2_;
	PluginEmailStore* _tmp3_;
	g_return_if_fail (APPLICATION_IS_EMAIL_PLUGIN_CONTEXT (self));
	_tmp0_ = self->priv->globals;
	_tmp1_ = application_plugin_manager_plugin_globals_get_email (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->email;
	application_email_store_factory_destroy_email_store (_tmp2_, _tmp3_);
}

static void
application_email_plugin_context_class_init (ApplicationEmailPluginContextClass * klass,
                                             gpointer klass_data)
{
	application_email_plugin_context_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ApplicationEmailPluginContext_private_offset);
	G_OBJECT_CLASS (klass)->finalize = application_email_plugin_context_finalize;
}

static void
application_email_plugin_context_plugin_email_context_interface_init (PluginEmailContextIface * iface,
                                                                      gpointer iface_data)
{
	application_email_plugin_context_plugin_email_context_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_email_store = (void (*) (PluginEmailContext*, GAsyncReadyCallback, gpointer)) application_email_plugin_context_real_get_email_store;
	iface->get_email_store_finish = (PluginEmailStore* (*) (PluginEmailContext*, GAsyncResult*, GError**)) application_email_plugin_context_get_email_store_finish;
	iface->add_email_info_bar = (void (*) (PluginEmailContext*, PluginEmailIdentifier*, PluginInfoBar*, guint)) application_email_plugin_context_real_add_email_info_bar;
	iface->remove_email_info_bar = (void (*) (PluginEmailContext*, PluginEmailIdentifier*, PluginInfoBar*)) application_email_plugin_context_real_remove_email_info_bar;
}

static void
application_email_plugin_context_instance_init (ApplicationEmailPluginContext * self,
                                                gpointer klass)
{
	self->priv = application_email_plugin_context_get_instance_private (self);
}

static void
application_email_plugin_context_finalize (GObject * obj)
{
	ApplicationEmailPluginContext * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, APPLICATION_TYPE_EMAIL_PLUGIN_CONTEXT, ApplicationEmailPluginContext);
	_application_plugin_manager_plugin_globals_unref0 (self->priv->globals);
	_application_plugin_manager_plugin_context_unref0 (self->priv->plugin);
	_g_object_unref0 (self->priv->email);
	G_OBJECT_CLASS (application_email_plugin_context_parent_class)->finalize (obj);
}

/**
 * Implementation of the email plugin extension context.
 */
static GType
application_email_plugin_context_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ApplicationEmailPluginContextClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) application_email_plugin_context_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ApplicationEmailPluginContext), 0, (GInstanceInitFunc) application_email_plugin_context_instance_init, NULL };
	static const GInterfaceInfo plugin_email_context_info = { (GInterfaceInitFunc) application_email_plugin_context_plugin_email_context_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType application_email_plugin_context_type_id;
	application_email_plugin_context_type_id = g_type_register_static (GEARY_TYPE_BASE_OBJECT, "ApplicationEmailPluginContext", &g_define_type_info, 0);
	g_type_add_interface_static (application_email_plugin_context_type_id, PLUGIN_TYPE_EMAIL_CONTEXT, &plugin_email_context_info);
	ApplicationEmailPluginContext_private_offset = g_type_add_instance_private (application_email_plugin_context_type_id, sizeof (ApplicationEmailPluginContextPrivate));
	return application_email_plugin_context_type_id;
}

GType
application_email_plugin_context_get_type (void)
{
	static volatile gsize application_email_plugin_context_type_id__once = 0;
	if (g_once_init_enter (&application_email_plugin_context_type_id__once)) {
		GType application_email_plugin_context_type_id;
		application_email_plugin_context_type_id = application_email_plugin_context_get_type_once ();
		g_once_init_leave (&application_email_plugin_context_type_id__once, application_email_plugin_context_type_id);
	}
	return application_email_plugin_context_type_id__once;
}

