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

#include "openpgp.h"
#include "qlite.h"
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include "xmpp-vala.h"
#include "libdino.h"

#define DINO_PLUGINS_OPEN_PGP_DATABASE_VERSION 0
#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 _qlite_table_unref0(var) ((var == NULL) ? NULL : (var = (qlite_table_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (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 _qlite_column_unref0(var) ((var == NULL) ? NULL : (var = (qlite_column_unref (var), NULL)))

struct _DinoPluginsOpenPgpDatabasePrivate {
	DinoPluginsOpenPgpDatabaseAccountSetting* _account_setting_table;
	DinoPluginsOpenPgpDatabaseContactKey* _contact_key_table;
};

static gint DinoPluginsOpenPgpDatabase_private_offset;
static gpointer dino_plugins_open_pgp_database_parent_class = NULL;
static gpointer dino_plugins_open_pgp_database_account_setting_parent_class = NULL;
static gpointer dino_plugins_open_pgp_database_contact_key_parent_class = NULL;

VALA_EXTERN DinoPluginsOpenPgpDatabaseAccountSetting* dino_plugins_open_pgp_database_account_setting_new (DinoPluginsOpenPgpDatabase* db);
VALA_EXTERN DinoPluginsOpenPgpDatabaseAccountSetting* dino_plugins_open_pgp_database_account_setting_construct (GType object_type,
                                                                                                    DinoPluginsOpenPgpDatabase* db);
static void dino_plugins_open_pgp_database_set_account_setting_table (DinoPluginsOpenPgpDatabase* self,
                                                               DinoPluginsOpenPgpDatabaseAccountSetting* value);
VALA_EXTERN DinoPluginsOpenPgpDatabaseContactKey* dino_plugins_open_pgp_database_contact_key_new (DinoPluginsOpenPgpDatabase* db);
VALA_EXTERN DinoPluginsOpenPgpDatabaseContactKey* dino_plugins_open_pgp_database_contact_key_construct (GType object_type,
                                                                                            DinoPluginsOpenPgpDatabase* db);
static void dino_plugins_open_pgp_database_set_contact_key_table (DinoPluginsOpenPgpDatabase* self,
                                                           DinoPluginsOpenPgpDatabaseContactKey* value);
static void dino_plugins_open_pgp_database_real_migrate (QliteDatabase* base,
                                                  glong oldVersion);
static void dino_plugins_open_pgp_database_account_setting_finalize (QliteTable * obj);
static GType dino_plugins_open_pgp_database_account_setting_get_type_once (void);
static void dino_plugins_open_pgp_database_contact_key_finalize (QliteTable * obj);
static GType dino_plugins_open_pgp_database_contact_key_get_type_once (void);
static void dino_plugins_open_pgp_database_finalize (QliteDatabase * obj);
static GType dino_plugins_open_pgp_database_get_type_once (void);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
dino_plugins_open_pgp_database_get_instance_private (DinoPluginsOpenPgpDatabase* self)
{
	return G_STRUCT_MEMBER_P (self, DinoPluginsOpenPgpDatabase_private_offset);
}

static gpointer
_qlite_table_ref0 (gpointer self)
{
	return self ? qlite_table_ref (self) : NULL;
}

