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

#include "omemo.h"
#include <glib-object.h>
#include "xmpp-vala.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <omemo/curve.h>
#include <native/helper.h>
#include <gee.h>
#include <gobject/gvaluecollector.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 _xmpp_stanza_entry_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_stanza_entry_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _omemo_context_unref0(var) ((var == NULL) ? NULL : (var = (omemo_context_unref (var), NULL)))
#define _signal_type_unref_vapi0(var) ((var == NULL) ? NULL : (var = (signal_type_unref_vapi (var), NULL)))
typedef struct _Block6Data Block6Data;
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _dino_plugins_omemo_bundle_unref0(var) ((var == NULL) ? NULL : (var = (dino_plugins_omemo_bundle_unref (var), NULL)))
#define _dino_plugins_omemo_bundle_pre_key_unref0(var) ((var == NULL) ? NULL : (var = (dino_plugins_omemo_bundle_pre_key_unref (var), NULL)))
typedef struct _DinoPluginsOmemoBundleParamSpecPreKey DinoPluginsOmemoBundleParamSpecPreKey;
typedef struct _DinoPluginsOmemoParamSpecBundle DinoPluginsOmemoParamSpecBundle;
#define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
#define _vala_return_if_fail(expr, msg) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return; }
#define _vala_return_val_if_fail(expr, msg, val) if G_LIKELY (expr) ; else { g_return_if_fail_warning (G_LOG_DOMAIN, G_STRFUNC, msg); return val; }
#define _vala_warn_if_fail(expr, msg) if G_LIKELY (expr) ; else g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);

struct _Block6Data {
	int _ref_count_;
	DinoPluginsOmemoBundle* self;
	GeeArrayList* list;
};

struct _DinoPluginsOmemoBundlePreKeyPrivate {
	XmppStanzaNode* node;
};

struct _DinoPluginsOmemoBundleParamSpecPreKey {
	GParamSpec parent_instance;
};

struct _DinoPluginsOmemoParamSpecBundle {
	GParamSpec parent_instance;
};

static gpointer dino_plugins_omemo_bundle_parent_class = NULL;
static gint DinoPluginsOmemoBundlePreKey_private_offset;
static gpointer dino_plugins_omemo_bundle_pre_key_parent_class = NULL;

static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
static gboolean _dino_plugins_omemo_bundle_pre_keys___lambda18_ (DinoPluginsOmemoBundle* self,
                                                          XmppStanzaNode* node);
static gboolean __dino_plugins_omemo_bundle_pre_keys___lambda18__gee_predicate (gconstpointer g,
                                                                         gpointer self);
static gpointer _dino_plugins_omemo_bundle_pre_key_create_gee_map_func (gpointer g,
                                                                 gpointer self);
static gboolean _dino_plugins_omemo_bundle_pre_keys___lambda19_ (Block6Data* _data6_,
                                                          DinoPluginsOmemoBundlePreKey* key);
static gboolean __dino_plugins_omemo_bundle_pre_keys___lambda19__gee_forall_func (gpointer g,
                                                                           gpointer self);
static void dino_plugins_omemo_bundle_pre_key_finalize (DinoPluginsOmemoBundlePreKey * obj);
static GType dino_plugins_omemo_bundle_pre_key_get_type_once (void);
static void dino_plugins_omemo_bundle_finalize (DinoPluginsOmemoBundle * obj);
static GType dino_plugins_omemo_bundle_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static gpointer
_xmpp_stanza_entry_ref0 (gpointer self)
{
	return self ? xmpp_stanza_entry_ref (self) : NULL;
}

DinoPluginsOmemoBundle*
dino_plugins_omemo_bundle_construct (GType object_type,
                                     XmppStanzaNode* node)
{
	DinoPluginsOmemoBundle* self = NULL;
	XmppStanzaNode* _tmp0_;
	self = (DinoPluginsOmemoBundle*) g_type_create_instance (object_type);
	_tmp0_ = _xmpp_stanza_entry_ref0 (node);
	_xmpp_stanza_entry_unref0 (self->node);
	self->node = _tmp0_;
	_vala_assert (dino_plugins_omemo_plugin_ensure_context (), "Plugin.ensure_context()");
	return self;
}

