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

#include "openpgp.h"
#include "libdino.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <glib-object.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

enum  {
	DINO_PLUGINS_OPEN_PGP_PGP_FILE_DECRYPTOR_0_PROPERTY,
	DINO_PLUGINS_OPEN_PGP_PGP_FILE_DECRYPTOR_NUM_PROPERTIES
};
static GParamSpec* dino_plugins_open_pgp_pgp_file_decryptor_properties[DINO_PLUGINS_OPEN_PGP_PGP_FILE_DECRYPTOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _dino_file_receive_data_unref0(var) ((var == NULL) ? NULL : (var = (dino_file_receive_data_unref (var), NULL)))
#define _g_byte_array_unref0(var) ((var == NULL) ? NULL : (var = (g_byte_array_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _gpg_helper_decrypted_data_unref0(var) ((var == NULL) ? NULL : (var = (gpg_helper_decrypted_data_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData;

struct _DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOpenPgpPgpFileDecryptor* self;
	GInputStream* encrypted_stream;
	DinoEntitiesConversation* conversation;
	DinoEntitiesFileTransfer* file_transfer;
	DinoFileReceiveData* receive_data;
	GInputStream* result;
	guint8* buf;
	guint8* _tmp0_;
	gint buf_length1;
	gint _buf_size_;
	GByteArray* data;
	GByteArray* _tmp1_;
	gsize len;
	gboolean _tmp2_;
	gssize _tmp3_;
	guint8* _tmp4_;
	gint _tmp4__length1;
	GByteArray* _tmp5_;
	guint8* _tmp6_;
	gint _tmp6__length1;
	GPGHelperDecryptedData* clear_data;
	GByteArray* _tmp7_;
	guint8* _tmp8_;
	gint _tmp8__length1;
	GPGHelperDecryptedData* _tmp9_;
	gboolean _tmp10_;
	GPGHelperDecryptedData* _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	GPGHelperDecryptedData* _tmp14_;
	const gchar* _tmp15_;
	const gchar* _tmp16_;
	GPGHelperDecryptedData* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	const gchar* _tmp20_;
	const gchar* _tmp21_;
	GPGHelperDecryptedData* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	gint _tmp31_;
	gint _tmp32_;
	gchar* _tmp33_;
	gchar* _tmp34_;
	const gchar* _tmp35_;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	const gchar* _tmp39_;
	const gchar* _tmp40_;
	gint _tmp41_;
	gint _tmp42_;
	gchar* _tmp43_;
	gchar* _tmp44_;
	GPGHelperDecryptedData* _tmp45_;
	guint8* _tmp46_;
	gint _tmp46__length1;
	gint _tmp47_;
	guint8* _tmp48_;
	gint _tmp48__length1;
	guint8* _tmp49_;
	gint _tmp49__length1;
	GMemoryInputStream* _tmp50_;
	GError* e;
	GError* _tmp51_;
	const gchar* _tmp52_;
	gchar* _tmp53_;
	gchar* _tmp54_;
	GError* _tmp55_;
	GError* _tmp56_;
	GError* _inner_error0_;
};

static gpointer dino_plugins_open_pgp_pgp_file_decryptor_parent_class = NULL;
static DinoFileDecryptorIface * dino_plugins_open_pgp_pgp_file_decryptor_dino_file_decryptor_parent_iface = NULL;

static DinoEntitiesEncryption dino_plugins_open_pgp_pgp_file_decryptor_real_get_encryption (DinoFileDecryptor* base);
static DinoFileReceiveData* dino_plugins_open_pgp_pgp_file_decryptor_real_prepare_get_meta_info (DinoFileDecryptor* base,
                                                                                          DinoEntitiesConversation* conversation,
                                                                                          DinoEntitiesFileTransfer* file_transfer,
                                                                                          DinoFileReceiveData* receive_data);
