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

#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "omemo.h"
#include <gee.h>
#include <glib-object.h>
#include "xmpp-vala.h"
#include <gio/gio.h>
#include <omemo/signal_protocol.h>
#include <native/helper.h>
#include <omemo/curve.h>
#include <omemo/signal_protocol_types.h>
#include <omemo/session_builder.h>
#include <omemo/session_pre_key.h>
#include <omemo/ratchet.h>

#define DINO_PLUGINS_OMEMO_NS_URI "eu.siacs.conversations.axolotl"
#define DINO_PLUGINS_OMEMO_NODE_DEVICELIST DINO_PLUGINS_OMEMO_NS_URI ".devicelist"
#define DINO_PLUGINS_OMEMO_NODE_BUNDLES DINO_PLUGINS_OMEMO_NS_URI ".bundles"
#define DINO_PLUGINS_OMEMO_NODE_VERIFICATION DINO_PLUGINS_OMEMO_NS_URI ".verification"
#define DINO_PLUGINS_OMEMO_NUM_KEYS_TO_PUBLISH 100
#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_OMEMO_STREAM_MODULE_0_PROPERTY,
	DINO_PLUGINS_OMEMO_STREAM_MODULE_STORE_PROPERTY,
	DINO_PLUGINS_OMEMO_STREAM_MODULE_NUM_PROPERTIES
};
static GParamSpec* dino_plugins_omemo_stream_module_properties[DINO_PLUGINS_OMEMO_STREAM_MODULE_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
typedef struct _Block7Data Block7Data;
#define _gee_promise_unref0(var) ((var == NULL) ? NULL : (var = (gee_promise_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _DinoPluginsOmemoStreamModuleRequestUserDevicelistData DinoPluginsOmemoStreamModuleRequestUserDevicelistData;
typedef struct _Block8Data Block8Data;
#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 _signal_protocol_address_free0(var) ((var == NULL) ? NULL : (var = (signal_protocol_address_free (var), NULL)))
typedef struct _Block9Data Block9Data;
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define _signal_buffer_free0(var) ((var == NULL) ? NULL : (var = (signal_buffer_free (var), NULL)))
#define _signal_type_unref_vapi0(var) ((var == NULL) ? NULL : (var = (signal_type_unref_vapi (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)))
#define _session_builder_free0(var) ((var == NULL) ? NULL : (var = (session_builder_free (var), NULL)))
#define _omemo_context_unref0(var) ((var == NULL) ? NULL : (var = (omemo_context_unref (var), NULL)))
typedef struct _DinoPluginsOmemoStreamModulePublishBundlesData DinoPluginsOmemoStreamModulePublishBundlesData;
#define _xmpp_xep_data_forms_data_form_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_data_forms_data_form_unref (var), NULL)))
typedef struct _DinoPluginsOmemoStreamModuleTryMakeNodePublicData DinoPluginsOmemoStreamModuleTryMakeNodePublicData;
enum  {
	DINO_PLUGINS_OMEMO_STREAM_MODULE_DEVICE_LIST_LOADED_SIGNAL,
	DINO_PLUGINS_OMEMO_STREAM_MODULE_BUNDLE_FETCHED_SIGNAL,
	DINO_PLUGINS_OMEMO_STREAM_MODULE_BUNDLE_FETCH_FAILED_SIGNAL,
	DINO_PLUGINS_OMEMO_STREAM_MODULE_NUM_SIGNALS
};
static guint dino_plugins_omemo_stream_module_signals[DINO_PLUGINS_OMEMO_STREAM_MODULE_NUM_SIGNALS] = {0};

struct _DinoPluginsOmemoStreamModulePrivate {
	OmemoStore* _store;
	GeeConcurrentSet* active_bundle_requests;
	GeeHashMap* active_devicelist_requests;
	GeeMap* device_ignore_time;
	GRecMutex __lock_device_ignore_time;
};

struct _Block7Data {
	int _ref_count_;
	DinoPluginsOmemoStreamModule* self;
	GeePromise* promise;
};

struct _DinoPluginsOmemoStreamModuleRequestUserDevicelistData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOmemoStreamModule* self;
	XmppXmppStream* stream;
	XmppJid* jid;
	GeeArrayList* result;
	GeeFuture* future;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	GeeFuture* _tmp2_;
	Block7Data* _data7_;
	GeePromise* _tmp3_;
	GeePromise* _tmp4_;
	GeeFuture* _tmp5_;
	GeeFuture* _tmp6_;
	GeeFuture* _tmp7_;
	GeeHashMap* _tmp8_;
	GeeFuture* _tmp9_;
	XmppModuleIdentity* _tmp10_;
	gpointer _tmp11_;
	XmppXepPubsubModule* _tmp12_;
	GeeArrayList* device_list;
	GeeFuture* _tmp13_;
	gconstpointer _tmp14_;
	GeeArrayList* _tmp15_;
	GError* _error_;
	GError* _tmp16_;
	const gchar* _tmp17_;
	GeeArrayList* _tmp18_;
	GError* _inner_error0_;
};

struct _Block8Data {
	int _ref_count_;
	DinoPluginsOmemoStreamModule* self;
	XmppXmppStream* stream;
};

struct _Block9Data {
	int _ref_count_;
	DinoPluginsOmemoStreamModule* self;
	gint device_id;
	gboolean ignore_if_non_present;
};

struct _DinoPluginsOmemoStreamModulePublishBundlesData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOmemoStreamModule* self;
	XmppXmppStream* stream;
	session_signed_pre_key* signed_pre_key_record;
	ratchet_identity_key_pair* identity_key_pair;
	GeeSet* pre_key_records;
	gint32 device_id;
	ec_key_pair* tmp;
	XmppStanzaNode* bundle;
	XmppStanzaNode* _tmp0_;
	XmppStanzaNode* _tmp1_;
	XmppStanzaNode* _tmp2_;
	XmppStanzaNode* _tmp3_;
	XmppStanzaNode* _tmp4_;
	XmppStanzaNode* _tmp5_;
	guint32 _tmp6_;
	guint32 _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	XmppStanzaNode* _tmp10_;
	XmppStanzaNode* _tmp11_;
	ec_key_pair* _tmp12_;
	ec_key_pair* _tmp13_;
	ec_key_pair* _tmp14_;
	ec_key_pair* _tmp15_;
	ec_public_key* _tmp16_;
	ec_public_key* _tmp17_;
	gint _tmp18_;
	guint8* _tmp19_;
	guint8* _tmp20_;
	gint _tmp20__length1;
	gchar* _tmp21_;
	gchar* _tmp22_;
	XmppStanzaNode* _tmp23_;
	XmppStanzaNode* _tmp24_;
	XmppStanzaNode* _tmp25_;
	XmppStanzaNode* _tmp26_;
	XmppStanzaNode* _tmp27_;
	XmppStanzaNode* _tmp28_;
	XmppStanzaNode* _tmp29_;
	XmppStanzaNode* _tmp30_;
	guint8* _tmp31_;
	gint _tmp31__length1;
	gint _tmp32_;
	guint8* _tmp33_;
	gint _tmp33__length1;
	gchar* _tmp34_;
	gchar* _tmp35_;
	XmppStanzaNode* _tmp36_;
	XmppStanzaNode* _tmp37_;
	XmppStanzaNode* _tmp38_;
	XmppStanzaNode* _tmp39_;
	XmppStanzaNode* _tmp40_;
	XmppStanzaNode* _tmp41_;
	XmppStanzaNode* _tmp42_;
	XmppStanzaNode* _tmp43_;
	ec_public_key* _tmp44_;
	ec_public_key* _tmp45_;
	gint _tmp46_;
	guint8* _tmp47_;
	guint8* _tmp48_;
	gint _tmp48__length1;
	gchar* _tmp49_;
	gchar* _tmp50_;
	XmppStanzaNode* _tmp51_;
	XmppStanzaNode* _tmp52_;
	XmppStanzaNode* _tmp53_;
	XmppStanzaNode* _tmp54_;
	XmppStanzaNode* _tmp55_;
	XmppStanzaNode* _tmp56_;
	XmppStanzaNode* prekeys;
	XmppStanzaNode* _tmp57_;
	GeeIterator* _pre_key_record_it;
	GeeIterator* _tmp58_;
	GeeIterator* _tmp59_;
	session_pre_key* pre_key_record;
	GeeIterator* _tmp60_;
	gpointer _tmp61_;
	XmppStanzaNode* _tmp62_;
	XmppStanzaNode* _tmp63_;
	XmppStanzaNode* _tmp64_;
	session_pre_key* _tmp65_;
	guint32 _tmp66_;
	guint32 _tmp67_;
	gchar* _tmp68_;
	gchar* _tmp69_;
	XmppStanzaNode* _tmp70_;
	XmppStanzaNode* _tmp71_;
	session_pre_key* _tmp72_;
	ec_key_pair* _tmp73_;
	ec_key_pair* _tmp74_;
	ec_public_key* _tmp75_;
	ec_public_key* _tmp76_;
	gint _tmp77_;
	guint8* _tmp78_;
	guint8* _tmp79_;
	gint _tmp79__length1;
	gchar* _tmp80_;
	gchar* _tmp81_;
	XmppStanzaNode* _tmp82_;
	XmppStanzaNode* _tmp83_;
	XmppStanzaNode* _tmp84_;
	XmppStanzaNode* _tmp85_;
	XmppStanzaNode* _tmp86_;
	XmppStanzaNode* _tmp87_;
	XmppStanzaNode* _tmp88_;
	XmppStanzaNode* _tmp89_;
	XmppStanzaNode* _tmp90_;
	XmppStanzaNode* _tmp91_;
	gchar* node_id;
	const gchar* _tmp92_;
	gchar* _tmp93_;
	gchar* _tmp94_;
	gchar* _tmp95_;
	gchar* _tmp96_;
	XmppModuleIdentity* _tmp97_;
	gpointer _tmp98_;
	XmppXepPubsubModule* _tmp99_;
	XmppStanzaNode* _tmp100_;
};

struct _DinoPluginsOmemoStreamModuleTryMakeNodePublicData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOmemoStreamModule* self;
	XmppXmppStream* stream;
	gchar* node_id;
	XmppXepDataFormsDataForm* data_form;
	XmppModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppXepPubsubModule* _tmp2_;
	XmppXepDataFormsDataForm* _tmp3_;
	XmppXepDataFormsDataForm* _tmp4_;
	XmppXepDataFormsDataForm* _tmp5_;
	GeeList* _field_list;
	XmppXepDataFormsDataForm* _tmp6_;
	GeeList* _tmp7_;
	gint _field_size;
	GeeList* _tmp8_;
	gint _tmp9_;
	gint _tmp10_;
	gint _field_index;
	gint _tmp11_;
	gint _tmp12_;
	XmppXepDataFormsDataFormField* field;
	GeeList* _tmp13_;
	gpointer _tmp14_;
	gboolean _tmp15_;
	XmppXepDataFormsDataFormField* _tmp16_;
	const gchar* _tmp17_;
	const gchar* _tmp18_;
	XmppXepDataFormsDataFormField* _tmp19_;
	gchar* _tmp20_;
	gchar* _tmp21_;
	XmppXepDataFormsDataFormField* _tmp22_;
	XmppModuleIdentity* _tmp23_;
	gpointer _tmp24_;
	XmppXepPubsubModule* _tmp25_;
	XmppXepDataFormsDataForm* _tmp26_;
};

static gint DinoPluginsOmemoStreamModule_private_offset;
static gpointer dino_plugins_omemo_stream_module_parent_class = NULL;
XmppModuleIdentity* dino_plugins_omemo_stream_module_IDENTITY = NULL;
static GTimeSpan dino_plugins_omemo_stream_module_IGNORE_TIME;
static GTimeSpan dino_plugins_omemo_stream_module_IGNORE_TIME = G_TIME_SPAN_MINUTE;

static guint _xmpp_jid_hash_func_gee_hash_data_func (gconstpointer v,
                                              gpointer self);
static gboolean _xmpp_jid_equals_func_gee_equal_data_func (gconstpointer a,
                                                    gconstpointer b,
                                                    gpointer self);
static void dino_plugins_omemo_stream_module_set_store (DinoPluginsOmemoStreamModule* self,
                                                 OmemoStore* value);
static void dino_plugins_omemo_stream_module_real_attach (XmppXmppStreamModule* base,
                                                   XmppXmppStream* stream);
static void __lambda16_ (DinoPluginsOmemoStreamModule* self,
                  XmppXmppStream* stream,
                  XmppJid* jid,
                  const gchar* id,
                  XmppStanzaNode* node);
static void ___lambda16__xmpp_xep_pubsub_item_listener_delegate_result_func (XmppXmppStream* stream,
                                                                      XmppJid* jid,
                                                                      const gchar* id,
                                                                      XmppStanzaNode* node,
                                                                      gpointer self);
static void dino_plugins_omemo_stream_module_real_detach (XmppXmppStreamModule* base,
                                                   XmppXmppStream* stream);
static void dino_plugins_omemo_stream_module_request_user_devicelist_data_free (gpointer _data);
static gboolean dino_plugins_omemo_stream_module_request_user_devicelist_co (DinoPluginsOmemoStreamModuleRequestUserDevicelistData* _data_);
static Block7Data* block7_data_ref (Block7Data* _data7_);
static void block7_data_unref (void * _userdata_);
static void ___lambda25_ (Block7Data* _data7_,
                   XmppXmppStream* stream,
                   XmppJid* jid,
                   const gchar* id,
                   XmppStanzaNode* node);
static void ____lambda25__xmpp_xep_pubsub_module_on_result (XmppXmppStream* stream,
                                                     XmppJid* jid,
                                                     const gchar* id,
                                                     XmppStanzaNode* node,
                                                     gpointer self);
static void dino_plugins_omemo_stream_module_request_user_devicelist_ready (GObject* source_object,
                                                                     GAsyncResult* _res_,
                                                                     gpointer _user_data_);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
static void ____lambda17_ (Block8Data* _data8_);
static void dino_plugins_omemo_stream_module_try_make_node_public (DinoPluginsOmemoStreamModule* self,
                                                            XmppXmppStream* stream,
                                                            const gchar* node_id,
                                                            GAsyncReadyCallback _callback_,
                                                            gpointer _user_data_);
static void dino_plugins_omemo_stream_module_try_make_node_public_finish (DinoPluginsOmemoStreamModule* self,
                                                                   GAsyncResult* _res_);
static void _____lambda17__gasync_ready_callback (GObject* source_object,
                                           GAsyncResult* res,
                                           gpointer self);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static void ___lambda21_ (Block9Data* _data9_,
                   XmppXmppStream* stream,
                   XmppJid* jid,
                   const gchar* id,
                   XmppStanzaNode* node);
static void dino_plugins_omemo_stream_module_on_other_bundle_result (DinoPluginsOmemoStreamModule* self,
                                                              XmppXmppStream* stream,
                                                              XmppJid* jid,
                                                              gint device_id,
                                                              const gchar* id,
                                                              XmppStanzaNode* node,
                                                              gboolean ignore_if_non_present);
static void ____lambda21__xmpp_xep_pubsub_module_on_result (XmppXmppStream* stream,
                                                     XmppJid* jid,
                                                     const gchar* id,
                                                     XmppStanzaNode* node,
                                                     gpointer self);
static guint8* _vala_array_dup27 (guint8* self,
                           gssize length);
static const char* _omemo_error_code_to_string (int value);
static void dino_plugins_omemo_stream_module_on_self_bundle_result (DinoPluginsOmemoStreamModule* self,
                                                             XmppXmppStream* stream,
                                                             XmppJid* jid,
                                                             const gchar* id,
                                                             XmppStanzaNode* node);
static void _dino_plugins_omemo_stream_module_on_self_bundle_result_xmpp_xep_pubsub_module_on_result (XmppXmppStream* stream,
                                                                                               XmppJid* jid,
                                                                                               const gchar* id,
                                                                                               XmppStanzaNode* node,
                                                                                               gpointer self);
static void dino_plugins_omemo_stream_module_publish_bundles_data_free (gpointer _data);
static gboolean dino_plugins_omemo_stream_module_publish_bundles_co (DinoPluginsOmemoStreamModulePublishBundlesData* _data_);
static void dino_plugins_omemo_stream_module_publish_bundles_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_);
static void dino_plugins_omemo_stream_module_try_make_node_public_data_free (gpointer _data);
static gboolean dino_plugins_omemo_stream_module_try_make_node_public_co (DinoPluginsOmemoStreamModuleTryMakeNodePublicData* _data_);
static void dino_plugins_omemo_stream_module_try_make_node_public_ready (GObject* source_object,
                                                                  GAsyncResult* _res_,
                                                                  gpointer _user_data_);