DinoPluginsOmemoBundle*
dino_plugins_omemo_bundle_new (XmppStanzaNode* node)
{
	return dino_plugins_omemo_bundle_construct (DINO_PLUGINS_OMEMO_TYPE_BUNDLE, node);
}

gint32
dino_plugins_omemo_bundle_get_signed_pre_key_id (DinoPluginsOmemoBundle* self)
{
	gint32 result;
	XmppStanzaNode* _tmp0_;
	gchar* id = NULL;
	XmppStanzaNode* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = self->node;
	if (_tmp0_ == NULL) {
		result = (gint32) -1;
		return result;
	}
	_tmp1_ = self->node;
	_tmp2_ = xmpp_stanza_node_get_deep_attribute (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, XMPP_TYPE_STANZA_NODE, XmppStanzaNode), "signedPreKeyPublic", "signedPreKeyId", NULL);
	_tmp3_ = g_strdup (_tmp2_);
	id = _tmp3_;
	_tmp4_ = id;
	if (_tmp4_ == NULL) {
		result = (gint32) -1;
		_g_free0 (id);
		return result;
	}
	_tmp5_ = id;
	result = (gint32) atoi ((const gchar*) _tmp5_);
	_g_free0 (id);
	return result;
}

ec_public_key*
dino_plugins_omemo_bundle_get_signed_pre_key (DinoPluginsOmemoBundle* self)
{
	ec_public_key* result;
	XmppStanzaNode* _tmp0_;
	gchar* key = NULL;
	XmppStanzaNode* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->node;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->node;
	_tmp2_ = xmpp_stanza_node_get_deep_string_content (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, XMPP_TYPE_STANZA_NODE, XmppStanzaNode), "signedPreKeyPublic", NULL);
	_tmp3_ = g_strdup (_tmp2_);
	key = _tmp3_;
	_tmp4_ = key;
	if (_tmp4_ == NULL) {
		result = NULL;
		_g_free0 (key);
		return result;
	}
	{
		ec_public_key* _tmp5_ = NULL;
		OmemoContext* _tmp6_;
		OmemoContext* _tmp7_;
		const gchar* _tmp8_;
		gsize _tmp9_ = 0;
		guchar* _tmp10_;
		guchar* _tmp11_;
		gint _tmp11__length1;
		ec_public_key* _tmp12_;
		ec_public_key* _tmp13_;
		ec_public_key* _tmp14_;
		_tmp6_ = dino_plugins_omemo_plugin_get_context ();
		_tmp7_ = _tmp6_;
		_tmp8_ = key;
		_tmp10_ = g_base64_decode ((const gchar*) _tmp8_, &_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp11__length1 = _tmp9_;
		_tmp12_ = omemo_context_decode_public_key (_tmp7_, _tmp11_, (gint) _tmp9_, &_inner_error0_);
		_tmp13_ = _tmp12_;
		_tmp11_ = (g_free (_tmp11_), NULL);
		_omemo_context_unref0 (_tmp7_);
		_tmp5_ = _tmp13_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp14_ = _tmp5_;
		_tmp5_ = NULL;
		result = _tmp14_;
		_signal_type_unref_vapi0 (_tmp5_);
		_g_free0 (key);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		_g_free0 (key);
		return result;
	}
	__finally0:
	_g_free0 (key);
	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;
}

