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

#include "omemo.h"
#include <glib-object.h>
#include <glib.h>
#include "qlite.h"
#include <omemo/signal_protocol.h>
#include <native/helper.h>
#include <stdlib.h>
#include <string.h>

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

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

typedef struct _DinoPluginsOmemoBackedSessionStore DinoPluginsOmemoBackedSessionStore;
typedef struct _DinoPluginsOmemoBackedSessionStoreClass DinoPluginsOmemoBackedSessionStoreClass;
typedef struct _DinoPluginsOmemoBackedSessionStorePrivate DinoPluginsOmemoBackedSessionStorePrivate;
enum  {
	DINO_PLUGINS_OMEMO_BACKED_SESSION_STORE_0_PROPERTY,
	DINO_PLUGINS_OMEMO_BACKED_SESSION_STORE_NUM_PROPERTIES
};
static GParamSpec* dino_plugins_omemo_backed_session_store_properties[DINO_PLUGINS_OMEMO_BACKED_SESSION_STORE_NUM_PROPERTIES];
#define _qlite_database_unref0(var) ((var == NULL) ? NULL : (var = (qlite_database_unref (var), NULL)))
#define _qlite_statement_builder_unref0(var) ((var == NULL) ? NULL : (var = (qlite_statement_builder_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _signal_protocol_address_free0(var) ((var == NULL) ? NULL : (var = (signal_protocol_address_free (var), NULL)))
#define _qlite_row_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_unref (var), NULL)))
#define _qlite_row_iterator_unref0(var) ((var == NULL) ? NULL : (var = (qlite_row_iterator_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))

struct _DinoPluginsOmemoBackedSessionStore {
	OmemoSimpleSessionStore parent_instance;
	DinoPluginsOmemoBackedSessionStorePrivate * priv;
};

struct _DinoPluginsOmemoBackedSessionStoreClass {
	OmemoSimpleSessionStoreClass parent_class;
};

struct _DinoPluginsOmemoBackedSessionStorePrivate {
	DinoPluginsOmemoDatabase* db;
	gint identity_id;
};

static gint DinoPluginsOmemoBackedSessionStore_private_offset;
static gpointer dino_plugins_omemo_backed_session_store_parent_class = NULL;

VALA_EXTERN GType dino_plugins_omemo_backed_session_store_get_type (void) G_GNUC_CONST ;
VALA_EXTERN DinoPluginsOmemoBackedSessionStore* dino_plugins_omemo_backed_session_store_new (DinoPluginsOmemoDatabase* db,
                                                                                 gint identity_id);
VALA_EXTERN DinoPluginsOmemoBackedSessionStore* dino_plugins_omemo_backed_session_store_construct (GType object_type,
                                                                                       DinoPluginsOmemoDatabase* db,
                                                                                       gint identity_id);
static void dino_plugins_omemo_backed_session_store_init (DinoPluginsOmemoBackedSessionStore* self);
VALA_EXTERN void dino_plugins_omemo_backed_session_store_on_session_stored (DinoPluginsOmemoBackedSessionStore* self,
                                                                OmemoSessionStoreSession* session);
static void _dino_plugins_omemo_backed_session_store_on_session_stored_omemo_session_store_session_stored (OmemoSessionStore* _sender,
                                                                                                    OmemoSessionStoreSession* session,
                                                                                                    gpointer self);
VALA_EXTERN void dino_plugins_omemo_backed_session_store_on_session_deleted (DinoPluginsOmemoBackedSessionStore* self,
                                                                 OmemoSessionStoreSession* session);
static void _dino_plugins_omemo_backed_session_store_on_session_deleted_omemo_session_store_session_removed (OmemoSessionStore* _sender,
                                                                                                      OmemoSessionStoreSession* session,
                                                                                                      gpointer self);
static void dino_plugins_omemo_backed_session_store_finalize (GObject * obj);
static GType dino_plugins_omemo_backed_session_store_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_plugins_omemo_backed_session_store_get_instance_private (DinoPluginsOmemoBackedSessionStore* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsOmemoBackedSessionStore_private_offset);
}

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