static DinoFileMeta* dino_plugins_open_pgp_pgp_file_decryptor_real_prepare_download_file (DinoFileDecryptor* base,
                                                                                   DinoEntitiesConversation* conversation,
                                                                                   DinoEntitiesFileTransfer* file_transfer,
                                                                                   DinoFileReceiveData* receive_data,
                                                                                   DinoFileMeta* file_meta);
static gboolean dino_plugins_open_pgp_pgp_file_decryptor_real_can_decrypt_file (DinoFileDecryptor* base,
                                                                         DinoEntitiesConversation* conversation,
                                                                         DinoEntitiesFileTransfer* file_transfer,
                                                                         DinoFileReceiveData* receive_data);
static void dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file_data_free (gpointer _data);
static void dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file (DinoFileDecryptor* base,
                                                                 GInputStream* encrypted_stream,
                                                                 DinoEntitiesConversation* conversation,
                                                                 DinoEntitiesFileTransfer* file_transfer,
                                                                 DinoFileReceiveData* receive_data,
                                                                 GAsyncReadyCallback _callback_,
                                                                 gpointer _user_data_);
static gboolean dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file_co (DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData* _data_);
static void dino_plugins_open_pgp_pgp_file_decryptor_decrypt_file_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static guint8* _vala_array_dup1 (guint8* self,
                          gssize length);
static void _g_free_gdestroy_notify (void* data);
static GType dino_plugins_open_pgp_pgp_file_decryptor_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static DinoEntitiesEncryption
dino_plugins_open_pgp_pgp_file_decryptor_real_get_encryption (DinoFileDecryptor* base)
{
	DinoPluginsOpenPgpPgpFileDecryptor * self;
	DinoEntitiesEncryption result;
	self = (DinoPluginsOpenPgpPgpFileDecryptor*) base;
	result = DINO_ENTITIES_ENCRYPTION_PGP;
	return result;
}

static gpointer
_dino_file_receive_data_ref0 (gpointer self)
{
	return self ? dino_file_receive_data_ref (self) : NULL;
}

static DinoFileReceiveData*
dino_plugins_open_pgp_pgp_file_decryptor_real_prepare_get_meta_info (DinoFileDecryptor* base,
                                                                     DinoEntitiesConversation* conversation,
                                                                     DinoEntitiesFileTransfer* file_transfer,
                                                                     DinoFileReceiveData* receive_data)
{
	DinoPluginsOpenPgpPgpFileDecryptor * self;
	DinoFileReceiveData* _tmp0_;
	DinoFileReceiveData* result;
	self = (DinoPluginsOpenPgpPgpFileDecryptor*) base;
	g_return_val_if_fail (conversation != NULL, NULL);
	g_return_val_if_fail (file_transfer != NULL, NULL);
	g_return_val_if_fail (receive_data != NULL, NULL);
	_tmp0_ = _dino_file_receive_data_ref0 (receive_data);
	result = _tmp0_;
	return result;
}

static gpointer
_dino_file_meta_ref0 (gpointer self)
{
	return self ? dino_file_meta_ref (self) : NULL;
}

static DinoFileMeta*
dino_plugins_open_pgp_pgp_file_decryptor_real_prepare_download_file (DinoFileDecryptor* base,
                                                                     DinoEntitiesConversation* conversation,
                                                                     DinoEntitiesFileTransfer* file_transfer,
                                                                     DinoFileReceiveData* receive_data,
                                                                     DinoFileMeta* file_meta)
{
	DinoPluginsOpenPgpPgpFileDecryptor * self;
	DinoFileMeta* _tmp0_;
	DinoFileMeta* result;
	self = (DinoPluginsOpenPgpPgpFileDecryptor*) base;
	g_return_val_if_fail (conversation != NULL, NULL);
	g_return_val_if_fail (file_transfer != NULL, NULL);
	g_return_val_if_fail (receive_data != NULL, NULL);
	g_return_val_if_fail (file_meta != NULL, NULL);
	_tmp0_ = _dino_file_meta_ref0 (file_meta);
	result = _tmp0_;
	return result;
}