guint8*
dino_plugins_omemo_bundle_get_signed_pre_key_signature (DinoPluginsOmemoBundle* self,
                                                        gint* result_length1)
{
	guint8* result;
	XmppStanzaNode* _tmp0_;
	gchar* sig = NULL;
	XmppStanzaNode* _tmp2_;
	const gchar* _tmp3_;
	gchar* _tmp4_;
	const gchar* _tmp5_;
	const gchar* _tmp7_;
	gsize _tmp8_ = 0;
	guchar* _tmp9_;
	guint8* _tmp10_;
	gint _tmp10__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->node;
	if (_tmp0_ == NULL) {
		guint8* _tmp1_;
		gint _tmp1__length1;
		_tmp1_ = NULL;
		_tmp1__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp1__length1;
		}
		result = _tmp1_;
		return result;
	}
	_tmp2_ = self->node;
	_tmp3_ = xmpp_stanza_node_get_deep_string_content (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, XMPP_TYPE_STANZA_NODE, XmppStanzaNode), "signedPreKeySignature", NULL);
	_tmp4_ = g_strdup (_tmp3_);
	sig = _tmp4_;
	_tmp5_ = sig;
	if (_tmp5_ == NULL) {
		guint8* _tmp6_;
		gint _tmp6__length1;
		_tmp6_ = NULL;
		_tmp6__length1 = 0;
		if (result_length1) {
			*result_length1 = _tmp6__length1;
		}
		result = _tmp6_;
		_g_free0 (sig);
		return result;
	}
	_tmp7_ = sig;
	_tmp9_ = g_base64_decode ((const gchar*) _tmp7_, &_tmp8_);
	_tmp10_ = _tmp9_;
	_tmp10__length1 = _tmp8_;
	if (result_length1) {
		*result_length1 = _tmp10__length1;
	}
	result = _tmp10_;
	_g_free0 (sig);
	return result;
}

ec_public_key*
dino_plugins_omemo_bundle_get_identity_key (DinoPluginsOmemoBundle* self)
{
	ec_public_key* result;
	XmppStanzaNode* _tmp0_;
	gchar* key = NULL;
	XmppStanzaNode* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	const gchar* _tmp4_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->node;
	if (_tmp0_ == NULL) {
		result = NULL;
		return result;
	}
	_tmp1_ = self->node;
	_tmp2_ = xmpp_stanza_node_get_deep_string_content (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, XMPP_TYPE_STANZA_NODE, XmppStanzaNode), "identityKey", NULL);
	_tmp3_ = g_strdup (_tmp2_);
	key = _tmp3_;
	_tmp4_ = key;
	if (_tmp4_ == NULL) {
		result = NULL;
		_g_free0 (key);
		return result;
	}
	{
		ec_public_key* _tmp5_ = NULL;
		OmemoContext* _tmp6_;
		OmemoContext* _tmp7_;
		const gchar* _tmp8_;
		gsize _tmp9_ = 0;
		guchar* _tmp10_;
		guchar* _tmp11_;
		gint _tmp11__length1;
		ec_public_key* _tmp12_;
		ec_public_key* _tmp13_;
		ec_public_key* _tmp14_;
		_tmp6_ = dino_plugins_omemo_plugin_get_context ();
		_tmp7_ = _tmp6_;
		_tmp8_ = key;
		_tmp10_ = g_base64_decode ((const gchar*) _tmp8_, &_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp11__length1 = _tmp9_;
		_tmp12_ = omemo_context_decode_public_key (_tmp7_, _tmp11_, (gint) _tmp9_, &_inner_error0_);
		_tmp13_ = _tmp12_;
		_tmp11_ = (g_free (_tmp11_), NULL);
		_omemo_context_unref0 (_tmp7_);
		_tmp5_ = _tmp13_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp14_ = _tmp5_;
		_tmp5_ = NULL;
		result = _tmp14_;
		_signal_type_unref_vapi0 (_tmp5_);
		_g_free0 (key);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		_g_free0 (key);
		return result;
	}
	__finally0:
	_g_free0 (key);
	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;
}

static Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		DinoPluginsOmemoBundle* self;
		self = _data6_->self;
		_g_object_unref0 (_data6_->list);
		_dino_plugins_omemo_bundle_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}

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

static gboolean
_dino_plugins_omemo_bundle_pre_keys___lambda18_ (DinoPluginsOmemoBundle* self,
                                                 XmppStanzaNode* node)
{
	const gchar* _tmp0_;
	gboolean result;
	g_return_val_if_fail (node != NULL, FALSE);
	_tmp0_ = xmpp_stanza_node_get_attribute (G_TYPE_CHECK_INSTANCE_CAST (node, XMPP_TYPE_STANZA_NODE, XmppStanzaNode), "preKeyId", NULL);
	result = _tmp0_ != NULL;
	return result;
}