static gchar* dino_plugins_omemo_stream_module_real_get_ns (XmppXmppStreamModule* base);
static gchar* dino_plugins_omemo_stream_module_real_get_id (XmppXmppStreamModule* base);
static void g_cclosure_user_marshal_VOID__XMPP_JID_OBJECT (GClosure * closure,
                                                    GValue * return_value,
                                                    guint n_param_values,
                                                    const GValue * param_values,
                                                    gpointer invocation_hint,
                                                    gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__XMPP_JID_INT_DINO_PLUGINS_OMEMO_BUNDLE (GClosure * closure,
                                                                           GValue * return_value,
                                                                           guint n_param_values,
                                                                           const GValue * param_values,
                                                                           gpointer invocation_hint,
                                                                           gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__XMPP_JID_INT (GClosure * closure,
                                                 GValue * return_value,
                                                 guint n_param_values,
                                                 const GValue * param_values,
                                                 gpointer invocation_hint,
                                                 gpointer marshal_data);
static void dino_plugins_omemo_stream_module_finalize (GObject * obj);
static GType dino_plugins_omemo_stream_module_get_type_once (void);
static void _vala_dino_plugins_omemo_stream_module_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec);
static void _vala_dino_plugins_omemo_stream_module_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_plugins_omemo_stream_module_get_instance_private (DinoPluginsOmemoStreamModule* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsOmemoStreamModule_private_offset);
}

static guint
_xmpp_jid_hash_func_gee_hash_data_func (gconstpointer v,
                                        gpointer self)
{
	guint result;
	result = xmpp_jid_hash_func ((XmppJid*) v);
	return result;
}

static gboolean
_xmpp_jid_equals_func_gee_equal_data_func (gconstpointer a,
                                           gconstpointer b,
                                           gpointer self)
{
	gboolean result;
	result = xmpp_jid_equals_func ((XmppJid*) a, (XmppJid*) b);
	return result;
}

DinoPluginsOmemoStreamModule*
dino_plugins_omemo_stream_module_construct (GType object_type,
                                            OmemoStore* store)
{
	DinoPluginsOmemoStreamModule * self = NULL;
	g_return_val_if_fail (store != NULL, NULL);
	self = (DinoPluginsOmemoStreamModule*) xmpp_xmpp_stream_module_construct (object_type);
	dino_plugins_omemo_stream_module_set_store (self, store);
	return self;
}

DinoPluginsOmemoStreamModule*
dino_plugins_omemo_stream_module_new (OmemoStore* store)
{
	return dino_plugins_omemo_stream_module_construct (DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, store);
}

static void
__lambda16_ (DinoPluginsOmemoStreamModule* self,
             XmppXmppStream* stream,
             XmppJid* jid,
             const gchar* id,
             XmppStanzaNode* node)
{
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (id != NULL);
	_tmp0_ = dino_plugins_omemo_stream_module_parse_device_list (self, stream, jid, id, node);
	_tmp1_ = _tmp0_;
	_g_object_unref0 (_tmp1_);
}

static void
___lambda16__xmpp_xep_pubsub_item_listener_delegate_result_func (XmppXmppStream* stream,
                                                                 XmppJid* jid,
                                                                 const gchar* id,
                                                                 XmppStanzaNode* node,
                                                                 gpointer self)
{
	__lambda16_ ((DinoPluginsOmemoStreamModule*) self, stream, jid, id, node);
}

static void
dino_plugins_omemo_stream_module_real_attach (XmppXmppStreamModule* base,
                                              XmppXmppStream* stream)
{
	DinoPluginsOmemoStreamModule * self;
	XmppModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppXepPubsubModule* _tmp2_;
	self = (DinoPluginsOmemoStreamModule*) base;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_xep_pubsub_module_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppXepPubsubModule*) _tmp1_;
	xmpp_xep_pubsub_module_add_filtered_notification (_tmp2_, stream, DINO_PLUGINS_OMEMO_NODE_DEVICELIST, ___lambda16__xmpp_xep_pubsub_item_listener_delegate_result_func, g_object_ref (self), g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (_tmp2_);
}

static void
dino_plugins_omemo_stream_module_real_detach (XmppXmppStreamModule* base,
                                              XmppXmppStream* stream)
{
	DinoPluginsOmemoStreamModule * self;
	XmppModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppXepPubsubModule* _tmp2_;
	self = (DinoPluginsOmemoStreamModule*) base;
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_xep_pubsub_module_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppXepPubsubModule*) _tmp1_;
	xmpp_xep_pubsub_module_remove_filtered_notification (_tmp2_, stream, DINO_PLUGINS_OMEMO_NODE_DEVICELIST);
	_g_object_unref0 (_tmp2_);
}

static void
dino_plugins_omemo_stream_module_request_user_devicelist_data_free (gpointer _data)
{
	DinoPluginsOmemoStreamModuleRequestUserDevicelistData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_xmpp_jid_unref0 (_data_->jid);
	_g_object_unref0 (_data_->result);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOmemoStreamModuleRequestUserDevicelistData, _data_);
}

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

static gpointer
_xmpp_jid_ref0 (gpointer self)
{
	return self ? xmpp_jid_ref (self) : NULL;
}

void
dino_plugins_omemo_stream_module_request_user_devicelist (DinoPluginsOmemoStreamModule* self,
                                                          XmppXmppStream* stream,
                                                          XmppJid* jid,
                                                          GAsyncReadyCallback _callback_,
                                                          gpointer _user_data_)
{
	DinoPluginsOmemoStreamModuleRequestUserDevicelistData* _data_;
	DinoPluginsOmemoStreamModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppJid* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	_data_ = g_slice_new0 (DinoPluginsOmemoStreamModuleRequestUserDevicelistData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_omemo_stream_module_request_user_devicelist_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	dino_plugins_omemo_stream_module_request_user_devicelist_co (_data_);
}

GeeArrayList*
dino_plugins_omemo_stream_module_request_user_devicelist_finish (DinoPluginsOmemoStreamModule* self,
                                                                 GAsyncResult* _res_)
{
	GeeArrayList* result;
	DinoPluginsOmemoStreamModuleRequestUserDevicelistData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	_data_->result = NULL;
	return result;
}

static Block7Data*
block7_data_ref (Block7Data* _data7_)
{
	g_atomic_int_inc (&_data7_->_ref_count_);
	return _data7_;
}

static void
block7_data_unref (void * _userdata_)
{
	Block7Data* _data7_;
	_data7_ = (Block7Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data7_->_ref_count_)) {
		DinoPluginsOmemoStreamModule* self;
		self = _data7_->self;
		_gee_promise_unref0 (_data7_->promise);
		_g_object_unref0 (self);
		g_slice_free (Block7Data, _data7_);
	}
}

static void
___lambda25_ (Block7Data* _data7_,
              XmppXmppStream* stream,
              XmppJid* jid,
              const gchar* id,
              XmppStanzaNode* node)
{
	DinoPluginsOmemoStreamModule* self;
	GeeArrayList* device_list = NULL;
	GeeArrayList* _tmp0_;
	GeePromise* _tmp1_;
	GeeArrayList* _tmp2_;
	GeeHashMap* _tmp3_;
	self = _data7_->self;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = dino_plugins_omemo_stream_module_parse_device_list (self, stream, jid, id, node);
	device_list = _tmp0_;
	_tmp1_ = _data7_->promise;
	_tmp2_ = _g_object_ref0 (device_list);
	gee_promise_set_value (_tmp1_, _tmp2_);
	_tmp3_ = self->priv->active_devicelist_requests;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp3_, jid, NULL);
	_g_object_unref0 (device_list);
}

static void
____lambda25__xmpp_xep_pubsub_module_on_result (XmppXmppStream* stream,
                                                XmppJid* jid,
                                                const gchar* id,
                                                XmppStanzaNode* node,
                                                gpointer self)
{
	___lambda25_ (self, stream, jid, id, node);
}

static void
dino_plugins_omemo_stream_module_request_user_devicelist_ready (GObject* source_object,
                                                                GAsyncResult* _res_,
                                                                gpointer _user_data_)
{
	DinoPluginsOmemoStreamModuleRequestUserDevicelistData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_omemo_stream_module_request_user_devicelist_co (_data_);
}

static gboolean
dino_plugins_omemo_stream_module_request_user_devicelist_co (DinoPluginsOmemoStreamModuleRequestUserDevicelistData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _data_->self->priv->active_devicelist_requests;
	_data_->_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _data_->_tmp0_, _data_->jid);
	_data_->future = (GeeFuture*) _data_->_tmp1_;
	_data_->_tmp2_ = _data_->future;
	if (_data_->_tmp2_ == NULL) {
		_data_->_data7_ = g_slice_new0 (Block7Data);
		_data_->_data7_->_ref_count_ = 1;
		_data_->_data7_->self = g_object_ref (_data_->self);
		_data_->_tmp3_ = gee_promise_new (GEE_TYPE_ARRAY_LIST, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref);
		_data_->_data7_->promise = _data_->_tmp3_;
		_data_->_tmp4_ = _data_->_data7_->promise;
		_data_->_tmp5_ = gee_promise_get_future (_data_->_tmp4_);
		_data_->_tmp6_ = _data_->_tmp5_;
		_data_->_tmp7_ = _g_object_ref0 (_data_->_tmp6_);
		_g_object_unref0 (_data_->future);
		_data_->future = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->self->priv->active_devicelist_requests;
		_data_->_tmp9_ = _data_->future;
		gee_abstract_map_set ((GeeAbstractMap*) _data_->_tmp8_, _data_->jid, _data_->_tmp9_);
		_data_->_tmp10_ = xmpp_xep_pubsub_module_IDENTITY;
		_data_->_tmp11_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp10_);
		_data_->_tmp12_ = (XmppXepPubsubModule*) _data_->_tmp11_;
		xmpp_xep_pubsub_module_request (_data_->_tmp12_, _data_->stream, _data_->jid, DINO_PLUGINS_OMEMO_NODE_DEVICELIST, ____lambda25__xmpp_xep_pubsub_module_on_result, block7_data_ref (_data_->_data7_), block7_data_unref);
		_g_object_unref0 (_data_->_tmp12_);
		block7_data_unref (_data_->_data7_);
		_data_->_data7_ = NULL;
	}
	{
		_data_->_tmp13_ = _data_->future;
		_data_->_state_ = 1;
		gee_future_wait_async (_data_->_tmp13_, dino_plugins_omemo_stream_module_request_user_devicelist_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp14_ = gee_future_wait_finish (_data_->_tmp13_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp15_ = _g_object_ref0 ((GeeArrayList*) _data_->_tmp14_);
		_data_->device_list = _data_->_tmp15_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			if (_data_->_inner_error0_->domain == GEE_FUTURE_ERROR) {
				goto __catch0_gee_future_error;
			}
			_g_object_unref0 (_data_->future);
			g_critical ("file %s: line %d: unexpected 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;
		}
		_data_->result = _data_->device_list;
		_g_object_unref0 (_data_->future);
		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_gee_future_error:
	{
		_data_->_error_ = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp16_ = _data_->_error_;
		_data_->_tmp17_ = _data_->_tmp16_->message;
		g_warning ("stream_module.vala:59: Future error when waiting for device list: %s", _data_->_tmp17_);
		_data_->_tmp18_ = gee_array_list_new (G_TYPE_INT, NULL, NULL, NULL, NULL, NULL);
		_data_->result = _data_->_tmp18_;
		_g_error_free0 (_data_->_error_);
		_g_object_unref0 (_data_->future);
		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;
	}
	__finally0:
	_g_object_unref0 (_data_->future);
	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;
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		DinoPluginsOmemoStreamModule* self;
		self = _data8_->self;
		_g_object_unref0 (_data8_->stream);
		_g_object_unref0 (self);
		g_slice_free (Block8Data, _data8_);
	}
}

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

static void
____lambda17_ (Block8Data* _data8_)
{
	DinoPluginsOmemoStreamModule* self;
	self = _data8_->self;
	dino_plugins_omemo_stream_module_try_make_node_public (self, _data8_->stream, DINO_PLUGINS_OMEMO_NODE_DEVICELIST, NULL, NULL);
}

static void
_____lambda17__gasync_ready_callback (GObject* source_object,
                                      GAsyncResult* res,
                                      gpointer self)
{
	____lambda17_ (self);
	block8_data_unref (self);
}

GeeArrayList*
dino_plugins_omemo_stream_module_parse_device_list (DinoPluginsOmemoStreamModule* self,
                                                    XmppXmppStream* stream,
                                                    XmppJid* jid,
                                                    const gchar* id,
                                                    XmppStanzaNode* node_)
{
	Block8Data* _data8_;
	XmppXmppStream* _tmp0_;
	GeeArrayList* device_list = NULL;
	GeeArrayList* _tmp1_;
	XmppStanzaNode* _tmp2_ = NULL;
	XmppStanzaNode* _tmp3_;
	XmppStanzaNode* node = NULL;
	XmppStanzaNode* _tmp7_;
	XmppJid* my_jid = NULL;
	XmppFlagIdentity* _tmp8_;
	gpointer _tmp9_;
	XmppBindFlag* _tmp10_;
	XmppJid* _tmp11_;
	XmppJid* _tmp12_;
	XmppJid* _tmp13_;
	XmppJid* _tmp14_;
	gboolean _tmp15_ = FALSE;
	XmppJid* _tmp16_;
	GeeArrayList* _tmp60_;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (stream != NULL, NULL);
	g_return_val_if_fail (jid != NULL, NULL);
	_data8_ = g_slice_new0 (Block8Data);
	_data8_->_ref_count_ = 1;
	_data8_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data8_->stream);
	_data8_->stream = _tmp0_;
	_tmp1_ = gee_array_list_new (G_TYPE_INT, NULL, NULL, NULL, NULL, NULL);
	device_list = _tmp1_;
	_tmp3_ = _xmpp_stanza_entry_ref0 (node_);
	_tmp2_ = _tmp3_;
	if (_tmp2_ == NULL) {
		XmppStanzaNode* _tmp4_;
		XmppStanzaNode* _tmp5_;
		XmppStanzaNode* _tmp6_;
		_tmp4_ = xmpp_stanza_node_new_build ("list", DINO_PLUGINS_OMEMO_NS_URI, NULL, NULL);
		_tmp5_ = _tmp4_;
		_tmp6_ = xmpp_stanza_node_add_self_xmlns (_tmp5_);
		_xmpp_stanza_entry_unref0 (_tmp2_);
		_tmp2_ = _tmp6_;
		_xmpp_stanza_entry_unref0 (_tmp5_);
	}
	_tmp7_ = _tmp2_;
	_tmp2_ = NULL;
	node = _tmp7_;
	_tmp8_ = xmpp_bind_flag_IDENTITY;
	_tmp9_ = xmpp_xmpp_stream_get_flag (_data8_->stream, XMPP_BIND_TYPE_FLAG, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp8_);
	_tmp10_ = (XmppBindFlag*) _tmp9_;
	_tmp11_ = _tmp10_->my_jid;
	_tmp12_ = _xmpp_jid_ref0 (_tmp11_);
	_tmp13_ = _tmp12_;
	_g_object_unref0 (_tmp10_);
	my_jid = _tmp13_;
	_tmp14_ = my_jid;
	if (_tmp14_ == NULL) {
		result = device_list;
		_xmpp_jid_unref0 (my_jid);
		_xmpp_stanza_entry_unref0 (node);
		_xmpp_stanza_entry_unref0 (_tmp2_);
		block8_data_unref (_data8_);
		_data8_ = NULL;
		return result;
	}
	_tmp16_ = my_jid;
	if (xmpp_jid_equals_bare (jid, _tmp16_)) {
		OmemoStore* _tmp17_;
		guint32 _tmp18_;
		guint32 _tmp19_;
		_tmp17_ = self->priv->_store;
		_tmp18_ = omemo_store_get_local_registration_id (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp15_ = _tmp19_ != ((guint32) 0);
	} else {
		_tmp15_ = FALSE;
	}
	if (_tmp15_) {
		gboolean am_on_devicelist = FALSE;
		am_on_devicelist = FALSE;
		{
			GeeList* _device_node_list = NULL;
			XmppStanzaNode* _tmp20_;
			GeeList* _tmp21_;
			gint _device_node_size = 0;
			GeeList* _tmp22_;
			gint _tmp23_;
			gint _tmp24_;
			gint _device_node_index = 0;
			_tmp20_ = node;
			_tmp21_ = xmpp_stanza_node_get_subnodes (_tmp20_, "device", NULL, FALSE);
			_device_node_list = _tmp21_;
			_tmp22_ = _device_node_list;
			_tmp23_ = gee_collection_get_size ((GeeCollection*) _tmp22_);
			_tmp24_ = _tmp23_;
			_device_node_size = _tmp24_;
			_device_node_index = -1;
			while (TRUE) {
				gint _tmp25_;
				gint _tmp26_;
				XmppStanzaNode* device_node = NULL;
				GeeList* _tmp27_;
				gpointer _tmp28_;
				gint device_id = 0;
				XmppStanzaNode* _tmp29_;
				OmemoStore* _tmp30_;
				guint32 _tmp31_;
				guint32 _tmp32_;
				_device_node_index = _device_node_index + 1;
				_tmp25_ = _device_node_index;
				_tmp26_ = _device_node_size;
				if (!(_tmp25_ < _tmp26_)) {
					break;
				}
				_tmp27_ = _device_node_list;
				_tmp28_ = gee_list_get (_tmp27_, _device_node_index);
				device_node = (XmppStanzaNode*) _tmp28_;
				_tmp29_ = device_node;
				device_id = xmpp_stanza_node_get_attribute_int (_tmp29_, "id", -1, NULL);
				_tmp30_ = self->priv->_store;
				_tmp31_ = omemo_store_get_local_registration_id (_tmp30_);
				_tmp32_ = _tmp31_;
				if (_tmp32_ == ((guint32) device_id)) {
					am_on_devicelist = TRUE;
				}
				_xmpp_stanza_entry_unref0 (device_node);
			}
			_g_object_unref0 (_device_node_list);
		}
		if (!am_on_devicelist) {
			XmppStanzaNode* _tmp33_;
			XmppStanzaNode* _tmp34_;
			XmppStanzaNode* _tmp35_;
			OmemoStore* _tmp36_;
			guint32 _tmp37_;
			guint32 _tmp38_;
			gchar* _tmp39_;
			gchar* _tmp40_;
			XmppStanzaNode* _tmp41_;
			XmppStanzaNode* _tmp42_;
			XmppStanzaNode* _tmp43_;
			XmppStanzaNode* _tmp44_;
			XmppModuleIdentity* _tmp45_;
			gpointer _tmp46_;
			XmppXepPubsubModule* _tmp47_;
			XmppStanzaNode* _tmp48_;
			g_debug ("stream_module.vala:79: Not on device list, adding id");
			_tmp33_ = node;
			_tmp34_ = xmpp_stanza_node_new_build ("device", DINO_PLUGINS_OMEMO_NS_URI, NULL, NULL);
			_tmp35_ = _tmp34_;
			_tmp36_ = self->priv->_store;
			_tmp37_ = omemo_store_get_local_registration_id (_tmp36_);
			_tmp38_ = _tmp37_;
			_tmp39_ = g_strdup_printf ("%u", _tmp38_);
			_tmp40_ = _tmp39_;
			_tmp41_ = xmpp_stanza_node_put_attribute (_tmp35_, "id", _tmp40_, NULL);
			_tmp42_ = _tmp41_;
			_tmp43_ = xmpp_stanza_node_put_node (_tmp33_, _tmp42_);
			_tmp44_ = _tmp43_;
			_xmpp_stanza_entry_unref0 (_tmp44_);
			_xmpp_stanza_entry_unref0 (_tmp42_);
			_g_free0 (_tmp40_);
			_xmpp_stanza_entry_unref0 (_tmp35_);
			_tmp45_ = xmpp_xep_pubsub_module_IDENTITY;
			_tmp46_ = xmpp_xmpp_stream_get_module (_data8_->stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp45_);
			_tmp47_ = (XmppXepPubsubModule*) _tmp46_;
			_tmp48_ = node;
			xmpp_xep_pubsub_module_publish (_tmp47_, _data8_->stream, jid, DINO_PLUGINS_OMEMO_NODE_DEVICELIST, id, _tmp48_, NULL, TRUE, _____lambda17__gasync_ready_callback, block8_data_ref (_data8_));
			_g_object_unref0 (_tmp47_);
		}
		dino_plugins_omemo_stream_module_publish_bundles_if_needed (self, _data8_->stream, jid);
	}
	{
		GeeList* _device_node_list = NULL;
		XmppStanzaNode* _tmp49_;
		GeeList* _tmp50_;
		gint _device_node_size = 0;
		GeeList* _tmp51_;
		gint _tmp52_;
		gint _tmp53_;
		gint _device_node_index = 0;
		_tmp49_ = node;
		_tmp50_ = xmpp_stanza_node_get_subnodes (_tmp49_, "device", NULL, FALSE);
		_device_node_list = _tmp50_;
		_tmp51_ = _device_node_list;
		_tmp52_ = gee_collection_get_size ((GeeCollection*) _tmp51_);
		_tmp53_ = _tmp52_;
		_device_node_size = _tmp53_;
		_device_node_index = -1;
		while (TRUE) {
			gint _tmp54_;
			gint _tmp55_;
			XmppStanzaNode* device_node = NULL;
			GeeList* _tmp56_;
			gpointer _tmp57_;
			GeeArrayList* _tmp58_;
			XmppStanzaNode* _tmp59_;
			_device_node_index = _device_node_index + 1;
			_tmp54_ = _device_node_index;
			_tmp55_ = _device_node_size;
			if (!(_tmp54_ < _tmp55_)) {
				break;
			}
			_tmp56_ = _device_node_list;
			_tmp57_ = gee_list_get (_tmp56_, _device_node_index);
			device_node = (XmppStanzaNode*) _tmp57_;
			_tmp58_ = device_list;
			_tmp59_ = device_node;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp58_, (gpointer) ((gintptr) xmpp_stanza_node_get_attribute_int (_tmp59_, "id", -1, NULL)));
			_xmpp_stanza_entry_unref0 (device_node);
		}
		_g_object_unref0 (_device_node_list);
	}
	_tmp60_ = device_list;
	g_signal_emit (self, dino_plugins_omemo_stream_module_signals[DINO_PLUGINS_OMEMO_STREAM_MODULE_DEVICE_LIST_LOADED_SIGNAL], 0, jid, _tmp60_);
	result = device_list;
	_xmpp_jid_unref0 (my_jid);
	_xmpp_stanza_entry_unref0 (node);
	_xmpp_stanza_entry_unref0 (_tmp2_);
	block8_data_unref (_data8_);
	_data8_ = NULL;
	return result;
}