DinoPluginsOpenPgpDatabase*
dino_plugins_open_pgp_database_construct (GType object_type,
                                          const gchar* filename)
{
	DinoPluginsOpenPgpDatabase* self = NULL;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp0_;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp1_;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp2_;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp3_;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp4_;
	QliteTable* _tmp5_;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp6_;
	QliteTable* _tmp7_;
	QliteTable** _tmp8_;
	QliteTable** _tmp9_;
	gint _tmp9__length1;
	GError* _inner_error0_ = NULL;
	g_return_val_if_fail (filename != NULL, NULL);
	self = (DinoPluginsOpenPgpDatabase*) qlite_database_construct (object_type, filename, (glong) DINO_PLUGINS_OPEN_PGP_DATABASE_VERSION);
	_tmp0_ = dino_plugins_open_pgp_database_account_setting_new (self);
	_tmp1_ = _tmp0_;
	dino_plugins_open_pgp_database_set_account_setting_table (self, _tmp1_);
	_qlite_table_unref0 (_tmp1_);
	_tmp2_ = dino_plugins_open_pgp_database_contact_key_new (self);
	_tmp3_ = _tmp2_;
	dino_plugins_open_pgp_database_set_contact_key_table (self, _tmp3_);
	_qlite_table_unref0 (_tmp3_);
	_tmp4_ = self->priv->_account_setting_table;
	_tmp5_ = _qlite_table_ref0 ((QliteTable*) _tmp4_);
	_tmp6_ = self->priv->_contact_key_table;
	_tmp7_ = _qlite_table_ref0 ((QliteTable*) _tmp6_);
	_tmp8_ = g_new0 (QliteTable*, 2 + 1);
	_tmp8_[0] = _tmp5_;
	_tmp8_[1] = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp9__length1 = 2;
	qlite_database_init ((QliteDatabase*) self, _tmp9_, (gint) 2);
	_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) qlite_table_unref), NULL);
	{
		qlite_database_exec ((QliteDatabase*) self, "PRAGMA journal_mode = WAL", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		qlite_database_exec ((QliteDatabase*) self, "PRAGMA synchronous = NORMAL", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		qlite_database_exec ((QliteDatabase*) self, "PRAGMA secure_delete = ON", &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		const gchar* _tmp10_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp10_ = e->message;
		g_error ("database.vala:45: Failed to set OpenPGP database properties: %s", _tmp10_);
		_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 NULL;
	}
	return self;
}

DinoPluginsOpenPgpDatabase*
dino_plugins_open_pgp_database_new (const gchar* filename)
{
	return dino_plugins_open_pgp_database_construct (DINO_PLUGINS_OPEN_PGP_TYPE_DATABASE, filename);
}

void
dino_plugins_open_pgp_database_set_contact_key (DinoPluginsOpenPgpDatabase* self,
                                                XmppJid* jid,
                                                const gchar* key)
{
	DinoPluginsOpenPgpDatabaseContactKey* _tmp0_;
	QliteUpsertBuilder* _tmp1_;
	QliteUpsertBuilder* _tmp2_;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp3_;
	QliteColumn* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	QliteUpsertBuilder* _tmp7_;
	QliteUpsertBuilder* _tmp8_;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp9_;
	QliteColumn* _tmp10_;
	QliteUpsertBuilder* _tmp11_;
	QliteUpsertBuilder* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (jid != NULL);
	g_return_if_fail (key != NULL);
	_tmp0_ = self->priv->_contact_key_table;
	_tmp1_ = qlite_table_upsert ((QliteTable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->_contact_key_table;
	_tmp4_ = _tmp3_->jid;
	_tmp5_ = xmpp_jid_to_string (jid);
	_tmp6_ = _tmp5_;
	_tmp7_ = qlite_upsert_builder_value (_tmp2_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp4_, _tmp6_, TRUE);
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->_contact_key_table;
	_tmp10_ = _tmp9_->key;
	_tmp11_ = qlite_upsert_builder_value (_tmp8_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp10_, key, FALSE);
	_tmp12_ = _tmp11_;
	qlite_upsert_builder_perform (_tmp12_);
	_qlite_statement_builder_unref0 (_tmp12_);
	_qlite_statement_builder_unref0 (_tmp8_);
	_g_free0 (_tmp6_);
	_qlite_statement_builder_unref0 (_tmp2_);
}

static gpointer
_qlite_column_ref0 (gpointer self)
{
	return self ? qlite_column_ref (self) : NULL;
}

gchar*
dino_plugins_open_pgp_database_get_contact_key (DinoPluginsOpenPgpDatabase* self,
                                                XmppJid* jid)
{
	DinoPluginsOpenPgpDatabaseContactKey* _tmp0_;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp1_;
	QliteColumn* _tmp2_;
	QliteColumn* _tmp3_;
	QliteColumn** _tmp4_;
	QliteColumn** _tmp5_;
	gint _tmp5__length1;
	QliteQueryBuilder* _tmp6_;
	QliteQueryBuilder* _tmp7_;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp8_;
	QliteColumn* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	QliteQueryBuilder* _tmp12_;
	QliteQueryBuilder* _tmp13_;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp14_;
	QliteColumn* _tmp15_;
	gpointer _tmp16_;
	gchar* _tmp17_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (jid != NULL, NULL);
	_tmp0_ = self->priv->_contact_key_table;
	_tmp1_ = self->priv->_contact_key_table;
	_tmp2_ = _tmp1_->key;
	_tmp3_ = _qlite_column_ref0 (_tmp2_);
	_tmp4_ = g_new0 (QliteColumn*, 1 + 1);
	_tmp4_[0] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 1;
	_tmp6_ = qlite_table_select ((QliteTable*) _tmp0_, _tmp5_, (gint) 1);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->_contact_key_table;
	_tmp9_ = _tmp8_->jid;
	_tmp10_ = xmpp_jid_to_string (jid);
	_tmp11_ = _tmp10_;
	_tmp12_ = qlite_query_builder_with (_tmp7_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp9_, "=", _tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = self->priv->_contact_key_table;
	_tmp15_ = _tmp14_->key;
	_tmp16_ = qlite_query_builder_get (_tmp13_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp15_, NULL);
	_tmp17_ = (gchar*) _tmp16_;
	_qlite_statement_builder_unref0 (_tmp13_);
	_g_free0 (_tmp11_);
	_qlite_statement_builder_unref0 (_tmp7_);
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) qlite_column_unref), NULL);
	result = _tmp17_;
	return result;
}

void
dino_plugins_open_pgp_database_set_account_key (DinoPluginsOpenPgpDatabase* self,
                                                DinoEntitiesAccount* account,
                                                const gchar* key)
{
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp0_;
	QliteUpsertBuilder* _tmp1_;
	QliteUpsertBuilder* _tmp2_;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp3_;
	QliteColumn* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	QliteUpsertBuilder* _tmp7_;
	QliteUpsertBuilder* _tmp8_;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp9_;
	QliteColumn* _tmp10_;
	QliteUpsertBuilder* _tmp11_;
	QliteUpsertBuilder* _tmp12_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	g_return_if_fail (key != NULL);
	_tmp0_ = self->priv->_account_setting_table;
	_tmp1_ = qlite_table_upsert ((QliteTable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->_account_setting_table;
	_tmp4_ = _tmp3_->account_id;
	_tmp5_ = dino_entities_account_get_id (account);
	_tmp6_ = _tmp5_;
	_tmp7_ = qlite_upsert_builder_value (_tmp2_, G_TYPE_INT, NULL, NULL, _tmp4_, (gpointer) ((gintptr) _tmp6_), TRUE);
	_tmp8_ = _tmp7_;
	_tmp9_ = self->priv->_account_setting_table;
	_tmp10_ = _tmp9_->key;
	_tmp11_ = qlite_upsert_builder_value (_tmp8_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp10_, key, FALSE);
	_tmp12_ = _tmp11_;
	qlite_upsert_builder_perform (_tmp12_);
	_qlite_statement_builder_unref0 (_tmp12_);
	_qlite_statement_builder_unref0 (_tmp8_);
	_qlite_statement_builder_unref0 (_tmp2_);
}

gchar*
dino_plugins_open_pgp_database_get_account_key (DinoPluginsOpenPgpDatabase* self,
                                                DinoEntitiesAccount* account)
{
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp0_;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp1_;
	QliteColumn* _tmp2_;
	QliteColumn* _tmp3_;
	QliteColumn** _tmp4_;
	QliteColumn** _tmp5_;
	gint _tmp5__length1;
	QliteQueryBuilder* _tmp6_;
	QliteQueryBuilder* _tmp7_;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp8_;
	QliteColumn* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	QliteQueryBuilder* _tmp12_;
	QliteQueryBuilder* _tmp13_;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp14_;
	QliteColumn* _tmp15_;
	gpointer _tmp16_;
	gchar* _tmp17_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (account != NULL, NULL);
	_tmp0_ = self->priv->_account_setting_table;
	_tmp1_ = self->priv->_account_setting_table;
	_tmp2_ = _tmp1_->key;
	_tmp3_ = _qlite_column_ref0 (_tmp2_);
	_tmp4_ = g_new0 (QliteColumn*, 1 + 1);
	_tmp4_[0] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 1;
	_tmp6_ = qlite_table_select ((QliteTable*) _tmp0_, _tmp5_, (gint) 1);
	_tmp7_ = _tmp6_;
	_tmp8_ = self->priv->_account_setting_table;
	_tmp9_ = _tmp8_->account_id;
	_tmp10_ = dino_entities_account_get_id (account);
	_tmp11_ = _tmp10_;
	_tmp12_ = qlite_query_builder_with (_tmp7_, G_TYPE_INT, NULL, NULL, _tmp9_, "=", (gpointer) ((gintptr) _tmp11_));
	_tmp13_ = _tmp12_;
	_tmp14_ = self->priv->_account_setting_table;
	_tmp15_ = _tmp14_->key;
	_tmp16_ = qlite_query_builder_get (_tmp13_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp15_, NULL);
	_tmp17_ = (gchar*) _tmp16_;
	_qlite_statement_builder_unref0 (_tmp13_);
	_qlite_statement_builder_unref0 (_tmp7_);
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) qlite_column_unref), NULL);
	result = _tmp17_;
	return result;
}

static void
dino_plugins_open_pgp_database_real_migrate (QliteDatabase* base,
                                             glong oldVersion)
{
	DinoPluginsOpenPgpDatabase * self;
	self = (DinoPluginsOpenPgpDatabase*) base;
}

DinoPluginsOpenPgpDatabaseAccountSetting*
dino_plugins_open_pgp_database_get_account_setting_table (DinoPluginsOpenPgpDatabase* self)
{
	DinoPluginsOpenPgpDatabaseAccountSetting* result;
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_account_setting_table;
	result = _tmp0_;
	return result;
}

static void
dino_plugins_open_pgp_database_set_account_setting_table (DinoPluginsOpenPgpDatabase* self,
                                                          DinoPluginsOpenPgpDatabaseAccountSetting* value)
{
	DinoPluginsOpenPgpDatabaseAccountSetting* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _qlite_table_ref0 (value);
	_qlite_table_unref0 (self->priv->_account_setting_table);
	self->priv->_account_setting_table = _tmp0_;
}

DinoPluginsOpenPgpDatabaseContactKey*
dino_plugins_open_pgp_database_get_contact_key_table (DinoPluginsOpenPgpDatabase* self)
{
	DinoPluginsOpenPgpDatabaseContactKey* result;
	DinoPluginsOpenPgpDatabaseContactKey* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_contact_key_table;
	result = _tmp0_;
	return result;
}

static void
dino_plugins_open_pgp_database_set_contact_key_table (DinoPluginsOpenPgpDatabase* self,
                                                      DinoPluginsOpenPgpDatabaseContactKey* value)
{
	DinoPluginsOpenPgpDatabaseContactKey* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _qlite_table_ref0 (value);
	_qlite_table_unref0 (self->priv->_contact_key_table);
	self->priv->_contact_key_table = _tmp0_;
}

DinoPluginsOpenPgpDatabaseAccountSetting*
dino_plugins_open_pgp_database_account_setting_construct (GType object_type,
                                                          DinoPluginsOpenPgpDatabase* db)
{
	DinoPluginsOpenPgpDatabaseAccountSetting* self = NULL;
	QliteColumn* _tmp0_;
	QliteColumn* _tmp1_;
	QliteColumn* _tmp2_;
	QliteColumn* _tmp3_;
	QliteColumn** _tmp4_;
	QliteColumn** _tmp5_;
	gint _tmp5__length1;
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoPluginsOpenPgpDatabaseAccountSetting*) qlite_table_construct (object_type, (QliteDatabase*) db, "account_setting");
	_tmp0_ = self->account_id;
	_tmp1_ = _qlite_column_ref0 (_tmp0_);
	_tmp2_ = self->key;
	_tmp3_ = _qlite_column_ref0 (_tmp2_);
	_tmp4_ = g_new0 (QliteColumn*, 2 + 1);
	_tmp4_[0] = _tmp1_;
	_tmp4_[1] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 2;
	qlite_table_init ((QliteTable*) self, _tmp5_, (gint) 2, "");
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) qlite_column_unref), NULL);
	return self;
}

