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

#include "omemo.h"
#include "libdino.h"
#include <gee.h>
#include <glib-object.h>
#include <glib.h>
#include "xmpp-vala.h"
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include "qlite.h"
#include <omemo/curve.h>
#include <native/helper.h>
#include <omemo/signal_protocol_types.h>
#include <omemo/signal_protocol.h>
#include <gobject/gvaluecollector.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE (dino_plugins_omemo_manager_message_state_get_type ())
#define DINO_PLUGINS_OMEMO_MANAGER_MESSAGE_STATE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE, DinoPluginsOmemoManagerMessageState))
#define DINO_PLUGINS_OMEMO_MANAGER_MESSAGE_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE, DinoPluginsOmemoManagerMessageStateClass))
#define DINO_PLUGINS_OMEMO_MANAGER_IS_MESSAGE_STATE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE))
#define DINO_PLUGINS_OMEMO_MANAGER_IS_MESSAGE_STATE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE))
#define DINO_PLUGINS_OMEMO_MANAGER_MESSAGE_STATE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE, DinoPluginsOmemoManagerMessageStateClass))

typedef struct _DinoPluginsOmemoManagerMessageState DinoPluginsOmemoManagerMessageState;
typedef struct _DinoPluginsOmemoManagerMessageStateClass DinoPluginsOmemoManagerMessageStateClass;
enum  {
	DINO_PLUGINS_OMEMO_MANAGER_0_PROPERTY,
	DINO_PLUGINS_OMEMO_MANAGER_ID_PROPERTY,
	DINO_PLUGINS_OMEMO_MANAGER_NUM_PROPERTIES
};
static GParamSpec* dino_plugins_omemo_manager_properties[DINO_PLUGINS_OMEMO_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _qlite_database_unref0(var) ((var == NULL) ? NULL : (var = (qlite_database_unref (var), NULL)))
#define _dino_plugins_omemo_trust_manager_unref0(var) ((var == NULL) ? NULL : (var = (dino_plugins_omemo_trust_manager_unref (var), NULL)))
#define _xmpp_jid_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_jid_unref (var), NULL)))
#define _dino_plugins_omemo_manager_message_state_unref0(var) ((var == NULL) ? NULL : (var = (dino_plugins_omemo_manager_message_state_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _xmpp_xep_omemo_encrypt_state_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_omemo_encrypt_state_unref (var), NULL)))
typedef struct _Block3Data Block3Data;
#define _qlite_statement_builder_unref0(var) ((var == NULL) ? NULL : (var = (qlite_statement_builder_unref (var), NULL)))
#define _qlite_row_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_unref (var), NULL)))
#define _qlite_row_iterator_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_iterator_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _signal_buffer_free0(var) ((var == NULL) ? NULL : (var = (signal_buffer_free (var), NULL)))
#define _qlite_row_option_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_option_unref (var), NULL)))
#define _signal_type_unref_vapi0(var) ((var == NULL) ? NULL : (var = (signal_type_unref_vapi (var), NULL)))
typedef struct _Block4Data Block4Data;
#define _omemo_context_unref0(var) ((var == NULL) ? NULL : (var = (omemo_context_unref (var), NULL)))
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))

#define DINO_PLUGINS_OMEMO_TYPE_BACKED_SIGNED_PRE_KEY_STORE (dino_plugins_omemo_backed_signed_pre_key_store_get_type ())
#define DINO_PLUGINS_OMEMO_BACKED_SIGNED_PRE_KEY_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_SIGNED_PRE_KEY_STORE, DinoPluginsOmemoBackedSignedPreKeyStore))
#define DINO_PLUGINS_OMEMO_BACKED_SIGNED_PRE_KEY_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_PLUGINS_OMEMO_TYPE_BACKED_SIGNED_PRE_KEY_STORE, DinoPluginsOmemoBackedSignedPreKeyStoreClass))
#define DINO_PLUGINS_OMEMO_IS_BACKED_SIGNED_PRE_KEY_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_SIGNED_PRE_KEY_STORE))
#define DINO_PLUGINS_OMEMO_IS_BACKED_SIGNED_PRE_KEY_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_PLUGINS_OMEMO_TYPE_BACKED_SIGNED_PRE_KEY_STORE))
#define DINO_PLUGINS_OMEMO_BACKED_SIGNED_PRE_KEY_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_SIGNED_PRE_KEY_STORE, DinoPluginsOmemoBackedSignedPreKeyStoreClass))

typedef struct _DinoPluginsOmemoBackedSignedPreKeyStore DinoPluginsOmemoBackedSignedPreKeyStore;
typedef struct _DinoPluginsOmemoBackedSignedPreKeyStoreClass DinoPluginsOmemoBackedSignedPreKeyStoreClass;

#define DINO_PLUGINS_OMEMO_TYPE_BACKED_PRE_KEY_STORE (dino_plugins_omemo_backed_pre_key_store_get_type ())
#define DINO_PLUGINS_OMEMO_BACKED_PRE_KEY_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_PRE_KEY_STORE, DinoPluginsOmemoBackedPreKeyStore))
#define DINO_PLUGINS_OMEMO_BACKED_PRE_KEY_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_PLUGINS_OMEMO_TYPE_BACKED_PRE_KEY_STORE, DinoPluginsOmemoBackedPreKeyStoreClass))
#define DINO_PLUGINS_OMEMO_IS_BACKED_PRE_KEY_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_PRE_KEY_STORE))
#define DINO_PLUGINS_OMEMO_IS_BACKED_PRE_KEY_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_PLUGINS_OMEMO_TYPE_BACKED_PRE_KEY_STORE))
#define DINO_PLUGINS_OMEMO_BACKED_PRE_KEY_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_PRE_KEY_STORE, DinoPluginsOmemoBackedPreKeyStoreClass))

typedef struct _DinoPluginsOmemoBackedPreKeyStore DinoPluginsOmemoBackedPreKeyStore;
typedef struct _DinoPluginsOmemoBackedPreKeyStoreClass DinoPluginsOmemoBackedPreKeyStoreClass;

#define DINO_PLUGINS_OMEMO_TYPE_BACKED_SESSION_STORE (dino_plugins_omemo_backed_session_store_get_type ())
#define DINO_PLUGINS_OMEMO_BACKED_SESSION_STORE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_SESSION_STORE, DinoPluginsOmemoBackedSessionStore))
#define DINO_PLUGINS_OMEMO_BACKED_SESSION_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_PLUGINS_OMEMO_TYPE_BACKED_SESSION_STORE, DinoPluginsOmemoBackedSessionStoreClass))
#define DINO_PLUGINS_OMEMO_IS_BACKED_SESSION_STORE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_SESSION_STORE))
#define DINO_PLUGINS_OMEMO_IS_BACKED_SESSION_STORE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_PLUGINS_OMEMO_TYPE_BACKED_SESSION_STORE))
#define DINO_PLUGINS_OMEMO_BACKED_SESSION_STORE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_PLUGINS_OMEMO_TYPE_BACKED_SESSION_STORE, DinoPluginsOmemoBackedSessionStoreClass))

typedef struct _DinoPluginsOmemoBackedSessionStore DinoPluginsOmemoBackedSessionStore;
typedef struct _DinoPluginsOmemoBackedSessionStoreClass DinoPluginsOmemoBackedSessionStoreClass;
typedef struct _DinoPluginsOmemoManagerInitializeStoreData DinoPluginsOmemoManagerInitializeStoreData;
typedef struct _DinoPluginsOmemoManagerEnsureGetKeysForConversationData DinoPluginsOmemoManagerEnsureGetKeysForConversationData;
typedef struct _DinoPluginsOmemoManagerEnsureGetKeysForJidData DinoPluginsOmemoManagerEnsureGetKeysForJidData;
typedef struct _DinoPluginsOmemoManagerMessageStatePrivate DinoPluginsOmemoManagerMessageStatePrivate;
typedef struct _DinoPluginsOmemoManagerParamSpecMessageState DinoPluginsOmemoManagerParamSpecMessageState;

struct _DinoPluginsOmemoManagerPrivate {
	DinoStreamInteractor* stream_interactor;
	DinoPluginsOmemoDatabase* db;
	DinoPluginsOmemoTrustManager* trust_manager;
	GeeHashMap* encryptors;
	GeeMap* message_states;
	GRecMutex __lock_message_states;
};

struct _Block3Data {
	int _ref_count_;
	DinoPluginsOmemoManager* self;
	DinoEntitiesAccount* account;
};

struct _Block4Data {
	int _ref_count_;
	DinoPluginsOmemoManager* self;
	gpointer _async_data_;
};

struct _DinoPluginsOmemoManagerInitializeStoreData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOmemoManager* self;
	DinoEntitiesAccount* account;
	Block4Data* _data4_;
	gint _tmp0_;
	gint _tmp1_;
	DinoPluginsOmemoStreamModule* module;
	DinoStreamInteractor* _tmp2_;
	DinoModuleManager* _tmp3_;
	XmppModuleIdentity* _tmp4_;
	gpointer _tmp5_;
	DinoPluginsOmemoStreamModule* _tmp6_;
	OmemoStore* store;
	DinoPluginsOmemoStreamModule* _tmp7_;
	OmemoStore* _tmp8_;
	OmemoStore* _tmp9_;
	OmemoStore* _tmp10_;
	QliteRow* row;
	DinoPluginsOmemoDatabase* _tmp11_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp12_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp13_;
	DinoPluginsOmemoDatabase* _tmp14_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp15_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp16_;
	QliteColumn* _tmp17_;
	gint _tmp18_;
	gint _tmp19_;
	QliteRowOption* _tmp20_;
	QliteRowOption* _tmp21_;
	QliteRow* _tmp22_;
	QliteRow* _tmp23_;
	QliteRow* _tmp24_;
	QliteRow* _tmp25_;
	gint identity_id;
	gboolean publish_identity;
	QliteRow* _tmp26_;
	OmemoStore* _tmp27_;
	OmemoIdentityKeyStore* _tmp28_;
	OmemoIdentityKeyStore* _tmp29_;
	ec_key_pair* key_pair;
	OmemoContext* _tmp30_;
	OmemoContext* _tmp31_;
	ec_key_pair* _tmp32_;
	ec_key_pair* _tmp33_;
	guint8* _tmp34_;
	ec_key_pair* _tmp35_;
	ec_private_key* _tmp36_;
	ec_private_key* _tmp37_;
	gint _tmp38_;
	guint8* _tmp39_;
	gint _tmp34__length1;
	gint __tmp34__size_;
	OmemoStore* _tmp40_;
	OmemoIdentityKeyStore* _tmp41_;
	OmemoIdentityKeyStore* _tmp42_;
	GBytes* _tmp43_;
	GBytes* _tmp44_;
	OmemoStore* _tmp45_;
	OmemoIdentityKeyStore* _tmp46_;
	OmemoIdentityKeyStore* _tmp47_;
	ec_key_pair* _tmp48_;
	ec_public_key* _tmp49_;
	ec_public_key* _tmp50_;
	gint _tmp51_;
	guint8* _tmp52_;
	guint8* _tmp53_;
	gint _tmp53__length1;
	GBytes* _tmp54_;
	GBytes* _tmp55_;
	DinoPluginsOmemoDatabase* _tmp56_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp57_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp58_;
	QliteUpsertBuilder* _tmp59_;
	QliteUpsertBuilder* _tmp60_;
	DinoPluginsOmemoDatabase* _tmp61_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp62_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp63_;
	QliteColumn* _tmp64_;
	gint _tmp65_;
	gint _tmp66_;
	QliteUpsertBuilder* _tmp67_;
	QliteUpsertBuilder* _tmp68_;
	DinoPluginsOmemoDatabase* _tmp69_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp70_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp71_;
	QliteColumn* _tmp72_;
	OmemoStore* _tmp73_;
	guint32 _tmp74_;
	guint32 _tmp75_;
	QliteUpsertBuilder* _tmp76_;
	QliteUpsertBuilder* _tmp77_;
	DinoPluginsOmemoDatabase* _tmp78_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp79_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp80_;
	QliteColumn* _tmp81_;
	OmemoStore* _tmp82_;
	OmemoIdentityKeyStore* _tmp83_;
	OmemoIdentityKeyStore* _tmp84_;
	GBytes* _tmp85_;
	GBytes* _tmp86_;
	gsize _tmp87_;
	guint8* _tmp88_;
	gchar* _tmp89_;
	gchar* _tmp90_;
	QliteUpsertBuilder* _tmp91_;
	QliteUpsertBuilder* _tmp92_;
	DinoPluginsOmemoDatabase* _tmp93_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp94_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp95_;
	QliteColumn* _tmp96_;
	OmemoStore* _tmp97_;
	OmemoIdentityKeyStore* _tmp98_;
	OmemoIdentityKeyStore* _tmp99_;
	GBytes* _tmp100_;
	GBytes* _tmp101_;
	gsize _tmp102_;
	guint8* _tmp103_;
	gchar* _tmp104_;
	gchar* _tmp105_;
	QliteUpsertBuilder* _tmp106_;
	QliteUpsertBuilder* _tmp107_;
	OmemoStore* _tmp108_;
	OmemoIdentityKeyStore* _tmp109_;
	OmemoIdentityKeyStore* _tmp110_;
	QliteRow* _tmp111_;
	DinoPluginsOmemoDatabase* _tmp112_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp113_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp114_;
	QliteColumn* _tmp115_;
	gpointer _tmp116_;
	OmemoStore* _tmp117_;
	OmemoIdentityKeyStore* _tmp118_;
	OmemoIdentityKeyStore* _tmp119_;
	QliteRow* _tmp120_;
	DinoPluginsOmemoDatabase* _tmp121_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp122_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp123_;
	QliteColumn* _tmp124_;
	gpointer _tmp125_;
	gchar* _tmp126_;
	gsize _tmp127_;
	guchar* _tmp128_;
	guchar* _tmp129_;
	gint _tmp129__length1;
	GBytes* _tmp130_;
	GBytes* _tmp131_;
	OmemoStore* _tmp132_;
	OmemoIdentityKeyStore* _tmp133_;
	OmemoIdentityKeyStore* _tmp134_;
	QliteRow* _tmp135_;
	DinoPluginsOmemoDatabase* _tmp136_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp137_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp138_;
	QliteColumn* _tmp139_;
	gpointer _tmp140_;
	gchar* _tmp141_;
	gsize _tmp142_;
	guchar* _tmp143_;
	guchar* _tmp144_;
	gint _tmp144__length1;
	GBytes* _tmp145_;
	GBytes* _tmp146_;
	QliteRow* _tmp147_;
	DinoPluginsOmemoDatabase* _tmp148_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp149_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp150_;
	QliteColumn* _tmp151_;
	gpointer _tmp152_;
	OmemoStore* _tmp153_;
	DinoPluginsOmemoDatabase* _tmp154_;
	DinoPluginsOmemoBackedSignedPreKeyStore* _tmp155_;
	DinoPluginsOmemoBackedSignedPreKeyStore* _tmp156_;
	OmemoStore* _tmp157_;
	DinoPluginsOmemoDatabase* _tmp158_;
	DinoPluginsOmemoBackedPreKeyStore* _tmp159_;
	DinoPluginsOmemoBackedPreKeyStore* _tmp160_;
	OmemoStore* _tmp161_;
	DinoPluginsOmemoDatabase* _tmp162_;
	DinoPluginsOmemoBackedSessionStore* _tmp163_;
	DinoPluginsOmemoBackedSessionStore* _tmp164_;
	XmppJid* _tmp165_;
	XmppJid* _tmp166_;
	XmppJid* _tmp167_;
	gchar* _tmp168_;
	gchar* _tmp169_;
	XmppXmppStream* stream;
	DinoStreamInteractor* _tmp170_;
	XmppXmppStream* _tmp171_;
	XmppXmppStream* _tmp172_;
	DinoPluginsOmemoStreamModule* _tmp173_;
	XmppXmppStream* _tmp174_;
	XmppJid* _tmp175_;
	XmppJid* _tmp176_;
	XmppJid* _tmp177_;
	GError* _inner_error0_;
};

struct _DinoPluginsOmemoManagerEnsureGetKeysForConversationData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOmemoManager* self;
	DinoEntitiesConversation* conversation;
	gboolean result;
	DinoStreamInteractor* _tmp0_;
	DinoModuleIdentity* _tmp1_;
	gpointer _tmp2_;
	DinoMucManager* _tmp3_;
	DinoEntitiesAccount* _tmp4_;
	DinoEntitiesAccount* _tmp5_;
	XmppJid* _tmp6_;
	XmppJid* _tmp7_;
	gboolean _tmp8_;
	GeeList* _offline_member_list;
	DinoStreamInteractor* _tmp9_;
	DinoModuleIdentity* _tmp10_;
	gpointer _tmp11_;
	DinoMucManager* _tmp12_;
	XmppJid* _tmp13_;
	XmppJid* _tmp14_;
	DinoEntitiesAccount* _tmp15_;
	DinoEntitiesAccount* _tmp16_;
	GeeList* _tmp17_;
	GeeList* _tmp18_;
	gint _offline_member_size;
	GeeList* _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	gint _offline_member_index;
	gint _tmp22_;
	gint _tmp23_;
	XmppJid* offline_member;
	GeeList* _tmp24_;
	gpointer _tmp25_;
	gboolean ok;
	DinoEntitiesAccount* _tmp26_;
	DinoEntitiesAccount* _tmp27_;
	XmppJid* _tmp28_;
	DinoEntitiesAccount* _tmp29_;
	DinoEntitiesAccount* _tmp30_;
	XmppJid* _tmp31_;
	XmppJid* _tmp32_;
	XmppJid* _tmp33_;
	XmppJid* _tmp34_;
	XmppJid* _tmp35_;
	gboolean _tmp36_;
};

struct _DinoPluginsOmemoManagerEnsureGetKeysForJidData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoPluginsOmemoManager* self;
	DinoEntitiesAccount* account;
	XmppJid* jid;
	gboolean result;
	DinoPluginsOmemoTrustManager* _tmp0_;
	XmppXmppStream* stream;
	DinoStreamInteractor* _tmp1_;
	XmppXmppStream* _tmp2_;
	XmppXmppStream* _tmp3_;
	GeeArrayList* device_list;
	DinoStreamInteractor* _tmp4_;
	DinoModuleManager* _tmp5_;
	XmppModuleIdentity* _tmp6_;
	gpointer _tmp7_;
	DinoPluginsOmemoStreamModule* _tmp8_;
	XmppXmppStream* _tmp9_;
	GeeArrayList* _tmp10_;
	GeeArrayList* _tmp11_;
	GeeArrayList* _tmp12_;
	gint _tmp13_;
	gint _tmp14_;
};

struct _DinoPluginsOmemoManagerMessageState {
	GTypeInstance parent_instance;
	volatile int ref_count;
	DinoPluginsOmemoManagerMessageStatePrivate * priv;
};

struct _DinoPluginsOmemoManagerMessageStateClass {
	GTypeClass parent_class;
	void (*finalize) (DinoPluginsOmemoManagerMessageState *self);
};

struct _DinoPluginsOmemoManagerMessageStatePrivate {
	DinoEntitiesMessage* _msg;
	XmppXepOmemoEncryptState* _last_try;
	gint _waiting_other_sessions;
	gint _waiting_own_sessions;
	gboolean _waiting_own_devicelist;
	gint _waiting_other_devicelists;
	gboolean _force_next_attempt;
	gboolean _will_send_now;
	gboolean _active_send_attempt;
};

struct _DinoPluginsOmemoManagerParamSpecMessageState {
	GParamSpec parent_instance;
};

static gint DinoPluginsOmemoManager_private_offset;
static gpointer dino_plugins_omemo_manager_parent_class = NULL;
DinoModuleIdentity* dino_plugins_omemo_manager_IDENTITY = NULL;
static gint DinoPluginsOmemoManagerMessageState_private_offset;
static gpointer dino_plugins_omemo_manager_message_state_parent_class = NULL;
static DinoStreamInteractionModuleIface * dino_plugins_omemo_manager_dino_stream_interaction_module_parent_iface = NULL;

static gpointer dino_plugins_omemo_manager_message_state_ref (gpointer instance);
static void dino_plugins_omemo_manager_message_state_unref (gpointer instance);
static GParamSpec* dino_plugins_omemo_manager_param_spec_message_state (const gchar* name,
                                                                 const gchar* nick,
                                                                 const gchar* blurb,
                                                                 GType object_type,
                                                                 GParamFlags flags) G_GNUC_UNUSED ;
static void dino_plugins_omemo_manager_value_set_message_state (GValue* value,
                                                         gpointer v_object) G_GNUC_UNUSED ;
static void dino_plugins_omemo_manager_value_take_message_state (GValue* value,
                                                          gpointer v_object) G_GNUC_UNUSED ;
static gpointer dino_plugins_omemo_manager_value_get_message_state (const GValue* value) G_GNUC_UNUSED ;
static GType dino_plugins_omemo_manager_message_state_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
static guint _dino_entities_message_hash_func_gee_hash_data_func (gconstpointer v,
                                                           gpointer self);
static gboolean _dino_entities_message_equals_func_gee_equal_data_func (gconstpointer a,
                                                                 gconstpointer b,
                                                                 gpointer self);
static DinoPluginsOmemoManager* dino_plugins_omemo_manager_new (DinoStreamInteractor* stream_interactor,
                                                         DinoPluginsOmemoDatabase* db,
                                                         DinoPluginsOmemoTrustManager* trust_manager,
                                                         GeeHashMap* encryptors);
static DinoPluginsOmemoManager* dino_plugins_omemo_manager_construct (GType object_type,
                                                               DinoStreamInteractor* stream_interactor,
                                                               DinoPluginsOmemoDatabase* db,
                                                               DinoPluginsOmemoTrustManager* trust_manager,
                                                               GeeHashMap* encryptors);
static void dino_plugins_omemo_manager_on_account_added (DinoPluginsOmemoManager* self,
                                                  DinoEntitiesAccount* account);
static void _dino_plugins_omemo_manager_on_account_added_dino_stream_interactor_account_added (DinoStreamInteractor* _sender,
                                                                                        DinoEntitiesAccount* account,
                                                                                        gpointer self);
static void dino_plugins_omemo_manager_on_stream_negotiated (DinoPluginsOmemoManager* self,
                                                      DinoEntitiesAccount* account,
                                                      XmppXmppStream* stream);
static void _dino_plugins_omemo_manager_on_stream_negotiated_dino_stream_interactor_stream_negotiated (DinoStreamInteractor* _sender,
                                                                                                DinoEntitiesAccount* account,
                                                                                                XmppXmppStream* stream,
                                                                                                gpointer self);