void
dino_plugins_omemo_stream_module_fetch_bundles (DinoPluginsOmemoStreamModule* self,
                                                XmppXmppStream* stream,
                                                XmppJid* jid,
                                                GeeList* devices)
{
	signal_protocol_address* address = NULL;
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	signal_protocol_address* _tmp5_;
	signal_protocol_address* _tmp6_;
	signal_protocol_address* _tmp18_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (devices != NULL);
	_tmp0_ = xmpp_jid_get_bare_jid (jid);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = xmpp_jid_to_string (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = signal_protocol_address_new (_tmp4_, (gint32) 0);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	_xmpp_jid_unref0 (_tmp2_);
	address = _tmp6_;
	{
		GeeList* _device_id_list = NULL;
		gint _device_id_size = 0;
		GeeList* _tmp7_;
		gint _tmp8_;
		gint _tmp9_;
		gint _device_id_index = 0;
		_device_id_list = devices;
		_tmp7_ = _device_id_list;
		_tmp8_ = gee_collection_get_size ((GeeCollection*) _tmp7_);
		_tmp9_ = _tmp8_;
		_device_id_size = _tmp9_;
		_device_id_index = -1;
		while (TRUE) {
			gint _tmp10_;
			gint _tmp11_;
			gint32 device_id = 0;
			GeeList* _tmp12_;
			gpointer _tmp13_;
			_device_id_index = _device_id_index + 1;
			_tmp10_ = _device_id_index;
			_tmp11_ = _device_id_size;
			if (!(_tmp10_ < _tmp11_)) {
				break;
			}
			_tmp12_ = _device_id_list;
			_tmp13_ = gee_list_get (_tmp12_, _device_id_index);
			device_id = (gint32) ((gintptr) _tmp13_);
			if (!dino_plugins_omemo_stream_module_is_ignored_device (self, jid, device_id)) {
				signal_protocol_address* _tmp14_;
				_tmp14_ = address;
				signal_protocol_address_set_device_id (_tmp14_, device_id);
				{
					gboolean _tmp15_ = FALSE;
					OmemoStore* _tmp16_;
					signal_protocol_address* _tmp17_;
					_tmp16_ = self->priv->_store;
					_tmp17_ = address;
					_tmp15_ = omemo_store_contains_session (_tmp16_, _tmp17_, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						goto __catch0_g_error;
					}
					if (!_tmp15_) {
						dino_plugins_omemo_stream_module_fetch_bundle (self, stream, jid, (gint) device_id, TRUE);
					}
				}
				goto __finally0;
				__catch0_g_error:
				{
					g_clear_error (&_inner_error0_);
				}
				__finally0:
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_signal_protocol_address_free0 (address);
					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;
				}
			}
		}
	}
	_tmp18_ = address;
	signal_protocol_address_set_device_id (_tmp18_, (gint32) 0);
	_signal_protocol_address_free0 (address);
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		DinoPluginsOmemoStreamModule* self;
		self = _data9_->self;
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}

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 void
___lambda21_ (Block9Data* _data9_,
              XmppXmppStream* stream,
              XmppJid* jid,
              const gchar* id,
              XmppStanzaNode* node)
{
	DinoPluginsOmemoStreamModule* self;
	self = _data9_->self;
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	dino_plugins_omemo_stream_module_on_other_bundle_result (self, stream, jid, _data9_->device_id, id, node, _data9_->ignore_if_non_present);
}

static void
____lambda21__xmpp_xep_pubsub_module_on_result (XmppXmppStream* stream,
                                                XmppJid* jid,
                                                const gchar* id,
                                                XmppStanzaNode* node,
                                                gpointer self)
{
	___lambda21_ (self, stream, jid, id, node);
}

void
dino_plugins_omemo_stream_module_fetch_bundle (DinoPluginsOmemoStreamModule* self,
                                               XmppXmppStream* stream,
                                               XmppJid* jid,
                                               gint device_id,
                                               gboolean ignore_if_non_present)
{
	Block9Data* _data9_;
	GeeConcurrentSet* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	XmppJid* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gboolean _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_data9_->self = g_object_ref (self);
	_data9_->device_id = device_id;
	_data9_->ignore_if_non_present = ignore_if_non_present;
	_tmp0_ = self->priv->active_bundle_requests;
	_tmp1_ = xmpp_jid_get_bare_jid (jid);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_jid_to_string (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = g_strdup_printf ("%i", _data9_->device_id);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strconcat (":", _tmp7_, NULL);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strconcat (_tmp5_, _tmp9_, NULL);
	_tmp11_ = _tmp10_;
	_tmp12_ = gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, _tmp11_);
	_g_free0 (_tmp11_);
	_g_free0 (_tmp9_);
	_g_free0 (_tmp7_);
	_g_free0 (_tmp5_);
	_xmpp_jid_unref0 (_tmp3_);
	if (_tmp12_) {
		XmppJid* _tmp13_;
		XmppJid* _tmp14_;
		XmppJid* _tmp15_;
		gchar* _tmp16_;
		gchar* _tmp17_;
		XmppModuleIdentity* _tmp18_;
		gpointer _tmp19_;
		XmppXepPubsubModule* _tmp20_;
		XmppJid* _tmp21_;
		XmppJid* _tmp22_;
		XmppJid* _tmp23_;
		const gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		gchar* _tmp28_;
		_tmp13_ = xmpp_jid_get_bare_jid (jid);
		_tmp14_ = _tmp13_;
		_tmp15_ = _tmp14_;
		_tmp16_ = xmpp_jid_to_string (_tmp15_);
		_tmp17_ = _tmp16_;
		g_debug ("stream_module.vala:115: Asking for bundle for %s/%d", _tmp17_, _data9_->device_id);
		_g_free0 (_tmp17_);
		_xmpp_jid_unref0 (_tmp15_);
		_tmp18_ = xmpp_xep_pubsub_module_IDENTITY;
		_tmp19_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp18_);
		_tmp20_ = (XmppXepPubsubModule*) _tmp19_;
		_tmp21_ = xmpp_jid_get_bare_jid (jid);
		_tmp22_ = _tmp21_;
		_tmp23_ = _tmp22_;
		_tmp24_ = string_to_string (DINO_PLUGINS_OMEMO_NODE_BUNDLES);
		_tmp25_ = g_strdup_printf ("%i", _data9_->device_id);
		_tmp26_ = _tmp25_;
		_tmp27_ = g_strconcat (_tmp24_, ":", _tmp26_, NULL);
		_tmp28_ = _tmp27_;
		xmpp_xep_pubsub_module_request (_tmp20_, stream, _tmp23_, _tmp28_, ____lambda21__xmpp_xep_pubsub_module_on_result, block9_data_ref (_data9_), block9_data_unref);
		_g_free0 (_tmp28_);
		_g_free0 (_tmp26_);
		_xmpp_jid_unref0 (_tmp23_);
		_g_object_unref0 (_tmp20_);
	}
	block9_data_unref (_data9_);
	_data9_ = NULL;
}

void
dino_plugins_omemo_stream_module_ignore_device (DinoPluginsOmemoStreamModule* self,
                                                XmppJid* jid,
                                                gint32 device_id)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (jid != NULL);
	if (device_id <= ((gint32) 0)) {
		return;
	}
	{
		GeeMap* _tmp0_;
		_tmp0_ = self->priv->device_ignore_time;
		g_rec_mutex_lock (&self->priv->__lock_device_ignore_time);
		{
			GeeMap* _tmp1_;
			XmppJid* _tmp2_;
			XmppJid* _tmp3_;
			XmppJid* _tmp4_;
			gchar* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			gchar* _tmp11_;
			gchar* _tmp12_;
			GDateTime* _tmp13_;
			GDateTime* _tmp14_;
			_tmp1_ = self->priv->device_ignore_time;
			_tmp2_ = xmpp_jid_get_bare_jid (jid);
			_tmp3_ = _tmp2_;
			_tmp4_ = _tmp3_;
			_tmp5_ = xmpp_jid_to_string (_tmp4_);
			_tmp6_ = _tmp5_;
			_tmp7_ = g_strdup_printf ("%i", device_id);
			_tmp8_ = _tmp7_;
			_tmp9_ = g_strconcat (":", _tmp8_, NULL);
			_tmp10_ = _tmp9_;
			_tmp11_ = g_strconcat (_tmp6_, _tmp10_, NULL);
			_tmp12_ = _tmp11_;
			_tmp13_ = g_date_time_new_now_utc ();
			_tmp14_ = _tmp13_;
			gee_map_set (_tmp1_, _tmp12_, _tmp14_);
			_g_date_time_unref0 (_tmp14_);
			_g_free0 (_tmp12_);
			_g_free0 (_tmp10_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp6_);
			_xmpp_jid_unref0 (_tmp4_);
		}
		__finally0:
		{
			GeeMap* _tmp15_;
			_tmp15_ = self->priv->device_ignore_time;
			g_rec_mutex_unlock (&self->priv->__lock_device_ignore_time);
		}
		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;
		}
	}
}

void
dino_plugins_omemo_stream_module_unignore_device (DinoPluginsOmemoStreamModule* self,
                                                  XmppJid* jid,
                                                  gint32 device_id)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (jid != NULL);
	if (device_id <= ((gint32) 0)) {
		return;
	}
	{
		GeeMap* _tmp0_;
		_tmp0_ = self->priv->device_ignore_time;
		g_rec_mutex_lock (&self->priv->__lock_device_ignore_time);
		{
			GeeMap* _tmp1_;
			XmppJid* _tmp2_;
			XmppJid* _tmp3_;
			XmppJid* _tmp4_;
			gchar* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			gchar* _tmp11_;
			gchar* _tmp12_;
			_tmp1_ = self->priv->device_ignore_time;
			_tmp2_ = xmpp_jid_get_bare_jid (jid);
			_tmp3_ = _tmp2_;
			_tmp4_ = _tmp3_;
			_tmp5_ = xmpp_jid_to_string (_tmp4_);
			_tmp6_ = _tmp5_;
			_tmp7_ = g_strdup_printf ("%i", device_id);
			_tmp8_ = _tmp7_;
			_tmp9_ = g_strconcat (":", _tmp8_, NULL);
			_tmp10_ = _tmp9_;
			_tmp11_ = g_strconcat (_tmp6_, _tmp10_, NULL);
			_tmp12_ = _tmp11_;
			gee_map_unset (_tmp1_, _tmp12_, NULL);
			_g_free0 (_tmp12_);
			_g_free0 (_tmp10_);
			_g_free0 (_tmp8_);
			_g_free0 (_tmp6_);
			_xmpp_jid_unref0 (_tmp4_);
		}
		__finally0:
		{
			GeeMap* _tmp13_;
			_tmp13_ = self->priv->device_ignore_time;
			g_rec_mutex_unlock (&self->priv->__lock_device_ignore_time);
		}
		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;
		}
	}
}