static gboolean
dino_plugins_open_pgp_pgp_file_decryptor_real_can_decrypt_file (DinoFileDecryptor* base,
                                                                DinoEntitiesConversation* conversation,
                                                                DinoEntitiesFileTransfer* file_transfer,
                                                                DinoFileReceiveData* receive_data)
{
	DinoPluginsOpenPgpPgpFileDecryptor * self;
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gboolean result;
	self = (DinoPluginsOpenPgpPgpFileDecryptor*) base;
	g_return_val_if_fail (conversation != NULL, FALSE);
	g_return_val_if_fail (file_transfer != NULL, FALSE);
	g_return_val_if_fail (receive_data != NULL, FALSE);
	_tmp1_ = dino_entities_file_transfer_get_file_name (file_transfer);
	_tmp2_ = _tmp1_;
	if (g_str_has_suffix (_tmp2_, "pgp")) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp3_ = dino_entities_file_transfer_get_mime_type (file_transfer);
		_tmp4_ = _tmp3_;
		_tmp0_ = g_strcmp0 (_tmp4_, "application/pgp-encrypted") == 0;
	}
	result = _tmp0_;
	return result;
}

static void
dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file_data_free (gpointer _data)
{
	DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->encrypted_stream);
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->file_transfer);
	_dino_file_receive_data_unref0 (_data_->receive_data);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData, _data_);
}

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

