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

#include "omemo.h"
#include <glib.h>
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <omemo/signal_protocol.h>
#include <native/helper.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_SIMPLE_IDENTITY_KEY_STORE_0_PROPERTY,
	OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PRIVATE_PROPERTY,
	OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PUBLIC_PROPERTY,
	OMEMO_SIMPLE_IDENTITY_KEY_STORE_LOCAL_REGISTRATION_ID_PROPERTY,
	OMEMO_SIMPLE_IDENTITY_KEY_STORE_NUM_PROPERTIES
};
static GParamSpec* omemo_simple_identity_key_store_properties[OMEMO_SIMPLE_IDENTITY_KEY_STORE_NUM_PROPERTIES];
#define _g_bytes_unref0(var) ((var == NULL) ? NULL : (var = (g_bytes_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _omemo_identity_key_store_trusted_identity_unref0(var) ((var == NULL) ? NULL : (var = (omemo_identity_key_store_trusted_identity_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))

struct _OmemoSimpleIdentityKeyStorePrivate {
	GBytes* _identity_key_private;
	GBytes* _identity_key_public;
	guint32 _local_registration_id;
	GeeMap* trusted_identities;
};

static gint OmemoSimpleIdentityKeyStore_private_offset;
static gpointer omemo_simple_identity_key_store_parent_class = NULL;

static void omemo_simple_identity_key_store_real_save_identity (OmemoIdentityKeyStore* base,
                                                         signal_protocol_address* address,
                                                         guint8* key,
                                                         gint key_length1,
                                                         GError** error);
static gboolean omemo_simple_identity_key_store_real_is_trusted_identity (OmemoIdentityKeyStore* base,
                                                                   signal_protocol_address* address,
                                                                   guint8* key,
                                                                   gint key_length1,
                                                                   GError** error);
static guint8* _vala_array_dup29 (guint8* self,
                           gssize length);
static void omemo_simple_identity_key_store_finalize (GObject * obj);
static GType omemo_simple_identity_key_store_get_type_once (void);
static void _vala_omemo_simple_identity_key_store_get_property (GObject * object,
                                                         guint property_id,
                                                         GValue * value,
                                                         GParamSpec * pspec);
static void _vala_omemo_simple_identity_key_store_set_property (GObject * object,
                                                         guint property_id,
                                                         const GValue * value,
                                                         GParamSpec * pspec);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
omemo_simple_identity_key_store_get_instance_private (OmemoSimpleIdentityKeyStore* self)
{
	return G_STRUCT_MEMBER_P (self, OmemoSimpleIdentityKeyStore_private_offset);
}