gboolean
dino_plugins_omemo_stream_module_is_ignored_device (DinoPluginsOmemoStreamModule* self,
                                                    XmppJid* jid,
                                                    gint32 device_id)
{
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (jid != NULL, FALSE);
	if (device_id <= ((gint32) 0)) {
		result = TRUE;
		return result;
	}
	{
		GeeMap* _tmp0_;
		_tmp0_ = self->priv->device_ignore_time;
		g_rec_mutex_lock (&self->priv->__lock_device_ignore_time);
		{
			gchar* id = NULL;
			XmppJid* _tmp1_;
			XmppJid* _tmp2_;
			XmppJid* _tmp3_;
			gchar* _tmp4_;
			gchar* _tmp5_;
			gchar* _tmp6_;
			gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			gchar* _tmp10_;
			gchar* _tmp11_;
			GeeMap* _tmp12_;
			const gchar* _tmp13_;
			_tmp1_ = xmpp_jid_get_bare_jid (jid);
			_tmp2_ = _tmp1_;
			_tmp3_ = _tmp2_;
			_tmp4_ = xmpp_jid_to_string (_tmp3_);
			_tmp5_ = _tmp4_;
			_tmp6_ = g_strdup_printf ("%i", device_id);
			_tmp7_ = _tmp6_;
			_tmp8_ = g_strconcat (":", _tmp7_, NULL);
			_tmp9_ = _tmp8_;
			_tmp10_ = g_strconcat (_tmp5_, _tmp9_, NULL);
			_tmp11_ = _tmp10_;
			_g_free0 (_tmp9_);
			_g_free0 (_tmp7_);
			_g_free0 (_tmp5_);
			_xmpp_jid_unref0 (_tmp3_);
			id = _tmp11_;
			_tmp12_ = self->priv->device_ignore_time;
			_tmp13_ = id;
			if (gee_map_has_key (_tmp12_, _tmp13_)) {
				GDateTime* _tmp14_;
				GDateTime* _tmp15_;
				GeeMap* _tmp16_;
				const gchar* _tmp17_;
				gpointer _tmp18_;
				GDateTime* _tmp19_;
				gboolean _tmp20_;
				_tmp14_ = g_date_time_new_now_utc ();
				_tmp15_ = _tmp14_;
				_tmp16_ = self->priv->device_ignore_time;
				_tmp17_ = id;
				_tmp18_ = gee_map_get (_tmp16_, _tmp17_);
				_tmp19_ = (GDateTime*) _tmp18_;
				_tmp20_ = g_date_time_difference (_tmp15_, _tmp19_) < dino_plugins_omemo_stream_module_IGNORE_TIME;
				_g_date_time_unref0 (_tmp19_);
				_g_date_time_unref0 (_tmp15_);
				result = _tmp20_;
				_g_free0 (id);
				{
					GeeMap* _tmp21_;
					_tmp21_ = self->priv->device_ignore_time;
					g_rec_mutex_unlock (&self->priv->__lock_device_ignore_time);
				}
				return result;
			}
			_g_free0 (id);
		}
		__finally0:
		{
			GeeMap* _tmp22_;
			_tmp22_ = self->priv->device_ignore_time;
			g_rec_mutex_unlock (&self->priv->__lock_device_ignore_time);
		}
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp23_ = FALSE;
			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 _tmp23_;
		}
	}
	result = FALSE;
	return result;
}

void
dino_plugins_omemo_stream_module_clear_device_list (DinoPluginsOmemoStreamModule* self,
                                                    XmppXmppStream* stream)
{
	XmppModuleIdentity* _tmp0_;
	gpointer _tmp1_;
	XmppXepPubsubModule* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	_tmp0_ = xmpp_xep_pubsub_module_IDENTITY;
	_tmp1_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp0_);
	_tmp2_ = (XmppXepPubsubModule*) _tmp1_;
	xmpp_xep_pubsub_module_delete_node (_tmp2_, stream, NULL, DINO_PLUGINS_OMEMO_NODE_DEVICELIST);
	_g_object_unref0 (_tmp2_);
}

static guint8*
signal_buffer_get_data (signal_buffer* self,
                        gint* result_length1)
{
	guint8* result;
	gint x = 0;
	guint8* res = NULL;
	guint8* _tmp0_;
	gint res_length1;
	gint _res_size_;
	guint8* _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, NULL);
	x = (gint) signal_buffer_len (self);
	_tmp0_ = signal_buffer_data (self);
	res = _tmp0_;
	res_length1 = -1;
	_res_size_ = res_length1;
	res_length1 = x;
	_tmp1_ = res;
	_tmp1__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

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

static guint8*
ec_public_key_serialize_ (ec_public_key* self,
                          gint* result_length1)
{
	signal_buffer* buffer = NULL;
	gint code = 0;
	signal_buffer* _tmp0_ = NULL;
	gint _tmp1_;
	gboolean _tmp2_ = FALSE;
	signal_buffer* _tmp3_;
	guint8* _tmp4_;
	gint _tmp4__length1;
	gint _tmp5_ = 0;
	guint8* _tmp6_;
	gint _tmp6__length1;
	guint8* _tmp7_;
	gint _tmp7__length1;
	guint8* _tmp8_;
	gint _tmp8__length1;
	guint8* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = ec_public_key_serialize (&_tmp0_, self);
	_signal_buffer_free0 (buffer);
	buffer = _tmp0_;
	code = _tmp1_;
	if (code < 0) {
		_tmp2_ = code > SG_ERR_MINIMUM;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		g_assert_not_reached ();
	}
	_tmp3_ = buffer;
	_tmp4_ = signal_buffer_get_data (_tmp3_, &_tmp5_);
	_tmp4__length1 = _tmp5_;
	_tmp6_ = _tmp4_;
	_tmp6__length1 = _tmp4__length1;
	_tmp7_ = (_tmp6_ != NULL) ? _vala_array_dup27 (_tmp6_, _tmp6__length1) : _tmp6_;
	_tmp7__length1 = _tmp6__length1;
	_tmp8_ = _tmp7_;
	_tmp8__length1 = _tmp7__length1;
	if (result_length1) {
		*result_length1 = _tmp8__length1;
	}
	result = _tmp8_;
	_signal_buffer_free0 (buffer);
	return result;
}

static void
dino_plugins_omemo_stream_module_on_other_bundle_result (DinoPluginsOmemoStreamModule* self,
                                                         XmppXmppStream* stream,
                                                         XmppJid* jid,
                                                         gint device_id,
                                                         const gchar* id,
                                                         XmppStanzaNode* node,
                                                         gboolean ignore_if_non_present)
{
	XmppModuleIdentity* _tmp27_;
	gpointer _tmp28_;
	DinoPluginsOmemoStreamModule* _tmp29_;
	GeeConcurrentSet* _tmp30_;
	XmppJid* _tmp31_;
	XmppJid* _tmp32_;
	XmppJid* _tmp33_;
	gchar* _tmp34_;
	gchar* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gchar* _tmp38_;
	gchar* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	if (node == NULL) {
		if (ignore_if_non_present) {
			XmppJid* _tmp0_;
			XmppJid* _tmp1_;
			XmppJid* _tmp2_;
			gchar* _tmp3_;
			gchar* _tmp4_;
			XmppModuleIdentity* _tmp5_;
			gpointer _tmp6_;
			DinoPluginsOmemoStreamModule* _tmp7_;
			_tmp0_ = xmpp_jid_get_bare_jid (jid);
			_tmp1_ = _tmp0_;
			_tmp2_ = _tmp1_;
			_tmp3_ = xmpp_jid_to_string (_tmp2_);
			_tmp4_ = _tmp3_;
			g_debug ("stream_module.vala:155: Ignoring device %s/%d: No bundle", _tmp4_, device_id);
			_g_free0 (_tmp4_);
			_xmpp_jid_unref0 (_tmp2_);
			_tmp5_ = dino_plugins_omemo_stream_module_IDENTITY;
			_tmp6_ = xmpp_xmpp_stream_get_module (stream, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp5_);
			_tmp7_ = (DinoPluginsOmemoStreamModule*) _tmp6_;
			dino_plugins_omemo_stream_module_ignore_device (_tmp7_, jid, (gint32) device_id);
			_g_object_unref0 (_tmp7_);
		}
		g_signal_emit (self, dino_plugins_omemo_stream_module_signals[DINO_PLUGINS_OMEMO_STREAM_MODULE_BUNDLE_FETCH_FAILED_SIGNAL], 0, jid, device_id);
	} else {
		DinoPluginsOmemoBundle* bundle = NULL;
		DinoPluginsOmemoBundle* _tmp8_;
		XmppModuleIdentity* _tmp9_;
		gpointer _tmp10_;
		DinoPluginsOmemoStreamModule* _tmp11_;
		XmppJid* _tmp12_;
		XmppJid* _tmp13_;
		XmppJid* _tmp14_;
		gchar* _tmp15_;
		gchar* _tmp16_;
		DinoPluginsOmemoBundle* _tmp17_;
		ec_public_key* _tmp18_;
		ec_public_key* _tmp19_;
		ec_public_key* _tmp20_;
		gint _tmp21_ = 0;
		guint8* _tmp22_;
		guint8* _tmp23_;
		gint _tmp23__length1;
		gchar* _tmp24_;
		gchar* _tmp25_;
		DinoPluginsOmemoBundle* _tmp26_;
		_tmp8_ = dino_plugins_omemo_bundle_new (node);
		bundle = _tmp8_;
		_tmp9_ = dino_plugins_omemo_stream_module_IDENTITY;
		_tmp10_ = xmpp_xmpp_stream_get_module (stream, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp9_);
		_tmp11_ = (DinoPluginsOmemoStreamModule*) _tmp10_;
		dino_plugins_omemo_stream_module_unignore_device (_tmp11_, jid, (gint32) device_id);
		_g_object_unref0 (_tmp11_);
		_tmp12_ = xmpp_jid_get_bare_jid (jid);
		_tmp13_ = _tmp12_;
		_tmp14_ = _tmp13_;
		_tmp15_ = xmpp_jid_to_string (_tmp14_);
		_tmp16_ = _tmp15_;
		_tmp17_ = bundle;
		_tmp18_ = dino_plugins_omemo_bundle_get_identity_key (_tmp17_);
		_tmp19_ = _tmp18_;
		_tmp20_ = _tmp19_;
		_tmp22_ = ec_public_key_serialize_ (_tmp20_, &_tmp21_);
		_tmp23_ = _tmp22_;
		_tmp23__length1 = _tmp21_;
		_tmp24_ = g_base64_encode (_tmp23_, (gint) _tmp21_);
		_tmp25_ = _tmp24_;
		g_debug ("stream_module.vala:162: Received bundle for %s/%d: %s", _tmp16_, device_id, _tmp25_);
		_g_free0 (_tmp25_);
		_tmp23_ = (g_free (_tmp23_), NULL);
		_signal_type_unref_vapi0 (_tmp20_);
		_g_free0 (_tmp16_);
		_xmpp_jid_unref0 (_tmp14_);
		_tmp26_ = bundle;
		g_signal_emit (self, dino_plugins_omemo_stream_module_signals[DINO_PLUGINS_OMEMO_STREAM_MODULE_BUNDLE_FETCHED_SIGNAL], 0, jid, device_id, _tmp26_);
		_dino_plugins_omemo_bundle_unref0 (bundle);
	}
	_tmp27_ = dino_plugins_omemo_stream_module_IDENTITY;
	_tmp28_ = xmpp_xmpp_stream_get_module (stream, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp27_);
	_tmp29_ = (DinoPluginsOmemoStreamModule*) _tmp28_;
	_tmp30_ = _tmp29_->priv->active_bundle_requests;
	_tmp31_ = xmpp_jid_get_bare_jid (jid);
	_tmp32_ = _tmp31_;
	_tmp33_ = _tmp32_;
	_tmp34_ = xmpp_jid_to_string (_tmp33_);
	_tmp35_ = _tmp34_;
	_tmp36_ = g_strdup_printf ("%i", device_id);
	_tmp37_ = _tmp36_;
	_tmp38_ = g_strconcat (":", _tmp37_, NULL);
	_tmp39_ = _tmp38_;
	_tmp40_ = g_strconcat (_tmp35_, _tmp39_, NULL);
	_tmp41_ = _tmp40_;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp30_, _tmp41_);
	_g_free0 (_tmp41_);
	_g_free0 (_tmp39_);
	_g_free0 (_tmp37_);
	_g_free0 (_tmp35_);
	_xmpp_jid_unref0 (_tmp33_);
	_g_object_unref0 (_tmp29_);
}

static const char*
_omemo_error_code_to_string (int value)
{
	switch (value) {
		case SG_SUCCESS:
		return "SG_SUCCESS";
		case SG_ERR_NOMEM:
		return "SG_ERR_NOMEM";
		case SG_ERR_INVAL:
		return "SG_ERR_INVAL";
		case SG_ERR_UNKNOWN:
		return "SG_ERR_UNKNOWN";
		case SG_ERR_DUPLICATE_MESSAGE:
		return "SG_ERR_DUPLICATE_MESSAGE";
		case SG_ERR_INVALID_KEY:
		return "SG_ERR_INVALID_KEY";
		case SG_ERR_INVALID_KEY_ID:
		return "SG_ERR_INVALID_KEY_ID";
		case SG_ERR_INVALID_MAC:
		return "SG_ERR_INVALID_MAC";
		case SG_ERR_INVALID_MESSAGE:
		return "SG_ERR_INVALID_MESSAGE";
		case SG_ERR_INVALID_VERSION:
		return "SG_ERR_INVALID_VERSION";
		case SG_ERR_LEGACY_MESSAGE:
		return "SG_ERR_LEGACY_MESSAGE";
		case SG_ERR_NO_SESSION:
		return "SG_ERR_NO_SESSION";
		case SG_ERR_STALE_KEY_EXCHANGE:
		return "SG_ERR_STALE_KEY_EXCHANGE";
		case SG_ERR_UNTRUSTED_IDENTITY:
		return "SG_ERR_UNTRUSTED_IDENTITY";
		case SG_ERR_VRF_SIG_VERIF_FAILED:
		return "SG_ERR_VRF_SIG_VERIF_FAILED";
		case SG_ERR_INVALID_PROTO_BUF:
		return "SG_ERR_INVALID_PROTO_BUF";
		case SG_ERR_FP_VERSION_MISMATCH:
		return "SG_ERR_FP_VERSION_MISMATCH";
		case SG_ERR_FP_IDENT_MISMATCH:
		return "SG_ERR_FP_IDENT_MISMATCH";
	}
	return NULL;
}

static gint
signal_throw_gerror_by_code_ (gint code,
                              const gchar* message,
                              GError** error)
{
	gboolean _tmp0_ = FALSE;
	GError* _inner_error0_ = NULL;
	gint result;
	if (code < 0) {
		_tmp0_ = code > SG_ERR_MINIMUM;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		const gchar* _tmp1_ = NULL;
		const gchar* _tmp2_;
		GError* _tmp3_;
		gint _tmp4_ = -1;
		_tmp1_ = message;
		if (_tmp1_ == NULL) {
			_tmp1_ = "libomemo-c error";
		}
		_tmp2_ = _omemo_error_code_to_string ((int) code);
		_tmp3_ = g_error_new ((GQuark) -1, code, "%s: %s", _tmp1_, _tmp2_);
		_inner_error0_ = _tmp3_;
		g_propagate_error (error, _inner_error0_);
		return _tmp4_;
	}
	result = code;
	return result;
}