static gboolean
__dino_plugins_omemo_bundle_pre_keys___lambda18__gee_predicate (gconstpointer g,
                                                                gpointer self)
{
	gboolean result;
	result = _dino_plugins_omemo_bundle_pre_keys___lambda18_ ((DinoPluginsOmemoBundle*) self, (XmppStanzaNode*) g);
	return result;
}

static gpointer
_dino_plugins_omemo_bundle_pre_key_create_gee_map_func (gpointer g,
                                                        gpointer self)
{
	gpointer result;
	result = dino_plugins_omemo_bundle_pre_key_create ((XmppStanzaNode*) g);
	return result;
}

static gboolean
_dino_plugins_omemo_bundle_pre_keys___lambda19_ (Block6Data* _data6_,
                                                 DinoPluginsOmemoBundlePreKey* key)
{
	DinoPluginsOmemoBundle* self;
	GeeArrayList* _tmp0_;
	gboolean result;
	self = _data6_->self;
	g_return_val_if_fail (key != NULL, FALSE);
	_tmp0_ = _data6_->list;
	result = gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, key);
	_dino_plugins_omemo_bundle_pre_key_unref0 (key);
	return result;
}

static gboolean
__dino_plugins_omemo_bundle_pre_keys___lambda19__gee_forall_func (gpointer g,
                                                                  gpointer self)
{
	gboolean result;
	result = _dino_plugins_omemo_bundle_pre_keys___lambda19_ (self, (DinoPluginsOmemoBundlePreKey*) g);
	return result;
}

GeeArrayList*
dino_plugins_omemo_bundle_get_pre_keys (DinoPluginsOmemoBundle* self)
{
	GeeArrayList* result;
	Block6Data* _data6_;
	GeeArrayList* _tmp0_;
	gboolean _tmp1_ = FALSE;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp8_;
	GeeList* _tmp9_;
	GeeList* _tmp10_;
	GeeIterator* _tmp11_;
	GeeIterator* _tmp12_;
	GeeIterator* _tmp13_;
	GeeIterator* _tmp14_;
	GeeArrayList* _tmp15_;
	GeeArrayList* _tmp16_;
	g_return_val_if_fail (self != NULL, NULL);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_data6_->self = dino_plugins_omemo_bundle_ref (self);
	_tmp0_ = gee_array_list_new (DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY, (GBoxedCopyFunc) dino_plugins_omemo_bundle_pre_key_ref, (GDestroyNotify) dino_plugins_omemo_bundle_pre_key_unref, NULL, NULL, NULL);
	_data6_->list = _tmp0_;
	_tmp2_ = self->node;
	if (_tmp2_ == NULL) {
		_tmp1_ = TRUE;
	} else {
		XmppStanzaNode* _tmp3_;
		XmppStanzaNode* _tmp4_;
		XmppStanzaNode* _tmp5_;
		_tmp3_ = self->node;
		_tmp4_ = xmpp_stanza_node_get_subnode (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, XMPP_TYPE_STANZA_NODE, XmppStanzaNode), "prekeys", NULL, FALSE);
		_tmp5_ = _tmp4_;
		_tmp1_ = _tmp5_ == NULL;
		_xmpp_stanza_entry_unref0 (_tmp5_);
	}
	if (_tmp1_) {
		GeeArrayList* _tmp6_;
		GeeArrayList* _tmp7_;
		_tmp6_ = _data6_->list;
		_tmp7_ = _g_object_ref0 (_tmp6_);
		result = _tmp7_;
		block6_data_unref (_data6_);
		_data6_ = NULL;
		return result;
	}
	_tmp8_ = self->node;
	_tmp9_ = xmpp_stanza_node_get_deep_subnodes (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, XMPP_TYPE_STANZA_NODE, XmppStanzaNode), "prekeys", "preKeyPublic", NULL);
	_tmp10_ = _tmp9_;
	_tmp11_ = gee_traversable_filter ((GeeTraversable*) _tmp10_, __dino_plugins_omemo_bundle_pre_keys___lambda18__gee_predicate, dino_plugins_omemo_bundle_ref (self), dino_plugins_omemo_bundle_unref);
	_tmp12_ = _tmp11_;
	_tmp13_ = gee_traversable_map ((GeeTraversable*) _tmp12_, DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY, (GBoxedCopyFunc) dino_plugins_omemo_bundle_pre_key_ref, (GDestroyNotify) dino_plugins_omemo_bundle_pre_key_unref, _dino_plugins_omemo_bundle_pre_key_create_gee_map_func, NULL);
	_tmp14_ = _tmp13_;
	gee_traversable_foreach ((GeeTraversable*) _tmp14_, __dino_plugins_omemo_bundle_pre_keys___lambda19__gee_forall_func, _data6_);
	_g_object_unref0 (_tmp14_);
	_g_object_unref0 (_tmp12_);
	_g_object_unref0 (_tmp10_);
	_tmp15_ = _data6_->list;
	_tmp16_ = _g_object_ref0 (_tmp15_);
	result = _tmp16_;
	block6_data_unref (_data6_);
	_data6_ = NULL;
	return result;
}