static void
omemo_simple_identity_key_store_real_save_identity (OmemoIdentityKeyStore* base,
                                                    signal_protocol_address* address,
                                                    guint8* key,
                                                    gint key_length1,
                                                    GError** error)
{
	OmemoSimpleIdentityKeyStore * self;
	gchar* name = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	GeeMap* _tmp2_;
	const gchar* _tmp3_;
	self = (OmemoSimpleIdentityKeyStore*) base;
	g_return_if_fail (address != NULL);
	_tmp0_ = signal_protocol_address_get_name (address);
	_tmp1_ = _tmp0_;
	name = _tmp1_;
	_tmp2_ = self->priv->trusted_identities;
	_tmp3_ = name;
	if (gee_map_has_key (_tmp2_, _tmp3_)) {
		GeeMap* _tmp4_;
		const gchar* _tmp5_;
		gpointer _tmp6_;
		GeeMap* _tmp7_;
		gint32 _tmp8_;
		gint32 _tmp9_;
		gboolean _tmp10_;
		_tmp4_ = self->priv->trusted_identities;
		_tmp5_ = name;
		_tmp6_ = gee_map_get (_tmp4_, _tmp5_);
		_tmp7_ = (GeeMap*) _tmp6_;
		_tmp8_ = signal_protocol_address_get_device_id (address);
		_tmp9_ = _tmp8_;
		_tmp10_ = gee_map_has_key (_tmp7_, (gpointer) ((gintptr) _tmp9_));
		_g_object_unref0 (_tmp7_);
		if (_tmp10_) {
			GeeMap* _tmp11_;
			const gchar* _tmp12_;
			gpointer _tmp13_;
			GeeMap* _tmp14_;
			gint32 _tmp15_;
			gint32 _tmp16_;
			gpointer _tmp17_;
			OmemoIdentityKeyStoreTrustedIdentity* _tmp18_;
			GeeMap* _tmp19_;
			const gchar* _tmp20_;
			gpointer _tmp21_;
			GeeMap* _tmp22_;
			gint32 _tmp23_;
			gint32 _tmp24_;
			gpointer _tmp25_;
			OmemoIdentityKeyStoreTrustedIdentity* _tmp26_;
			_tmp11_ = self->priv->trusted_identities;
			_tmp12_ = name;
			_tmp13_ = gee_map_get (_tmp11_, _tmp12_);
			_tmp14_ = (GeeMap*) _tmp13_;
			_tmp15_ = signal_protocol_address_get_device_id (address);
			_tmp16_ = _tmp15_;
			_tmp17_ = gee_map_get (_tmp14_, (gpointer) ((gintptr) _tmp16_));
			_tmp18_ = (OmemoIdentityKeyStoreTrustedIdentity*) _tmp17_;
			omemo_identity_key_store_trusted_identity_set_key (_tmp18_, key, key_length1);
			_omemo_identity_key_store_trusted_identity_unref0 (_tmp18_);
			_g_object_unref0 (_tmp14_);
			_tmp19_ = self->priv->trusted_identities;
			_tmp20_ = name;
			_tmp21_ = gee_map_get (_tmp19_, _tmp20_);
			_tmp22_ = (GeeMap*) _tmp21_;
			_tmp23_ = signal_protocol_address_get_device_id (address);
			_tmp24_ = _tmp23_;
			_tmp25_ = gee_map_get (_tmp22_, (gpointer) ((gintptr) _tmp24_));
			_tmp26_ = (OmemoIdentityKeyStoreTrustedIdentity*) _tmp25_;
			g_signal_emit_by_name ((OmemoIdentityKeyStore*) self, "trusted-identity-updated", _tmp26_);
			_omemo_identity_key_store_trusted_identity_unref0 (_tmp26_);
			_g_object_unref0 (_tmp22_);
		} else {
			GeeMap* _tmp27_;
			const gchar* _tmp28_;
			gpointer _tmp29_;
			GeeMap* _tmp30_;
			gint32 _tmp31_;
			gint32 _tmp32_;
			OmemoIdentityKeyStoreTrustedIdentity* _tmp33_;
			OmemoIdentityKeyStoreTrustedIdentity* _tmp34_;
			GeeMap* _tmp35_;
			const gchar* _tmp36_;
			gpointer _tmp37_;
			GeeMap* _tmp38_;
			gint32 _tmp39_;
			gint32 _tmp40_;
			gpointer _tmp41_;
			OmemoIdentityKeyStoreTrustedIdentity* _tmp42_;
			_tmp27_ = self->priv->trusted_identities;
			_tmp28_ = name;
			_tmp29_ = gee_map_get (_tmp27_, _tmp28_);
			_tmp30_ = (GeeMap*) _tmp29_;
			_tmp31_ = signal_protocol_address_get_device_id (address);
			_tmp32_ = _tmp31_;
			_tmp33_ = omemo_identity_key_store_trusted_identity_new_by_address (address, key, key_length1);
			_tmp34_ = _tmp33_;
			gee_map_set (_tmp30_, (gpointer) ((gintptr) _tmp32_), _tmp34_);
			_omemo_identity_key_store_trusted_identity_unref0 (_tmp34_);
			_g_object_unref0 (_tmp30_);
			_tmp35_ = self->priv->trusted_identities;
			_tmp36_ = name;
			_tmp37_ = gee_map_get (_tmp35_, _tmp36_);
			_tmp38_ = (GeeMap*) _tmp37_;
			_tmp39_ = signal_protocol_address_get_device_id (address);
			_tmp40_ = _tmp39_;
			_tmp41_ = gee_map_get (_tmp38_, (gpointer) ((gintptr) _tmp40_));
			_tmp42_ = (OmemoIdentityKeyStoreTrustedIdentity*) _tmp41_;
			g_signal_emit_by_name ((OmemoIdentityKeyStore*) self, "trusted-identity-added", _tmp42_);
			_omemo_identity_key_store_trusted_identity_unref0 (_tmp42_);
			_g_object_unref0 (_tmp38_);
		}
	} else {
		GeeMap* _tmp43_;
		const gchar* _tmp44_;
		GeeHashMap* _tmp45_;
		GeeHashMap* _tmp46_;
		GeeMap* _tmp47_;
		const gchar* _tmp48_;
		gpointer _tmp49_;
		GeeMap* _tmp50_;
		gint32 _tmp51_;
		gint32 _tmp52_;
		OmemoIdentityKeyStoreTrustedIdentity* _tmp53_;
		OmemoIdentityKeyStoreTrustedIdentity* _tmp54_;
		GeeMap* _tmp55_;
		const gchar* _tmp56_;
		gpointer _tmp57_;
		GeeMap* _tmp58_;
		gint32 _tmp59_;
		gint32 _tmp60_;
		gpointer _tmp61_;
		OmemoIdentityKeyStoreTrustedIdentity* _tmp62_;
		_tmp43_ = self->priv->trusted_identities;
		_tmp44_ = name;
		_tmp45_ = gee_hash_map_new (G_TYPE_INT, NULL, NULL, OMEMO_IDENTITY_KEY_STORE_TYPE_TRUSTED_IDENTITY, (GBoxedCopyFunc) omemo_identity_key_store_trusted_identity_ref, (GDestroyNotify) omemo_identity_key_store_trusted_identity_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
		_tmp46_ = _tmp45_;
		gee_map_set (_tmp43_, _tmp44_, (GeeMap*) _tmp46_);
		_g_object_unref0 (_tmp46_);
		_tmp47_ = self->priv->trusted_identities;
		_tmp48_ = name;
		_tmp49_ = gee_map_get (_tmp47_, _tmp48_);
		_tmp50_ = (GeeMap*) _tmp49_;
		_tmp51_ = signal_protocol_address_get_device_id (address);
		_tmp52_ = _tmp51_;
		_tmp53_ = omemo_identity_key_store_trusted_identity_new_by_address (address, key, key_length1);
		_tmp54_ = _tmp53_;
		gee_map_set (_tmp50_, (gpointer) ((gintptr) _tmp52_), _tmp54_);
		_omemo_identity_key_store_trusted_identity_unref0 (_tmp54_);
		_g_object_unref0 (_tmp50_);
		_tmp55_ = self->priv->trusted_identities;
		_tmp56_ = name;
		_tmp57_ = gee_map_get (_tmp55_, _tmp56_);
		_tmp58_ = (GeeMap*) _tmp57_;
		_tmp59_ = signal_protocol_address_get_device_id (address);
		_tmp60_ = _tmp59_;
		_tmp61_ = gee_map_get (_tmp58_, (gpointer) ((gintptr) _tmp60_));
		_tmp62_ = (OmemoIdentityKeyStoreTrustedIdentity*) _tmp61_;
		g_signal_emit_by_name ((OmemoIdentityKeyStore*) self, "trusted-identity-added", _tmp62_);
		_omemo_identity_key_store_trusted_identity_unref0 (_tmp62_);
		_g_object_unref0 (_tmp58_);
	}
	_g_free0 (name);
}

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

static gboolean
omemo_simple_identity_key_store_real_is_trusted_identity (OmemoIdentityKeyStore* base,
                                                          signal_protocol_address* address,
                                                          guint8* key,
                                                          gint key_length1,
                                                          GError** error)
{
	OmemoSimpleIdentityKeyStore * self;
	GeeMap* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp4_;
	GeeMap* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gpointer _tmp9_;
	GeeMap* _tmp10_;
	gint32 _tmp11_;
	gint32 _tmp12_;
	gboolean _tmp13_;
	guint8* other_key = NULL;
	GeeMap* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gchar* _tmp17_;
	gpointer _tmp18_;
	GeeMap* _tmp19_;
	gint32 _tmp20_;
	gint32 _tmp21_;
	gpointer _tmp22_;
	OmemoIdentityKeyStoreTrustedIdentity* _tmp23_;
	guint8* _tmp24_;
	gint _tmp24__length1;
	gint _tmp25_ = 0;
	guint8* _tmp26_;
	gint _tmp26__length1;
	guint8* _tmp27_;
	gint _tmp27__length1;
	guint8* _tmp28_;
	gint _tmp28__length1;
	gint other_key_length1;
	gint _other_key_size_;
	guint8* _tmp29_;
	gint _tmp29__length1;
	gboolean result;
	self = (OmemoSimpleIdentityKeyStore*) base;
	g_return_val_if_fail (address != NULL, FALSE);
	_tmp0_ = self->priv->trusted_identities;
	_tmp1_ = signal_protocol_address_get_name (address);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = !gee_map_has_key (_tmp0_, _tmp3_);
	_g_free0 (_tmp3_);
	if (_tmp4_) {
		result = TRUE;
		return result;
	}
	_tmp5_ = self->priv->trusted_identities;
	_tmp6_ = signal_protocol_address_get_name (address);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	_tmp9_ = gee_map_get (_tmp5_, _tmp8_);
	_tmp10_ = (GeeMap*) _tmp9_;
	_tmp11_ = signal_protocol_address_get_device_id (address);
	_tmp12_ = _tmp11_;
	_tmp13_ = !gee_map_has_key (_tmp10_, (gpointer) ((gintptr) _tmp12_));
	_g_object_unref0 (_tmp10_);
	_g_free0 (_tmp8_);
	if (_tmp13_) {
		result = TRUE;
		return result;
	}
	_tmp14_ = self->priv->trusted_identities;
	_tmp15_ = signal_protocol_address_get_name (address);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_;
	_tmp18_ = gee_map_get (_tmp14_, _tmp17_);
	_tmp19_ = (GeeMap*) _tmp18_;
	_tmp20_ = signal_protocol_address_get_device_id (address);
	_tmp21_ = _tmp20_;
	_tmp22_ = gee_map_get (_tmp19_, (gpointer) ((gintptr) _tmp21_));
	_tmp23_ = (OmemoIdentityKeyStoreTrustedIdentity*) _tmp22_;
	_tmp24_ = omemo_identity_key_store_trusted_identity_get_key (_tmp23_, &_tmp25_);
	_tmp24__length1 = _tmp25_;
	_tmp26_ = _tmp24_;
	_tmp26__length1 = _tmp24__length1;
	_tmp27_ = (_tmp26_ != NULL) ? _vala_array_dup29 (_tmp26_, _tmp26__length1) : _tmp26_;
	_tmp27__length1 = _tmp26__length1;
	_tmp28_ = _tmp27_;
	_tmp28__length1 = _tmp27__length1;
	_omemo_identity_key_store_trusted_identity_unref0 (_tmp23_);
	_g_object_unref0 (_tmp19_);
	_g_free0 (_tmp17_);
	other_key = _tmp28_;
	other_key_length1 = _tmp28__length1;
	_other_key_size_ = other_key_length1;
	_tmp29_ = other_key;
	_tmp29__length1 = other_key_length1;
	if (_tmp29__length1 != key_length1) {
		result = FALSE;
		other_key = (g_free (other_key), NULL);
		return result;
	}
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp30_ = FALSE;
			_tmp30_ = TRUE;
			while (TRUE) {
				guint8* _tmp32_;
				gint _tmp32__length1;
				guint8 _tmp33_;
				guint8 _tmp34_;
				if (!_tmp30_) {
					gint _tmp31_;
					_tmp31_ = i;
					i = _tmp31_ + 1;
				}
				_tmp30_ = FALSE;
				if (!(i < key_length1)) {
					break;
				}
				_tmp32_ = other_key;
				_tmp32__length1 = other_key_length1;
				_tmp33_ = _tmp32_[i];
				_tmp34_ = key[i];
				if (_tmp33_ != _tmp34_) {
					result = FALSE;
					other_key = (g_free (other_key), NULL);
					return result;
				}
			}
		}
	}
	result = TRUE;
	other_key = (g_free (other_key), NULL);
	return result;
}