static void
session_builder_process_pre_key_bundle_ (session_builder* self,
                                         session_pre_key_bundle* pre_key_bundle,
                                         GError** error)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (pre_key_bundle != NULL);
	signal_throw_gerror_by_code_ (session_builder_process_pre_key_bundle (self, pre_key_bundle), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

gboolean
dino_plugins_omemo_stream_module_start_session (DinoPluginsOmemoStreamModule* self,
                                                XmppXmppStream* stream,
                                                XmppJid* jid,
                                                gint32 device_id,
                                                DinoPluginsOmemoBundle* bundle)
{
	gboolean fail = FALSE;
	gint32 signed_pre_key_id = 0;
	gint32 _tmp0_;
	gint32 _tmp1_;
	ec_public_key* signed_pre_key = NULL;
	ec_public_key* _tmp2_;
	ec_public_key* _tmp3_;
	guint8* signed_pre_key_signature = NULL;
	guint8* _tmp4_;
	gint _tmp4__length1;
	gint _tmp5_ = 0;
	guint8* _tmp6_;
	gint _tmp6__length1;
	gint signed_pre_key_signature_length1;
	gint _signed_pre_key_signature_size_;
	ec_public_key* identity_key = NULL;
	ec_public_key* _tmp7_;
	ec_public_key* _tmp8_;
	GeeArrayList* pre_keys = NULL;
	GeeArrayList* _tmp9_;
	GeeArrayList* _tmp10_;
	gboolean _tmp11_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gboolean _tmp13_ = FALSE;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (stream != NULL, FALSE);
	g_return_val_if_fail (jid != NULL, FALSE);
	g_return_val_if_fail (bundle != NULL, FALSE);
	fail = FALSE;
	_tmp0_ = dino_plugins_omemo_bundle_get_signed_pre_key_id (bundle);
	_tmp1_ = _tmp0_;
	signed_pre_key_id = _tmp1_;
	_tmp2_ = dino_plugins_omemo_bundle_get_signed_pre_key (bundle);
	_tmp3_ = _tmp2_;
	signed_pre_key = _tmp3_;
	_tmp4_ = dino_plugins_omemo_bundle_get_signed_pre_key_signature (bundle, &_tmp5_);
	_tmp4__length1 = _tmp5_;
	_tmp6_ = _tmp4_;
	_tmp6__length1 = _tmp4__length1;
	signed_pre_key_signature = _tmp6_;
	signed_pre_key_signature_length1 = _tmp6__length1;
	_signed_pre_key_signature_size_ = signed_pre_key_signature_length1;
	_tmp7_ = dino_plugins_omemo_bundle_get_identity_key (bundle);
	_tmp8_ = _tmp7_;
	identity_key = _tmp8_;
	_tmp9_ = dino_plugins_omemo_bundle_get_pre_keys (bundle);
	_tmp10_ = _tmp9_;
	pre_keys = _tmp10_;
	if (signed_pre_key_id < ((gint32) 0)) {
		_tmp13_ = TRUE;
	} else {
		ec_public_key* _tmp14_;
		_tmp14_ = signed_pre_key;
		_tmp13_ = _tmp14_ == NULL;
	}
	if (_tmp13_) {
		_tmp12_ = TRUE;
	} else {
		ec_public_key* _tmp15_;
		_tmp15_ = identity_key;
		_tmp12_ = _tmp15_ == NULL;
	}
	if (_tmp12_) {
		_tmp11_ = TRUE;
	} else {
		GeeArrayList* _tmp16_;
		gint _tmp17_;
		gint _tmp18_;
		_tmp16_ = pre_keys;
		_tmp17_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp16_);
		_tmp18_ = _tmp17_;
		_tmp11_ = _tmp18_ == 0;
	}
	if (_tmp11_) {
		fail = TRUE;
	} else {
		gint pre_key_idx = 0;
		GeeArrayList* _tmp19_;
		gint _tmp20_;
		gint _tmp21_;
		gint32 pre_key_id = 0;
		GeeArrayList* _tmp22_;
		gpointer _tmp23_;
		DinoPluginsOmemoBundlePreKey* _tmp24_;
		gint32 _tmp25_;
		gint32 _tmp26_;
		gint32 _tmp27_;
		ec_public_key* pre_key = NULL;
		GeeArrayList* _tmp28_;
		gpointer _tmp29_;
		DinoPluginsOmemoBundlePreKey* _tmp30_;
		ec_public_key* _tmp31_;
		ec_public_key* _tmp32_;
		ec_public_key* _tmp33_;
		gboolean _tmp34_ = FALSE;
		_tmp19_ = pre_keys;
		_tmp20_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp19_);
		_tmp21_ = _tmp20_;
		pre_key_idx = (gint) g_random_int_range ((gint32) 0, (gint32) _tmp21_);
		_tmp22_ = pre_keys;
		_tmp23_ = gee_abstract_list_get ((GeeAbstractList*) _tmp22_, pre_key_idx);
		_tmp24_ = (DinoPluginsOmemoBundlePreKey*) _tmp23_;
		_tmp25_ = dino_plugins_omemo_bundle_pre_key_get_key_id (_tmp24_);
		_tmp26_ = _tmp25_;
		_tmp27_ = _tmp26_;
		_dino_plugins_omemo_bundle_pre_key_unref0 (_tmp24_);
		pre_key_id = _tmp27_;
		_tmp28_ = pre_keys;
		_tmp29_ = gee_abstract_list_get ((GeeAbstractList*) _tmp28_, pre_key_idx);
		_tmp30_ = (DinoPluginsOmemoBundlePreKey*) _tmp29_;
		_tmp31_ = dino_plugins_omemo_bundle_pre_key_get_key (_tmp30_);
		_tmp32_ = _tmp31_;
		_tmp33_ = _tmp32_;
		_dino_plugins_omemo_bundle_pre_key_unref0 (_tmp30_);
		pre_key = _tmp33_;
		if (pre_key_id < ((gint32) 0)) {
			_tmp34_ = TRUE;
		} else {
			ec_public_key* _tmp35_;
			_tmp35_ = pre_key;
			_tmp34_ = _tmp35_ == NULL;
		}
		if (_tmp34_) {
			fail = TRUE;
		} else {
			signal_protocol_address* address = NULL;
			XmppJid* _tmp36_;
			XmppJid* _tmp37_;
			XmppJid* _tmp38_;
			gchar* _tmp39_;
			gchar* _tmp40_;
			signal_protocol_address* _tmp41_;
			signal_protocol_address* _tmp42_;
			signal_protocol_address* _tmp69_;
			_tmp36_ = xmpp_jid_get_bare_jid (jid);
			_tmp37_ = _tmp36_;
			_tmp38_ = _tmp37_;
			_tmp39_ = xmpp_jid_to_string (_tmp38_);
			_tmp40_ = _tmp39_;
			_tmp41_ = signal_protocol_address_new (_tmp40_, device_id);
			_tmp42_ = _tmp41_;
			_g_free0 (_tmp40_);
			_xmpp_jid_unref0 (_tmp38_);
			address = _tmp42_;
			{
				gboolean _tmp43_ = FALSE;
				OmemoStore* _tmp44_;
				signal_protocol_address* _tmp45_;
				XmppJid* _tmp46_;
				XmppJid* _tmp47_;
				XmppJid* _tmp48_;
				gchar* _tmp49_;
				gchar* _tmp50_;
				session_builder* builder = NULL;
				OmemoStore* _tmp51_;
				signal_protocol_address* _tmp52_;
				session_builder* _tmp53_;
				session_pre_key_bundle* _tmp54_ = NULL;
				ec_public_key* _tmp55_;
				ec_public_key* _tmp56_;
				guint8* _tmp57_;
				gint _tmp57__length1;
				ec_public_key* _tmp58_;
				session_pre_key_bundle* _tmp59_;
				session_builder* _tmp60_;
				_tmp44_ = self->priv->_store;
				_tmp45_ = address;
				_tmp43_ = omemo_store_contains_session (_tmp44_, _tmp45_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				if (_tmp43_) {
					result = FALSE;
					_signal_protocol_address_free0 (address);
					_signal_type_unref_vapi0 (pre_key);
					_g_object_unref0 (pre_keys);
					_signal_type_unref_vapi0 (identity_key);
					signed_pre_key_signature = (g_free (signed_pre_key_signature), NULL);
					_signal_type_unref_vapi0 (signed_pre_key);
					return result;
				}
				_tmp46_ = xmpp_jid_get_bare_jid (jid);
				_tmp47_ = _tmp46_;
				_tmp48_ = _tmp47_;
				_tmp49_ = xmpp_jid_to_string (_tmp48_);
				_tmp50_ = _tmp49_;
				g_debug ("stream_module.vala:190: Starting new session for encryption with %s/%d", _tmp50_, (gint) device_id);
				_g_free0 (_tmp50_);
				_xmpp_jid_unref0 (_tmp48_);
				_tmp51_ = self->priv->_store;
				_tmp52_ = address;
				_tmp53_ = omemo_store_create_session_builder (_tmp51_, _tmp52_, &_inner_error0_);
				builder = _tmp53_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					goto __catch0_g_error;
				}
				_tmp55_ = pre_key;
				_tmp56_ = signed_pre_key;
				_tmp57_ = signed_pre_key_signature;
				_tmp57__length1 = signed_pre_key_signature_length1;
				_tmp58_ = identity_key;
				_tmp59_ = omemo_create_pre_key_bundle ((guint32) device_id, (gint) device_id, (guint32) pre_key_id, _tmp55_, (guint32) signed_pre_key_id, _tmp56_, _tmp57_, (gint) _tmp57__length1, _tmp58_, &_inner_error0_);
				_tmp54_ = _tmp59_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_session_builder_free0 (builder);
					goto __catch0_g_error;
				}
				_tmp60_ = builder;
				session_builder_process_pre_key_bundle_ (_tmp60_, _tmp54_, &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_signal_type_unref_vapi0 (_tmp54_);
					_session_builder_free0 (builder);
					goto __catch0_g_error;
				}
				_signal_type_unref_vapi0 (_tmp54_);
				_session_builder_free0 (builder);
			}
			goto __finally0;
			__catch0_g_error:
			{
				GError* e = NULL;
				XmppJid* _tmp61_;
				XmppJid* _tmp62_;
				XmppJid* _tmp63_;
				gchar* _tmp64_;
				gchar* _tmp65_;
				GError* _tmp66_;
				const gchar* _tmp67_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp61_ = xmpp_jid_get_bare_jid (jid);
				_tmp62_ = _tmp61_;
				_tmp63_ = _tmp62_;
				_tmp64_ = xmpp_jid_to_string (_tmp63_);
				_tmp65_ = _tmp64_;
				_tmp66_ = e;
				_tmp67_ = _tmp66_->message;
				g_debug ("stream_module.vala:194: Can't create session with %s/%d: %s", _tmp65_, (gint) device_id, _tmp67_);
				_g_free0 (_tmp65_);
				_xmpp_jid_unref0 (_tmp63_);
				fail = TRUE;
				_g_error_free0 (e);
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				gboolean _tmp68_ = FALSE;
				_signal_protocol_address_free0 (address);
				_signal_type_unref_vapi0 (pre_key);
				_g_object_unref0 (pre_keys);
				_signal_type_unref_vapi0 (identity_key);
				signed_pre_key_signature = (g_free (signed_pre_key_signature), NULL);
				_signal_type_unref_vapi0 (signed_pre_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 _tmp68_;
			}
			_tmp69_ = address;
			signal_protocol_address_set_device_id (_tmp69_, (gint32) 0);
			_signal_protocol_address_free0 (address);
		}
		_signal_type_unref_vapi0 (pre_key);
	}
	if (fail) {
		XmppJid* _tmp70_;
		XmppJid* _tmp71_;
		XmppJid* _tmp72_;
		gchar* _tmp73_;
		gchar* _tmp74_;
		XmppStanzaNode* _tmp75_;
		gchar* _tmp76_;
		gchar* _tmp77_;
		XmppModuleIdentity* _tmp78_;
		gpointer _tmp79_;
		DinoPluginsOmemoStreamModule* _tmp80_;
		_tmp70_ = xmpp_jid_get_bare_jid (jid);
		_tmp71_ = _tmp70_;
		_tmp72_ = _tmp71_;
		_tmp73_ = xmpp_jid_to_string (_tmp72_);
		_tmp74_ = _tmp73_;
		_tmp75_ = bundle->node;
		_tmp76_ = xmpp_stanza_entry_to_string ((XmppStanzaEntry*) _tmp75_, 0);
		_tmp77_ = _tmp76_;
		g_debug ("stream_module.vala:201: Ignoring device %s/%d: Bad bundle: %s", _tmp74_, (gint) device_id, _tmp77_);
		_g_free0 (_tmp77_);
		_g_free0 (_tmp74_);
		_xmpp_jid_unref0 (_tmp72_);
		_tmp78_ = dino_plugins_omemo_stream_module_IDENTITY;
		_tmp79_ = xmpp_xmpp_stream_get_module (stream, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp78_);
		_tmp80_ = (DinoPluginsOmemoStreamModule*) _tmp79_;
		dino_plugins_omemo_stream_module_ignore_device (_tmp80_, jid, device_id);
		_g_object_unref0 (_tmp80_);
	}
	result = TRUE;
	_g_object_unref0 (pre_keys);
	_signal_type_unref_vapi0 (identity_key);
	signed_pre_key_signature = (g_free (signed_pre_key_signature), NULL);
	_signal_type_unref_vapi0 (signed_pre_key);
	return result;
}

static void
_dino_plugins_omemo_stream_module_on_self_bundle_result_xmpp_xep_pubsub_module_on_result (XmppXmppStream* stream,
                                                                                          XmppJid* jid,
                                                                                          const gchar* id,
                                                                                          XmppStanzaNode* node,
                                                                                          gpointer self)
{
	dino_plugins_omemo_stream_module_on_self_bundle_result ((DinoPluginsOmemoStreamModule*) self, stream, jid, id, node);
}