DinoPluginsOpenPgpDatabaseAccountSetting*
dino_plugins_open_pgp_database_account_setting_new (DinoPluginsOpenPgpDatabase* db)
{
	return dino_plugins_open_pgp_database_account_setting_construct (DINO_PLUGINS_OPEN_PGP_DATABASE_TYPE_ACCOUNT_SETTING, db);
}

static void
dino_plugins_open_pgp_database_account_setting_class_init (DinoPluginsOpenPgpDatabaseAccountSettingClass * klass,
                                                           gpointer klass_data)
{
	dino_plugins_open_pgp_database_account_setting_parent_class = g_type_class_peek_parent (klass);
	((QliteTableClass *) klass)->finalize = dino_plugins_open_pgp_database_account_setting_finalize;
}

static void
dino_plugins_open_pgp_database_account_setting_instance_init (DinoPluginsOpenPgpDatabaseAccountSetting * self,
                                                              gpointer klass)
{
	QliteColumnInteger* _tmp0_ = NULL;
	QliteColumnText* _tmp1_ = NULL;
	_tmp0_ = qlite_column_integer_new ("account_id");
	qlite_column_set_primary_key ((QliteColumn*) _tmp0_, TRUE);
	self->account_id = (QliteColumn*) _tmp0_;
	_tmp1_ = qlite_column_text_new ("key");
	qlite_column_set_not_null ((QliteColumn*) _tmp1_, TRUE);
	self->key = (QliteColumn*) _tmp1_;
}

