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

#include "omemo.h"
#include <omemo/signal_protocol.h>
#include <native/helper.h>
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <gobject/gvaluecollector.h>
#include <omemo/signal_protocol_types.h>
#include <omemo/session_builder.h>
#include <omemo/session_cipher.h>
#include <omemo/curve.h>
#include <omemo/session_pre_key.h>
#include <omemo/ratchet.h>

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

enum  {
	OMEMO_IDENTITY_KEY_STORE_0_PROPERTY,
	OMEMO_IDENTITY_KEY_STORE_IDENTITY_KEY_PRIVATE_PROPERTY,
	OMEMO_IDENTITY_KEY_STORE_IDENTITY_KEY_PUBLIC_PROPERTY,
	OMEMO_IDENTITY_KEY_STORE_LOCAL_REGISTRATION_ID_PROPERTY,
	OMEMO_IDENTITY_KEY_STORE_NUM_PROPERTIES
};
static GParamSpec* omemo_identity_key_store_properties[OMEMO_IDENTITY_KEY_STORE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
typedef struct _OmemoIdentityKeyStoreParamSpecTrustedIdentity OmemoIdentityKeyStoreParamSpecTrustedIdentity;
enum  {
	OMEMO_IDENTITY_KEY_STORE_TRUSTED_IDENTITY_ADDED_SIGNAL,
	OMEMO_IDENTITY_KEY_STORE_TRUSTED_IDENTITY_UPDATED_SIGNAL,
	OMEMO_IDENTITY_KEY_STORE_NUM_SIGNALS
};
static guint omemo_identity_key_store_signals[OMEMO_IDENTITY_KEY_STORE_NUM_SIGNALS] = {0};
enum  {
	OMEMO_SESSION_STORE_0_PROPERTY,
	OMEMO_SESSION_STORE_NUM_PROPERTIES
};
static GParamSpec* omemo_session_store_properties[OMEMO_SESSION_STORE_NUM_PROPERTIES];
typedef struct _OmemoSessionStoreParamSpecSession OmemoSessionStoreParamSpecSession;
enum  {
	OMEMO_SESSION_STORE_SESSION_STORED_SIGNAL,
	OMEMO_SESSION_STORE_SESSION_REMOVED_SIGNAL,
	OMEMO_SESSION_STORE_NUM_SIGNALS
};
static guint omemo_session_store_signals[OMEMO_SESSION_STORE_NUM_SIGNALS] = {0};
enum  {
	OMEMO_PRE_KEY_STORE_0_PROPERTY,
	OMEMO_PRE_KEY_STORE_NUM_PROPERTIES
};
static GParamSpec* omemo_pre_key_store_properties[OMEMO_PRE_KEY_STORE_NUM_PROPERTIES];
typedef struct _OmemoPreKeyStoreParamSpecKey OmemoPreKeyStoreParamSpecKey;
enum  {
	OMEMO_PRE_KEY_STORE_PRE_KEY_STORED_SIGNAL,
	OMEMO_PRE_KEY_STORE_PRE_KEY_DELETED_SIGNAL,
	OMEMO_PRE_KEY_STORE_NUM_SIGNALS
};
static guint omemo_pre_key_store_signals[OMEMO_PRE_KEY_STORE_NUM_SIGNALS] = {0};
enum  {
	OMEMO_SIGNED_PRE_KEY_STORE_0_PROPERTY,
	OMEMO_SIGNED_PRE_KEY_STORE_NUM_PROPERTIES
};
static GParamSpec* omemo_signed_pre_key_store_properties[OMEMO_SIGNED_PRE_KEY_STORE_NUM_PROPERTIES];
typedef struct _OmemoSignedPreKeyStoreParamSpecKey OmemoSignedPreKeyStoreParamSpecKey;
enum  {
	OMEMO_SIGNED_PRE_KEY_STORE_SIGNED_PRE_KEY_STORED_SIGNAL,
	OMEMO_SIGNED_PRE_KEY_STORE_SIGNED_PRE_KEY_DELETED_SIGNAL,
	OMEMO_SIGNED_PRE_KEY_STORE_NUM_SIGNALS
};
static guint omemo_signed_pre_key_store_signals[OMEMO_SIGNED_PRE_KEY_STORE_NUM_SIGNALS] = {0};
enum  {
	OMEMO_STORE_0_PROPERTY,
	OMEMO_STORE_CONTEXT_PROPERTY,
	OMEMO_STORE_IDENTITY_KEY_STORE_PROPERTY,
	OMEMO_STORE_SESSION_STORE_PROPERTY,
	OMEMO_STORE_PRE_KEY_STORE_PROPERTY,
	OMEMO_STORE_SIGNED_PRE_KEY_STORE_PROPERTY,
	OMEMO_STORE_LOCAL_REGISTRATION_ID_PROPERTY,
	OMEMO_STORE_NATIVE_CONTEXT_PROPERTY,
	OMEMO_STORE_IDENTITY_KEY_PAIR_PROPERTY,
	OMEMO_STORE_NUM_PROPERTIES
};
static GParamSpec* omemo_store_properties[OMEMO_STORE_NUM_PROPERTIES];
#define _omemo_context_unref0(var) ((var == NULL) ? NULL : (var = (omemo_context_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _signal_protocol_store_context_destroy0(var) ((var == NULL) ? NULL : (var = (signal_protocol_store_context_destroy (var), NULL)))
#define _signal_buffer_free0(var) ((var == NULL) ? NULL : (var = (signal_buffer_free (var), NULL)))
typedef struct _Block10Data Block10Data;
typedef gint (*OmemoCodeErroringFunc) (gpointer user_data, GError** error);
typedef struct _Block11Data Block11Data;
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _signal_int_list_free0(var) ((var == NULL) ? NULL : (var = (signal_int_list_free (var), NULL)))
typedef struct _Block12Data Block12Data;
typedef struct _Block13Data Block13Data;
typedef struct _Block14Data Block14Data;
typedef struct _Block15Data Block15Data;
typedef struct _Block16Data Block16Data;
typedef struct _Block17Data Block17Data;
typedef struct _Block18Data Block18Data;
typedef struct _Block19Data Block19Data;
typedef struct _Block20Data Block20Data;
typedef struct _Block21Data Block21Data;
#define _session_builder_free0(var) ((var == NULL) ? NULL : (var = (session_builder_free (var), NULL)))
#define _session_cipher_free0(var) ((var == NULL) ? NULL : (var = (session_cipher_free (var), NULL)))
#define _signal_type_unref_vapi0(var) ((var == NULL) ? NULL : (var = (signal_type_unref_vapi (var), NULL)))

struct _OmemoIdentityKeyStoreTrustedIdentityPrivate {
	guint8* _key;
	gint _key_length1;
	gint __key_size_;
	gchar* _name;
	gint _device_id;
};

struct _OmemoIdentityKeyStoreParamSpecTrustedIdentity {
	GParamSpec parent_instance;
};

struct _OmemoSessionStoreParamSpecSession {
	GParamSpec parent_instance;
};

struct _OmemoPreKeyStoreKeyPrivate {
	guint32 _key_id;
	guint8* _record;
	gint _record_length1;
	gint __record_size_;
};

struct _OmemoPreKeyStoreParamSpecKey {
	GParamSpec parent_instance;
};

struct _OmemoSignedPreKeyStoreKeyPrivate {
	guint32 _key_id;
	guint8* _record;
	gint _record_length1;
	gint __record_size_;
};

struct _OmemoSignedPreKeyStoreParamSpecKey {
	GParamSpec parent_instance;
};

struct _OmemoStorePrivate {
	OmemoContext* _context;
	OmemoIdentityKeyStore* _identity_key_store;
	OmemoSessionStore* _session_store;
	OmemoPreKeyStore* _pre_key_store;
	OmemoSignedPreKeyStore* _signed_pre_key_store;
	signal_protocol_store_context* native_store_context_;
};

struct _Block10Data {
	int _ref_count_;
	OmemoStore* store;
	signal_protocol_address* address;
	guint8* key;
	gint key_length1;
};

struct _Block11Data {
	int _ref_count_;
	OmemoStore* store;
	signal_protocol_address* address;
	guint8* key;
	gint key_length1;
};

struct _Block12Data {
	int _ref_count_;
	OmemoStore* store;
	signal_protocol_address* address;
	guint8* record;
	gint record_length1;
};

struct _Block13Data {
	int _ref_count_;
	OmemoStore* store;
	signal_protocol_address* address;
};

struct _Block14Data {
	int _ref_count_;
	OmemoStore* store;
	signal_protocol_address* address;
};

struct _Block15Data {
	int _ref_count_;
	OmemoStore* store;
	gchar* name;
	gint name_length1;
};

struct _Block16Data {
	int _ref_count_;
	OmemoStore* store;
	guint32 pre_key_id;
	guint8* record;
	gint record_length1;
};

struct _Block17Data {
	int _ref_count_;
	OmemoStore* store;
	guint32 pre_key_id;
};

struct _Block18Data {
	int _ref_count_;
	OmemoStore* store;
	guint32 pre_key_id;
};

struct _Block19Data {
	int _ref_count_;
	OmemoStore* store;
	guint32 pre_key_id;
	guint8* record;
	gint record_length1;
};

struct _Block20Data {
	int _ref_count_;
	OmemoStore* store;
	guint32 pre_key_id;
};

struct _Block21Data {
	int _ref_count_;
	OmemoStore* store;
	guint32 pre_key_id;
};

static gpointer omemo_identity_key_store_parent_class = NULL;
static gint OmemoIdentityKeyStoreTrustedIdentity_private_offset;
static gpointer omemo_identity_key_store_trusted_identity_parent_class = NULL;
static gpointer omemo_session_store_parent_class = NULL;
static gpointer omemo_session_store_session_parent_class = NULL;
static gpointer omemo_pre_key_store_parent_class = NULL;
static gint OmemoPreKeyStoreKey_private_offset;
static gpointer omemo_pre_key_store_key_parent_class = NULL;
static gpointer omemo_signed_pre_key_store_parent_class = NULL;
static gint OmemoSignedPreKeyStoreKey_private_offset;
static gpointer omemo_signed_pre_key_store_key_parent_class = NULL;
static gint OmemoStore_private_offset;
static gpointer omemo_store_parent_class = NULL;

static void omemo_identity_key_store_real_save_identity (OmemoIdentityKeyStore* self,
                                                  signal_protocol_address* address,
                                                  guint8* key,
                                                  gint key_length1,
                                                  GError** error);
static gboolean omemo_identity_key_store_real_is_trusted_identity (OmemoIdentityKeyStore* self,
                                                            signal_protocol_address* address,
                                                            guint8* key,
                                                            gint key_length1,
                                                            GError** error);
static void g_cclosure_user_marshal_VOID__OMEMO_IDENTITY_KEY_STORE_TRUSTED_IDENTITY (GClosure * closure,
                                                                              GValue * return_value,
                                                                              guint n_param_values,
                                                                              const GValue * param_values,
                                                                              gpointer invocation_hint,
                                                                              gpointer marshal_data);
static void omemo_identity_key_store_trusted_identity_set_name (OmemoIdentityKeyStoreTrustedIdentity* self,
                                                         const gchar* value);
static void omemo_identity_key_store_trusted_identity_set_device_id (OmemoIdentityKeyStoreTrustedIdentity* self,
                                                              gint value);
static guint8* _vala_array_dup34 (guint8* self,
                           gssize length);
static void omemo_identity_key_store_trusted_identity_finalize (OmemoIdentityKeyStoreTrustedIdentity * obj);
static GType omemo_identity_key_store_trusted_identity_get_type_once (void);
static GType omemo_identity_key_store_get_type_once (void);
static void _vala_omemo_identity_key_store_get_property (GObject * object,
                                                  guint property_id,
                                                  GValue * value,
                                                  GParamSpec * pspec);
static void _vala_omemo_identity_key_store_set_property (GObject * object,
                                                  guint property_id,
                                                  const GValue * value,
                                                  GParamSpec * pspec);
static guint8* omemo_session_store_real_load_session (OmemoSessionStore* self,
                                               signal_protocol_address* address,
                                               gint* result_length1,
                                               GError** error);
static signal_int_list* omemo_session_store_real_get_sub_device_sessions (OmemoSessionStore* self,
                                                                   const gchar* name,
                                                                   GError** error);
static void omemo_session_store_real_store_session (OmemoSessionStore* self,
                                             signal_protocol_address* address,
                                             guint8* record,
                                             gint record_length1,
                                             GError** error);
static gboolean omemo_session_store_real_contains_session (OmemoSessionStore* self,
                                                    signal_protocol_address* address,
                                                    GError** error);
static void omemo_session_store_real_delete_session (OmemoSessionStore* self,
                                              signal_protocol_address* address,
                                              GError** error);
static void omemo_session_store_real_delete_all_sessions (OmemoSessionStore* self,
                                                   const gchar* name,
                                                   GError** error);
static void g_cclosure_user_marshal_VOID__OMEMO_SESSION_STORE_SESSION (GClosure * closure,
                                                                GValue * return_value,
                                                                guint n_param_values,
                                                                const GValue * param_values,
                                                                gpointer invocation_hint,
                                                                gpointer marshal_data);
static void omemo_session_store_session_finalize (OmemoSessionStoreSession * obj);
static GType omemo_session_store_session_get_type_once (void);
static GType omemo_session_store_get_type_once (void);
static guint8* omemo_pre_key_store_real_load_pre_key (OmemoPreKeyStore* self,
                                               guint32 pre_key_id,
                                               gint* result_length1,
                                               GError** error);
static void omemo_pre_key_store_real_store_pre_key (OmemoPreKeyStore* self,
                                             guint32 pre_key_id,
                                             guint8* record,
                                             gint record_length1,
                                             GError** error);
static gboolean omemo_pre_key_store_real_contains_pre_key (OmemoPreKeyStore* self,
                                                    guint32 pre_key_id,
                                                    GError** error);
static void omemo_pre_key_store_real_delete_pre_key (OmemoPreKeyStore* self,
                                              guint32 pre_key_id,
                                              GError** error);
static void g_cclosure_user_marshal_VOID__OMEMO_PRE_KEY_STORE_KEY (GClosure * closure,
                                                            GValue * return_value,
                                                            guint n_param_values,
                                                            const GValue * param_values,
                                                            gpointer invocation_hint,
                                                            gpointer marshal_data);
static void omemo_pre_key_store_key_set_key_id (OmemoPreKeyStoreKey* self,
                                         guint32 value);
static void omemo_pre_key_store_key_set_record (OmemoPreKeyStoreKey* self,
                                         guint8* value,
                                         gint value_length1);
static guint8* _vala_array_dup35 (guint8* self,
                           gssize length);
static void omemo_pre_key_store_key_finalize (OmemoPreKeyStoreKey * obj);
static GType omemo_pre_key_store_key_get_type_once (void);
static GType omemo_pre_key_store_get_type_once (void);
static guint8* omemo_signed_pre_key_store_real_load_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                             guint32 pre_key_id,
                                                             gint* result_length1,
                                                             GError** error);
static void omemo_signed_pre_key_store_real_store_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                           guint32 pre_key_id,
                                                           guint8* record,
                                                           gint record_length1,
                                                           GError** error);
static gboolean omemo_signed_pre_key_store_real_contains_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                                  guint32 pre_key_id,
                                                                  GError** error);
static void omemo_signed_pre_key_store_real_delete_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                            guint32 pre_key_id,
                                                            GError** error);
static void g_cclosure_user_marshal_VOID__OMEMO_SIGNED_PRE_KEY_STORE_KEY (GClosure * closure,
                                                                   GValue * return_value,
                                                                   guint n_param_values,
                                                                   const GValue * param_values,
                                                                   gpointer invocation_hint,
                                                                   gpointer marshal_data);
static void omemo_signed_pre_key_store_key_set_key_id (OmemoSignedPreKeyStoreKey* self,
                                                guint32 value);
static void omemo_signed_pre_key_store_key_set_record (OmemoSignedPreKeyStoreKey* self,
                                                guint8* value,
                                                gint value_length1);
static guint8* _vala_array_dup36 (guint8* self,
                           gssize length);
static void omemo_signed_pre_key_store_key_finalize (OmemoSignedPreKeyStoreKey * obj);
static GType omemo_signed_pre_key_store_key_get_type_once (void);
static GType omemo_signed_pre_key_store_get_type_once (void);
static gint omemo_store_iks_get_identity_key_pair (signal_buffer** public_data,
                                            signal_buffer** private_data,
                                            void* user_data);
static gint omemo_store_iks_get_local_registration_id (void* user_data,
                                                guint32* registration_id);
static gint omemo_store_iks_save_identity (signal_protocol_address* address,
                                    guint8* key,
                                    gint key_length1,
                                    void* user_data);
static Block10Data* block10_data_ref (Block10Data* _data10_);
static void block10_data_unref (void * _userdata_);
VALA_EXTERN gint omemo_catch_to_code (OmemoCodeErroringFunc func,
                          gpointer func_target);
static gint __lambda4_ (Block10Data* _data10_,
                 GError** error);
static gint ___lambda4__omemo_code_erroring_func (gpointer self,
                                           GError** error);
static gint omemo_store_iks_is_trusted_identity (signal_protocol_address* address,
                                          guint8* key,
                                          gint key_length1,
                                          void* user_data);
static Block11Data* block11_data_ref (Block11Data* _data11_);
static void block11_data_unref (void * _userdata_);
static gint __lambda5_ (Block11Data* _data11_,
                 GError** error);
static gint ___lambda5__omemo_code_erroring_func (gpointer self,
                                           GError** error);
static void omemo_store_iks_destroy_func (void* user_data);
static gint omemo_store_ss_load_session_func (signal_buffer** record,
                                       signal_buffer** user_record,
                                       signal_protocol_address* address,
                                       void* user_data);
static gint omemo_store_ss_get_sub_device_sessions_func (signal_int_list** sessions,
                                                  gchar* name,
                                                  gint name_length1,
                                                  void* user_data);
VALA_EXTERN gchar* omemo_carr_to_string (gchar* carr,
                             gint carr_length1);
static gint omemo_store_ss_store_session_func (signal_protocol_address* address,
                                        guint8* record,
                                        gint record_length1,
                                        guint8* user_record,
                                        gint user_record_length1,
                                        void* user_data);