OmemoSimpleIdentityKeyStore*
omemo_simple_identity_key_store_construct (GType object_type)
{
	OmemoSimpleIdentityKeyStore * self = NULL;
	self = (OmemoSimpleIdentityKeyStore*) omemo_identity_key_store_construct (object_type);
	return self;
}

OmemoSimpleIdentityKeyStore*
omemo_simple_identity_key_store_new (void)
{
	return omemo_simple_identity_key_store_construct (OMEMO_TYPE_SIMPLE_IDENTITY_KEY_STORE);
}

static GBytes*
omemo_simple_identity_key_store_real_get_identity_key_private (OmemoIdentityKeyStore* base)
{
	GBytes* result;
	OmemoSimpleIdentityKeyStore* self;
	GBytes* _tmp0_;
	self = (OmemoSimpleIdentityKeyStore*) base;
	_tmp0_ = self->priv->_identity_key_private;
	result = _tmp0_;
	return result;
}

static gpointer
_g_bytes_ref0 (gpointer self)
{
	return self ? g_bytes_ref (self) : NULL;
}

static void
omemo_simple_identity_key_store_real_set_identity_key_private (OmemoIdentityKeyStore* base,
                                                               GBytes* value)
{
	OmemoSimpleIdentityKeyStore* self;
	GBytes* old_value;
	self = (OmemoSimpleIdentityKeyStore*) base;
	old_value = omemo_simple_identity_key_store_real_get_identity_key_private (base);
	if (old_value != value) {
		GBytes* _tmp0_;
		_tmp0_ = _g_bytes_ref0 (value);
		_g_bytes_unref0 (self->priv->_identity_key_private);
		self->priv->_identity_key_private = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, omemo_simple_identity_key_store_properties[OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PRIVATE_PROPERTY]);
	}
}