static void dino_plugins_omemo_manager_on_pre_message_send (DinoPluginsOmemoManager* self,
                                                     DinoEntitiesMessage* message,
                                                     XmppMessageStanza* message_stanza,
                                                     DinoEntitiesConversation* conversation);
static void _dino_plugins_omemo_manager_on_pre_message_send_dino_message_processor_pre_message_send (DinoMessageProcessor* _sender,
                                                                                              DinoEntitiesMessage* message,
                                                                                              XmppMessageStanza* message_stanza,
                                                                                              DinoEntitiesConversation* conversation,
                                                                                              gpointer self);
static void dino_plugins_omemo_manager_on_mutual_subscription (DinoPluginsOmemoManager* self,
                                                        DinoEntitiesAccount* account,
                                                        XmppJid* jid);
static void _dino_plugins_omemo_manager_on_mutual_subscription_dino_roster_manager_mutual_subscription (DinoRosterManager* _sender,
                                                                                                 DinoEntitiesAccount* account,
                                                                                                 XmppJid* jid,
                                                                                                 gpointer self);
static GeeList* dino_plugins_omemo_manager_get_occupants (DinoPluginsOmemoManager* self,
                                                   XmppJid* jid,
                                                   DinoEntitiesAccount* account);
static gboolean _xmpp_jid_equals_bare_func_gee_equal_data_func (gconstpointer a,
                                                         gconstpointer b,
                                                         gpointer self);
static void dino_plugins_omemo_manager_message_state_update_from_encrypt_status (DinoPluginsOmemoManagerMessageState* self,
                                                                          DinoEntitiesMessage* msg,
                                                                          XmppXepOmemoEncryptState* new_try);
static gboolean dino_plugins_omemo_manager_message_state_get_will_send_now (DinoPluginsOmemoManagerMessageState* self);
static gchar* dino_plugins_omemo_manager_message_state_to_string (DinoPluginsOmemoManagerMessageState* self);
static DinoPluginsOmemoManagerMessageState* dino_plugins_omemo_manager_message_state_new (DinoEntitiesMessage* msg,
                                                                                   XmppXepOmemoEncryptState* last_try);
static DinoPluginsOmemoManagerMessageState* dino_plugins_omemo_manager_message_state_construct (GType object_type,
                                                                                         DinoEntitiesMessage* msg,
                                                                                         XmppXepOmemoEncryptState* last_try);
static gint dino_plugins_omemo_manager_message_state_get_waiting_own_sessions (DinoPluginsOmemoManagerMessageState* self);
static gint dino_plugins_omemo_manager_message_state_get_waiting_other_sessions (DinoPluginsOmemoManagerMessageState* self);
static gint dino_plugins_omemo_manager_message_state_get_waiting_other_devicelists (DinoPluginsOmemoManagerMessageState* self);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
static void ___lambda20_ (Block3Data* _data3_,
                   XmppJid* jid,
                   GeeArrayList* devices);
static void dino_plugins_omemo_manager_on_device_list_loaded (DinoPluginsOmemoManager* self,
                                                       DinoEntitiesAccount* account,
                                                       XmppJid* jid,
                                                       GeeArrayList* device_list);
static void ____lambda20__dino_plugins_omemo_stream_module_device_list_loaded (DinoPluginsOmemoStreamModule* _sender,
                                                                        XmppJid* jid,
                                                                        GeeArrayList* devices,
                                                                        gpointer self);
static void ___lambda22_ (Block3Data* _data3_,
                   XmppJid* jid,
                   gint device_id,
                   DinoPluginsOmemoBundle* bundle);
static void dino_plugins_omemo_manager_on_bundle_fetched (DinoPluginsOmemoManager* self,
                                                   DinoEntitiesAccount* account,
                                                   XmppJid* jid,
                                                   gint32 device_id,
                                                   DinoPluginsOmemoBundle* bundle);
static void ____lambda22__dino_plugins_omemo_stream_module_bundle_fetched (DinoPluginsOmemoStreamModule* _sender,
                                                                    XmppJid* jid,
                                                                    gint device_id,
                                                                    DinoPluginsOmemoBundle* bundle,
                                                                    gpointer self);
static void ___lambda23_ (Block3Data* _data3_,
                   XmppJid* jid);
static void dino_plugins_omemo_manager_continue_message_sending (DinoPluginsOmemoManager* self,
                                                          DinoEntitiesAccount* account,
                                                          XmppJid* jid);
static void ____lambda23__dino_plugins_omemo_stream_module_bundle_fetch_failed (DinoPluginsOmemoStreamModule* _sender,
                                                                         XmppJid* jid,
                                                                         gint device_id,
                                                                         gpointer self);
static void dino_plugins_omemo_manager_initialize_store (DinoPluginsOmemoManager* self,
                                                  DinoEntitiesAccount* account,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
static void dino_plugins_omemo_manager_initialize_store_finish (DinoPluginsOmemoManager* self,
                                                         GAsyncResult* _res_);
static void dino_plugins_omemo_manager_message_state_set_waiting_own_devicelist (DinoPluginsOmemoManagerMessageState* self,
                                                                          gboolean value);
static void dino_plugins_omemo_manager_message_state_set_waiting_other_devicelists (DinoPluginsOmemoManagerMessageState* self,
                                                                             gint value);
static gboolean dino_plugins_omemo_manager_message_state_should_retry_now (DinoPluginsOmemoManagerMessageState* self);
static void dino_plugins_omemo_manager_message_state_set_active_send_attempt (DinoPluginsOmemoManagerMessageState* self,
                                                                       gboolean value);
static guint8* _vala_array_dup25 (guint8* self,
                           gssize length);
static gboolean dino_plugins_omemo_manager_should_start_session (DinoPluginsOmemoManager* self,
                                                          DinoEntitiesAccount* account,
                                                          XmppJid* jid);
static void dino_plugins_omemo_manager_message_state_set_waiting_own_sessions (DinoPluginsOmemoManagerMessageState* self,
                                                                        gint value);
static void dino_plugins_omemo_manager_message_state_set_waiting_other_sessions (DinoPluginsOmemoManagerMessageState* self,
                                                                          gint value);
static void dino_plugins_omemo_manager_initialize_store_data_free (gpointer _data);
static gboolean dino_plugins_omemo_manager_initialize_store_co (DinoPluginsOmemoManagerInitializeStoreData* _data_);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void ___lambda24_ (Block4Data* _data4_);
static void ____lambda24__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static guint8* _vala_array_dup26 (guint8* self,
                           gssize length);
VALA_EXTERN DinoPluginsOmemoBackedSignedPreKeyStore* dino_plugins_omemo_backed_signed_pre_key_store_new (DinoPluginsOmemoDatabase* db,
                                                                                             gint identity_id);
VALA_EXTERN DinoPluginsOmemoBackedSignedPreKeyStore* dino_plugins_omemo_backed_signed_pre_key_store_construct (GType object_type,
                                                                                                   DinoPluginsOmemoDatabase* db,
                                                                                                   gint identity_id);
VALA_EXTERN GType dino_plugins_omemo_backed_signed_pre_key_store_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DinoPluginsOmemoBackedPreKeyStore* dino_plugins_omemo_backed_pre_key_store_new (DinoPluginsOmemoDatabase* db,
                                                                                gint identity_id);
VALA_EXTERN DinoPluginsOmemoBackedPreKeyStore* dino_plugins_omemo_backed_pre_key_store_construct (GType object_type,
                                                                                      DinoPluginsOmemoDatabase* db,
                                                                                      gint identity_id);
VALA_EXTERN GType dino_plugins_omemo_backed_pre_key_store_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DinoPluginsOmemoBackedSessionStore* dino_plugins_omemo_backed_session_store_new (DinoPluginsOmemoDatabase* db,
                                                                                 gint identity_id);
VALA_EXTERN DinoPluginsOmemoBackedSessionStore* dino_plugins_omemo_backed_session_store_construct (GType object_type,
                                                                                       DinoPluginsOmemoDatabase* db,
                                                                                       gint identity_id);
VALA_EXTERN GType dino_plugins_omemo_backed_session_store_get_type (void) G_GNUC_CONST ;
static void dino_plugins_omemo_manager_ensure_get_keys_for_conversation_data_free (gpointer _data);
static gboolean dino_plugins_omemo_manager_ensure_get_keys_for_conversation_co (DinoPluginsOmemoManagerEnsureGetKeysForConversationData* _data_);
static void dino_plugins_omemo_manager_ensure_get_keys_for_conversation_ready (GObject* source_object,
                                                                        GAsyncResult* _res_,
                                                                        gpointer _user_data_);
static void dino_plugins_omemo_manager_ensure_get_keys_for_jid_data_free (gpointer _data);
static gboolean dino_plugins_omemo_manager_ensure_get_keys_for_jid_co (DinoPluginsOmemoManagerEnsureGetKeysForJidData* _data_);
static void dino_plugins_omemo_manager_ensure_get_keys_for_jid_ready (GObject* source_object,
                                                               GAsyncResult* _res_,
                                                               gpointer _user_data_);
static void dino_plugins_omemo_manager_message_state_set_msg (DinoPluginsOmemoManagerMessageState* self,
                                                       DinoEntitiesMessage* value);
static void dino_plugins_omemo_manager_message_state_set_last_try (DinoPluginsOmemoManagerMessageState* self,
                                                            XmppXepOmemoEncryptState* value);
static void dino_plugins_omemo_manager_message_state_set_will_send_now (DinoPluginsOmemoManagerMessageState* self,
                                                                 gboolean value);
static gboolean dino_plugins_omemo_manager_message_state_get_waiting_own_devicelist (DinoPluginsOmemoManagerMessageState* self);
static gboolean dino_plugins_omemo_manager_message_state_get_active_send_attempt (DinoPluginsOmemoManagerMessageState* self);
static DinoEntitiesMessage* dino_plugins_omemo_manager_message_state_get_msg (DinoPluginsOmemoManagerMessageState* self);
static XmppXepOmemoEncryptState* dino_plugins_omemo_manager_message_state_get_last_try (DinoPluginsOmemoManagerMessageState* self);
static gboolean dino_plugins_omemo_manager_message_state_get_force_next_attempt (DinoPluginsOmemoManagerMessageState* self);
static void dino_plugins_omemo_manager_message_state_set_force_next_attempt (DinoPluginsOmemoManagerMessageState* self,
                                                                      gboolean value);
static void dino_plugins_omemo_manager_message_state_finalize (DinoPluginsOmemoManagerMessageState * obj);
static GType dino_plugins_omemo_manager_message_state_get_type_once (void);
static void dino_plugins_omemo_manager_finalize (GObject * obj);
static GType dino_plugins_omemo_manager_get_type_once (void);
static void _vala_dino_plugins_omemo_manager_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_plugins_omemo_manager_get_instance_private (DinoPluginsOmemoManager* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsOmemoManager_private_offset);
}

static guint
_dino_entities_message_hash_func_gee_hash_data_func (gconstpointer v,
                                                     gpointer self)
{
	guint result;
	result = dino_entities_message_hash_func ((DinoEntitiesMessage*) v);
	return result;
}

static gboolean
_dino_entities_message_equals_func_gee_equal_data_func (gconstpointer a,
                                                        gconstpointer b,
                                                        gpointer self)
{
	gboolean result;
	result = dino_entities_message_equals_func ((DinoEntitiesMessage*) a, (DinoEntitiesMessage*) b);
	return result;
}

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

static gpointer
_qlite_database_ref0 (gpointer self)
{
	return self ? qlite_database_ref (self) : NULL;
}

static gpointer
_dino_plugins_omemo_trust_manager_ref0 (gpointer self)
{
	return self ? dino_plugins_omemo_trust_manager_ref (self) : NULL;
}

static void
_dino_plugins_omemo_manager_on_account_added_dino_stream_interactor_account_added (DinoStreamInteractor* _sender,
                                                                                   DinoEntitiesAccount* account,
                                                                                   gpointer self)
{
	dino_plugins_omemo_manager_on_account_added ((DinoPluginsOmemoManager*) self, account);
}

static void
_dino_plugins_omemo_manager_on_stream_negotiated_dino_stream_interactor_stream_negotiated (DinoStreamInteractor* _sender,
                                                                                           DinoEntitiesAccount* account,
                                                                                           XmppXmppStream* stream,
                                                                                           gpointer self)
{
	dino_plugins_omemo_manager_on_stream_negotiated ((DinoPluginsOmemoManager*) self, account, stream);
}

static void
_dino_plugins_omemo_manager_on_pre_message_send_dino_message_processor_pre_message_send (DinoMessageProcessor* _sender,
                                                                                         DinoEntitiesMessage* message,
                                                                                         XmppMessageStanza* message_stanza,
                                                                                         DinoEntitiesConversation* conversation,
                                                                                         gpointer self)
{
	dino_plugins_omemo_manager_on_pre_message_send ((DinoPluginsOmemoManager*) self, message, message_stanza, conversation);
}

static void
_dino_plugins_omemo_manager_on_mutual_subscription_dino_roster_manager_mutual_subscription (DinoRosterManager* _sender,
                                                                                            DinoEntitiesAccount* account,
                                                                                            XmppJid* jid,
                                                                                            gpointer self)
{
	dino_plugins_omemo_manager_on_mutual_subscription ((DinoPluginsOmemoManager*) self, account, jid);
}

static DinoPluginsOmemoManager*
dino_plugins_omemo_manager_construct (GType object_type,
                                      DinoStreamInteractor* stream_interactor,
                                      DinoPluginsOmemoDatabase* db,
                                      DinoPluginsOmemoTrustManager* trust_manager,
                                      GeeHashMap* encryptors)
{
	DinoPluginsOmemoManager * self = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoPluginsOmemoDatabase* _tmp1_;
	DinoPluginsOmemoTrustManager* _tmp2_;
	GeeHashMap* _tmp3_;
	DinoModuleIdentity* _tmp4_;
	gpointer _tmp5_;
	DinoMessageProcessor* _tmp6_;
	DinoModuleIdentity* _tmp7_;
	gpointer _tmp8_;
	DinoRosterManager* _tmp9_;
	g_return_val_if_fail (stream_interactor != NULL, NULL);
	g_return_val_if_fail (db != NULL, NULL);
	g_return_val_if_fail (trust_manager != NULL, NULL);
	g_return_val_if_fail (encryptors != NULL, NULL);
	self = (DinoPluginsOmemoManager*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (stream_interactor);
	_g_object_unref0 (self->priv->stream_interactor);
	self->priv->stream_interactor = _tmp0_;
	_tmp1_ = _qlite_database_ref0 (db);
	_qlite_database_unref0 (self->priv->db);
	self->priv->db = _tmp1_;
	_tmp2_ = _dino_plugins_omemo_trust_manager_ref0 (trust_manager);
	_dino_plugins_omemo_trust_manager_unref0 (self->priv->trust_manager);
	self->priv->trust_manager = _tmp2_;
	_tmp3_ = _g_object_ref0 (encryptors);
	_g_object_unref0 (self->priv->encryptors);
	self->priv->encryptors = _tmp3_;
	g_signal_connect_object (stream_interactor, "account-added", (GCallback) _dino_plugins_omemo_manager_on_account_added_dino_stream_interactor_account_added, self, 0);
	g_signal_connect_object (stream_interactor, "stream-negotiated", (GCallback) _dino_plugins_omemo_manager_on_stream_negotiated_dino_stream_interactor_stream_negotiated, self, 0);
	_tmp4_ = dino_message_processor_IDENTITY;
	_tmp5_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp4_);
	_tmp6_ = (DinoMessageProcessor*) _tmp5_;
	g_signal_connect_object (_tmp6_, "pre-message-send", (GCallback) _dino_plugins_omemo_manager_on_pre_message_send_dino_message_processor_pre_message_send, self, 0);
	_g_object_unref0 (_tmp6_);
	_tmp7_ = dino_roster_manager_IDENTITY;
	_tmp8_ = dino_stream_interactor_get_module (stream_interactor, DINO_TYPE_ROSTER_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp7_);
	_tmp9_ = (DinoRosterManager*) _tmp8_;
	g_signal_connect_object (_tmp9_, "mutual-subscription", (GCallback) _dino_plugins_omemo_manager_on_mutual_subscription_dino_roster_manager_mutual_subscription, self, 0);
	_g_object_unref0 (_tmp9_);
	return self;
}

static DinoPluginsOmemoManager*
dino_plugins_omemo_manager_new (DinoStreamInteractor* stream_interactor,
                                DinoPluginsOmemoDatabase* db,
                                DinoPluginsOmemoTrustManager* trust_manager,
                                GeeHashMap* encryptors)
{
	return dino_plugins_omemo_manager_construct (DINO_PLUGINS_OMEMO_TYPE_MANAGER, stream_interactor, db, trust_manager, encryptors);
}

void
dino_plugins_omemo_manager_clear_device_list (DinoPluginsOmemoManager* self,
                                              DinoEntitiesAccount* account)
{
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppXmppStream* _tmp2_;
	XmppXmppStream* _tmp3_;
	XmppModuleIdentity* _tmp4_;
	gpointer _tmp5_;
	DinoPluginsOmemoStreamModule* _tmp6_;
	XmppXmppStream* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_stream_interactor_get_stream (_tmp0_, account);
	stream = _tmp1_;
	_tmp2_ = stream;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (stream);
		return;
	}
	_tmp3_ = stream;
	_tmp4_ = dino_plugins_omemo_stream_module_IDENTITY;
	_tmp5_ = xmpp_xmpp_stream_get_module (_tmp3_, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp4_);
	_tmp6_ = (DinoPluginsOmemoStreamModule*) _tmp5_;
	_tmp7_ = stream;
	dino_plugins_omemo_stream_module_clear_device_list (_tmp6_, _tmp7_);
	_g_object_unref0 (_tmp6_);
	_g_object_unref0 (stream);
}

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

static GeeList*
dino_plugins_omemo_manager_get_occupants (DinoPluginsOmemoManager* self,
                                          XmppJid* jid,
                                          DinoEntitiesAccount* account)
{
	GeeList* occupants = NULL;
	GeeArrayList* _tmp0_;
	DinoStreamInteractor* _tmp1_;
	DinoModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	DinoMucManager* _tmp4_;
	gboolean _tmp5_;
	GeeList* occupant_jids = NULL;
	DinoStreamInteractor* _tmp7_;
	DinoModuleIdentity* _tmp8_;
	gpointer _tmp9_;
	DinoMucManager* _tmp10_;
	GeeList* _tmp11_;
	GeeList* _tmp12_;
	GeeList* _tmp13_;
	GeeList* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (jid != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	_tmp0_ = gee_array_list_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, _xmpp_jid_equals_bare_func_gee_equal_data_func, NULL, NULL);
	occupants = (GeeList*) _tmp0_;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = dino_muc_manager_IDENTITY;
	_tmp3_ = dino_stream_interactor_get_module (_tmp1_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp2_);
	_tmp4_ = (DinoMucManager*) _tmp3_;
	_tmp5_ = !dino_muc_manager_is_groupchat (_tmp4_, jid, account);
	_g_object_unref0 (_tmp4_);
	if (_tmp5_) {
		GeeList* _tmp6_;
		_tmp6_ = occupants;
		gee_collection_add ((GeeCollection*) _tmp6_, jid);
	}
	_tmp7_ = self->priv->stream_interactor;
	_tmp8_ = dino_muc_manager_IDENTITY;
	_tmp9_ = dino_stream_interactor_get_module (_tmp7_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp8_);
	_tmp10_ = (DinoMucManager*) _tmp9_;
	_tmp11_ = dino_muc_manager_get_offline_members (_tmp10_, jid, account);
	_tmp12_ = _tmp11_;
	_g_object_unref0 (_tmp10_);
	occupant_jids = _tmp12_;
	_tmp13_ = occupant_jids;
	if (_tmp13_ == NULL) {
		result = occupants;
		_g_object_unref0 (occupant_jids);
		return result;
	}
	{
		GeeList* _occupant_list = NULL;
		GeeList* _tmp14_;
		gint _occupant_size = 0;
		GeeList* _tmp15_;
		gint _tmp16_;
		gint _tmp17_;
		gint _occupant_index = 0;
		_tmp14_ = occupant_jids;
		_occupant_list = _tmp14_;
		_tmp15_ = _occupant_list;
		_tmp16_ = gee_collection_get_size ((GeeCollection*) _tmp15_);
		_tmp17_ = _tmp16_;
		_occupant_size = _tmp17_;
		_occupant_index = -1;
		while (TRUE) {
			gint _tmp18_;
			gint _tmp19_;
			XmppJid* occupant = NULL;
			GeeList* _tmp20_;
			gpointer _tmp21_;
			XmppJid* _tmp22_;
			XmppJid* _tmp23_;
			XmppJid* _tmp24_;
			XmppJid* _tmp25_;
			gboolean _tmp26_;
			_occupant_index = _occupant_index + 1;
			_tmp18_ = _occupant_index;
			_tmp19_ = _occupant_size;
			if (!(_tmp18_ < _tmp19_)) {
				break;
			}
			_tmp20_ = _occupant_list;
			_tmp21_ = gee_list_get (_tmp20_, _occupant_index);
			occupant = (XmppJid*) _tmp21_;
			_tmp22_ = occupant;
			_tmp23_ = dino_entities_account_get_bare_jid (account);
			_tmp24_ = _tmp23_;
			_tmp25_ = _tmp24_;
			_tmp26_ = !xmpp_jid_equals (_tmp22_, _tmp25_);
			_xmpp_jid_unref0 (_tmp25_);
			if (_tmp26_) {
				GeeList* _tmp27_;
				XmppJid* _tmp28_;
				XmppJid* _tmp29_;
				XmppJid* _tmp30_;
				XmppJid* _tmp31_;
				_tmp27_ = occupants;
				_tmp28_ = occupant;
				_tmp29_ = xmpp_jid_get_bare_jid (_tmp28_);
				_tmp30_ = _tmp29_;
				_tmp31_ = _tmp30_;
				gee_collection_add ((GeeCollection*) _tmp27_, _tmp31_);
				_xmpp_jid_unref0 (_tmp31_);
			}
			_xmpp_jid_unref0 (occupant);
		}
	}
	result = occupants;
	_g_object_unref0 (occupant_jids);
	return result;
}