static Block12Data* block12_data_ref (Block12Data* _data12_);
static void block12_data_unref (void * _userdata_);
static gint __lambda6_ (Block12Data* _data12_,
                 GError** error);
static gint ___lambda6__omemo_code_erroring_func (gpointer self,
                                           GError** error);
static gint omemo_store_ss_contains_session_func (signal_protocol_address* address,
                                           void* user_data);
static Block13Data* block13_data_ref (Block13Data* _data13_);
static void block13_data_unref (void * _userdata_);
static gint __lambda7_ (Block13Data* _data13_,
                 GError** error);
static gint ___lambda7__omemo_code_erroring_func (gpointer self,
                                           GError** error);
static gint omemo_store_ss_delete_session_func (signal_protocol_address* address,
                                         void* user_data);
static Block14Data* block14_data_ref (Block14Data* _data14_);
static void block14_data_unref (void * _userdata_);
static gint __lambda8_ (Block14Data* _data14_,
                 GError** error);
static gint ___lambda8__omemo_code_erroring_func (gpointer self,
                                           GError** error);
static gint omemo_store_ss_delete_all_sessions_func (gchar* name,
                                              gint name_length1,
                                              void* user_data);
static Block15Data* block15_data_ref (Block15Data* _data15_);
static void block15_data_unref (void * _userdata_);
static gint __lambda9_ (Block15Data* _data15_,
                 GError** error);
static gint ___lambda9__omemo_code_erroring_func (gpointer self,
                                           GError** error);
static void omemo_store_ss_destroy_func (void* user_data);
static gint omemo_store_pks_load_pre_key (signal_buffer** record,
                                   guint32 pre_key_id,
                                   void* user_data);
static gint omemo_store_pks_store_pre_key (guint32 pre_key_id,
                                    guint8* record,
                                    gint record_length1,
                                    void* user_data);
static Block16Data* block16_data_ref (Block16Data* _data16_);
static void block16_data_unref (void * _userdata_);
static gint __lambda10_ (Block16Data* _data16_,
                  GError** error);
static gint ___lambda10__omemo_code_erroring_func (gpointer self,
                                            GError** error);
static gint omemo_store_pks_contains_pre_key (guint32 pre_key_id,
                                       void* user_data);
static Block17Data* block17_data_ref (Block17Data* _data17_);
static void block17_data_unref (void * _userdata_);
static gint __lambda11_ (Block17Data* _data17_,
                  GError** error);
static gint ___lambda11__omemo_code_erroring_func (gpointer self,
                                            GError** error);
static gint omemo_store_pks_remove_pre_key (guint32 pre_key_id,
                                     void* user_data);
static Block18Data* block18_data_ref (Block18Data* _data18_);
static void block18_data_unref (void * _userdata_);
static gint __lambda12_ (Block18Data* _data18_,
                  GError** error);
static gint ___lambda12__omemo_code_erroring_func (gpointer self,
                                            GError** error);
static void omemo_store_pks_destroy_func (void* user_data);
static gint omemo_store_spks_load_signed_pre_key (signal_buffer** record,
                                           guint32 pre_key_id,
                                           void* user_data);
static gint omemo_store_spks_store_signed_pre_key (guint32 pre_key_id,
                                            guint8* record,
                                            gint record_length1,
                                            void* user_data);
static Block19Data* block19_data_ref (Block19Data* _data19_);
static void block19_data_unref (void * _userdata_);
static gint __lambda13_ (Block19Data* _data19_,
                  GError** error);
static gint ___lambda13__omemo_code_erroring_func (gpointer self,
                                            GError** error);
static gint omemo_store_spks_contains_signed_pre_key (guint32 pre_key_id,
                                               void* user_data);
static Block20Data* block20_data_ref (Block20Data* _data20_);
static void block20_data_unref (void * _userdata_);
static gint __lambda14_ (Block20Data* _data20_,
                  GError** error);
static gint ___lambda14__omemo_code_erroring_func (gpointer self,
                                            GError** error);
static gint omemo_store_spks_remove_signed_pre_key (guint32 pre_key_id,
                                             void* user_data);
static Block21Data* block21_data_ref (Block21Data* _data21_);
static void block21_data_unref (void * _userdata_);
static gint __lambda15_ (Block21Data* _data21_,
                  GError** error);
static gint ___lambda15__omemo_code_erroring_func (gpointer self,
                                            GError** error);
static void omemo_store_spks_destroy_func (void* user_data);
VALA_EXTERN OmemoStore* omemo_store_new (OmemoContext* context);
VALA_EXTERN OmemoStore* omemo_store_construct (GType object_type,
                                   OmemoContext* context);
static void omemo_store_set_context (OmemoStore* self,
                              OmemoContext* value);
static gint _omemo_store_iks_get_identity_key_pair_omemo_get_identity_key_pair_func (signal_buffer** public_data,
                                                                              signal_buffer** private_data,
                                                                              void* user_data);
static gint _omemo_store_iks_get_local_registration_id_omemo_get_local_registration_id_func (void* user_data,
                                                                                      guint32* registration_id);
static gint _omemo_store_iks_save_identity_omemo_save_identity_func (signal_protocol_address* address,
                                                              guint8* key,
                                                              size_t key_length1,
                                                              void* user_data);
static gint _omemo_store_iks_is_trusted_identity_omemo_is_trusted_identity_func (signal_protocol_address* address,
                                                                          guint8* key,
                                                                          size_t key_length1,
                                                                          void* user_data);
static void _omemo_store_iks_destroy_func_omemo_destroy_func (void* user_data);
VALA_EXTERN signal_protocol_store_context* omemo_store_get_native_context (OmemoStore* self);
static gint _omemo_store_ss_load_session_func_omemo_load_session_func (signal_buffer** record,
                                                                signal_buffer** user_record,
                                                                signal_protocol_address* address,
                                                                void* user_data);
static gint _omemo_store_ss_get_sub_device_sessions_func_omemo_get_sub_device_sessions_func (signal_int_list** sessions,
                                                                                      gchar* name,
                                                                                      size_t name_length1,
                                                                                      void* user_data);
static gint _omemo_store_ss_store_session_func_omemo_store_session_func (signal_protocol_address* address,
                                                                  guint8* record,
                                                                  size_t record_length1,
                                                                  guint8* user_record,
                                                                  size_t user_record_length1,
                                                                  void* user_data);
static gint _omemo_store_ss_contains_session_func_omemo_contains_session_func (signal_protocol_address* address,
                                                                        void* user_data);
static gint _omemo_store_ss_delete_session_func_omemo_delete_session_func (signal_protocol_address* address,
                                                                    void* user_data);
static gint _omemo_store_ss_delete_all_sessions_func_omemo_delete_all_sessions_func (gchar* name,
                                                                              size_t name_length1,
                                                                              void* user_data);
static void _omemo_store_ss_destroy_func_omemo_destroy_func (void* user_data);
static gint _omemo_store_pks_load_pre_key_omemo_load_pre_key_func (signal_buffer** record,
                                                            guint32 pre_key_id,
                                                            void* user_data);
static gint _omemo_store_pks_store_pre_key_omemo_store_pre_key_func (guint32 pre_key_id,
                                                              guint8* record,
                                                              size_t record_length1,
                                                              void* user_data);
static gint _omemo_store_pks_contains_pre_key_omemo_contains_pre_key_func (guint32 pre_key_id,
                                                                    void* user_data);
static gint _omemo_store_pks_remove_pre_key_omemo_remove_pre_key_func (guint32 pre_key_id,
                                                                void* user_data);
static void _omemo_store_pks_destroy_func_omemo_destroy_func (void* user_data);
static gint _omemo_store_spks_load_signed_pre_key_omemo_load_pre_key_func (signal_buffer** record,
                                                                    guint32 pre_key_id,
                                                                    void* user_data);
static gint _omemo_store_spks_store_signed_pre_key_omemo_store_pre_key_func (guint32 pre_key_id,
                                                                      guint8* record,
                                                                      size_t record_length1,
                                                                      void* user_data);
static gint _omemo_store_spks_contains_signed_pre_key_omemo_contains_pre_key_func (guint32 pre_key_id,
                                                                            void* user_data);
static gint _omemo_store_spks_remove_signed_pre_key_omemo_remove_pre_key_func (guint32 pre_key_id,
                                                                        void* user_data);
static void _omemo_store_spks_destroy_func_omemo_destroy_func (void* user_data);
static const char* _omemo_error_code_to_string (int value);
static void omemo_store_finalize (GObject * obj);
static GType omemo_store_get_type_once (void);
static void _vala_omemo_store_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec);
static void _vala_omemo_store_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static void
omemo_identity_key_store_real_save_identity (OmemoIdentityKeyStore* self,
                                             signal_protocol_address* address,
                                             guint8* key,
                                             gint key_length1,
                                             GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_identity_key_store_save_identity'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
omemo_identity_key_store_save_identity (OmemoIdentityKeyStore* self,
                                        signal_protocol_address* address,
                                        guint8* key,
                                        gint key_length1,
                                        GError** error)
{
	OmemoIdentityKeyStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_IDENTITY_KEY_STORE_GET_CLASS (self);
	if (_klass_->save_identity) {
		_klass_->save_identity (self, address, key, key_length1, error);
	}
}

static gboolean
omemo_identity_key_store_real_is_trusted_identity (OmemoIdentityKeyStore* self,
                                                   signal_protocol_address* address,
                                                   guint8* key,
                                                   gint key_length1,
                                                   GError** error)
{
	gboolean _tmp0_ = FALSE;
	g_critical ("Type `%s' does not implement abstract method `omemo_identity_key_store_is_trusted_identity'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gboolean
omemo_identity_key_store_is_trusted_identity (OmemoIdentityKeyStore* self,
                                              signal_protocol_address* address,
                                              guint8* key,
                                              gint key_length1,
                                              GError** error)
{
	OmemoIdentityKeyStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = OMEMO_IDENTITY_KEY_STORE_GET_CLASS (self);
	if (_klass_->is_trusted_identity) {
		return _klass_->is_trusted_identity (self, address, key, key_length1, error);
	}
	return FALSE;
}

OmemoIdentityKeyStore*
omemo_identity_key_store_construct (GType object_type)
{
	OmemoIdentityKeyStore * self = NULL;
	self = (OmemoIdentityKeyStore*) g_object_new (object_type, NULL);
	return self;
}

GBytes*
omemo_identity_key_store_get_identity_key_private (OmemoIdentityKeyStore* self)
{
	OmemoIdentityKeyStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = OMEMO_IDENTITY_KEY_STORE_GET_CLASS (self);
	if (_klass_->get_identity_key_private) {
		return _klass_->get_identity_key_private (self);
	}
	return NULL;
}

void
omemo_identity_key_store_set_identity_key_private (OmemoIdentityKeyStore* self,
                                                   GBytes* value)
{
	OmemoIdentityKeyStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_IDENTITY_KEY_STORE_GET_CLASS (self);
	if (_klass_->set_identity_key_private) {
		_klass_->set_identity_key_private (self, value);
	}
}

GBytes*
omemo_identity_key_store_get_identity_key_public (OmemoIdentityKeyStore* self)
{
	OmemoIdentityKeyStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = OMEMO_IDENTITY_KEY_STORE_GET_CLASS (self);
	if (_klass_->get_identity_key_public) {
		return _klass_->get_identity_key_public (self);
	}
	return NULL;
}

void
omemo_identity_key_store_set_identity_key_public (OmemoIdentityKeyStore* self,
                                                  GBytes* value)
{
	OmemoIdentityKeyStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_IDENTITY_KEY_STORE_GET_CLASS (self);
	if (_klass_->set_identity_key_public) {
		_klass_->set_identity_key_public (self, value);
	}
}

guint32
omemo_identity_key_store_get_local_registration_id (OmemoIdentityKeyStore* self)
{
	OmemoIdentityKeyStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, 0U);
	_klass_ = OMEMO_IDENTITY_KEY_STORE_GET_CLASS (self);
	if (_klass_->get_local_registration_id) {
		return _klass_->get_local_registration_id (self);
	}
	return 0U;
}

void
omemo_identity_key_store_set_local_registration_id (OmemoIdentityKeyStore* self,
                                                    guint32 value)
{
	OmemoIdentityKeyStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_IDENTITY_KEY_STORE_GET_CLASS (self);
	if (_klass_->set_local_registration_id) {
		_klass_->set_local_registration_id (self, value);
	}
}

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

static inline gpointer
omemo_identity_key_store_trusted_identity_get_instance_private (OmemoIdentityKeyStoreTrustedIdentity* self)
{
	return G_STRUCT_MEMBER_P (self, OmemoIdentityKeyStoreTrustedIdentity_private_offset);
}

OmemoIdentityKeyStoreTrustedIdentity*
omemo_identity_key_store_trusted_identity_construct (GType object_type,
                                                     const gchar* name,
                                                     gint device_id,
                                                     guint8* key,
                                                     gint key_length1)
{
	OmemoIdentityKeyStoreTrustedIdentity* self = NULL;
	g_return_val_if_fail (name != NULL, NULL);
	self = (OmemoIdentityKeyStoreTrustedIdentity*) g_type_create_instance (object_type);
	omemo_identity_key_store_trusted_identity_set_key (self, key, key_length1);
	omemo_identity_key_store_trusted_identity_set_name (self, name);
	omemo_identity_key_store_trusted_identity_set_device_id (self, device_id);
	return self;
}

OmemoIdentityKeyStoreTrustedIdentity*
omemo_identity_key_store_trusted_identity_new (const gchar* name,
                                               gint device_id,
                                               guint8* key,
                                               gint key_length1)
{
	return omemo_identity_key_store_trusted_identity_construct (OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY, name, device_id, key, key_length1);
}

OmemoIdentityKeyStoreTrustedIdentity*
omemo_identity_key_store_trusted_identity_construct_by_address (GType object_type,
                                                                signal_protocol_address* address,
                                                                guint8* key,
                                                                gint key_length1)
{
	OmemoIdentityKeyStoreTrustedIdentity* self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gint32 _tmp3_;
	gint32 _tmp4_;
	g_return_val_if_fail (address != NULL, NULL);
	_tmp0_ = signal_protocol_address_get_name (address);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = signal_protocol_address_get_device_id (address);
	_tmp4_ = _tmp3_;
	self = (OmemoIdentityKeyStoreTrustedIdentity*) omemo_identity_key_store_trusted_identity_construct (object_type, _tmp2_, (gint) _tmp4_, key, (gint) key_length1);
	_g_free0 (_tmp2_);
	return self;
}

OmemoIdentityKeyStoreTrustedIdentity*
omemo_identity_key_store_trusted_identity_new_by_address (signal_protocol_address* address,
                                                          guint8* key,
                                                          gint key_length1)
{
	return omemo_identity_key_store_trusted_identity_construct_by_address (OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY, address, key, key_length1);
}

guint8*
omemo_identity_key_store_trusted_identity_get_key (OmemoIdentityKeyStoreTrustedIdentity* self,
                                                   gint* result_length1)
{
	guint8* result;
	guint8* _tmp0_;
	gint _tmp0__length1;
	guint8* _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_key;
	_tmp0__length1 = self->priv->_key_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

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

void
omemo_identity_key_store_trusted_identity_set_key (OmemoIdentityKeyStoreTrustedIdentity* self,
                                                   guint8* value,
                                                   gint value_length1)
{
	guint8* _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = (value != NULL) ? _vala_array_dup34 (value, value_length1) : value;
	_tmp0__length1 = value_length1;
	self->priv->_key = (g_free (self->priv->_key), NULL);
	self->priv->_key = _tmp0_;
	self->priv->_key_length1 = _tmp0__length1;
	self->priv->__key_size_ = self->priv->_key_length1;
}

const gchar*
omemo_identity_key_store_trusted_identity_get_name (OmemoIdentityKeyStoreTrustedIdentity* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_name;
	result = _tmp0_;
	return result;
}

static void
omemo_identity_key_store_trusted_identity_set_name (OmemoIdentityKeyStoreTrustedIdentity* self,
                                                    const gchar* value)
{
	gchar* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = g_strdup (value);
	_g_free0 (self->priv->_name);
	self->priv->_name = _tmp0_;
}

gint
omemo_identity_key_store_trusted_identity_get_device_id (OmemoIdentityKeyStoreTrustedIdentity* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_device_id;
	return result;
}

static void
omemo_identity_key_store_trusted_identity_set_device_id (OmemoIdentityKeyStoreTrustedIdentity* self,
                                                         gint value)
{
	g_return_if_fail (self != NULL);
	self->priv->_device_id = value;
}

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

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

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

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

static gchar*
omemo_identity_key_store_value_trusted_identity_collect_value (GValue* value,
                                                               guint n_collect_values,
                                                               GTypeCValue* collect_values,
                                                               guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		OmemoIdentityKeyStoreTrustedIdentity * 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 = omemo_identity_key_store_trusted_identity_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
omemo_identity_key_store_value_trusted_identity_lcopy_value (const GValue* value,
                                                             guint n_collect_values,
                                                             GTypeCValue* collect_values,
                                                             guint collect_flags)
{
	OmemoIdentityKeyStoreTrustedIdentity ** 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 = omemo_identity_key_store_trusted_identity_ref (value->data[0].v_pointer);
	}
	return NULL;
}

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

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

void
omemo_identity_key_store_value_set_trusted_identity (GValue* value,
                                                     gpointer v_object)
{
	OmemoIdentityKeyStoreTrustedIdentity * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY));
		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;
		omemo_identity_key_store_trusted_identity_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		omemo_identity_key_store_trusted_identity_unref (old);
	}
}

void
omemo_identity_key_store_value_take_trusted_identity (GValue* value,
                                                      gpointer v_object)
{
	OmemoIdentityKeyStoreTrustedIdentity * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY));
		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) {
		omemo_identity_key_store_trusted_identity_unref (old);
	}
}

static void
omemo_identity_key_store_trusted_identity_class_init (OmemoIdentityKeyStoreTrustedIdentityClass * klass,
                                                      gpointer klass_data)
{
	omemo_identity_key_store_trusted_identity_parent_class = g_type_class_peek_parent (klass);
	((OmemoIdentityKeyStoreTrustedIdentityClass *) klass)->finalize = omemo_identity_key_store_trusted_identity_finalize;
	g_type_class_adjust_private_offset (klass, &OmemoIdentityKeyStoreTrustedIdentity_private_offset);
}

