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

#include "openpgp.h"
#include "libdino.h"
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <gtk/gtk.h>
#include "dino_i18n.h"
#include <adwaita.h>
#include <gio/gio.h>
#include <gee.h>
#include <gpgme.h>
#include <gpgme_fix.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_PREFERENCES_ENTRY_0_PROPERTY,
	DINO_PLUGINS_OPEN_PGP_PGP_PREFERENCES_ENTRY_ID_PROPERTY,
	DINO_PLUGINS_OPEN_PGP_PGP_PREFERENCES_ENTRY_NUM_PROPERTIES
};
static GParamSpec* dino_plugins_open_pgp_pgp_preferences_entry_properties[DINO_PLUGINS_OPEN_PGP_PGP_PREFERENCES_ENTRY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _Block1Data Block1Data;
#define _gpgme_key_unref_vapi0(var) ((var == NULL) ? NULL : (var = (gpgme_key_unref_vapi (var), NULL)))
typedef struct _DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData;
typedef struct _Block2Data Block2Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_thread_unref0(var) ((var == NULL) ? NULL : (var = (g_thread_unref (var), NULL)))
typedef struct _DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData;

struct _DinoPluginsOpenPgpPgpPreferencesEntryPrivate {
	DinoPluginsOpenPgpPlugin* plugin;
};

struct _Block1Data {
	int _ref_count_;
	DinoPluginsOpenPgpPgpPreferencesEntry* self;
	GeeList* keys;
	AdwComboRow* drop_down;
	DinoEntitiesAccount* account;
	gpointer _async_data_;
};

struct _DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOpenPgpPgpPreferencesEntry* self;
	DinoEntitiesAccount* account;
	AdwPreferencesGroup* preferences_group;
	Block1Data* _data1_;
	GeeList* _tmp0_;
	GeeList* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	gchar* _tmp5_;
	AdwActionRow* _tmp6_;
	AdwActionRow* _tmp7_;
	GeeList* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	const gchar* _tmp11_;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	AdwActionRow* _tmp15_;
	AdwActionRow* _tmp16_;
	GtkStringList* string_list;
	GtkStringList* _tmp17_;
	const gchar* _tmp18_;
	gchar* _tmp19_;
	AdwComboRow* _tmp20_;
	AdwComboRow* _tmp21_;
	GtkStringList* _tmp22_;
	AdwComboRow* _tmp23_;
	GtkStringList* _tmp24_;
	const gchar* _tmp25_;
	gint i;
	gboolean _tmp26_;
	gint _tmp27_;
	GeeList* _tmp28_;
	gint _tmp29_;
	gint _tmp30_;
	GtkStringList* _tmp31_;
	GeeList* _tmp32_;
	gpointer _tmp33_;
	struct _gpgme_key* _tmp34_;
	struct _gpgme_user_id* _tmp35_;
	gint _tmp35__length1;
	struct _gpgme_user_id _tmp36_;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	GeeList* _tmp39_;
	gpointer _tmp40_;
	struct _gpgme_key* _tmp41_;
	const gchar* _tmp42_;
	const gchar* _tmp43_;
	gchar* _tmp44_;
	gchar* _tmp45_;
	const gchar* _tmp46_;
	gchar* _tmp47_;
	gchar* _tmp48_;
	GeeList* _tmp49_;
	gpointer _tmp50_;
	struct _gpgme_key* _tmp51_;
	const gchar* _tmp52_;
	const gchar* _tmp53_;
	DinoPluginsOpenPgpPlugin* _tmp54_;
	DinoPluginsOpenPgpDatabase* _tmp55_;
	gchar* _tmp56_;
	gchar* _tmp57_;
	gboolean _tmp58_;
	AdwComboRow* _tmp59_;
	AdwComboRow* _tmp60_;
};

struct _Block2Data {
	int _ref_count_;
	GeeList* keys;
	GSourceFunc callback;
	gpointer callback_target;
	GDestroyNotify callback_target_destroy_notify;
	gpointer _async_data_;
};