static void
dino_plugins_omemo_manager_on_pre_message_send (DinoPluginsOmemoManager* self,
                                                DinoEntitiesMessage* message,
                                                XmppMessageStanza* message_stanza,
                                                DinoEntitiesConversation* conversation)
{
	DinoEntitiesEncryption _tmp0_;
	DinoEntitiesEncryption _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (message != NULL);
	g_return_if_fail (message_stanza != NULL);
	g_return_if_fail (conversation != NULL);
	_tmp0_ = dino_entities_message_get_encryption (message);
	_tmp1_ = _tmp0_;
	if (_tmp1_ == DINO_ENTITIES_ENCRYPTION_OMEMO) {
		DinoEntitiesMessageType _tmp2_;
		DinoEntitiesMessageType _tmp3_;
		XmppXmppStream* stream = NULL;
		DinoStreamInteractor* _tmp4_;
		DinoEntitiesAccount* _tmp5_;
		DinoEntitiesAccount* _tmp6_;
		XmppXmppStream* _tmp7_;
		XmppXmppStream* _tmp8_;
		DinoPluginsOmemoStreamModule* module_ = NULL;
		XmppXmppStream* _tmp9_;
		XmppModuleIdentity* _tmp10_;
		gpointer _tmp11_;
		DinoPluginsOmemoStreamModule* _tmp12_;
		DinoPluginsOmemoStreamModule* module = NULL;
		DinoPluginsOmemoStreamModule* _tmp13_;
		DinoPluginsOmemoStreamModule* _tmp14_;
		GeeList* recipients = NULL;
		const gchar* _tmp15_;
		const gchar* _tmp16_;
		XmppXepOmemoEncryptState* enc_state = NULL;
		GeeHashMap* _tmp33_;
		DinoEntitiesAccount* _tmp34_;
		DinoEntitiesAccount* _tmp35_;
		gpointer _tmp36_;
		DinoPluginsOmemoOmemoEncryptor* _tmp37_;
		DinoEntitiesAccount* _tmp38_;
		DinoEntitiesAccount* _tmp39_;
		XmppJid* _tmp40_;
		XmppJid* _tmp41_;
		XmppJid* _tmp42_;
		GeeList* _tmp43_;
		XmppXmppStream* _tmp44_;
		XmppXepOmemoEncryptState* _tmp45_;
		XmppXepOmemoEncryptState* _tmp46_;
		DinoPluginsOmemoManagerMessageState* state = NULL;
		DinoPluginsOmemoManagerMessageState* _tmp68_;
		gboolean _tmp69_;
		gboolean _tmp70_;
		_tmp2_ = dino_entities_message_get_type_ (message);
		_tmp3_ = _tmp2_;
		if (_tmp3_ == DINO_ENTITIES_MESSAGE_TYPE_GROUPCHAT_PM) {
			dino_entities_message_set_marked (message, DINO_ENTITIES_MESSAGE_MARKED_WONTSEND);
			return;
		}
		_tmp4_ = self->priv->stream_interactor;
		_tmp5_ = dino_entities_conversation_get_account (conversation);
		_tmp6_ = _tmp5_;
		_tmp7_ = dino_stream_interactor_get_stream (_tmp4_, _tmp6_);
		stream = _tmp7_;
		_tmp8_ = stream;
		if (_tmp8_ == NULL) {
			dino_entities_message_set_marked (message, DINO_ENTITIES_MESSAGE_MARKED_UNSENT);
			_g_object_unref0 (stream);
			return;
		}
		_tmp9_ = stream;
		_tmp10_ = dino_plugins_omemo_stream_module_IDENTITY;
		_tmp11_ = xmpp_xmpp_stream_get_module (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, XMPP_TYPE_XMPP_STREAM, XmppXmppStream), DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp10_);
		module_ = (DinoPluginsOmemoStreamModule*) _tmp11_;
		_tmp12_ = module_;
		if (_tmp12_ == NULL) {
			dino_entities_message_set_marked (message, DINO_ENTITIES_MESSAGE_MARKED_UNSENT);
			_g_object_unref0 (module_);
			_g_object_unref0 (stream);
			return;
		}
		_tmp13_ = module_;
		_tmp14_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, DinoPluginsOmemoStreamModule));
		module = _tmp14_;
		_tmp15_ = xmpp_stanza_get_type_ ((XmppStanza*) message_stanza);
		_tmp16_ = _tmp15_;
		if (g_strcmp0 (_tmp16_, XMPP_MESSAGE_STANZA_TYPE_GROUPCHAT) == 0) {
			XmppJid* _tmp17_;
			XmppJid* _tmp18_;
			XmppJid* _tmp19_;
			XmppJid* _tmp20_;
			XmppJid* _tmp21_;
			DinoEntitiesAccount* _tmp22_;
			DinoEntitiesAccount* _tmp23_;
			GeeList* _tmp24_;
			GeeList* _tmp25_;
			gint _tmp26_;
			gint _tmp27_;
			_tmp17_ = dino_entities_message_get_to (message);
			_tmp18_ = _tmp17_;
			_tmp19_ = xmpp_jid_get_bare_jid (_tmp18_);
			_tmp20_ = _tmp19_;
			_tmp21_ = G_TYPE_CHECK_INSTANCE_CAST (_tmp20_, XMPP_TYPE_JID, XmppJid);
			_tmp22_ = dino_entities_conversation_get_account (conversation);
			_tmp23_ = _tmp22_;
			_tmp24_ = dino_plugins_omemo_manager_get_occupants (self, _tmp21_, _tmp23_);
			_g_object_unref0 (recipients);
			recipients = _tmp24_;
			_xmpp_jid_unref0 (_tmp21_);
			_tmp25_ = recipients;
			_tmp26_ = gee_collection_get_size ((GeeCollection*) _tmp25_);
			_tmp27_ = _tmp26_;
			if (_tmp27_ == 0) {
				dino_entities_message_set_marked (message, DINO_ENTITIES_MESSAGE_MARKED_WONTSEND);
				_g_object_unref0 (recipients);
				_g_object_unref0 (module);
				_g_object_unref0 (module_);
				_g_object_unref0 (stream);
				return;
			}
		} else {
			GeeArrayList* _tmp28_;
			GeeList* _tmp29_;
			XmppJid* _tmp30_;
			XmppJid* _tmp31_;
			XmppJid* _tmp32_;
			_tmp28_ = gee_array_list_new (XMPP_TYPE_JID, (GBoxedCopyFunc) xmpp_jid_ref, (GDestroyNotify) xmpp_jid_unref, _xmpp_jid_equals_bare_func_gee_equal_data_func, NULL, NULL);
			_g_object_unref0 (recipients);
			recipients = (GeeList*) _tmp28_;
			_tmp29_ = recipients;
			_tmp30_ = xmpp_stanza_get_to ((XmppStanza*) message_stanza);
			_tmp31_ = _tmp30_;
			_tmp32_ = _tmp31_;
			gee_collection_add ((GeeCollection*) _tmp29_, _tmp32_);
			_xmpp_jid_unref0 (_tmp32_);
		}
		_tmp33_ = self->priv->encryptors;
		_tmp34_ = dino_entities_conversation_get_account (conversation);
		_tmp35_ = _tmp34_;
		_tmp36_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp33_, _tmp35_);
		_tmp37_ = (DinoPluginsOmemoOmemoEncryptor*) _tmp36_;
		_tmp38_ = dino_entities_conversation_get_account (conversation);
		_tmp39_ = _tmp38_;
		_tmp40_ = dino_entities_account_get_bare_jid (_tmp39_);
		_tmp41_ = _tmp40_;
		_tmp42_ = _tmp41_;
		_tmp43_ = recipients;
		_tmp44_ = stream;
		_tmp45_ = dino_plugins_omemo_omemo_encryptor_encrypt (_tmp37_, message_stanza, _tmp42_, _tmp43_, _tmp44_);
		_tmp46_ = _tmp45_;
		_xmpp_jid_unref0 (_tmp42_);
		_g_object_unref0 (_tmp37_);
		enc_state = _tmp46_;
		{
			GeeMap* _tmp47_;
			_tmp47_ = self->priv->message_states;
			g_rec_mutex_lock (&self->priv->__lock_message_states);
			{
				GeeMap* _tmp48_;
				DinoPluginsOmemoManagerMessageState* _tmp63_;
				gboolean _tmp64_;
				gboolean _tmp65_;
				_tmp48_ = self->priv->message_states;
				if (gee_map_has_key (_tmp48_, message)) {
					GeeMap* _tmp49_;
					gpointer _tmp50_;
					DinoPluginsOmemoManagerMessageState* _tmp51_;
					XmppXepOmemoEncryptState* _tmp52_;
					DinoPluginsOmemoManagerMessageState* _tmp53_;
					gboolean _tmp54_;
					gboolean _tmp55_;
					_tmp49_ = self->priv->message_states;
					_tmp50_ = gee_map_get (_tmp49_, message);
					_dino_plugins_omemo_manager_message_state_unref0 (state);
					state = (DinoPluginsOmemoManagerMessageState*) _tmp50_;
					_tmp51_ = state;
					_tmp52_ = enc_state;
					dino_plugins_omemo_manager_message_state_update_from_encrypt_status (_tmp51_, message, _tmp52_);
					_tmp53_ = state;
					_tmp54_ = dino_plugins_omemo_manager_message_state_get_will_send_now (_tmp53_);
					_tmp55_ = _tmp54_;
					if (_tmp55_) {
						DinoPluginsOmemoManagerMessageState* _tmp56_;
						gchar* _tmp57_;
						gchar* _tmp58_;
						_tmp56_ = state;
						_tmp57_ = dino_plugins_omemo_manager_message_state_to_string (_tmp56_);
						_tmp58_ = _tmp57_;
						g_debug ("manager.vala:138: sending message delayed: %s", _tmp58_);
						_g_free0 (_tmp58_);
					}
				} else {
					XmppXepOmemoEncryptState* _tmp59_;
					DinoPluginsOmemoManagerMessageState* _tmp60_;
					GeeMap* _tmp61_;
					DinoPluginsOmemoManagerMessageState* _tmp62_;
					_tmp59_ = enc_state;
					_tmp60_ = dino_plugins_omemo_manager_message_state_new (message, _tmp59_);
					_dino_plugins_omemo_manager_message_state_unref0 (state);
					state = _tmp60_;
					_tmp61_ = self->priv->message_states;
					_tmp62_ = state;
					gee_map_set (_tmp61_, message, _tmp62_);
				}
				_tmp63_ = state;
				_tmp64_ = dino_plugins_omemo_manager_message_state_get_will_send_now (_tmp63_);
				_tmp65_ = _tmp64_;
				if (_tmp65_) {
					GeeMap* _tmp66_;
					_tmp66_ = self->priv->message_states;
					gee_map_unset (_tmp66_, message, NULL);
				}
			}
			__finally0:
			{
				GeeMap* _tmp67_;
				_tmp67_ = self->priv->message_states;
				g_rec_mutex_unlock (&self->priv->__lock_message_states);
			}
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_dino_plugins_omemo_manager_message_state_unref0 (state);
				_xmpp_xep_omemo_encrypt_state_unref0 (enc_state);
				_g_object_unref0 (recipients);
				_g_object_unref0 (module);
				_g_object_unref0 (module_);
				_g_object_unref0 (stream);
				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_ = state;
		_tmp69_ = dino_plugins_omemo_manager_message_state_get_will_send_now (_tmp68_);
		_tmp70_ = _tmp69_;
		if (!_tmp70_) {
			DinoEntitiesMessageMarked _tmp71_;
			DinoEntitiesMessageMarked _tmp72_;
			_tmp71_ = dino_entities_message_get_marked (message);
			_tmp72_ = _tmp71_;
			if (_tmp72_ == DINO_ENTITIES_MESSAGE_MARKED_WONTSEND) {
				DinoPluginsOmemoManagerMessageState* _tmp73_;
				gchar* _tmp74_;
				gchar* _tmp75_;
				GeeMap* _tmp76_;
				_tmp73_ = state;
				_tmp74_ = dino_plugins_omemo_manager_message_state_to_string (_tmp73_);
				_tmp75_ = _tmp74_;
				g_debug ("manager.vala:152: retracting message %s", _tmp75_);
				_g_free0 (_tmp75_);
				_tmp76_ = self->priv->message_states;
				gee_map_unset (_tmp76_, message, NULL);
			} else {
				DinoPluginsOmemoManagerMessageState* _tmp77_;
				gchar* _tmp78_;
				gchar* _tmp79_;
				DinoPluginsOmemoManagerMessageState* _tmp80_;
				gint _tmp81_;
				gint _tmp82_;
				gboolean _tmp100_ = FALSE;
				DinoPluginsOmemoManagerMessageState* _tmp101_;
				gint _tmp102_;
				gint _tmp103_;
				gboolean _tmp131_ = FALSE;
				DinoPluginsOmemoManagerMessageState* _tmp132_;
				gint _tmp133_;
				gint _tmp134_;
				_tmp77_ = state;
				_tmp78_ = dino_plugins_omemo_manager_message_state_to_string (_tmp77_);
				_tmp79_ = _tmp78_;
				g_debug ("manager.vala:155: delaying message %s", _tmp79_);
				_g_free0 (_tmp79_);
				_tmp80_ = state;
				_tmp81_ = dino_plugins_omemo_manager_message_state_get_waiting_own_sessions (_tmp80_);
				_tmp82_ = _tmp81_;
				if (_tmp82_ > 0) {
					DinoPluginsOmemoStreamModule* _tmp83_;
					XmppXmppStream* _tmp84_;
					DinoEntitiesAccount* _tmp85_;
					DinoEntitiesAccount* _tmp86_;
					XmppJid* _tmp87_;
					XmppJid* _tmp88_;
					XmppJid* _tmp89_;
					DinoPluginsOmemoTrustManager* _tmp90_;
					DinoEntitiesAccount* _tmp91_;
					DinoEntitiesAccount* _tmp92_;
					DinoEntitiesAccount* _tmp93_;
					DinoEntitiesAccount* _tmp94_;
					XmppJid* _tmp95_;
					XmppJid* _tmp96_;
					XmppJid* _tmp97_;
					GeeList* _tmp98_;
					GeeList* _tmp99_;
					_tmp83_ = module;
					_tmp84_ = stream;
					_tmp85_ = dino_entities_conversation_get_account (conversation);
					_tmp86_ = _tmp85_;
					_tmp87_ = dino_entities_account_get_bare_jid (_tmp86_);
					_tmp88_ = _tmp87_;
					_tmp89_ = _tmp88_;
					_tmp90_ = self->priv->trust_manager;
					_tmp91_ = dino_entities_conversation_get_account (conversation);
					_tmp92_ = _tmp91_;
					_tmp93_ = dino_entities_conversation_get_account (conversation);
					_tmp94_ = _tmp93_;
					_tmp95_ = dino_entities_account_get_bare_jid (_tmp94_);
					_tmp96_ = _tmp95_;
					_tmp97_ = _tmp96_;
					_tmp98_ = dino_plugins_omemo_trust_manager_get_trusted_devices (_tmp90_, _tmp92_, _tmp97_);
					_tmp99_ = _tmp98_;
					dino_plugins_omemo_stream_module_fetch_bundles (_tmp83_, G_TYPE_CHECK_INSTANCE_CAST (_tmp84_, XMPP_TYPE_XMPP_STREAM, XmppXmppStream), _tmp89_, _tmp99_);
					_g_object_unref0 (_tmp99_);
					_xmpp_jid_unref0 (_tmp97_);
					_xmpp_jid_unref0 (_tmp89_);
				}
				_tmp101_ = state;
				_tmp102_ = dino_plugins_omemo_manager_message_state_get_waiting_other_sessions (_tmp101_);
				_tmp103_ = _tmp102_;
				if (_tmp103_ > 0) {
					XmppJid* _tmp104_;
					XmppJid* _tmp105_;
					_tmp104_ = dino_entities_message_get_counterpart (message);
					_tmp105_ = _tmp104_;
					_tmp100_ = _tmp105_ != NULL;
				} else {
					_tmp100_ = FALSE;
				}
				if (_tmp100_) {
					{
						GeeList* _jid_list = NULL;
						XmppJid* _tmp106_;
						XmppJid* _tmp107_;
						XmppJid* _tmp108_;
						XmppJid* _tmp109_;
						XmppJid* _tmp110_;
						DinoEntitiesAccount* _tmp111_;
						DinoEntitiesAccount* _tmp112_;
						GeeList* _tmp113_;
						GeeList* _tmp114_;
						gint _jid_size = 0;
						GeeList* _tmp115_;
						gint _tmp116_;
						gint _tmp117_;
						gint _jid_index = 0;
						_tmp106_ = dino_entities_message_get_counterpart (message);
						_tmp107_ = _tmp106_;
						_tmp108_ = xmpp_jid_get_bare_jid (G_TYPE_CHECK_INSTANCE_CAST (_tmp107_, XMPP_TYPE_JID, XmppJid));
						_tmp109_ = _tmp108_;
						_tmp110_ = _tmp109_;
						_tmp111_ = dino_entities_conversation_get_account (conversation);
						_tmp112_ = _tmp111_;
						_tmp113_ = dino_plugins_omemo_manager_get_occupants (self, _tmp110_, _tmp112_);
						_tmp114_ = _tmp113_;
						_xmpp_jid_unref0 (_tmp110_);
						_jid_list = _tmp114_;
						_tmp115_ = _jid_list;
						_tmp116_ = gee_collection_get_size ((GeeCollection*) _tmp115_);
						_tmp117_ = _tmp116_;
						_jid_size = _tmp117_;
						_jid_index = -1;
						while (TRUE) {
							gint _tmp118_;
							gint _tmp119_;
							XmppJid* jid = NULL;
							GeeList* _tmp120_;
							gpointer _tmp121_;
							DinoPluginsOmemoStreamModule* _tmp122_;
							XmppXmppStream* _tmp123_;
							XmppJid* _tmp124_;
							DinoPluginsOmemoTrustManager* _tmp125_;
							DinoEntitiesAccount* _tmp126_;
							DinoEntitiesAccount* _tmp127_;
							XmppJid* _tmp128_;
							GeeList* _tmp129_;
							GeeList* _tmp130_;
							_jid_index = _jid_index + 1;
							_tmp118_ = _jid_index;
							_tmp119_ = _jid_size;
							if (!(_tmp118_ < _tmp119_)) {
								break;
							}
							_tmp120_ = _jid_list;
							_tmp121_ = gee_list_get (_tmp120_, _jid_index);
							jid = (XmppJid*) _tmp121_;
							_tmp122_ = module;
							_tmp123_ = stream;
							_tmp124_ = jid;
							_tmp125_ = self->priv->trust_manager;
							_tmp126_ = dino_entities_conversation_get_account (conversation);
							_tmp127_ = _tmp126_;
							_tmp128_ = jid;
							_tmp129_ = dino_plugins_omemo_trust_manager_get_trusted_devices (_tmp125_, _tmp127_, _tmp128_);
							_tmp130_ = _tmp129_;
							dino_plugins_omemo_stream_module_fetch_bundles (_tmp122_, G_TYPE_CHECK_INSTANCE_CAST (_tmp123_, XMPP_TYPE_XMPP_STREAM, XmppXmppStream), _tmp124_, _tmp130_);
							_g_object_unref0 (_tmp130_);
							_xmpp_jid_unref0 (jid);
						}
						_g_object_unref0 (_jid_list);
					}
				}
				_tmp132_ = state;
				_tmp133_ = dino_plugins_omemo_manager_message_state_get_waiting_other_devicelists (_tmp132_);
				_tmp134_ = _tmp133_;
				if (_tmp134_ > 0) {
					XmppJid* _tmp135_;
					XmppJid* _tmp136_;
					_tmp135_ = dino_entities_message_get_counterpart (message);
					_tmp136_ = _tmp135_;
					_tmp131_ = _tmp136_ != NULL;
				} else {
					_tmp131_ = FALSE;
				}
				if (_tmp131_) {
					{
						GeeList* _jid_list = NULL;
						XmppJid* _tmp137_;
						XmppJid* _tmp138_;
						XmppJid* _tmp139_;
						XmppJid* _tmp140_;
						XmppJid* _tmp141_;
						DinoEntitiesAccount* _tmp142_;
						DinoEntitiesAccount* _tmp143_;
						GeeList* _tmp144_;
						GeeList* _tmp145_;
						gint _jid_size = 0;
						GeeList* _tmp146_;
						gint _tmp147_;
						gint _tmp148_;
						gint _jid_index = 0;
						_tmp137_ = dino_entities_message_get_counterpart (message);
						_tmp138_ = _tmp137_;
						_tmp139_ = xmpp_jid_get_bare_jid (G_TYPE_CHECK_INSTANCE_CAST (_tmp138_, XMPP_TYPE_JID, XmppJid));
						_tmp140_ = _tmp139_;
						_tmp141_ = _tmp140_;
						_tmp142_ = dino_entities_conversation_get_account (conversation);
						_tmp143_ = _tmp142_;
						_tmp144_ = dino_plugins_omemo_manager_get_occupants (self, _tmp141_, _tmp143_);
						_tmp145_ = _tmp144_;
						_xmpp_jid_unref0 (_tmp141_);
						_jid_list = _tmp145_;
						_tmp146_ = _jid_list;
						_tmp147_ = gee_collection_get_size ((GeeCollection*) _tmp146_);
						_tmp148_ = _tmp147_;
						_jid_size = _tmp148_;
						_jid_index = -1;
						while (TRUE) {
							gint _tmp149_;
							gint _tmp150_;
							XmppJid* jid = NULL;
							GeeList* _tmp151_;
							gpointer _tmp152_;
							DinoPluginsOmemoStreamModule* _tmp153_;
							XmppXmppStream* _tmp154_;
							XmppJid* _tmp155_;
							_jid_index = _jid_index + 1;
							_tmp149_ = _jid_index;
							_tmp150_ = _jid_size;
							if (!(_tmp149_ < _tmp150_)) {
								break;
							}
							_tmp151_ = _jid_list;
							_tmp152_ = gee_list_get (_tmp151_, _jid_index);
							jid = (XmppJid*) _tmp152_;
							_tmp153_ = module;
							_tmp154_ = stream;
							_tmp155_ = jid;
							dino_plugins_omemo_stream_module_request_user_devicelist (_tmp153_, G_TYPE_CHECK_INSTANCE_CAST (_tmp154_, XMPP_TYPE_XMPP_STREAM, XmppXmppStream), _tmp155_, NULL, NULL);
							_xmpp_jid_unref0 (jid);
						}
						_g_object_unref0 (_jid_list);
					}
				}
			}
		}
		_dino_plugins_omemo_manager_message_state_unref0 (state);
		_xmpp_xep_omemo_encrypt_state_unref0 (enc_state);
		_g_object_unref0 (recipients);
		_g_object_unref0 (module);
		_g_object_unref0 (module_);
		_g_object_unref0 (stream);
	}
}