static void
omemo_identity_key_store_trusted_identity_instance_init (OmemoIdentityKeyStoreTrustedIdentity * self,
                                                         gpointer klass)
{
	self->priv = omemo_identity_key_store_trusted_identity_get_instance_private (self);
	self->ref_count = 1;
}

static void
omemo_identity_key_store_trusted_identity_finalize (OmemoIdentityKeyStoreTrustedIdentity * obj)
{
	OmemoIdentityKeyStoreTrustedIdentity * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY, OmemoIdentityKeyStoreTrustedIdentity);
	g_signal_handlers_destroy (self);
	self->priv->_key = (g_free (self->priv->_key), NULL);
	_g_free0 (self->priv->_name);
}

static GType
omemo_identity_key_store_trusted_identity_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { omemo_identity_key_store_value_trusted_identity_init, omemo_identity_key_store_value_trusted_identity_free_value, omemo_identity_key_store_value_trusted_identity_copy_value, omemo_identity_key_store_value_trusted_identity_peek_pointer, "p", omemo_identity_key_store_value_trusted_identity_collect_value, "p", omemo_identity_key_store_value_trusted_identity_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (OmemoIdentityKeyStoreTrustedIdentityClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_identity_key_store_trusted_identity_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoIdentityKeyStoreTrustedIdentity), 0, (GInstanceInitFunc) omemo_identity_key_store_trusted_identity_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 omemo_identity_key_store_trusted_identity_type_id;
	omemo_identity_key_store_trusted_identity_type_id = g_type_register_fundamental (g_type_fundamental_next (), "OmemoIdentityKeyStoreTrustedIdentity", &g_define_type_info, &g_define_type_fundamental_info, 0);
	OmemoIdentityKeyStoreTrustedIdentity_private_offset = g_type_add_instance_private (omemo_identity_key_store_trusted_identity_type_id, sizeof (OmemoIdentityKeyStoreTrustedIdentityPrivate));
	return omemo_identity_key_store_trusted_identity_type_id;
}

GType
omemo_identity_key_store_trusted_identity_get_type (void)
{
	static volatile gsize omemo_identity_key_store_trusted_identity_type_id__once = 0;
	if (g_once_init_enter (&omemo_identity_key_store_trusted_identity_type_id__once)) {
		GType omemo_identity_key_store_trusted_identity_type_id;
		omemo_identity_key_store_trusted_identity_type_id = omemo_identity_key_store_trusted_identity_get_type_once ();
		g_once_init_leave (&omemo_identity_key_store_trusted_identity_type_id__once, omemo_identity_key_store_trusted_identity_type_id);
	}
	return omemo_identity_key_store_trusted_identity_type_id__once;
}

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

void
omemo_identity_key_store_trusted_identity_unref (gpointer instance)
{
	OmemoIdentityKeyStoreTrustedIdentity * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		OMEMO_IDENTITY_KEY_STORE_TRUSTED_IDENTITY_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
omemo_identity_key_store_class_init (OmemoIdentityKeyStoreClass * klass,
                                     gpointer klass_data)
{
	omemo_identity_key_store_parent_class = g_type_class_peek_parent (klass);
	((OmemoIdentityKeyStoreClass *) klass)->save_identity = (void (*) (OmemoIdentityKeyStore*, signal_protocol_address*, guint8*, gint, GError**)) omemo_identity_key_store_real_save_identity;
	((OmemoIdentityKeyStoreClass *) klass)->is_trusted_identity = (gboolean (*) (OmemoIdentityKeyStore*, signal_protocol_address*, guint8*, gint, GError**)) omemo_identity_key_store_real_is_trusted_identity;
	G_OBJECT_CLASS (klass)->get_property = _vala_omemo_identity_key_store_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_omemo_identity_key_store_set_property;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_IDENTITY_KEY_STORE_IDENTITY_KEY_PRIVATE_PROPERTY, omemo_identity_key_store_properties[OMEMO_IDENTITY_KEY_STORE_IDENTITY_KEY_PRIVATE_PROPERTY] = g_param_spec_boxed ("identity-key-private", "identity-key-private", "identity-key-private", G_TYPE_BYTES, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_IDENTITY_KEY_STORE_IDENTITY_KEY_PUBLIC_PROPERTY, omemo_identity_key_store_properties[OMEMO_IDENTITY_KEY_STORE_IDENTITY_KEY_PUBLIC_PROPERTY] = g_param_spec_boxed ("identity-key-public", "identity-key-public", "identity-key-public", G_TYPE_BYTES, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_IDENTITY_KEY_STORE_LOCAL_REGISTRATION_ID_PROPERTY, omemo_identity_key_store_properties[OMEMO_IDENTITY_KEY_STORE_LOCAL_REGISTRATION_ID_PROPERTY] = g_param_spec_uint ("local-registration-id", "local-registration-id", "local-registration-id", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	omemo_identity_key_store_signals[OMEMO_IDENTITY_KEY_STORE_TRUSTED_IDENTITY_ADDED_SIGNAL] = g_signal_new ("trusted-identity-added", OMEMO_TYPE_IDENTITY_KEY_STORE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OMEMO_IDENTITY_KEY_STORE_TRUSTED_IDENTITY, G_TYPE_NONE, 1, OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY);
	omemo_identity_key_store_signals[OMEMO_IDENTITY_KEY_STORE_TRUSTED_IDENTITY_UPDATED_SIGNAL] = g_signal_new ("trusted-identity-updated", OMEMO_TYPE_IDENTITY_KEY_STORE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OMEMO_IDENTITY_KEY_STORE_TRUSTED_IDENTITY, G_TYPE_NONE, 1, OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY);
}

static void
omemo_identity_key_store_instance_init (OmemoIdentityKeyStore * self,
                                        gpointer klass)
{
}

static GType
omemo_identity_key_store_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OmemoIdentityKeyStoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_identity_key_store_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoIdentityKeyStore), 0, (GInstanceInitFunc) omemo_identity_key_store_instance_init, NULL };
	GType omemo_identity_key_store_type_id;
	omemo_identity_key_store_type_id = g_type_register_static (G_TYPE_OBJECT, "OmemoIdentityKeyStore", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return omemo_identity_key_store_type_id;
}

GType
omemo_identity_key_store_get_type (void)
{
	static volatile gsize omemo_identity_key_store_type_id__once = 0;
	if (g_once_init_enter (&omemo_identity_key_store_type_id__once)) {
		GType omemo_identity_key_store_type_id;
		omemo_identity_key_store_type_id = omemo_identity_key_store_get_type_once ();
		g_once_init_leave (&omemo_identity_key_store_type_id__once, omemo_identity_key_store_type_id);
	}
	return omemo_identity_key_store_type_id__once;
}

static void
_vala_omemo_identity_key_store_get_property (GObject * object,
                                             guint property_id,
                                             GValue * value,
                                             GParamSpec * pspec)
{
	OmemoIdentityKeyStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OMEMO_TYPE_IDENTITY_KEY_STORE, OmemoIdentityKeyStore);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_omemo_identity_key_store_set_property (GObject * object,
                                             guint property_id,
                                             const GValue * value,
                                             GParamSpec * pspec)
{
	OmemoIdentityKeyStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OMEMO_TYPE_IDENTITY_KEY_STORE, OmemoIdentityKeyStore);
	switch (property_id) {
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static guint8*
omemo_session_store_real_load_session (OmemoSessionStore* self,
                                       signal_protocol_address* address,
                                       gint* result_length1,
                                       GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_session_store_load_session'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

guint8*
omemo_session_store_load_session (OmemoSessionStore* self,
                                  signal_protocol_address* address,
                                  gint* result_length1,
                                  GError** error)
{
	OmemoSessionStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = OMEMO_SESSION_STORE_GET_CLASS (self);
	if (_klass_->load_session) {
		return _klass_->load_session (self, address, result_length1, error);
	}
	return NULL;
}

static signal_int_list*
omemo_session_store_real_get_sub_device_sessions (OmemoSessionStore* self,
                                                  const gchar* name,
                                                  GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_session_store_get_sub_device_sessions'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

signal_int_list*
omemo_session_store_get_sub_device_sessions (OmemoSessionStore* self,
                                             const gchar* name,
                                             GError** error)
{
	OmemoSessionStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = OMEMO_SESSION_STORE_GET_CLASS (self);
	if (_klass_->get_sub_device_sessions) {
		return _klass_->get_sub_device_sessions (self, name, error);
	}
	return NULL;
}

static void
omemo_session_store_real_store_session (OmemoSessionStore* self,
                                        signal_protocol_address* address,
                                        guint8* record,
                                        gint record_length1,
                                        GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_session_store_store_session'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
omemo_session_store_store_session (OmemoSessionStore* self,
                                   signal_protocol_address* address,
                                   guint8* record,
                                   gint record_length1,
                                   GError** error)
{
	OmemoSessionStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_SESSION_STORE_GET_CLASS (self);
	if (_klass_->store_session) {
		_klass_->store_session (self, address, record, record_length1, error);
	}
}

static gboolean
omemo_session_store_real_contains_session (OmemoSessionStore* self,
                                           signal_protocol_address* address,
                                           GError** error)
{
	gboolean _tmp0_ = FALSE;
	g_critical ("Type `%s' does not implement abstract method `omemo_session_store_contains_session'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gboolean
omemo_session_store_contains_session (OmemoSessionStore* self,
                                      signal_protocol_address* address,
                                      GError** error)
{
	OmemoSessionStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = OMEMO_SESSION_STORE_GET_CLASS (self);
	if (_klass_->contains_session) {
		return _klass_->contains_session (self, address, error);
	}
	return FALSE;
}

static void
omemo_session_store_real_delete_session (OmemoSessionStore* self,
                                         signal_protocol_address* address,
                                         GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_session_store_delete_session'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
omemo_session_store_delete_session (OmemoSessionStore* self,
                                    signal_protocol_address* address,
                                    GError** error)
{
	OmemoSessionStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_SESSION_STORE_GET_CLASS (self);
	if (_klass_->delete_session) {
		_klass_->delete_session (self, address, error);
	}
}

static void
omemo_session_store_real_delete_all_sessions (OmemoSessionStore* self,
                                              const gchar* name,
                                              GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_session_store_delete_all_sessions'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
omemo_session_store_delete_all_sessions (OmemoSessionStore* self,
                                         const gchar* name,
                                         GError** error)
{
	OmemoSessionStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_SESSION_STORE_GET_CLASS (self);
	if (_klass_->delete_all_sessions) {
		_klass_->delete_all_sessions (self, name, error);
	}
}

OmemoSessionStore*
omemo_session_store_construct (GType object_type)
{
	OmemoSessionStore * self = NULL;
	self = (OmemoSessionStore*) g_object_new (object_type, NULL);
	return self;
}

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

OmemoSessionStoreSession*
omemo_session_store_session_construct (GType object_type)
{
	OmemoSessionStoreSession* self = NULL;
	self = (OmemoSessionStoreSession*) g_type_create_instance (object_type);
	return self;
}

OmemoSessionStoreSession*
omemo_session_store_session_new (void)
{
	return omemo_session_store_session_construct (OMEMO_SESSION_STORE_TYPE_SESSION);
}

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

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

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

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

static gchar*
omemo_session_store_value_session_collect_value (GValue* value,
                                                 guint n_collect_values,
                                                 GTypeCValue* collect_values,
                                                 guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		OmemoSessionStoreSession * 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 = omemo_session_store_session_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
omemo_session_store_value_session_lcopy_value (const GValue* value,
                                               guint n_collect_values,
                                               GTypeCValue* collect_values,
                                               guint collect_flags)
{
	OmemoSessionStoreSession ** 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 = omemo_session_store_session_ref (value->data[0].v_pointer);
	}
	return NULL;
}

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

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

void
omemo_session_store_value_set_session (GValue* value,
                                       gpointer v_object)
{
	OmemoSessionStoreSession * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, OMEMO_SESSION_STORE_TYPE_SESSION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, OMEMO_SESSION_STORE_TYPE_SESSION));
		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;
		omemo_session_store_session_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		omemo_session_store_session_unref (old);
	}
}

void
omemo_session_store_value_take_session (GValue* value,
                                        gpointer v_object)
{
	OmemoSessionStoreSession * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, OMEMO_SESSION_STORE_TYPE_SESSION));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, OMEMO_SESSION_STORE_TYPE_SESSION));
		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) {
		omemo_session_store_session_unref (old);
	}
}

static void
omemo_session_store_session_class_init (OmemoSessionStoreSessionClass * klass,
                                        gpointer klass_data)
{
	omemo_session_store_session_parent_class = g_type_class_peek_parent (klass);
	((OmemoSessionStoreSessionClass *) klass)->finalize = omemo_session_store_session_finalize;
}

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

static void
omemo_session_store_session_finalize (OmemoSessionStoreSession * obj)
{
	OmemoSessionStoreSession * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OMEMO_SESSION_STORE_TYPE_SESSION, OmemoSessionStoreSession);
	g_signal_handlers_destroy (self);
	_g_free0 (self->name);
	self->record = (g_free (self->record), NULL);
}

static GType
omemo_session_store_session_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { omemo_session_store_value_session_init, omemo_session_store_value_session_free_value, omemo_session_store_value_session_copy_value, omemo_session_store_value_session_peek_pointer, "p", omemo_session_store_value_session_collect_value, "p", omemo_session_store_value_session_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (OmemoSessionStoreSessionClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_session_store_session_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoSessionStoreSession), 0, (GInstanceInitFunc) omemo_session_store_session_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 omemo_session_store_session_type_id;
	omemo_session_store_session_type_id = g_type_register_fundamental (g_type_fundamental_next (), "OmemoSessionStoreSession", &g_define_type_info, &g_define_type_fundamental_info, 0);
	return omemo_session_store_session_type_id;
}

GType
omemo_session_store_session_get_type (void)
{
	static volatile gsize omemo_session_store_session_type_id__once = 0;
	if (g_once_init_enter (&omemo_session_store_session_type_id__once)) {
		GType omemo_session_store_session_type_id;
		omemo_session_store_session_type_id = omemo_session_store_session_get_type_once ();
		g_once_init_leave (&omemo_session_store_session_type_id__once, omemo_session_store_session_type_id);
	}
	return omemo_session_store_session_type_id__once;
}

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

void
omemo_session_store_session_unref (gpointer instance)
{
	OmemoSessionStoreSession * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		OMEMO_SESSION_STORE_SESSION_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
omemo_session_store_class_init (OmemoSessionStoreClass * klass,
                                gpointer klass_data)
{
	omemo_session_store_parent_class = g_type_class_peek_parent (klass);
	((OmemoSessionStoreClass *) klass)->load_session = (guint8* (*) (OmemoSessionStore*, signal_protocol_address*, gint*, GError**)) omemo_session_store_real_load_session;
	((OmemoSessionStoreClass *) klass)->get_sub_device_sessions = (signal_int_list* (*) (OmemoSessionStore*, const gchar*, GError**)) omemo_session_store_real_get_sub_device_sessions;
	((OmemoSessionStoreClass *) klass)->store_session = (void (*) (OmemoSessionStore*, signal_protocol_address*, guint8*, gint, GError**)) omemo_session_store_real_store_session;
	((OmemoSessionStoreClass *) klass)->contains_session = (gboolean (*) (OmemoSessionStore*, signal_protocol_address*, GError**)) omemo_session_store_real_contains_session;
	((OmemoSessionStoreClass *) klass)->delete_session = (void (*) (OmemoSessionStore*, signal_protocol_address*, GError**)) omemo_session_store_real_delete_session;
	((OmemoSessionStoreClass *) klass)->delete_all_sessions = (void (*) (OmemoSessionStore*, const gchar*, GError**)) omemo_session_store_real_delete_all_sessions;
	omemo_session_store_signals[OMEMO_SESSION_STORE_SESSION_STORED_SIGNAL] = g_signal_new ("session-stored", OMEMO_TYPE_SESSION_STORE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OMEMO_SESSION_STORE_SESSION, G_TYPE_NONE, 1, OMEMO_SESSION_STORE_TYPE_SESSION);
	omemo_session_store_signals[OMEMO_SESSION_STORE_SESSION_REMOVED_SIGNAL] = g_signal_new ("session-removed", OMEMO_TYPE_SESSION_STORE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OMEMO_SESSION_STORE_SESSION, G_TYPE_NONE, 1, OMEMO_SESSION_STORE_TYPE_SESSION);
}

static void
omemo_session_store_instance_init (OmemoSessionStore * self,
                                   gpointer klass)
{
}

static GType
omemo_session_store_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OmemoSessionStoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_session_store_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoSessionStore), 0, (GInstanceInitFunc) omemo_session_store_instance_init, NULL };
	GType omemo_session_store_type_id;
	omemo_session_store_type_id = g_type_register_static (G_TYPE_OBJECT, "OmemoSessionStore", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return omemo_session_store_type_id;
}

GType
omemo_session_store_get_type (void)
{
	static volatile gsize omemo_session_store_type_id__once = 0;
	if (g_once_init_enter (&omemo_session_store_type_id__once)) {
		GType omemo_session_store_type_id;
		omemo_session_store_type_id = omemo_session_store_get_type_once ();
		g_once_init_leave (&omemo_session_store_type_id__once, omemo_session_store_type_id);
	}
	return omemo_session_store_type_id__once;
}