static void
dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file (DinoFileDecryptor* base,
                                                            GInputStream* encrypted_stream,
                                                            DinoEntitiesConversation* conversation,
                                                            DinoEntitiesFileTransfer* file_transfer,
                                                            DinoFileReceiveData* receive_data,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_)
{
	DinoPluginsOpenPgpPgpFileDecryptor * self;
	DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData* _data_;
	DinoPluginsOpenPgpPgpFileDecryptor* _tmp0_;
	GInputStream* _tmp1_;
	DinoEntitiesConversation* _tmp2_;
	DinoEntitiesFileTransfer* _tmp3_;
	DinoFileReceiveData* _tmp4_;
	g_return_if_fail (encrypted_stream != NULL);
	g_return_if_fail (conversation != NULL);
	g_return_if_fail (file_transfer != NULL);
	g_return_if_fail (receive_data != NULL);
	self = (DinoPluginsOpenPgpPgpFileDecryptor*) base;
	_data_ = g_slice_new0 (DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (encrypted_stream);
	_g_object_unref0 (_data_->encrypted_stream);
	_data_->encrypted_stream = _tmp1_;
	_tmp2_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp2_;
	_tmp3_ = _g_object_ref0 (file_transfer);
	_g_object_unref0 (_data_->file_transfer);
	_data_->file_transfer = _tmp3_;
	_tmp4_ = _dino_file_receive_data_ref0 (receive_data);
	_dino_file_receive_data_unref0 (_data_->receive_data);
	_data_->receive_data = _tmp4_;
	dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file_co (_data_);
}

static GInputStream*
dino_plugins_open_pgp_pgp_file_decryptor_decrypt_file_finish (DinoFileDecryptor* base,
                                                              GAsyncResult* _res_,
                                                              GError** error)
{
	GInputStream* result;
	DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData* _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
dino_plugins_open_pgp_pgp_file_decryptor_decrypt_file_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file_co (_data_);
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static guint8*
_vala_array_dup1 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

static void
_g_free_gdestroy_notify (void* data)
{
	g_free (data);
}

static gboolean
dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file_co (DinoPluginsOpenPgpPgpFileDecryptorDecryptFileData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = g_new0 (guint8, 256);
		_data_->buf = _data_->_tmp0_;
		_data_->buf_length1 = 256;
		_data_->_buf_size_ = _data_->buf_length1;
		_data_->_tmp1_ = g_byte_array_new ();
		_data_->data = _data_->_tmp1_;
		_data_->len = (gsize) -1;
		{
			_data_->_tmp2_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp2_) {
					if (!(_data_->len > ((gsize) 0))) {
						break;
					}
				}
				_data_->_tmp2_ = FALSE;
				_data_->_tmp4_ = _data_->buf;
				_data_->_tmp4__length1 = _data_->buf_length1;
				_data_->_state_ = 1;
				g_input_stream_read_async (_data_->encrypted_stream, _data_->_tmp4_, (gsize) _data_->_tmp4__length1, G_PRIORITY_DEFAULT, NULL, dino_plugins_open_pgp_pgp_file_decryptor_decrypt_file_ready, _data_);
				return FALSE;
				_state_1:
				_data_->_tmp3_ = g_input_stream_read_finish (_data_->encrypted_stream, _data_->_res_, &_data_->_inner_error0_);
				if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
					_g_byte_array_unref0 (_data_->data);
					_data_->buf = (g_free (_data_->buf), NULL);
					goto __catch0_g_error;
				}
				_data_->len = (gsize) _data_->_tmp3_;
				_data_->_tmp5_ = _data_->data;
				_data_->_tmp6_ = _data_->buf;
				_data_->_tmp6__length1 = _data_->buf_length1;
				g_byte_array_append (_data_->_tmp5_, _data_->_tmp6_ + 0, (gint) (((gint) _data_->len) - 0));
			}
		}
		_data_->_tmp7_ = _data_->data;
		_data_->_tmp8_ = _data_->_tmp7_->data;
		_data_->_tmp8__length1 = _data_->_tmp7_->len;
		_data_->_tmp9_ = gpg_helper_decrypt_data (_data_->_tmp8_, (gint) _data_->_tmp8__length1, &_data_->_inner_error0_);
		_data_->clear_data = _data_->_tmp9_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_byte_array_unref0 (_data_->data);
			_data_->buf = (g_free (_data_->buf), NULL);
			goto __catch0_g_error;
		}
		dino_entities_file_transfer_set_encryption (_data_->file_transfer, DINO_ENTITIES_ENCRYPTION_PGP);
		_data_->_tmp11_ = _data_->clear_data;
		_data_->_tmp12_ = gpg_helper_decrypted_data_get_filename (_data_->_tmp11_);
		_data_->_tmp13_ = _data_->_tmp12_;
		if (_data_->_tmp13_ != NULL) {
			_data_->_tmp14_ = _data_->clear_data;
			_data_->_tmp15_ = gpg_helper_decrypted_data_get_filename (_data_->_tmp14_);
			_data_->_tmp16_ = _data_->_tmp15_;
			_data_->_tmp10_ = g_strcmp0 (_data_->_tmp16_, "") != 0;
		} else {
			_data_->_tmp10_ = FALSE;
		}
		if (_data_->_tmp10_) {
			_data_->_tmp17_ = _data_->clear_data;
			_data_->_tmp18_ = gpg_helper_decrypted_data_get_filename (_data_->_tmp17_);
			_data_->_tmp19_ = _data_->_tmp18_;
			_data_->_tmp20_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
			_data_->_tmp21_ = _data_->_tmp20_;
			g_debug ("file_decryptor.vala:36: Decrypting file %s from %s", _data_->_tmp19_, _data_->_tmp21_);
			_data_->_tmp22_ = _data_->clear_data;
			_data_->_tmp23_ = gpg_helper_decrypted_data_get_filename (_data_->_tmp22_);
			_data_->_tmp24_ = _data_->_tmp23_;
			dino_entities_file_transfer_set_file_name (_data_->file_transfer, _data_->_tmp24_);
		} else {
			_data_->_tmp25_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
			_data_->_tmp26_ = _data_->_tmp25_;
			if (g_str_has_suffix (_data_->_tmp26_, ".pgp")) {
				_data_->_tmp27_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
				_data_->_tmp28_ = _data_->_tmp27_;
				_data_->_tmp29_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
				_data_->_tmp30_ = _data_->_tmp29_;
				_data_->_tmp31_ = strlen (_data_->_tmp30_);
				_data_->_tmp32_ = _data_->_tmp31_;
				_data_->_tmp33_ = string_substring (_data_->_tmp28_, (glong) 0, (glong) (_data_->_tmp32_ - 4));
				_data_->_tmp34_ = _data_->_tmp33_;
				_data_->_tmp35_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
				_data_->_tmp36_ = _data_->_tmp35_;
				g_debug ("file_decryptor.vala:39: Decrypting file %s from %s", _data_->_tmp34_, _data_->_tmp36_);
				_g_free0 (_data_->_tmp34_);
				_data_->_tmp37_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
				_data_->_tmp38_ = _data_->_tmp37_;
				_data_->_tmp39_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
				_data_->_tmp40_ = _data_->_tmp39_;
				_data_->_tmp41_ = strlen (_data_->_tmp40_);
				_data_->_tmp42_ = _data_->_tmp41_;
				_data_->_tmp43_ = string_substring (_data_->_tmp38_, (glong) 0, (glong) (_data_->_tmp42_ - 4));
				_data_->_tmp44_ = _data_->_tmp43_;
				dino_entities_file_transfer_set_file_name (_data_->file_transfer, _data_->_tmp44_);
				_g_free0 (_data_->_tmp44_);
			}
		}
		_data_->_tmp45_ = _data_->clear_data;
		_data_->_tmp47_ = 0;
		_data_->_tmp46_ = gpg_helper_decrypted_data_get_data (_data_->_tmp45_, &_data_->_tmp47_);
		_data_->_tmp46__length1 = _data_->_tmp47_;
		_data_->_tmp48_ = _data_->_tmp46_;
		_data_->_tmp48__length1 = _data_->_tmp46__length1;
		_data_->_tmp49_ = (_data_->_tmp48_ != NULL) ? _vala_array_dup1 (_data_->_tmp48_, _data_->_tmp48__length1) : _data_->_tmp48_;
		_data_->_tmp49__length1 = _data_->_tmp48__length1;
		_data_->_tmp50_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_data_->_tmp49_, _data_->_tmp49__length1, _g_free_gdestroy_notify);
		_data_->result = (GInputStream*) _data_->_tmp50_;
		_gpg_helper_decrypted_data_unref0 (_data_->clear_data);
		_g_byte_array_unref0 (_data_->data);
		_data_->buf = (g_free (_data_->buf), 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;
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp51_ = _data_->e;
		_data_->_tmp52_ = _data_->_tmp51_->message;
		_data_->_tmp53_ = g_strdup_printf ("PGP file decryption error: %s", _data_->_tmp52_);
		_data_->_tmp54_ = _data_->_tmp53_;
		_data_->_tmp55_ = g_error_new_literal (DINO_FILE_RECEIVE_ERROR, DINO_FILE_RECEIVE_ERROR_DECRYPTION_FAILED, _data_->_tmp54_);
		_data_->_tmp56_ = _data_->_tmp55_;
		_g_free0 (_data_->_tmp54_);
		_data_->_inner_error0_ = _data_->_tmp56_;
		_g_error_free0 (_data_->e);
		goto __finally0;
	}
	__finally0:
	if (_data_->_inner_error0_->domain == DINO_FILE_RECEIVE_ERROR) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	} else {
		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;
	}
}