static GBytes*
omemo_simple_identity_key_store_real_get_identity_key_public (OmemoIdentityKeyStore* base)
{
	GBytes* result;
	OmemoSimpleIdentityKeyStore* self;
	GBytes* _tmp0_;
	self = (OmemoSimpleIdentityKeyStore*) base;
	_tmp0_ = self->priv->_identity_key_public;
	result = _tmp0_;
	return result;
}

static void
omemo_simple_identity_key_store_real_set_identity_key_public (OmemoIdentityKeyStore* base,
                                                              GBytes* value)
{
	OmemoSimpleIdentityKeyStore* self;
	GBytes* old_value;
	self = (OmemoSimpleIdentityKeyStore*) base;
	old_value = omemo_simple_identity_key_store_real_get_identity_key_public (base);
	if (old_value != value) {
		GBytes* _tmp0_;
		_tmp0_ = _g_bytes_ref0 (value);
		_g_bytes_unref0 (self->priv->_identity_key_public);
		self->priv->_identity_key_public = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, omemo_simple_identity_key_store_properties[OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PUBLIC_PROPERTY]);
	}
}

static guint32
omemo_simple_identity_key_store_real_get_local_registration_id (OmemoIdentityKeyStore* base)
{
	guint32 result;
	OmemoSimpleIdentityKeyStore* self;
	self = (OmemoSimpleIdentityKeyStore*) base;
	result = self->priv->_local_registration_id;
	return result;
}

