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

/*
* Copyright 2021 elementary, Inc. (https://elementary.io)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#define _GNU_SOURCE

#include "pantheon-files-send-by-email.h"
#include <gio/gio.h>
#include <glib.h>
#include <gdk/gdk.h>
#include "pantheon-files-core.h"
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <gee.h>
#include <glib-object.h>
#include <gio/gunixfdlist.h>
#include <fcntl.h>
#include <sys/types.h>
#include <gdk/gdkx.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
#include <X11/Xutil.h>
#include <X11/Xregion.h>
#include <gdk/gdkwayland.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 _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

#define PORTAL_TYPE_EMAIL (portal_email_get_type ())
#define PORTAL_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PORTAL_TYPE_EMAIL, PortalEmail))
#define PORTAL_IS_EMAIL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PORTAL_TYPE_EMAIL))
#define PORTAL_EMAIL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), PORTAL_TYPE_EMAIL, PortalEmailIface))

typedef struct _PortalEmail PortalEmail;
typedef struct _PortalEmailIface PortalEmailIface;

#define PORTAL_TYPE_EMAIL_PROXY (portal_email_proxy_get_type ())
typedef struct _Block1Data Block1Data;
#define _files_plugins_base_unref0(var) ((var == NULL) ? NULL : (var = (files_plugins_base_unref (var), NULL)))
#define _g_variant_type_free0(var) ((var == NULL) ? NULL : (var = (g_variant_type_free (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_variant_builder_unref0(var) ((var == NULL) ? NULL : (var = (g_variant_builder_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _Block2Data Block2Data;
typedef struct _Block3Data Block3Data;
typedef struct _FilesPluginsSendByEmailWindowExportData FilesPluginsSendByEmailWindowExportData;

struct _FilesPluginsSendByEmailPrivate {
	GFile** files;
	gint files_length1;
	gint _files_size_;
	GdkWindow* parent;
};

struct _PortalEmailIface {
	GTypeInterface parent_iface;
	guint (*get_version) (PortalEmail* self);
};

struct _Block1Data {
	int _ref_count_;
	FilesPluginsSendByEmail* self;
	PortalEmail* portal;
};

struct _Block2Data {
	int _ref_count_;
	FilesPluginsSendByEmail* self;
	gpointer _async_data_;
};

struct _Block3Data {
	int _ref_count_;
	Block2Data * _data2_;
	gchar* handle;
};

struct _FilesPluginsSendByEmailWindowExportData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FilesPluginsSendByEmail* self;
	gchar* result;
	Block2Data* _data2_;
	GdkWindow* _tmp0_;
	Window xid;
	GdkWindow* _tmp1_;
	gchar* _tmp2_;
	GdkWindow* _tmp3_;
	Block3Data* _data3_;
	gchar* _tmp4_;
	GdkWindow* _tmp5_;
	const gchar* _tmp6_;
	const gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
};

static gint FilesPluginsSendByEmail_private_offset;
static gpointer files_plugins_send_by_email_parent_class = NULL;

static void files_plugins_send_by_email_real_context_menu (FilesPluginsBase* base,
                                                    GtkWidget* widget,
                                                    GList* gof_files);
static GFile** files_plugins_send_by_email_get_file_array (GList* files,
                                                    gint* result_length1);
static void files_plugins_send_by_email_action_email (FilesPluginsSendByEmail* self);
static void _files_plugins_send_by_email_action_email_g_simple_action_activate (GSimpleAction* _sender,
                                                                         GVariant* parameter,
                                                                         gpointer self);
static void _vala_array_add1 (GFile** * array,
                       gint* length,
                       gint* size,
                       GFile* value);
static void _vala_array_add2 (GFile** * array,
                       gint* length,
                       gint* size,
                       GFile* value);
VALA_EXTERN GType portal_email_get_type (void) G_GNUC_CONST ;
VALA_EXTERN GType portal_email_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint portal_email_register_object (void* object,
                                    GDBusConnection* connection,
                                    const gchar* path,
                                    GError** error);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
VALA_EXTERN PortalEmail* portal_email_get (GError** error);
static void files_plugins_send_by_email_window_export (FilesPluginsSendByEmail* self,
                                                GAsyncReadyCallback _callback_,
                                                gpointer _user_data_);
static gchar* files_plugins_send_by_email_window_export_finish (FilesPluginsSendByEmail* self,
                                                         GAsyncResult* _res_);
static void ___lambda6_ (Block1Data* _data1_,
                  GObject* obj,
                  GAsyncResult* res);
static void _g_free0_ (gpointer var);
static void _g_variant_unref0_ (gpointer var);
static GVariant* _variant_new1 (gchar* value);
VALA_EXTERN guint portal_email_get_version (PortalEmail* self);
VALA_EXTERN char* portal_email_compose_email (PortalEmail* self,
                                  const gchar* window_handle,
                                  GHashTable* options,
                                  GUnixFDList* attachments,
                                  GError** error);
static void ____lambda6__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static void files_plugins_send_by_email_window_export_data_free (gpointer _data);
static gboolean files_plugins_send_by_email_window_export_co (FilesPluginsSendByEmailWindowExportData* _data_);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void ____lambda5_ (Block3Data* _data3_,
                   GdkWindow* w,
                   const gchar* h);
static void _____lambda5__gdk_wayland_window_exported (GdkWindow* window,
                                                const gchar* handle,
                                                gpointer self);
static void files_plugins_send_by_email_finalize (FilesPluginsBase * obj);
static GType files_plugins_send_by_email_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
files_plugins_send_by_email_get_instance_private (FilesPluginsSendByEmail* self)
{
	return G_STRUCT_MEMBER_P (self, FilesPluginsSendByEmail_private_offset);
}

static void
_files_plugins_send_by_email_action_email_g_simple_action_activate (GSimpleAction* _sender,
                                                                    GVariant* parameter,
                                                                    gpointer self)
{
	files_plugins_send_by_email_action_email ((FilesPluginsSendByEmail*) self);
}

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

static void
files_plugins_send_by_email_real_context_menu (FilesPluginsBase* base,
                                               GtkWidget* widget,
                                               GList* gof_files)
{
	FilesPluginsSendByEmail * self;
	gboolean _tmp0_ = FALSE;
	gint _tmp1_ = 0;
	GFile** _tmp2_;
	gboolean _tmp3_ = FALSE;
	GFile** _tmp4_;
	gint _tmp4__length1;
	GSimpleAction* email_action = NULL;
	GSimpleAction* _tmp6_;
	GSimpleAction* _tmp7_;
	GSimpleActionGroup* action_group = NULL;
	GSimpleActionGroup* _tmp8_;
	GSimpleActionGroup* _tmp9_;
	GSimpleAction* _tmp10_;
	GtkSeparatorMenuItem* separator = NULL;
	GtkSeparatorMenuItem* _tmp11_;
	GtkMenuItem* send_by_email_menuitem = NULL;
	gchar* _tmp12_;
	GtkMenuItem* _tmp13_ = NULL;
	GtkMenu* menu = NULL;
	GtkMenu* _tmp14_;
	GtkMenu* _tmp15_;
	GtkSeparatorMenuItem* _tmp16_;
	GtkMenu* _tmp17_;
	GtkMenuItem* _tmp18_;
	GtkMenu* _tmp19_;
	GSimpleActionGroup* _tmp20_;
	FilesPluginManager* _tmp21_;
	GeeList* _tmp22_;
	GeeList* _tmp23_;
	GtkSeparatorMenuItem* _tmp24_;
	FilesPluginManager* _tmp25_;
	GeeList* _tmp26_;
	GeeList* _tmp27_;
	GtkMenuItem* _tmp28_;
	GtkMenu* _tmp29_;
	GtkWidget* _tmp30_;
	GdkWindow* _tmp31_;
	GdkWindow* _tmp32_;
	self = (FilesPluginsSendByEmail*) base;
	g_return_if_fail (widget != NULL);
	if (gof_files == NULL) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_list_length (gof_files) == ((guint) 0);
	}
	if (_tmp0_) {
		return;
	}
	_tmp2_ = files_plugins_send_by_email_get_file_array (gof_files, &_tmp1_);
	self->priv->files = (_vala_array_free (self->priv->files, self->priv->files_length1, (GDestroyNotify) g_object_unref), NULL);
	self->priv->files = _tmp2_;
	self->priv->files_length1 = _tmp1_;
	self->priv->_files_size_ = self->priv->files_length1;
	_tmp4_ = self->priv->files;
	_tmp4__length1 = self->priv->files_length1;
	if (_tmp4_ == NULL) {
		_tmp3_ = TRUE;
	} else {
		GFile** _tmp5_;
		gint _tmp5__length1;
		_tmp5_ = self->priv->files;
		_tmp5__length1 = self->priv->files_length1;
		_tmp3_ = _tmp5__length1 <= 0;
	}
	if (_tmp3_) {
		return;
	}
	_tmp6_ = g_simple_action_new ("send", NULL);
	email_action = _tmp6_;
	_tmp7_ = email_action;
	g_signal_connect (_tmp7_, "activate", (GCallback) _files_plugins_send_by_email_action_email_g_simple_action_activate, self);
	_tmp8_ = g_simple_action_group_new ();
	action_group = _tmp8_;
	_tmp9_ = action_group;
	_tmp10_ = email_action;
	g_action_map_add_action ((GActionMap*) _tmp9_, (GAction*) _tmp10_);
	_tmp11_ = (GtkSeparatorMenuItem*) gtk_separator_menu_item_new ();
	g_object_ref_sink (_tmp11_);
	separator = _tmp11_;
	_tmp12_ = g_strdup ("email.send");
	_tmp13_ = (GtkMenuItem*) gtk_menu_item_new_with_label (_ ("Send by Email"));
	gtk_actionable_set_action_name ((GtkActionable*) _tmp13_, _tmp12_);
	_g_free0 (_tmp12_);
	g_object_ref_sink (_tmp13_);
	send_by_email_menuitem = _tmp13_;
	_tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (widget, gtk_menu_get_type (), GtkMenu));
	menu = _tmp14_;
	_tmp15_ = menu;
	_tmp16_ = separator;
	gtk_menu_shell_append ((GtkMenuShell*) _tmp15_, (GtkMenuItem*) _tmp16_);
	_tmp17_ = menu;
	_tmp18_ = send_by_email_menuitem;
	gtk_menu_shell_append ((GtkMenuShell*) _tmp17_, _tmp18_);
	_tmp19_ = menu;
	_tmp20_ = action_group;
	gtk_widget_insert_action_group ((GtkWidget*) _tmp19_, "email", (GActionGroup*) _tmp20_);
	_tmp21_ = plugins;
	_tmp22_ = files_plugin_manager_get_menuitem_references (_tmp21_);
	_tmp23_ = _tmp22_;
	_tmp24_ = separator;
	gee_collection_add ((GeeCollection*) _tmp23_, (GtkWidget*) _tmp24_);
	_tmp25_ = plugins;
	_tmp26_ = files_plugin_manager_get_menuitem_references (_tmp25_);
	_tmp27_ = _tmp26_;
	_tmp28_ = send_by_email_menuitem;
	gee_collection_add ((GeeCollection*) _tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = menu;
	_tmp30_ = gtk_widget_get_toplevel ((GtkWidget*) _tmp29_);
	_tmp31_ = gtk_widget_get_window (_tmp30_);
	_tmp32_ = _g_object_ref0 (_tmp31_);
	_g_object_unref0 (self->priv->parent);
	self->priv->parent = _tmp32_;
	_g_object_unref0 (menu);
	_g_object_unref0 (send_by_email_menuitem);
	_g_object_unref0 (separator);
	_g_object_unref0 (action_group);
	_g_object_unref0 (email_action);
}

static void
_vala_array_add1 (GFile** * array,
                  gint* length,
                  gint* size,
                  GFile* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GFile*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static void
_vala_array_add2 (GFile** * array,
                  gint* length,
                  gint* size,
                  GFile* value)
{
	if ((*length) == (*size)) {
		*size = (*size) ? (2 * (*size)) : 4;
		*array = g_renew (GFile*, *array, (*size) + 1);
	}
	(*array)[(*length)++] = value;
	(*array)[*length] = NULL;
}

static GFile**
files_plugins_send_by_email_get_file_array (GList* files,
                                            gint* result_length1)
{
	GFile** file_array = NULL;
	GFile** _tmp0_;
	gint file_array_length1;
	gint _file_array_size_;
	GFile** _tmp22_;
	gint _tmp22__length1;
	GFile** result;
	_tmp0_ = g_new0 (GFile*, 0 + 1);
	file_array = _tmp0_;
	file_array_length1 = 0;
	_file_array_size_ = file_array_length1;
	{
		GList* file_collection = NULL;
		GList* file_it = NULL;
		file_collection = files;
		for (file_it = file_collection; file_it != NULL; file_it = file_it->next) {
			FilesFile* file = NULL;
			file = (FilesFile*) file_it->data;
			{
				gboolean _tmp1_ = FALSE;
				gboolean _tmp2_ = FALSE;
				FilesFile* _tmp3_;
				GFile* _tmp4_;
				GFile* _tmp5_;
				_tmp3_ = file;
				_tmp4_ = files_file_get_location (_tmp3_);
				_tmp5_ = _tmp4_;
				if (_tmp5_ != NULL) {
					FilesFile* _tmp6_;
					_tmp6_ = file;
					_tmp2_ = !_tmp6_->is_directory;
				} else {
					_tmp2_ = FALSE;
				}
				if (_tmp2_) {
					FilesFile* _tmp7_;
					_tmp7_ = file;
					_tmp1_ = files_file_is_readable (_tmp7_);
				} else {
					_tmp1_ = FALSE;
				}
				if (_tmp1_) {
					FilesFile* _tmp8_;
					GFile* _tmp9_;
					GFile* _tmp10_;
					gchar* _tmp11_;
					gchar* _tmp12_;
					gboolean _tmp13_;
					_tmp8_ = file;
					_tmp9_ = files_file_get_location (_tmp8_);
					_tmp10_ = _tmp9_;
					_tmp11_ = g_file_get_uri_scheme (_tmp10_);
					_tmp12_ = _tmp11_;
					_tmp13_ = g_strcmp0 (_tmp12_, "recent") == 0;
					_g_free0 (_tmp12_);
					if (_tmp13_) {
						FilesFile* _tmp14_;
						gchar* _tmp15_;
						gchar* _tmp16_;
						GFile* _tmp17_;
						_tmp14_ = file;
						_tmp15_ = files_file_get_display_target_uri (_tmp14_);
						_tmp16_ = _tmp15_;
						_tmp17_ = g_file_new_for_uri (_tmp16_);
						_vala_array_add1 (&file_array, &file_array_length1, &_file_array_size_, _tmp17_);
						_g_free0 (_tmp16_);
					} else {
						FilesFile* _tmp18_;
						GFile* _tmp19_;
						GFile* _tmp20_;
						GFile* _tmp21_;
						_tmp18_ = file;
						_tmp19_ = files_file_get_location (_tmp18_);
						_tmp20_ = _tmp19_;
						_tmp21_ = _g_object_ref0 (_tmp20_);
						_vala_array_add2 (&file_array, &file_array_length1, &_file_array_size_, _tmp21_);
					}
				}
			}
		}
	}
	_tmp22_ = file_array;
	_tmp22__length1 = file_array_length1;
	if (result_length1) {
		*result_length1 = _tmp22__length1;
	}
	result = _tmp22_;
	return result;
}

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_)) {
		FilesPluginsSendByEmail* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->portal);
		_files_plugins_base_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_g_variant_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_variant_unref (var), NULL));
}

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

static void
___lambda6_ (Block1Data* _data1_,
             GObject* obj,
             GAsyncResult* res)
{
	FilesPluginsSendByEmail* self;
	GHashTable* options = NULL;
	GHashFunc _tmp0_;
	GEqualFunc _tmp1_;
	GHashTable* _tmp2_;
	GHashTable* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	GVariant* _tmp7_;
	GVariantBuilder* files_builder = NULL;
	GVariantType* _tmp8_;
	GVariantType* _tmp9_;
	GVariantBuilder* _tmp10_;
	GVariantBuilder* _tmp11_;
	GUnixFDList* file_descriptors = NULL;
	GUnixFDList* _tmp12_;
	GFile** _tmp13_;
	gint _tmp13__length1;
	GHashTable* _tmp27_;
	gchar* _tmp28_;
	GVariantBuilder* _tmp29_;
	GVariant* _tmp30_;
	guint _tmp31_;
	guint _tmp32_;
	GError* _inner_error0_ = NULL;
	self = _data1_->self;
	g_return_if_fail (res != NULL);
	_tmp0_ = g_str_hash;
	_tmp1_ = g_str_equal;
	_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_variant_unref0_);
	options = _tmp2_;
	_tmp3_ = options;
	_tmp4_ = g_strdup ("handle_token");
	_tmp5_ = portal_generate_token ();
	_tmp6_ = _tmp5_;
	_tmp7_ = _variant_new1 (_tmp6_);
	g_hash_table_insert (_tmp3_, _tmp4_, _tmp7_);
	_g_free0 (_tmp6_);
	_tmp8_ = g_variant_type_new ("ah");
	_tmp9_ = _tmp8_;
	_tmp10_ = g_variant_builder_new (_tmp9_);
	_tmp11_ = _tmp10_;
	_g_variant_type_free0 (_tmp9_);
	files_builder = _tmp11_;
	_tmp12_ = g_unix_fd_list_new ();
	file_descriptors = _tmp12_;
	_tmp13_ = self->priv->files;
	_tmp13__length1 = self->priv->files_length1;
	{
		GFile** file_collection = NULL;
		gint file_collection_length1 = 0;
		gint _file_collection_size_ = 0;
		gint file_it = 0;
		file_collection = _tmp13_;
		file_collection_length1 = _tmp13__length1;
		for (file_it = 0; file_it < file_collection_length1; file_it = file_it + 1) {
			GFile* _tmp14_;
			GFile* file = NULL;
			_tmp14_ = _g_object_ref0 (file_collection[file_it]);
			file = _tmp14_;
			{
				gint fd = 0;
				GFile* _tmp15_;
				gchar* _tmp16_;
				gchar* _tmp17_;
				gint _tmp18_;
				_tmp15_ = file;
				_tmp16_ = g_file_get_path (_tmp15_);
				_tmp17_ = _tmp16_;
				_tmp18_ = open (_tmp17_, O_RDONLY | O_CLOEXEC, (mode_t) 0);
				_g_free0 (_tmp17_);
				fd = _tmp18_;
				if (fd == -1) {
					GFile* _tmp19_;
					gchar* _tmp20_;
					gchar* _tmp21_;
					_tmp19_ = file;
					_tmp20_ = g_file_get_path (_tmp19_);
					_tmp21_ = _tmp20_;
					g_warning ("plugin.vala:86: send-by-mail: cannot open file: '%s'", _tmp21_);
					_g_free0 (_tmp21_);
					_g_object_unref0 (file);
					continue;
				}
				{
					gint _tmp22_ = 0;
					GUnixFDList* _tmp23_;
					GVariantBuilder* _tmp24_;
					_tmp23_ = file_descriptors;
					_tmp22_ = g_unix_fd_list_append (_tmp23_, fd, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					_tmp24_ = files_builder;
					g_variant_builder_add (_tmp24_, "h", _tmp22_, NULL);
				}
				goto __finally0;
				__catch0_g_error:
				{
					GError* e = NULL;
					GError* _tmp25_;
					const gchar* _tmp26_;
					e = _inner_error0_;
					_inner_error0_ = NULL;
					_tmp25_ = e;
					_tmp26_ = _tmp25_->message;
					g_warning ("plugin.vala:93: send-by-mail: cannot append file descriptor: %s", _tmp26_);
					_g_error_free0 (e);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (file);
					_g_object_unref0 (file_descriptors);
					_g_variant_builder_unref0 (files_builder);
					_g_hash_table_unref0 (options);
					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 (file);
			}
		}
	}
	_tmp27_ = options;
	_tmp28_ = g_strdup ("attachment_fds");
	_tmp29_ = files_builder;
	_tmp30_ = g_variant_builder_end (_tmp29_);
	g_variant_ref_sink (_tmp30_);
	g_hash_table_insert (_tmp27_, _tmp28_, _tmp30_);
	_tmp31_ = portal_email_get_version (_data1_->portal);
	_tmp32_ = _tmp31_;
	if (_tmp32_ > ((guint) 2)) {
		GHashTable* _tmp33_;
		gchar* _tmp34_;
		GVariant* _tmp35_;
		_tmp33_ = options;
		_tmp34_ = g_strdup ("addresses");
		_tmp35_ = g_variant_new ("as", NULL, NULL);
		g_variant_ref_sink (_tmp35_);
		g_hash_table_insert (_tmp33_, _tmp34_, _tmp35_);
	}
	{
		gchar* handle = NULL;
		gchar* _tmp36_;
		GHashTable* _tmp37_;
		GUnixFDList* _tmp38_;
		char* _tmp39_;
		char* _tmp40_;
		_tmp36_ = files_plugins_send_by_email_window_export_finish (self, res);
		handle = _tmp36_;
		_tmp37_ = options;
		_tmp38_ = file_descriptors;
		_tmp39_ = portal_email_compose_email (_data1_->portal, handle, _tmp37_, _tmp38_, &_inner_error0_);
		_tmp40_ = _tmp39_;
		_g_free0 (_tmp40_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (handle);
			goto __catch1_g_error;
		}
		_g_free0 (handle);
	}
	goto __finally1;
	__catch1_g_error:
	{
		GError* e = NULL;
		GError* _tmp41_;
		const gchar* _tmp42_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp41_ = e;
		_tmp42_ = _tmp41_->message;
		g_warning ("plugin.vala:114: %s", _tmp42_);
		_g_error_free0 (e);
	}
	__finally1:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (file_descriptors);
		_g_variant_builder_unref0 (files_builder);
		_g_hash_table_unref0 (options);
		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 (file_descriptors);
	_g_variant_builder_unref0 (files_builder);
	_g_hash_table_unref0 (options);
}

static void
____lambda6__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	___lambda6_ (self, source_object, res);
	block1_data_unref (self);
}

static void
files_plugins_send_by_email_action_email (FilesPluginsSendByEmail* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		Block1Data* _data1_;
		PortalEmail* _tmp0_;
		_data1_ = g_slice_new0 (Block1Data);
		_data1_->_ref_count_ = 1;
		_data1_->self = files_plugins_base_ref (self);
		_tmp0_ = portal_email_get (&_inner_error0_);
		_data1_->portal = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			block1_data_unref (_data1_);
			_data1_ = NULL;
			goto __catch0_g_error;
		}
		files_plugins_send_by_email_window_export (self, ____lambda6__gasync_ready_callback, block1_data_ref (_data1_));
		block1_data_unref (_data1_);
		_data1_ = NULL;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp1_;
		const gchar* _tmp2_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp1_ = e;
		_tmp2_ = _tmp1_->message;
		g_warning ("plugin.vala:118: %s", _tmp2_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
}

static void
files_plugins_send_by_email_window_export_data_free (gpointer _data)
{
	FilesPluginsSendByEmailWindowExportData* _data_;
	_data_ = _data;
	_g_free0 (_data_->result);
	_files_plugins_base_unref0 (_data_->self);
	g_slice_free (FilesPluginsSendByEmailWindowExportData, _data_);
}

static gpointer
_files_plugins_base_ref0 (gpointer self)
{
	return self ? files_plugins_base_ref (self) : NULL;
}

static void
files_plugins_send_by_email_window_export (FilesPluginsSendByEmail* self,
                                           GAsyncReadyCallback _callback_,
                                           gpointer _user_data_)
{
	FilesPluginsSendByEmailWindowExportData* _data_;
	FilesPluginsSendByEmail* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (FilesPluginsSendByEmailWindowExportData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, files_plugins_send_by_email_window_export_data_free);
	_tmp0_ = _files_plugins_base_ref0 (self);
	_data_->self = _tmp0_;
	files_plugins_send_by_email_window_export_co (_data_);
}

static gchar*
files_plugins_send_by_email_window_export_finish (FilesPluginsSendByEmail* self,
                                                  GAsyncResult* _res_)
{
	gchar* result;
	FilesPluginsSendByEmailWindowExportData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

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_)) {
		FilesPluginsSendByEmail* self;
		self = _data2_->self;
		_files_plugins_base_unref0 (self);
		g_slice_free (Block2Data, _data2_);
	}
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		FilesPluginsSendByEmail* self;
		self = _data3_->_data2_->self;
		_g_free0 (_data3_->handle);
		block2_data_unref (_data3_->_data2_);
		_data3_->_data2_ = NULL;
		g_slice_free (Block3Data, _data3_);
	}
}

static void
____lambda5_ (Block3Data* _data3_,
              GdkWindow* w,
              const gchar* h)
{
	Block2Data* _data2_;
	FilesPluginsSendByEmail* self;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	_data2_ = _data3_->_data2_;
	self = _data2_->self;
	g_return_if_fail (w != NULL);
	g_return_if_fail (h != NULL);
	_tmp0_ = _data3_->handle;
	_tmp1_ = g_strconcat (_tmp0_, h, NULL);
	_g_free0 (_data3_->handle);
	_data3_->handle = _tmp1_;
	files_plugins_send_by_email_window_export_co (_data2_->_async_data_);
}

static void
_____lambda5__gdk_wayland_window_exported (GdkWindow* window,
                                           const gchar* handle,
                                           gpointer self)
{
	____lambda5_ (self, window, handle);
}

static gboolean
files_plugins_send_by_email_window_export_co (FilesPluginsSendByEmailWindowExportData* _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 = files_plugins_base_ref (_data_->self);
	_data_->_data2_->_async_data_ = _data_;
	_data_->_tmp0_ = _data_->self->priv->parent;
	if (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp0_, gdk_x11_window_get_type ())) {
		_data_->_tmp1_ = _data_->self->priv->parent;
		_data_->xid = gdk_x11_window_get_xid (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp1_, gdk_x11_window_get_type (), GdkX11Window));
		_data_->_tmp2_ = g_strdup_printf ("x11:%x", (guint) _data_->xid);
		_data_->result = _data_->_tmp2_;
		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;
	} else {
		_data_->_tmp3_ = _data_->self->priv->parent;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_data_->_tmp3_, GDK_TYPE_WAYLAND_WINDOW)) {
			_data_->_data3_ = g_slice_new0 (Block3Data);
			_data_->_data3_->_ref_count_ = 1;
			_data_->_data3_->_data2_ = block2_data_ref (_data_->_data2_);
			_data_->_tmp4_ = g_strdup ("wayland:");
			_data_->_data3_->handle = _data_->_tmp4_;
			_data_->_tmp5_ = _data_->self->priv->parent;
			gdk_wayland_window_export_handle (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, GDK_TYPE_WAYLAND_WINDOW, GdkWaylandWindow), _____lambda5__gdk_wayland_window_exported, block3_data_ref (_data_->_data3_), block3_data_unref);
			_data_->_state_ = 1;
			return FALSE;
			_state_1:
			;
			_data_->_tmp6_ = _data_->_data3_->handle;
			if (g_strcmp0 (_data_->_tmp6_, "wayland:") != 0) {
				_data_->_tmp7_ = _data_->_data3_->handle;
				_data_->_tmp8_ = g_strdup (_data_->_tmp7_);
				_data_->result = _data_->_tmp8_;
				block3_data_unref (_data_->_data3_);
				_data_->_data3_ = NULL;
				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;
			}
			_data_->_tmp9_ = g_strdup ("");
			_data_->result = _data_->_tmp9_;
			block3_data_unref (_data_->_data3_);
			_data_->_data3_ = NULL;
			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;
		} else {
			g_warning ("plugin.vala:141: Unknown windowing system, not exporting window");
			_data_->_tmp10_ = g_strdup ("");
			_data_->result = _data_->_tmp10_;
			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;
		}
	}
}

FilesPluginsSendByEmail*
files_plugins_send_by_email_construct (GType object_type)
{
	FilesPluginsSendByEmail* self = NULL;
	self = (FilesPluginsSendByEmail*) files_plugins_base_construct (object_type);
	return self;
}

FilesPluginsSendByEmail*
files_plugins_send_by_email_new (void)
{
	return files_plugins_send_by_email_construct (FILES_PLUGINS_TYPE_SEND_BY_EMAIL);
}

static void
files_plugins_send_by_email_class_init (FilesPluginsSendByEmailClass * klass,
                                        gpointer klass_data)
{
	files_plugins_send_by_email_parent_class = g_type_class_peek_parent (klass);
	((FilesPluginsBaseClass *) klass)->finalize = files_plugins_send_by_email_finalize;
	g_type_class_adjust_private_offset (klass, &FilesPluginsSendByEmail_private_offset);
	((FilesPluginsBaseClass *) klass)->context_menu = (void (*) (FilesPluginsBase*, GtkWidget*, GList*)) files_plugins_send_by_email_real_context_menu;
}

static void
files_plugins_send_by_email_instance_init (FilesPluginsSendByEmail * self,
                                           gpointer klass)
{
	self->priv = files_plugins_send_by_email_get_instance_private (self);
}

static void
files_plugins_send_by_email_finalize (FilesPluginsBase * obj)
{
	FilesPluginsSendByEmail * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, FILES_PLUGINS_TYPE_SEND_BY_EMAIL, FilesPluginsSendByEmail);
	self->priv->files = (_vala_array_free (self->priv->files, self->priv->files_length1, (GDestroyNotify) g_object_unref), NULL);
	_g_object_unref0 (self->priv->parent);
	FILES_PLUGINS_BASE_CLASS (files_plugins_send_by_email_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
files_plugins_send_by_email_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (FilesPluginsSendByEmailClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) files_plugins_send_by_email_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FilesPluginsSendByEmail), 0, (GInstanceInitFunc) files_plugins_send_by_email_instance_init, NULL };
	GType files_plugins_send_by_email_type_id;
	files_plugins_send_by_email_type_id = g_type_register_static (FILES_PLUGINS_TYPE_BASE, "FilesPluginsSendByEmail", &g_define_type_info, 0);
	FilesPluginsSendByEmail_private_offset = g_type_add_instance_private (files_plugins_send_by_email_type_id, sizeof (FilesPluginsSendByEmailPrivate));
	return files_plugins_send_by_email_type_id;
}

GType
files_plugins_send_by_email_get_type (void)
{
	static volatile gsize files_plugins_send_by_email_type_id__once = 0;
	if (g_once_init_enter (&files_plugins_send_by_email_type_id__once)) {
		GType files_plugins_send_by_email_type_id;
		files_plugins_send_by_email_type_id = files_plugins_send_by_email_get_type_once ();
		g_once_init_leave (&files_plugins_send_by_email_type_id__once, files_plugins_send_by_email_type_id);
	}
	return files_plugins_send_by_email_type_id__once;
}

FilesPluginsBase*
module_init (void)
{
	FilesPluginsSendByEmail* _tmp0_;
	FilesPluginsBase* result;
	_tmp0_ = files_plugins_send_by_email_new ();
	result = (FilesPluginsBase*) _tmp0_;
	return result;
}

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

