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

#include "libdino.h"
#include <glib.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include "qlite.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  {
	DINO_ENTITIES_SETTINGS_0_PROPERTY,
	DINO_ENTITIES_SETTINGS_SEND_TYPING_PROPERTY,
	DINO_ENTITIES_SETTINGS_SEND_MARKER_PROPERTY,
	DINO_ENTITIES_SETTINGS_NOTIFICATIONS_PROPERTY,
	DINO_ENTITIES_SETTINGS_CONVERT_UTF8_SMILEYS_PROPERTY,
	DINO_ENTITIES_SETTINGS_CHECK_SPELLING_PROPERTY,
	DINO_ENTITIES_SETTINGS_NUM_PROPERTIES
};
static GParamSpec* dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_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))

struct _DinoEntitiesSettingsPrivate {
	DinoDatabase* db;
	gboolean send_typing_;
	gboolean send_marker_;
	gboolean notifications_;
	gboolean convert_utf8_smileys_;
	gboolean check_spelling_;
};

static gint DinoEntitiesSettings_private_offset;
static gpointer dino_entities_settings_parent_class = NULL;

static gboolean dino_entities_settings_col_to_bool_or_default (DinoEntitiesSettings* self,
                                                        const gchar* key,
                                                        gboolean def);
static void dino_entities_settings_finalize (GObject * obj);
static GType dino_entities_settings_get_type_once (void);
static void _vala_dino_entities_settings_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_dino_entities_settings_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
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_entities_settings_get_instance_private (DinoEntitiesSettings* self)
{
	return G_STRUCT_MEMBER_P (self, DinoEntitiesSettings_private_offset);
}

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

DinoEntitiesSettings*
dino_entities_settings_construct_from_db (GType object_type,
                                          DinoDatabase* db)
{
	DinoEntitiesSettings * self = NULL;
	DinoDatabase* _tmp0_;
	g_return_val_if_fail (db != NULL, NULL);
	self = (DinoEntitiesSettings*) g_object_new (object_type, NULL);
	_tmp0_ = _qlite_database_ref0 (db);
	_qlite_database_unref0 (self->priv->db);
	self->priv->db = _tmp0_;
	self->priv->send_typing_ = dino_entities_settings_col_to_bool_or_default (self, "send_typing", TRUE);
	self->priv->send_marker_ = dino_entities_settings_col_to_bool_or_default (self, "send_marker", TRUE);
	self->priv->notifications_ = dino_entities_settings_col_to_bool_or_default (self, "notifications", TRUE);
	self->priv->convert_utf8_smileys_ = dino_entities_settings_col_to_bool_or_default (self, "convert_utf8_smileys", TRUE);
	dino_entities_settings_set_check_spelling (self, dino_entities_settings_col_to_bool_or_default (self, "check_spelling", TRUE));
	return self;
}

DinoEntitiesSettings*
dino_entities_settings_new_from_db (DinoDatabase* db)
{
	return dino_entities_settings_construct_from_db (DINO_ENTITIES_TYPE_SETTINGS, db);
}

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

static gboolean
bool_parse (const gchar* str)
{
	gboolean result;
	g_return_val_if_fail (str != NULL, FALSE);
	if (g_strcmp0 (str, "true") == 0) {
		result = TRUE;
		return result;
	} else {
		result = FALSE;
		return result;
	}
}