static void
omemo_simple_identity_key_store_real_set_local_registration_id (OmemoIdentityKeyStore* base,
                                                                guint32 value)
{
	OmemoSimpleIdentityKeyStore* self;
	guint32 old_value;
	self = (OmemoSimpleIdentityKeyStore*) base;
	old_value = omemo_simple_identity_key_store_real_get_local_registration_id (base);
	if (old_value != value) {
		self->priv->_local_registration_id = value;
		g_object_notify_by_pspec ((GObject *) self, omemo_simple_identity_key_store_properties[OMEMO_SIMPLE_IDENTITY_KEY_STORE_LOCAL_REGISTRATION_ID_PROPERTY]);
	}
}

static void
omemo_simple_identity_key_store_class_init (OmemoSimpleIdentityKeyStoreClass * klass,
                                            gpointer klass_data)
{
	omemo_simple_identity_key_store_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &OmemoSimpleIdentityKeyStore_private_offset);
	((OmemoIdentityKeyStoreClass *) klass)->save_identity = (void (*) (OmemoIdentityKeyStore*, signal_protocol_address*, guint8*, gint, GError**)) omemo_simple_identity_key_store_real_save_identity;
	((OmemoIdentityKeyStoreClass *) klass)->is_trusted_identity = (gboolean (*) (OmemoIdentityKeyStore*, signal_protocol_address*, guint8*, gint, GError**)) omemo_simple_identity_key_store_real_is_trusted_identity;
	OMEMO_IDENTITY_KEY_STORE_CLASS (klass)->get_identity_key_private = (GBytes* (*) (OmemoIdentityKeyStore*)) omemo_simple_identity_key_store_real_get_identity_key_private;
	OMEMO_IDENTITY_KEY_STORE_CLASS (klass)->set_identity_key_private = (void (*) (OmemoIdentityKeyStore*, GBytes*)) omemo_simple_identity_key_store_real_set_identity_key_private;
	OMEMO_IDENTITY_KEY_STORE_CLASS (klass)->get_identity_key_public = (GBytes* (*) (OmemoIdentityKeyStore*)) omemo_simple_identity_key_store_real_get_identity_key_public;
	OMEMO_IDENTITY_KEY_STORE_CLASS (klass)->set_identity_key_public = (void (*) (OmemoIdentityKeyStore*, GBytes*)) omemo_simple_identity_key_store_real_set_identity_key_public;
	OMEMO_IDENTITY_KEY_STORE_CLASS (klass)->get_local_registration_id = (guint32 (*) (OmemoIdentityKeyStore*)) omemo_simple_identity_key_store_real_get_local_registration_id;
	OMEMO_IDENTITY_KEY_STORE_CLASS (klass)->set_local_registration_id = (void (*) (OmemoIdentityKeyStore*, guint32)) omemo_simple_identity_key_store_real_set_local_registration_id;
	G_OBJECT_CLASS (klass)->get_property = _vala_omemo_simple_identity_key_store_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_omemo_simple_identity_key_store_set_property;
	G_OBJECT_CLASS (klass)->finalize = omemo_simple_identity_key_store_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PRIVATE_PROPERTY, omemo_simple_identity_key_store_properties[OMEMO_SIMPLE_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_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PUBLIC_PROPERTY, omemo_simple_identity_key_store_properties[OMEMO_SIMPLE_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_SIMPLE_IDENTITY_KEY_STORE_LOCAL_REGISTRATION_ID_PROPERTY, omemo_simple_identity_key_store_properties[OMEMO_SIMPLE_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));
}