struct _DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GeeList* result;
	Block2Data* _data2_;
	GThread* _tmp0_;
	GThread* _tmp1_;
	GeeList* _tmp2_;
};

static gint DinoPluginsOpenPgpPgpPreferencesEntry_private_offset;
static gpointer dino_plugins_open_pgp_pgp_preferences_entry_parent_class = NULL;

static GObject* dino_plugins_open_pgp_pgp_preferences_entry_real_get_widget (DinoPluginsEncryptionPreferencesEntry* base,
                                                                      DinoEntitiesAccount* account,
                                                                      DinoPluginsWidgetType type);
static void dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list (DinoPluginsOpenPgpPgpPreferencesEntry* self,
                                                                       DinoEntitiesAccount* account,
                                                                       AdwPreferencesGroup* preferences_group,
                                                                       GAsyncReadyCallback _callback_,
                                                                       gpointer _user_data_);
static void dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_finish (DinoPluginsOpenPgpPgpPreferencesEntry* self,
                                                                              GAsyncResult* _res_);
static void dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_data_free (gpointer _data);
static gboolean dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_co (DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData* _data_);
static Block1Data* block1_data_ref (Block1Data* _data1_);
static void block1_data_unref (void * _userdata_);
static void dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys (GAsyncReadyCallback _callback_,
                                                               gpointer _user_data_);
static GeeList* dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_finish (GAsyncResult* _res_);
static void dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_ready (GObject* source_object,
                                                                             GAsyncResult* _res_,
                                                                             gpointer _user_data_);
static void __lambda9_ (Block1Data* _data1_);
static void ___lambda9__g_object_notify (GObject* _sender,
                                  GParamSpec* pspec,
                                  gpointer self);
static void dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_data_free (gpointer _data);
static gboolean dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_co (DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData* _data_);
static Block2Data* block2_data_ref (Block2Data* _data2_);
static void block2_data_unref (void * _userdata_);
static gboolean _dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_co_gsource_func (gpointer self);
static void* __lambda8_ (Block2Data* _data2_);
static gpointer ___lambda8__gthread_func (gpointer self);
static void dino_plugins_open_pgp_pgp_preferences_entry_finalize (GObject * obj);
static GType dino_plugins_open_pgp_pgp_preferences_entry_get_type_once (void);
static void _vala_dino_plugins_open_pgp_pgp_preferences_entry_get_property (GObject * object,
                                                                     guint property_id,
                                                                     GValue * value,
                                                                     GParamSpec * pspec);
static gssize _vala_array_length (gpointer array);

static inline gpointer
dino_plugins_open_pgp_pgp_preferences_entry_get_instance_private (DinoPluginsOpenPgpPgpPreferencesEntry* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsOpenPgpPgpPreferencesEntry_private_offset);
}

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

DinoPluginsOpenPgpPgpPreferencesEntry*
dino_plugins_open_pgp_pgp_preferences_entry_construct (GType object_type,
                                                       DinoPluginsOpenPgpPlugin* plugin)
{
	DinoPluginsOpenPgpPgpPreferencesEntry * self = NULL;
	DinoPluginsOpenPgpPlugin* _tmp0_;
	g_return_val_if_fail (plugin != NULL, NULL);
	self = (DinoPluginsOpenPgpPgpPreferencesEntry*) dino_plugins_encryption_preferences_entry_construct (object_type);
	_tmp0_ = _g_object_ref0 (plugin);
	_g_object_unref0 (self->priv->plugin);
	self->priv->plugin = _tmp0_;
	return self;
}

DinoPluginsOpenPgpPgpPreferencesEntry*
dino_plugins_open_pgp_pgp_preferences_entry_new (DinoPluginsOpenPgpPlugin* plugin)
{
	return dino_plugins_open_pgp_pgp_preferences_entry_construct (DINO_PLUGINS_OPEN_PGP_TYPE_PGP_PREFERENCES_ENTRY, plugin);
}