static void
dino_plugins_omemo_manager_on_mutual_subscription (DinoPluginsOmemoManager* self,
                                                   DinoEntitiesAccount* account,
                                                   XmppJid* jid)
{
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp0_;
	XmppXmppStream* _tmp1_;
	XmppXmppStream* _tmp2_;
	DinoStreamInteractor* _tmp3_;
	DinoModuleManager* _tmp4_;
	XmppModuleIdentity* _tmp5_;
	gpointer _tmp6_;
	DinoPluginsOmemoStreamModule* _tmp7_;
	XmppXmppStream* _tmp8_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = dino_stream_interactor_get_stream (_tmp0_, account);
	stream = _tmp1_;
	_tmp2_ = stream;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (stream);
		return;
	}
	_tmp3_ = self->priv->stream_interactor;
	_tmp4_ = _tmp3_->module_manager;
	_tmp5_ = dino_plugins_omemo_stream_module_IDENTITY;
	_tmp6_ = dino_module_manager_get_module (_tmp4_, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, account, _tmp5_);
	_tmp7_ = (DinoPluginsOmemoStreamModule*) _tmp6_;
	_tmp8_ = stream;
	dino_plugins_omemo_stream_module_request_user_devicelist (_tmp7_, G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, XMPP_TYPE_XMPP_STREAM, XmppXmppStream), jid, NULL, NULL);
	_g_object_unref0 (_tmp7_);
	_g_object_unref0 (stream);
}

static void
dino_plugins_omemo_manager_on_stream_negotiated (DinoPluginsOmemoManager* self,
                                                 DinoEntitiesAccount* account,
                                                 XmppXmppStream* stream)
{
	DinoPluginsOmemoStreamModule* module = NULL;
	DinoStreamInteractor* _tmp0_;
	DinoModuleManager* _tmp1_;
	XmppModuleIdentity* _tmp2_;
	gpointer _tmp3_;
	DinoPluginsOmemoStreamModule* _tmp4_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (stream != NULL);
	_tmp0_ = self->priv->stream_interactor;
	_tmp1_ = _tmp0_->module_manager;
	_tmp2_ = dino_plugins_omemo_stream_module_IDENTITY;
	_tmp3_ = dino_module_manager_get_module (_tmp1_, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, account, _tmp2_);
	module = (DinoPluginsOmemoStreamModule*) _tmp3_;
	_tmp4_ = module;
	if (_tmp4_ != NULL) {
		DinoPluginsOmemoStreamModule* _tmp5_;
		XmppJid* _tmp6_;
		XmppJid* _tmp7_;
		XmppJid* _tmp8_;
		_tmp5_ = module;
		_tmp6_ = dino_entities_account_get_bare_jid (account);
		_tmp7_ = _tmp6_;
		_tmp8_ = _tmp7_;
		dino_plugins_omemo_stream_module_request_user_devicelist (_tmp5_, stream, _tmp8_, NULL, NULL);
		_xmpp_jid_unref0 (_tmp8_);
	}
	_g_object_unref0 (module);
}

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

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		DinoPluginsOmemoManager* self;
		self = _data3_->self;
		_g_object_unref0 (_data3_->account);
		_g_object_unref0 (self);
		g_slice_free (Block3Data, _data3_);
	}
}

static void
___lambda20_ (Block3Data* _data3_,
              XmppJid* jid,
              GeeArrayList* devices)
{
	DinoPluginsOmemoManager* self;
	self = _data3_->self;
	g_return_if_fail (jid != NULL);
	g_return_if_fail (devices != NULL);
	dino_plugins_omemo_manager_on_device_list_loaded (self, _data3_->account, jid, devices);
}

static void
____lambda20__dino_plugins_omemo_stream_module_device_list_loaded (DinoPluginsOmemoStreamModule* _sender,
                                                                   XmppJid* jid,
                                                                   GeeArrayList* devices,
                                                                   gpointer self)
{
	___lambda20_ (self, jid, devices);
}

static void
___lambda22_ (Block3Data* _data3_,
              XmppJid* jid,
              gint device_id,
              DinoPluginsOmemoBundle* bundle)
{
	DinoPluginsOmemoManager* self;
	self = _data3_->self;
	g_return_if_fail (jid != NULL);
	g_return_if_fail (bundle != NULL);
	dino_plugins_omemo_manager_on_bundle_fetched (self, _data3_->account, jid, (gint32) device_id, bundle);
}

static void
____lambda22__dino_plugins_omemo_stream_module_bundle_fetched (DinoPluginsOmemoStreamModule* _sender,
                                                               XmppJid* jid,
                                                               gint device_id,
                                                               DinoPluginsOmemoBundle* bundle,
                                                               gpointer self)
{
	___lambda22_ (self, jid, device_id, bundle);
}

static void
___lambda23_ (Block3Data* _data3_,
              XmppJid* jid)
{
	DinoPluginsOmemoManager* self;
	self = _data3_->self;
	g_return_if_fail (jid != NULL);
	dino_plugins_omemo_manager_continue_message_sending (self, _data3_->account, jid);
}

static void
____lambda23__dino_plugins_omemo_stream_module_bundle_fetch_failed (DinoPluginsOmemoStreamModule* _sender,
                                                                    XmppJid* jid,
                                                                    gint device_id,
                                                                    gpointer self)
{
	___lambda23_ (self, jid);
}