static inline gpointer
dino_plugins_omemo_bundle_pre_key_get_instance_private (DinoPluginsOmemoBundlePreKey* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsOmemoBundlePreKey_private_offset);
}

DinoPluginsOmemoBundlePreKey*
dino_plugins_omemo_bundle_pre_key_create (XmppStanzaNode* node)
{
	DinoPluginsOmemoBundlePreKey* _tmp0_;
	DinoPluginsOmemoBundlePreKey* result;
	g_return_val_if_fail (node != NULL, NULL);
	_tmp0_ = dino_plugins_omemo_bundle_pre_key_new (node);
	result = _tmp0_;
	_xmpp_stanza_entry_unref0 (node);
	return result;
}

DinoPluginsOmemoBundlePreKey*
dino_plugins_omemo_bundle_pre_key_construct (GType object_type,
                                             XmppStanzaNode* node)
{
	DinoPluginsOmemoBundlePreKey* self = NULL;
	XmppStanzaNode* _tmp0_;
	g_return_val_if_fail (node != NULL, NULL);
	self = (DinoPluginsOmemoBundlePreKey*) g_type_create_instance (object_type);
	_tmp0_ = _xmpp_stanza_entry_ref0 (node);
	_xmpp_stanza_entry_unref0 (self->priv->node);
	self->priv->node = _tmp0_;
	return self;
}

DinoPluginsOmemoBundlePreKey*
dino_plugins_omemo_bundle_pre_key_new (XmppStanzaNode* node)
{
	return dino_plugins_omemo_bundle_pre_key_construct (DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY, node);
}

gint32
dino_plugins_omemo_bundle_pre_key_get_key_id (DinoPluginsOmemoBundlePreKey* self)
{
	gint32 result;
	const gchar* _tmp0_ = NULL;
	XmppStanzaNode* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (self != NULL, -1);
	_tmp1_ = self->priv->node;
	_tmp2_ = xmpp_stanza_node_get_attribute (_tmp1_, "preKeyId", NULL);
	_tmp0_ = _tmp2_;
	if (_tmp0_ == NULL) {
		_tmp0_ = "-1";
	}
	result = (gint32) atoi (_tmp0_);
	return result;
}