static void
dino_plugins_open_pgp_database_account_setting_finalize (QliteTable * obj)
{
	DinoPluginsOpenPgpDatabaseAccountSetting * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OPEN_PGP_DATABASE_TYPE_ACCOUNT_SETTING, DinoPluginsOpenPgpDatabaseAccountSetting);
	_qlite_column_unref0 (self->account_id);
	_qlite_column_unref0 (self->key);
	QLITE_TABLE_CLASS (dino_plugins_open_pgp_database_account_setting_parent_class)->finalize (obj);
}

static GType
dino_plugins_open_pgp_database_account_setting_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOpenPgpDatabaseAccountSettingClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_open_pgp_database_account_setting_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOpenPgpDatabaseAccountSetting), 0, (GInstanceInitFunc) dino_plugins_open_pgp_database_account_setting_instance_init, NULL };
	GType dino_plugins_open_pgp_database_account_setting_type_id;
	dino_plugins_open_pgp_database_account_setting_type_id = g_type_register_static (QLITE_TYPE_TABLE, "DinoPluginsOpenPgpDatabaseAccountSetting", &g_define_type_info, 0);
	return dino_plugins_open_pgp_database_account_setting_type_id;
}

GType
dino_plugins_open_pgp_database_account_setting_get_type (void)
{
	static volatile gsize dino_plugins_open_pgp_database_account_setting_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_open_pgp_database_account_setting_type_id__once)) {
		GType dino_plugins_open_pgp_database_account_setting_type_id;
		dino_plugins_open_pgp_database_account_setting_type_id = dino_plugins_open_pgp_database_account_setting_get_type_once ();
		g_once_init_leave (&dino_plugins_open_pgp_database_account_setting_type_id__once, dino_plugins_open_pgp_database_account_setting_type_id);
	}
	return dino_plugins_open_pgp_database_account_setting_type_id__once;
}

