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

#include "seafile-object.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.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  {
	SEAFILE_CRYPT_KEY_0_PROPERTY,
	SEAFILE_CRYPT_KEY_KEY_PROPERTY,
	SEAFILE_CRYPT_KEY_IV_PROPERTY,
	SEAFILE_CRYPT_KEY_NUM_PROPERTIES
};
static GParamSpec* seafile_crypt_key_properties[SEAFILE_CRYPT_KEY_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _SeafileCryptKeyPrivate {
	gchar* _key;
	gchar* _iv;
};

static gint SeafileCryptKey_private_offset;
static gpointer seafile_crypt_key_parent_class = NULL;

static void seafile_crypt_key_finalize (GObject * obj);
static GType seafile_crypt_key_get_type_once (void);
static void _vala_seafile_crypt_key_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec);
static void _vala_seafile_crypt_key_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec);

static inline gpointer
seafile_crypt_key_get_instance_private (SeafileCryptKey* self)
{
	return G_STRUCT_MEMBER_P (self, SeafileCryptKey_private_offset);
}

SeafileCryptKey*
seafile_crypt_key_construct (GType object_type)
{
	SeafileCryptKey * self = NULL;
	self = (SeafileCryptKey*) g_object_new (object_type, NULL);
	return self;
}

SeafileCryptKey*
seafile_crypt_key_new (void)
{
	return seafile_crypt_key_construct (SEAFILE_TYPE_CRYPT_KEY);
}

const gchar*
seafile_crypt_key_get_key (SeafileCryptKey* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_key;
	result = _tmp0_;
	return result;
}

void
seafile_crypt_key_set_key (SeafileCryptKey* self,
                           const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = seafile_crypt_key_get_key (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_key);
		self->priv->_key = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, seafile_crypt_key_properties[SEAFILE_CRYPT_KEY_KEY_PROPERTY]);
	}
}

const gchar*
seafile_crypt_key_get_iv (SeafileCryptKey* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_iv;
	result = _tmp0_;
	return result;
}

void
seafile_crypt_key_set_iv (SeafileCryptKey* self,
                          const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = seafile_crypt_key_get_iv (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_iv);
		self->priv->_iv = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, seafile_crypt_key_properties[SEAFILE_CRYPT_KEY_IV_PROPERTY]);
	}
}

static void
seafile_crypt_key_class_init (SeafileCryptKeyClass * klass,
                              gpointer klass_data)
{
	seafile_crypt_key_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &SeafileCryptKey_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_seafile_crypt_key_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_seafile_crypt_key_set_property;
	G_OBJECT_CLASS (klass)->finalize = seafile_crypt_key_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAFILE_CRYPT_KEY_KEY_PROPERTY, seafile_crypt_key_properties[SEAFILE_CRYPT_KEY_KEY_PROPERTY] = g_param_spec_string ("key", "key", "key", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), SEAFILE_CRYPT_KEY_IV_PROPERTY, seafile_crypt_key_properties[SEAFILE_CRYPT_KEY_IV_PROPERTY] = g_param_spec_string ("iv", "iv", "iv", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
seafile_crypt_key_instance_init (SeafileCryptKey * self,
                                 gpointer klass)
{
	self->priv = seafile_crypt_key_get_instance_private (self);
}

static void
seafile_crypt_key_finalize (GObject * obj)
{
	SeafileCryptKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, SEAFILE_TYPE_CRYPT_KEY, SeafileCryptKey);
	_g_free0 (self->priv->_key);
	_g_free0 (self->priv->_iv);
	G_OBJECT_CLASS (seafile_crypt_key_parent_class)->finalize (obj);
}

static GType
seafile_crypt_key_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (SeafileCryptKeyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) seafile_crypt_key_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (SeafileCryptKey), 0, (GInstanceInitFunc) seafile_crypt_key_instance_init, NULL };
	GType seafile_crypt_key_type_id;
	seafile_crypt_key_type_id = g_type_register_static (G_TYPE_OBJECT, "SeafileCryptKey", &g_define_type_info, 0);
	SeafileCryptKey_private_offset = g_type_add_instance_private (seafile_crypt_key_type_id, sizeof (SeafileCryptKeyPrivate));
	return seafile_crypt_key_type_id;
}

GType
seafile_crypt_key_get_type (void)
{
	static volatile gsize seafile_crypt_key_type_id__once = 0;
	if (g_once_init_enter (&seafile_crypt_key_type_id__once)) {
		GType seafile_crypt_key_type_id;
		seafile_crypt_key_type_id = seafile_crypt_key_get_type_once ();
		g_once_init_leave (&seafile_crypt_key_type_id__once, seafile_crypt_key_type_id);
	}
	return seafile_crypt_key_type_id__once;
}

static void
_vala_seafile_crypt_key_get_property (GObject * object,
                                      guint property_id,
                                      GValue * value,
                                      GParamSpec * pspec)
{
	SeafileCryptKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SEAFILE_TYPE_CRYPT_KEY, SeafileCryptKey);
	switch (property_id) {
		case SEAFILE_CRYPT_KEY_KEY_PROPERTY:
		g_value_set_string (value, seafile_crypt_key_get_key (self));
		break;
		case SEAFILE_CRYPT_KEY_IV_PROPERTY:
		g_value_set_string (value, seafile_crypt_key_get_iv (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_seafile_crypt_key_set_property (GObject * object,
                                      guint property_id,
                                      const GValue * value,
                                      GParamSpec * pspec)
{
	SeafileCryptKey * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, SEAFILE_TYPE_CRYPT_KEY, SeafileCryptKey);
	switch (property_id) {
		case SEAFILE_CRYPT_KEY_KEY_PROPERTY:
		seafile_crypt_key_set_key (self, g_value_get_string (value));
		break;
		case SEAFILE_CRYPT_KEY_IV_PROPERTY:
		seafile_crypt_key_set_iv (self, g_value_get_string (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