static void
omemo_simple_identity_key_store_instance_init (OmemoSimpleIdentityKeyStore * self,
                                               gpointer klass)
{
	GeeHashMap* _tmp0_;
	self->priv = omemo_simple_identity_key_store_get_instance_private (self);
	_tmp0_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, GEE_TYPE_MAP, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	self->priv->trusted_identities = (GeeMap*) _tmp0_;
}

static void
omemo_simple_identity_key_store_finalize (GObject * obj)
{
	OmemoSimpleIdentityKeyStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OMEMO_TYPE_SIMPLE_IDENTITY_KEY_STORE, OmemoSimpleIdentityKeyStore);
	_g_bytes_unref0 (self->priv->_identity_key_private);
	_g_bytes_unref0 (self->priv->_identity_key_public);
	_g_object_unref0 (self->priv->trusted_identities);
	G_OBJECT_CLASS (omemo_simple_identity_key_store_parent_class)->finalize (obj);
}

static GType
omemo_simple_identity_key_store_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (OmemoSimpleIdentityKeyStoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) omemo_simple_identity_key_store_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (OmemoSimpleIdentityKeyStore), 0, (GInstanceInitFunc) omemo_simple_identity_key_store_instance_init, NULL };
	GType omemo_simple_identity_key_store_type_id;
	omemo_simple_identity_key_store_type_id = g_type_register_static (OMEMO_TYPE_IDENTITY_KEY_STORE, "OmemoSimpleIdentityKeyStore", &g_define_type_info, 0);
	OmemoSimpleIdentityKeyStore_private_offset = g_type_add_instance_private (omemo_simple_identity_key_store_type_id, sizeof (OmemoSimpleIdentityKeyStorePrivate));
	return omemo_simple_identity_key_store_type_id;
}