void
dino_plugins_omemo_stream_module_publish_bundles_if_needed (DinoPluginsOmemoStreamModule* self,
                                                            XmppXmppStream* stream,
                                                            XmppJid* jid)
{
	GeeConcurrentSet* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	XmppJid* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	OmemoStore* _tmp6_;
	guint32 _tmp7_;
	guint32 _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	gboolean _tmp15_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = self->priv->active_bundle_requests;
	_tmp1_ = xmpp_jid_get_bare_jid (jid);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = xmpp_jid_to_string (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = self->priv->_store;
	_tmp7_ = omemo_store_get_local_registration_id (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = g_strdup_printf ("%u", _tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = g_strconcat (":", _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	_tmp13_ = g_strconcat (_tmp5_, _tmp12_, NULL);
	_tmp14_ = _tmp13_;
	_tmp15_ = gee_abstract_collection_add ((GeeAbstractCollection*) _tmp0_, _tmp14_);
	_g_free0 (_tmp14_);
	_g_free0 (_tmp12_);
	_g_free0 (_tmp10_);
	_g_free0 (_tmp5_);
	_xmpp_jid_unref0 (_tmp3_);
	if (_tmp15_) {
		XmppModuleIdentity* _tmp16_;
		gpointer _tmp17_;
		XmppXepPubsubModule* _tmp18_;
		const gchar* _tmp19_;
		OmemoStore* _tmp20_;
		guint32 _tmp21_;
		guint32 _tmp22_;
		gchar* _tmp23_;
		gchar* _tmp24_;
		gchar* _tmp25_;
		gchar* _tmp26_;
		_tmp16_ = xmpp_xep_pubsub_module_IDENTITY;
		_tmp17_ = xmpp_xmpp_stream_get_module (stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp16_);
		_tmp18_ = (XmppXepPubsubModule*) _tmp17_;
		_tmp19_ = string_to_string (DINO_PLUGINS_OMEMO_NODE_BUNDLES);
		_tmp20_ = self->priv->_store;
		_tmp21_ = omemo_store_get_local_registration_id (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = g_strdup_printf ("%u", _tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = g_strconcat (_tmp19_, ":", _tmp24_, NULL);
		_tmp26_ = _tmp25_;
		xmpp_xep_pubsub_module_request (_tmp18_, stream, jid, _tmp26_, _dino_plugins_omemo_stream_module_on_self_bundle_result_xmpp_xep_pubsub_module_on_result, g_object_ref (self), g_object_unref);
		_g_free0 (_tmp26_);
		_g_free0 (_tmp24_);
		_g_object_unref0 (_tmp18_);
	}
}

static gpointer
_signal_type_ref_vapi0 (gpointer self)
{
	return self ? signal_type_ref_vapi (self) : NULL;
}

static void
dino_plugins_omemo_stream_module_on_self_bundle_result (DinoPluginsOmemoStreamModule* self,
                                                        XmppXmppStream* stream,
                                                        XmppJid* jid,
                                                        const gchar* id,
                                                        XmppStanzaNode* node)
{
	GeeMap* keys = NULL;
	GeeHashMap* _tmp0_;
	ec_public_key* identity_key = NULL;
	gint32 signed_pre_key_id = 0;
	ec_public_key* signed_pre_key = NULL;
	session_signed_pre_key* signed_pre_key_record = NULL;
	gboolean changed = FALSE;
	XmppModuleIdentity* _tmp133_;
	gpointer _tmp134_;
	DinoPluginsOmemoStreamModule* _tmp135_;
	GeeConcurrentSet* _tmp136_;
	XmppJid* _tmp137_;
	XmppJid* _tmp138_;
	XmppJid* _tmp139_;
	gchar* _tmp140_;
	gchar* _tmp141_;
	OmemoStore* _tmp142_;
	guint32 _tmp143_;
	guint32 _tmp144_;
	gchar* _tmp145_;
	gchar* _tmp146_;
	gchar* _tmp147_;
	gchar* _tmp148_;
	gchar* _tmp149_;
	gchar* _tmp150_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (jid != NULL);
	if (!dino_plugins_omemo_plugin_ensure_context ()) {
		return;
	}
	_tmp0_ = gee_hash_map_new (G_TYPE_INT, NULL, NULL, G_TYPE_POINTER, (GBoxedCopyFunc) signal_type_ref_vapi, (GDestroyNotify) signal_type_unref_vapi, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	keys = (GeeMap*) _tmp0_;
	identity_key = NULL;
	signed_pre_key_id = (gint32) -1;
	signed_pre_key = NULL;
	signed_pre_key_record = NULL;
	changed = FALSE;
	if (node == NULL) {
		OmemoStore* _tmp1_;
		ratchet_identity_key_pair* _tmp2_;
		ratchet_identity_key_pair* _tmp3_;
		ratchet_identity_key_pair* _tmp4_;
		ec_public_key* _tmp5_;
		ec_public_key* _tmp6_;
		ec_public_key* _tmp7_;
		_tmp1_ = self->priv->_store;
		_tmp2_ = omemo_store_get_identity_key_pair (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = _tmp3_;
		_tmp5_ = ratchet_identity_key_pair_get_public (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = _signal_type_ref_vapi0 (_tmp6_);
		_signal_type_unref_vapi0 (identity_key);
		identity_key = _tmp7_;
		_signal_type_unref_vapi0 (_tmp4_);
		changed = TRUE;
	} else {
		DinoPluginsOmemoBundle* bundle = NULL;
		DinoPluginsOmemoBundle* _tmp8_;
		DinoPluginsOmemoBundle* _tmp28_;
		ec_public_key* _tmp29_;
		ec_public_key* _tmp30_;
		DinoPluginsOmemoBundle* _tmp31_;
		gint32 _tmp32_;
		gint32 _tmp33_;
		DinoPluginsOmemoBundle* _tmp34_;
		ec_public_key* _tmp35_;
		ec_public_key* _tmp36_;
		_tmp8_ = dino_plugins_omemo_bundle_new (node);
		bundle = _tmp8_;
		{
			GeeArrayList* _prekey_list = NULL;
			DinoPluginsOmemoBundle* _tmp9_;
			GeeArrayList* _tmp10_;
			GeeArrayList* _tmp11_;
			gint _prekey_size = 0;
			GeeArrayList* _tmp12_;
			gint _tmp13_;
			gint _tmp14_;
			gint _prekey_index = 0;
			_tmp9_ = bundle;
			_tmp10_ = dino_plugins_omemo_bundle_get_pre_keys (_tmp9_);
			_tmp11_ = _tmp10_;
			_prekey_list = _tmp11_;
			_tmp12_ = _prekey_list;
			_tmp13_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp12_);
			_tmp14_ = _tmp13_;
			_prekey_size = _tmp14_;
			_prekey_index = -1;
			while (TRUE) {
				gint _tmp15_;
				gint _tmp16_;
				DinoPluginsOmemoBundlePreKey* prekey = NULL;
				GeeArrayList* _tmp17_;
				gpointer _tmp18_;
				ec_public_key* key = NULL;
				DinoPluginsOmemoBundlePreKey* _tmp19_;
				ec_public_key* _tmp20_;
				ec_public_key* _tmp21_;
				ec_public_key* _tmp22_;
				_prekey_index = _prekey_index + 1;
				_tmp15_ = _prekey_index;
				_tmp16_ = _prekey_size;
				if (!(_tmp15_ < _tmp16_)) {
					break;
				}
				_tmp17_ = _prekey_list;
				_tmp18_ = gee_abstract_list_get ((GeeAbstractList*) _tmp17_, _prekey_index);
				prekey = (DinoPluginsOmemoBundlePreKey*) _tmp18_;
				_tmp19_ = prekey;
				_tmp20_ = dino_plugins_omemo_bundle_pre_key_get_key (_tmp19_);
				_tmp21_ = _tmp20_;
				key = _tmp21_;
				_tmp22_ = key;
				if (_tmp22_ != NULL) {
					GeeMap* _tmp23_;
					DinoPluginsOmemoBundlePreKey* _tmp24_;
					gint32 _tmp25_;
					gint32 _tmp26_;
					ec_public_key* _tmp27_;
					_tmp23_ = keys;
					_tmp24_ = prekey;
					_tmp25_ = dino_plugins_omemo_bundle_pre_key_get_key_id (_tmp24_);
					_tmp26_ = _tmp25_;
					_tmp27_ = key;
					gee_map_set (_tmp23_, (gpointer) ((gintptr) _tmp26_), (ec_public_key*) _tmp27_);
				}
				_signal_type_unref_vapi0 (key);
				_dino_plugins_omemo_bundle_pre_key_unref0 (prekey);
			}
			_g_object_unref0 (_prekey_list);
		}
		_tmp28_ = bundle;
		_tmp29_ = dino_plugins_omemo_bundle_get_identity_key (_tmp28_);
		_tmp30_ = _tmp29_;
		_signal_type_unref_vapi0 (identity_key);
		identity_key = _tmp30_;
		_tmp31_ = bundle;
		_tmp32_ = dino_plugins_omemo_bundle_get_signed_pre_key_id (_tmp31_);
		_tmp33_ = _tmp32_;
		signed_pre_key_id = _tmp33_;
		_tmp34_ = bundle;
		_tmp35_ = dino_plugins_omemo_bundle_get_signed_pre_key (_tmp34_);
		_tmp36_ = _tmp35_;
		_signal_type_unref_vapi0 (signed_pre_key);
		signed_pre_key = _tmp36_;
		_dino_plugins_omemo_bundle_unref0 (bundle);
	}
	{
		gboolean _tmp37_ = FALSE;
		ec_public_key* _tmp38_;
		ratchet_identity_key_pair* identity_key_pair = NULL;
		OmemoStore* _tmp46_;
		ratchet_identity_key_pair* _tmp47_;
		ratchet_identity_key_pair* _tmp48_;
		gboolean _tmp49_ = FALSE;
		gboolean _tmp50_ = FALSE;
		gboolean _tmp51_ = FALSE;
		ec_public_key* _tmp52_;
		GeeSet* pre_key_records = NULL;
		GeeHashSet* _tmp76_;
		gint new_keys = 0;
		GeeSet* _tmp106_;
		gint _tmp107_;
		gint _tmp108_;
		_tmp38_ = identity_key;
		if (_tmp38_ == NULL) {
			_tmp37_ = TRUE;
		} else {
			OmemoStore* _tmp39_;
			ratchet_identity_key_pair* _tmp40_;
			ratchet_identity_key_pair* _tmp41_;
			ratchet_identity_key_pair* _tmp42_;
			ec_public_key* _tmp43_;
			ec_public_key* _tmp44_;
			ec_public_key* _tmp45_;
			_tmp39_ = self->priv->_store;
			_tmp40_ = omemo_store_get_identity_key_pair (_tmp39_);
			_tmp41_ = _tmp40_;
			_tmp42_ = _tmp41_;
			_tmp43_ = ratchet_identity_key_pair_get_public (_tmp42_);
			_tmp44_ = _tmp43_;
			_tmp45_ = identity_key;
			_tmp37_ = ec_public_key_compare (_tmp44_, (ec_public_key*) _tmp45_) != 0;
			_signal_type_unref_vapi0 (_tmp42_);
		}
		if (_tmp37_) {
			changed = TRUE;
		}
		_tmp46_ = self->priv->_store;
		_tmp47_ = omemo_store_get_identity_key_pair (_tmp46_);
		_tmp48_ = _tmp47_;
		identity_key_pair = _tmp48_;
		_tmp52_ = signed_pre_key;
		if (_tmp52_ == NULL) {
			_tmp51_ = TRUE;
		} else {
			_tmp51_ = signed_pre_key_id == ((gint32) -1);
		}
		if (_tmp51_) {
			_tmp50_ = TRUE;
		} else {
			gboolean _tmp53_ = FALSE;
			OmemoStore* _tmp54_;
			_tmp54_ = self->priv->_store;
			_tmp53_ = omemo_store_contains_signed_pre_key (_tmp54_, (guint32) signed_pre_key_id, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_signal_type_unref_vapi0 (identity_key_pair);
				goto __catch0_g_error;
			}
			_tmp50_ = !_tmp53_;
		}
		if (_tmp50_) {
			_tmp49_ = TRUE;
		} else {
			session_signed_pre_key* _tmp55_ = NULL;
			OmemoStore* _tmp56_;
			session_signed_pre_key* _tmp57_;
			ec_key_pair* _tmp58_;
			ec_key_pair* _tmp59_;
			ec_public_key* _tmp60_;
			ec_public_key* _tmp61_;
			ec_public_key* _tmp62_;
			_tmp56_ = self->priv->_store;
			_tmp57_ = omemo_store_load_signed_pre_key (_tmp56_, (guint32) signed_pre_key_id, &_inner_error0_);
			_tmp55_ = _tmp57_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_signal_type_unref_vapi0 (identity_key_pair);
				goto __catch0_g_error;
			}
			_tmp58_ = session_signed_pre_key_get_key_pair (_tmp55_);
			_tmp59_ = _tmp58_;
			_tmp60_ = ec_key_pair_get_public (_tmp59_);
			_tmp61_ = _tmp60_;
			_tmp62_ = signed_pre_key;
			_tmp49_ = ec_public_key_compare (_tmp61_, (ec_public_key*) _tmp62_) != 0;
			_signal_type_unref_vapi0 (_tmp55_);
		}
		if (_tmp49_) {
			session_signed_pre_key* _tmp63_ = NULL;
			OmemoContext* _tmp64_;
			OmemoContext* _tmp65_;
			ratchet_identity_key_pair* _tmp66_;
			session_signed_pre_key* _tmp67_;
			session_signed_pre_key* _tmp68_;
			session_signed_pre_key* _tmp69_;
			OmemoStore* _tmp70_;
			session_signed_pre_key* _tmp71_;
			signed_pre_key_id = g_random_int_range ((gint32) 1, G_MAXINT32);
			_tmp64_ = dino_plugins_omemo_plugin_get_context ();
			_tmp65_ = _tmp64_;
			_tmp66_ = identity_key_pair;
			_tmp67_ = omemo_context_generate_signed_pre_key (_tmp65_, _tmp66_, signed_pre_key_id, (guint64) 0, &_inner_error0_);
			_tmp68_ = _tmp67_;
			_omemo_context_unref0 (_tmp65_);
			_tmp63_ = _tmp68_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_signal_type_unref_vapi0 (identity_key_pair);
				goto __catch0_g_error;
			}
			_tmp69_ = _tmp63_;
			_tmp63_ = NULL;
			_signal_type_unref_vapi0 (signed_pre_key_record);
			signed_pre_key_record = _tmp69_;
			_tmp70_ = self->priv->_store;
			_tmp71_ = signed_pre_key_record;
			omemo_store_store_signed_pre_key (_tmp70_, (session_signed_pre_key*) _tmp71_, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_signal_type_unref_vapi0 (_tmp63_);
				_signal_type_unref_vapi0 (identity_key_pair);
				goto __catch0_g_error;
			}
			changed = TRUE;
			_signal_type_unref_vapi0 (_tmp63_);
		} else {
			session_signed_pre_key* _tmp72_ = NULL;
			OmemoStore* _tmp73_;
			session_signed_pre_key* _tmp74_;
			session_signed_pre_key* _tmp75_;
			_tmp73_ = self->priv->_store;
			_tmp74_ = omemo_store_load_signed_pre_key (_tmp73_, (guint32) signed_pre_key_id, &_inner_error0_);
			_tmp72_ = _tmp74_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_signal_type_unref_vapi0 (identity_key_pair);
				goto __catch0_g_error;
			}
			_tmp75_ = _tmp72_;
			_tmp72_ = NULL;
			_signal_type_unref_vapi0 (signed_pre_key_record);
			signed_pre_key_record = _tmp75_;
			_signal_type_unref_vapi0 (_tmp72_);
		}
		_tmp76_ = gee_hash_set_new (G_TYPE_POINTER, (GBoxedCopyFunc) signal_type_ref_vapi, (GDestroyNotify) signal_type_unref_vapi, NULL, NULL, NULL, NULL, NULL, NULL);
		pre_key_records = (GeeSet*) _tmp76_;
		{
			GeeIterator* _entry_it = NULL;
			GeeMap* _tmp77_;
			GeeSet* _tmp78_;
			GeeSet* _tmp79_;
			GeeSet* _tmp80_;
			GeeIterator* _tmp81_;
			GeeIterator* _tmp82_;
			_tmp77_ = keys;
			_tmp78_ = gee_map_get_entries (_tmp77_);
			_tmp79_ = _tmp78_;
			_tmp80_ = _tmp79_;
			_tmp81_ = gee_iterable_iterator ((GeeIterable*) _tmp80_);
			_tmp82_ = _tmp81_;
			_g_object_unref0 (_tmp80_);
			_entry_it = _tmp82_;
			while (TRUE) {
				GeeIterator* _tmp83_;
				GeeMapEntry* entry = NULL;
				GeeIterator* _tmp84_;
				gpointer _tmp85_;
				gboolean _tmp86_ = FALSE;
				OmemoStore* _tmp87_;
				GeeMapEntry* _tmp88_;
				gconstpointer _tmp89_;
				gconstpointer _tmp90_;
				_tmp83_ = _entry_it;
				if (!gee_iterator_next (_tmp83_)) {
					break;
				}
				_tmp84_ = _entry_it;
				_tmp85_ = gee_iterator_get (_tmp84_);
				entry = (GeeMapEntry*) _tmp85_;
				_tmp87_ = self->priv->_store;
				_tmp88_ = entry;
				_tmp89_ = gee_map_entry_get_key (_tmp88_);
				_tmp90_ = _tmp89_;
				_tmp86_ = omemo_store_contains_pre_key (_tmp87_, (guint32) ((gint) ((gintptr) _tmp90_)), &_inner_error0_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_g_object_unref0 (entry);
					_g_object_unref0 (_entry_it);
					_g_object_unref0 (pre_key_records);
					_signal_type_unref_vapi0 (identity_key_pair);
					goto __catch0_g_error;
				}
				if (_tmp86_) {
					session_pre_key* record = NULL;
					OmemoStore* _tmp91_;
					GeeMapEntry* _tmp92_;
					gconstpointer _tmp93_;
					gconstpointer _tmp94_;
					session_pre_key* _tmp95_;
					session_pre_key* _tmp96_;
					ec_key_pair* _tmp97_;
					ec_key_pair* _tmp98_;
					ec_public_key* _tmp99_;
					ec_public_key* _tmp100_;
					GeeMapEntry* _tmp101_;
					gconstpointer _tmp102_;
					gconstpointer _tmp103_;
					_tmp91_ = self->priv->_store;
					_tmp92_ = entry;
					_tmp93_ = gee_map_entry_get_key (_tmp92_);
					_tmp94_ = _tmp93_;
					_tmp95_ = omemo_store_load_pre_key (_tmp91_, (guint32) ((gint) ((gintptr) _tmp94_)), &_inner_error0_);
					record = _tmp95_;
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_g_object_unref0 (entry);
						_g_object_unref0 (_entry_it);
						_g_object_unref0 (pre_key_records);
						_signal_type_unref_vapi0 (identity_key_pair);
						goto __catch0_g_error;
					}
					_tmp96_ = record;
					_tmp97_ = session_pre_key_get_key_pair (_tmp96_);
					_tmp98_ = _tmp97_;
					_tmp99_ = ec_key_pair_get_public (_tmp98_);
					_tmp100_ = _tmp99_;
					_tmp101_ = entry;
					_tmp102_ = gee_map_entry_get_value (_tmp101_);
					_tmp103_ = _tmp102_;
					if (ec_public_key_compare (_tmp100_, (ec_public_key*) _tmp103_) == 0) {
						GeeSet* _tmp104_;
						session_pre_key* _tmp105_;
						_tmp104_ = pre_key_records;
						_tmp105_ = record;
						gee_collection_add ((GeeCollection*) _tmp104_, _tmp105_);
					}
					_signal_type_unref_vapi0 (record);
				}
				_g_object_unref0 (entry);
			}
			_g_object_unref0 (_entry_it);
		}
		_tmp106_ = pre_key_records;
		_tmp107_ = gee_collection_get_size ((GeeCollection*) _tmp106_);
		_tmp108_ = _tmp107_;
		new_keys = DINO_PLUGINS_OMEMO_NUM_KEYS_TO_PUBLISH - _tmp108_;
		if (new_keys > 0) {
			gint32 next_id = 0;
			GeeSet* new_records = NULL;
			OmemoContext* _tmp109_;
			OmemoContext* _tmp110_;
			GeeSet* _tmp111_;
			GeeSet* _tmp112_;
			GeeSet* _tmp113_;
			GeeSet* _tmp114_;
			next_id = g_random_int_range ((gint32) 1, G_MAXINT32);
			_tmp109_ = dino_plugins_omemo_plugin_get_context ();
			_tmp110_ = _tmp109_;
			_tmp111_ = omemo_context_generate_pre_keys (_tmp110_, (guint) next_id, (guint) new_keys, &_inner_error0_);
			_tmp112_ = _tmp111_;
			_omemo_context_unref0 (_tmp110_);
			new_records = _tmp112_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (pre_key_records);
				_signal_type_unref_vapi0 (identity_key_pair);
				goto __catch0_g_error;
			}
			_tmp113_ = pre_key_records;
			_tmp114_ = new_records;
			gee_collection_add_all ((GeeCollection*) _tmp113_, (GeeCollection*) _tmp114_);
			{
				GeeIterator* _record_it = NULL;
				GeeSet* _tmp115_;
				GeeIterator* _tmp116_;
				_tmp115_ = new_records;
				_tmp116_ = gee_iterable_iterator ((GeeIterable*) _tmp115_);
				_record_it = _tmp116_;
				while (TRUE) {
					GeeIterator* _tmp117_;
					session_pre_key* record = NULL;
					GeeIterator* _tmp118_;
					gpointer _tmp119_;
					OmemoStore* _tmp120_;
					session_pre_key* _tmp121_;
					_tmp117_ = _record_it;
					if (!gee_iterator_next (_tmp117_)) {
						break;
					}
					_tmp118_ = _record_it;
					_tmp119_ = gee_iterator_get (_tmp118_);
					record = (session_pre_key*) _tmp119_;
					_tmp120_ = self->priv->_store;
					_tmp121_ = record;
					omemo_store_store_pre_key (_tmp120_, _tmp121_, &_inner_error0_);
					if (G_UNLIKELY (_inner_error0_ != NULL)) {
						_signal_type_unref_vapi0 (record);
						_g_object_unref0 (_record_it);
						_g_object_unref0 (new_records);
						_g_object_unref0 (pre_key_records);
						_signal_type_unref_vapi0 (identity_key_pair);
						goto __catch0_g_error;
					}
					_signal_type_unref_vapi0 (record);
				}
				_g_object_unref0 (_record_it);
			}
			changed = TRUE;
			_g_object_unref0 (new_records);
		}
		if (changed) {
			session_signed_pre_key* _tmp122_;
			ratchet_identity_key_pair* _tmp123_;
			GeeSet* _tmp124_;
			OmemoStore* _tmp125_;
			guint32 _tmp126_;
			guint32 _tmp127_;
			_tmp122_ = signed_pre_key_record;
			_tmp123_ = identity_key_pair;
			_tmp124_ = pre_key_records;
			_tmp125_ = self->priv->_store;
			_tmp126_ = omemo_store_get_local_registration_id (_tmp125_);
			_tmp127_ = _tmp126_;
			dino_plugins_omemo_stream_module_publish_bundles (self, stream, (session_signed_pre_key*) _tmp122_, _tmp123_, _tmp124_, (gint32) _tmp127_, NULL, NULL);
		}
		_g_object_unref0 (pre_key_records);
		_signal_type_unref_vapi0 (identity_key_pair);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp128_;
		const gchar* _tmp129_;
		const gchar* _tmp130_;
		gchar* _tmp131_;
		gchar* _tmp132_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp128_ = e;
		_tmp129_ = _tmp128_->message;
		_tmp130_ = string_to_string (_tmp129_);
		_tmp131_ = g_strconcat ("Unexpected error while publishing bundle: ", _tmp130_, "\n", NULL);
		_tmp132_ = _tmp131_;
		g_warning ("stream_module.vala:279: %s", _tmp132_);
		_g_free0 (_tmp132_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_signal_type_unref_vapi0 (signed_pre_key_record);
		_signal_type_unref_vapi0 (signed_pre_key);
		_signal_type_unref_vapi0 (identity_key);
		_g_object_unref0 (keys);
		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;
	}
	_tmp133_ = dino_plugins_omemo_stream_module_IDENTITY;
	_tmp134_ = xmpp_xmpp_stream_get_module (stream, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp133_);
	_tmp135_ = (DinoPluginsOmemoStreamModule*) _tmp134_;
	_tmp136_ = _tmp135_->priv->active_bundle_requests;
	_tmp137_ = xmpp_jid_get_bare_jid (jid);
	_tmp138_ = _tmp137_;
	_tmp139_ = _tmp138_;
	_tmp140_ = xmpp_jid_to_string (_tmp139_);
	_tmp141_ = _tmp140_;
	_tmp142_ = self->priv->_store;
	_tmp143_ = omemo_store_get_local_registration_id (_tmp142_);
	_tmp144_ = _tmp143_;
	_tmp145_ = g_strdup_printf ("%u", _tmp144_);
	_tmp146_ = _tmp145_;
	_tmp147_ = g_strconcat (":", _tmp146_, NULL);
	_tmp148_ = _tmp147_;
	_tmp149_ = g_strconcat (_tmp141_, _tmp148_, NULL);
	_tmp150_ = _tmp149_;
	gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp136_, _tmp150_);
	_g_free0 (_tmp150_);
	_g_free0 (_tmp148_);
	_g_free0 (_tmp146_);
	_g_free0 (_tmp141_);
	_xmpp_jid_unref0 (_tmp139_);
	_g_object_unref0 (_tmp135_);
	_signal_type_unref_vapi0 (signed_pre_key_record);
	_signal_type_unref_vapi0 (signed_pre_key);
	_signal_type_unref_vapi0 (identity_key);
	_g_object_unref0 (keys);
}

static void
dino_plugins_omemo_stream_module_publish_bundles_data_free (gpointer _data)
{
	DinoPluginsOmemoStreamModulePublishBundlesData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_signal_type_unref_vapi0 (_data_->signed_pre_key_record);
	_signal_type_unref_vapi0 (_data_->identity_key_pair);
	_g_object_unref0 (_data_->pre_key_records);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOmemoStreamModulePublishBundlesData, _data_);
}

void
dino_plugins_omemo_stream_module_publish_bundles (DinoPluginsOmemoStreamModule* self,
                                                  XmppXmppStream* stream,
                                                  session_signed_pre_key* signed_pre_key_record,
                                                  ratchet_identity_key_pair* identity_key_pair,
                                                  GeeSet* pre_key_records,
                                                  gint32 device_id,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_)
{
	DinoPluginsOmemoStreamModulePublishBundlesData* _data_;
	DinoPluginsOmemoStreamModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	session_signed_pre_key* _tmp2_;
	ratchet_identity_key_pair* _tmp3_;
	GeeSet* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (signed_pre_key_record != NULL);
	g_return_if_fail (identity_key_pair != NULL);
	g_return_if_fail (pre_key_records != NULL);
	_data_ = g_slice_new0 (DinoPluginsOmemoStreamModulePublishBundlesData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_omemo_stream_module_publish_bundles_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp1_;
	_tmp2_ = _signal_type_ref_vapi0 (signed_pre_key_record);
	_signal_type_unref_vapi0 (_data_->signed_pre_key_record);
	_data_->signed_pre_key_record = _tmp2_;
	_tmp3_ = _signal_type_ref_vapi0 (identity_key_pair);
	_signal_type_unref_vapi0 (_data_->identity_key_pair);
	_data_->identity_key_pair = _tmp3_;
	_tmp4_ = _g_object_ref0 (pre_key_records);
	_g_object_unref0 (_data_->pre_key_records);
	_data_->pre_key_records = _tmp4_;
	_data_->device_id = device_id;
	dino_plugins_omemo_stream_module_publish_bundles_co (_data_);
}

void
dino_plugins_omemo_stream_module_publish_bundles_finish (DinoPluginsOmemoStreamModule* self,
                                                         GAsyncResult* _res_,
                                                         GError** error)
{
	DinoPluginsOmemoStreamModulePublishBundlesData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static guint8*
session_signed_pre_key_get_signature_ (session_signed_pre_key* self,
                                       gint* result_length1)
{
	guint8* result;
	gint x = 0;
	guint8* res = NULL;
	guint8* _tmp0_;
	gint res_length1;
	gint _res_size_;
	guint8* _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, NULL);
	x = (gint) session_signed_pre_key_get_signature_len (self);
	_tmp0_ = session_signed_pre_key_get_signature (self);
	res = _tmp0_;
	res_length1 = -1;
	_res_size_ = res_length1;
	res_length1 = x;
	_tmp1_ = res;
	_tmp1__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

static void
dino_plugins_omemo_stream_module_publish_bundles_ready (GObject* source_object,
                                                        GAsyncResult* _res_,
                                                        gpointer _user_data_)
{
	DinoPluginsOmemoStreamModulePublishBundlesData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_omemo_stream_module_publish_bundles_co (_data_);
}

static gboolean
dino_plugins_omemo_stream_module_publish_bundles_co (DinoPluginsOmemoStreamModulePublishBundlesData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = xmpp_stanza_node_new_build ("bundle", DINO_PLUGINS_OMEMO_NS_URI, NULL, NULL);
	_data_->_tmp1_ = _data_->_tmp0_;
	_data_->_tmp2_ = xmpp_stanza_node_add_self_xmlns (_data_->_tmp1_);
	_data_->_tmp3_ = _data_->_tmp2_;
	_data_->_tmp4_ = xmpp_stanza_node_new_build ("signedPreKeyPublic", DINO_PLUGINS_OMEMO_NS_URI, NULL, NULL);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = session_signed_pre_key_get_id (_data_->signed_pre_key_record);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = g_strdup_printf ("%u", _data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	_data_->_tmp10_ = xmpp_stanza_node_put_attribute (_data_->_tmp5_, "signedPreKeyId", _data_->_tmp9_, NULL);
	_data_->_tmp11_ = _data_->_tmp10_;
	_data_->_tmp12_ = session_signed_pre_key_get_key_pair (_data_->signed_pre_key_record);
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_tmp14_ = _signal_type_ref_vapi0 (_data_->_tmp13_);
	_signal_type_unref_vapi0 (_data_->tmp);
	_data_->tmp = _data_->_tmp14_;
	_data_->_tmp15_ = _data_->tmp;
	_data_->_tmp16_ = ec_key_pair_get_public (_data_->_tmp15_);
	_data_->_tmp17_ = _data_->_tmp16_;
	_data_->_tmp18_ = 0;
	_data_->_tmp19_ = ec_public_key_serialize_ (_data_->_tmp17_, &_data_->_tmp18_);
	_data_->_tmp20_ = _data_->_tmp19_;
	_data_->_tmp20__length1 = _data_->_tmp18_;
	_data_->_tmp21_ = g_base64_encode (_data_->_tmp20_, (gint) _data_->_tmp18_);
	_data_->_tmp22_ = _data_->_tmp21_;
	_data_->_tmp23_ = xmpp_stanza_node_new_text (_data_->_tmp22_);
	_data_->_tmp24_ = _data_->_tmp23_;
	_data_->_tmp25_ = xmpp_stanza_node_put_node (_data_->_tmp11_, _data_->_tmp24_);
	_data_->_tmp26_ = _data_->_tmp25_;
	_data_->_tmp27_ = xmpp_stanza_node_put_node (_data_->_tmp3_, _data_->_tmp26_);
	_data_->_tmp28_ = _data_->_tmp27_;
	_data_->_tmp29_ = xmpp_stanza_node_new_build ("signedPreKeySignature", DINO_PLUGINS_OMEMO_NS_URI, NULL, NULL);
	_data_->_tmp30_ = _data_->_tmp29_;
	_data_->_tmp32_ = 0;
	_data_->_tmp31_ = session_signed_pre_key_get_signature_ (_data_->signed_pre_key_record, &_data_->_tmp32_);
	_data_->_tmp31__length1 = _data_->_tmp32_;
	_data_->_tmp33_ = _data_->_tmp31_;
	_data_->_tmp33__length1 = _data_->_tmp31__length1;
	_data_->_tmp34_ = g_base64_encode (_data_->_tmp33_, (gint) _data_->_tmp33__length1);
	_data_->_tmp35_ = _data_->_tmp34_;
	_data_->_tmp36_ = xmpp_stanza_node_new_text (_data_->_tmp35_);
	_data_->_tmp37_ = _data_->_tmp36_;
	_data_->_tmp38_ = xmpp_stanza_node_put_node (_data_->_tmp30_, _data_->_tmp37_);
	_data_->_tmp39_ = _data_->_tmp38_;
	_data_->_tmp40_ = xmpp_stanza_node_put_node (_data_->_tmp28_, _data_->_tmp39_);
	_data_->_tmp41_ = _data_->_tmp40_;
	_data_->_tmp42_ = xmpp_stanza_node_new_build ("identityKey", DINO_PLUGINS_OMEMO_NS_URI, NULL, NULL);
	_data_->_tmp43_ = _data_->_tmp42_;
	_data_->_tmp44_ = ratchet_identity_key_pair_get_public (_data_->identity_key_pair);
	_data_->_tmp45_ = _data_->_tmp44_;
	_data_->_tmp46_ = 0;
	_data_->_tmp47_ = ec_public_key_serialize_ (_data_->_tmp45_, &_data_->_tmp46_);
	_data_->_tmp48_ = _data_->_tmp47_;
	_data_->_tmp48__length1 = _data_->_tmp46_;
	_data_->_tmp49_ = g_base64_encode (_data_->_tmp48_, (gint) _data_->_tmp46_);
	_data_->_tmp50_ = _data_->_tmp49_;
	_data_->_tmp51_ = xmpp_stanza_node_new_text (_data_->_tmp50_);
	_data_->_tmp52_ = _data_->_tmp51_;
	_data_->_tmp53_ = xmpp_stanza_node_put_node (_data_->_tmp43_, _data_->_tmp52_);
	_data_->_tmp54_ = _data_->_tmp53_;
	_data_->_tmp55_ = xmpp_stanza_node_put_node (_data_->_tmp41_, _data_->_tmp54_);
	_data_->_tmp56_ = _data_->_tmp55_;
	_xmpp_stanza_entry_unref0 (_data_->_tmp54_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp52_);
	_g_free0 (_data_->_tmp50_);
	_data_->_tmp48_ = (g_free (_data_->_tmp48_), NULL);
	_xmpp_stanza_entry_unref0 (_data_->_tmp43_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp41_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp39_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp37_);
	_g_free0 (_data_->_tmp35_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp30_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp28_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp26_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp24_);
	_g_free0 (_data_->_tmp22_);
	_data_->_tmp20_ = (g_free (_data_->_tmp20_), NULL);
	_xmpp_stanza_entry_unref0 (_data_->_tmp11_);
	_g_free0 (_data_->_tmp9_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp5_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp3_);
	_xmpp_stanza_entry_unref0 (_data_->_tmp1_);
	_data_->bundle = _data_->_tmp56_;
	_data_->_tmp57_ = xmpp_stanza_node_new_build ("prekeys", DINO_PLUGINS_OMEMO_NS_URI, NULL, NULL);
	_data_->prekeys = _data_->_tmp57_;
	{
		_data_->_tmp58_ = gee_iterable_iterator ((GeeIterable*) _data_->pre_key_records);
		_data_->_pre_key_record_it = _data_->_tmp58_;
		while (TRUE) {
			_data_->_tmp59_ = _data_->_pre_key_record_it;
			if (!gee_iterator_next (_data_->_tmp59_)) {
				break;
			}
			_data_->_tmp60_ = _data_->_pre_key_record_it;
			_data_->_tmp61_ = gee_iterator_get (_data_->_tmp60_);
			_data_->pre_key_record = (session_pre_key*) _data_->_tmp61_;
			_data_->_tmp62_ = _data_->prekeys;
			_data_->_tmp63_ = xmpp_stanza_node_new_build ("preKeyPublic", DINO_PLUGINS_OMEMO_NS_URI, NULL, NULL);
			_data_->_tmp64_ = _data_->_tmp63_;
			_data_->_tmp65_ = _data_->pre_key_record;
			_data_->_tmp66_ = session_pre_key_get_id (_data_->_tmp65_);
			_data_->_tmp67_ = _data_->_tmp66_;
			_data_->_tmp68_ = g_strdup_printf ("%u", _data_->_tmp67_);
			_data_->_tmp69_ = _data_->_tmp68_;
			_data_->_tmp70_ = xmpp_stanza_node_put_attribute (_data_->_tmp64_, "preKeyId", _data_->_tmp69_, NULL);
			_data_->_tmp71_ = _data_->_tmp70_;
			_data_->_tmp72_ = _data_->pre_key_record;
			_data_->_tmp73_ = session_pre_key_get_key_pair (_data_->_tmp72_);
			_data_->_tmp74_ = _data_->_tmp73_;
			_data_->_tmp75_ = ec_key_pair_get_public (_data_->_tmp74_);
			_data_->_tmp76_ = _data_->_tmp75_;
			_data_->_tmp77_ = 0;
			_data_->_tmp78_ = ec_public_key_serialize_ (_data_->_tmp76_, &_data_->_tmp77_);
			_data_->_tmp79_ = _data_->_tmp78_;
			_data_->_tmp79__length1 = _data_->_tmp77_;
			_data_->_tmp80_ = g_base64_encode (_data_->_tmp79_, (gint) _data_->_tmp77_);
			_data_->_tmp81_ = _data_->_tmp80_;
			_data_->_tmp82_ = xmpp_stanza_node_new_text (_data_->_tmp81_);
			_data_->_tmp83_ = _data_->_tmp82_;
			_data_->_tmp84_ = xmpp_stanza_node_put_node (_data_->_tmp71_, _data_->_tmp83_);
			_data_->_tmp85_ = _data_->_tmp84_;
			_data_->_tmp86_ = xmpp_stanza_node_put_node (_data_->_tmp62_, _data_->_tmp85_);
			_data_->_tmp87_ = _data_->_tmp86_;
			_xmpp_stanza_entry_unref0 (_data_->_tmp87_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp85_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp83_);
			_g_free0 (_data_->_tmp81_);
			_data_->_tmp79_ = (g_free (_data_->_tmp79_), NULL);
			_xmpp_stanza_entry_unref0 (_data_->_tmp71_);
			_g_free0 (_data_->_tmp69_);
			_xmpp_stanza_entry_unref0 (_data_->_tmp64_);
			_signal_type_unref_vapi0 (_data_->pre_key_record);
		}
		_g_object_unref0 (_data_->_pre_key_record_it);
	}
	_data_->_tmp88_ = _data_->bundle;
	_data_->_tmp89_ = _data_->prekeys;
	_data_->_tmp90_ = xmpp_stanza_node_put_node (_data_->_tmp88_, _data_->_tmp89_);
	_data_->_tmp91_ = _data_->_tmp90_;
	_xmpp_stanza_entry_unref0 (_data_->_tmp91_);
	_data_->_tmp92_ = string_to_string (DINO_PLUGINS_OMEMO_NODE_BUNDLES);
	_data_->_tmp93_ = g_strdup_printf ("%i", _data_->device_id);
	_data_->_tmp94_ = _data_->_tmp93_;
	_data_->_tmp95_ = g_strconcat (_data_->_tmp92_, ":", _data_->_tmp94_, NULL);
	_data_->_tmp96_ = _data_->_tmp95_;
	_g_free0 (_data_->_tmp94_);
	_data_->node_id = _data_->_tmp96_;
	_data_->_tmp97_ = xmpp_xep_pubsub_module_IDENTITY;
	_data_->_tmp98_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp97_);
	_data_->_tmp99_ = (XmppXepPubsubModule*) _data_->_tmp98_;
	_data_->_tmp100_ = _data_->bundle;
	_data_->_state_ = 1;
	xmpp_xep_pubsub_module_publish (_data_->_tmp99_, _data_->stream, NULL, _data_->node_id, "1", _data_->_tmp100_, NULL, TRUE, dino_plugins_omemo_stream_module_publish_bundles_ready, _data_);
	return FALSE;
	_state_1:
	xmpp_xep_pubsub_module_publish_finish (_data_->_tmp99_, _data_->_res_);
	_g_object_unref0 (_data_->_tmp99_);
	_data_->_state_ = 2;
	dino_plugins_omemo_stream_module_try_make_node_public (_data_->self, _data_->stream, _data_->node_id, dino_plugins_omemo_stream_module_publish_bundles_ready, _data_);
	return FALSE;
	_state_2:
	dino_plugins_omemo_stream_module_try_make_node_public_finish (_data_->self, _data_->_res_);
	_g_free0 (_data_->node_id);
	_xmpp_stanza_entry_unref0 (_data_->prekeys);
	_xmpp_stanza_entry_unref0 (_data_->bundle);
	_signal_type_unref_vapi0 (_data_->tmp);
	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_omemo_stream_module_try_make_node_public_data_free (gpointer _data)
{
	DinoPluginsOmemoStreamModuleTryMakeNodePublicData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->stream);
	_g_free0 (_data_->node_id);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOmemoStreamModuleTryMakeNodePublicData, _data_);
}

static void
dino_plugins_omemo_stream_module_try_make_node_public (DinoPluginsOmemoStreamModule* self,
                                                       XmppXmppStream* stream,
                                                       const gchar* node_id,
                                                       GAsyncReadyCallback _callback_,
                                                       gpointer _user_data_)
{
	DinoPluginsOmemoStreamModuleTryMakeNodePublicData* _data_;
	DinoPluginsOmemoStreamModule* _tmp0_;
	XmppXmppStream* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stream != NULL);
	g_return_if_fail (node_id != NULL);
	_data_ = g_slice_new0 (DinoPluginsOmemoStreamModuleTryMakeNodePublicData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_plugins_omemo_stream_module_try_make_node_public_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (stream);
	_g_object_unref0 (_data_->stream);
	_data_->stream = _tmp1_;
	_tmp2_ = g_strdup (node_id);
	_g_free0 (_data_->node_id);
	_data_->node_id = _tmp2_;
	dino_plugins_omemo_stream_module_try_make_node_public_co (_data_);
}

static void
dino_plugins_omemo_stream_module_try_make_node_public_finish (DinoPluginsOmemoStreamModule* self,
                                                              GAsyncResult* _res_)
{
	DinoPluginsOmemoStreamModuleTryMakeNodePublicData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dino_plugins_omemo_stream_module_try_make_node_public_ready (GObject* source_object,
                                                             GAsyncResult* _res_,
                                                             gpointer _user_data_)
{
	DinoPluginsOmemoStreamModuleTryMakeNodePublicData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_omemo_stream_module_try_make_node_public_co (_data_);
}

static gboolean
dino_plugins_omemo_stream_module_try_make_node_public_co (DinoPluginsOmemoStreamModuleTryMakeNodePublicData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = xmpp_xep_pubsub_module_IDENTITY;
	_data_->_tmp1_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp0_);
	_data_->_tmp2_ = (XmppXepPubsubModule*) _data_->_tmp1_;
	_data_->_state_ = 1;
	xmpp_xep_pubsub_module_request_node_config (_data_->_tmp2_, _data_->stream, NULL, _data_->node_id, dino_plugins_omemo_stream_module_try_make_node_public_ready, _data_);
	return FALSE;
	_state_1:
	_data_->_tmp3_ = xmpp_xep_pubsub_module_request_node_config_finish (_data_->_tmp2_, _data_->_res_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_g_object_unref0 (_data_->_tmp2_);
	_data_->data_form = _data_->_tmp4_;
	_data_->_tmp5_ = _data_->data_form;
	if (_data_->_tmp5_ == NULL) {
		_xmpp_xep_data_forms_data_form_unref0 (_data_->data_form);
		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_->_tmp6_ = _data_->data_form;
		_data_->_tmp7_ = _data_->_tmp6_->fields;
		_data_->_field_list = _data_->_tmp7_;
		_data_->_tmp8_ = _data_->_field_list;
		_data_->_tmp9_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp8_);
		_data_->_tmp10_ = _data_->_tmp9_;
		_data_->_field_size = _data_->_tmp10_;
		_data_->_field_index = -1;
		while (TRUE) {
			_data_->_field_index = _data_->_field_index + 1;
			_data_->_tmp11_ = _data_->_field_index;
			_data_->_tmp12_ = _data_->_field_size;
			if (!(_data_->_tmp11_ < _data_->_tmp12_)) {
				break;
			}
			_data_->_tmp13_ = _data_->_field_list;
			_data_->_tmp14_ = gee_list_get (_data_->_tmp13_, _data_->_field_index);
			_data_->field = (XmppXepDataFormsDataFormField*) _data_->_tmp14_;
			_data_->_tmp16_ = _data_->field;
			_data_->_tmp17_ = xmpp_xep_data_forms_data_form_field_get_var (_data_->_tmp16_);
			_data_->_tmp18_ = _data_->_tmp17_;
			if (g_strcmp0 (_data_->_tmp18_, "pubsub#access_model") == 0) {
				_data_->_tmp19_ = _data_->field;
				_data_->_tmp20_ = xmpp_xep_data_forms_data_form_field_get_value_string (_data_->_tmp19_);
				_data_->_tmp21_ = _data_->_tmp20_;
				_data_->_tmp15_ = g_strcmp0 (_data_->_tmp21_, XMPP_XEP_PUBSUB_ACCESS_MODEL_OPEN) != 0;
				_g_free0 (_data_->_tmp21_);
			} else {
				_data_->_tmp15_ = FALSE;
			}
			if (_data_->_tmp15_) {
				_data_->_tmp22_ = _data_->field;
				xmpp_xep_data_forms_data_form_field_set_value_string (_data_->_tmp22_, XMPP_XEP_PUBSUB_ACCESS_MODEL_OPEN);
				_data_->_tmp23_ = xmpp_xep_pubsub_module_IDENTITY;
				_data_->_tmp24_ = xmpp_xmpp_stream_get_module (_data_->stream, XMPP_XEP_PUBSUB_TYPE_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp23_);
				_data_->_tmp25_ = (XmppXepPubsubModule*) _data_->_tmp24_;
				_data_->_tmp26_ = _data_->data_form;
				_data_->_state_ = 2;
				xmpp_xep_pubsub_module_submit_node_config (_data_->_tmp25_, _data_->stream, _data_->_tmp26_, _data_->node_id, dino_plugins_omemo_stream_module_try_make_node_public_ready, _data_);
				return FALSE;
				_state_2:
				xmpp_xep_pubsub_module_submit_node_config_finish (_data_->_tmp25_, _data_->_res_);
				_g_object_unref0 (_data_->_tmp25_);
				_g_object_unref0 (_data_->field);
				break;
			}
			_g_object_unref0 (_data_->field);
		}
	}
	_xmpp_xep_data_forms_data_form_unref0 (_data_->data_form);
	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 gchar*
dino_plugins_omemo_stream_module_real_get_ns (XmppXmppStreamModule* base)
{
	DinoPluginsOmemoStreamModule * self;
	gchar* _tmp0_;
	gchar* result;
	self = (DinoPluginsOmemoStreamModule*) base;
	_tmp0_ = g_strdup (DINO_PLUGINS_OMEMO_NS_URI);
	result = _tmp0_;
	return result;
}

static gchar*
dino_plugins_omemo_stream_module_real_get_id (XmppXmppStreamModule* base)
{
	DinoPluginsOmemoStreamModule * self;
	XmppModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* result;
	self = (DinoPluginsOmemoStreamModule*) base;
	_tmp0_ = dino_plugins_omemo_stream_module_IDENTITY;
	_tmp1_ = xmpp_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup (_tmp2_);
	result = _tmp3_;
	return result;
}

OmemoStore*
dino_plugins_omemo_stream_module_get_store (DinoPluginsOmemoStreamModule* self)
{
	OmemoStore* result;
	OmemoStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_store;
	result = _tmp0_;
	return result;
}

static void
dino_plugins_omemo_stream_module_set_store (DinoPluginsOmemoStreamModule* self,
                                            OmemoStore* value)
{
	OmemoStore* old_value;
	g_return_if_fail (self != NULL);
	old_value = dino_plugins_omemo_stream_module_get_store (self);
	if (old_value != value) {
		OmemoStore* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_store);
		self->priv->_store = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, dino_plugins_omemo_stream_module_properties[DINO_PLUGINS_OMEMO_STREAM_MODULE_STORE_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__XMPP_JID_OBJECT (GClosure * closure,
                                               GValue * return_value,
                                               guint n_param_values,
                                               const GValue * param_values,
                                               gpointer invocation_hint,
                                               gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__XMPP_JID_OBJECT) (gpointer data1, gpointer arg_1, gpointer arg_2, gpointer data2);
	register GMarshalFunc_VOID__XMPP_JID_OBJECT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__XMPP_JID_OBJECT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, xmpp_value_get_jid (param_values + 1), g_value_get_object (param_values + 2), data2);
}

static void
g_cclosure_user_marshal_VOID__XMPP_JID_INT_DINO_PLUGINS_OMEMO_BUNDLE (GClosure * closure,
                                                                      GValue * return_value,
                                                                      guint n_param_values,
                                                                      const GValue * param_values,
                                                                      gpointer invocation_hint,
                                                                      gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__XMPP_JID_INT_DINO_PLUGINS_OMEMO_BUNDLE) (gpointer data1, gpointer arg_1, gint arg_2, gpointer arg_3, gpointer data2);
	register GMarshalFunc_VOID__XMPP_JID_INT_DINO_PLUGINS_OMEMO_BUNDLE callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 4);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__XMPP_JID_INT_DINO_PLUGINS_OMEMO_BUNDLE) (marshal_data ? marshal_data : cc->callback);
	callback (data1, xmpp_value_get_jid (param_values + 1), g_value_get_int (param_values + 2), dino_plugins_omemo_value_get_bundle (param_values + 3), data2);
}

static void
g_cclosure_user_marshal_VOID__XMPP_JID_INT (GClosure * closure,
                                            GValue * return_value,
                                            guint n_param_values,
                                            const GValue * param_values,
                                            gpointer invocation_hint,
                                            gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__XMPP_JID_INT) (gpointer data1, gpointer arg_1, gint arg_2, gpointer data2);
	register GMarshalFunc_VOID__XMPP_JID_INT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__XMPP_JID_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, xmpp_value_get_jid (param_values + 1), g_value_get_int (param_values + 2), data2);
}