static GObject*
dino_plugins_open_pgp_pgp_preferences_entry_real_get_widget (DinoPluginsEncryptionPreferencesEntry* base,
                                                             DinoEntitiesAccount* account,
                                                             DinoPluginsWidgetType type)
{
	DinoPluginsOpenPgpPgpPreferencesEntry * self;
	GtkStringList* string_list = NULL;
	GtkStringList* _tmp0_;
	GtkStringList* _tmp1_;
	const gchar* _tmp2_;
	AdwPreferencesGroup* preferences_group = NULL;
	gchar* _tmp3_;
	AdwPreferencesGroup* _tmp4_ = NULL;
	AdwPreferencesGroup* _tmp5_;
	GObject* result;
	self = (DinoPluginsOpenPgpPgpPreferencesEntry*) base;
	g_return_val_if_fail (account != NULL, NULL);
	if (type != DINO_PLUGINS_WIDGET_TYPE_GTK4) {
		result = NULL;
		return result;
	}
	_tmp0_ = gtk_string_list_new (NULL);
	string_list = _tmp0_;
	_tmp1_ = string_list;
	_tmp2_ = dino_gettext ("Querying GnuPG");
	gtk_string_list_append (_tmp1_, _tmp2_);
	_tmp3_ = g_strdup ("OpenPGP");
	_tmp4_ = (AdwPreferencesGroup*) adw_preferences_group_new ();
	adw_preferences_group_set_title (_tmp4_, _tmp3_);
	_g_free0 (_tmp3_);
	g_object_ref_sink (_tmp4_);
	preferences_group = _tmp4_;
	_tmp5_ = preferences_group;
	dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list (self, account, _tmp5_, NULL, NULL);
	result = (GObject*) preferences_group;
	_g_object_unref0 (string_list);
	return result;
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_data_free (gpointer _data)
{
	DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->preferences_group);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData, _data_);
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list (DinoPluginsOpenPgpPgpPreferencesEntry* self,
                                                                  DinoEntitiesAccount* account,
                                                                  AdwPreferencesGroup* preferences_group,
                                                                  GAsyncReadyCallback _callback_,
                                                                  gpointer _user_data_)
{
	DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData* _data_;
	DinoPluginsOpenPgpPgpPreferencesEntry* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	AdwPreferencesGroup* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (preferences_group != NULL);
	_data_ = g_slice_new0 (DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData);
	_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_preferences_entry_populate_string_list_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	_tmp2_ = _g_object_ref0 (preferences_group);
	_g_object_unref0 (_data_->preferences_group);
	_data_->preferences_group = _tmp2_;
	dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_co (_data_);
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_finish (DinoPluginsOpenPgpPgpPreferencesEntry* self,
                                                                         GAsyncResult* _res_)
{
	DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

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

static void
block1_data_unref (void * _userdata_)
{
	Block1Data* _data1_;
	_data1_ = (Block1Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data1_->_ref_count_)) {
		DinoPluginsOpenPgpPgpPreferencesEntry* self;
		self = _data1_->self;
		_g_object_unref0 (_data1_->drop_down);
		_g_object_unref0 (_data1_->keys);
		_g_object_unref0 (_data1_->account);
		_g_object_unref0 (self);
		g_slice_free (Block1Data, _data1_);
	}
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_ready (GObject* source_object,
                                                                        GAsyncResult* _res_,
                                                                        gpointer _user_data_)
{
	DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_co (_data_);
}

static const gchar*
string_to_string (const gchar* self)
{
	const gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	result = self;
	return result;
}

static const gchar*
gpgme_key_get_fpr (struct _gpgme_key* self)
{
	const gchar* result;
	struct _gpgme_subkey* _tmp0_;
	gint _tmp0__length1;
	struct _gpgme_subkey _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->subkeys;
	_tmp0__length1 = _vala_array_length (self->subkeys);
	_tmp1_ = _tmp0_[0];
	_tmp2_ = _tmp1_.fpr;
	result = _tmp2_;
	return result;
}

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 void
__lambda9_ (Block1Data* _data1_)
{
	DinoPluginsOpenPgpPgpPreferencesEntry* self;
	const gchar* _tmp0_ = NULL;
	AdwComboRow* _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	gchar* key_id = NULL;
	gchar* _tmp12_;
	DinoPluginsOpenPgpPlugin* _tmp13_;
	GeeHashMap* _tmp14_;
	DinoPluginsOpenPgpPlugin* _tmp20_;
	DinoPluginsOpenPgpDatabase* _tmp21_;
	const gchar* _tmp22_;
	self = _data1_->self;
	_tmp1_ = _data1_->drop_down;
	_tmp2_ = adw_combo_row_get_selected (_tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ == ((guint) 0)) {
		_tmp0_ = "";
	} else {
		GeeList* _tmp4_;
		AdwComboRow* _tmp5_;
		guint _tmp6_;
		guint _tmp7_;
		gpointer _tmp8_;
		struct _gpgme_key* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		_tmp4_ = _data1_->keys;
		_tmp5_ = _data1_->drop_down;
		_tmp6_ = adw_combo_row_get_selected (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = gee_list_get (_tmp4_, ((gint) _tmp7_) - 1);
		_tmp9_ = (struct _gpgme_key*) _tmp8_;
		_tmp10_ = gpgme_key_get_fpr (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp0_ = _tmp11_;
		_gpgme_key_unref_vapi0 (_tmp9_);
	}
	_tmp12_ = g_strdup (_tmp0_);
	key_id = _tmp12_;
	_tmp13_ = self->priv->plugin;
	_tmp14_ = _tmp13_->modules;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp14_, _data1_->account)) {
		DinoPluginsOpenPgpPlugin* _tmp15_;
		GeeHashMap* _tmp16_;
		gpointer _tmp17_;
		DinoPluginsOpenPgpModule* _tmp18_;
		const gchar* _tmp19_;
		_tmp15_ = self->priv->plugin;
		_tmp16_ = _tmp15_->modules;
		_tmp17_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp16_, _data1_->account);
		_tmp18_ = (DinoPluginsOpenPgpModule*) _tmp17_;
		_tmp19_ = key_id;
		dino_plugins_open_pgp_module_set_private_key_id (_tmp18_, _tmp19_);
		_g_object_unref0 (_tmp18_);
	}
	_tmp20_ = self->priv->plugin;
	_tmp21_ = _tmp20_->db;
	_tmp22_ = key_id;
	dino_plugins_open_pgp_database_set_account_key (_tmp21_, _data1_->account, _tmp22_);
	_g_free0 (key_id);
}

static void
___lambda9__g_object_notify (GObject* _sender,
                             GParamSpec* pspec,
                             gpointer self)
{
	__lambda9_ (self);
}

static gboolean
dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_co (DinoPluginsOpenPgpPgpPreferencesEntryPopulateStringListData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data1_ = g_slice_new0 (Block1Data);
	_data_->_data1_->_ref_count_ = 1;
	_data_->_data1_->self = g_object_ref (_data_->self);
	_g_object_unref0 (_data_->_data1_->account);
	_data_->_data1_->account = _data_->account;
	_data_->_data1_->_async_data_ = _data_;
	_data_->_state_ = 1;
	dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys (dino_plugins_open_pgp_pgp_preferences_entry_populate_string_list_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp0_ = dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_finish (_data_->_res_);
	_data_->_data1_->keys = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->_data1_->keys;
	if (_data_->_tmp1_ == NULL) {
		_data_->_tmp2_ = dino_gettext ("Announce key");
		_data_->_tmp3_ = g_strdup (_data_->_tmp2_);
		_data_->_tmp4_ = dino_gettext ("Error in GnuPG");
		_data_->_tmp5_ = g_strdup (_data_->_tmp4_);
		_data_->_tmp6_ = NULL;
		_data_->_tmp6_ = (AdwActionRow*) adw_action_row_new ();
		adw_preferences_row_set_title ((AdwPreferencesRow*) _data_->_tmp6_, _data_->_tmp3_);
		_g_free0 (_data_->_tmp3_);
		adw_action_row_set_subtitle (_data_->_tmp6_, _data_->_tmp5_);
		_g_free0 (_data_->_tmp5_);
		g_object_ref_sink (_data_->_tmp6_);
		_data_->_tmp7_ = _data_->_tmp6_;
		adw_preferences_group_add (_data_->preferences_group, (GtkWidget*) _data_->_tmp7_);
		_g_object_unref0 (_data_->_tmp7_);
		block1_data_unref (_data_->_data1_);
		_data_->_data1_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp8_ = _data_->_data1_->keys;
	_data_->_tmp9_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp8_);
	_data_->_tmp10_ = _data_->_tmp9_;
	if (_data_->_tmp10_ == 0) {
		_data_->_tmp11_ = dino_gettext ("Announce key");
		_data_->_tmp12_ = g_strdup (_data_->_tmp11_);
		_data_->_tmp13_ = dino_gettext ("No keys available. Generate one!");
		_data_->_tmp14_ = g_strdup (_data_->_tmp13_);
		_data_->_tmp15_ = NULL;
		_data_->_tmp15_ = (AdwActionRow*) adw_action_row_new ();
		adw_preferences_row_set_title ((AdwPreferencesRow*) _data_->_tmp15_, _data_->_tmp12_);
		_g_free0 (_data_->_tmp12_);
		adw_action_row_set_subtitle (_data_->_tmp15_, _data_->_tmp14_);
		_g_free0 (_data_->_tmp14_);
		g_object_ref_sink (_data_->_tmp15_);
		_data_->_tmp16_ = _data_->_tmp15_;
		adw_preferences_group_add (_data_->preferences_group, (GtkWidget*) _data_->_tmp16_);
		_g_object_unref0 (_data_->_tmp16_);
		block1_data_unref (_data_->_data1_);
		_data_->_data1_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp17_ = gtk_string_list_new (NULL);
	_data_->string_list = _data_->_tmp17_;
	_data_->_tmp18_ = dino_gettext ("Announce key");
	_data_->_tmp19_ = g_strdup (_data_->_tmp18_);
	_data_->_tmp20_ = NULL;
	_data_->_tmp20_ = (AdwComboRow*) adw_combo_row_new ();
	adw_preferences_row_set_title ((AdwPreferencesRow*) _data_->_tmp20_, _data_->_tmp19_);
	_g_free0 (_data_->_tmp19_);
	g_object_ref_sink (_data_->_tmp20_);
	_data_->_data1_->drop_down = _data_->_tmp20_;
	_data_->_tmp21_ = _data_->_data1_->drop_down;
	_data_->_tmp22_ = _data_->string_list;
	adw_combo_row_set_model (_data_->_tmp21_, (GListModel*) _data_->_tmp22_);
	_data_->_tmp23_ = _data_->_data1_->drop_down;
	adw_preferences_group_add (_data_->preferences_group, (GtkWidget*) _data_->_tmp23_);
	_data_->_tmp24_ = _data_->string_list;
	_data_->_tmp25_ = dino_gettext ("Disabled");
	gtk_string_list_append (_data_->_tmp24_, _data_->_tmp25_);
	{
		_data_->i = 0;
		{
			_data_->_tmp26_ = TRUE;
			while (TRUE) {
				if (!_data_->_tmp26_) {
					_data_->_tmp27_ = _data_->i;
					_data_->i = _data_->_tmp27_ + 1;
				}
				_data_->_tmp26_ = FALSE;
				_data_->_tmp28_ = _data_->_data1_->keys;
				_data_->_tmp29_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp28_);
				_data_->_tmp30_ = _data_->_tmp29_;
				if (!(_data_->i < _data_->_tmp30_)) {
					break;
				}
				_data_->_tmp31_ = _data_->string_list;
				_data_->_tmp32_ = _data_->_data1_->keys;
				_data_->_tmp33_ = gee_list_get (_data_->_tmp32_, _data_->i);
				_data_->_tmp34_ = (struct _gpgme_key*) _data_->_tmp33_;
				_data_->_tmp35_ = _data_->_tmp34_->uids;
				_data_->_tmp35__length1 = _vala_array_length (_data_->_tmp34_->uids);
				_data_->_tmp36_ = _data_->_tmp35_[0];
				_data_->_tmp37_ = _data_->_tmp36_.uid;
				_data_->_tmp38_ = string_to_string (_data_->_tmp37_);
				_data_->_tmp39_ = _data_->_data1_->keys;
				_data_->_tmp40_ = gee_list_get (_data_->_tmp39_, _data_->i);
				_data_->_tmp41_ = (struct _gpgme_key*) _data_->_tmp40_;
				_data_->_tmp42_ = gpgme_key_get_fpr (_data_->_tmp41_);
				_data_->_tmp43_ = _data_->_tmp42_;
				_data_->_tmp44_ = string_substring (_data_->_tmp43_, (glong) 24, (glong) 16);
				_data_->_tmp45_ = _data_->_tmp44_;
				_data_->_tmp46_ = string_to_string (_data_->_tmp45_);
				_data_->_tmp47_ = g_strconcat (_data_->_tmp38_, "\n", _data_->_tmp46_, NULL);
				_data_->_tmp48_ = _data_->_tmp47_;
				gtk_string_list_append (_data_->_tmp31_, _data_->_tmp48_);
				_g_free0 (_data_->_tmp48_);
				_g_free0 (_data_->_tmp45_);
				_gpgme_key_unref_vapi0 (_data_->_tmp41_);
				_gpgme_key_unref_vapi0 (_data_->_tmp34_);
				_data_->_tmp49_ = _data_->_data1_->keys;
				_data_->_tmp50_ = gee_list_get (_data_->_tmp49_, _data_->i);
				_data_->_tmp51_ = (struct _gpgme_key*) _data_->_tmp50_;
				_data_->_tmp52_ = gpgme_key_get_fpr (_data_->_tmp51_);
				_data_->_tmp53_ = _data_->_tmp52_;
				_data_->_tmp54_ = _data_->self->priv->plugin;
				_data_->_tmp55_ = _data_->_tmp54_->db;
				_data_->_tmp56_ = dino_plugins_open_pgp_database_get_account_key (_data_->_tmp55_, _data_->_data1_->account);
				_data_->_tmp57_ = _data_->_tmp56_;
				_data_->_tmp58_ = g_strcmp0 (_data_->_tmp53_, _data_->_tmp57_) == 0;
				_g_free0 (_data_->_tmp57_);
				_gpgme_key_unref_vapi0 (_data_->_tmp51_);
				if (_data_->_tmp58_) {
					_data_->_tmp59_ = _data_->_data1_->drop_down;
					adw_combo_row_set_selected (_data_->_tmp59_, (guint) (_data_->i + 1));
				}
			}
		}
	}
	_data_->_tmp60_ = _data_->_data1_->drop_down;
	g_signal_connect_data ((GObject*) _data_->_tmp60_, "notify::selected", (GCallback) ___lambda9__g_object_notify, block1_data_ref (_data_->_data1_), (GClosureNotify) block1_data_unref, 0);
	_g_object_unref0 (_data_->string_list);
	block1_data_unref (_data_->_data1_);
	_data_->_data1_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_data_free (gpointer _data)
{
	DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->result);
	g_slice_free (DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData, _data_);
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys (GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData* _data_;
	_data_ = g_slice_new0 (DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData);
	_data_->_async_result = g_task_new (NULL, NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_data_free);
	dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_co (_data_);
}

static GeeList*
dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_finish (GAsyncResult* _res_)
{
	GeeList* result;
	DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData* _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_)) {
		(_data2_->callback_target_destroy_notify == NULL) ? NULL : (_data2_->callback_target_destroy_notify (_data2_->callback_target), NULL);
		_data2_->callback = NULL;
		_data2_->callback_target = NULL;
		_data2_->callback_target_destroy_notify = NULL;
		_g_object_unref0 (_data2_->keys);
		g_slice_free (Block2Data, _data2_);
	}
}

static gboolean
_dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_co_gsource_func (gpointer self)
{
	gboolean result;
	result = dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_co (self);
	return result;
}

static void*
__lambda8_ (Block2Data* _data2_)
{
	GSourceFunc _tmp5_;
	gpointer _tmp5__target;
	GDestroyNotify _tmp5__target_destroy_notify;
	GError* _inner_error0_ = NULL;
	void* result;
	{
		GeeList* _tmp0_ = NULL;
		GeeList* _tmp1_;
		GeeList* _tmp2_;
		_tmp1_ = gpg_helper_get_keylist (NULL, TRUE, &_inner_error0_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp2_ = _tmp0_;
		_tmp0_ = NULL;
		_g_object_unref0 (_data2_->keys);
		_data2_->keys = _tmp2_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_warning ("encryption_preferences_entry.vala:77: %s", _tmp4_);
		_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 NULL;
	}
	_tmp5_ = _data2_->callback;
	_tmp5__target = _data2_->callback_target;
	_tmp5__target_destroy_notify = _data2_->callback_target_destroy_notify;
	_data2_->callback = NULL;
	_data2_->callback_target = NULL;
	_data2_->callback_target_destroy_notify = NULL;
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, _tmp5_, _tmp5__target, _tmp5__target_destroy_notify);
	result = NULL;
	return result;
}

static gpointer
___lambda8__gthread_func (gpointer self)
{
	gpointer result;
	result = __lambda8_ (self);
	block2_data_unref (self);
	return result;
}

static gboolean
dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_co (DinoPluginsOpenPgpPgpPreferencesEntryGetPgpKeysData* _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_->_async_data_ = _data_;
	_data_->_data2_->keys = NULL;
	_data_->_data2_->callback = _dino_plugins_open_pgp_pgp_preferences_entry_get_pgp_keys_co_gsource_func;
	_data_->_data2_->callback_target = _data_;
	_data_->_data2_->callback_target_destroy_notify = NULL;
	_data_->_tmp0_ = g_thread_new (NULL, ___lambda8__gthread_func, block2_data_ref (_data_->_data2_));
	_data_->_tmp1_ = _data_->_tmp0_;
	_g_thread_unref0 (_data_->_tmp1_);
	_data_->_state_ = 1;
	return FALSE;
	_state_1:
	;
	_data_->_tmp2_ = _g_object_ref0 (_data_->_data2_->keys);
	_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;
}

static const gchar*
dino_plugins_open_pgp_pgp_preferences_entry_real_get_id (DinoPluginsEncryptionPreferencesEntry* base)
{
	const gchar* result;
	DinoPluginsOpenPgpPgpPreferencesEntry* self;
	self = (DinoPluginsOpenPgpPgpPreferencesEntry*) base;
	result = "pgp_preferences_encryption";
	return result;
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_class_init (DinoPluginsOpenPgpPgpPreferencesEntryClass * klass,
                                                        gpointer klass_data)
{
	dino_plugins_open_pgp_pgp_preferences_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoPluginsOpenPgpPgpPreferencesEntry_private_offset);
	((DinoPluginsEncryptionPreferencesEntryClass *) klass)->get_widget = (GObject* (*) (DinoPluginsEncryptionPreferencesEntry*, DinoEntitiesAccount*, DinoPluginsWidgetType)) dino_plugins_open_pgp_pgp_preferences_entry_real_get_widget;
	DINO_PLUGINS_ENCRYPTION_PREFERENCES_ENTRY_CLASS (klass)->get_id = (const gchar* (*) (DinoPluginsEncryptionPreferencesEntry*)) dino_plugins_open_pgp_pgp_preferences_entry_real_get_id;
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_plugins_open_pgp_pgp_preferences_entry_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_plugins_open_pgp_pgp_preferences_entry_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_PLUGINS_OPEN_PGP_PGP_PREFERENCES_ENTRY_ID_PROPERTY, dino_plugins_open_pgp_pgp_preferences_entry_properties[DINO_PLUGINS_OPEN_PGP_PGP_PREFERENCES_ENTRY_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_instance_init (DinoPluginsOpenPgpPgpPreferencesEntry * self,
                                                           gpointer klass)
{
	self->priv = dino_plugins_open_pgp_pgp_preferences_entry_get_instance_private (self);
}

static void
dino_plugins_open_pgp_pgp_preferences_entry_finalize (GObject * obj)
{
	DinoPluginsOpenPgpPgpPreferencesEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OPEN_PGP_TYPE_PGP_PREFERENCES_ENTRY, DinoPluginsOpenPgpPgpPreferencesEntry);
	_g_object_unref0 (self->priv->plugin);
	G_OBJECT_CLASS (dino_plugins_open_pgp_pgp_preferences_entry_parent_class)->finalize (obj);
}

static GType
dino_plugins_open_pgp_pgp_preferences_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOpenPgpPgpPreferencesEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_open_pgp_pgp_preferences_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOpenPgpPgpPreferencesEntry), 0, (GInstanceInitFunc) dino_plugins_open_pgp_pgp_preferences_entry_instance_init, NULL };
	GType dino_plugins_open_pgp_pgp_preferences_entry_type_id;
	dino_plugins_open_pgp_pgp_preferences_entry_type_id = g_type_register_static (DINO_PLUGINS_TYPE_ENCRYPTION_PREFERENCES_ENTRY, "DinoPluginsOpenPgpPgpPreferencesEntry", &g_define_type_info, 0);
	DinoPluginsOpenPgpPgpPreferencesEntry_private_offset = g_type_add_instance_private (dino_plugins_open_pgp_pgp_preferences_entry_type_id, sizeof (DinoPluginsOpenPgpPgpPreferencesEntryPrivate));
	return dino_plugins_open_pgp_pgp_preferences_entry_type_id;
}