static void
dino_plugins_omemo_manager_on_account_added (DinoPluginsOmemoManager* self,
                                             DinoEntitiesAccount* account)
{
	Block3Data* _data3_;
	DinoEntitiesAccount* _tmp0_;
	DinoPluginsOmemoStreamModule* module = NULL;
	DinoStreamInteractor* _tmp1_;
	DinoModuleManager* _tmp2_;
	XmppModuleIdentity* _tmp3_;
	gpointer _tmp4_;
	DinoPluginsOmemoStreamModule* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_data3_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (account);
	_g_object_unref0 (_data3_->account);
	_data3_->account = _tmp0_;
	_tmp1_ = self->priv->stream_interactor;
	_tmp2_ = _tmp1_->module_manager;
	_tmp3_ = dino_plugins_omemo_stream_module_IDENTITY;
	_tmp4_ = dino_module_manager_get_module (_tmp2_, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data3_->account, _tmp3_);
	module = (DinoPluginsOmemoStreamModule*) _tmp4_;
	_tmp5_ = module;
	if (_tmp5_ != NULL) {
		DinoPluginsOmemoStreamModule* _tmp6_;
		DinoPluginsOmemoStreamModule* _tmp7_;
		DinoPluginsOmemoStreamModule* _tmp8_;
		_tmp6_ = module;
		g_signal_connect_data (_tmp6_, "device-list-loaded", (GCallback) ____lambda20__dino_plugins_omemo_stream_module_device_list_loaded, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
		_tmp7_ = module;
		g_signal_connect_data (_tmp7_, "bundle-fetched", (GCallback) ____lambda22__dino_plugins_omemo_stream_module_bundle_fetched, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
		_tmp8_ = module;
		g_signal_connect_data (_tmp8_, "bundle-fetch-failed", (GCallback) ____lambda23__dino_plugins_omemo_stream_module_bundle_fetch_failed, block3_data_ref (_data3_), (GClosureNotify) block3_data_unref, 0);
	}
	dino_plugins_omemo_manager_initialize_store (self, _data3_->account, NULL, NULL);
	_g_object_unref0 (module);
	block3_data_unref (_data3_);
	_data3_ = NULL;
}

static void
dino_plugins_omemo_manager_on_device_list_loaded (DinoPluginsOmemoManager* self,
                                                  DinoEntitiesAccount* account,
                                                  XmppJid* jid,
                                                  GeeArrayList* device_list)
{
	XmppJid* _tmp0_;
	XmppJid* _tmp1_;
	XmppJid* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	XmppXmppStream* stream = NULL;
	DinoStreamInteractor* _tmp7_;
	XmppXmppStream* _tmp8_;
	XmppXmppStream* _tmp9_;
	DinoPluginsOmemoStreamModule* module = NULL;
	XmppXmppStream* _tmp10_;
	XmppModuleIdentity* _tmp11_;
	gpointer _tmp12_;
	DinoPluginsOmemoStreamModule* _tmp13_;
	gint identity_id = 0;
	DinoPluginsOmemoDatabase* _tmp14_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp15_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp16_;
	gint _tmp17_;
	gint _tmp18_;
	DinoPluginsOmemoDatabase* _tmp19_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp20_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp21_;
	XmppJid* _tmp22_;
	XmppJid* _tmp23_;
	XmppJid* _tmp24_;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gint inc = 0;
	DinoPluginsOmemoDatabase* _tmp67_;
	DinoPluginsOmemoDatabaseTrustTable* _tmp68_;
	DinoPluginsOmemoDatabaseTrustTable* _tmp69_;
	QliteQueryBuilder* _tmp70_;
	QliteQueryBuilder* _tmp71_;
	DinoPluginsOmemoDatabase* _tmp72_;
	DinoPluginsOmemoDatabaseTrustTable* _tmp73_;
	DinoPluginsOmemoDatabaseTrustTable* _tmp74_;
	QliteColumn* _tmp75_;
	QliteQueryBuilder* _tmp76_;
	QliteQueryBuilder* _tmp77_;
	DinoPluginsOmemoDatabase* _tmp78_;
	DinoPluginsOmemoDatabaseTrustTable* _tmp79_;
	DinoPluginsOmemoDatabaseTrustTable* _tmp80_;
	QliteColumn* _tmp81_;
	XmppJid* _tmp82_;
	XmppJid* _tmp83_;
	XmppJid* _tmp84_;
	gchar* _tmp85_;
	gchar* _tmp86_;
	QliteQueryBuilder* _tmp87_;
	QliteQueryBuilder* _tmp88_;
	gboolean _tmp89_;
	GeeHashSet* send_now = NULL;
	GeeHashSet* _tmp118_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (device_list != NULL);
	_tmp0_ = dino_entities_account_get_bare_jid (account);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = xmpp_jid_to_string (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = xmpp_jid_to_string (jid);
	_tmp6_ = _tmp5_;
	g_debug ("manager.vala:200: received device list for %s from %s", _tmp4_, _tmp6_);
	_g_free0 (_tmp6_);
	_g_free0 (_tmp4_);
	_xmpp_jid_unref0 (_tmp2_);
	_tmp7_ = self->priv->stream_interactor;
	_tmp8_ = dino_stream_interactor_get_stream (_tmp7_, account);
	stream = _tmp8_;
	_tmp9_ = stream;
	if (_tmp9_ == NULL) {
		_g_object_unref0 (stream);
		return;
	}
	_tmp10_ = stream;
	_tmp11_ = dino_plugins_omemo_stream_module_IDENTITY;
	_tmp12_ = xmpp_xmpp_stream_get_module (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, XMPP_TYPE_XMPP_STREAM, XmppXmppStream), DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp11_);
	module = (DinoPluginsOmemoStreamModule*) _tmp12_;
	_tmp13_ = module;
	if (_tmp13_ == NULL) {
		_g_object_unref0 (module);
		_g_object_unref0 (stream);
		return;
	}
	_tmp14_ = self->priv->db;
	_tmp15_ = dino_plugins_omemo_database_get_identity (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = dino_entities_account_get_id (account);
	_tmp18_ = _tmp17_;
	identity_id = dino_plugins_omemo_database_identity_table_get_id (_tmp16_, _tmp18_);
	if (identity_id < 0) {
		_g_object_unref0 (module);
		_g_object_unref0 (stream);
		return;
	}
	_tmp19_ = self->priv->db;
	_tmp20_ = dino_plugins_omemo_database_get_identity_meta (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = xmpp_jid_get_bare_jid (jid);
	_tmp23_ = _tmp22_;
	_tmp24_ = _tmp23_;
	_tmp25_ = xmpp_jid_to_string (_tmp24_);
	_tmp26_ = _tmp25_;
	dino_plugins_omemo_database_identity_meta_table_insert_device_list (_tmp21_, (gint32) identity_id, _tmp26_, device_list);
	_g_free0 (_tmp26_);
	_xmpp_jid_unref0 (_tmp24_);
	inc = 0;
	{
		QliteRowIterator* _row_it = NULL;
		DinoPluginsOmemoDatabase* _tmp27_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp28_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp29_;
		XmppJid* _tmp30_;
		XmppJid* _tmp31_;
		XmppJid* _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		QliteQueryBuilder* _tmp35_;
		QliteQueryBuilder* _tmp36_;
		QliteRowIterator* _tmp37_;
		QliteRowIterator* _tmp38_;
		_tmp27_ = self->priv->db;
		_tmp28_ = dino_plugins_omemo_database_get_identity_meta (_tmp27_);
		_tmp29_ = _tmp28_;
		_tmp30_ = xmpp_jid_get_bare_jid (jid);
		_tmp31_ = _tmp30_;
		_tmp32_ = _tmp31_;
		_tmp33_ = xmpp_jid_to_string (_tmp32_);
		_tmp34_ = _tmp33_;
		_tmp35_ = dino_plugins_omemo_database_identity_meta_table_get_unknown_devices (_tmp29_, identity_id, _tmp34_);
		_tmp36_ = _tmp35_;
		_tmp37_ = qlite_query_builder_iterator (_tmp36_);
		_tmp38_ = _tmp37_;
		_qlite_statement_builder_unref0 (_tmp36_);
		_g_free0 (_tmp34_);
		_xmpp_jid_unref0 (_tmp32_);
		_row_it = _tmp38_;
		while (TRUE) {
			QliteRowIterator* _tmp39_;
			QliteRow* row = NULL;
			QliteRowIterator* _tmp40_;
			QliteRow* _tmp41_;
			_tmp39_ = _row_it;
			if (!qlite_row_iterator_next (_tmp39_)) {
				break;
			}
			_tmp40_ = _row_it;
			_tmp41_ = qlite_row_iterator_get (_tmp40_);
			row = _tmp41_;
			{
				XmppJid* _tmp42_ = NULL;
				QliteRow* _tmp43_;
				DinoPluginsOmemoDatabase* _tmp44_;
				DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp45_;
				DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp46_;
				QliteColumn* _tmp47_;
				gpointer _tmp48_;
				gchar* _tmp49_;
				XmppJid* _tmp50_;
				XmppJid* _tmp51_;
				DinoPluginsOmemoStreamModule* _tmp52_;
				XmppXmppStream* _tmp53_;
				QliteRow* _tmp54_;
				DinoPluginsOmemoDatabase* _tmp55_;
				DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp56_;
				DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp57_;
				QliteColumn* _tmp58_;
				gpointer _tmp59_;
				gint _tmp60_;
				_tmp43_ = row;
				_tmp44_ = self->priv->db;
				_tmp45_ = dino_plugins_omemo_database_get_identity_meta (_tmp44_);
				_tmp46_ = _tmp45_;
				_tmp47_ = _tmp46_->address_name;
				_tmp48_ = qlite_row_get (_tmp43_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp47_);
				_tmp49_ = (gchar*) _tmp48_;
				_tmp50_ = xmpp_jid_new (_tmp49_, &_inner_error0_);
				_tmp51_ = _tmp50_;
				_g_free0 (_tmp49_);
				_tmp42_ = _tmp51_;
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					if (_inner_error0_->domain == XMPP_INVALID_JID_ERROR) {
						goto __catch0_xmpp_invalid_jid_error;
					}
					_qlite_row_unref0 (row);
					_qlite_row_iterator_unref0 (_row_it);
					_g_object_unref0 (module);
					_g_object_unref0 (stream);
					g_critical ("file %s: line %d: unexpected 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;
				}
				_tmp52_ = module;
				_tmp53_ = stream;
				_tmp54_ = row;
				_tmp55_ = self->priv->db;
				_tmp56_ = dino_plugins_omemo_database_get_identity_meta (_tmp55_);
				_tmp57_ = _tmp56_;
				_tmp58_ = _tmp57_->device_id;
				_tmp59_ = qlite_row_get (_tmp54_, G_TYPE_INT, NULL, NULL, _tmp58_);
				dino_plugins_omemo_stream_module_fetch_bundle (_tmp52_, _tmp53_, _tmp42_, (gint) ((gintptr) _tmp59_), FALSE);
				_tmp60_ = inc;
				inc = _tmp60_ + 1;
				_xmpp_jid_unref0 (_tmp42_);
			}
			goto __finally0;
			__catch0_xmpp_invalid_jid_error:
			{
				GError* e = NULL;
				GError* _tmp61_;
				const gchar* _tmp62_;
				e = _inner_error0_;
				_inner_error0_ = NULL;
				_tmp61_ = e;
				_tmp62_ = _tmp61_->message;
				g_warning ("manager.vala:224: Ignoring device with invalid Jid: %s", _tmp62_);
				_g_error_free0 (e);
			}
			__finally0:
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_qlite_row_unref0 (row);
				_qlite_row_iterator_unref0 (_row_it);
				_g_object_unref0 (module);
				_g_object_unref0 (stream);
				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;
			}
			_qlite_row_unref0 (row);
		}
		_qlite_row_iterator_unref0 (_row_it);
	}
	if (inc > 0) {
		gint _tmp63_;
		gint _tmp64_;
		gchar* _tmp65_;
		gchar* _tmp66_;
		_tmp63_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) device_list);
		_tmp64_ = _tmp63_;
		_tmp65_ = xmpp_jid_to_string (jid);
		_tmp66_ = _tmp65_;
		g_debug ("manager.vala:228: new bundles %i/%i for %s", inc, _tmp64_, _tmp66_);
		_g_free0 (_tmp66_);
	}
	_tmp67_ = self->priv->db;
	_tmp68_ = dino_plugins_omemo_database_get_trust (_tmp67_);
	_tmp69_ = _tmp68_;
	_tmp70_ = qlite_table_select ((QliteTable*) _tmp69_, NULL, (gint) 0);
	_tmp71_ = _tmp70_;
	_tmp72_ = self->priv->db;
	_tmp73_ = dino_plugins_omemo_database_get_trust (_tmp72_);
	_tmp74_ = _tmp73_;
	_tmp75_ = _tmp74_->identity_id;
	_tmp76_ = qlite_query_builder_with (_tmp71_, G_TYPE_INT, NULL, NULL, _tmp75_, "=", (gpointer) ((gintptr) identity_id));
	_tmp77_ = _tmp76_;
	_tmp78_ = self->priv->db;
	_tmp79_ = dino_plugins_omemo_database_get_trust (_tmp78_);
	_tmp80_ = _tmp79_;
	_tmp81_ = _tmp80_->address_name;
	_tmp82_ = xmpp_jid_get_bare_jid (jid);
	_tmp83_ = _tmp82_;
	_tmp84_ = _tmp83_;
	_tmp85_ = xmpp_jid_to_string (_tmp84_);
	_tmp86_ = _tmp85_;
	_tmp87_ = qlite_query_builder_with (_tmp77_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp81_, "=", _tmp86_);
	_tmp88_ = _tmp87_;
	_tmp89_ = qlite_query_builder_count (_tmp88_) == ((gint64) 0);
	_qlite_statement_builder_unref0 (_tmp88_);
	_g_free0 (_tmp86_);
	_xmpp_jid_unref0 (_tmp84_);
	_qlite_statement_builder_unref0 (_tmp77_);
	_qlite_statement_builder_unref0 (_tmp71_);
	if (_tmp89_) {
		DinoPluginsOmemoDatabase* _tmp90_;
		DinoPluginsOmemoDatabaseTrustTable* _tmp91_;
		DinoPluginsOmemoDatabaseTrustTable* _tmp92_;
		QliteInsertBuilder* _tmp93_;
		QliteInsertBuilder* _tmp94_;
		DinoPluginsOmemoDatabase* _tmp95_;
		DinoPluginsOmemoDatabaseTrustTable* _tmp96_;
		DinoPluginsOmemoDatabaseTrustTable* _tmp97_;
		QliteColumn* _tmp98_;
		QliteInsertBuilder* _tmp99_;
		QliteInsertBuilder* _tmp100_;
		DinoPluginsOmemoDatabase* _tmp101_;
		DinoPluginsOmemoDatabaseTrustTable* _tmp102_;
		DinoPluginsOmemoDatabaseTrustTable* _tmp103_;
		QliteColumn* _tmp104_;
		XmppJid* _tmp105_;
		XmppJid* _tmp106_;
		XmppJid* _tmp107_;
		gchar* _tmp108_;
		gchar* _tmp109_;
		QliteInsertBuilder* _tmp110_;
		QliteInsertBuilder* _tmp111_;
		DinoPluginsOmemoDatabase* _tmp112_;
		DinoPluginsOmemoDatabaseTrustTable* _tmp113_;
		DinoPluginsOmemoDatabaseTrustTable* _tmp114_;
		QliteColumn* _tmp115_;
		QliteInsertBuilder* _tmp116_;
		QliteInsertBuilder* _tmp117_;
		_tmp90_ = self->priv->db;
		_tmp91_ = dino_plugins_omemo_database_get_trust (_tmp90_);
		_tmp92_ = _tmp91_;
		_tmp93_ = qlite_table_insert ((QliteTable*) _tmp92_);
		_tmp94_ = _tmp93_;
		_tmp95_ = self->priv->db;
		_tmp96_ = dino_plugins_omemo_database_get_trust (_tmp95_);
		_tmp97_ = _tmp96_;
		_tmp98_ = _tmp97_->identity_id;
		_tmp99_ = qlite_insert_builder_value (_tmp94_, G_TYPE_INT, NULL, NULL, _tmp98_, (gpointer) ((gintptr) identity_id));
		_tmp100_ = _tmp99_;
		_tmp101_ = self->priv->db;
		_tmp102_ = dino_plugins_omemo_database_get_trust (_tmp101_);
		_tmp103_ = _tmp102_;
		_tmp104_ = _tmp103_->address_name;
		_tmp105_ = xmpp_jid_get_bare_jid (jid);
		_tmp106_ = _tmp105_;
		_tmp107_ = _tmp106_;
		_tmp108_ = xmpp_jid_to_string (_tmp107_);
		_tmp109_ = _tmp108_;
		_tmp110_ = qlite_insert_builder_value (_tmp100_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp104_, _tmp109_);
		_tmp111_ = _tmp110_;
		_tmp112_ = self->priv->db;
		_tmp113_ = dino_plugins_omemo_database_get_trust (_tmp112_);
		_tmp114_ = _tmp113_;
		_tmp115_ = _tmp114_->blind_trust;
		_tmp116_ = qlite_insert_builder_value (_tmp111_, G_TYPE_BOOLEAN, NULL, NULL, _tmp115_, (gpointer) ((gintptr) TRUE));
		_tmp117_ = _tmp116_;
		qlite_insert_builder_perform (_tmp117_);
		_qlite_statement_builder_unref0 (_tmp117_);
		_qlite_statement_builder_unref0 (_tmp111_);
		_g_free0 (_tmp109_);
		_xmpp_jid_unref0 (_tmp107_);
		_qlite_statement_builder_unref0 (_tmp100_);
		_qlite_statement_builder_unref0 (_tmp94_);
	}
	_tmp118_ = gee_hash_set_new (DINO_ENTITIES_TYPE_MESSAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	send_now = _tmp118_;
	{
		GeeMap* _tmp119_;
		_tmp119_ = self->priv->message_states;
		g_rec_mutex_lock (&self->priv->__lock_message_states);
		{
			{
				GeeIterator* _msg_it = NULL;
				GeeMap* _tmp120_;
				GeeSet* _tmp121_;
				GeeSet* _tmp122_;
				GeeSet* _tmp123_;
				GeeIterator* _tmp124_;
				GeeIterator* _tmp125_;
				_tmp120_ = self->priv->message_states;
				_tmp121_ = gee_map_get_keys (_tmp120_);
				_tmp122_ = _tmp121_;
				_tmp123_ = _tmp122_;
				_tmp124_ = gee_iterable_iterator ((GeeIterable*) _tmp123_);
				_tmp125_ = _tmp124_;
				_g_object_unref0 (_tmp123_);
				_msg_it = _tmp125_;
				while (TRUE) {
					GeeIterator* _tmp126_;
					DinoEntitiesMessage* msg = NULL;
					GeeIterator* _tmp127_;
					gpointer _tmp128_;
					DinoEntitiesMessage* _tmp129_;
					DinoEntitiesAccount* _tmp130_;
					DinoEntitiesAccount* _tmp131_;
					GeeList* occupants = NULL;
					DinoEntitiesMessage* _tmp132_;
					XmppJid* _tmp133_;
					XmppJid* _tmp134_;
					XmppJid* _tmp135_;
					XmppJid* _tmp136_;
					XmppJid* _tmp137_;
					GeeList* _tmp138_;
					GeeList* _tmp139_;
					DinoPluginsOmemoManagerMessageState* state = NULL;
					GeeMap* _tmp140_;
					DinoEntitiesMessage* _tmp141_;
					gpointer _tmp142_;
					XmppJid* _tmp143_;
					XmppJid* _tmp144_;
					XmppJid* _tmp145_;
					gboolean _tmp146_;
					DinoPluginsOmemoManagerMessageState* _tmp156_;
					_tmp126_ = _msg_it;
					if (!gee_iterator_next (_tmp126_)) {
						break;
					}
					_tmp127_ = _msg_it;
					_tmp128_ = gee_iterator_get (_tmp127_);
					msg = (DinoEntitiesMessage*) _tmp128_;
					_tmp129_ = msg;
					_tmp130_ = dino_entities_message_get_account (_tmp129_);
					_tmp131_ = _tmp130_;
					if (!dino_entities_account_equals (_tmp131_, account)) {
						_g_object_unref0 (msg);
						continue;
					}
					_tmp132_ = msg;
					_tmp133_ = dino_entities_message_get_counterpart (_tmp132_);
					_tmp134_ = _tmp133_;
					_tmp135_ = xmpp_jid_get_bare_jid (_tmp134_);
					_tmp136_ = _tmp135_;
					_tmp137_ = _tmp136_;
					_tmp138_ = dino_plugins_omemo_manager_get_occupants (self, _tmp137_, account);
					_tmp139_ = _tmp138_;
					_xmpp_jid_unref0 (_tmp137_);
					occupants = _tmp139_;
					_tmp140_ = self->priv->message_states;
					_tmp141_ = msg;
					_tmp142_ = gee_map_get (_tmp140_, _tmp141_);
					state = (DinoPluginsOmemoManagerMessageState*) _tmp142_;
					_tmp143_ = dino_entities_account_get_bare_jid (account);
					_tmp144_ = _tmp143_;
					_tmp145_ = _tmp144_;
					_tmp146_ = xmpp_jid_equals (_tmp145_, jid);
					_xmpp_jid_unref0 (_tmp145_);
					if (_tmp146_) {
						DinoPluginsOmemoManagerMessageState* _tmp147_;
						_tmp147_ = state;
						dino_plugins_omemo_manager_message_state_set_waiting_own_devicelist (_tmp147_, FALSE);
					} else {
						gboolean _tmp148_ = FALSE;
						DinoEntitiesMessage* _tmp149_;
						XmppJid* _tmp150_;
						XmppJid* _tmp151_;
						_tmp149_ = msg;
						_tmp150_ = dino_entities_message_get_counterpart (_tmp149_);
						_tmp151_ = _tmp150_;
						if (_tmp151_ != NULL) {
							GeeList* _tmp152_;
							_tmp152_ = occupants;
							_tmp148_ = gee_collection_contains ((GeeCollection*) _tmp152_, jid);
						} else {
							_tmp148_ = FALSE;
						}
						if (_tmp148_) {
							DinoPluginsOmemoManagerMessageState* _tmp153_;
							gint _tmp154_;
							gint _tmp155_;
							_tmp153_ = state;
							_tmp154_ = dino_plugins_omemo_manager_message_state_get_waiting_other_devicelists (_tmp153_);
							_tmp155_ = _tmp154_;
							dino_plugins_omemo_manager_message_state_set_waiting_other_devicelists (_tmp153_, _tmp155_ - 1);
						}
					}
					_tmp156_ = state;
					if (dino_plugins_omemo_manager_message_state_should_retry_now (_tmp156_)) {
						GeeHashSet* _tmp157_;
						DinoEntitiesMessage* _tmp158_;
						DinoPluginsOmemoManagerMessageState* _tmp159_;
						_tmp157_ = send_now;
						_tmp158_ = msg;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp157_, _tmp158_);
						_tmp159_ = state;
						dino_plugins_omemo_manager_message_state_set_active_send_attempt (_tmp159_, TRUE);
					}
					_dino_plugins_omemo_manager_message_state_unref0 (state);
					_g_object_unref0 (occupants);
					_g_object_unref0 (msg);
				}
				_g_object_unref0 (_msg_it);
			}
		}
		__finally1:
		{
			GeeMap* _tmp160_;
			_tmp160_ = self->priv->message_states;
			g_rec_mutex_unlock (&self->priv->__lock_message_states);
		}
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (send_now);
			_g_object_unref0 (module);
			_g_object_unref0 (stream);
			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;
		}
	}
	{
		GeeIterator* _msg_it = NULL;
		GeeHashSet* _tmp161_;
		GeeIterator* _tmp162_;
		_tmp161_ = send_now;
		_tmp162_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _tmp161_);
		_msg_it = _tmp162_;
		while (TRUE) {
			GeeIterator* _tmp163_;
			DinoEntitiesMessage* msg = NULL;
			GeeIterator* _tmp164_;
			gpointer _tmp165_;
			DinoEntitiesMessage* _tmp166_;
			XmppJid* _tmp167_;
			XmppJid* _tmp168_;
			DinoEntitiesConversation* conv = NULL;
			DinoStreamInteractor* _tmp169_;
			DinoModuleIdentity* _tmp170_;
			gpointer _tmp171_;
			DinoConversationManager* _tmp172_;
			DinoEntitiesMessage* _tmp173_;
			XmppJid* _tmp174_;
			XmppJid* _tmp175_;
			DinoEntitiesConversation* _tmp176_;
			DinoEntitiesConversation* _tmp177_;
			DinoEntitiesConversation* _tmp178_;
			DinoStreamInteractor* _tmp179_;
			DinoModuleIdentity* _tmp180_;
			gpointer _tmp181_;
			DinoMessageProcessor* _tmp182_;
			DinoEntitiesMessage* _tmp183_;
			DinoEntitiesConversation* _tmp184_;
			_tmp163_ = _msg_it;
			if (!gee_iterator_next (_tmp163_)) {
				break;
			}
			_tmp164_ = _msg_it;
			_tmp165_ = gee_iterator_get (_tmp164_);
			msg = (DinoEntitiesMessage*) _tmp165_;
			_tmp166_ = msg;
			_tmp167_ = dino_entities_message_get_counterpart (_tmp166_);
			_tmp168_ = _tmp167_;
			if (_tmp168_ == NULL) {
				_g_object_unref0 (msg);
				continue;
			}
			_tmp169_ = self->priv->stream_interactor;
			_tmp170_ = dino_conversation_manager_IDENTITY;
			_tmp171_ = dino_stream_interactor_get_module (_tmp169_, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp170_);
			_tmp172_ = (DinoConversationManager*) _tmp171_;
			_tmp173_ = msg;
			_tmp174_ = dino_entities_message_get_counterpart (_tmp173_);
			_tmp175_ = _tmp174_;
			_tmp176_ = dino_conversation_manager_get_conversation (_tmp172_, G_TYPE_CHECK_INSTANCE_CAST (_tmp175_, XMPP_TYPE_JID, XmppJid), account, NULL);
			_tmp177_ = _tmp176_;
			_g_object_unref0 (_tmp172_);
			conv = _tmp177_;
			_tmp178_ = conv;
			if (_tmp178_ == NULL) {
				_g_object_unref0 (conv);
				_g_object_unref0 (msg);
				continue;
			}
			_tmp179_ = self->priv->stream_interactor;
			_tmp180_ = dino_message_processor_IDENTITY;
			_tmp181_ = dino_stream_interactor_get_module (_tmp179_, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp180_);
			_tmp182_ = (DinoMessageProcessor*) _tmp181_;
			_tmp183_ = msg;
			_tmp184_ = conv;
			dino_message_processor_send_xmpp_message (_tmp182_, _tmp183_, G_TYPE_CHECK_INSTANCE_CAST (_tmp184_, DINO_ENTITIES_TYPE_CONVERSATION, DinoEntitiesConversation), TRUE);
			_g_object_unref0 (_tmp182_);
			_g_object_unref0 (conv);
			_g_object_unref0 (msg);
		}
		_g_object_unref0 (_msg_it);
	}
	_g_object_unref0 (send_now);
	_g_object_unref0 (module);
	_g_object_unref0 (stream);
}

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_dup25 (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_dup25 (_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_manager_on_bundle_fetched (DinoPluginsOmemoManager* self,
                                              DinoEntitiesAccount* account,
                                              XmppJid* jid,
                                              gint32 device_id,
                                              DinoPluginsOmemoBundle* bundle)
{
	gint identity_id = 0;
	DinoPluginsOmemoDatabase* _tmp0_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp1_;
	DinoPluginsOmemoDatabaseIdentityTable* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gboolean blind_trust = FALSE;
	DinoPluginsOmemoDatabase* _tmp5_;
	DinoPluginsOmemoDatabaseTrustTable* _tmp6_;
	DinoPluginsOmemoDatabaseTrustTable* _tmp7_;
	XmppJid* _tmp8_;
	XmppJid* _tmp9_;
	XmppJid* _tmp10_;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gboolean _tmp13_;
	gboolean _tmp14_ = FALSE;
	gboolean untrust = FALSE;
	QliteRow* device = NULL;
	DinoPluginsOmemoDatabase* _tmp49_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp50_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp51_;
	XmppJid* _tmp52_;
	XmppJid* _tmp53_;
	XmppJid* _tmp54_;
	gchar* _tmp55_;
	gchar* _tmp56_;
	QliteRow* _tmp57_;
	QliteRow* _tmp58_;
	DinoPluginsOmemoTrustLevel trusted = 0;
	QliteRow* _tmp59_;
	DinoPluginsOmemoDatabase* _tmp67_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp68_;
	DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp69_;
	XmppJid* _tmp70_;
	XmppJid* _tmp71_;
	XmppJid* _tmp72_;
	gchar* _tmp73_;
	gchar* _tmp74_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (bundle != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_plugins_omemo_database_get_identity (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = dino_entities_account_get_id (account);
	_tmp4_ = _tmp3_;
	identity_id = dino_plugins_omemo_database_identity_table_get_id (_tmp2_, _tmp4_);
	if (identity_id < 0) {
		return;
	}
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_plugins_omemo_database_get_trust (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = xmpp_jid_get_bare_jid (jid);
	_tmp9_ = _tmp8_;
	_tmp10_ = _tmp9_;
	_tmp11_ = xmpp_jid_to_string (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = dino_plugins_omemo_database_trust_table_get_blind_trust (_tmp7_, (gint32) identity_id, _tmp12_, TRUE);
	_g_free0 (_tmp12_);
	_xmpp_jid_unref0 (_tmp10_);
	blind_trust = _tmp13_;
	if (blind_trust) {
		_tmp14_ = TRUE;
	} else {
		DinoPluginsOmemoDatabase* _tmp15_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp16_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp17_;
		XmppJid* _tmp18_;
		XmppJid* _tmp19_;
		XmppJid* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		QliteQueryBuilder* _tmp23_;
		QliteQueryBuilder* _tmp24_;
		DinoPluginsOmemoDatabase* _tmp25_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp26_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp27_;
		QliteColumn* _tmp28_;
		QliteQueryBuilder* _tmp29_;
		QliteQueryBuilder* _tmp30_;
		DinoPluginsOmemoDatabase* _tmp31_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp32_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp33_;
		QliteColumn* _tmp34_;
		ec_public_key* _tmp35_;
		ec_public_key* _tmp36_;
		ec_public_key* _tmp37_;
		gint _tmp38_ = 0;
		guint8* _tmp39_;
		guint8* _tmp40_;
		gint _tmp40__length1;
		gchar* _tmp41_;
		gchar* _tmp42_;
		QliteQueryBuilder* _tmp43_;
		QliteQueryBuilder* _tmp44_;
		QliteQueryBuilder* _tmp45_;
		QliteQueryBuilder* _tmp46_;
		QliteRowOption* _tmp47_;
		QliteRowOption* _tmp48_;
		_tmp15_ = self->priv->db;
		_tmp16_ = dino_plugins_omemo_database_get_identity_meta (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = xmpp_jid_get_bare_jid (jid);
		_tmp19_ = _tmp18_;
		_tmp20_ = _tmp19_;
		_tmp21_ = xmpp_jid_to_string (_tmp20_);
		_tmp22_ = _tmp21_;
		_tmp23_ = dino_plugins_omemo_database_identity_meta_table_with_address (_tmp17_, identity_id, _tmp22_);
		_tmp24_ = _tmp23_;
		_tmp25_ = self->priv->db;
		_tmp26_ = dino_plugins_omemo_database_get_identity_meta (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = _tmp27_->device_id;
		_tmp29_ = qlite_query_builder_with (_tmp24_, G_TYPE_INT, NULL, NULL, _tmp28_, "=", (gpointer) ((gintptr) device_id));
		_tmp30_ = _tmp29_;
		_tmp31_ = self->priv->db;
		_tmp32_ = dino_plugins_omemo_database_get_identity_meta (_tmp31_);
		_tmp33_ = _tmp32_;
		_tmp34_ = _tmp33_->identity_key_public_base64;
		_tmp35_ = dino_plugins_omemo_bundle_get_identity_key (bundle);
		_tmp36_ = _tmp35_;
		_tmp37_ = _tmp36_;
		_tmp39_ = ec_public_key_serialize_ (_tmp37_, &_tmp38_);
		_tmp40_ = _tmp39_;
		_tmp40__length1 = _tmp38_;
		_tmp41_ = g_base64_encode (_tmp40_, (gint) _tmp38_);
		_tmp42_ = _tmp41_;
		_tmp43_ = qlite_query_builder_with (_tmp30_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp34_, "=", _tmp42_);
		_tmp44_ = _tmp43_;
		_tmp45_ = qlite_query_builder_single (_tmp44_);
		_tmp46_ = _tmp45_;
		_tmp47_ = qlite_query_builder_row (_tmp46_);
		_tmp48_ = _tmp47_;
		_tmp14_ = qlite_row_option_is_present (_tmp48_);
		_qlite_row_option_unref0 (_tmp48_);
		_qlite_statement_builder_unref0 (_tmp46_);
		_qlite_statement_builder_unref0 (_tmp44_);
		_g_free0 (_tmp42_);
		_tmp40_ = (g_free (_tmp40_), NULL);
		_signal_type_unref_vapi0 (_tmp37_);
		_qlite_statement_builder_unref0 (_tmp30_);
		_qlite_statement_builder_unref0 (_tmp24_);
		_g_free0 (_tmp22_);
		_xmpp_jid_unref0 (_tmp20_);
	}
	untrust = !_tmp14_;
	_tmp49_ = self->priv->db;
	_tmp50_ = dino_plugins_omemo_database_get_identity_meta (_tmp49_);
	_tmp51_ = _tmp50_;
	_tmp52_ = xmpp_jid_get_bare_jid (jid);
	_tmp53_ = _tmp52_;
	_tmp54_ = _tmp53_;
	_tmp55_ = xmpp_jid_to_string (_tmp54_);
	_tmp56_ = _tmp55_;
	_tmp57_ = dino_plugins_omemo_database_identity_meta_table_get_device (_tmp51_, identity_id, _tmp56_, (gint) device_id);
	_tmp58_ = _tmp57_;
	_g_free0 (_tmp56_);
	_xmpp_jid_unref0 (_tmp54_);
	device = _tmp58_;
	trusted = DINO_PLUGINS_OMEMO_TRUST_LEVEL_UNKNOWN;
	_tmp59_ = device;
	if (_tmp59_ != NULL) {
		QliteRow* _tmp60_;
		DinoPluginsOmemoDatabase* _tmp61_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp62_;
		DinoPluginsOmemoDatabaseIdentityMetaTable* _tmp63_;
		QliteColumn* _tmp64_;
		gpointer _tmp65_;
		_tmp60_ = device;
		_tmp61_ = self->priv->db;
		_tmp62_ = dino_plugins_omemo_database_get_identity_meta (_tmp61_);
		_tmp63_ = _tmp62_;
		_tmp64_ = _tmp63_->trust_level;
		_tmp65_ = qlite_row_get (_tmp60_, G_TYPE_INT, NULL, NULL, _tmp64_);
		trusted = (DinoPluginsOmemoTrustLevel) ((gint) ((gintptr) _tmp65_));
	}
	if (untrust) {
		trusted = DINO_PLUGINS_OMEMO_TRUST_LEVEL_UNKNOWN;
	} else {
		gboolean _tmp66_ = FALSE;
		if (blind_trust) {
			_tmp66_ = trusted == DINO_PLUGINS_OMEMO_TRUST_LEVEL_UNKNOWN;
		} else {
			_tmp66_ = FALSE;
		}
		if (_tmp66_) {
			trusted = DINO_PLUGINS_OMEMO_TRUST_LEVEL_TRUSTED;
		}
	}
	_tmp67_ = self->priv->db;
	_tmp68_ = dino_plugins_omemo_database_get_identity_meta (_tmp67_);
	_tmp69_ = _tmp68_;
	_tmp70_ = xmpp_jid_get_bare_jid (jid);
	_tmp71_ = _tmp70_;
	_tmp72_ = _tmp71_;
	_tmp73_ = xmpp_jid_to_string (_tmp72_);
	_tmp74_ = _tmp73_;
	dino_plugins_omemo_database_identity_meta_table_insert_device_bundle (_tmp69_, (gint32) identity_id, _tmp74_, (gint) device_id, bundle, trusted);
	_g_free0 (_tmp74_);
	_xmpp_jid_unref0 (_tmp72_);
	if (dino_plugins_omemo_manager_should_start_session (self, account, jid)) {
		XmppXmppStream* stream = NULL;
		DinoStreamInteractor* _tmp75_;
		XmppXmppStream* _tmp76_;
		XmppXmppStream* _tmp77_;
		_tmp75_ = self->priv->stream_interactor;
		_tmp76_ = dino_stream_interactor_get_stream (_tmp75_, account);
		stream = _tmp76_;
		_tmp77_ = stream;
		if (_tmp77_ != NULL) {
			DinoPluginsOmemoStreamModule* module = NULL;
			XmppXmppStream* _tmp78_;
			XmppModuleIdentity* _tmp79_;
			gpointer _tmp80_;
			DinoPluginsOmemoStreamModule* _tmp81_;
			_tmp78_ = stream;
			_tmp79_ = dino_plugins_omemo_stream_module_IDENTITY;
			_tmp80_ = xmpp_xmpp_stream_get_module (G_TYPE_CHECK_INSTANCE_CAST (_tmp78_, XMPP_TYPE_XMPP_STREAM, XmppXmppStream), DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp79_);
			module = (DinoPluginsOmemoStreamModule*) _tmp80_;
			_tmp81_ = module;
			if (_tmp81_ != NULL) {
				DinoPluginsOmemoStreamModule* _tmp82_;
				XmppXmppStream* _tmp83_;
				_tmp82_ = module;
				_tmp83_ = stream;
				dino_plugins_omemo_stream_module_start_session (_tmp82_, _tmp83_, jid, device_id, bundle);
			}
			_g_object_unref0 (module);
		}
		_g_object_unref0 (stream);
	}
	dino_plugins_omemo_manager_continue_message_sending (self, account, jid);
	_qlite_row_unref0 (device);
}

static gboolean
dino_plugins_omemo_manager_should_start_session (DinoPluginsOmemoManager* self,
                                                 DinoEntitiesAccount* account,
                                                 XmppJid* jid)
{
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (account != NULL, FALSE);
	g_return_val_if_fail (jid != NULL, FALSE);
	{
		GeeMap* _tmp0_;
		_tmp0_ = self->priv->message_states;
		g_rec_mutex_lock (&self->priv->__lock_message_states);
		{
			{
				GeeIterator* _msg_it = NULL;
				GeeMap* _tmp1_;
				GeeSet* _tmp2_;
				GeeSet* _tmp3_;
				GeeSet* _tmp4_;
				GeeIterator* _tmp5_;
				GeeIterator* _tmp6_;
				_tmp1_ = self->priv->message_states;
				_tmp2_ = gee_map_get_keys (_tmp1_);
				_tmp3_ = _tmp2_;
				_tmp4_ = _tmp3_;
				_tmp5_ = gee_iterable_iterator ((GeeIterable*) _tmp4_);
				_tmp6_ = _tmp5_;
				_g_object_unref0 (_tmp4_);
				_msg_it = _tmp6_;
				while (TRUE) {
					GeeIterator* _tmp7_;
					DinoEntitiesMessage* msg = NULL;
					GeeIterator* _tmp8_;
					gpointer _tmp9_;
					DinoEntitiesMessage* _tmp10_;
					DinoEntitiesAccount* _tmp11_;
					DinoEntitiesAccount* _tmp12_;
					GeeList* occupants = NULL;
					DinoEntitiesMessage* _tmp13_;
					XmppJid* _tmp14_;
					XmppJid* _tmp15_;
					XmppJid* _tmp16_;
					XmppJid* _tmp17_;
					XmppJid* _tmp18_;
					GeeList* _tmp19_;
					GeeList* _tmp20_;
					gboolean _tmp21_ = FALSE;
					XmppJid* _tmp22_;
					XmppJid* _tmp23_;
					XmppJid* _tmp24_;
					gboolean _tmp25_;
					_tmp7_ = _msg_it;
					if (!gee_iterator_next (_tmp7_)) {
						break;
					}
					_tmp8_ = _msg_it;
					_tmp9_ = gee_iterator_get (_tmp8_);
					msg = (DinoEntitiesMessage*) _tmp9_;
					_tmp10_ = msg;
					_tmp11_ = dino_entities_message_get_account (_tmp10_);
					_tmp12_ = _tmp11_;
					if (!dino_entities_account_equals (_tmp12_, account)) {
						_g_object_unref0 (msg);
						continue;
					}
					_tmp13_ = msg;
					_tmp14_ = dino_entities_message_get_counterpart (_tmp13_);
					_tmp15_ = _tmp14_;
					_tmp16_ = xmpp_jid_get_bare_jid (_tmp15_);
					_tmp17_ = _tmp16_;
					_tmp18_ = _tmp17_;
					_tmp19_ = dino_plugins_omemo_manager_get_occupants (self, _tmp18_, account);
					_tmp20_ = _tmp19_;
					_xmpp_jid_unref0 (_tmp18_);
					occupants = _tmp20_;
					_tmp22_ = dino_entities_account_get_bare_jid (account);
					_tmp23_ = _tmp22_;
					_tmp24_ = _tmp23_;
					_tmp25_ = xmpp_jid_equals (_tmp24_, jid);
					_xmpp_jid_unref0 (_tmp24_);
					if (_tmp25_) {
						_tmp21_ = TRUE;
					} else {
						gboolean _tmp26_ = FALSE;
						DinoEntitiesMessage* _tmp27_;
						XmppJid* _tmp28_;
						XmppJid* _tmp29_;
						_tmp27_ = msg;
						_tmp28_ = dino_entities_message_get_counterpart (_tmp27_);
						_tmp29_ = _tmp28_;
						if (_tmp29_ != NULL) {
							gboolean _tmp30_ = FALSE;
							DinoEntitiesMessage* _tmp31_;
							XmppJid* _tmp32_;
							XmppJid* _tmp33_;
							_tmp31_ = msg;
							_tmp32_ = dino_entities_message_get_counterpart (_tmp31_);
							_tmp33_ = _tmp32_;
							if (xmpp_jid_equals_bare (_tmp33_, jid)) {
								_tmp30_ = TRUE;
							} else {
								GeeList* _tmp34_;
								_tmp34_ = occupants;
								_tmp30_ = gee_collection_contains ((GeeCollection*) _tmp34_, jid);
							}
							_tmp26_ = _tmp30_;
						} else {
							_tmp26_ = FALSE;
						}
						_tmp21_ = _tmp26_;
					}
					if (_tmp21_) {
						result = TRUE;
						_g_object_unref0 (occupants);
						_g_object_unref0 (msg);
						_g_object_unref0 (_msg_it);
						{
							GeeMap* _tmp35_;
							_tmp35_ = self->priv->message_states;
							g_rec_mutex_unlock (&self->priv->__lock_message_states);
						}
						return result;
					}
					_g_object_unref0 (occupants);
					_g_object_unref0 (msg);
				}
				_g_object_unref0 (_msg_it);
			}
		}
		__finally0:
		{
			GeeMap* _tmp36_;
			_tmp36_ = self->priv->message_states;
			g_rec_mutex_unlock (&self->priv->__lock_message_states);
		}
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gboolean _tmp37_ = 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 _tmp37_;
		}
	}
	result = FALSE;
	return result;
}

static void
dino_plugins_omemo_manager_continue_message_sending (DinoPluginsOmemoManager* self,
                                                     DinoEntitiesAccount* account,
                                                     XmppJid* jid)
{
	GeeHashSet* send_now = NULL;
	GeeHashSet* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	_tmp0_ = gee_hash_set_new (DINO_ENTITIES_TYPE_MESSAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL);
	send_now = _tmp0_;
	{
		GeeMap* _tmp1_;
		_tmp1_ = self->priv->message_states;
		g_rec_mutex_lock (&self->priv->__lock_message_states);
		{
			{
				GeeIterator* _msg_it = NULL;
				GeeMap* _tmp2_;
				GeeSet* _tmp3_;
				GeeSet* _tmp4_;
				GeeSet* _tmp5_;
				GeeIterator* _tmp6_;
				GeeIterator* _tmp7_;
				_tmp2_ = self->priv->message_states;
				_tmp3_ = gee_map_get_keys (_tmp2_);
				_tmp4_ = _tmp3_;
				_tmp5_ = _tmp4_;
				_tmp6_ = gee_iterable_iterator ((GeeIterable*) _tmp5_);
				_tmp7_ = _tmp6_;
				_g_object_unref0 (_tmp5_);
				_msg_it = _tmp7_;
				while (TRUE) {
					GeeIterator* _tmp8_;
					DinoEntitiesMessage* msg = NULL;
					GeeIterator* _tmp9_;
					gpointer _tmp10_;
					DinoEntitiesMessage* _tmp11_;
					DinoEntitiesAccount* _tmp12_;
					DinoEntitiesAccount* _tmp13_;
					GeeList* occupants = NULL;
					DinoEntitiesMessage* _tmp14_;
					XmppJid* _tmp15_;
					XmppJid* _tmp16_;
					XmppJid* _tmp17_;
					XmppJid* _tmp18_;
					XmppJid* _tmp19_;
					GeeList* _tmp20_;
					GeeList* _tmp21_;
					DinoPluginsOmemoManagerMessageState* state = NULL;
					GeeMap* _tmp22_;
					DinoEntitiesMessage* _tmp23_;
					gpointer _tmp24_;
					XmppJid* _tmp25_;
					XmppJid* _tmp26_;
					XmppJid* _tmp27_;
					gboolean _tmp28_;
					DinoPluginsOmemoManagerMessageState* _tmp44_;
					_tmp8_ = _msg_it;
					if (!gee_iterator_next (_tmp8_)) {
						break;
					}
					_tmp9_ = _msg_it;
					_tmp10_ = gee_iterator_get (_tmp9_);
					msg = (DinoEntitiesMessage*) _tmp10_;
					_tmp11_ = msg;
					_tmp12_ = dino_entities_message_get_account (_tmp11_);
					_tmp13_ = _tmp12_;
					if (!dino_entities_account_equals (_tmp13_, account)) {
						_g_object_unref0 (msg);
						continue;
					}
					_tmp14_ = msg;
					_tmp15_ = dino_entities_message_get_counterpart (_tmp14_);
					_tmp16_ = _tmp15_;
					_tmp17_ = xmpp_jid_get_bare_jid (_tmp16_);
					_tmp18_ = _tmp17_;
					_tmp19_ = _tmp18_;
					_tmp20_ = dino_plugins_omemo_manager_get_occupants (self, _tmp19_, account);
					_tmp21_ = _tmp20_;
					_xmpp_jid_unref0 (_tmp19_);
					occupants = _tmp21_;
					_tmp22_ = self->priv->message_states;
					_tmp23_ = msg;
					_tmp24_ = gee_map_get (_tmp22_, _tmp23_);
					state = (DinoPluginsOmemoManagerMessageState*) _tmp24_;
					_tmp25_ = dino_entities_account_get_bare_jid (account);
					_tmp26_ = _tmp25_;
					_tmp27_ = _tmp26_;
					_tmp28_ = xmpp_jid_equals (_tmp27_, jid);
					_xmpp_jid_unref0 (_tmp27_);
					if (_tmp28_) {
						DinoPluginsOmemoManagerMessageState* _tmp29_;
						gint _tmp30_;
						gint _tmp31_;
						_tmp29_ = state;
						_tmp30_ = dino_plugins_omemo_manager_message_state_get_waiting_own_sessions (_tmp29_);
						_tmp31_ = _tmp30_;
						dino_plugins_omemo_manager_message_state_set_waiting_own_sessions (_tmp29_, _tmp31_ - 1);
					} else {
						gboolean _tmp32_ = FALSE;
						DinoEntitiesMessage* _tmp33_;
						XmppJid* _tmp34_;
						XmppJid* _tmp35_;
						_tmp33_ = msg;
						_tmp34_ = dino_entities_message_get_counterpart (_tmp33_);
						_tmp35_ = _tmp34_;
						if (_tmp35_ != NULL) {
							gboolean _tmp36_ = FALSE;
							DinoEntitiesMessage* _tmp37_;
							XmppJid* _tmp38_;
							XmppJid* _tmp39_;
							_tmp37_ = msg;
							_tmp38_ = dino_entities_message_get_counterpart (_tmp37_);
							_tmp39_ = _tmp38_;
							if (xmpp_jid_equals_bare (_tmp39_, jid)) {
								_tmp36_ = TRUE;
							} else {
								GeeList* _tmp40_;
								_tmp40_ = occupants;
								_tmp36_ = gee_collection_contains ((GeeCollection*) _tmp40_, jid);
							}
							_tmp32_ = _tmp36_;
						} else {
							_tmp32_ = FALSE;
						}
						if (_tmp32_) {
							DinoPluginsOmemoManagerMessageState* _tmp41_;
							gint _tmp42_;
							gint _tmp43_;
							_tmp41_ = state;
							_tmp42_ = dino_plugins_omemo_manager_message_state_get_waiting_other_sessions (_tmp41_);
							_tmp43_ = _tmp42_;
							dino_plugins_omemo_manager_message_state_set_waiting_other_sessions (_tmp41_, _tmp43_ - 1);
						}
					}
					_tmp44_ = state;
					if (dino_plugins_omemo_manager_message_state_should_retry_now (_tmp44_)) {
						GeeHashSet* _tmp45_;
						DinoEntitiesMessage* _tmp46_;
						DinoPluginsOmemoManagerMessageState* _tmp47_;
						_tmp45_ = send_now;
						_tmp46_ = msg;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp45_, _tmp46_);
						_tmp47_ = state;
						dino_plugins_omemo_manager_message_state_set_active_send_attempt (_tmp47_, TRUE);
					}
					_dino_plugins_omemo_manager_message_state_unref0 (state);
					_g_object_unref0 (occupants);
					_g_object_unref0 (msg);
				}
				_g_object_unref0 (_msg_it);
			}
		}
		__finally0:
		{
			GeeMap* _tmp48_;
			_tmp48_ = self->priv->message_states;
			g_rec_mutex_unlock (&self->priv->__lock_message_states);
		}
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_object_unref0 (send_now);
			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;
		}
	}
	{
		GeeIterator* _msg_it = NULL;
		GeeHashSet* _tmp49_;
		GeeIterator* _tmp50_;
		_tmp49_ = send_now;
		_tmp50_ = gee_abstract_collection_iterator ((GeeAbstractCollection*) _tmp49_);
		_msg_it = _tmp50_;
		while (TRUE) {
			GeeIterator* _tmp51_;
			DinoEntitiesMessage* msg = NULL;
			GeeIterator* _tmp52_;
			gpointer _tmp53_;
			DinoEntitiesMessage* _tmp54_;
			XmppJid* _tmp55_;
			XmppJid* _tmp56_;
			DinoEntitiesConversation* conv = NULL;
			DinoStreamInteractor* _tmp57_;
			DinoModuleIdentity* _tmp58_;
			gpointer _tmp59_;
			DinoConversationManager* _tmp60_;
			DinoEntitiesMessage* _tmp61_;
			XmppJid* _tmp62_;
			XmppJid* _tmp63_;
			DinoEntitiesConversation* _tmp64_;
			DinoEntitiesConversation* _tmp65_;
			DinoEntitiesConversation* _tmp66_;
			DinoStreamInteractor* _tmp67_;
			DinoModuleIdentity* _tmp68_;
			gpointer _tmp69_;
			DinoMessageProcessor* _tmp70_;
			DinoEntitiesMessage* _tmp71_;
			DinoEntitiesConversation* _tmp72_;
			_tmp51_ = _msg_it;
			if (!gee_iterator_next (_tmp51_)) {
				break;
			}
			_tmp52_ = _msg_it;
			_tmp53_ = gee_iterator_get (_tmp52_);
			msg = (DinoEntitiesMessage*) _tmp53_;
			_tmp54_ = msg;
			_tmp55_ = dino_entities_message_get_counterpart (_tmp54_);
			_tmp56_ = _tmp55_;
			if (_tmp56_ == NULL) {
				_g_object_unref0 (msg);
				continue;
			}
			_tmp57_ = self->priv->stream_interactor;
			_tmp58_ = dino_conversation_manager_IDENTITY;
			_tmp59_ = dino_stream_interactor_get_module (_tmp57_, DINO_TYPE_CONVERSATION_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp58_);
			_tmp60_ = (DinoConversationManager*) _tmp59_;
			_tmp61_ = msg;
			_tmp62_ = dino_entities_message_get_counterpart (_tmp61_);
			_tmp63_ = _tmp62_;
			_tmp64_ = dino_conversation_manager_get_conversation (_tmp60_, G_TYPE_CHECK_INSTANCE_CAST (_tmp63_, XMPP_TYPE_JID, XmppJid), account, NULL);
			_tmp65_ = _tmp64_;
			_g_object_unref0 (_tmp60_);
			conv = _tmp65_;
			_tmp66_ = conv;
			if (_tmp66_ == NULL) {
				_g_object_unref0 (conv);
				_g_object_unref0 (msg);
				continue;
			}
			_tmp67_ = self->priv->stream_interactor;
			_tmp68_ = dino_message_processor_IDENTITY;
			_tmp69_ = dino_stream_interactor_get_module (_tmp67_, DINO_TYPE_MESSAGE_PROCESSOR, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _tmp68_);
			_tmp70_ = (DinoMessageProcessor*) _tmp69_;
			_tmp71_ = msg;
			_tmp72_ = conv;
			dino_message_processor_send_xmpp_message (_tmp70_, _tmp71_, G_TYPE_CHECK_INSTANCE_CAST (_tmp72_, DINO_ENTITIES_TYPE_CONVERSATION, DinoEntitiesConversation), TRUE);
			_g_object_unref0 (_tmp70_);
			_g_object_unref0 (conv);
			_g_object_unref0 (msg);
		}
		_g_object_unref0 (_msg_it);
	}
	_g_object_unref0 (send_now);
}

static void
dino_plugins_omemo_manager_initialize_store_data_free (gpointer _data)
{
	DinoPluginsOmemoManagerInitializeStoreData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOmemoManagerInitializeStoreData, _data_);
}

static void
dino_plugins_omemo_manager_initialize_store (DinoPluginsOmemoManager* self,
                                             DinoEntitiesAccount* account,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	DinoPluginsOmemoManagerInitializeStoreData* _data_;
	DinoPluginsOmemoManager* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_data_ = g_slice_new0 (DinoPluginsOmemoManagerInitializeStoreData);
	_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_manager_initialize_store_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	dino_plugins_omemo_manager_initialize_store_co (_data_);
}

static void
dino_plugins_omemo_manager_initialize_store_finish (DinoPluginsOmemoManager* self,
                                                    GAsyncResult* _res_)
{
	DinoPluginsOmemoManagerInitializeStoreData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		DinoPluginsOmemoManager* self;
		self = _data4_->self;
		_g_object_unref0 (self);
		g_slice_free (Block4Data, _data4_);
	}
}

static void
___lambda24_ (Block4Data* _data4_)
{
	DinoPluginsOmemoManager* self;
	self = _data4_->self;
	dino_plugins_omemo_manager_initialize_store_co (_data4_->_async_data_);
}

static void
____lambda24__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	___lambda24_ (self);
}

static gpointer
_qlite_row_ref0 (gpointer self)
{
	return self ? qlite_row_ref (self) : NULL;
}

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

static guint8*
ec_private_key_serialize_ (ec_private_key* self,
                           gint* result_length1,
                           GError** error)
{
	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_private_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_dup26 (_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 gboolean
dino_plugins_omemo_manager_initialize_store_co (DinoPluginsOmemoManagerInitializeStoreData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_data4_ = g_slice_new0 (Block4Data);
	_data_->_data4_->_ref_count_ = 1;
	_data_->_data4_->self = g_object_ref (_data_->self);
	_data_->_data4_->_async_data_ = _data_;
	_data_->_tmp0_ = dino_entities_account_get_id (_data_->account);
	_data_->_tmp1_ = _data_->_tmp0_;
	if (_data_->_tmp1_ == -1) {
		g_signal_connect_data ((GObject*) _data_->account, "notify::id", (GCallback) ____lambda24__g_object_notify, block4_data_ref (_data_->_data4_), (GClosureNotify) block4_data_unref, 0);
		_data_->_state_ = 1;
		return FALSE;
		_state_1:
		;
	}
	_data_->_tmp2_ = _data_->self->priv->stream_interactor;
	_data_->_tmp3_ = _data_->_tmp2_->module_manager;
	_data_->_tmp4_ = dino_plugins_omemo_stream_module_IDENTITY;
	_data_->_tmp5_ = dino_module_manager_get_module (_data_->_tmp3_, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->account, _data_->_tmp4_);
	_data_->module = (DinoPluginsOmemoStreamModule*) _data_->_tmp5_;
	_data_->_tmp6_ = _data_->module;
	if (_data_->_tmp6_ == NULL) {
		_g_object_unref0 (_data_->module);
		block4_data_unref (_data_->_data4_);
		_data_->_data4_ = NULL;
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp7_ = _data_->module;
	_data_->_tmp8_ = dino_plugins_omemo_stream_module_get_store (_data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	_data_->_tmp10_ = _g_object_ref0 (_data_->_tmp9_);
	_data_->store = _data_->_tmp10_;
	_data_->_tmp11_ = _data_->self->priv->db;
	_data_->_tmp12_ = dino_plugins_omemo_database_get_identity (_data_->_tmp11_);
	_data_->_tmp13_ = _data_->_tmp12_;
	_data_->_tmp14_ = _data_->self->priv->db;
	_data_->_tmp15_ = dino_plugins_omemo_database_get_identity (_data_->_tmp14_);
	_data_->_tmp16_ = _data_->_tmp15_;
	_data_->_tmp17_ = _data_->_tmp16_->account_id;
	_data_->_tmp18_ = dino_entities_account_get_id (_data_->account);
	_data_->_tmp19_ = _data_->_tmp18_;
	_data_->_tmp20_ = qlite_table_row_with ((QliteTable*) _data_->_tmp13_, G_TYPE_INT, NULL, NULL, _data_->_tmp17_, (gpointer) ((gintptr) _data_->_tmp19_));
	_data_->_tmp21_ = _data_->_tmp20_;
	_data_->_tmp22_ = qlite_row_option_get_inner (_data_->_tmp21_);
	_data_->_tmp23_ = _data_->_tmp22_;
	_data_->_tmp24_ = _qlite_row_ref0 (_data_->_tmp23_);
	_data_->_tmp25_ = _data_->_tmp24_;
	_qlite_row_option_unref0 (_data_->_tmp21_);
	_data_->row = _data_->_tmp25_;
	_data_->identity_id = -1;
	_data_->publish_identity = FALSE;
	_data_->_tmp26_ = _data_->row;
	if (_data_->_tmp26_ == NULL) {
		_data_->publish_identity = TRUE;
		{
			_data_->_tmp27_ = _data_->store;
			_data_->_tmp28_ = omemo_store_get_identity_key_store (_data_->_tmp27_);
			_data_->_tmp29_ = _data_->_tmp28_;
			omemo_identity_key_store_set_local_registration_id (_data_->_tmp29_, (guint32) g_random_int_range ((gint32) 1, G_MAXINT32));
			_data_->_tmp30_ = dino_plugins_omemo_plugin_get_context ();
			_data_->_tmp31_ = _data_->_tmp30_;
			_data_->_tmp32_ = omemo_context_generate_key_pair (_data_->_tmp31_, &_data_->_inner_error0_);
			_data_->_tmp33_ = _data_->_tmp32_;
			_omemo_context_unref0 (_data_->_tmp31_);
			_data_->key_pair = _data_->_tmp33_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->_tmp35_ = _data_->key_pair;
			_data_->_tmp36_ = ec_key_pair_get_private (_data_->_tmp35_);
			_data_->_tmp37_ = _data_->_tmp36_;
			_data_->_tmp38_ = 0;
			_data_->_tmp39_ = ec_private_key_serialize_ (_data_->_tmp37_, &_data_->_tmp38_, &_data_->_inner_error0_);
			_data_->_tmp34_ = _data_->_tmp39_;
			_data_->_tmp34__length1 = _data_->_tmp38_;
			_data_->__tmp34__size_ = _data_->_tmp34__length1;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				_signal_type_unref_vapi0 (_data_->key_pair);
				goto __catch0_g_error;
			}
			_data_->_tmp40_ = _data_->store;
			_data_->_tmp41_ = omemo_store_get_identity_key_store (_data_->_tmp40_);
			_data_->_tmp42_ = _data_->_tmp41_;
			_data_->_tmp43_ = g_bytes_new (_data_->_tmp34_, _data_->_tmp34__length1);
			_data_->_tmp44_ = _data_->_tmp43_;
			omemo_identity_key_store_set_identity_key_private (_data_->_tmp42_, _data_->_tmp44_);
			_g_bytes_unref0 (_data_->_tmp44_);
			_data_->_tmp45_ = _data_->store;
			_data_->_tmp46_ = omemo_store_get_identity_key_store (_data_->_tmp45_);
			_data_->_tmp47_ = _data_->_tmp46_;
			_data_->_tmp48_ = _data_->key_pair;
			_data_->_tmp49_ = ec_key_pair_get_public (_data_->_tmp48_);
			_data_->_tmp50_ = _data_->_tmp49_;
			_data_->_tmp51_ = 0;
			_data_->_tmp52_ = ec_public_key_serialize_ (_data_->_tmp50_, &_data_->_tmp51_);
			_data_->_tmp53_ = _data_->_tmp52_;
			_data_->_tmp53__length1 = _data_->_tmp51_;
			_data_->_tmp54_ = g_bytes_new (_data_->_tmp53_, _data_->_tmp51_);
			_data_->_tmp55_ = _data_->_tmp54_;
			omemo_identity_key_store_set_identity_key_public (_data_->_tmp47_, _data_->_tmp55_);
			_g_bytes_unref0 (_data_->_tmp55_);
			_data_->_tmp53_ = (g_free (_data_->_tmp53_), NULL);
			_data_->_tmp56_ = _data_->self->priv->db;
			_data_->_tmp57_ = dino_plugins_omemo_database_get_identity (_data_->_tmp56_);
			_data_->_tmp58_ = _data_->_tmp57_;
			_data_->_tmp59_ = qlite_table_upsert ((QliteTable*) _data_->_tmp58_);
			_data_->_tmp60_ = _data_->_tmp59_;
			_data_->_tmp61_ = _data_->self->priv->db;
			_data_->_tmp62_ = dino_plugins_omemo_database_get_identity (_data_->_tmp61_);
			_data_->_tmp63_ = _data_->_tmp62_;
			_data_->_tmp64_ = _data_->_tmp63_->account_id;
			_data_->_tmp65_ = dino_entities_account_get_id (_data_->account);
			_data_->_tmp66_ = _data_->_tmp65_;
			_data_->_tmp67_ = qlite_upsert_builder_value (_data_->_tmp60_, G_TYPE_INT, NULL, NULL, _data_->_tmp64_, (gpointer) ((gintptr) _data_->_tmp66_), TRUE);
			_data_->_tmp68_ = _data_->_tmp67_;
			_data_->_tmp69_ = _data_->self->priv->db;
			_data_->_tmp70_ = dino_plugins_omemo_database_get_identity (_data_->_tmp69_);
			_data_->_tmp71_ = _data_->_tmp70_;
			_data_->_tmp72_ = _data_->_tmp71_->device_id;
			_data_->_tmp73_ = _data_->store;
			_data_->_tmp74_ = omemo_store_get_local_registration_id (_data_->_tmp73_);
			_data_->_tmp75_ = _data_->_tmp74_;
			_data_->_tmp76_ = qlite_upsert_builder_value (_data_->_tmp68_, G_TYPE_INT, NULL, NULL, _data_->_tmp72_, (gpointer) ((gintptr) _data_->_tmp75_), FALSE);
			_data_->_tmp77_ = _data_->_tmp76_;
			_data_->_tmp78_ = _data_->self->priv->db;
			_data_->_tmp79_ = dino_plugins_omemo_database_get_identity (_data_->_tmp78_);
			_data_->_tmp80_ = _data_->_tmp79_;
			_data_->_tmp81_ = _data_->_tmp80_->identity_key_private_base64;
			_data_->_tmp82_ = _data_->store;
			_data_->_tmp83_ = omemo_store_get_identity_key_store (_data_->_tmp82_);
			_data_->_tmp84_ = _data_->_tmp83_;
			_data_->_tmp85_ = omemo_identity_key_store_get_identity_key_private (_data_->_tmp84_);
			_data_->_tmp86_ = _data_->_tmp85_;
			_data_->_tmp87_ = 0;
			_data_->_tmp88_ = g_bytes_get_data (_data_->_tmp86_, &_data_->_tmp87_);
			_data_->_tmp89_ = g_base64_encode (_data_->_tmp88_, (gint) _data_->_tmp87_);
			_data_->_tmp90_ = _data_->_tmp89_;
			_data_->_tmp91_ = qlite_upsert_builder_value (_data_->_tmp77_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp81_, _data_->_tmp90_, FALSE);
			_data_->_tmp92_ = _data_->_tmp91_;
			_data_->_tmp93_ = _data_->self->priv->db;
			_data_->_tmp94_ = dino_plugins_omemo_database_get_identity (_data_->_tmp93_);
			_data_->_tmp95_ = _data_->_tmp94_;
			_data_->_tmp96_ = _data_->_tmp95_->identity_key_public_base64;
			_data_->_tmp97_ = _data_->store;
			_data_->_tmp98_ = omemo_store_get_identity_key_store (_data_->_tmp97_);
			_data_->_tmp99_ = _data_->_tmp98_;
			_data_->_tmp100_ = omemo_identity_key_store_get_identity_key_public (_data_->_tmp99_);
			_data_->_tmp101_ = _data_->_tmp100_;
			_data_->_tmp102_ = 0;
			_data_->_tmp103_ = g_bytes_get_data (_data_->_tmp101_, &_data_->_tmp102_);
			_data_->_tmp104_ = g_base64_encode (_data_->_tmp103_, (gint) _data_->_tmp102_);
			_data_->_tmp105_ = _data_->_tmp104_;
			_data_->_tmp106_ = qlite_upsert_builder_value (_data_->_tmp92_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp96_, _data_->_tmp105_, FALSE);
			_data_->_tmp107_ = _data_->_tmp106_;
			_data_->identity_id = (gint) qlite_upsert_builder_perform (_data_->_tmp107_);
			_qlite_statement_builder_unref0 (_data_->_tmp107_);
			_g_free0 (_data_->_tmp105_);
			_qlite_statement_builder_unref0 (_data_->_tmp92_);
			_g_free0 (_data_->_tmp90_);
			_qlite_statement_builder_unref0 (_data_->_tmp77_);
			_qlite_statement_builder_unref0 (_data_->_tmp68_);
			_qlite_statement_builder_unref0 (_data_->_tmp60_);
			_data_->_tmp34_ = (g_free (_data_->_tmp34_), NULL);
			_signal_type_unref_vapi0 (_data_->key_pair);
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_data_->_inner_error0_);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_qlite_row_unref0 (_data_->row);
			_g_object_unref0 (_data_->store);
			_g_object_unref0 (_data_->module);
			block4_data_unref (_data_->_data4_);
			_data_->_data4_ = NULL;
			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;
		}
	} else {
		_data_->_tmp108_ = _data_->store;
		_data_->_tmp109_ = omemo_store_get_identity_key_store (_data_->_tmp108_);
		_data_->_tmp110_ = _data_->_tmp109_;
		_data_->_tmp111_ = _data_->row;
		_data_->_tmp112_ = _data_->self->priv->db;
		_data_->_tmp113_ = dino_plugins_omemo_database_get_identity (_data_->_tmp112_);
		_data_->_tmp114_ = _data_->_tmp113_;
		_data_->_tmp115_ = _data_->_tmp114_->device_id;
		_data_->_tmp116_ = qlite_row_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp111_, QLITE_TYPE_ROW, QliteRow), G_TYPE_INT, NULL, NULL, _data_->_tmp115_);
		omemo_identity_key_store_set_local_registration_id (_data_->_tmp110_, (guint32) ((gint) ((gintptr) _data_->_tmp116_)));
		_data_->_tmp117_ = _data_->store;
		_data_->_tmp118_ = omemo_store_get_identity_key_store (_data_->_tmp117_);
		_data_->_tmp119_ = _data_->_tmp118_;
		_data_->_tmp120_ = _data_->row;
		_data_->_tmp121_ = _data_->self->priv->db;
		_data_->_tmp122_ = dino_plugins_omemo_database_get_identity (_data_->_tmp121_);
		_data_->_tmp123_ = _data_->_tmp122_;
		_data_->_tmp124_ = _data_->_tmp123_->identity_key_private_base64;
		_data_->_tmp125_ = qlite_row_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp120_, QLITE_TYPE_ROW, QliteRow), G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp124_);
		_data_->_tmp126_ = (gchar*) _data_->_tmp125_;
		_data_->_tmp127_ = 0;
		_data_->_tmp128_ = g_base64_decode (_data_->_tmp126_, &_data_->_tmp127_);
		_data_->_tmp129_ = _data_->_tmp128_;
		_data_->_tmp129__length1 = _data_->_tmp127_;
		_data_->_tmp130_ = g_bytes_new (_data_->_tmp129_, _data_->_tmp127_);
		_data_->_tmp131_ = _data_->_tmp130_;
		omemo_identity_key_store_set_identity_key_private (_data_->_tmp119_, _data_->_tmp131_);
		_g_bytes_unref0 (_data_->_tmp131_);
		_data_->_tmp129_ = (g_free (_data_->_tmp129_), NULL);
		_g_free0 (_data_->_tmp126_);
		_data_->_tmp132_ = _data_->store;
		_data_->_tmp133_ = omemo_store_get_identity_key_store (_data_->_tmp132_);
		_data_->_tmp134_ = _data_->_tmp133_;
		_data_->_tmp135_ = _data_->row;
		_data_->_tmp136_ = _data_->self->priv->db;
		_data_->_tmp137_ = dino_plugins_omemo_database_get_identity (_data_->_tmp136_);
		_data_->_tmp138_ = _data_->_tmp137_;
		_data_->_tmp139_ = _data_->_tmp138_->identity_key_public_base64;
		_data_->_tmp140_ = qlite_row_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp135_, QLITE_TYPE_ROW, QliteRow), G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _data_->_tmp139_);
		_data_->_tmp141_ = (gchar*) _data_->_tmp140_;
		_data_->_tmp142_ = 0;
		_data_->_tmp143_ = g_base64_decode (_data_->_tmp141_, &_data_->_tmp142_);
		_data_->_tmp144_ = _data_->_tmp143_;
		_data_->_tmp144__length1 = _data_->_tmp142_;
		_data_->_tmp145_ = g_bytes_new (_data_->_tmp144_, _data_->_tmp142_);
		_data_->_tmp146_ = _data_->_tmp145_;
		omemo_identity_key_store_set_identity_key_public (_data_->_tmp134_, _data_->_tmp146_);
		_g_bytes_unref0 (_data_->_tmp146_);
		_data_->_tmp144_ = (g_free (_data_->_tmp144_), NULL);
		_g_free0 (_data_->_tmp141_);
		_data_->_tmp147_ = _data_->row;
		_data_->_tmp148_ = _data_->self->priv->db;
		_data_->_tmp149_ = dino_plugins_omemo_database_get_identity (_data_->_tmp148_);
		_data_->_tmp150_ = _data_->_tmp149_;
		_data_->_tmp151_ = _data_->_tmp150_->id;
		_data_->_tmp152_ = qlite_row_get (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp147_, QLITE_TYPE_ROW, QliteRow), G_TYPE_INT, NULL, NULL, _data_->_tmp151_);
		_data_->identity_id = (gint) ((gintptr) _data_->_tmp152_);
	}
	if (_data_->identity_id >= 0) {
		_data_->_tmp153_ = _data_->store;
		_data_->_tmp154_ = _data_->self->priv->db;
		_data_->_tmp155_ = dino_plugins_omemo_backed_signed_pre_key_store_new (_data_->_tmp154_, _data_->identity_id);
		_data_->_tmp156_ = _data_->_tmp155_;
		omemo_store_set_signed_pre_key_store (_data_->_tmp153_, (OmemoSignedPreKeyStore*) _data_->_tmp156_);
		_g_object_unref0 (_data_->_tmp156_);
		_data_->_tmp157_ = _data_->store;
		_data_->_tmp158_ = _data_->self->priv->db;
		_data_->_tmp159_ = dino_plugins_omemo_backed_pre_key_store_new (_data_->_tmp158_, _data_->identity_id);
		_data_->_tmp160_ = _data_->_tmp159_;
		omemo_store_set_pre_key_store (_data_->_tmp157_, (OmemoPreKeyStore*) _data_->_tmp160_);
		_g_object_unref0 (_data_->_tmp160_);
		_data_->_tmp161_ = _data_->store;
		_data_->_tmp162_ = _data_->self->priv->db;
		_data_->_tmp163_ = dino_plugins_omemo_backed_session_store_new (_data_->_tmp162_, _data_->identity_id);
		_data_->_tmp164_ = _data_->_tmp163_;
		omemo_store_set_session_store (_data_->_tmp161_, (OmemoSessionStore*) _data_->_tmp164_);
		_g_object_unref0 (_data_->_tmp164_);
	} else {
		_data_->_tmp165_ = dino_entities_account_get_bare_jid (_data_->account);
		_data_->_tmp166_ = _data_->_tmp165_;
		_data_->_tmp167_ = _data_->_tmp166_;
		_data_->_tmp168_ = xmpp_jid_to_string (_data_->_tmp167_);
		_data_->_tmp169_ = _data_->_tmp168_;
		g_warning ("manager.vala:389: store for %s is not persisted!", _data_->_tmp169_);
		_g_free0 (_data_->_tmp169_);
		_xmpp_jid_unref0 (_data_->_tmp167_);
	}
	_data_->_tmp170_ = _data_->self->priv->stream_interactor;
	_data_->_tmp171_ = dino_stream_interactor_get_stream (_data_->_tmp170_, _data_->account);
	_data_->stream = _data_->_tmp171_;
	_data_->_tmp172_ = _data_->stream;
	if (_data_->_tmp172_ != NULL) {
		_data_->_tmp173_ = _data_->module;
		_data_->_tmp174_ = _data_->stream;
		_data_->_tmp175_ = dino_entities_account_get_bare_jid (_data_->account);
		_data_->_tmp176_ = _data_->_tmp175_;
		_data_->_tmp177_ = _data_->_tmp176_;
		dino_plugins_omemo_stream_module_request_user_devicelist (_data_->_tmp173_, G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp174_, XMPP_TYPE_XMPP_STREAM, XmppXmppStream), _data_->_tmp177_, NULL, NULL);
		_xmpp_jid_unref0 (_data_->_tmp177_);
	}
	_g_object_unref0 (_data_->stream);
	_qlite_row_unref0 (_data_->row);
	_g_object_unref0 (_data_->store);
	_g_object_unref0 (_data_->module);
	block4_data_unref (_data_->_data4_);
	_data_->_data4_ = NULL;
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dino_plugins_omemo_manager_ensure_get_keys_for_conversation_data_free (gpointer _data)
{
	DinoPluginsOmemoManagerEnsureGetKeysForConversationData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->conversation);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOmemoManagerEnsureGetKeysForConversationData, _data_);
}