static guint8*
omemo_pre_key_store_real_load_pre_key (OmemoPreKeyStore* self,
                                       guint32 pre_key_id,
                                       gint* result_length1,
                                       GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_pre_key_store_load_pre_key'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

guint8*
omemo_pre_key_store_load_pre_key (OmemoPreKeyStore* self,
                                  guint32 pre_key_id,
                                  gint* result_length1,
                                  GError** error)
{
	OmemoPreKeyStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = OMEMO_PRE_KEY_STORE_GET_CLASS (self);
	if (_klass_->load_pre_key) {
		return _klass_->load_pre_key (self, pre_key_id, result_length1, error);
	}
	return NULL;
}

static void
omemo_pre_key_store_real_store_pre_key (OmemoPreKeyStore* self,
                                        guint32 pre_key_id,
                                        guint8* record,
                                        gint record_length1,
                                        GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_pre_key_store_store_pre_key'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
omemo_pre_key_store_store_pre_key (OmemoPreKeyStore* self,
                                   guint32 pre_key_id,
                                   guint8* record,
                                   gint record_length1,
                                   GError** error)
{
	OmemoPreKeyStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_PRE_KEY_STORE_GET_CLASS (self);
	if (_klass_->store_pre_key) {
		_klass_->store_pre_key (self, pre_key_id, record, record_length1, error);
	}
}

static gboolean
omemo_pre_key_store_real_contains_pre_key (OmemoPreKeyStore* self,
                                           guint32 pre_key_id,
                                           GError** error)
{
	gboolean _tmp0_ = FALSE;
	g_critical ("Type `%s' does not implement abstract method `omemo_pre_key_store_contains_pre_key'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gboolean
omemo_pre_key_store_contains_pre_key (OmemoPreKeyStore* self,
                                      guint32 pre_key_id,
                                      GError** error)
{
	OmemoPreKeyStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = OMEMO_PRE_KEY_STORE_GET_CLASS (self);
	if (_klass_->contains_pre_key) {
		return _klass_->contains_pre_key (self, pre_key_id, error);
	}
	return FALSE;
}

static void
omemo_pre_key_store_real_delete_pre_key (OmemoPreKeyStore* self,
                                         guint32 pre_key_id,
                                         GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_pre_key_store_delete_pre_key'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
omemo_pre_key_store_delete_pre_key (OmemoPreKeyStore* self,
                                    guint32 pre_key_id,
                                    GError** error)
{
	OmemoPreKeyStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_PRE_KEY_STORE_GET_CLASS (self);
	if (_klass_->delete_pre_key) {
		_klass_->delete_pre_key (self, pre_key_id, error);
	}
}

OmemoPreKeyStore*
omemo_pre_key_store_construct (GType object_type)
{
	OmemoPreKeyStore * self = NULL;
	self = (OmemoPreKeyStore*) g_object_new (object_type, NULL);
	return self;
}

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

static inline gpointer
omemo_pre_key_store_key_get_instance_private (OmemoPreKeyStoreKey* self)
{
	return G_STRUCT_MEMBER_P (self, OmemoPreKeyStoreKey_private_offset);
}

OmemoPreKeyStoreKey*
omemo_pre_key_store_key_construct (GType object_type,
                                   guint32 key_id,
                                   guint8* record,
                                   gint record_length1)
{
	OmemoPreKeyStoreKey* self = NULL;
	self = (OmemoPreKeyStoreKey*) g_type_create_instance (object_type);
	omemo_pre_key_store_key_set_key_id (self, key_id);
	omemo_pre_key_store_key_set_record (self, record, record_length1);
	return self;
}

OmemoPreKeyStoreKey*
omemo_pre_key_store_key_new (guint32 key_id,
                             guint8* record,
                             gint record_length1)
{
	return omemo_pre_key_store_key_construct (OMEMO_PRE_KEY_STORE_TYPE_KEY, key_id, record, record_length1);
}

guint32
omemo_pre_key_store_key_get_key_id (OmemoPreKeyStoreKey* self)
{
	guint32 result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_key_id;
	return result;
}

static void
omemo_pre_key_store_key_set_key_id (OmemoPreKeyStoreKey* self,
                                    guint32 value)
{
	g_return_if_fail (self != NULL);
	self->priv->_key_id = value;
}

guint8*
omemo_pre_key_store_key_get_record (OmemoPreKeyStoreKey* self,
                                    gint* result_length1)
{
	guint8* result;
	guint8* _tmp0_;
	gint _tmp0__length1;
	guint8* _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_record;
	_tmp0__length1 = self->priv->_record_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

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

static void
omemo_pre_key_store_key_set_record (OmemoPreKeyStoreKey* self,
                                    guint8* value,
                                    gint value_length1)
{
	guint8* _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = (value != NULL) ? _vala_array_dup35 (value, value_length1) : value;
	_tmp0__length1 = value_length1;
	self->priv->_record = (g_free (self->priv->_record), NULL);
	self->priv->_record = _tmp0_;
	self->priv->_record_length1 = _tmp0__length1;
	self->priv->__record_size_ = self->priv->_record_length1;
}

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

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

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

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

static gchar*
omemo_pre_key_store_value_key_collect_value (GValue* value,
                                             guint n_collect_values,
                                             GTypeCValue* collect_values,
                                             guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		OmemoPreKeyStoreKey * 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 = omemo_pre_key_store_key_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
omemo_pre_key_store_value_key_lcopy_value (const GValue* value,
                                           guint n_collect_values,
                                           GTypeCValue* collect_values,
                                           guint collect_flags)
{
	OmemoPreKeyStoreKey ** 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 = omemo_pre_key_store_key_ref (value->data[0].v_pointer);
	}
	return NULL;
}

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

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

void
omemo_pre_key_store_value_set_key (GValue* value,
                                   gpointer v_object)
{
	OmemoPreKeyStoreKey * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, OMEMO_PRE_KEY_STORE_TYPE_KEY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, OMEMO_PRE_KEY_STORE_TYPE_KEY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		omemo_pre_key_store_key_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		omemo_pre_key_store_key_unref (old);
	}
}

void
omemo_pre_key_store_value_take_key (GValue* value,
                                    gpointer v_object)
{
	OmemoPreKeyStoreKey * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, OMEMO_PRE_KEY_STORE_TYPE_KEY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, OMEMO_PRE_KEY_STORE_TYPE_KEY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		omemo_pre_key_store_key_unref (old);
	}
}

static void
omemo_pre_key_store_key_class_init (OmemoPreKeyStoreKeyClass * klass,
                                    gpointer klass_data)
{
	omemo_pre_key_store_key_parent_class = g_type_class_peek_parent (klass);
	((OmemoPreKeyStoreKeyClass *) klass)->finalize = omemo_pre_key_store_key_finalize;
	g_type_class_adjust_private_offset (klass, &OmemoPreKeyStoreKey_private_offset);
}

static void
omemo_pre_key_store_key_instance_init (OmemoPreKeyStoreKey * self,
                                       gpointer klass)
{
	self->priv = omemo_pre_key_store_key_get_instance_private (self);
	self->ref_count = 1;
}

static void
omemo_pre_key_store_key_finalize (OmemoPreKeyStoreKey * obj)
{
	OmemoPreKeyStoreKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OMEMO_PRE_KEY_STORE_TYPE_KEY, OmemoPreKeyStoreKey);
	g_signal_handlers_destroy (self);
	self->priv->_record = (g_free (self->priv->_record), NULL);
}

static GType
omemo_pre_key_store_key_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { omemo_pre_key_store_value_key_init, omemo_pre_key_store_value_key_free_value, omemo_pre_key_store_value_key_copy_value, omemo_pre_key_store_value_key_peek_pointer, "p", omemo_pre_key_store_value_key_collect_value, "p", omemo_pre_key_store_value_key_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (OmemoPreKeyStoreKeyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_pre_key_store_key_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoPreKeyStoreKey), 0, (GInstanceInitFunc) omemo_pre_key_store_key_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType omemo_pre_key_store_key_type_id;
	omemo_pre_key_store_key_type_id = g_type_register_fundamental (g_type_fundamental_next (), "OmemoPreKeyStoreKey", &g_define_type_info, &g_define_type_fundamental_info, 0);
	OmemoPreKeyStoreKey_private_offset = g_type_add_instance_private (omemo_pre_key_store_key_type_id, sizeof (OmemoPreKeyStoreKeyPrivate));
	return omemo_pre_key_store_key_type_id;
}

GType
omemo_pre_key_store_key_get_type (void)
{
	static volatile gsize omemo_pre_key_store_key_type_id__once = 0;
	if (g_once_init_enter (&omemo_pre_key_store_key_type_id__once)) {
		GType omemo_pre_key_store_key_type_id;
		omemo_pre_key_store_key_type_id = omemo_pre_key_store_key_get_type_once ();
		g_once_init_leave (&omemo_pre_key_store_key_type_id__once, omemo_pre_key_store_key_type_id);
	}
	return omemo_pre_key_store_key_type_id__once;
}

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

void
omemo_pre_key_store_key_unref (gpointer instance)
{
	OmemoPreKeyStoreKey * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		OMEMO_PRE_KEY_STORE_KEY_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
omemo_pre_key_store_class_init (OmemoPreKeyStoreClass * klass,
                                gpointer klass_data)
{
	omemo_pre_key_store_parent_class = g_type_class_peek_parent (klass);
	((OmemoPreKeyStoreClass *) klass)->load_pre_key = (guint8* (*) (OmemoPreKeyStore*, guint32, gint*, GError**)) omemo_pre_key_store_real_load_pre_key;
	((OmemoPreKeyStoreClass *) klass)->store_pre_key = (void (*) (OmemoPreKeyStore*, guint32, guint8*, gint, GError**)) omemo_pre_key_store_real_store_pre_key;
	((OmemoPreKeyStoreClass *) klass)->contains_pre_key = (gboolean (*) (OmemoPreKeyStore*, guint32, GError**)) omemo_pre_key_store_real_contains_pre_key;
	((OmemoPreKeyStoreClass *) klass)->delete_pre_key = (void (*) (OmemoPreKeyStore*, guint32, GError**)) omemo_pre_key_store_real_delete_pre_key;
	omemo_pre_key_store_signals[OMEMO_PRE_KEY_STORE_PRE_KEY_STORED_SIGNAL] = g_signal_new ("pre-key-stored", OMEMO_TYPE_PRE_KEY_STORE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OMEMO_PRE_KEY_STORE_KEY, G_TYPE_NONE, 1, OMEMO_PRE_KEY_STORE_TYPE_KEY);
	omemo_pre_key_store_signals[OMEMO_PRE_KEY_STORE_PRE_KEY_DELETED_SIGNAL] = g_signal_new ("pre-key-deleted", OMEMO_TYPE_PRE_KEY_STORE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OMEMO_PRE_KEY_STORE_KEY, G_TYPE_NONE, 1, OMEMO_PRE_KEY_STORE_TYPE_KEY);
}

static void
omemo_pre_key_store_instance_init (OmemoPreKeyStore * self,
                                   gpointer klass)
{
}

static GType
omemo_pre_key_store_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OmemoPreKeyStoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_pre_key_store_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoPreKeyStore), 0, (GInstanceInitFunc) omemo_pre_key_store_instance_init, NULL };
	GType omemo_pre_key_store_type_id;
	omemo_pre_key_store_type_id = g_type_register_static (G_TYPE_OBJECT, "OmemoPreKeyStore", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return omemo_pre_key_store_type_id;
}

GType
omemo_pre_key_store_get_type (void)
{
	static volatile gsize omemo_pre_key_store_type_id__once = 0;
	if (g_once_init_enter (&omemo_pre_key_store_type_id__once)) {
		GType omemo_pre_key_store_type_id;
		omemo_pre_key_store_type_id = omemo_pre_key_store_get_type_once ();
		g_once_init_leave (&omemo_pre_key_store_type_id__once, omemo_pre_key_store_type_id);
	}
	return omemo_pre_key_store_type_id__once;
}

static guint8*
omemo_signed_pre_key_store_real_load_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                     guint32 pre_key_id,
                                                     gint* result_length1,
                                                     GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_signed_pre_key_store_load_signed_pre_key'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

guint8*
omemo_signed_pre_key_store_load_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                guint32 pre_key_id,
                                                gint* result_length1,
                                                GError** error)
{
	OmemoSignedPreKeyStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = OMEMO_SIGNED_PRE_KEY_STORE_GET_CLASS (self);
	if (_klass_->load_signed_pre_key) {
		return _klass_->load_signed_pre_key (self, pre_key_id, result_length1, error);
	}
	return NULL;
}

static void
omemo_signed_pre_key_store_real_store_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                      guint32 pre_key_id,
                                                      guint8* record,
                                                      gint record_length1,
                                                      GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_signed_pre_key_store_store_signed_pre_key'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
omemo_signed_pre_key_store_store_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                 guint32 pre_key_id,
                                                 guint8* record,
                                                 gint record_length1,
                                                 GError** error)
{
	OmemoSignedPreKeyStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_SIGNED_PRE_KEY_STORE_GET_CLASS (self);
	if (_klass_->store_signed_pre_key) {
		_klass_->store_signed_pre_key (self, pre_key_id, record, record_length1, error);
	}
}

static gboolean
omemo_signed_pre_key_store_real_contains_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                         guint32 pre_key_id,
                                                         GError** error)
{
	gboolean _tmp0_ = FALSE;
	g_critical ("Type `%s' does not implement abstract method `omemo_signed_pre_key_store_contains_signed_pre_key'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return _tmp0_;
}

gboolean
omemo_signed_pre_key_store_contains_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                    guint32 pre_key_id,
                                                    GError** error)
{
	OmemoSignedPreKeyStoreClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = OMEMO_SIGNED_PRE_KEY_STORE_GET_CLASS (self);
	if (_klass_->contains_signed_pre_key) {
		return _klass_->contains_signed_pre_key (self, pre_key_id, error);
	}
	return FALSE;
}

static void
omemo_signed_pre_key_store_real_delete_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                       guint32 pre_key_id,
                                                       GError** error)
{
	g_critical ("Type `%s' does not implement abstract method `omemo_signed_pre_key_store_delete_signed_pre_key'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return;
}

void
omemo_signed_pre_key_store_delete_signed_pre_key (OmemoSignedPreKeyStore* self,
                                                  guint32 pre_key_id,
                                                  GError** error)
{
	OmemoSignedPreKeyStoreClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = OMEMO_SIGNED_PRE_KEY_STORE_GET_CLASS (self);
	if (_klass_->delete_signed_pre_key) {
		_klass_->delete_signed_pre_key (self, pre_key_id, error);
	}
}

OmemoSignedPreKeyStore*
omemo_signed_pre_key_store_construct (GType object_type)
{
	OmemoSignedPreKeyStore * self = NULL;
	self = (OmemoSignedPreKeyStore*) g_object_new (object_type, NULL);
	return self;
}

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

static inline gpointer
omemo_signed_pre_key_store_key_get_instance_private (OmemoSignedPreKeyStoreKey* self)
{
	return G_STRUCT_MEMBER_P (self, OmemoSignedPreKeyStoreKey_private_offset);
}

OmemoSignedPreKeyStoreKey*
omemo_signed_pre_key_store_key_construct (GType object_type,
                                          guint32 key_id,
                                          guint8* record,
                                          gint record_length1)
{
	OmemoSignedPreKeyStoreKey* self = NULL;
	self = (OmemoSignedPreKeyStoreKey*) g_type_create_instance (object_type);
	omemo_signed_pre_key_store_key_set_key_id (self, key_id);
	omemo_signed_pre_key_store_key_set_record (self, record, record_length1);
	return self;
}

OmemoSignedPreKeyStoreKey*
omemo_signed_pre_key_store_key_new (guint32 key_id,
                                    guint8* record,
                                    gint record_length1)
{
	return omemo_signed_pre_key_store_key_construct (OMEMO_SIGNED_PRE_KEY_STORE_TYPE_KEY, key_id, record, record_length1);
}

guint32
omemo_signed_pre_key_store_key_get_key_id (OmemoSignedPreKeyStoreKey* self)
{
	guint32 result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_key_id;
	return result;
}

static void
omemo_signed_pre_key_store_key_set_key_id (OmemoSignedPreKeyStoreKey* self,
                                           guint32 value)
{
	g_return_if_fail (self != NULL);
	self->priv->_key_id = value;
}

guint8*
omemo_signed_pre_key_store_key_get_record (OmemoSignedPreKeyStoreKey* self,
                                           gint* result_length1)
{
	guint8* result;
	guint8* _tmp0_;
	gint _tmp0__length1;
	guint8* _tmp1_;
	gint _tmp1__length1;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_record;
	_tmp0__length1 = self->priv->_record_length1;
	_tmp1_ = _tmp0_;
	_tmp1__length1 = _tmp0__length1;
	if (result_length1) {
		*result_length1 = _tmp1__length1;
	}
	result = _tmp1_;
	return result;
}

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

static void
omemo_signed_pre_key_store_key_set_record (OmemoSignedPreKeyStoreKey* self,
                                           guint8* value,
                                           gint value_length1)
{
	guint8* _tmp0_;
	gint _tmp0__length1;
	g_return_if_fail (self != NULL);
	_tmp0_ = (value != NULL) ? _vala_array_dup36 (value, value_length1) : value;
	_tmp0__length1 = value_length1;
	self->priv->_record = (g_free (self->priv->_record), NULL);
	self->priv->_record = _tmp0_;
	self->priv->_record_length1 = _tmp0__length1;
	self->priv->__record_size_ = self->priv->_record_length1;
}

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

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

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

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

static gchar*
omemo_signed_pre_key_store_value_key_collect_value (GValue* value,
                                                    guint n_collect_values,
                                                    GTypeCValue* collect_values,
                                                    guint collect_flags)
{
	if (collect_values[0].v_pointer) {
		OmemoSignedPreKeyStoreKey * 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 = omemo_signed_pre_key_store_key_ref (object);
	} else {
		value->data[0].v_pointer = NULL;
	}
	return NULL;
}

static gchar*
omemo_signed_pre_key_store_value_key_lcopy_value (const GValue* value,
                                                  guint n_collect_values,
                                                  GTypeCValue* collect_values,
                                                  guint collect_flags)
{
	OmemoSignedPreKeyStoreKey ** 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 = omemo_signed_pre_key_store_key_ref (value->data[0].v_pointer);
	}
	return NULL;
}

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

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

void
omemo_signed_pre_key_store_value_set_key (GValue* value,
                                          gpointer v_object)
{
	OmemoSignedPreKeyStoreKey * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, OMEMO_SIGNED_PRE_KEY_STORE_TYPE_KEY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, OMEMO_SIGNED_PRE_KEY_STORE_TYPE_KEY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
		omemo_signed_pre_key_store_key_ref (value->data[0].v_pointer);
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		omemo_signed_pre_key_store_key_unref (old);
	}
}