DinoPluginsOpenPgpPgpFileDecryptor*
dino_plugins_open_pgp_pgp_file_decryptor_construct (GType object_type)
{
	DinoPluginsOpenPgpPgpFileDecryptor * self = NULL;
	self = (DinoPluginsOpenPgpPgpFileDecryptor*) g_object_new (object_type, NULL);
	return self;
}

DinoPluginsOpenPgpPgpFileDecryptor*
dino_plugins_open_pgp_pgp_file_decryptor_new (void)
{
	return dino_plugins_open_pgp_pgp_file_decryptor_construct (DINO_PLUGINS_OPEN_PGP_TYPE_PGP_FILE_DECRYPTOR);
}

static void
dino_plugins_open_pgp_pgp_file_decryptor_class_init (DinoPluginsOpenPgpPgpFileDecryptorClass * klass,
                                                     gpointer klass_data)
{
	dino_plugins_open_pgp_pgp_file_decryptor_parent_class = g_type_class_peek_parent (klass);
}

static void
dino_plugins_open_pgp_pgp_file_decryptor_dino_file_decryptor_interface_init (DinoFileDecryptorIface * iface,
                                                                             gpointer iface_data)
{
	dino_plugins_open_pgp_pgp_file_decryptor_dino_file_decryptor_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_encryption = (DinoEntitiesEncryption (*) (DinoFileDecryptor*)) dino_plugins_open_pgp_pgp_file_decryptor_real_get_encryption;
	iface->prepare_get_meta_info = (DinoFileReceiveData* (*) (DinoFileDecryptor*, DinoEntitiesConversation*, DinoEntitiesFileTransfer*, DinoFileReceiveData*)) dino_plugins_open_pgp_pgp_file_decryptor_real_prepare_get_meta_info;
	iface->prepare_download_file = (DinoFileMeta* (*) (DinoFileDecryptor*, DinoEntitiesConversation*, DinoEntitiesFileTransfer*, DinoFileReceiveData*, DinoFileMeta*)) dino_plugins_open_pgp_pgp_file_decryptor_real_prepare_download_file;
	iface->can_decrypt_file = (gboolean (*) (DinoFileDecryptor*, DinoEntitiesConversation*, DinoEntitiesFileTransfer*, DinoFileReceiveData*)) dino_plugins_open_pgp_pgp_file_decryptor_real_can_decrypt_file;
	iface->decrypt_file = (void (*) (DinoFileDecryptor*, GInputStream*, DinoEntitiesConversation*, DinoEntitiesFileTransfer*, DinoFileReceiveData*, GAsyncReadyCallback, gpointer)) dino_plugins_open_pgp_pgp_file_decryptor_real_decrypt_file;
	iface->decrypt_file_finish = (GInputStream* (*) (DinoFileDecryptor*, GAsyncResult*, GError**)) dino_plugins_open_pgp_pgp_file_decryptor_decrypt_file_finish;
}