void
dino_plugins_omemo_manager_ensure_get_keys_for_conversation (DinoPluginsOmemoManager* self,
                                                             DinoEntitiesConversation* conversation,
                                                             GAsyncReadyCallback _callback_,
                                                             gpointer _user_data_)
{
	DinoPluginsOmemoManagerEnsureGetKeysForConversationData* _data_;
	DinoPluginsOmemoManager* _tmp0_;
	DinoEntitiesConversation* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (conversation != NULL);
	_data_ = g_slice_new0 (DinoPluginsOmemoManagerEnsureGetKeysForConversationData);
	_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_manager_ensure_get_keys_for_conversation_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (conversation);
	_g_object_unref0 (_data_->conversation);
	_data_->conversation = _tmp1_;
	dino_plugins_omemo_manager_ensure_get_keys_for_conversation_co (_data_);
}

gboolean
dino_plugins_omemo_manager_ensure_get_keys_for_conversation_finish (DinoPluginsOmemoManager* self,
                                                                    GAsyncResult* _res_)
{
	gboolean result;
	DinoPluginsOmemoManagerEnsureGetKeysForConversationData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
dino_plugins_omemo_manager_ensure_get_keys_for_conversation_ready (GObject* source_object,
                                                                   GAsyncResult* _res_,
                                                                   gpointer _user_data_)
{
	DinoPluginsOmemoManagerEnsureGetKeysForConversationData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_omemo_manager_ensure_get_keys_for_conversation_co (_data_);
}

static gboolean
dino_plugins_omemo_manager_ensure_get_keys_for_conversation_co (DinoPluginsOmemoManagerEnsureGetKeysForConversationData* _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_ = _data_->self->priv->stream_interactor;
	_data_->_tmp1_ = dino_muc_manager_IDENTITY;
	_data_->_tmp2_ = dino_stream_interactor_get_module (_data_->_tmp0_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp1_);
	_data_->_tmp3_ = (DinoMucManager*) _data_->_tmp2_;
	_data_->_tmp4_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp5_ = _data_->_tmp4_;
	_data_->_tmp6_ = dino_entities_conversation_get_counterpart (_data_->conversation);
	_data_->_tmp7_ = _data_->_tmp6_;
	_data_->_tmp8_ = dino_muc_manager_is_private_room (_data_->_tmp3_, _data_->_tmp5_, _data_->_tmp7_);
	_g_object_unref0 (_data_->_tmp3_);
	if (_data_->_tmp8_) {
		{
			_data_->_tmp9_ = _data_->self->priv->stream_interactor;
			_data_->_tmp10_ = dino_muc_manager_IDENTITY;
			_data_->_tmp11_ = dino_stream_interactor_get_module (_data_->_tmp9_, DINO_TYPE_MUC_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->_tmp10_);
			_data_->_tmp12_ = (DinoMucManager*) _data_->_tmp11_;
			_data_->_tmp13_ = dino_entities_conversation_get_counterpart (_data_->conversation);
			_data_->_tmp14_ = _data_->_tmp13_;
			_data_->_tmp15_ = dino_entities_conversation_get_account (_data_->conversation);
			_data_->_tmp16_ = _data_->_tmp15_;
			_data_->_tmp17_ = dino_muc_manager_get_offline_members (_data_->_tmp12_, _data_->_tmp14_, _data_->_tmp16_);
			_data_->_tmp18_ = _data_->_tmp17_;
			_g_object_unref0 (_data_->_tmp12_);
			_data_->_offline_member_list = _data_->_tmp18_;
			_data_->_tmp19_ = _data_->_offline_member_list;
			_data_->_tmp20_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp19_);
			_data_->_tmp21_ = _data_->_tmp20_;
			_data_->_offline_member_size = _data_->_tmp21_;
			_data_->_offline_member_index = -1;
			while (TRUE) {
				_data_->_offline_member_index = _data_->_offline_member_index + 1;
				_data_->_tmp22_ = _data_->_offline_member_index;
				_data_->_tmp23_ = _data_->_offline_member_size;
				if (!(_data_->_tmp22_ < _data_->_tmp23_)) {
					break;
				}
				_data_->_tmp24_ = _data_->_offline_member_list;
				_data_->_tmp25_ = gee_list_get (_data_->_tmp24_, _data_->_offline_member_index);
				_data_->offline_member = (XmppJid*) _data_->_tmp25_;
				_data_->_tmp26_ = dino_entities_conversation_get_account (_data_->conversation);
				_data_->_tmp27_ = _data_->_tmp26_;
				_data_->_tmp28_ = _data_->offline_member;
				_data_->_state_ = 1;
				dino_plugins_omemo_manager_ensure_get_keys_for_jid (_data_->self, _data_->_tmp27_, _data_->_tmp28_, dino_plugins_omemo_manager_ensure_get_keys_for_conversation_ready, _data_);
				return FALSE;
				_state_1:
				_data_->ok = dino_plugins_omemo_manager_ensure_get_keys_for_jid_finish (_data_->self, _data_->_res_);
				if (!_data_->ok) {
					_data_->result = FALSE;
					_xmpp_jid_unref0 (_data_->offline_member);
					_g_object_unref0 (_data_->_offline_member_list);
					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;
				}
				_xmpp_jid_unref0 (_data_->offline_member);
			}
			_g_object_unref0 (_data_->_offline_member_list);
		}
		_data_->result = TRUE;
		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_->_tmp29_ = dino_entities_conversation_get_account (_data_->conversation);
	_data_->_tmp30_ = _data_->_tmp29_;
	_data_->_tmp31_ = dino_entities_conversation_get_counterpart (_data_->conversation);
	_data_->_tmp32_ = _data_->_tmp31_;
	_data_->_tmp33_ = xmpp_jid_get_bare_jid (_data_->_tmp32_);
	_data_->_tmp34_ = _data_->_tmp33_;
	_data_->_tmp35_ = _data_->_tmp34_;
	_data_->_state_ = 2;
	dino_plugins_omemo_manager_ensure_get_keys_for_jid (_data_->self, _data_->_tmp30_, _data_->_tmp35_, dino_plugins_omemo_manager_ensure_get_keys_for_conversation_ready, _data_);
	return FALSE;
	_state_2:
	_data_->_tmp36_ = dino_plugins_omemo_manager_ensure_get_keys_for_jid_finish (_data_->self, _data_->_res_);
	_xmpp_jid_unref0 (_data_->_tmp35_);
	_data_->result = _data_->_tmp36_;
	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_manager_ensure_get_keys_for_jid_data_free (gpointer _data)
{
	DinoPluginsOmemoManagerEnsureGetKeysForJidData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->account);
	_xmpp_jid_unref0 (_data_->jid);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoPluginsOmemoManagerEnsureGetKeysForJidData, _data_);
}

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