static void
dino_plugins_omemo_stream_module_class_init (DinoPluginsOmemoStreamModuleClass * klass,
                                             gpointer klass_data)
{
	XmppModuleIdentity* _tmp0_;
	dino_plugins_omemo_stream_module_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoPluginsOmemoStreamModule_private_offset);
	((XmppXmppStreamModuleClass *) klass)->attach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) dino_plugins_omemo_stream_module_real_attach;
	((XmppXmppStreamModuleClass *) klass)->detach = (void (*) (XmppXmppStreamModule*, XmppXmppStream*)) dino_plugins_omemo_stream_module_real_detach;
	((XmppXmppStreamModuleClass *) klass)->get_ns = (gchar* (*) (XmppXmppStreamModule*)) dino_plugins_omemo_stream_module_real_get_ns;
	((XmppXmppStreamModuleClass *) klass)->get_id = (gchar* (*) (XmppXmppStreamModule*)) dino_plugins_omemo_stream_module_real_get_id;
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_plugins_omemo_stream_module_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dino_plugins_omemo_stream_module_set_property;
	G_OBJECT_CLASS (klass)->finalize = dino_plugins_omemo_stream_module_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_PLUGINS_OMEMO_STREAM_MODULE_STORE_PROPERTY, dino_plugins_omemo_stream_module_properties[DINO_PLUGINS_OMEMO_STREAM_MODULE_STORE_PROPERTY] = g_param_spec_object ("store", "store", "store", OMEMO_TYPE_STORE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	dino_plugins_omemo_stream_module_signals[DINO_PLUGINS_OMEMO_STREAM_MODULE_DEVICE_LIST_LOADED_SIGNAL] = g_signal_new ("device-list-loaded", DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__XMPP_JID_OBJECT, G_TYPE_NONE, 2, XMPP_TYPE_JID, GEE_TYPE_ARRAY_LIST);
	dino_plugins_omemo_stream_module_signals[DINO_PLUGINS_OMEMO_STREAM_MODULE_BUNDLE_FETCHED_SIGNAL] = g_signal_new ("bundle-fetched", DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__XMPP_JID_INT_DINO_PLUGINS_OMEMO_BUNDLE, G_TYPE_NONE, 3, XMPP_TYPE_JID, G_TYPE_INT, DINO_PLUGINS_OMEMO_TYPE_BUNDLE);
	dino_plugins_omemo_stream_module_signals[DINO_PLUGINS_OMEMO_STREAM_MODULE_BUNDLE_FETCH_FAILED_SIGNAL] = g_signal_new ("bundle-fetch-failed", DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__XMPP_JID_INT, G_TYPE_NONE, 2, XMPP_TYPE_JID, G_TYPE_INT);
	_tmp0_ = xmpp_module_identity_new (DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, DINO_PLUGINS_OMEMO_NS_URI, "omemo_module");
	dino_plugins_omemo_stream_module_IDENTITY = _tmp0_;
}

