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

/*
* Copyright © 2025 Alain M. (https://github.com/alainm23/planify)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Alain M. <alainmh23@gmail.com>
*/

#include "planify.h"
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <json-glib/json-glib.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  {
	OBJECTS_RELEASE_0_PROPERTY,
	OBJECTS_RELEASE_RELEASE_TYPE_PROPERTY,
	OBJECTS_RELEASE_VERSION_PROPERTY,
	OBJECTS_RELEASE_TIMESTAMP_PROPERTY,
	OBJECTS_RELEASE_DESCRIPTION_PROPERTY,
	OBJECTS_RELEASE_NUM_PROPERTIES
};
static GParamSpec* objects_release_properties[OBJECTS_RELEASE_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))

struct _ObjectsReleasePrivate {
	gchar* _release_type;
	gchar* _version;
	gint64 _timestamp;
	gchar* _description;
};

static gint ObjectsRelease_private_offset;
static gpointer objects_release_parent_class = NULL;

static void objects_release_finalize (GObject * obj);
static GType objects_release_get_type_once (void);
static void _vala_objects_release_get_property (GObject * object,
                                         guint property_id,
                                         GValue * value,
                                         GParamSpec * pspec);
static void _vala_objects_release_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
objects_release_get_instance_private (ObjectsRelease* self)
{
	return G_STRUCT_MEMBER_P (self, ObjectsRelease_private_offset);
}

static gint64
int64_parse (const gchar* str,
             guint _base)
{
	gint64 result;
	g_return_val_if_fail (str != NULL, -1LL);
	result = g_ascii_strtoll (str, NULL, _base);
	return result;
}

ObjectsRelease*
objects_release_construct_from_json (GType object_type,
                                     JsonObject* object)
{
	ObjectsRelease * self = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	g_return_val_if_fail (object != NULL, NULL);
	self = (ObjectsRelease*) g_object_new (object_type, NULL);
	_tmp0_ = json_object_get_string_member (object, "type");
	objects_release_set_release_type (self, _tmp0_);
	_tmp1_ = json_object_get_string_member (object, "version");
	objects_release_set_version (self, _tmp1_);
	_tmp2_ = json_object_get_string_member (object, "timestamp");
	objects_release_set_timestamp (self, int64_parse (_tmp2_, (guint) 0));
	if (json_object_has_member (object, "description")) {
		const gchar* _tmp3_;
		_tmp3_ = json_object_get_string_member (object, "description");
		objects_release_set_description (self, _tmp3_);
	} else {
		objects_release_set_description (self, "");
	}
	return self;
}

ObjectsRelease*
objects_release_new_from_json (JsonObject* object)
{
	return objects_release_construct_from_json (OBJECTS_TYPE_RELEASE, object);
}

static gint
string_index_of (const gchar* self,
                 const gchar* needle,
                 gint start_index)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	g_return_val_if_fail (needle != NULL, -1);
	_tmp0_ = strstr (((gchar*) self) + start_index, (gchar*) needle);
	_result_ = _tmp0_;
	_tmp1_ = _result_;
	if (_tmp1_ != NULL) {
		gchar* _tmp2_;
		_tmp2_ = _result_;
		result = (gint) (_tmp2_ - ((gchar*) self));
		return result;
	} else {
		result = -1;
		return result;
	}
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

gchar*
objects_release_get_release_message (ObjectsRelease* self)
{
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	gint start = 0;
	const gchar* _tmp3_;
	gint end = 0;
	const gchar* _tmp4_;
	gchar* message = NULL;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	const gchar* _tmp10_ = NULL;
	const gchar* _tmp11_;
	gchar* _tmp13_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp1_ = self->priv->_description;
	if (_tmp1_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp2_;
		_tmp2_ = self->priv->_description;
		_tmp0_ = g_strcmp0 (_tmp2_, "") == 0;
	}
	if (_tmp0_) {
		result = NULL;
		return result;
	}
	_tmp3_ = self->priv->_description;
	start = string_index_of (_tmp3_, "<p>", 0);
	if (start == -1) {
		result = NULL;
		return result;
	}
	start += 3;
	_tmp4_ = self->priv->_description;
	end = string_index_of (_tmp4_, "</p>", start);
	if (end == -1) {
		result = NULL;
		return result;
	}
	_tmp5_ = self->priv->_description;
	_tmp6_ = string_substring (_tmp5_, (glong) start, (glong) (end - start));
	_tmp7_ = _tmp6_;
	_tmp8_ = string_strip (_tmp7_);
	_tmp9_ = _tmp8_;
	_g_free0 (_tmp7_);
	message = _tmp9_;
	_tmp11_ = message;
	if (g_strcmp0 (_tmp11_, "") != 0) {
		const gchar* _tmp12_;
		_tmp12_ = message;
		_tmp10_ = _tmp12_;
	} else {
		_tmp10_ = NULL;
	}
	_tmp13_ = g_strdup (_tmp10_);
	result = _tmp13_;
	_g_free0 (message);
	return result;
}

ObjectsRelease*
objects_release_construct (GType object_type)
{
	ObjectsRelease * self = NULL;
	self = (ObjectsRelease*) g_object_new (object_type, NULL);
	return self;
}

ObjectsRelease*
objects_release_new (void)
{
	return objects_release_construct (OBJECTS_TYPE_RELEASE);
}

const gchar*
objects_release_get_release_type (ObjectsRelease* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_release_type;
	result = _tmp0_;
	return result;
}