void
omemo_signed_pre_key_store_value_take_key (GValue* value,
                                           gpointer v_object)
{
	OmemoSignedPreKeyStoreKey * old;
	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, OMEMO_SIGNED_PRE_KEY_STORE_TYPE_KEY));
	old = value->data[0].v_pointer;
	if (v_object) {
		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, OMEMO_SIGNED_PRE_KEY_STORE_TYPE_KEY));
		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
		value->data[0].v_pointer = v_object;
	} else {
		value->data[0].v_pointer = NULL;
	}
	if (old) {
		omemo_signed_pre_key_store_key_unref (old);
	}
}

static void
omemo_signed_pre_key_store_key_class_init (OmemoSignedPreKeyStoreKeyClass * klass,
                                           gpointer klass_data)
{
	omemo_signed_pre_key_store_key_parent_class = g_type_class_peek_parent (klass);
	((OmemoSignedPreKeyStoreKeyClass *) klass)->finalize = omemo_signed_pre_key_store_key_finalize;
	g_type_class_adjust_private_offset (klass, &OmemoSignedPreKeyStoreKey_private_offset);
}

static void
omemo_signed_pre_key_store_key_instance_init (OmemoSignedPreKeyStoreKey * self,
                                              gpointer klass)
{
	self->priv = omemo_signed_pre_key_store_key_get_instance_private (self);
	self->ref_count = 1;
}

static void
omemo_signed_pre_key_store_key_finalize (OmemoSignedPreKeyStoreKey * obj)
{
	OmemoSignedPreKeyStoreKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OMEMO_SIGNED_PRE_KEY_STORE_TYPE_KEY, OmemoSignedPreKeyStoreKey);
	g_signal_handlers_destroy (self);
	self->priv->_record = (g_free (self->priv->_record), NULL);
}

static GType
omemo_signed_pre_key_store_key_get_type_once (void)
{
	static const GTypeValueTable g_define_type_value_table = { omemo_signed_pre_key_store_value_key_init, omemo_signed_pre_key_store_value_key_free_value, omemo_signed_pre_key_store_value_key_copy_value, omemo_signed_pre_key_store_value_key_peek_pointer, "p", omemo_signed_pre_key_store_value_key_collect_value, "p", omemo_signed_pre_key_store_value_key_lcopy_value };
	static const GTypeInfo g_define_type_info = { sizeof (OmemoSignedPreKeyStoreKeyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_signed_pre_key_store_key_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoSignedPreKeyStoreKey), 0, (GInstanceInitFunc) omemo_signed_pre_key_store_key_instance_init, &g_define_type_value_table };
	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
	GType omemo_signed_pre_key_store_key_type_id;
	omemo_signed_pre_key_store_key_type_id = g_type_register_fundamental (g_type_fundamental_next (), "OmemoSignedPreKeyStoreKey", &g_define_type_info, &g_define_type_fundamental_info, 0);
	OmemoSignedPreKeyStoreKey_private_offset = g_type_add_instance_private (omemo_signed_pre_key_store_key_type_id, sizeof (OmemoSignedPreKeyStoreKeyPrivate));
	return omemo_signed_pre_key_store_key_type_id;
}

GType
omemo_signed_pre_key_store_key_get_type (void)
{
	static volatile gsize omemo_signed_pre_key_store_key_type_id__once = 0;
	if (g_once_init_enter (&omemo_signed_pre_key_store_key_type_id__once)) {
		GType omemo_signed_pre_key_store_key_type_id;
		omemo_signed_pre_key_store_key_type_id = omemo_signed_pre_key_store_key_get_type_once ();
		g_once_init_leave (&omemo_signed_pre_key_store_key_type_id__once, omemo_signed_pre_key_store_key_type_id);
	}
	return omemo_signed_pre_key_store_key_type_id__once;
}

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

void
omemo_signed_pre_key_store_key_unref (gpointer instance)
{
	OmemoSignedPreKeyStoreKey * self;
	self = instance;
	if (g_atomic_int_dec_and_test (&self->ref_count)) {
		OMEMO_SIGNED_PRE_KEY_STORE_KEY_GET_CLASS (self)->finalize (self);
		g_type_free_instance ((GTypeInstance *) self);
	}
}

static void
omemo_signed_pre_key_store_class_init (OmemoSignedPreKeyStoreClass * klass,
                                       gpointer klass_data)
{
	omemo_signed_pre_key_store_parent_class = g_type_class_peek_parent (klass);
	((OmemoSignedPreKeyStoreClass *) klass)->load_signed_pre_key = (guint8* (*) (OmemoSignedPreKeyStore*, guint32, gint*, GError**)) omemo_signed_pre_key_store_real_load_signed_pre_key;
	((OmemoSignedPreKeyStoreClass *) klass)->store_signed_pre_key = (void (*) (OmemoSignedPreKeyStore*, guint32, guint8*, gint, GError**)) omemo_signed_pre_key_store_real_store_signed_pre_key;
	((OmemoSignedPreKeyStoreClass *) klass)->contains_signed_pre_key = (gboolean (*) (OmemoSignedPreKeyStore*, guint32, GError**)) omemo_signed_pre_key_store_real_contains_signed_pre_key;
	((OmemoSignedPreKeyStoreClass *) klass)->delete_signed_pre_key = (void (*) (OmemoSignedPreKeyStore*, guint32, GError**)) omemo_signed_pre_key_store_real_delete_signed_pre_key;
	omemo_signed_pre_key_store_signals[OMEMO_SIGNED_PRE_KEY_STORE_SIGNED_PRE_KEY_STORED_SIGNAL] = g_signal_new ("signed-pre-key-stored", OMEMO_TYPE_SIGNED_PRE_KEY_STORE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OMEMO_SIGNED_PRE_KEY_STORE_KEY, G_TYPE_NONE, 1, OMEMO_SIGNED_PRE_KEY_STORE_TYPE_KEY);
	omemo_signed_pre_key_store_signals[OMEMO_SIGNED_PRE_KEY_STORE_SIGNED_PRE_KEY_DELETED_SIGNAL] = g_signal_new ("signed-pre-key-deleted", OMEMO_TYPE_SIGNED_PRE_KEY_STORE, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__OMEMO_SIGNED_PRE_KEY_STORE_KEY, G_TYPE_NONE, 1, OMEMO_SIGNED_PRE_KEY_STORE_TYPE_KEY);
}

static void
omemo_signed_pre_key_store_instance_init (OmemoSignedPreKeyStore * self,
                                          gpointer klass)
{
}

static GType
omemo_signed_pre_key_store_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OmemoSignedPreKeyStoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_signed_pre_key_store_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoSignedPreKeyStore), 0, (GInstanceInitFunc) omemo_signed_pre_key_store_instance_init, NULL };
	GType omemo_signed_pre_key_store_type_id;
	omemo_signed_pre_key_store_type_id = g_type_register_static (G_TYPE_OBJECT, "OmemoSignedPreKeyStore", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return omemo_signed_pre_key_store_type_id;
}

GType
omemo_signed_pre_key_store_get_type (void)
{
	static volatile gsize omemo_signed_pre_key_store_type_id__once = 0;
	if (g_once_init_enter (&omemo_signed_pre_key_store_type_id__once)) {
		GType omemo_signed_pre_key_store_type_id;
		omemo_signed_pre_key_store_type_id = omemo_signed_pre_key_store_get_type_once ();
		g_once_init_leave (&omemo_signed_pre_key_store_type_id__once, omemo_signed_pre_key_store_type_id);
	}
	return omemo_signed_pre_key_store_type_id__once;
}

static inline gpointer
omemo_store_get_instance_private (OmemoStore* self)
{
	return G_STRUCT_MEMBER_P (self, OmemoStore_private_offset);
}

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

static gint
omemo_store_iks_get_identity_key_pair (signal_buffer** public_data,
                                       signal_buffer** private_data,
                                       void* user_data)
{
	signal_buffer* _vala_public_data = NULL;
	signal_buffer* _vala_private_data = NULL;
	OmemoStore* store = NULL;
	OmemoStore* _tmp0_;
	OmemoIdentityKeyStore* _tmp1_;
	GBytes* _tmp2_;
	GBytes* _tmp3_;
	gsize _tmp4_ = 0;
	guint8* _tmp5_;
	signal_buffer* _tmp6_;
	OmemoIdentityKeyStore* _tmp7_;
	GBytes* _tmp8_;
	GBytes* _tmp9_;
	gsize _tmp10_ = 0;
	guint8* _tmp11_;
	signal_buffer* _tmp12_;
	gint result;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	store = _tmp0_;
	_tmp1_ = store->priv->_identity_key_store;
	_tmp2_ = omemo_identity_key_store_get_identity_key_public (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp5_ = g_bytes_get_data (_tmp3_, &_tmp4_);
	_tmp6_ = signal_buffer_create (_tmp5_, _tmp4_);
	_signal_buffer_free0 (_vala_public_data);
	_vala_public_data = _tmp6_;
	_tmp7_ = store->priv->_identity_key_store;
	_tmp8_ = omemo_identity_key_store_get_identity_key_private (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp11_ = g_bytes_get_data (_tmp9_, &_tmp10_);
	_tmp12_ = signal_buffer_create (_tmp11_, _tmp10_);
	_signal_buffer_free0 (_vala_private_data);
	_vala_private_data = _tmp12_;
	result = 0;
	_g_object_unref0 (store);
	if (public_data) {
		*public_data = _vala_public_data;
	} else {
		_signal_buffer_free0 (_vala_public_data);
	}
	if (private_data) {
		*private_data = _vala_private_data;
	} else {
		_signal_buffer_free0 (_vala_private_data);
	}
	return result;
}

static gint
omemo_store_iks_get_local_registration_id (void* user_data,
                                           guint32* registration_id)
{
	guint32 _vala_registration_id = 0U;
	OmemoStore* store = NULL;
	OmemoStore* _tmp0_;
	OmemoIdentityKeyStore* _tmp1_;
	guint32 _tmp2_;
	guint32 _tmp3_;
	gint result;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	store = _tmp0_;
	_tmp1_ = store->priv->_identity_key_store;
	_tmp2_ = omemo_identity_key_store_get_local_registration_id (_tmp1_);
	_tmp3_ = _tmp2_;
	_vala_registration_id = _tmp3_;
	result = 0;
	_g_object_unref0 (store);
	if (registration_id) {
		*registration_id = _vala_registration_id;
	}
	return result;
}

static Block10Data*
block10_data_ref (Block10Data* _data10_)
{
	g_atomic_int_inc (&_data10_->_ref_count_);
	return _data10_;
}

static void
block10_data_unref (void * _userdata_)
{
	Block10Data* _data10_;
	_data10_ = (Block10Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data10_->_ref_count_)) {
		_g_object_unref0 (_data10_->store);
		g_slice_free (Block10Data, _data10_);
	}
}

static gint
__lambda4_ (Block10Data* _data10_,
            GError** error)
{
	OmemoIdentityKeyStore* _tmp0_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _data10_->store->priv->_identity_key_store;
	omemo_identity_key_store_save_identity (_tmp0_, _data10_->address, _data10_->key, (gint) _data10_->key_length1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp1_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = 0;
	return result;
}

static gint
___lambda4__omemo_code_erroring_func (gpointer self,
                                      GError** error)
{
	gint result;
	result = __lambda4_ (self, error);
	return result;
}

static gint
omemo_store_iks_save_identity (signal_protocol_address* address,
                               guint8* key,
                               gint key_length1,
                               void* user_data)
{
	Block10Data* _data10_;
	OmemoStore* _tmp0_;
	gint result;
	g_return_val_if_fail (address != NULL, -1);
	_data10_ = g_slice_new0 (Block10Data);
	_data10_->_ref_count_ = 1;
	_data10_->address = address;
	_data10_->key = key;
	_data10_->key_length1 = key_length1;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data10_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda4__omemo_code_erroring_func, _data10_);
	block10_data_unref (_data10_);
	_data10_ = NULL;
	return result;
}

static Block11Data*
block11_data_ref (Block11Data* _data11_)
{
	g_atomic_int_inc (&_data11_->_ref_count_);
	return _data11_;
}

static void
block11_data_unref (void * _userdata_)
{
	Block11Data* _data11_;
	_data11_ = (Block11Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data11_->_ref_count_)) {
		_g_object_unref0 (_data11_->store);
		g_slice_free (Block11Data, _data11_);
	}
}

static gint
__lambda5_ (Block11Data* _data11_,
            GError** error)
{
	gint _tmp0_ = 0;
	gboolean _tmp1_ = FALSE;
	OmemoIdentityKeyStore* _tmp2_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp2_ = _data11_->store->priv->_identity_key_store;
	_tmp1_ = omemo_identity_key_store_is_trusted_identity (_tmp2_, _data11_->address, _data11_->key, (gint) _data11_->key_length1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp3_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	if (_tmp1_) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	result = _tmp0_;
	return result;
}

static gint
___lambda5__omemo_code_erroring_func (gpointer self,
                                      GError** error)
{
	gint result;
	result = __lambda5_ (self, error);
	return result;
}

static gint
omemo_store_iks_is_trusted_identity (signal_protocol_address* address,
                                     guint8* key,
                                     gint key_length1,
                                     void* user_data)
{
	Block11Data* _data11_;
	OmemoStore* _tmp0_;
	gint result;
	g_return_val_if_fail (address != NULL, -1);
	_data11_ = g_slice_new0 (Block11Data);
	_data11_->_ref_count_ = 1;
	_data11_->address = address;
	_data11_->key = key;
	_data11_->key_length1 = key_length1;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data11_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda5__omemo_code_erroring_func, _data11_);
	block11_data_unref (_data11_);
	_data11_ = NULL;
	return result;
}

static void
omemo_store_iks_destroy_func (void* user_data)
{
}

static gint
omemo_store_ss_load_session_func (signal_buffer** record,
                                  signal_buffer** user_record,
                                  signal_protocol_address* address,
                                  void* user_data)
{
	signal_buffer* _vala_record = NULL;
	signal_buffer* _vala_user_record = NULL;
	OmemoStore* store = NULL;
	OmemoStore* _tmp0_;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	guint8* _tmp9_;
	gint _tmp9__length1;
	guint8* _tmp10_;
	gint _tmp10__length1;
	signal_buffer* _tmp11_;
	signal_buffer* _tmp12_;
	GError* _inner_error0_ = NULL;
	gint result;
	g_return_val_if_fail (address != NULL, -1);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	store = _tmp0_;
	_signal_buffer_free0 (_vala_user_record);
	_vala_user_record = NULL;
	res = NULL;
	res_length1 = 0;
	_res_size_ = res_length1;
	{
		guint8* _tmp1_ = NULL;
		OmemoStore* _tmp2_;
		OmemoSessionStore* _tmp3_;
		gint _tmp4_ = 0;
		guint8* _tmp5_;
		gint _tmp1__length1;
		gint __tmp1__size_;
		guint8* _tmp6_;
		gint _tmp6__length1;
		_tmp2_ = store;
		_tmp3_ = _tmp2_->priv->_session_store;
		_tmp5_ = omemo_session_store_load_session (_tmp3_, address, &_tmp4_, &_inner_error0_);
		_tmp1_ = _tmp5_;
		_tmp1__length1 = _tmp4_;
		__tmp1__size_ = _tmp1__length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = _tmp1_;
		_tmp6__length1 = _tmp1__length1;
		_tmp1_ = NULL;
		_tmp1__length1 = 0;
		res = (g_free (res), NULL);
		res = _tmp6_;
		res_length1 = _tmp6__length1;
		_res_size_ = res_length1;
		_tmp1_ = (g_free (_tmp1_), NULL);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_signal_buffer_free0 (_vala_record);
		_vala_record = NULL;
		_tmp7_ = e;
		result = _tmp7_->code;
		_g_error_free0 (e);
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		if (user_record) {
			*user_record = _vala_user_record;
		} else {
			_signal_buffer_free0 (_vala_user_record);
		}
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp8_ = -1;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		_signal_buffer_free0 (_vala_record);
		_signal_buffer_free0 (_vala_user_record);
		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 _tmp8_;
	}
	_tmp9_ = res;
	_tmp9__length1 = res_length1;
	if (_tmp9_ == NULL) {
		_signal_buffer_free0 (_vala_record);
		_vala_record = NULL;
		result = 0;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		if (user_record) {
			*user_record = _vala_user_record;
		} else {
			_signal_buffer_free0 (_vala_user_record);
		}
		return result;
	}
	_tmp10_ = res;
	_tmp10__length1 = res_length1;
	_tmp11_ = signal_buffer_create ((guint8*) _tmp10_, (_tmp10__length1 * sizeof (guint8)) / sizeof (guint8));
	_signal_buffer_free0 (_vala_record);
	_vala_record = _tmp11_;
	_tmp12_ = _vala_record;
	if (_tmp12_ == NULL) {
		result = (gint) SG_ERR_NOMEM;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		if (user_record) {
			*user_record = _vala_user_record;
		} else {
			_signal_buffer_free0 (_vala_user_record);
		}
		return result;
	}
	result = 1;
	res = (g_free (res), NULL);
	_g_object_unref0 (store);
	if (record) {
		*record = _vala_record;
	} else {
		_signal_buffer_free0 (_vala_record);
	}
	if (user_record) {
		*user_record = _vala_user_record;
	} else {
		_signal_buffer_free0 (_vala_user_record);
	}
	return result;
}