ec_public_key*
dino_plugins_omemo_bundle_pre_key_get_key (DinoPluginsOmemoBundlePreKey* self)
{
	ec_public_key* result;
	gchar* key = NULL;
	XmppStanzaNode* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_;
	const gchar* _tmp3_;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->node;
	_tmp1_ = xmpp_stanza_entry_get_string_content ((XmppStanzaEntry*) _tmp0_);
	_tmp2_ = g_strdup (_tmp1_);
	key = _tmp2_;
	_tmp3_ = key;
	if (_tmp3_ == NULL) {
		result = NULL;
		_g_free0 (key);
		return result;
	}
	{
		ec_public_key* _tmp4_ = NULL;
		OmemoContext* _tmp5_;
		OmemoContext* _tmp6_;
		const gchar* _tmp7_;
		gsize _tmp8_ = 0;
		guchar* _tmp9_;
		guchar* _tmp10_;
		gint _tmp10__length1;
		ec_public_key* _tmp11_;
		ec_public_key* _tmp12_;
		ec_public_key* _tmp13_;
		_tmp5_ = dino_plugins_omemo_plugin_get_context ();
		_tmp6_ = _tmp5_;
		_tmp7_ = key;
		_tmp9_ = g_base64_decode ((const gchar*) _tmp7_, &_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp10__length1 = _tmp8_;
		_tmp11_ = omemo_context_decode_public_key (_tmp6_, _tmp10_, (gint) _tmp8_, &_inner_error0_);
		_tmp12_ = _tmp11_;
		_tmp10_ = (g_free (_tmp10_), NULL);
		_omemo_context_unref0 (_tmp6_);
		_tmp4_ = _tmp12_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp13_ = _tmp4_;
		_tmp4_ = NULL;
		result = _tmp13_;
		_signal_type_unref_vapi0 (_tmp4_);
		_g_free0 (key);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = NULL;
		_g_free0 (key);
		return result;
	}
	__finally0:
	_g_free0 (key);
	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;
}

static void
dino_plugins_omemo_bundle_value_pre_key_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dino_plugins_omemo_bundle_value_pre_key_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dino_plugins_omemo_bundle_pre_key_unref (value->data[0].v_pointer);
	}
}

static void
dino_plugins_omemo_bundle_value_pre_key_copy_value (const GValue* src_value,
                                                    GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dino_plugins_omemo_bundle_pre_key_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dino_plugins_omemo_bundle_value_pre_key_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dino_plugins_omemo_bundle_value_pre_key_collect_value (GValue* value,
                                                       guint n_collect_values,
                                                       GTypeCValue* collect_values,
                                                       guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DinoPluginsOmemoBundlePreKey * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dino_plugins_omemo_bundle_pre_key_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dino_plugins_omemo_bundle_value_pre_key_lcopy_value (const GValue* value,
                                                     guint n_collect_values,
                                                     GTypeCValue* collect_values,
                                                     guint collect_flags)
{
	DinoPluginsOmemoBundlePreKey ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dino_plugins_omemo_bundle_pre_key_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
dino_plugins_omemo_bundle_param_spec_pre_key (const gchar* name,
                                              const gchar* nick,
                                              const gchar* blurb,
                                              GType object_type,
                                              GParamFlags flags)
{
	DinoPluginsOmemoBundleParamSpecPreKey* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
dino_plugins_omemo_bundle_value_get_pre_key (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY), NULL);
	return value->data[0].v_pointer;
}

void
dino_plugins_omemo_bundle_value_set_pre_key (GValue* value,
                                             gpointer v_object)
{
	DinoPluginsOmemoBundlePreKey * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dino_plugins_omemo_bundle_pre_key_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_plugins_omemo_bundle_pre_key_unref (old);
	}
}

void
dino_plugins_omemo_bundle_value_take_pre_key (GValue* value,
                                              gpointer v_object)
{
	DinoPluginsOmemoBundlePreKey * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_plugins_omemo_bundle_pre_key_unref (old);
	}
}

static void
dino_plugins_omemo_bundle_pre_key_class_init (DinoPluginsOmemoBundlePreKeyClass * klass,
                                              gpointer klass_data)
{
	dino_plugins_omemo_bundle_pre_key_parent_class = g_type_class_peek_parent (klass);
	((DinoPluginsOmemoBundlePreKeyClass *) klass)->finalize = dino_plugins_omemo_bundle_pre_key_finalize;
	g_type_class_adjust_private_offset (klass, &DinoPluginsOmemoBundlePreKey_private_offset);
}

static void
dino_plugins_omemo_bundle_pre_key_instance_init (DinoPluginsOmemoBundlePreKey * self,
                                                 gpointer klass)
{
	self->priv = dino_plugins_omemo_bundle_pre_key_get_instance_private (self);
	self->ref_count = 1;
}

static void
dino_plugins_omemo_bundle_pre_key_finalize (DinoPluginsOmemoBundlePreKey * obj)
{
	DinoPluginsOmemoBundlePreKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OMEMO_BUNDLE_TYPE_PRE_KEY, DinoPluginsOmemoBundlePreKey);
	g_signal_handlers_destroy (self);
	_xmpp_stanza_entry_unref0 (self->priv->node);
}