static gboolean
dino_entities_settings_col_to_bool_or_default (DinoEntitiesSettings* self,
                                               const gchar* key,
                                               gboolean def)
{
	gchar* val = NULL;
	DinoDatabase* _tmp0_;
	DinoDatabaseSettingsTable* _tmp1_;
	DinoDatabaseSettingsTable* _tmp2_;
	DinoDatabase* _tmp3_;
	DinoDatabaseSettingsTable* _tmp4_;
	DinoDatabaseSettingsTable* _tmp5_;
	QliteColumn* _tmp6_;
	QliteColumn* _tmp7_;
	QliteColumn** _tmp8_;
	QliteColumn** _tmp9_;
	gint _tmp9__length1;
	QliteQueryBuilder* _tmp10_;
	QliteQueryBuilder* _tmp11_;
	DinoDatabase* _tmp12_;
	DinoDatabaseSettingsTable* _tmp13_;
	DinoDatabaseSettingsTable* _tmp14_;
	QliteColumn* _tmp15_;
	QliteQueryBuilder* _tmp16_;
	QliteQueryBuilder* _tmp17_;
	DinoDatabase* _tmp18_;
	DinoDatabaseSettingsTable* _tmp19_;
	DinoDatabaseSettingsTable* _tmp20_;
	QliteColumn* _tmp21_;
	gpointer _tmp22_;
	gchar* _tmp23_;
	gboolean _tmp24_ = FALSE;
	const gchar* _tmp25_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (key != NULL, FALSE);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->db;
	_tmp4_ = dino_database_get_settings (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_->value;
	_tmp7_ = _qlite_column_ref0 (_tmp6_);
	_tmp8_ = g_new0 (QliteColumn*, 1 + 1);
	_tmp8_[0] = _tmp7_;
	_tmp9_ = _tmp8_;
	_tmp9__length1 = 1;
	_tmp10_ = qlite_table_select ((QliteTable*) _tmp2_, _tmp9_, (gint) 1);
	_tmp11_ = _tmp10_;
	_tmp12_ = self->priv->db;
	_tmp13_ = dino_database_get_settings (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = _tmp14_->key;
	_tmp16_ = qlite_query_builder_with (_tmp11_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp15_, "=", key);
	_tmp17_ = _tmp16_;
	_tmp18_ = self->priv->db;
	_tmp19_ = dino_database_get_settings (_tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = _tmp20_->value;
	_tmp22_ = qlite_query_builder_get (_tmp17_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp21_, NULL);
	_tmp23_ = (gchar*) _tmp22_;
	_qlite_statement_builder_unref0 (_tmp17_);
	_qlite_statement_builder_unref0 (_tmp11_);
	_tmp9_ = (_vala_array_free (_tmp9_, _tmp9__length1, (GDestroyNotify) qlite_column_unref), NULL);
	val = _tmp23_;
	_tmp25_ = val;
	if (_tmp25_ != NULL) {
		const gchar* _tmp26_;
		_tmp26_ = val;
		_tmp24_ = bool_parse (_tmp26_);
	} else {
		_tmp24_ = def;
	}
	result = _tmp24_;
	_g_free0 (val);
	return result;
}

DinoEntitiesEncryption
dino_entities_settings_get_default_encryption (DinoEntitiesSettings* self,
                                               DinoEntitiesAccount* account)
{
	gchar* setting = NULL;
	DinoDatabase* _tmp0_;
	DinoDatabaseAccountSettingsTable* _tmp1_;
	DinoDatabaseAccountSettingsTable* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gchar* _tmp5_;
	const gchar* _tmp6_;
	DinoEntitiesEncryption result;
	g_return_val_if_fail (self != NULL, 0);
	g_return_val_if_fail (account != NULL, 0);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_account_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = dino_entities_account_get_id (account);
	_tmp4_ = _tmp3_;
	_tmp5_ = dino_database_account_settings_table_get_value (_tmp2_, _tmp4_, "default-encryption");
	setting = _tmp5_;
	_tmp6_ = setting;
	if (_tmp6_ != NULL) {
		const gchar* _tmp7_;
		_tmp7_ = setting;
		result = (DinoEntitiesEncryption) atoi (_tmp7_);
		_g_free0 (setting);
		return result;
	}
	result = DINO_ENTITIES_ENCRYPTION_OMEMO;
	_g_free0 (setting);
	return result;
}

void
dino_entities_settings_set_default_encryption (DinoEntitiesSettings* self,
                                               DinoEntitiesAccount* account,
                                               DinoEntitiesEncryption encryption)
{
	DinoDatabase* _tmp0_;
	DinoDatabaseAccountSettingsTable* _tmp1_;
	DinoDatabaseAccountSettingsTable* _tmp2_;
	QliteUpsertBuilder* _tmp3_;
	QliteUpsertBuilder* _tmp4_;
	DinoDatabase* _tmp5_;
	DinoDatabaseAccountSettingsTable* _tmp6_;
	DinoDatabaseAccountSettingsTable* _tmp7_;
	QliteColumn* _tmp8_;
	QliteUpsertBuilder* _tmp9_;
	QliteUpsertBuilder* _tmp10_;
	DinoDatabase* _tmp11_;
	DinoDatabaseAccountSettingsTable* _tmp12_;
	DinoDatabaseAccountSettingsTable* _tmp13_;
	QliteColumn* _tmp14_;
	gint _tmp15_;
	gint _tmp16_;
	QliteUpsertBuilder* _tmp17_;
	QliteUpsertBuilder* _tmp18_;
	DinoDatabase* _tmp19_;
	DinoDatabaseAccountSettingsTable* _tmp20_;
	DinoDatabaseAccountSettingsTable* _tmp21_;
	QliteColumn* _tmp22_;
	gchar* _tmp23_;
	gchar* _tmp24_;
	QliteUpsertBuilder* _tmp25_;
	QliteUpsertBuilder* _tmp26_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (account != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_account_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_upsert ((QliteTable*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_database_get_account_settings (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->key;
	_tmp9_ = qlite_upsert_builder_value (_tmp4_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp8_, "default-encryption", TRUE);
	_tmp10_ = _tmp9_;
	_tmp11_ = self->priv->db;
	_tmp12_ = dino_database_get_account_settings (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_->account_id;
	_tmp15_ = dino_entities_account_get_id (account);
	_tmp16_ = _tmp15_;
	_tmp17_ = qlite_upsert_builder_value (_tmp10_, G_TYPE_INT, NULL, NULL, _tmp14_, (gpointer) ((gintptr) _tmp16_), TRUE);
	_tmp18_ = _tmp17_;
	_tmp19_ = self->priv->db;
	_tmp20_ = dino_database_get_account_settings (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = _tmp21_->value;
	_tmp23_ = g_strdup_printf ("%i", (gint) encryption);
	_tmp24_ = _tmp23_;
	_tmp25_ = qlite_upsert_builder_value (_tmp18_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp22_, _tmp24_, FALSE);
	_tmp26_ = _tmp25_;
	qlite_upsert_builder_perform (_tmp26_);
	_qlite_statement_builder_unref0 (_tmp26_);
	_g_free0 (_tmp24_);
	_qlite_statement_builder_unref0 (_tmp18_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp4_);
}

DinoEntitiesSettings*
dino_entities_settings_construct (GType object_type)
{
	DinoEntitiesSettings * self = NULL;
	self = (DinoEntitiesSettings*) g_object_new (object_type, NULL);
	return self;
}

DinoEntitiesSettings*
dino_entities_settings_new (void)
{
	return dino_entities_settings_construct (DINO_ENTITIES_TYPE_SETTINGS);
}

gboolean
dino_entities_settings_get_send_typing (DinoEntitiesSettings* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->send_typing_;
	return result;
}

static gchar*
bool_to_string (gboolean self)
{
	gchar* result;
	if (self) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("true");
		result = _tmp0_;
		return result;
	} else {
		gchar* _tmp1_;
		_tmp1_ = g_strdup ("false");
		result = _tmp1_;
		return result;
	}
}

void
dino_entities_settings_set_send_typing (DinoEntitiesSettings* self,
                                        gboolean value)
{
	DinoDatabase* _tmp0_;
	DinoDatabaseSettingsTable* _tmp1_;
	DinoDatabaseSettingsTable* _tmp2_;
	QliteUpsertBuilder* _tmp3_;
	QliteUpsertBuilder* _tmp4_;
	DinoDatabase* _tmp5_;
	DinoDatabaseSettingsTable* _tmp6_;
	DinoDatabaseSettingsTable* _tmp7_;
	QliteColumn* _tmp8_;
	QliteUpsertBuilder* _tmp9_;
	QliteUpsertBuilder* _tmp10_;
	DinoDatabase* _tmp11_;
	DinoDatabaseSettingsTable* _tmp12_;
	DinoDatabaseSettingsTable* _tmp13_;
	QliteColumn* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	QliteUpsertBuilder* _tmp17_;
	QliteUpsertBuilder* _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_upsert ((QliteTable*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_database_get_settings (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->key;
	_tmp9_ = qlite_upsert_builder_value (_tmp4_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp8_, "send_typing", TRUE);
	_tmp10_ = _tmp9_;
	_tmp11_ = self->priv->db;
	_tmp12_ = dino_database_get_settings (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_->value;
	_tmp15_ = bool_to_string (value);
	_tmp16_ = _tmp15_;
	_tmp17_ = qlite_upsert_builder_value (_tmp10_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp14_, _tmp16_, FALSE);
	_tmp18_ = _tmp17_;
	qlite_upsert_builder_perform (_tmp18_);
	_qlite_statement_builder_unref0 (_tmp18_);
	_g_free0 (_tmp16_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp4_);
	self->priv->send_typing_ = value;
	g_object_notify_by_pspec ((GObject *) self, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_SEND_TYPING_PROPERTY]);
}

gboolean
dino_entities_settings_get_send_marker (DinoEntitiesSettings* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->send_marker_;
	return result;
}

void
dino_entities_settings_set_send_marker (DinoEntitiesSettings* self,
                                        gboolean value)
{
	DinoDatabase* _tmp0_;
	DinoDatabaseSettingsTable* _tmp1_;
	DinoDatabaseSettingsTable* _tmp2_;
	QliteUpsertBuilder* _tmp3_;
	QliteUpsertBuilder* _tmp4_;
	DinoDatabase* _tmp5_;
	DinoDatabaseSettingsTable* _tmp6_;
	DinoDatabaseSettingsTable* _tmp7_;
	QliteColumn* _tmp8_;
	QliteUpsertBuilder* _tmp9_;
	QliteUpsertBuilder* _tmp10_;
	DinoDatabase* _tmp11_;
	DinoDatabaseSettingsTable* _tmp12_;
	DinoDatabaseSettingsTable* _tmp13_;
	QliteColumn* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	QliteUpsertBuilder* _tmp17_;
	QliteUpsertBuilder* _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_upsert ((QliteTable*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_database_get_settings (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->key;
	_tmp9_ = qlite_upsert_builder_value (_tmp4_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp8_, "send_marker", TRUE);
	_tmp10_ = _tmp9_;
	_tmp11_ = self->priv->db;
	_tmp12_ = dino_database_get_settings (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_->value;
	_tmp15_ = bool_to_string (value);
	_tmp16_ = _tmp15_;
	_tmp17_ = qlite_upsert_builder_value (_tmp10_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp14_, _tmp16_, FALSE);
	_tmp18_ = _tmp17_;
	qlite_upsert_builder_perform (_tmp18_);
	_qlite_statement_builder_unref0 (_tmp18_);
	_g_free0 (_tmp16_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp4_);
	self->priv->send_marker_ = value;
	g_object_notify_by_pspec ((GObject *) self, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_SEND_MARKER_PROPERTY]);
}

gboolean
dino_entities_settings_get_notifications (DinoEntitiesSettings* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->notifications_;
	return result;
}

void
dino_entities_settings_set_notifications (DinoEntitiesSettings* self,
                                          gboolean value)
{
	DinoDatabase* _tmp0_;
	DinoDatabaseSettingsTable* _tmp1_;
	DinoDatabaseSettingsTable* _tmp2_;
	QliteUpsertBuilder* _tmp3_;
	QliteUpsertBuilder* _tmp4_;
	DinoDatabase* _tmp5_;
	DinoDatabaseSettingsTable* _tmp6_;
	DinoDatabaseSettingsTable* _tmp7_;
	QliteColumn* _tmp8_;
	QliteUpsertBuilder* _tmp9_;
	QliteUpsertBuilder* _tmp10_;
	DinoDatabase* _tmp11_;
	DinoDatabaseSettingsTable* _tmp12_;
	DinoDatabaseSettingsTable* _tmp13_;
	QliteColumn* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	QliteUpsertBuilder* _tmp17_;
	QliteUpsertBuilder* _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_upsert ((QliteTable*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_database_get_settings (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->key;
	_tmp9_ = qlite_upsert_builder_value (_tmp4_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp8_, "notifications", TRUE);
	_tmp10_ = _tmp9_;
	_tmp11_ = self->priv->db;
	_tmp12_ = dino_database_get_settings (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_->value;
	_tmp15_ = bool_to_string (value);
	_tmp16_ = _tmp15_;
	_tmp17_ = qlite_upsert_builder_value (_tmp10_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp14_, _tmp16_, FALSE);
	_tmp18_ = _tmp17_;
	qlite_upsert_builder_perform (_tmp18_);
	_qlite_statement_builder_unref0 (_tmp18_);
	_g_free0 (_tmp16_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp4_);
	self->priv->notifications_ = value;
	g_object_notify_by_pspec ((GObject *) self, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_NOTIFICATIONS_PROPERTY]);
}

gboolean
dino_entities_settings_get_convert_utf8_smileys (DinoEntitiesSettings* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->convert_utf8_smileys_;
	return result;
}

void
dino_entities_settings_set_convert_utf8_smileys (DinoEntitiesSettings* self,
                                                 gboolean value)
{
	DinoDatabase* _tmp0_;
	DinoDatabaseSettingsTable* _tmp1_;
	DinoDatabaseSettingsTable* _tmp2_;
	QliteUpsertBuilder* _tmp3_;
	QliteUpsertBuilder* _tmp4_;
	DinoDatabase* _tmp5_;
	DinoDatabaseSettingsTable* _tmp6_;
	DinoDatabaseSettingsTable* _tmp7_;
	QliteColumn* _tmp8_;
	QliteUpsertBuilder* _tmp9_;
	QliteUpsertBuilder* _tmp10_;
	DinoDatabase* _tmp11_;
	DinoDatabaseSettingsTable* _tmp12_;
	DinoDatabaseSettingsTable* _tmp13_;
	QliteColumn* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	QliteUpsertBuilder* _tmp17_;
	QliteUpsertBuilder* _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_upsert ((QliteTable*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_database_get_settings (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->key;
	_tmp9_ = qlite_upsert_builder_value (_tmp4_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp8_, "convert_utf8_smileys", TRUE);
	_tmp10_ = _tmp9_;
	_tmp11_ = self->priv->db;
	_tmp12_ = dino_database_get_settings (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_->value;
	_tmp15_ = bool_to_string (value);
	_tmp16_ = _tmp15_;
	_tmp17_ = qlite_upsert_builder_value (_tmp10_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp14_, _tmp16_, FALSE);
	_tmp18_ = _tmp17_;
	qlite_upsert_builder_perform (_tmp18_);
	_qlite_statement_builder_unref0 (_tmp18_);
	_g_free0 (_tmp16_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp4_);
	self->priv->convert_utf8_smileys_ = value;
	g_object_notify_by_pspec ((GObject *) self, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_CONVERT_UTF8_SMILEYS_PROPERTY]);
}

gboolean
dino_entities_settings_get_check_spelling (DinoEntitiesSettings* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->check_spelling_;
	return result;
}

void
dino_entities_settings_set_check_spelling (DinoEntitiesSettings* self,
                                           gboolean value)
{
	DinoDatabase* _tmp0_;
	DinoDatabaseSettingsTable* _tmp1_;
	DinoDatabaseSettingsTable* _tmp2_;
	QliteUpsertBuilder* _tmp3_;
	QliteUpsertBuilder* _tmp4_;
	DinoDatabase* _tmp5_;
	DinoDatabaseSettingsTable* _tmp6_;
	DinoDatabaseSettingsTable* _tmp7_;
	QliteColumn* _tmp8_;
	QliteUpsertBuilder* _tmp9_;
	QliteUpsertBuilder* _tmp10_;
	DinoDatabase* _tmp11_;
	DinoDatabaseSettingsTable* _tmp12_;
	DinoDatabaseSettingsTable* _tmp13_;
	QliteColumn* _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	QliteUpsertBuilder* _tmp17_;
	QliteUpsertBuilder* _tmp18_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->db;
	_tmp1_ = dino_database_get_settings (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = qlite_table_upsert ((QliteTable*) _tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = self->priv->db;
	_tmp6_ = dino_database_get_settings (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_->key;
	_tmp9_ = qlite_upsert_builder_value (_tmp4_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp8_, "check_spelling", TRUE);
	_tmp10_ = _tmp9_;
	_tmp11_ = self->priv->db;
	_tmp12_ = dino_database_get_settings (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _tmp13_->value;
	_tmp15_ = bool_to_string (value);
	_tmp16_ = _tmp15_;
	_tmp17_ = qlite_upsert_builder_value (_tmp10_, G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp14_, _tmp16_, FALSE);
	_tmp18_ = _tmp17_;
	qlite_upsert_builder_perform (_tmp18_);
	_qlite_statement_builder_unref0 (_tmp18_);
	_g_free0 (_tmp16_);
	_qlite_statement_builder_unref0 (_tmp10_);
	_qlite_statement_builder_unref0 (_tmp4_);
	self->priv->check_spelling_ = value;
	g_object_notify_by_pspec ((GObject *) self, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_CHECK_SPELLING_PROPERTY]);
}

static void
dino_entities_settings_class_init (DinoEntitiesSettingsClass * klass,
                                   gpointer klass_data)
{
	dino_entities_settings_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoEntitiesSettings_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dino_entities_settings_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dino_entities_settings_set_property;
	G_OBJECT_CLASS (klass)->finalize = dino_entities_settings_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_ENTITIES_SETTINGS_SEND_TYPING_PROPERTY, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_SEND_TYPING_PROPERTY] = g_param_spec_boolean ("send-typing", "send-typing", "send-typing", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_ENTITIES_SETTINGS_SEND_MARKER_PROPERTY, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_SEND_MARKER_PROPERTY] = g_param_spec_boolean ("send-marker", "send-marker", "send-marker", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_ENTITIES_SETTINGS_NOTIFICATIONS_PROPERTY, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_NOTIFICATIONS_PROPERTY] = g_param_spec_boolean ("notifications", "notifications", "notifications", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_ENTITIES_SETTINGS_CONVERT_UTF8_SMILEYS_PROPERTY, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_CONVERT_UTF8_SMILEYS_PROPERTY] = g_param_spec_boolean ("convert-utf8-smileys", "convert-utf8-smileys", "convert-utf8-smileys", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), DINO_ENTITIES_SETTINGS_CHECK_SPELLING_PROPERTY, dino_entities_settings_properties[DINO_ENTITIES_SETTINGS_CHECK_SPELLING_PROPERTY] = g_param_spec_boolean ("check-spelling", "check-spelling", "check-spelling", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
dino_entities_settings_instance_init (DinoEntitiesSettings * self,
                                      gpointer klass)
{
	self->priv = dino_entities_settings_get_instance_private (self);
}

static void
dino_entities_settings_finalize (GObject * obj)
{
	DinoEntitiesSettings * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_ENTITIES_TYPE_SETTINGS, DinoEntitiesSettings);
	_qlite_database_unref0 (self->priv->db);
	G_OBJECT_CLASS (dino_entities_settings_parent_class)->finalize (obj);
}

static GType
dino_entities_settings_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoEntitiesSettingsClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_entities_settings_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoEntitiesSettings), 0, (GInstanceInitFunc) dino_entities_settings_instance_init, NULL };
	GType dino_entities_settings_type_id;
	dino_entities_settings_type_id = g_type_register_static (G_TYPE_OBJECT, "DinoEntitiesSettings", &g_define_type_info, 0);
	DinoEntitiesSettings_private_offset = g_type_add_instance_private (dino_entities_settings_type_id, sizeof (DinoEntitiesSettingsPrivate));
	return dino_entities_settings_type_id;
}

GType
dino_entities_settings_get_type (void)
{
	static volatile gsize dino_entities_settings_type_id__once = 0;
	if (g_once_init_enter (&dino_entities_settings_type_id__once)) {
		GType dino_entities_settings_type_id;
		dino_entities_settings_type_id = dino_entities_settings_get_type_once ();
		g_once_init_leave (&dino_entities_settings_type_id__once, dino_entities_settings_type_id);
	}
	return dino_entities_settings_type_id__once;
}

static void
_vala_dino_entities_settings_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	DinoEntitiesSettings * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_ENTITIES_TYPE_SETTINGS, DinoEntitiesSettings);
	switch (property_id) {
		case DINO_ENTITIES_SETTINGS_SEND_TYPING_PROPERTY:
		g_value_set_boolean (value, dino_entities_settings_get_send_typing (self));
		break;
		case DINO_ENTITIES_SETTINGS_SEND_MARKER_PROPERTY:
		g_value_set_boolean (value, dino_entities_settings_get_send_marker (self));
		break;
		case DINO_ENTITIES_SETTINGS_NOTIFICATIONS_PROPERTY:
		g_value_set_boolean (value, dino_entities_settings_get_notifications (self));
		break;
		case DINO_ENTITIES_SETTINGS_CONVERT_UTF8_SMILEYS_PROPERTY:
		g_value_set_boolean (value, dino_entities_settings_get_convert_utf8_smileys (self));
		break;
		case DINO_ENTITIES_SETTINGS_CHECK_SPELLING_PROPERTY:
		g_value_set_boolean (value, dino_entities_settings_get_check_spelling (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dino_entities_settings_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	DinoEntitiesSettings * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DINO_ENTITIES_TYPE_SETTINGS, DinoEntitiesSettings);
	switch (property_id) {
		case DINO_ENTITIES_SETTINGS_SEND_TYPING_PROPERTY:
		dino_entities_settings_set_send_typing (self, g_value_get_boolean (value));
		break;
		case DINO_ENTITIES_SETTINGS_SEND_MARKER_PROPERTY:
		dino_entities_settings_set_send_marker (self, g_value_get_boolean (value));
		break;
		case DINO_ENTITIES_SETTINGS_NOTIFICATIONS_PROPERTY:
		dino_entities_settings_set_notifications (self, g_value_get_boolean (value));
		break;
		case DINO_ENTITIES_SETTINGS_CONVERT_UTF8_SMILEYS_PROPERTY:
		dino_entities_settings_set_convert_utf8_smileys (self, g_value_get_boolean (value));
		break;
		case DINO_ENTITIES_SETTINGS_CHECK_SPELLING_PROPERTY:
		dino_entities_settings_set_check_spelling (self, g_value_get_boolean (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