static gint
omemo_store_ss_get_sub_device_sessions_func (signal_int_list** sessions,
                                             gchar* name,
                                             gint name_length1,
                                             void* user_data)
{
	signal_int_list* _vala_sessions = NULL;
	OmemoStore* store = NULL;
	OmemoStore* _tmp0_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	store = _tmp0_;
	{
		signal_int_list* _tmp1_ = NULL;
		OmemoStore* _tmp2_;
		OmemoSessionStore* _tmp3_;
		gchar* _tmp4_;
		gchar* _tmp5_;
		signal_int_list* _tmp6_;
		signal_int_list* _tmp7_;
		signal_int_list* _tmp8_;
		_tmp2_ = store;
		_tmp3_ = _tmp2_->priv->_session_store;
		_tmp4_ = omemo_carr_to_string (name, (gint) name_length1);
		_tmp5_ = _tmp4_;
		_tmp6_ = omemo_session_store_get_sub_device_sessions (_tmp3_, _tmp5_, &_inner_error0_);
		_tmp7_ = _tmp6_;
		_g_free0 (_tmp5_);
		_tmp1_ = _tmp7_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp8_ = _tmp1_;
		_tmp1_ = NULL;
		_signal_int_list_free0 (_vala_sessions);
		_vala_sessions = _tmp8_;
		_signal_int_list_free0 (_tmp1_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp9_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_signal_int_list_free0 (_vala_sessions);
		_vala_sessions = NULL;
		_tmp9_ = e;
		result = _tmp9_->code;
		_g_error_free0 (e);
		_g_object_unref0 (store);
		if (sessions) {
			*sessions = _vala_sessions;
		} else {
			_signal_int_list_free0 (_vala_sessions);
		}
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp10_ = -1;
		_g_object_unref0 (store);
		_signal_int_list_free0 (_vala_sessions);
		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 _tmp10_;
	}
	result = 0;
	_g_object_unref0 (store);
	if (sessions) {
		*sessions = _vala_sessions;
	} else {
		_signal_int_list_free0 (_vala_sessions);
	}
	return result;
}

static Block12Data*
block12_data_ref (Block12Data* _data12_)
{
	g_atomic_int_inc (&_data12_->_ref_count_);
	return _data12_;
}

static void
block12_data_unref (void * _userdata_)
{
	Block12Data* _data12_;
	_data12_ = (Block12Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data12_->_ref_count_)) {
		_g_object_unref0 (_data12_->store);
		g_slice_free (Block12Data, _data12_);
	}
}

static gint
__lambda6_ (Block12Data* _data12_,
            GError** error)
{
	OmemoSessionStore* _tmp0_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _data12_->store->priv->_session_store;
	omemo_session_store_store_session (_tmp0_, _data12_->address, _data12_->record, (gint) _data12_->record_length1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp1_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = 0;
	return result;
}

static gint
___lambda6__omemo_code_erroring_func (gpointer self,
                                      GError** error)
{
	gint result;
	result = __lambda6_ (self, error);
	return result;
}

static gint
omemo_store_ss_store_session_func (signal_protocol_address* address,
                                   guint8* record,
                                   gint record_length1,
                                   guint8* user_record,
                                   gint user_record_length1,
                                   void* user_data)
{
	Block12Data* _data12_;
	OmemoStore* _tmp0_;
	gint result;
	g_return_val_if_fail (address != NULL, -1);
	_data12_ = g_slice_new0 (Block12Data);
	_data12_->_ref_count_ = 1;
	_data12_->address = address;
	_data12_->record = record;
	_data12_->record_length1 = record_length1;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data12_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda6__omemo_code_erroring_func, _data12_);
	block12_data_unref (_data12_);
	_data12_ = NULL;
	return result;
}

static Block13Data*
block13_data_ref (Block13Data* _data13_)
{
	g_atomic_int_inc (&_data13_->_ref_count_);
	return _data13_;
}

static void
block13_data_unref (void * _userdata_)
{
	Block13Data* _data13_;
	_data13_ = (Block13Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data13_->_ref_count_)) {
		_g_object_unref0 (_data13_->store);
		g_slice_free (Block13Data, _data13_);
	}
}

static gint
__lambda7_ (Block13Data* _data13_,
            GError** error)
{
	gint _tmp0_ = 0;
	gboolean _tmp1_ = FALSE;
	OmemoSessionStore* _tmp2_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp2_ = _data13_->store->priv->_session_store;
	_tmp1_ = omemo_session_store_contains_session (_tmp2_, _data13_->address, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp3_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	if (_tmp1_) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	result = _tmp0_;
	return result;
}

static gint
___lambda7__omemo_code_erroring_func (gpointer self,
                                      GError** error)
{
	gint result;
	result = __lambda7_ (self, error);
	return result;
}

static gint
omemo_store_ss_contains_session_func (signal_protocol_address* address,
                                      void* user_data)
{
	Block13Data* _data13_;
	OmemoStore* _tmp0_;
	gint result;
	g_return_val_if_fail (address != NULL, -1);
	_data13_ = g_slice_new0 (Block13Data);
	_data13_->_ref_count_ = 1;
	_data13_->address = address;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data13_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda7__omemo_code_erroring_func, _data13_);
	block13_data_unref (_data13_);
	_data13_ = NULL;
	return result;
}

static Block14Data*
block14_data_ref (Block14Data* _data14_)
{
	g_atomic_int_inc (&_data14_->_ref_count_);
	return _data14_;
}

static void
block14_data_unref (void * _userdata_)
{
	Block14Data* _data14_;
	_data14_ = (Block14Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data14_->_ref_count_)) {
		_g_object_unref0 (_data14_->store);
		g_slice_free (Block14Data, _data14_);
	}
}

static gint
__lambda8_ (Block14Data* _data14_,
            GError** error)
{
	OmemoSessionStore* _tmp0_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _data14_->store->priv->_session_store;
	omemo_session_store_delete_session (_tmp0_, _data14_->address, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp1_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = 0;
	return result;
}

static gint
___lambda8__omemo_code_erroring_func (gpointer self,
                                      GError** error)
{
	gint result;
	result = __lambda8_ (self, error);
	return result;
}

static gint
omemo_store_ss_delete_session_func (signal_protocol_address* address,
                                    void* user_data)
{
	Block14Data* _data14_;
	OmemoStore* _tmp0_;
	gint result;
	g_return_val_if_fail (address != NULL, -1);
	_data14_ = g_slice_new0 (Block14Data);
	_data14_->_ref_count_ = 1;
	_data14_->address = address;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data14_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda8__omemo_code_erroring_func, _data14_);
	block14_data_unref (_data14_);
	_data14_ = NULL;
	return result;
}

static Block15Data*
block15_data_ref (Block15Data* _data15_)
{
	g_atomic_int_inc (&_data15_->_ref_count_);
	return _data15_;
}

static void
block15_data_unref (void * _userdata_)
{
	Block15Data* _data15_;
	_data15_ = (Block15Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data15_->_ref_count_)) {
		_g_object_unref0 (_data15_->store);
		g_slice_free (Block15Data, _data15_);
	}
}

static gint
__lambda9_ (Block15Data* _data15_,
            GError** error)
{
	OmemoSessionStore* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _data15_->store->priv->_session_store;
	_tmp1_ = omemo_carr_to_string (_data15_->name, (gint) _data15_->name_length1);
	_tmp2_ = _tmp1_;
	omemo_session_store_delete_all_sessions (_tmp0_, _tmp2_, &_inner_error0_);
	_g_free0 (_tmp2_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp3_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	result = 0;
	return result;
}

static gint
___lambda9__omemo_code_erroring_func (gpointer self,
                                      GError** error)
{
	gint result;
	result = __lambda9_ (self, error);
	return result;
}

static gint
omemo_store_ss_delete_all_sessions_func (gchar* name,
                                         gint name_length1,
                                         void* user_data)
{
	Block15Data* _data15_;
	OmemoStore* _tmp0_;
	gint result;
	_data15_ = g_slice_new0 (Block15Data);
	_data15_->_ref_count_ = 1;
	_data15_->name = name;
	_data15_->name_length1 = name_length1;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data15_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda9__omemo_code_erroring_func, _data15_);
	block15_data_unref (_data15_);
	_data15_ = NULL;
	return result;
}

static void
omemo_store_ss_destroy_func (void* user_data)
{
}

static gint
omemo_store_pks_load_pre_key (signal_buffer** record,
                              guint32 pre_key_id,
                              void* user_data)
{
	signal_buffer* _vala_record = NULL;
	OmemoStore* store = NULL;
	OmemoStore* _tmp0_;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	guint8* _tmp9_;
	gint _tmp9__length1;
	guint8* _tmp11_;
	gint _tmp11__length1;
	signal_buffer* _tmp12_;
	signal_buffer* _tmp13_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	store = _tmp0_;
	res = NULL;
	res_length1 = 0;
	_res_size_ = res_length1;
	{
		guint8* _tmp1_ = NULL;
		OmemoStore* _tmp2_;
		OmemoPreKeyStore* _tmp3_;
		gint _tmp4_ = 0;
		guint8* _tmp5_;
		gint _tmp1__length1;
		gint __tmp1__size_;
		guint8* _tmp6_;
		gint _tmp6__length1;
		_tmp2_ = store;
		_tmp3_ = _tmp2_->priv->_pre_key_store;
		_tmp5_ = omemo_pre_key_store_load_pre_key (_tmp3_, pre_key_id, &_tmp4_, &_inner_error0_);
		_tmp1_ = _tmp5_;
		_tmp1__length1 = _tmp4_;
		__tmp1__size_ = _tmp1__length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = _tmp1_;
		_tmp6__length1 = _tmp1__length1;
		_tmp1_ = NULL;
		_tmp1__length1 = 0;
		res = (g_free (res), NULL);
		res = _tmp6_;
		res_length1 = _tmp6__length1;
		_res_size_ = res_length1;
		_tmp1_ = (g_free (_tmp1_), NULL);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_signal_buffer_free0 (_vala_record);
		_vala_record = NULL;
		_tmp7_ = e;
		result = _tmp7_->code;
		_g_error_free0 (e);
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp8_ = -1;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		_signal_buffer_free0 (_vala_record);
		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 _tmp8_;
	}
	_tmp9_ = res;
	_tmp9__length1 = res_length1;
	if (_tmp9_ == NULL) {
		signal_buffer* _tmp10_;
		_tmp10_ = signal_buffer_alloc ((gsize) 0);
		_signal_buffer_free0 (_vala_record);
		_vala_record = _tmp10_;
		result = 0;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		return result;
	}
	_tmp11_ = res;
	_tmp11__length1 = res_length1;
	_tmp12_ = signal_buffer_create ((guint8*) _tmp11_, (_tmp11__length1 * sizeof (guint8)) / sizeof (guint8));
	_signal_buffer_free0 (_vala_record);
	_vala_record = _tmp12_;
	_tmp13_ = _vala_record;
	if (_tmp13_ == NULL) {
		result = (gint) SG_ERR_NOMEM;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		return result;
	}
	result = 1;
	res = (g_free (res), NULL);
	_g_object_unref0 (store);
	if (record) {
		*record = _vala_record;
	} else {
		_signal_buffer_free0 (_vala_record);
	}
	return result;
}

static Block16Data*
block16_data_ref (Block16Data* _data16_)
{
	g_atomic_int_inc (&_data16_->_ref_count_);
	return _data16_;
}

static void
block16_data_unref (void * _userdata_)
{
	Block16Data* _data16_;
	_data16_ = (Block16Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data16_->_ref_count_)) {
		_g_object_unref0 (_data16_->store);
		g_slice_free (Block16Data, _data16_);
	}
}

static gint
__lambda10_ (Block16Data* _data16_,
             GError** error)
{
	OmemoPreKeyStore* _tmp0_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _data16_->store->priv->_pre_key_store;
	omemo_pre_key_store_store_pre_key (_tmp0_, _data16_->pre_key_id, _data16_->record, (gint) _data16_->record_length1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp1_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = 0;
	return result;
}

static gint
___lambda10__omemo_code_erroring_func (gpointer self,
                                       GError** error)
{
	gint result;
	result = __lambda10_ (self, error);
	return result;
}

static gint
omemo_store_pks_store_pre_key (guint32 pre_key_id,
                               guint8* record,
                               gint record_length1,
                               void* user_data)
{
	Block16Data* _data16_;
	OmemoStore* _tmp0_;
	gint result;
	_data16_ = g_slice_new0 (Block16Data);
	_data16_->_ref_count_ = 1;
	_data16_->pre_key_id = pre_key_id;
	_data16_->record = record;
	_data16_->record_length1 = record_length1;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data16_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda10__omemo_code_erroring_func, _data16_);
	block16_data_unref (_data16_);
	_data16_ = NULL;
	return result;
}

static Block17Data*
block17_data_ref (Block17Data* _data17_)
{
	g_atomic_int_inc (&_data17_->_ref_count_);
	return _data17_;
}

static void
block17_data_unref (void * _userdata_)
{
	Block17Data* _data17_;
	_data17_ = (Block17Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data17_->_ref_count_)) {
		_g_object_unref0 (_data17_->store);
		g_slice_free (Block17Data, _data17_);
	}
}

static gint
__lambda11_ (Block17Data* _data17_,
             GError** error)
{
	gint _tmp0_ = 0;
	gboolean _tmp1_ = FALSE;
	OmemoPreKeyStore* _tmp2_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp2_ = _data17_->store->priv->_pre_key_store;
	_tmp1_ = omemo_pre_key_store_contains_pre_key (_tmp2_, _data17_->pre_key_id, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp3_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	if (_tmp1_) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	result = _tmp0_;
	return result;
}

static gint
___lambda11__omemo_code_erroring_func (gpointer self,
                                       GError** error)
{
	gint result;
	result = __lambda11_ (self, error);
	return result;
}

static gint
omemo_store_pks_contains_pre_key (guint32 pre_key_id,
                                  void* user_data)
{
	Block17Data* _data17_;
	OmemoStore* _tmp0_;
	gint result;
	_data17_ = g_slice_new0 (Block17Data);
	_data17_->_ref_count_ = 1;
	_data17_->pre_key_id = pre_key_id;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data17_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda11__omemo_code_erroring_func, _data17_);
	block17_data_unref (_data17_);
	_data17_ = NULL;
	return result;
}

static Block18Data*
block18_data_ref (Block18Data* _data18_)
{
	g_atomic_int_inc (&_data18_->_ref_count_);
	return _data18_;
}

static void
block18_data_unref (void * _userdata_)
{
	Block18Data* _data18_;
	_data18_ = (Block18Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data18_->_ref_count_)) {
		_g_object_unref0 (_data18_->store);
		g_slice_free (Block18Data, _data18_);
	}
}

static gint
__lambda12_ (Block18Data* _data18_,
             GError** error)
{
	OmemoPreKeyStore* _tmp0_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _data18_->store->priv->_pre_key_store;
	omemo_pre_key_store_delete_pre_key (_tmp0_, _data18_->pre_key_id, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp1_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = 0;
	return result;
}

static gint
___lambda12__omemo_code_erroring_func (gpointer self,
                                       GError** error)
{
	gint result;
	result = __lambda12_ (self, error);
	return result;
}

static gint
omemo_store_pks_remove_pre_key (guint32 pre_key_id,
                                void* user_data)
{
	Block18Data* _data18_;
	OmemoStore* _tmp0_;
	gint result;
	_data18_ = g_slice_new0 (Block18Data);
	_data18_->_ref_count_ = 1;
	_data18_->pre_key_id = pre_key_id;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data18_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda12__omemo_code_erroring_func, _data18_);
	block18_data_unref (_data18_);
	_data18_ = NULL;
	return result;
}

static void
omemo_store_pks_destroy_func (void* user_data)
{
}

static gint
omemo_store_spks_load_signed_pre_key (signal_buffer** record,
                                      guint32 pre_key_id,
                                      void* user_data)
{
	signal_buffer* _vala_record = NULL;
	OmemoStore* store = NULL;
	OmemoStore* _tmp0_;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	guint8* _tmp9_;
	gint _tmp9__length1;
	guint8* _tmp11_;
	gint _tmp11__length1;
	signal_buffer* _tmp12_;
	signal_buffer* _tmp13_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	store = _tmp0_;
	res = NULL;
	res_length1 = 0;
	_res_size_ = res_length1;
	{
		guint8* _tmp1_ = NULL;
		OmemoStore* _tmp2_;
		OmemoSignedPreKeyStore* _tmp3_;
		gint _tmp4_ = 0;
		guint8* _tmp5_;
		gint _tmp1__length1;
		gint __tmp1__size_;
		guint8* _tmp6_;
		gint _tmp6__length1;
		_tmp2_ = store;
		_tmp3_ = _tmp2_->priv->_signed_pre_key_store;
		_tmp5_ = omemo_signed_pre_key_store_load_signed_pre_key (_tmp3_, pre_key_id, &_tmp4_, &_inner_error0_);
		_tmp1_ = _tmp5_;
		_tmp1__length1 = _tmp4_;
		__tmp1__size_ = _tmp1__length1;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp6_ = _tmp1_;
		_tmp6__length1 = _tmp1__length1;
		_tmp1_ = NULL;
		_tmp1__length1 = 0;
		res = (g_free (res), NULL);
		res = _tmp6_;
		res_length1 = _tmp6__length1;
		_res_size_ = res_length1;
		_tmp1_ = (g_free (_tmp1_), NULL);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_signal_buffer_free0 (_vala_record);
		_vala_record = NULL;
		_tmp7_ = e;
		result = _tmp7_->code;
		_g_error_free0 (e);
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		return result;
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp8_ = -1;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		_signal_buffer_free0 (_vala_record);
		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 _tmp8_;
	}
	_tmp9_ = res;
	_tmp9__length1 = res_length1;
	if (_tmp9_ == NULL) {
		signal_buffer* _tmp10_;
		_tmp10_ = signal_buffer_alloc ((gsize) 0);
		_signal_buffer_free0 (_vala_record);
		_vala_record = _tmp10_;
		result = 0;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		return result;
	}
	_tmp11_ = res;
	_tmp11__length1 = res_length1;
	_tmp12_ = signal_buffer_create ((guint8*) _tmp11_, (_tmp11__length1 * sizeof (guint8)) / sizeof (guint8));
	_signal_buffer_free0 (_vala_record);
	_vala_record = _tmp12_;
	_tmp13_ = _vala_record;
	if (_tmp13_ == NULL) {
		result = (gint) SG_ERR_NOMEM;
		res = (g_free (res), NULL);
		_g_object_unref0 (store);
		if (record) {
			*record = _vala_record;
		} else {
			_signal_buffer_free0 (_vala_record);
		}
		return result;
	}
	result = 1;
	res = (g_free (res), NULL);
	_g_object_unref0 (store);
	if (record) {
		*record = _vala_record;
	} else {
		_signal_buffer_free0 (_vala_record);
	}
	return result;
}

static Block19Data*
block19_data_ref (Block19Data* _data19_)
{
	g_atomic_int_inc (&_data19_->_ref_count_);
	return _data19_;
}

static void
block19_data_unref (void * _userdata_)
{
	Block19Data* _data19_;
	_data19_ = (Block19Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data19_->_ref_count_)) {
		_g_object_unref0 (_data19_->store);
		g_slice_free (Block19Data, _data19_);
	}
}