DinoPluginsOmemoBackedSessionStore*
dino_plugins_omemo_backed_session_store_construct (GType object_type,
                                                   DinoPluginsOmemoDatabase* db,
                                                   gint identity_id)
{
	DinoPluginsOmemoBackedSessionStore * self = NULL;
	DinoPluginsOmemoDatabase* _tmp0_;
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoPluginsOmemoBackedSessionStore*) omemo_simple_session_store_construct (object_type);
	_tmp0_ = _qlite_database_ref0 (db);
	_qlite_database_unref0 (self->priv->db);
	self->priv->db = _tmp0_;
	self->priv->identity_id = identity_id;
	dino_plugins_omemo_backed_session_store_init (self);
	return self;
}

DinoPluginsOmemoBackedSessionStore*
dino_plugins_omemo_backed_session_store_new (DinoPluginsOmemoDatabase* db,
                                             gint identity_id)
{
	return dino_plugins_omemo_backed_session_store_construct (DINO_PLUGINS_OMEMO_TYPE_BACKED_SESSION_STORE, db, identity_id);
}

static void
_dino_plugins_omemo_backed_session_store_on_session_stored_omemo_session_store_session_stored (OmemoSessionStore* _sender,
                                                                                               OmemoSessionStoreSession* session,
                                                                                               gpointer self)
{
	dino_plugins_omemo_backed_session_store_on_session_stored ((DinoPluginsOmemoBackedSessionStore*) self, session);
}

static void
_dino_plugins_omemo_backed_session_store_on_session_deleted_omemo_session_store_session_removed (OmemoSessionStore* _sender,
                                                                                                 OmemoSessionStoreSession* session,
                                                                                                 gpointer self)
{
	dino_plugins_omemo_backed_session_store_on_session_deleted ((DinoPluginsOmemoBackedSessionStore*) self, session);
}