DinoPluginsOpenPgpDatabaseContactKey*
dino_plugins_open_pgp_database_contact_key_construct (GType object_type,
                                                      DinoPluginsOpenPgpDatabase* db)
{
	DinoPluginsOpenPgpDatabaseContactKey* self = NULL;
	QliteColumn* _tmp0_;
	QliteColumn* _tmp1_;
	QliteColumn* _tmp2_;
	QliteColumn* _tmp3_;
	QliteColumn** _tmp4_;
	QliteColumn** _tmp5_;
	gint _tmp5__length1;
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoPluginsOpenPgpDatabaseContactKey*) qlite_table_construct (object_type, (QliteDatabase*) db, "contact_key");
	_tmp0_ = self->jid;
	_tmp1_ = _qlite_column_ref0 (_tmp0_);
	_tmp2_ = self->key;
	_tmp3_ = _qlite_column_ref0 (_tmp2_);
	_tmp4_ = g_new0 (QliteColumn*, 2 + 1);
	_tmp4_[0] = _tmp1_;
	_tmp4_[1] = _tmp3_;
	_tmp5_ = _tmp4_;
	_tmp5__length1 = 2;
	qlite_table_init ((QliteTable*) self, _tmp5_, (gint) 2, "");
	_tmp5_ = (_vala_array_free (_tmp5_, _tmp5__length1, (GDestroyNotify) qlite_column_unref), NULL);
	return self;
}