static gint
__lambda13_ (Block19Data* _data19_,
             GError** error)
{
	OmemoSignedPreKeyStore* _tmp0_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _data19_->store->priv->_signed_pre_key_store;
	omemo_signed_pre_key_store_store_signed_pre_key (_tmp0_, _data19_->pre_key_id, _data19_->record, (gint) _data19_->record_length1, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp1_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = 0;
	return result;
}

static gint
___lambda13__omemo_code_erroring_func (gpointer self,
                                       GError** error)
{
	gint result;
	result = __lambda13_ (self, error);
	return result;
}

static gint
omemo_store_spks_store_signed_pre_key (guint32 pre_key_id,
                                       guint8* record,
                                       gint record_length1,
                                       void* user_data)
{
	Block19Data* _data19_;
	OmemoStore* _tmp0_;
	gint result;
	_data19_ = g_slice_new0 (Block19Data);
	_data19_->_ref_count_ = 1;
	_data19_->pre_key_id = pre_key_id;
	_data19_->record = record;
	_data19_->record_length1 = record_length1;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data19_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda13__omemo_code_erroring_func, _data19_);
	block19_data_unref (_data19_);
	_data19_ = NULL;
	return result;
}

static Block20Data*
block20_data_ref (Block20Data* _data20_)
{
	g_atomic_int_inc (&_data20_->_ref_count_);
	return _data20_;
}

static void
block20_data_unref (void * _userdata_)
{
	Block20Data* _data20_;
	_data20_ = (Block20Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data20_->_ref_count_)) {
		_g_object_unref0 (_data20_->store);
		g_slice_free (Block20Data, _data20_);
	}
}

static gint
__lambda14_ (Block20Data* _data20_,
             GError** error)
{
	gint _tmp0_ = 0;
	gboolean _tmp1_ = FALSE;
	OmemoSignedPreKeyStore* _tmp2_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp2_ = _data20_->store->priv->_signed_pre_key_store;
	_tmp1_ = omemo_signed_pre_key_store_contains_signed_pre_key (_tmp2_, _data20_->pre_key_id, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp3_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	if (_tmp1_) {
		_tmp0_ = 1;
	} else {
		_tmp0_ = 0;
	}
	result = _tmp0_;
	return result;
}

static gint
___lambda14__omemo_code_erroring_func (gpointer self,
                                       GError** error)
{
	gint result;
	result = __lambda14_ (self, error);
	return result;
}

static gint
omemo_store_spks_contains_signed_pre_key (guint32 pre_key_id,
                                          void* user_data)
{
	Block20Data* _data20_;
	OmemoStore* _tmp0_;
	gint result;
	_data20_ = g_slice_new0 (Block20Data);
	_data20_->_ref_count_ = 1;
	_data20_->pre_key_id = pre_key_id;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data20_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda14__omemo_code_erroring_func, _data20_);
	block20_data_unref (_data20_);
	_data20_ = NULL;
	return result;
}

static Block21Data*
block21_data_ref (Block21Data* _data21_)
{
	g_atomic_int_inc (&_data21_->_ref_count_);
	return _data21_;
}

static void
block21_data_unref (void * _userdata_)
{
	Block21Data* _data21_;
	_data21_ = (Block21Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data21_->_ref_count_)) {
		_g_object_unref0 (_data21_->store);
		g_slice_free (Block21Data, _data21_);
	}
}

static gint
__lambda15_ (Block21Data* _data21_,
             GError** error)
{
	OmemoSignedPreKeyStore* _tmp0_;
	GError* _inner_error0_ = NULL;
	gint result;
	_tmp0_ = _data21_->store->priv->_signed_pre_key_store;
	omemo_signed_pre_key_store_delete_signed_pre_key (_tmp0_, _data21_->pre_key_id, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp1_ = -1;
		g_propagate_error (error, _inner_error0_);
		return _tmp1_;
	}
	result = 0;
	return result;
}

static gint
___lambda15__omemo_code_erroring_func (gpointer self,
                                       GError** error)
{
	gint result;
	result = __lambda15_ (self, error);
	return result;
}

static gint
omemo_store_spks_remove_signed_pre_key (guint32 pre_key_id,
                                        void* user_data)
{
	Block21Data* _data21_;
	OmemoStore* _tmp0_;
	gint result;
	_data21_ = g_slice_new0 (Block21Data);
	_data21_->_ref_count_ = 1;
	_data21_->pre_key_id = pre_key_id;
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (user_data, OMEMO_TYPE_STORE, OmemoStore));
	_data21_->store = _tmp0_;
	result = omemo_catch_to_code (___lambda15__omemo_code_erroring_func, _data21_);
	block21_data_unref (_data21_);
	_data21_ = NULL;
	return result;
}

static void
omemo_store_spks_destroy_func (void* user_data)
{
}

static gint
_omemo_store_iks_get_identity_key_pair_omemo_get_identity_key_pair_func (signal_buffer** public_data,
                                                                         signal_buffer** private_data,
                                                                         void* user_data)
{
	gint result;
	result = omemo_store_iks_get_identity_key_pair (public_data, private_data, user_data);
	return result;
}

static gint
_omemo_store_iks_get_local_registration_id_omemo_get_local_registration_id_func (void* user_data,
                                                                                 guint32* registration_id)
{
	gint result;
	result = omemo_store_iks_get_local_registration_id (user_data, registration_id);
	return result;
}

static gint
_omemo_store_iks_save_identity_omemo_save_identity_func (signal_protocol_address* address,
                                                         guint8* key,
                                                         size_t key_length1,
                                                         void* user_data)
{
	gint result;
	result = omemo_store_iks_save_identity (address, key, key_length1, user_data);
	return result;
}

static gint
_omemo_store_iks_is_trusted_identity_omemo_is_trusted_identity_func (signal_protocol_address* address,
                                                                     guint8* key,
                                                                     size_t key_length1,
                                                                     void* user_data)
{
	gint result;
	result = omemo_store_iks_is_trusted_identity (address, key, key_length1, user_data);
	return result;
}

static void
_omemo_store_iks_destroy_func_omemo_destroy_func (void* user_data)
{
	omemo_store_iks_destroy_func (user_data);
}

static gint
_omemo_store_ss_load_session_func_omemo_load_session_func (signal_buffer** record,
                                                           signal_buffer** user_record,
                                                           signal_protocol_address* address,
                                                           void* user_data)
{
	gint result;
	result = omemo_store_ss_load_session_func (record, user_record, address, user_data);
	return result;
}

static gint
_omemo_store_ss_get_sub_device_sessions_func_omemo_get_sub_device_sessions_func (signal_int_list** sessions,
                                                                                 gchar* name,
                                                                                 size_t name_length1,
                                                                                 void* user_data)
{
	gint result;
	result = omemo_store_ss_get_sub_device_sessions_func (sessions, name, name_length1, user_data);
	return result;
}

static gint
_omemo_store_ss_store_session_func_omemo_store_session_func (signal_protocol_address* address,
                                                             guint8* record,
                                                             size_t record_length1,
                                                             guint8* user_record,
                                                             size_t user_record_length1,
                                                             void* user_data)
{
	gint result;
	result = omemo_store_ss_store_session_func (address, record, record_length1, user_record, user_record_length1, user_data);
	return result;
}

static gint
_omemo_store_ss_contains_session_func_omemo_contains_session_func (signal_protocol_address* address,
                                                                   void* user_data)
{
	gint result;
	result = omemo_store_ss_contains_session_func (address, user_data);
	return result;
}

static gint
_omemo_store_ss_delete_session_func_omemo_delete_session_func (signal_protocol_address* address,
                                                               void* user_data)
{
	gint result;
	result = omemo_store_ss_delete_session_func (address, user_data);
	return result;
}

static gint
_omemo_store_ss_delete_all_sessions_func_omemo_delete_all_sessions_func (gchar* name,
                                                                         size_t name_length1,
                                                                         void* user_data)
{
	gint result;
	result = omemo_store_ss_delete_all_sessions_func (name, name_length1, user_data);
	return result;
}

static void
_omemo_store_ss_destroy_func_omemo_destroy_func (void* user_data)
{
	omemo_store_ss_destroy_func (user_data);
}

static gint
_omemo_store_pks_load_pre_key_omemo_load_pre_key_func (signal_buffer** record,
                                                       guint32 pre_key_id,
                                                       void* user_data)
{
	gint result;
	result = omemo_store_pks_load_pre_key (record, pre_key_id, user_data);
	return result;
}

static gint
_omemo_store_pks_store_pre_key_omemo_store_pre_key_func (guint32 pre_key_id,
                                                         guint8* record,
                                                         size_t record_length1,
                                                         void* user_data)
{
	gint result;
	result = omemo_store_pks_store_pre_key (pre_key_id, record, record_length1, user_data);
	return result;
}

static gint
_omemo_store_pks_contains_pre_key_omemo_contains_pre_key_func (guint32 pre_key_id,
                                                               void* user_data)
{
	gint result;
	result = omemo_store_pks_contains_pre_key (pre_key_id, user_data);
	return result;
}

static gint
_omemo_store_pks_remove_pre_key_omemo_remove_pre_key_func (guint32 pre_key_id,
                                                           void* user_data)
{
	gint result;
	result = omemo_store_pks_remove_pre_key (pre_key_id, user_data);
	return result;
}

static void
_omemo_store_pks_destroy_func_omemo_destroy_func (void* user_data)
{
	omemo_store_pks_destroy_func (user_data);
}

static gint
_omemo_store_spks_load_signed_pre_key_omemo_load_pre_key_func (signal_buffer** record,
                                                               guint32 pre_key_id,
                                                               void* user_data)
{
	gint result;
	result = omemo_store_spks_load_signed_pre_key (record, pre_key_id, user_data);
	return result;
}

static gint
_omemo_store_spks_store_signed_pre_key_omemo_store_pre_key_func (guint32 pre_key_id,
                                                                 guint8* record,
                                                                 size_t record_length1,
                                                                 void* user_data)
{
	gint result;
	result = omemo_store_spks_store_signed_pre_key (pre_key_id, record, record_length1, user_data);
	return result;
}

static gint
_omemo_store_spks_contains_signed_pre_key_omemo_contains_pre_key_func (guint32 pre_key_id,
                                                                       void* user_data)
{
	gint result;
	result = omemo_store_spks_contains_signed_pre_key (pre_key_id, user_data);
	return result;
}

static gint
_omemo_store_spks_remove_signed_pre_key_omemo_remove_pre_key_func (guint32 pre_key_id,
                                                                   void* user_data)
{
	gint result;
	result = omemo_store_spks_remove_signed_pre_key (pre_key_id, user_data);
	return result;
}

static void
_omemo_store_spks_destroy_func_omemo_destroy_func (void* user_data)
{
	omemo_store_spks_destroy_func (user_data);
}

OmemoStore*
omemo_store_construct (GType object_type,
                       OmemoContext* context)
{
	OmemoStore * self = NULL;
	signal_context* _tmp0_;
	signal_protocol_store_context* _tmp1_ = NULL;
	signal_protocol_identity_key_store iks = {0};
	signal_protocol_identity_key_store _tmp2_ = {0};
	signal_protocol_store_context* _tmp3_;
	signal_protocol_store_context* _tmp4_;
	signal_protocol_identity_key_store _tmp5_;
	signal_protocol_session_store ss = {0};
	signal_protocol_session_store _tmp6_ = {0};
	signal_protocol_store_context* _tmp7_;
	signal_protocol_store_context* _tmp8_;
	signal_protocol_session_store _tmp9_;
	signal_protocol_pre_key_store pks = {0};
	signal_protocol_pre_key_store _tmp10_ = {0};
	signal_protocol_store_context* _tmp11_;
	signal_protocol_store_context* _tmp12_;
	signal_protocol_pre_key_store _tmp13_;
	signal_protocol_signed_pre_key_store spks = {0};
	signal_protocol_signed_pre_key_store _tmp14_ = {0};
	signal_protocol_store_context* _tmp15_;
	signal_protocol_store_context* _tmp16_;
	signal_protocol_signed_pre_key_store _tmp17_;
	g_return_val_if_fail (context != NULL, NULL);
	self = (OmemoStore*) g_object_new (object_type, NULL);
	omemo_store_set_context (self, context);
	_tmp0_ = context->native_context;
	signal_protocol_store_context_create (&_tmp1_, _tmp0_);
	_signal_protocol_store_context_destroy0 (self->priv->native_store_context_);
	self->priv->native_store_context_ = _tmp1_;
	memset (&_tmp2_, 0, sizeof (signal_protocol_identity_key_store));
	_tmp2_.get_identity_key_pair = _omemo_store_iks_get_identity_key_pair_omemo_get_identity_key_pair_func;
	_tmp2_.get_local_registration_id = _omemo_store_iks_get_local_registration_id_omemo_get_local_registration_id_func;
	_tmp2_.save_identity = _omemo_store_iks_save_identity_omemo_save_identity_func;
	_tmp2_.is_trusted_identity = _omemo_store_iks_is_trusted_identity_omemo_is_trusted_identity_func;
	_tmp2_.destroy_func = _omemo_store_iks_destroy_func_omemo_destroy_func;
	_tmp2_.user_data = self;
	iks = _tmp2_;
	_tmp3_ = omemo_store_get_native_context (self);
	_tmp4_ = _tmp3_;
	_tmp5_ = iks;
	signal_protocol_store_context_set_identity_key_store (_tmp4_, &_tmp5_);
	memset (&_tmp6_, 0, sizeof (signal_protocol_session_store));
	_tmp6_.load_session_func = _omemo_store_ss_load_session_func_omemo_load_session_func;
	_tmp6_.get_sub_device_sessions_func = _omemo_store_ss_get_sub_device_sessions_func_omemo_get_sub_device_sessions_func;
	_tmp6_.store_session_func = _omemo_store_ss_store_session_func_omemo_store_session_func;
	_tmp6_.contains_session_func = _omemo_store_ss_contains_session_func_omemo_contains_session_func;
	_tmp6_.delete_session_func = _omemo_store_ss_delete_session_func_omemo_delete_session_func;
	_tmp6_.delete_all_sessions_func = _omemo_store_ss_delete_all_sessions_func_omemo_delete_all_sessions_func;
	_tmp6_.destroy_func = _omemo_store_ss_destroy_func_omemo_destroy_func;
	_tmp6_.user_data = self;
	ss = _tmp6_;
	_tmp7_ = omemo_store_get_native_context (self);
	_tmp8_ = _tmp7_;
	_tmp9_ = ss;
	signal_protocol_store_context_set_session_store (_tmp8_, &_tmp9_);
	memset (&_tmp10_, 0, sizeof (signal_protocol_pre_key_store));
	_tmp10_.load_pre_key = _omemo_store_pks_load_pre_key_omemo_load_pre_key_func;
	_tmp10_.store_pre_key = _omemo_store_pks_store_pre_key_omemo_store_pre_key_func;
	_tmp10_.contains_pre_key = _omemo_store_pks_contains_pre_key_omemo_contains_pre_key_func;
	_tmp10_.remove_pre_key = _omemo_store_pks_remove_pre_key_omemo_remove_pre_key_func;
	_tmp10_.destroy_func = _omemo_store_pks_destroy_func_omemo_destroy_func;
	_tmp10_.user_data = self;
	pks = _tmp10_;
	_tmp11_ = omemo_store_get_native_context (self);
	_tmp12_ = _tmp11_;
	_tmp13_ = pks;
	signal_protocol_store_context_set_pre_key_store (_tmp12_, &_tmp13_);
	memset (&_tmp14_, 0, sizeof (signal_protocol_signed_pre_key_store));
	_tmp14_.load_signed_pre_key = _omemo_store_spks_load_signed_pre_key_omemo_load_pre_key_func;
	_tmp14_.store_signed_pre_key = _omemo_store_spks_store_signed_pre_key_omemo_store_pre_key_func;
	_tmp14_.contains_signed_pre_key = _omemo_store_spks_contains_signed_pre_key_omemo_contains_pre_key_func;
	_tmp14_.remove_signed_pre_key = _omemo_store_spks_remove_signed_pre_key_omemo_remove_pre_key_func;
	_tmp14_.destroy_func = _omemo_store_spks_destroy_func_omemo_destroy_func;
	_tmp14_.user_data = self;
	spks = _tmp14_;
	_tmp15_ = omemo_store_get_native_context (self);
	_tmp16_ = _tmp15_;
	_tmp17_ = spks;
	signal_protocol_store_context_set_signed_pre_key_store (_tmp16_, &_tmp17_);
	return self;
}

OmemoStore*
omemo_store_new (OmemoContext* context)
{
	return omemo_store_construct (OMEMO_TYPE_STORE, context);
}

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

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