void
dino_plugins_omemo_manager_ensure_get_keys_for_jid (DinoPluginsOmemoManager* self,
                                                    DinoEntitiesAccount* account,
                                                    XmppJid* jid,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_)
{
	DinoPluginsOmemoManagerEnsureGetKeysForJidData* _data_;
	DinoPluginsOmemoManager* _tmp0_;
	DinoEntitiesAccount* _tmp1_;
	XmppJid* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (jid != NULL);
	_data_ = g_slice_new0 (DinoPluginsOmemoManagerEnsureGetKeysForJidData);
	_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_manager_ensure_get_keys_for_jid_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (account);
	_g_object_unref0 (_data_->account);
	_data_->account = _tmp1_;
	_tmp2_ = _xmpp_jid_ref0 (jid);
	_xmpp_jid_unref0 (_data_->jid);
	_data_->jid = _tmp2_;
	dino_plugins_omemo_manager_ensure_get_keys_for_jid_co (_data_);
}

gboolean
dino_plugins_omemo_manager_ensure_get_keys_for_jid_finish (DinoPluginsOmemoManager* self,
                                                           GAsyncResult* _res_)
{
	gboolean result;
	DinoPluginsOmemoManagerEnsureGetKeysForJidData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
	result = _data_->result;
	return result;
}

static void
dino_plugins_omemo_manager_ensure_get_keys_for_jid_ready (GObject* source_object,
                                                          GAsyncResult* _res_,
                                                          gpointer _user_data_)
{
	DinoPluginsOmemoManagerEnsureGetKeysForJidData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dino_plugins_omemo_manager_ensure_get_keys_for_jid_co (_data_);
}