DinoPluginsOpenPgpDatabaseContactKey*
dino_plugins_open_pgp_database_contact_key_new (DinoPluginsOpenPgpDatabase* db)
{
	return dino_plugins_open_pgp_database_contact_key_construct (DINO_PLUGINS_OPEN_PGP_DATABASE_TYPE_CONTACT_KEY, db);
}

static void
dino_plugins_open_pgp_database_contact_key_class_init (DinoPluginsOpenPgpDatabaseContactKeyClass * klass,
                                                       gpointer klass_data)
{
	dino_plugins_open_pgp_database_contact_key_parent_class = g_type_class_peek_parent (klass);
	((QliteTableClass *) klass)->finalize = dino_plugins_open_pgp_database_contact_key_finalize;
}

static void
dino_plugins_open_pgp_database_contact_key_instance_init (DinoPluginsOpenPgpDatabaseContactKey * self,
                                                          gpointer klass)
{
	QliteColumnText* _tmp0_ = NULL;
	QliteColumnText* _tmp1_ = NULL;
	_tmp0_ = qlite_column_text_new ("jid");
	qlite_column_set_primary_key ((QliteColumn*) _tmp0_, TRUE);
	self->jid = (QliteColumn*) _tmp0_;
	_tmp1_ = qlite_column_text_new ("key");
	qlite_column_set_not_null ((QliteColumn*) _tmp1_, TRUE);
	self->key = (QliteColumn*) _tmp1_;
}

static void
dino_plugins_open_pgp_database_contact_key_finalize (QliteTable * obj)
{
	DinoPluginsOpenPgpDatabaseContactKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OPEN_PGP_DATABASE_TYPE_CONTACT_KEY, DinoPluginsOpenPgpDatabaseContactKey);
	_qlite_column_unref0 (self->jid);
	_qlite_column_unref0 (self->key);
	QLITE_TABLE_CLASS (dino_plugins_open_pgp_database_contact_key_parent_class)->finalize (obj);
}