GType
dino_plugins_open_pgp_pgp_preferences_entry_get_type (void)
{
	static volatile gsize dino_plugins_open_pgp_pgp_preferences_entry_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_open_pgp_pgp_preferences_entry_type_id__once)) {
		GType dino_plugins_open_pgp_pgp_preferences_entry_type_id;
		dino_plugins_open_pgp_pgp_preferences_entry_type_id = dino_plugins_open_pgp_pgp_preferences_entry_get_type_once ();
		g_once_init_leave (&dino_plugins_open_pgp_pgp_preferences_entry_type_id__once, dino_plugins_open_pgp_pgp_preferences_entry_type_id);
	}
	return dino_plugins_open_pgp_pgp_preferences_entry_type_id__once;
}

static void
_vala_dino_plugins_open_pgp_pgp_preferences_entry_get_property (GObject * object,
                                                                guint property_id,
                                                                GValue * value,
                                                                GParamSpec * pspec)
{
	DinoPluginsOpenPgpPgpPreferencesEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_PLUGINS_OPEN_PGP_TYPE_PGP_PREFERENCES_ENTRY, DinoPluginsOpenPgpPgpPreferencesEntry);
	switch (property_id) {
		case DINO_PLUGINS_OPEN_PGP_PGP_PREFERENCES_ENTRY_ID_PROPERTY:
		g_value_set_string (value, dino_plugins_encryption_preferences_entry_get_id ((DinoPluginsEncryptionPreferencesEntry*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