static void
dino_plugins_omemo_stream_module_instance_init (DinoPluginsOmemoStreamModule * self,
                                                gpointer klass)
{
	GeeConcurrentSet* _tmp0_;
	GeeHashMap* _tmp1_;
	GeeHashMap* _tmp2_;
	self->priv = dino_plugins_omemo_stream_module_get_instance_private (self);
	_tmp0_ = gee_concurrent_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	self->priv->active_bundle_requests = _tmp0_;
	_tmp1_ = gee_hash_map_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, GEE_TYPE_FUTURE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _xmpp_jid_hash_func_gee_hash_data_func, NULL, NULL, _xmpp_jid_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->active_devicelist_requests = _tmp1_;
	g_rec_mutex_init (&self->priv->__lock_device_ignore_time);
	_tmp2_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, G_TYPE_DATE_TIME, (GBoxedCopyFunc) g_date_time_ref, (GDestroyNotify) g_date_time_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->device_ignore_time = (GeeMap*) _tmp2_;
}

static void
dino_plugins_omemo_stream_module_finalize (GObject * obj)
{
	DinoPluginsOmemoStreamModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, DinoPluginsOmemoStreamModule);
	_g_object_unref0 (self->priv->_store);
	_g_object_unref0 (self->priv->active_bundle_requests);
	_g_object_unref0 (self->priv->active_devicelist_requests);
	g_rec_mutex_clear (&self->priv->__lock_device_ignore_time);
	_g_object_unref0 (self->priv->device_ignore_time);
	G_OBJECT_CLASS (dino_plugins_omemo_stream_module_parent_class)->finalize (obj);
}

static GType
dino_plugins_omemo_stream_module_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOmemoStreamModuleClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_omemo_stream_module_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOmemoStreamModule), 0, (GInstanceInitFunc) dino_plugins_omemo_stream_module_instance_init, NULL };
	GType dino_plugins_omemo_stream_module_type_id;
	dino_plugins_omemo_stream_module_type_id = g_type_register_static (XMPP_TYPE_XMPP_STREAM_MODULE, "DinoPluginsOmemoStreamModule", &g_define_type_info, 0);
	DinoPluginsOmemoStreamModule_private_offset = g_type_add_instance_private (dino_plugins_omemo_stream_module_type_id, sizeof (DinoPluginsOmemoStreamModulePrivate));
	return dino_plugins_omemo_stream_module_type_id;
}

GType
dino_plugins_omemo_stream_module_get_type (void)
{
	static volatile gsize dino_plugins_omemo_stream_module_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_omemo_stream_module_type_id__once)) {
		GType dino_plugins_omemo_stream_module_type_id;
		dino_plugins_omemo_stream_module_type_id = dino_plugins_omemo_stream_module_get_type_once ();
		g_once_init_leave (&dino_plugins_omemo_stream_module_type_id__once, dino_plugins_omemo_stream_module_type_id);
	}
	return dino_plugins_omemo_stream_module_type_id__once;
}

static void
_vala_dino_plugins_omemo_stream_module_get_property (GObject * object,
                                                     guint property_id,
                                                     GValue * value,
                                                     GParamSpec * pspec)
{
	DinoPluginsOmemoStreamModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, DinoPluginsOmemoStreamModule);
	switch (property_id) {
		case DINO_PLUGINS_OMEMO_STREAM_MODULE_STORE_PROPERTY:
		g_value_set_object (value, dino_plugins_omemo_stream_module_get_store (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dino_plugins_omemo_stream_module_set_property (GObject * object,
                                                     guint property_id,
                                                     const GValue * value,
                                                     GParamSpec * pspec)
{
	DinoPluginsOmemoStreamModule * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, DinoPluginsOmemoStreamModule);
	switch (property_id) {
		case DINO_PLUGINS_OMEMO_STREAM_MODULE_STORE_PROPERTY:
		dino_plugins_omemo_stream_module_set_store (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