static GType
dino_plugins_open_pgp_database_contact_key_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOpenPgpDatabaseContactKeyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_open_pgp_database_contact_key_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOpenPgpDatabaseContactKey), 0, (GInstanceInitFunc) dino_plugins_open_pgp_database_contact_key_instance_init, NULL };
	GType dino_plugins_open_pgp_database_contact_key_type_id;
	dino_plugins_open_pgp_database_contact_key_type_id = g_type_register_static (QLITE_TYPE_TABLE, "DinoPluginsOpenPgpDatabaseContactKey", &g_define_type_info, 0);
	return dino_plugins_open_pgp_database_contact_key_type_id;
}

GType
dino_plugins_open_pgp_database_contact_key_get_type (void)
{
	static volatile gsize dino_plugins_open_pgp_database_contact_key_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_open_pgp_database_contact_key_type_id__once)) {
		GType dino_plugins_open_pgp_database_contact_key_type_id;
		dino_plugins_open_pgp_database_contact_key_type_id = dino_plugins_open_pgp_database_contact_key_get_type_once ();
		g_once_init_leave (&dino_plugins_open_pgp_database_contact_key_type_id__once, dino_plugins_open_pgp_database_contact_key_type_id);
	}
	return dino_plugins_open_pgp_database_contact_key_type_id__once;
}

static void
dino_plugins_open_pgp_database_class_init (DinoPluginsOpenPgpDatabaseClass * klass,
                                           gpointer klass_data)
{
	dino_plugins_open_pgp_database_parent_class = g_type_class_peek_parent (klass);
	((QliteDatabaseClass *) klass)->finalize = dino_plugins_open_pgp_database_finalize;
	g_type_class_adjust_private_offset (klass, &DinoPluginsOpenPgpDatabase_private_offset);
	((QliteDatabaseClass *) klass)->migrate = (void (*) (QliteDatabase*, glong)) dino_plugins_open_pgp_database_real_migrate;
}

static void
dino_plugins_open_pgp_database_instance_init (DinoPluginsOpenPgpDatabase * self,
                                              gpointer klass)
{
	self->priv = dino_plugins_open_pgp_database_get_instance_private (self);
}

static void
dino_plugins_open_pgp_database_finalize (QliteDatabase * obj)
{
	DinoPluginsOpenPgpDatabase * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_PLUGINS_OPEN_PGP_TYPE_DATABASE, DinoPluginsOpenPgpDatabase);
	_qlite_table_unref0 (self->priv->_account_setting_table);
	_qlite_table_unref0 (self->priv->_contact_key_table);
	QLITE_DATABASE_CLASS (dino_plugins_open_pgp_database_parent_class)->finalize (obj);
}

static GType
dino_plugins_open_pgp_database_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoPluginsOpenPgpDatabaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_plugins_open_pgp_database_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoPluginsOpenPgpDatabase), 0, (GInstanceInitFunc) dino_plugins_open_pgp_database_instance_init, NULL };
	GType dino_plugins_open_pgp_database_type_id;
	dino_plugins_open_pgp_database_type_id = g_type_register_static (QLITE_TYPE_DATABASE, "DinoPluginsOpenPgpDatabase", &g_define_type_info, 0);
	DinoPluginsOpenPgpDatabase_private_offset = g_type_add_instance_private (dino_plugins_open_pgp_database_type_id, sizeof (DinoPluginsOpenPgpDatabasePrivate));
	return dino_plugins_open_pgp_database_type_id;
}

GType
dino_plugins_open_pgp_database_get_type (void)
{
	static volatile gsize dino_plugins_open_pgp_database_type_id__once = 0;
	if (g_once_init_enter (&dino_plugins_open_pgp_database_type_id__once)) {
		GType dino_plugins_open_pgp_database_type_id;
		dino_plugins_open_pgp_database_type_id = dino_plugins_open_pgp_database_get_type_once ();
		g_once_init_leave (&dino_plugins_open_pgp_database_type_id__once, dino_plugins_open_pgp_database_type_id);
	}
	return dino_plugins_open_pgp_database_type_id__once;
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