void
objects_release_set_release_type (ObjectsRelease* self,
                                  const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_release_get_release_type (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_release_type);
		self->priv->_release_type = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_release_properties[OBJECTS_RELEASE_RELEASE_TYPE_PROPERTY]);
	}
}

const gchar*
objects_release_get_version (ObjectsRelease* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_version;
	result = _tmp0_;
	return result;
}

void
objects_release_set_version (ObjectsRelease* self,
                             const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_release_get_version (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_version);
		self->priv->_version = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_release_properties[OBJECTS_RELEASE_VERSION_PROPERTY]);
	}
}

gint64
objects_release_get_timestamp (ObjectsRelease* self)
{
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	result = self->priv->_timestamp;
	return result;
}

void
objects_release_set_timestamp (ObjectsRelease* self,
                               gint64 value)
{
	gint64 old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_release_get_timestamp (self);
	if (old_value != value) {
		self->priv->_timestamp = value;
		g_object_notify_by_pspec ((GObject *) self, objects_release_properties[OBJECTS_RELEASE_TIMESTAMP_PROPERTY]);
	}
}

const gchar*
objects_release_get_description (ObjectsRelease* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_description;
	result = _tmp0_;
	return result;
}

void
objects_release_set_description (ObjectsRelease* self,
                                 const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_release_get_description (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_description);
		self->priv->_description = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_release_properties[OBJECTS_RELEASE_DESCRIPTION_PROPERTY]);
	}
}

static void
objects_release_class_init (ObjectsReleaseClass * klass,
                            gpointer klass_data)
{
	objects_release_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ObjectsRelease_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_objects_release_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_objects_release_set_property;
	G_OBJECT_CLASS (klass)->finalize = objects_release_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_RELEASE_RELEASE_TYPE_PROPERTY, objects_release_properties[OBJECTS_RELEASE_RELEASE_TYPE_PROPERTY] = g_param_spec_string ("release-type", "release-type", "release-type", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_RELEASE_VERSION_PROPERTY, objects_release_properties[OBJECTS_RELEASE_VERSION_PROPERTY] = g_param_spec_string ("version", "version", "version", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_RELEASE_TIMESTAMP_PROPERTY, objects_release_properties[OBJECTS_RELEASE_TIMESTAMP_PROPERTY] = g_param_spec_int64 ("timestamp", "timestamp", "timestamp", G_MININT64, G_MAXINT64, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_RELEASE_DESCRIPTION_PROPERTY, objects_release_properties[OBJECTS_RELEASE_DESCRIPTION_PROPERTY] = g_param_spec_string ("description", "description", "description", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
}

static void
objects_release_instance_init (ObjectsRelease * self,
                               gpointer klass)
{
	self->priv = objects_release_get_instance_private (self);
}

static void
objects_release_finalize (GObject * obj)
{
	ObjectsRelease * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OBJECTS_TYPE_RELEASE, ObjectsRelease);
	_g_free0 (self->priv->_release_type);
	_g_free0 (self->priv->_version);
	_g_free0 (self->priv->_description);
	G_OBJECT_CLASS (objects_release_parent_class)->finalize (obj);
}

static GType
objects_release_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ObjectsReleaseClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) objects_release_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ObjectsRelease), 0, (GInstanceInitFunc) objects_release_instance_init, NULL };
	GType objects_release_type_id;
	objects_release_type_id = g_type_register_static (G_TYPE_OBJECT, "ObjectsRelease", &g_define_type_info, 0);
	ObjectsRelease_private_offset = g_type_add_instance_private (objects_release_type_id, sizeof (ObjectsReleasePrivate));
	return objects_release_type_id;
}

GType
objects_release_get_type (void)
{
	static volatile gsize objects_release_type_id__once = 0;
	if (g_once_init_enter (&objects_release_type_id__once)) {
		GType objects_release_type_id;
		objects_release_type_id = objects_release_get_type_once ();
		g_once_init_leave (&objects_release_type_id__once, objects_release_type_id);
	}
	return objects_release_type_id__once;
}

static void
_vala_objects_release_get_property (GObject * object,
                                    guint property_id,
                                    GValue * value,
                                    GParamSpec * pspec)
{
	ObjectsRelease * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_TYPE_RELEASE, ObjectsRelease);
	switch (property_id) {
		case OBJECTS_RELEASE_RELEASE_TYPE_PROPERTY:
		g_value_set_string (value, objects_release_get_release_type (self));
		break;
		case OBJECTS_RELEASE_VERSION_PROPERTY:
		g_value_set_string (value, objects_release_get_version (self));
		break;
		case OBJECTS_RELEASE_TIMESTAMP_PROPERTY:
		g_value_set_int64 (value, objects_release_get_timestamp (self));
		break;
		case OBJECTS_RELEASE_DESCRIPTION_PROPERTY:
		g_value_set_string (value, objects_release_get_description (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_objects_release_set_property (GObject * object,
                                    guint property_id,
                                    const GValue * value,
                                    GParamSpec * pspec)
{
	ObjectsRelease * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_TYPE_RELEASE, ObjectsRelease);
	switch (property_id) {
		case OBJECTS_RELEASE_RELEASE_TYPE_PROPERTY:
		objects_release_set_release_type (self, g_value_get_string (value));
		break;
		case OBJECTS_RELEASE_VERSION_PROPERTY:
		objects_release_set_version (self, g_value_get_string (value));
		break;
		case OBJECTS_RELEASE_TIMESTAMP_PROPERTY:
		objects_release_set_timestamp (self, g_value_get_int64 (value));
		break;
		case OBJECTS_RELEASE_DESCRIPTION_PROPERTY:
		objects_release_set_description (self, g_value_get_string (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;
}