static GType
dino_plugins_omemo_bundle_pre_key_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dino_plugins_omemo_bundle_value_pre_key_init, dino_plugins_omemo_bundle_value_pre_key_free_value, dino_plugins_omemo_bundle_value_pre_key_copy_value, dino_plugins_omemo_bundle_value_pre_key_peek_pointer, "p", dino_plugins_omemo_bundle_value_pre_key_collect_value, "p", dino_plugins_omemo_bundle_value_pre_key_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOmemoBundlePreKeyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_omemo_bundle_pre_key_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOmemoBundlePreKey), 0, (GInstanceInitFunc) dino_plugins_omemo_bundle_pre_key_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dino_plugins_omemo_bundle_pre_key_type_id;
	dino_plugins_omemo_bundle_pre_key_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DinoPluginsOmemoBundlePreKey", &g_define_type_info, &g_define_type_fundamental_info, 0);
	DinoPluginsOmemoBundlePreKey_private_offset = g_type_add_instance_private (dino_plugins_omemo_bundle_pre_key_type_id, sizeof (DinoPluginsOmemoBundlePreKeyPrivate));
	return dino_plugins_omemo_bundle_pre_key_type_id;
}

GType
dino_plugins_omemo_bundle_pre_key_get_type (void)
{
	static volatile gsize dino_plugins_omemo_bundle_pre_key_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_omemo_bundle_pre_key_type_id__once)) {
		GType dino_plugins_omemo_bundle_pre_key_type_id;
		dino_plugins_omemo_bundle_pre_key_type_id = dino_plugins_omemo_bundle_pre_key_get_type_once ();
		g_once_init_leave (&dino_plugins_omemo_bundle_pre_key_type_id__once, dino_plugins_omemo_bundle_pre_key_type_id);
	}
	return dino_plugins_omemo_bundle_pre_key_type_id__once;
}

gpointer
dino_plugins_omemo_bundle_pre_key_ref (gpointer instance)
{
	DinoPluginsOmemoBundlePreKey * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
dino_plugins_omemo_bundle_pre_key_unref (gpointer instance)
{
	DinoPluginsOmemoBundlePreKey * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DINO_PLUGINS_OMEMO_BUNDLE_PRE_KEY_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
dino_plugins_omemo_value_bundle_init (GValue* value)
{
	value->data[0].v_pointer = NULL;
}

static void
dino_plugins_omemo_value_bundle_free_value (GValue* value)
{
	if (value->data[0].v_pointer) {
		dino_plugins_omemo_bundle_unref (value->data[0].v_pointer);
	}
}

static void
dino_plugins_omemo_value_bundle_copy_value (const GValue* src_value,
                                            GValue* dest_value)
{
	if (src_value->data[0].v_pointer) {
		dest_value->data[0].v_pointer = dino_plugins_omemo_bundle_ref (src_value->data[0].v_pointer);
	} else {
		dest_value->data[0].v_pointer = NULL;
	}
}

static gpointer
dino_plugins_omemo_value_bundle_peek_pointer (const GValue* value)
{
	return value->data[0].v_pointer;
}

static gchar*
dino_plugins_omemo_value_bundle_collect_value (GValue* value,
                                               guint n_collect_values,
                                               GTypeCValue* collect_values,
                                               guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		DinoPluginsOmemoBundle * object;
		object = collect_values[0].v_pointer;
		if (object->parent_instance.g_class == NULL) {
			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
		}
		value->data[0].v_pointer = dino_plugins_omemo_bundle_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
dino_plugins_omemo_value_bundle_lcopy_value (const GValue* value,
                                             guint n_collect_values,
                                             GTypeCValue* collect_values,
                                             guint collect_flags)
{
	DinoPluginsOmemoBundle ** object_p;
	object_p = collect_values[0].v_pointer;
	if (!object_p) {
		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
	}
	if (!value->data[0].v_pointer) {
		*object_p = NULL;
	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
		*object_p = value->data[0].v_pointer;
	} else {
		*object_p = dino_plugins_omemo_bundle_ref (value->data[0].v_pointer);
	}
	return NULL;
}

GParamSpec*
dino_plugins_omemo_param_spec_bundle (const gchar* name,
                                      const gchar* nick,
                                      const gchar* blurb,
                                      GType object_type,
                                      GParamFlags flags)
{
	DinoPluginsOmemoParamSpecBundle* spec;
	g_return_val_if_fail (g_type_is_a (object_type, DINO_PLUGINS_OMEMO_TYPE_BUNDLE), NULL);
	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
	G_PARAM_SPEC (spec)->value_type = object_type;
	return G_PARAM_SPEC (spec);
}

gpointer
dino_plugins_omemo_value_get_bundle (const GValue* value)
{
	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_PLUGINS_OMEMO_TYPE_BUNDLE), NULL);
	return value->data[0].v_pointer;
}

void
dino_plugins_omemo_value_set_bundle (GValue* value,
                                     gpointer v_object)
{
	DinoPluginsOmemoBundle * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_PLUGINS_OMEMO_TYPE_BUNDLE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_PLUGINS_OMEMO_TYPE_BUNDLE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dino_plugins_omemo_bundle_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_plugins_omemo_bundle_unref (old);
	}
}