GType
omemo_simple_identity_key_store_get_type (void)
{
	static volatile gsize omemo_simple_identity_key_store_type_id__once = 0;
	if (g_once_init_enter (&omemo_simple_identity_key_store_type_id__once)) {
		GType omemo_simple_identity_key_store_type_id;
		omemo_simple_identity_key_store_type_id = omemo_simple_identity_key_store_get_type_once ();
		g_once_init_leave (&omemo_simple_identity_key_store_type_id__once, omemo_simple_identity_key_store_type_id);
	}
	return omemo_simple_identity_key_store_type_id__once;
}

static void
_vala_omemo_simple_identity_key_store_get_property (GObject * object,
                                                    guint property_id,
                                                    GValue * value,
                                                    GParamSpec * pspec)
{
	OmemoSimpleIdentityKeyStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OMEMO_TYPE_SIMPLE_IDENTITY_KEY_STORE, OmemoSimpleIdentityKeyStore);
	switch (property_id) {
		case OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PRIVATE_PROPERTY:
		g_value_set_boxed (value, omemo_identity_key_store_get_identity_key_private ((OmemoIdentityKeyStore*) self));
		break;
		case OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PUBLIC_PROPERTY:
		g_value_set_boxed (value, omemo_identity_key_store_get_identity_key_public ((OmemoIdentityKeyStore*) self));
		break;
		case OMEMO_SIMPLE_IDENTITY_KEY_STORE_LOCAL_REGISTRATION_ID_PROPERTY:
		g_value_set_uint (value, omemo_identity_key_store_get_local_registration_id ((OmemoIdentityKeyStore*) self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_omemo_simple_identity_key_store_set_property (GObject * object,
                                                    guint property_id,
                                                    const GValue * value,
                                                    GParamSpec * pspec)
{
	OmemoSimpleIdentityKeyStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OMEMO_TYPE_SIMPLE_IDENTITY_KEY_STORE, OmemoSimpleIdentityKeyStore);
	switch (property_id) {
		case OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PRIVATE_PROPERTY:
		omemo_identity_key_store_set_identity_key_private ((OmemoIdentityKeyStore*) self, g_value_get_boxed (value));
		break;
		case OMEMO_SIMPLE_IDENTITY_KEY_STORE_IDENTITY_KEY_PUBLIC_PROPERTY:
		omemo_identity_key_store_set_identity_key_public ((OmemoIdentityKeyStore*) self, g_value_get_boxed (value));
		break;
		case OMEMO_SIMPLE_IDENTITY_KEY_STORE_LOCAL_REGISTRATION_ID_PROPERTY:
		omemo_identity_key_store_set_local_registration_id ((OmemoIdentityKeyStore*) self, g_value_get_uint (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;
}