static gboolean
dino_plugins_omemo_manager_ensure_get_keys_for_jid_co (DinoPluginsOmemoManagerEnsureGetKeysForJidData* _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->trust_manager;
	if (dino_plugins_omemo_trust_manager_is_known_address (_data_->_tmp0_, _data_->account, _data_->jid)) {
		_data_->result = TRUE;
		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_->_tmp1_ = _data_->self->priv->stream_interactor;
	_data_->_tmp2_ = dino_stream_interactor_get_stream (_data_->_tmp1_, _data_->account);
	_data_->stream = _data_->_tmp2_;
	_data_->_tmp3_ = _data_->stream;
	if (_data_->_tmp3_ != NULL) {
		_data_->_tmp4_ = _data_->self->priv->stream_interactor;
		_data_->_tmp5_ = _data_->_tmp4_->module_manager;
		_data_->_tmp6_ = dino_plugins_omemo_stream_module_IDENTITY;
		_data_->_tmp7_ = dino_module_manager_get_module (_data_->_tmp5_, DINO_PLUGINS_OMEMO_TYPE_STREAM_MODULE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, _data_->account, _data_->_tmp6_);
		_data_->_tmp8_ = (DinoPluginsOmemoStreamModule*) _data_->_tmp7_;
		_data_->_tmp9_ = _data_->stream;
		_data_->_state_ = 1;
		dino_plugins_omemo_stream_module_request_user_devicelist (_data_->_tmp8_, _data_->_tmp9_, _data_->jid, dino_plugins_omemo_manager_ensure_get_keys_for_jid_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp10_ = dino_plugins_omemo_stream_module_request_user_devicelist_finish (_data_->_tmp8_, _data_->_res_);
		_data_->_tmp11_ = _data_->_tmp10_;
		_g_object_unref0 (_data_->_tmp8_);
		_data_->device_list = _data_->_tmp11_;
		_data_->_tmp12_ = _data_->device_list;
		_data_->_tmp13_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _data_->_tmp12_);
		_data_->_tmp14_ = _data_->_tmp13_;
		_data_->result = _data_->_tmp14_ > 0;
		_g_object_unref0 (_data_->device_list);
		_g_object_unref0 (_data_->stream);
		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_->result = TRUE;
	_g_object_unref0 (_data_->stream);
	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;
}

void
dino_plugins_omemo_manager_start (DinoStreamInteractor* stream_interactor,
                                  DinoPluginsOmemoDatabase* db,
                                  DinoPluginsOmemoTrustManager* trust_manager,
                                  GeeHashMap* encryptors)
{
	DinoPluginsOmemoManager* m = NULL;
	DinoPluginsOmemoManager* _tmp0_;
	g_return_if_fail (stream_interactor != NULL);
	g_return_if_fail (db != NULL);
	g_return_if_fail (trust_manager != NULL);
	g_return_if_fail (encryptors != NULL);
	_tmp0_ = dino_plugins_omemo_manager_new (stream_interactor, db, trust_manager, encryptors);
	m = _tmp0_;
	dino_stream_interactor_add_module (stream_interactor, (DinoStreamInteractionModule*) m);
	_g_object_unref0 (m);
}

static const gchar*
dino_plugins_omemo_manager_real_get_id (DinoStreamInteractionModule* base)
{
	const gchar* result;
	DinoPluginsOmemoManager* self;
	DinoModuleIdentity* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	self = (DinoPluginsOmemoManager*) base;
	_tmp0_ = dino_plugins_omemo_manager_IDENTITY;
	_tmp1_ = dino_module_identity_get_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

static inline gpointer
dino_plugins_omemo_manager_message_state_get_instance_private (DinoPluginsOmemoManagerMessageState* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsOmemoManagerMessageState_private_offset);
}

static DinoPluginsOmemoManagerMessageState*
dino_plugins_omemo_manager_message_state_construct (GType object_type,
                                                    DinoEntitiesMessage* msg,
                                                    XmppXepOmemoEncryptState* last_try)
{
	DinoPluginsOmemoManagerMessageState* self = NULL;
	g_return_val_if_fail (msg != NULL, NULL);
	g_return_val_if_fail (last_try != NULL, NULL);
	self = (DinoPluginsOmemoManagerMessageState*) g_type_create_instance (object_type);
	dino_plugins_omemo_manager_message_state_update_from_encrypt_status (self, msg, last_try);
	return self;
}

static DinoPluginsOmemoManagerMessageState*
dino_plugins_omemo_manager_message_state_new (DinoEntitiesMessage* msg,
                                              XmppXepOmemoEncryptState* last_try)
{
	return dino_plugins_omemo_manager_message_state_construct (DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE, msg, last_try);
}

static void
dino_plugins_omemo_manager_message_state_update_from_encrypt_status (DinoPluginsOmemoManagerMessageState* self,
                                                                     DinoEntitiesMessage* msg,
                                                                     XmppXepOmemoEncryptState* new_try)
{
	gint _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	gboolean _tmp8_ = FALSE;
	gint _tmp9_;
	gint _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (msg != NULL);
	g_return_if_fail (new_try != NULL);
	dino_plugins_omemo_manager_message_state_set_msg (self, msg);
	dino_plugins_omemo_manager_message_state_set_last_try (self, new_try);
	_tmp0_ = xmpp_xep_omemo_encrypt_state_get_other_unknown (new_try);
	_tmp1_ = _tmp0_;
	dino_plugins_omemo_manager_message_state_set_waiting_other_sessions (self, _tmp1_);
	_tmp2_ = xmpp_xep_omemo_encrypt_state_get_own_unknown (new_try);
	_tmp3_ = _tmp2_;
	dino_plugins_omemo_manager_message_state_set_waiting_own_sessions (self, _tmp3_);
	_tmp4_ = xmpp_xep_omemo_encrypt_state_get_own_list (new_try);
	_tmp5_ = _tmp4_;
	dino_plugins_omemo_manager_message_state_set_waiting_own_devicelist (self, !_tmp5_);
	_tmp6_ = xmpp_xep_omemo_encrypt_state_get_other_waiting_lists (new_try);
	_tmp7_ = _tmp6_;
	dino_plugins_omemo_manager_message_state_set_waiting_other_devicelists (self, _tmp7_);
	dino_plugins_omemo_manager_message_state_set_active_send_attempt (self, FALSE);
	dino_plugins_omemo_manager_message_state_set_will_send_now (self, FALSE);
	_tmp9_ = xmpp_xep_omemo_encrypt_state_get_other_failure (new_try);
	_tmp10_ = _tmp9_;
	if (_tmp10_ > 0) {
		_tmp8_ = TRUE;
	} else {
		gboolean _tmp11_ = FALSE;
		gint _tmp12_;
		gint _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		_tmp12_ = xmpp_xep_omemo_encrypt_state_get_other_lost (new_try);
		_tmp13_ = _tmp12_;
		_tmp14_ = xmpp_xep_omemo_encrypt_state_get_other_devices (new_try);
		_tmp15_ = _tmp14_;
		if (_tmp13_ == _tmp15_) {
			gint _tmp16_;
			gint _tmp17_;
			_tmp16_ = xmpp_xep_omemo_encrypt_state_get_other_devices (new_try);
			_tmp17_ = _tmp16_;
			_tmp11_ = _tmp17_ > 0;
		} else {
			_tmp11_ = FALSE;
		}
		_tmp8_ = _tmp11_;
	}
	if (_tmp8_) {
		dino_entities_message_set_marked (msg, DINO_ENTITIES_MESSAGE_MARKED_WONTSEND);
	} else {
		gboolean _tmp18_ = FALSE;
		gboolean _tmp19_ = FALSE;
		gboolean _tmp20_ = FALSE;
		gboolean _tmp21_ = FALSE;
		gint _tmp22_;
		gint _tmp23_;
		_tmp22_ = xmpp_xep_omemo_encrypt_state_get_other_unknown (new_try);
		_tmp23_ = _tmp22_;
		if (_tmp23_ > 0) {
			_tmp21_ = TRUE;
		} else {
			gint _tmp24_;
			gint _tmp25_;
			_tmp24_ = xmpp_xep_omemo_encrypt_state_get_own_unknown (new_try);
			_tmp25_ = _tmp24_;
			_tmp21_ = _tmp25_ > 0;
		}
		if (_tmp21_) {
			_tmp20_ = TRUE;
		} else {
			gint _tmp26_;
			gint _tmp27_;
			_tmp26_ = xmpp_xep_omemo_encrypt_state_get_other_waiting_lists (new_try);
			_tmp27_ = _tmp26_;
			_tmp20_ = _tmp27_ > 0;
		}
		if (_tmp20_) {
			_tmp19_ = TRUE;
		} else {
			gboolean _tmp28_;
			gboolean _tmp29_;
			_tmp28_ = xmpp_xep_omemo_encrypt_state_get_own_list (new_try);
			_tmp29_ = _tmp28_;
			_tmp19_ = !_tmp29_;
		}
		if (_tmp19_) {
			_tmp18_ = TRUE;
		} else {
			gint _tmp30_;
			gint _tmp31_;
			_tmp30_ = xmpp_xep_omemo_encrypt_state_get_own_devices (new_try);
			_tmp31_ = _tmp30_;
			_tmp18_ = _tmp31_ == 0;
		}
		if (_tmp18_) {
			dino_entities_message_set_marked (msg, DINO_ENTITIES_MESSAGE_MARKED_UNSENT);
		} else {
			gboolean _tmp32_;
			gboolean _tmp33_;
			_tmp32_ = xmpp_xep_omemo_encrypt_state_get_encrypted (new_try);
			_tmp33_ = _tmp32_;
			if (!_tmp33_) {
				dino_entities_message_set_marked (msg, DINO_ENTITIES_MESSAGE_MARKED_WONTSEND);
			} else {
				dino_plugins_omemo_manager_message_state_set_will_send_now (self, TRUE);
			}
		}
	}
}

static gboolean
dino_plugins_omemo_manager_message_state_should_retry_now (DinoPluginsOmemoManagerMessageState* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp4_ = self->priv->_waiting_own_devicelist;
	if (!_tmp4_) {
		gint _tmp5_;
		_tmp5_ = self->priv->_waiting_other_devicelists;
		_tmp3_ = _tmp5_ <= 0;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		gint _tmp6_;
		_tmp6_ = self->priv->_waiting_other_sessions;
		_tmp2_ = _tmp6_ <= 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		gint _tmp7_;
		_tmp7_ = self->priv->_waiting_own_sessions;
		_tmp1_ = _tmp7_ <= 0;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gboolean _tmp8_;
		_tmp8_ = self->priv->_active_send_attempt;
		_tmp0_ = !_tmp8_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

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 gchar*
bool_to_string (gboolean self)
{
	gchar* result;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}

static gchar*
dino_plugins_omemo_manager_message_state_to_string (DinoPluginsOmemoManagerMessageState* self)
{
	DinoEntitiesMessage* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gboolean _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	XmppXepOmemoEncryptState* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_msg;
	_tmp1_ = dino_entities_message_get_stanza_id (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_to_string (_tmp2_);
	_tmp4_ = self->priv->_will_send_now;
	_tmp5_ = bool_to_string (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = self->priv->_last_try;
	_tmp8_ = xmpp_xep_omemo_encrypt_state_to_string (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = g_strconcat ("MessageState (msg=", _tmp3_, ", send=", _tmp6_, ", ", _tmp9_, ")", NULL);
	_tmp11_ = _tmp10_;
	_g_free0 (_tmp9_);
	_g_free0 (_tmp6_);
	result = _tmp11_;
	return result;
}

static DinoEntitiesMessage*
dino_plugins_omemo_manager_message_state_get_msg (DinoPluginsOmemoManagerMessageState* self)
{
	DinoEntitiesMessage* result;
	DinoEntitiesMessage* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_msg;
	result = _tmp0_;
	return result;
}

static void
dino_plugins_omemo_manager_message_state_set_msg (DinoPluginsOmemoManagerMessageState* self,
                                                  DinoEntitiesMessage* value)
{
	DinoEntitiesMessage* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_msg);
	self->priv->_msg = _tmp0_;
}

static XmppXepOmemoEncryptState*
dino_plugins_omemo_manager_message_state_get_last_try (DinoPluginsOmemoManagerMessageState* self)
{
	XmppXepOmemoEncryptState* result;
	XmppXepOmemoEncryptState* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_last_try;
	result = _tmp0_;
	return result;
}

static gpointer
_xmpp_xep_omemo_encrypt_state_ref0 (gpointer self)
{
	return self ? xmpp_xep_omemo_encrypt_state_ref (self) : NULL;
}

static void
dino_plugins_omemo_manager_message_state_set_last_try (DinoPluginsOmemoManagerMessageState* self,
                                                       XmppXepOmemoEncryptState* value)
{
	XmppXepOmemoEncryptState* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _xmpp_xep_omemo_encrypt_state_ref0 (value);
	_xmpp_xep_omemo_encrypt_state_unref0 (self->priv->_last_try);
	self->priv->_last_try = _tmp0_;
}

static gint
dino_plugins_omemo_manager_message_state_get_waiting_other_sessions (DinoPluginsOmemoManagerMessageState* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_waiting_other_sessions;
	return result;
}

static void
dino_plugins_omemo_manager_message_state_set_waiting_other_sessions (DinoPluginsOmemoManagerMessageState* self,
                                                                     gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_waiting_other_sessions = value;
}

static gint
dino_plugins_omemo_manager_message_state_get_waiting_own_sessions (DinoPluginsOmemoManagerMessageState* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_waiting_own_sessions;
	return result;
}

static void
dino_plugins_omemo_manager_message_state_set_waiting_own_sessions (DinoPluginsOmemoManagerMessageState* self,
                                                                   gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_waiting_own_sessions = value;
}

static gboolean
dino_plugins_omemo_manager_message_state_get_waiting_own_devicelist (DinoPluginsOmemoManagerMessageState* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_waiting_own_devicelist;
	return result;
}

static void
dino_plugins_omemo_manager_message_state_set_waiting_own_devicelist (DinoPluginsOmemoManagerMessageState* self,
                                                                     gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_waiting_own_devicelist = value;
}

static gint
dino_plugins_omemo_manager_message_state_get_waiting_other_devicelists (DinoPluginsOmemoManagerMessageState* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_waiting_other_devicelists;
	return result;
}

static void
dino_plugins_omemo_manager_message_state_set_waiting_other_devicelists (DinoPluginsOmemoManagerMessageState* self,
                                                                        gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_waiting_other_devicelists = value;
}

static gboolean
dino_plugins_omemo_manager_message_state_get_force_next_attempt (DinoPluginsOmemoManagerMessageState* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_force_next_attempt;
	return result;
}

static void
dino_plugins_omemo_manager_message_state_set_force_next_attempt (DinoPluginsOmemoManagerMessageState* self,
                                                                 gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_force_next_attempt = value;
}

static gboolean
dino_plugins_omemo_manager_message_state_get_will_send_now (DinoPluginsOmemoManagerMessageState* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_will_send_now;
	return result;
}

static void
dino_plugins_omemo_manager_message_state_set_will_send_now (DinoPluginsOmemoManagerMessageState* self,
                                                            gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_will_send_now = value;
}

static gboolean
dino_plugins_omemo_manager_message_state_get_active_send_attempt (DinoPluginsOmemoManagerMessageState* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_active_send_attempt;
	return result;
}

static void
dino_plugins_omemo_manager_message_state_set_active_send_attempt (DinoPluginsOmemoManagerMessageState* self,
                                                                  gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_active_send_attempt = value;
}

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

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

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

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

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

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

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

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

static void
dino_plugins_omemo_manager_value_set_message_state (GValue* value,
                                                    gpointer v_object)
{
	DinoPluginsOmemoManagerMessageState * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		dino_plugins_omemo_manager_message_state_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_plugins_omemo_manager_message_state_unref (old);
	}
}

static void
dino_plugins_omemo_manager_value_take_message_state (GValue* value,
                                                     gpointer v_object)
{
	DinoPluginsOmemoManagerMessageState * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		dino_plugins_omemo_manager_message_state_unref (old);
	}
}

static void
dino_plugins_omemo_manager_message_state_class_init (DinoPluginsOmemoManagerMessageStateClass * klass,
                                                     gpointer klass_data)
{
	dino_plugins_omemo_manager_message_state_parent_class = g_type_class_peek_parent (klass);
	((DinoPluginsOmemoManagerMessageStateClass *) klass)->finalize = dino_plugins_omemo_manager_message_state_finalize;
	g_type_class_adjust_private_offset (klass, &DinoPluginsOmemoManagerMessageState_private_offset);
}

static void
dino_plugins_omemo_manager_message_state_instance_init (DinoPluginsOmemoManagerMessageState * self,
                                                        gpointer klass)
{
	self->priv = dino_plugins_omemo_manager_message_state_get_instance_private (self);
	self->ref_count = 1;
}

static void
dino_plugins_omemo_manager_message_state_finalize (DinoPluginsOmemoManagerMessageState * obj)
{
	DinoPluginsOmemoManagerMessageState * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE, DinoPluginsOmemoManagerMessageState);
	g_signal_handlers_destroy (self);
	_g_object_unref0 (self->priv->_msg);
	_xmpp_xep_omemo_encrypt_state_unref0 (self->priv->_last_try);
}

static GType
dino_plugins_omemo_manager_message_state_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { dino_plugins_omemo_manager_value_message_state_init, dino_plugins_omemo_manager_value_message_state_free_value, dino_plugins_omemo_manager_value_message_state_copy_value, dino_plugins_omemo_manager_value_message_state_peek_pointer, "p", dino_plugins_omemo_manager_value_message_state_collect_value, "p", dino_plugins_omemo_manager_value_message_state_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOmemoManagerMessageStateClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_omemo_manager_message_state_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOmemoManagerMessageState), 0, (GInstanceInitFunc) dino_plugins_omemo_manager_message_state_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType dino_plugins_omemo_manager_message_state_type_id;
	dino_plugins_omemo_manager_message_state_type_id = g_type_register_fundamental (g_type_fundamental_next (), "DinoPluginsOmemoManagerMessageState", &g_define_type_info, &g_define_type_fundamental_info, 0);
	DinoPluginsOmemoManagerMessageState_private_offset = g_type_add_instance_private (dino_plugins_omemo_manager_message_state_type_id, sizeof (DinoPluginsOmemoManagerMessageStatePrivate));
	return dino_plugins_omemo_manager_message_state_type_id;
}

static GType
dino_plugins_omemo_manager_message_state_get_type (void)
{
	static volatile gsize dino_plugins_omemo_manager_message_state_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_omemo_manager_message_state_type_id__once)) {
		GType dino_plugins_omemo_manager_message_state_type_id;
		dino_plugins_omemo_manager_message_state_type_id = dino_plugins_omemo_manager_message_state_get_type_once ();
		g_once_init_leave (&dino_plugins_omemo_manager_message_state_type_id__once, dino_plugins_omemo_manager_message_state_type_id);
	}
	return dino_plugins_omemo_manager_message_state_type_id__once;
}

static gpointer
dino_plugins_omemo_manager_message_state_ref (gpointer instance)
{
	DinoPluginsOmemoManagerMessageState * self;
	self = instance;
	g_atomic_int_inc (&self->ref_count);
	return instance;
}

static void
dino_plugins_omemo_manager_message_state_unref (gpointer instance)
{
	DinoPluginsOmemoManagerMessageState * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		DINO_PLUGINS_OMEMO_MANAGER_MESSAGE_STATE_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
dino_plugins_omemo_manager_class_init (DinoPluginsOmemoManagerClass * klass,
                                       gpointer klass_data)
{
	DinoModuleIdentity* _tmp0_;
	dino_plugins_omemo_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoPluginsOmemoManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_plugins_omemo_manager_get_property;
	G_OBJECT_CLASS (klass)->finalize = dino_plugins_omemo_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_PLUGINS_OMEMO_MANAGER_ID_PROPERTY, dino_plugins_omemo_manager_properties[DINO_PLUGINS_OMEMO_MANAGER_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	_tmp0_ = dino_module_identity_new (DINO_PLUGINS_OMEMO_TYPE_MANAGER, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, "omemo_manager");
	dino_plugins_omemo_manager_IDENTITY = _tmp0_;
}

static void
dino_plugins_omemo_manager_dino_stream_interaction_module_interface_init (DinoStreamInteractionModuleIface * iface,
                                                                          gpointer iface_data)
{
	dino_plugins_omemo_manager_dino_stream_interaction_module_parent_iface = g_type_interface_peek_parent (iface);
	iface->get_id = dino_plugins_omemo_manager_real_get_id;
}

static void
dino_plugins_omemo_manager_instance_init (DinoPluginsOmemoManager * self,
                                          gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = dino_plugins_omemo_manager_get_instance_private (self);
	g_rec_mutex_init (&self->priv->__lock_message_states);
	_tmp0_ = gee_hash_map_new (DINO_ENTITIES_TYPE_MESSAGE, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, DINO_PLUGINS_OMEMO_MANAGER_TYPE_MESSAGE_STATE, (GBoxedCopyFunc) dino_plugins_omemo_manager_message_state_ref, (GDestroyNotify) dino_plugins_omemo_manager_message_state_unref, _dino_entities_message_hash_func_gee_hash_data_func, NULL, NULL, _dino_entities_message_equals_func_gee_equal_data_func, NULL, NULL, NULL, NULL, NULL);
	self->priv->message_states = (GeeMap*) _tmp0_;
}

static void
dino_plugins_omemo_manager_finalize (GObject * obj)
{
	DinoPluginsOmemoManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OMEMO_TYPE_MANAGER, DinoPluginsOmemoManager);
	_g_object_unref0 (self->priv->stream_interactor);
	_qlite_database_unref0 (self->priv->db);
	_dino_plugins_omemo_trust_manager_unref0 (self->priv->trust_manager);
	_g_object_unref0 (self->priv->encryptors);
	g_rec_mutex_clear (&self->priv->__lock_message_states);
	_g_object_unref0 (self->priv->message_states);
	G_OBJECT_CLASS (dino_plugins_omemo_manager_parent_class)->finalize (obj);
}

static GType
dino_plugins_omemo_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOmemoManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_omemo_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOmemoManager), 0, (GInstanceInitFunc) dino_plugins_omemo_manager_instance_init, NULL };
	static const GInterfaceInfo dino_stream_interaction_module_info = { (GInterfaceInitFunc) dino_plugins_omemo_manager_dino_stream_interaction_module_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType dino_plugins_omemo_manager_type_id;
	dino_plugins_omemo_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoPluginsOmemoManager", &g_define_type_info, 0);
	g_type_add_interface_static (dino_plugins_omemo_manager_type_id, DINO_TYPE_STREAM_INTERACTION_MODULE, &dino_stream_interaction_module_info);
	DinoPluginsOmemoManager_private_offset = g_type_add_instance_private (dino_plugins_omemo_manager_type_id, sizeof (DinoPluginsOmemoManagerPrivate));
	return dino_plugins_omemo_manager_type_id;
}

GType
dino_plugins_omemo_manager_get_type (void)
{
	static volatile gsize dino_plugins_omemo_manager_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_omemo_manager_type_id__once)) {
		GType dino_plugins_omemo_manager_type_id;
		dino_plugins_omemo_manager_type_id = dino_plugins_omemo_manager_get_type_once ();
		g_once_init_leave (&dino_plugins_omemo_manager_type_id__once, dino_plugins_omemo_manager_type_id);
	}
	return dino_plugins_omemo_manager_type_id__once;
}

static void
_vala_dino_plugins_omemo_manager_get_property (GObject * object,
                                               guint property_id,
                                               GValue * value,
                                               GParamSpec * pspec)
{
	DinoPluginsOmemoManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_PLUGINS_OMEMO_TYPE_MANAGER, DinoPluginsOmemoManager);
	switch (property_id) {
		case DINO_PLUGINS_OMEMO_MANAGER_ID_PROPERTY:
		g_value_set_string (value, dino_stream_interaction_module_get_id ((DinoStreamInteractionModule*) self));
		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;
}