session_builder*
omemo_store_create_session_builder (OmemoStore* self,
                                    signal_protocol_address* other,
                                    GError** error)
{
	session_builder* builder = NULL;
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	OmemoContext* _tmp2_;
	signal_context* _tmp3_;
	session_builder* _tmp4_ = NULL;
	gint _tmp5_;
	GError* _inner_error0_ = NULL;
	session_builder* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (other != NULL, NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->_context;
	_tmp3_ = _tmp2_->native_context;
	_tmp5_ = session_builder_create (&_tmp4_, _tmp1_, other, _tmp3_);
	_session_builder_free0 (builder);
	builder = _tmp4_;
	signal_throw_gerror_by_code_ (_tmp5_, "Error creating session builder", &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_session_builder_free0 (builder);
		return NULL;
	}
	result = builder;
	return result;
}

session_cipher*
omemo_store_create_session_cipher (OmemoStore* self,
                                   signal_protocol_address* other,
                                   GError** error)
{
	session_cipher* cipher = NULL;
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	OmemoContext* _tmp2_;
	signal_context* _tmp3_;
	session_cipher* _tmp4_ = NULL;
	gint _tmp5_;
	GError* _inner_error0_ = NULL;
	session_cipher* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (other != NULL, NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = self->priv->_context;
	_tmp3_ = _tmp2_->native_context;
	_tmp5_ = session_cipher_create (&_tmp4_, _tmp1_, other, _tmp3_);
	_session_cipher_free0 (cipher);
	cipher = _tmp4_;
	signal_throw_gerror_by_code_ (_tmp5_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_session_cipher_free0 (cipher);
		return NULL;
	}
	result = cipher;
	return result;
}

gboolean
omemo_store_is_trusted_identity (OmemoStore* self,
                                 signal_protocol_address* address,
                                 ec_public_key* key,
                                 GError** error)
{
	gint _tmp0_ = 0;
	signal_protocol_store_context* _tmp1_;
	signal_protocol_store_context* _tmp2_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (address != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	_tmp1_ = omemo_store_get_native_context (self);
	_tmp2_ = _tmp1_;
	_tmp0_ = signal_throw_gerror_by_code_ (signal_protocol_identity_is_trusted_identity (_tmp2_, address, key), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp3_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	result = _tmp0_ == 1;
	return result;
}

void
omemo_store_save_identity (OmemoStore* self,
                           signal_protocol_address* address,
                           ec_public_key* key,
                           GError** error)
{
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (address != NULL);
	g_return_if_fail (key != NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	signal_throw_gerror_by_code_ (signal_protocol_identity_save_identity (_tmp1_, address, key), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

gboolean
omemo_store_contains_session (OmemoStore* self,
                              signal_protocol_address* other,
                              GError** error)
{
	gint _tmp0_ = 0;
	signal_protocol_store_context* _tmp1_;
	signal_protocol_store_context* _tmp2_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (other != NULL, FALSE);
	_tmp1_ = omemo_store_get_native_context (self);
	_tmp2_ = _tmp1_;
	_tmp0_ = signal_throw_gerror_by_code_ (signal_protocol_session_contains_session (_tmp2_, other), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp3_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	result = _tmp0_ == 1;
	return result;
}

void
omemo_store_delete_session (OmemoStore* self,
                            signal_protocol_address* address,
                            GError** error)
{
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (address != NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	signal_throw_gerror_by_code_ (signal_protocol_session_delete_session (_tmp1_, address), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

session_record*
omemo_store_load_session (OmemoStore* self,
                          signal_protocol_address* other,
                          GError** error)
{
	session_record* record = NULL;
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	session_record* _tmp2_ = NULL;
	gint _tmp3_;
	GError* _inner_error0_ = NULL;
	session_record* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (other != NULL, NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	_tmp3_ = signal_protocol_session_load_session (_tmp1_, &_tmp2_, other, (gint32) 3);
	_signal_type_unref_vapi0 (record);
	record = _tmp2_;
	signal_throw_gerror_by_code_ (_tmp3_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_signal_type_unref_vapi0 (record);
		return NULL;
	}
	result = record;
	return result;
}

gboolean
omemo_store_contains_pre_key (OmemoStore* self,
                              guint32 pre_key_id,
                              GError** error)
{
	gint _tmp0_ = 0;
	signal_protocol_store_context* _tmp1_;
	signal_protocol_store_context* _tmp2_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = omemo_store_get_native_context (self);
	_tmp2_ = _tmp1_;
	_tmp0_ = signal_throw_gerror_by_code_ (signal_protocol_pre_key_contains_key (_tmp2_, pre_key_id), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp3_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	result = _tmp0_ == 1;
	return result;
}

void
omemo_store_store_pre_key (OmemoStore* self,
                           session_pre_key* record,
                           GError** error)
{
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (record != NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	signal_throw_gerror_by_code_ (signal_protocol_pre_key_store_key (_tmp1_, record), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

session_pre_key*
omemo_store_load_pre_key (OmemoStore* self,
                          guint32 pre_key_id,
                          GError** error)
{
	session_pre_key* res = NULL;
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	session_pre_key* _tmp2_ = NULL;
	gint _tmp3_;
	GError* _inner_error0_ = NULL;
	session_pre_key* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	_tmp3_ = signal_protocol_pre_key_load_key (_tmp1_, &_tmp2_, pre_key_id);
	_signal_type_unref_vapi0 (res);
	res = _tmp2_;
	signal_throw_gerror_by_code_ (_tmp3_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_signal_type_unref_vapi0 (res);
		return NULL;
	}
	result = res;
	return result;
}

gboolean
omemo_store_contains_signed_pre_key (OmemoStore* self,
                                     guint32 pre_key_id,
                                     GError** error)
{
	gint _tmp0_ = 0;
	signal_protocol_store_context* _tmp1_;
	signal_protocol_store_context* _tmp2_;
	GError* _inner_error0_ = NULL;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp1_ = omemo_store_get_native_context (self);
	_tmp2_ = _tmp1_;
	_tmp0_ = signal_throw_gerror_by_code_ (signal_protocol_signed_pre_key_contains_key (_tmp2_, pre_key_id), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gboolean _tmp3_ = FALSE;
		g_propagate_error (error, _inner_error0_);
		return _tmp3_;
	}
	result = _tmp0_ == 1;
	return result;
}

void
omemo_store_store_signed_pre_key (OmemoStore* self,
                                  session_signed_pre_key* record,
                                  GError** error)
{
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (record != NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	signal_throw_gerror_by_code_ (signal_protocol_signed_pre_key_store_key (_tmp1_, record), NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		return;
	}
}

session_signed_pre_key*
omemo_store_load_signed_pre_key (OmemoStore* self,
                                 guint32 pre_key_id,
                                 GError** error)
{
	session_signed_pre_key* res = NULL;
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	session_signed_pre_key* _tmp2_ = NULL;
	gint _tmp3_;
	GError* _inner_error0_ = NULL;
	session_signed_pre_key* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	_tmp3_ = signal_protocol_signed_pre_key_load_key (_tmp1_, &_tmp2_, pre_key_id);
	_signal_type_unref_vapi0 (res);
	res = _tmp2_;
	signal_throw_gerror_by_code_ (_tmp3_, NULL, &_inner_error0_);
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_propagate_error (error, _inner_error0_);
		_signal_type_unref_vapi0 (res);
		return NULL;
	}
	result = res;
	return result;
}

OmemoContext*
omemo_store_get_context (OmemoStore* self)
{
	OmemoContext* result;
	OmemoContext* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_context;
	result = _tmp0_;
	return result;
}

static gpointer
_omemo_context_ref0 (gpointer self)
{
	return self ? omemo_context_ref (self) : NULL;
}

static void
omemo_store_set_context (OmemoStore* self,
                         OmemoContext* value)
{
	OmemoContext* old_value;
	g_return_if_fail (self != NULL);
	old_value = omemo_store_get_context (self);
	if (old_value != value) {
		OmemoContext* _tmp0_;
		_tmp0_ = _omemo_context_ref0 (value);
		_omemo_context_unref0 (self->priv->_context);
		self->priv->_context = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, omemo_store_properties[OMEMO_STORE_CONTEXT_PROPERTY]);
	}
}

OmemoIdentityKeyStore*
omemo_store_get_identity_key_store (OmemoStore* self)
{
	OmemoIdentityKeyStore* result;
	OmemoIdentityKeyStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_identity_key_store;
	result = _tmp0_;
	return result;
}

void
omemo_store_set_identity_key_store (OmemoStore* self,
                                    OmemoIdentityKeyStore* value)
{
	OmemoIdentityKeyStore* old_value;
	g_return_if_fail (self != NULL);
	old_value = omemo_store_get_identity_key_store (self);
	if (old_value != value) {
		OmemoIdentityKeyStore* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_identity_key_store);
		self->priv->_identity_key_store = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, omemo_store_properties[OMEMO_STORE_IDENTITY_KEY_STORE_PROPERTY]);
	}
}

OmemoSessionStore*
omemo_store_get_session_store (OmemoStore* self)
{
	OmemoSessionStore* result;
	OmemoSessionStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_session_store;
	result = _tmp0_;
	return result;
}

void
omemo_store_set_session_store (OmemoStore* self,
                               OmemoSessionStore* value)
{
	OmemoSessionStore* old_value;
	g_return_if_fail (self != NULL);
	old_value = omemo_store_get_session_store (self);
	if (old_value != value) {
		OmemoSessionStore* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_session_store);
		self->priv->_session_store = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, omemo_store_properties[OMEMO_STORE_SESSION_STORE_PROPERTY]);
	}
}

OmemoPreKeyStore*
omemo_store_get_pre_key_store (OmemoStore* self)
{
	OmemoPreKeyStore* result;
	OmemoPreKeyStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_pre_key_store;
	result = _tmp0_;
	return result;
}

void
omemo_store_set_pre_key_store (OmemoStore* self,
                               OmemoPreKeyStore* value)
{
	OmemoPreKeyStore* old_value;
	g_return_if_fail (self != NULL);
	old_value = omemo_store_get_pre_key_store (self);
	if (old_value != value) {
		OmemoPreKeyStore* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_pre_key_store);
		self->priv->_pre_key_store = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, omemo_store_properties[OMEMO_STORE_PRE_KEY_STORE_PROPERTY]);
	}
}

OmemoSignedPreKeyStore*
omemo_store_get_signed_pre_key_store (OmemoStore* self)
{
	OmemoSignedPreKeyStore* result;
	OmemoSignedPreKeyStore* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_signed_pre_key_store;
	result = _tmp0_;
	return result;
}

void
omemo_store_set_signed_pre_key_store (OmemoStore* self,
                                      OmemoSignedPreKeyStore* value)
{
	OmemoSignedPreKeyStore* old_value;
	g_return_if_fail (self != NULL);
	old_value = omemo_store_get_signed_pre_key_store (self);
	if (old_value != value) {
		OmemoSignedPreKeyStore* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_signed_pre_key_store);
		self->priv->_signed_pre_key_store = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, omemo_store_properties[OMEMO_STORE_SIGNED_PRE_KEY_STORE_PROPERTY]);
	}
}

guint32
omemo_store_get_local_registration_id (OmemoStore* self)
{
	guint32 result;
	OmemoIdentityKeyStore* _tmp0_;
	guint32 _tmp1_;
	guint32 _tmp2_;
	g_return_val_if_fail (self != NULL, 0U);
	_tmp0_ = self->priv->_identity_key_store;
	_tmp1_ = omemo_identity_key_store_get_local_registration_id (_tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}

signal_protocol_store_context*
omemo_store_get_native_context (OmemoStore* self)
{
	signal_protocol_store_context* result;
	signal_protocol_store_context* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->native_store_context_;
	result = _tmp0_;
	return result;
}

ratchet_identity_key_pair*
omemo_store_get_identity_key_pair (OmemoStore* self)
{
	ratchet_identity_key_pair* result;
	ratchet_identity_key_pair* pair = NULL;
	signal_protocol_store_context* _tmp0_;
	signal_protocol_store_context* _tmp1_;
	ratchet_identity_key_pair* _tmp2_ = NULL;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = omemo_store_get_native_context (self);
	_tmp1_ = _tmp0_;
	signal_protocol_identity_get_key_pair (_tmp1_, &_tmp2_);
	_signal_type_unref_vapi0 (pair);
	pair = _tmp2_;
	result = pair;
	return result;
}

static void
omemo_store_class_init (OmemoStoreClass * klass,
                        gpointer klass_data)
{
	omemo_store_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &OmemoStore_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_omemo_store_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_omemo_store_set_property;
	G_OBJECT_CLASS (klass)->finalize = omemo_store_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_STORE_CONTEXT_PROPERTY, omemo_store_properties[OMEMO_STORE_CONTEXT_PROPERTY] = omemo_param_spec_context ("context", "context", "context", OMEMO_TYPE_CONTEXT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_STORE_IDENTITY_KEY_STORE_PROPERTY, omemo_store_properties[OMEMO_STORE_IDENTITY_KEY_STORE_PROPERTY] = g_param_spec_object ("identity-key-store", "identity-key-store", "identity-key-store", OMEMO_TYPE_IDENTITY_KEY_STORE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_STORE_SESSION_STORE_PROPERTY, omemo_store_properties[OMEMO_STORE_SESSION_STORE_PROPERTY] = g_param_spec_object ("session-store", "session-store", "session-store", OMEMO_TYPE_SESSION_STORE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_STORE_PRE_KEY_STORE_PROPERTY, omemo_store_properties[OMEMO_STORE_PRE_KEY_STORE_PROPERTY] = g_param_spec_object ("pre-key-store", "pre-key-store", "pre-key-store", OMEMO_TYPE_PRE_KEY_STORE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_STORE_SIGNED_PRE_KEY_STORE_PROPERTY, omemo_store_properties[OMEMO_STORE_SIGNED_PRE_KEY_STORE_PROPERTY] = g_param_spec_object ("signed-pre-key-store", "signed-pre-key-store", "signed-pre-key-store", OMEMO_TYPE_SIGNED_PRE_KEY_STORE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_STORE_LOCAL_REGISTRATION_ID_PROPERTY, omemo_store_properties[OMEMO_STORE_LOCAL_REGISTRATION_ID_PROPERTY] = g_param_spec_uint ("local-registration-id", "local-registration-id", "local-registration-id", 0, G_MAXUINT, 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_STORE_NATIVE_CONTEXT_PROPERTY, omemo_store_properties[OMEMO_STORE_NATIVE_CONTEXT_PROPERTY] = g_param_spec_pointer ("native-context", "native-context", "native-context", G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_STORE_IDENTITY_KEY_PAIR_PROPERTY, omemo_store_properties[OMEMO_STORE_IDENTITY_KEY_PAIR_PROPERTY] = g_param_spec_pointer ("identity-key-pair", "identity-key-pair", "identity-key-pair", G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
omemo_store_instance_init (OmemoStore * self,
                           gpointer klass)
{
	OmemoSimpleIdentityKeyStore* _tmp0_;
	OmemoSimpleSessionStore* _tmp1_;
	OmemoSimplePreKeyStore* _tmp2_;
	OmemoSimpleSignedPreKeyStore* _tmp3_;
	self->priv = omemo_store_get_instance_private (self);
	_tmp0_ = omemo_simple_identity_key_store_new ();
	self->priv->_identity_key_store = (OmemoIdentityKeyStore*) _tmp0_;
	_tmp1_ = omemo_simple_session_store_new ();
	self->priv->_session_store = (OmemoSessionStore*) _tmp1_;
	_tmp2_ = omemo_simple_pre_key_store_new ();
	self->priv->_pre_key_store = (OmemoPreKeyStore*) _tmp2_;
	_tmp3_ = omemo_simple_signed_pre_key_store_new ();
	self->priv->_signed_pre_key_store = (OmemoSignedPreKeyStore*) _tmp3_;
}

static void
omemo_store_finalize (GObject * obj)
{
	OmemoStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OMEMO_TYPE_STORE, OmemoStore);
	_omemo_context_unref0 (self->priv->_context);
	_g_object_unref0 (self->priv->_identity_key_store);
	_g_object_unref0 (self->priv->_session_store);
	_g_object_unref0 (self->priv->_pre_key_store);
	_g_object_unref0 (self->priv->_signed_pre_key_store);
	_signal_protocol_store_context_destroy0 (self->priv->native_store_context_);
	G_OBJECT_CLASS (omemo_store_parent_class)->finalize (obj);
}

static GType
omemo_store_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OmemoStoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_store_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoStore), 0, (GInstanceInitFunc) omemo_store_instance_init, NULL };
	GType omemo_store_type_id;
	omemo_store_type_id = g_type_register_static (G_TYPE_OBJECT, "OmemoStore", &g_define_type_info, 0);
	OmemoStore_private_offset = g_type_add_instance_private (omemo_store_type_id, sizeof (OmemoStorePrivate));
	return omemo_store_type_id;
}

GType
omemo_store_get_type (void)
{
	static volatile gsize omemo_store_type_id__once = 0;
	if (g_once_init_enter (&omemo_store_type_id__once)) {
		GType omemo_store_type_id;
		omemo_store_type_id = omemo_store_get_type_once ();
		g_once_init_leave (&omemo_store_type_id__once, omemo_store_type_id);
	}
	return omemo_store_type_id__once;
}

static void
_vala_omemo_store_get_property (GObject * object,
                                guint property_id,
                                GValue * value,
                                GParamSpec * pspec)
{
	OmemoStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OMEMO_TYPE_STORE, OmemoStore);
	switch (property_id) {
		case OMEMO_STORE_CONTEXT_PROPERTY:
		omemo_value_set_context (value, omemo_store_get_context (self));
		break;
		case OMEMO_STORE_IDENTITY_KEY_STORE_PROPERTY:
		g_value_set_object (value, omemo_store_get_identity_key_store (self));
		break;
		case OMEMO_STORE_SESSION_STORE_PROPERTY:
		g_value_set_object (value, omemo_store_get_session_store (self));
		break;
		case OMEMO_STORE_PRE_KEY_STORE_PROPERTY:
		g_value_set_object (value, omemo_store_get_pre_key_store (self));
		break;
		case OMEMO_STORE_SIGNED_PRE_KEY_STORE_PROPERTY:
		g_value_set_object (value, omemo_store_get_signed_pre_key_store (self));
		break;
		case OMEMO_STORE_LOCAL_REGISTRATION_ID_PROPERTY:
		g_value_set_uint (value, omemo_store_get_local_registration_id (self));
		break;
		case OMEMO_STORE_NATIVE_CONTEXT_PROPERTY:
		g_value_set_pointer (value, omemo_store_get_native_context (self));
		break;
		case OMEMO_STORE_IDENTITY_KEY_PAIR_PROPERTY:
		g_value_set_pointer (value, omemo_store_get_identity_key_pair (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_omemo_store_set_property (GObject * object,
                                guint property_id,
                                const GValue * value,
                                GParamSpec * pspec)
{
	OmemoStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OMEMO_TYPE_STORE, OmemoStore);
	switch (property_id) {
		case OMEMO_STORE_CONTEXT_PROPERTY:
		omemo_store_set_context (self, omemo_value_get_context (value));
		break;
		case OMEMO_STORE_IDENTITY_KEY_STORE_PROPERTY:
		omemo_store_set_identity_key_store (self, g_value_get_object (value));
		break;
		case OMEMO_STORE_SESSION_STORE_PROPERTY:
		omemo_store_set_session_store (self, g_value_get_object (value));
		break;
		case OMEMO_STORE_PRE_KEY_STORE_PROPERTY:
		omemo_store_set_pre_key_store (self, g_value_get_object (value));
		break;
		case OMEMO_STORE_SIGNED_PRE_KEY_STORE_PROPERTY:
		omemo_store_set_signed_pre_key_store (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