static void
dino_plugins_omemo_backed_session_store_init (DinoPluginsOmemoBackedSessionStore* self)
{
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	{
		{
			QliteRowIterator* _row_it = NULL;
			DinoPluginsOmemoDatabase* _tmp0_;
			DinoPluginsOmemoDatabaseSessionTable* _tmp1_;
			DinoPluginsOmemoDatabaseSessionTable* _tmp2_;
			QliteQueryBuilder* _tmp3_;
			QliteQueryBuilder* _tmp4_;
			DinoPluginsOmemoDatabase* _tmp5_;
			DinoPluginsOmemoDatabaseSessionTable* _tmp6_;
			DinoPluginsOmemoDatabaseSessionTable* _tmp7_;
			QliteColumn* _tmp8_;
			QliteQueryBuilder* _tmp9_;
			QliteQueryBuilder* _tmp10_;
			QliteRowIterator* _tmp11_;
			QliteRowIterator* _tmp12_;
			_tmp0_ = self->priv->db;
			_tmp1_ = dino_plugins_omemo_database_get_session (_tmp0_);
			_tmp2_ = _tmp1_;
			_tmp3_ = qlite_table_select ((QliteTable*) _tmp2_, NULL, (gint) 0);
			_tmp4_ = _tmp3_;
			_tmp5_ = self->priv->db;
			_tmp6_ = dino_plugins_omemo_database_get_session (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = _tmp7_->identity_id;
			_tmp9_ = qlite_query_builder_with (_tmp4_, G_TYPE_INT, NULL, NULL, _tmp8_, "=", (gpointer) ((gintptr) self->priv->identity_id));
			_tmp10_ = _tmp9_;
			_tmp11_ = qlite_query_builder_iterator (_tmp10_);
			_tmp12_ = _tmp11_;
			_qlite_statement_builder_unref0 (_tmp10_);
			_qlite_statement_builder_unref0 (_tmp4_);
			_row_it = _tmp12_;
			while (TRUE) {
				QliteRowIterator* _tmp13_;
				QliteRow* row = NULL;
				QliteRowIterator* _tmp14_;
				QliteRow* _tmp15_;
				signal_protocol_address* addr = NULL;
				QliteRow* _tmp16_;
				DinoPluginsOmemoDatabase* _tmp17_;
				DinoPluginsOmemoDatabaseSessionTable* _tmp18_;
				DinoPluginsOmemoDatabaseSessionTable* _tmp19_;
				QliteColumn* _tmp20_;
				gpointer _tmp21_;
				gchar* _tmp22_;
				QliteRow* _tmp23_;
				DinoPluginsOmemoDatabase* _tmp24_;
				DinoPluginsOmemoDatabaseSessionTable* _tmp25_;
				DinoPluginsOmemoDatabaseSessionTable* _tmp26_;
				QliteColumn* _tmp27_;
				gpointer _tmp28_;
				signal_protocol_address* _tmp29_;
				signal_protocol_address* _tmp30_;
				signal_protocol_address* _tmp31_;
				QliteRow* _tmp32_;
				DinoPluginsOmemoDatabase* _tmp33_;
				DinoPluginsOmemoDatabaseSessionTable* _tmp34_;
				DinoPluginsOmemoDatabaseSessionTable* _tmp35_;
				QliteColumn* _tmp36_;
				gpointer _tmp37_;
				gchar* _tmp38_;
				gsize _tmp39_ = 0;
				guchar* _tmp40_;
				guchar* _tmp41_;
				gint _tmp41__length1;
				signal_protocol_address* _tmp42_;
				_tmp13_ = _row_it;
				if (!qlite_row_iterator_next (_tmp13_)) {
					break;
				}
				_tmp14_ = _row_it;
				_tmp15_ = qlite_row_iterator_get (_tmp14_);
				row = _tmp15_;
				_tmp16_ = row;
				_tmp17_ = self->priv->db;
				_tmp18_ = dino_plugins_omemo_database_get_session (_tmp17_);
				_tmp19_ = _tmp18_;
				_tmp20_ = _tmp19_->address_name;
				_tmp21_ = qlite_row_get (_tmp16_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp20_);
				_tmp22_ = (gchar*) _tmp21_;
				_tmp23_ = row;
				_tmp24_ = self->priv->db;
				_tmp25_ = dino_plugins_omemo_database_get_session (_tmp24_);
				_tmp26_ = _tmp25_;
				_tmp27_ = _tmp26_->device_id;
				_tmp28_ = qlite_row_get (_tmp23_, G_TYPE_INT, NULL, NULL, _tmp27_);
				_tmp29_ = signal_protocol_address_new (_tmp22_, (gint32) ((gint) ((gintptr) _tmp28_)));
				_tmp30_ = _tmp29_;
				_g_free0 (_tmp22_);
				addr = _tmp30_;
				_tmp31_ = addr;
				_tmp32_ = row;
				_tmp33_ = self->priv->db;
				_tmp34_ = dino_plugins_omemo_database_get_session (_tmp33_);
				_tmp35_ = _tmp34_;
				_tmp36_ = _tmp35_->record_base64;
				_tmp37_ = qlite_row_get (_tmp32_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp36_);
				_tmp38_ = (gchar*) _tmp37_;
				_tmp40_ = g_base64_decode (_tmp38_, &_tmp39_);
				_tmp41_ = _tmp40_;
				_tmp41__length1 = _tmp39_;
				omemo_session_store_store_session ((OmemoSessionStore*) self, _tmp31_, _tmp41_, (gint) _tmp39_, &_inner_error0_);
				_tmp41_ = (g_free (_tmp41_), NULL);
				_g_free0 (_tmp38_);
				if (G_UNLIKELY (_inner_error0_ != NULL)) {
					_signal_protocol_address_free0 (addr);
					_qlite_row_unref0 (row);
					_qlite_row_iterator_unref0 (_row_it);
					goto __catch0_g_error;
				}
				_tmp42_ = addr;
				signal_protocol_address_set_device_id (_tmp42_, (gint32) 0);
				_signal_protocol_address_free0 (addr);
				_qlite_row_unref0 (row);
			}
			_qlite_row_iterator_unref0 (_row_it);
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp43_;
		const gchar* _tmp44_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp43_ = e;
		_tmp44_ = _tmp43_->message;
		g_print ("Error while initializing session store: %s", _tmp44_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return;
	}
	g_signal_connect_object ((OmemoSessionStore*) self, "session-stored", (GCallback) _dino_plugins_omemo_backed_session_store_on_session_stored_omemo_session_store_session_stored, self, 0);
	g_signal_connect_object ((OmemoSessionStore*) self, "session-removed", (GCallback) _dino_plugins_omemo_backed_session_store_on_session_deleted_omemo_session_store_session_removed, self, 0);
}

void
dino_plugins_omemo_backed_session_store_on_session_stored (DinoPluginsOmemoBackedSessionStore* self,
                                                           OmemoSessionStoreSession* session)
{
	DinoPluginsOmemoDatabase* _tmp0_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp1_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp2_;
	QliteUpsertBuilder* _tmp3_;
	QliteUpsertBuilder* _tmp4_;
	DinoPluginsOmemoDatabase* _tmp5_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp6_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp7_;
	QliteColumn* _tmp8_;
	QliteUpsertBuilder* _tmp9_;
	QliteUpsertBuilder* _tmp10_;
	DinoPluginsOmemoDatabase* _tmp11_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp12_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp13_;
	QliteColumn* _tmp14_;
	const gchar* _tmp15_;
	QliteUpsertBuilder* _tmp16_;
	QliteUpsertBuilder* _tmp17_;
	DinoPluginsOmemoDatabase* _tmp18_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp19_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp20_;
	QliteColumn* _tmp21_;
	QliteUpsertBuilder* _tmp22_;
	QliteUpsertBuilder* _tmp23_;
	DinoPluginsOmemoDatabase* _tmp24_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp25_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp26_;
	QliteColumn* _tmp27_;
	guint8* _tmp28_;
	gint _tmp28__length1;
	gchar* _tmp29_;
	gchar* _tmp30_;
	QliteUpsertBuilder* _tmp31_;
	QliteUpsertBuilder* _tmp32_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (session != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_plugins_omemo_database_get_session (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_upsert ((QliteTable*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_plugins_omemo_database_get_session (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->identity_id;
	_tmp9_ = qlite_upsert_builder_value (_tmp4_, G_TYPE_INT, NULL, NULL, _tmp8_, (gpointer) ((gintptr) self->priv->identity_id), TRUE);
	_tmp10_ = _tmp9_;
	_tmp11_ = self->priv->db;
	_tmp12_ = dino_plugins_omemo_database_get_session (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_->address_name;
	_tmp15_ = session->name;
	_tmp16_ = qlite_upsert_builder_value (_tmp10_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp14_, _tmp15_, TRUE);
	_tmp17_ = _tmp16_;
	_tmp18_ = self->priv->db;
	_tmp19_ = dino_plugins_omemo_database_get_session (_tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = _tmp20_->device_id;
	_tmp22_ = qlite_upsert_builder_value (_tmp17_, G_TYPE_INT, NULL, NULL, _tmp21_, (gpointer) ((gintptr) session->device_id), TRUE);
	_tmp23_ = _tmp22_;
	_tmp24_ = self->priv->db;
	_tmp25_ = dino_plugins_omemo_database_get_session (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = _tmp26_->record_base64;
	_tmp28_ = session->record;
	_tmp28__length1 = session->record_length1;
	_tmp29_ = g_base64_encode (_tmp28_, (gint) _tmp28__length1);
	_tmp30_ = _tmp29_;
	_tmp31_ = qlite_upsert_builder_value (_tmp23_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp27_, _tmp30_, FALSE);
	_tmp32_ = _tmp31_;
	qlite_upsert_builder_perform (_tmp32_);
	_qlite_statement_builder_unref0 (_tmp32_);
	_g_free0 (_tmp30_);
	_qlite_statement_builder_unref0 (_tmp23_);
	_qlite_statement_builder_unref0 (_tmp17_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp4_);
}

void
dino_plugins_omemo_backed_session_store_on_session_deleted (DinoPluginsOmemoBackedSessionStore* self,
                                                            OmemoSessionStoreSession* session)
{
	DinoPluginsOmemoDatabase* _tmp0_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp1_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp2_;
	QliteDeleteBuilder* _tmp3_;
	QliteDeleteBuilder* _tmp4_;
	DinoPluginsOmemoDatabase* _tmp5_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp6_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp7_;
	QliteColumn* _tmp8_;
	QliteDeleteBuilder* _tmp9_;
	QliteDeleteBuilder* _tmp10_;
	DinoPluginsOmemoDatabase* _tmp11_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp12_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp13_;
	QliteColumn* _tmp14_;
	const gchar* _tmp15_;
	QliteDeleteBuilder* _tmp16_;
	QliteDeleteBuilder* _tmp17_;
	DinoPluginsOmemoDatabase* _tmp18_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp19_;
	DinoPluginsOmemoDatabaseSessionTable* _tmp20_;
	QliteColumn* _tmp21_;
	QliteDeleteBuilder* _tmp22_;
	QliteDeleteBuilder* _tmp23_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (session != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_plugins_omemo_database_get_session (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_delete ((QliteTable*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_plugins_omemo_database_get_session (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->identity_id;
	_tmp9_ = qlite_delete_builder_with (_tmp4_, G_TYPE_INT, NULL, NULL, _tmp8_, "=", (gpointer) ((gintptr) self->priv->identity_id));
	_tmp10_ = _tmp9_;
	_tmp11_ = self->priv->db;
	_tmp12_ = dino_plugins_omemo_database_get_session (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_->address_name;
	_tmp15_ = session->name;
	_tmp16_ = qlite_delete_builder_with (_tmp10_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp14_, "=", _tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = self->priv->db;
	_tmp19_ = dino_plugins_omemo_database_get_session (_tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = _tmp20_->device_id;
	_tmp22_ = qlite_delete_builder_with (_tmp17_, G_TYPE_INT, NULL, NULL, _tmp21_, "=", (gpointer) ((gintptr) session->device_id));
	_tmp23_ = _tmp22_;
	qlite_delete_builder_perform (_tmp23_);
	_qlite_statement_builder_unref0 (_tmp23_);
	_qlite_statement_builder_unref0 (_tmp17_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp4_);
}

static void
dino_plugins_omemo_backed_session_store_class_init (DinoPluginsOmemoBackedSessionStoreClass * klass,
                                                    gpointer klass_data)
{
	dino_plugins_omemo_backed_session_store_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoPluginsOmemoBackedSessionStore_private_offset);
	G_OBJECT_CLASS (klass)->finalize = dino_plugins_omemo_backed_session_store_finalize;
}

static void
dino_plugins_omemo_backed_session_store_instance_init (DinoPluginsOmemoBackedSessionStore * self,
                                                       gpointer klass)
{
	self->priv = dino_plugins_omemo_backed_session_store_get_instance_private (self);
}

static void
dino_plugins_omemo_backed_session_store_finalize (GObject * obj)
{
	DinoPluginsOmemoBackedSessionStore * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OMEMO_TYPE_BACKED_SESSION_STORE, DinoPluginsOmemoBackedSessionStore);
	_qlite_database_unref0 (self->priv->db);
	G_OBJECT_CLASS (dino_plugins_omemo_backed_session_store_parent_class)->finalize (obj);
}

static GType
dino_plugins_omemo_backed_session_store_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOmemoBackedSessionStoreClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_omemo_backed_session_store_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOmemoBackedSessionStore), 0, (GInstanceInitFunc) dino_plugins_omemo_backed_session_store_instance_init, NULL };
	GType dino_plugins_omemo_backed_session_store_type_id;
	dino_plugins_omemo_backed_session_store_type_id = g_type_register_static (OMEMO_TYPE_SIMPLE_SESSION_STORE, "DinoPluginsOmemoBackedSessionStore", &g_define_type_info, 0);
	DinoPluginsOmemoBackedSessionStore_private_offset = g_type_add_instance_private (dino_plugins_omemo_backed_session_store_type_id, sizeof (DinoPluginsOmemoBackedSessionStorePrivate));
	return dino_plugins_omemo_backed_session_store_type_id;
}

GType
dino_plugins_omemo_backed_session_store_get_type (void)
{
	static volatile gsize dino_plugins_omemo_backed_session_store_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_omemo_backed_session_store_type_id__once)) {
		GType dino_plugins_omemo_backed_session_store_type_id;
		dino_plugins_omemo_backed_session_store_type_id = dino_plugins_omemo_backed_session_store_get_type_once ();
		g_once_init_leave (&dino_plugins_omemo_backed_session_store_type_id__once, dino_plugins_omemo_backed_session_store_type_id);
	}
	return dino_plugins_omemo_backed_session_store_type_id__once;
}

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