void
dino_plugins_omemo_value_take_bundle (GValue* value,
                                      gpointer v_object)
{
	DinoPluginsOmemoBundle * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_PLUGINS_OMEMO_TYPE_BUNDLE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_PLUGINS_OMEMO_TYPE_BUNDLE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_plugins_omemo_bundle_unref (old);
	}
}

static void
dino_plugins_omemo_bundle_class_init (DinoPluginsOmemoBundleClass * klass,
                                      gpointer klass_data)
{
	dino_plugins_omemo_bundle_parent_class = g_type_class_peek_parent (klass);
	((DinoPluginsOmemoBundleClass *) klass)->finalize = dino_plugins_omemo_bundle_finalize;
}

static void
dino_plugins_omemo_bundle_instance_init (DinoPluginsOmemoBundle * self,
                                         gpointer klass)
{
	self->ref_count = 1;
}

static void
dino_plugins_omemo_bundle_finalize (DinoPluginsOmemoBundle * obj)
{
	DinoPluginsOmemoBundle * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OMEMO_TYPE_BUNDLE, DinoPluginsOmemoBundle);
	g_signal_handlers_destroy (self);
	_xmpp_stanza_entry_unref0 (self->node);
}

static GType
dino_plugins_omemo_bundle_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dino_plugins_omemo_value_bundle_init, dino_plugins_omemo_value_bundle_free_value, dino_plugins_omemo_value_bundle_copy_value, dino_plugins_omemo_value_bundle_peek_pointer, "p", dino_plugins_omemo_value_bundle_collect_value, "p", dino_plugins_omemo_value_bundle_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOmemoBundleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_omemo_bundle_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOmemoBundle), 0, (GInstanceInitFunc) dino_plugins_omemo_bundle_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dino_plugins_omemo_bundle_type_id;
	dino_plugins_omemo_bundle_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DinoPluginsOmemoBundle", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return dino_plugins_omemo_bundle_type_id;
}

GType
dino_plugins_omemo_bundle_get_type (void)
{
	static volatile gsize dino_plugins_omemo_bundle_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_omemo_bundle_type_id__once)) {
		GType dino_plugins_omemo_bundle_type_id;
		dino_plugins_omemo_bundle_type_id = dino_plugins_omemo_bundle_get_type_once ();
		g_once_init_leave (&dino_plugins_omemo_bundle_type_id__once, dino_plugins_omemo_bundle_type_id);
	}
	return dino_plugins_omemo_bundle_type_id__once;
}

gpointer
dino_plugins_omemo_bundle_ref (gpointer instance)
{
	DinoPluginsOmemoBundle * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

void
dino_plugins_omemo_bundle_unref (gpointer instance)
{
	DinoPluginsOmemoBundle * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DINO_PLUGINS_OMEMO_BUNDLE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

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