static void
dino_plugins_open_pgp_pgp_file_decryptor_instance_init (DinoPluginsOpenPgpPgpFileDecryptor * self,
                                                        gpointer klass)
{
}

static GType
dino_plugins_open_pgp_pgp_file_decryptor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOpenPgpPgpFileDecryptorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_open_pgp_pgp_file_decryptor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOpenPgpPgpFileDecryptor), 0, (GInstanceInitFunc) dino_plugins_open_pgp_pgp_file_decryptor_instance_init, NULL };
	static const GInterfaceInfo dino_file_decryptor_info = { (GInterfaceInitFunc) dino_plugins_open_pgp_pgp_file_decryptor_dino_file_decryptor_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_plugins_open_pgp_pgp_file_decryptor_type_id;
	dino_plugins_open_pgp_pgp_file_decryptor_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoPluginsOpenPgpPgpFileDecryptor", &g_define_type_info, 0);
	g_type_add_interface_static (dino_plugins_open_pgp_pgp_file_decryptor_type_id, DINO_TYPE_FILE_DECRYPTOR, &dino_file_decryptor_info);
	return dino_plugins_open_pgp_pgp_file_decryptor_type_id;
}

GType
dino_plugins_open_pgp_pgp_file_decryptor_get_type (void)
{
	static volatile gsize dino_plugins_open_pgp_pgp_file_decryptor_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_open_pgp_pgp_file_decryptor_type_id__once)) {
		GType dino_plugins_open_pgp_pgp_file_decryptor_type_id;
		dino_plugins_open_pgp_pgp_file_decryptor_type_id = dino_plugins_open_pgp_pgp_file_decryptor_get_type_once ();
		g_once_init_leave (&dino_plugins_open_pgp_pgp_file_decryptor_type_id__once, dino_plugins_open_pgp_pgp_file_decryptor_type_id);
	}
	return dino_plugins_open_pgp_pgp_file_decryptor_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

