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

/*
 * Copyright © 2023 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>

#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_ATTACHMENT_0_PROPERTY,
	OBJECTS_ATTACHMENT_ID_PROPERTY,
	OBJECTS_ATTACHMENT_ITEM_ID_PROPERTY,
	OBJECTS_ATTACHMENT_FILE_TYPE_PROPERTY,
	OBJECTS_ATTACHMENT_FILE_NAME_PROPERTY,
	OBJECTS_ATTACHMENT_FILE_SIZE_PROPERTY,
	OBJECTS_ATTACHMENT_FILE_PATH_PROPERTY,
	OBJECTS_ATTACHMENT_ITEM_PROPERTY,
	OBJECTS_ATTACHMENT_NUM_PROPERTIES
};
static GParamSpec* objects_attachment_properties[OBJECTS_ATTACHMENT_NUM_PROPERTIES];
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	OBJECTS_ATTACHMENT_DELETED_SIGNAL,
	OBJECTS_ATTACHMENT_NUM_SIGNALS
};
static guint objects_attachment_signals[OBJECTS_ATTACHMENT_NUM_SIGNALS] = {0};

struct _ObjectsAttachmentPrivate {
	gchar* _id;
	gchar* _item_id;
	gchar* _file_type;
	gchar* _file_name;
	gchar* _file_size;
	gchar* _file_path;
	ObjectsItem* _item;
};

static gint ObjectsAttachment_private_offset;
static gpointer objects_attachment_parent_class = NULL;

static void objects_attachment_finalize (GObject * obj);
static GType objects_attachment_get_type_once (void);
static void _vala_objects_attachment_get_property (GObject * object,
                                            guint property_id,
                                            GValue * value,
                                            GParamSpec * pspec);
static void _vala_objects_attachment_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_attachment_get_instance_private (ObjectsAttachment* self)
{
	return G_STRUCT_MEMBER_P (self, ObjectsAttachment_private_offset);
}

gchar*
objects_attachment_to_string (ObjectsAttachment* self)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_id;
	_tmp1_ = self->priv->_item_id;
	_tmp2_ = self->priv->_file_type;
	_tmp3_ = self->priv->_file_name;
	_tmp4_ = self->priv->_file_size;
	_tmp5_ = self->priv->_file_path;
	_tmp6_ = g_strdup_printf ("\n" \
"        _________________________________\n" \
"            ID: %s\n" \
"            ITEM ID: %s\n" \
"            FILE TYPE: %s\n" \
"            FILE NAME: %s\n" \
"            FILE SIZE: %s\n" \
"            FILE PATH: %s\n" \
"        ---------------------------------\n" \
"        ", _tmp0_, _tmp1_, _tmp2_, _tmp3_, _tmp4_, _tmp5_);
	result = _tmp6_;
	return result;
}

void
objects_attachment_delete (ObjectsAttachment* self)
{
	ServicesStore* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = services_store_instance ();
	services_store_delete_attachment (_tmp0_, self);
}

ObjectsAttachment*
objects_attachment_duplicate (ObjectsAttachment* self)
{
	ObjectsAttachment* new_attachment = NULL;
	ObjectsAttachment* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	ObjectsAttachment* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = objects_attachment_new ();
	new_attachment = _tmp0_;
	_tmp1_ = self->priv->_file_type;
	objects_attachment_set_file_type (new_attachment, _tmp1_);
	_tmp2_ = self->priv->_file_name;
	objects_attachment_set_file_name (new_attachment, _tmp2_);
	_tmp3_ = self->priv->_file_size;
	objects_attachment_set_file_size (new_attachment, _tmp3_);
	_tmp4_ = self->priv->_file_path;
	objects_attachment_set_file_path (new_attachment, _tmp4_);
	result = new_attachment;
	return result;
}

ObjectsAttachment*
objects_attachment_construct (GType object_type)
{
	ObjectsAttachment * self = NULL;
	self = (ObjectsAttachment*) g_object_new (object_type, NULL);
	return self;
}

ObjectsAttachment*
objects_attachment_new (void)
{
	return objects_attachment_construct (OBJECTS_TYPE_ATTACHMENT);
}

const gchar*
objects_attachment_get_id (ObjectsAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_id;
	result = _tmp0_;
	return result;
}

void
objects_attachment_set_id (ObjectsAttachment* self,
                           const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_attachment_get_id (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_id);
		self->priv->_id = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_attachment_properties[OBJECTS_ATTACHMENT_ID_PROPERTY]);
	}
}

const gchar*
objects_attachment_get_item_id (ObjectsAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_item_id;
	result = _tmp0_;
	return result;
}

void
objects_attachment_set_item_id (ObjectsAttachment* self,
                                const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_attachment_get_item_id (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_item_id);
		self->priv->_item_id = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_attachment_properties[OBJECTS_ATTACHMENT_ITEM_ID_PROPERTY]);
	}
}

const gchar*
objects_attachment_get_file_type (ObjectsAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file_type;
	result = _tmp0_;
	return result;
}

void
objects_attachment_set_file_type (ObjectsAttachment* self,
                                  const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_attachment_get_file_type (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_file_type);
		self->priv->_file_type = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_attachment_properties[OBJECTS_ATTACHMENT_FILE_TYPE_PROPERTY]);
	}
}

const gchar*
objects_attachment_get_file_name (ObjectsAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file_name;
	result = _tmp0_;
	return result;
}

void
objects_attachment_set_file_name (ObjectsAttachment* self,
                                  const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_attachment_get_file_name (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_file_name);
		self->priv->_file_name = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_attachment_properties[OBJECTS_ATTACHMENT_FILE_NAME_PROPERTY]);
	}
}

const gchar*
objects_attachment_get_file_size (ObjectsAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file_size;
	result = _tmp0_;
	return result;
}

void
objects_attachment_set_file_size (ObjectsAttachment* self,
                                  const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_attachment_get_file_size (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_file_size);
		self->priv->_file_size = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_attachment_properties[OBJECTS_ATTACHMENT_FILE_SIZE_PROPERTY]);
	}
}

const gchar*
objects_attachment_get_file_path (ObjectsAttachment* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_file_path;
	result = _tmp0_;
	return result;
}

void
objects_attachment_set_file_path (ObjectsAttachment* self,
                                  const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_attachment_get_file_path (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_file_path);
		self->priv->_file_path = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_attachment_properties[OBJECTS_ATTACHMENT_FILE_PATH_PROPERTY]);
	}
}

ObjectsItem*
objects_attachment_get_item (ObjectsAttachment* self)
{
	ObjectsItem* result;
	ServicesStore* _tmp0_;
	const gchar* _tmp1_;
	ObjectsItem* _tmp2_;
	ObjectsItem* _tmp3_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = services_store_instance ();
	_tmp1_ = self->priv->_item_id;
	_tmp2_ = services_store_get_item (_tmp0_, _tmp1_);
	_g_object_unref0 (self->priv->_item);
	self->priv->_item = _tmp2_;
	_tmp3_ = self->priv->_item;
	result = _tmp3_;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

void
objects_attachment_set_item (ObjectsAttachment* self,
                             ObjectsItem* value)
{
	ObjectsItem* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _g_object_ref0 (value);
	_g_object_unref0 (self->priv->_item);
	self->priv->_item = _tmp0_;
	g_object_notify_by_pspec ((GObject *) self, objects_attachment_properties[OBJECTS_ATTACHMENT_ITEM_PROPERTY]);
}

static void
objects_attachment_class_init (ObjectsAttachmentClass * klass,
                               gpointer klass_data)
{
	objects_attachment_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ObjectsAttachment_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_objects_attachment_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_objects_attachment_set_property;
	G_OBJECT_CLASS (klass)->finalize = objects_attachment_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_ATTACHMENT_ID_PROPERTY, objects_attachment_properties[OBJECTS_ATTACHMENT_ID_PROPERTY] = g_param_spec_string ("id", "id", "id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_ATTACHMENT_ITEM_ID_PROPERTY, objects_attachment_properties[OBJECTS_ATTACHMENT_ITEM_ID_PROPERTY] = g_param_spec_string ("item-id", "item-id", "item-id", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_ATTACHMENT_FILE_TYPE_PROPERTY, objects_attachment_properties[OBJECTS_ATTACHMENT_FILE_TYPE_PROPERTY] = g_param_spec_string ("file-type", "file-type", "file-type", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_ATTACHMENT_FILE_NAME_PROPERTY, objects_attachment_properties[OBJECTS_ATTACHMENT_FILE_NAME_PROPERTY] = g_param_spec_string ("file-name", "file-name", "file-name", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_ATTACHMENT_FILE_SIZE_PROPERTY, objects_attachment_properties[OBJECTS_ATTACHMENT_FILE_SIZE_PROPERTY] = g_param_spec_string ("file-size", "file-size", "file-size", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_ATTACHMENT_FILE_PATH_PROPERTY, objects_attachment_properties[OBJECTS_ATTACHMENT_FILE_PATH_PROPERTY] = g_param_spec_string ("file-path", "file-path", "file-path", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_ATTACHMENT_ITEM_PROPERTY, objects_attachment_properties[OBJECTS_ATTACHMENT_ITEM_PROPERTY] = g_param_spec_object ("item", "item", "item", OBJECTS_TYPE_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	objects_attachment_signals[OBJECTS_ATTACHMENT_DELETED_SIGNAL] = g_signal_new ("deleted", OBJECTS_TYPE_ATTACHMENT, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
objects_attachment_instance_init (ObjectsAttachment * self,
                                  gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	self->priv = objects_attachment_get_instance_private (self);
	_tmp0_ = g_strdup ("");
	self->priv->_id = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_item_id = _tmp1_;
	_tmp2_ = g_strdup ("");
	self->priv->_file_type = _tmp2_;
	_tmp3_ = g_strdup ("");
	self->priv->_file_name = _tmp3_;
	_tmp4_ = g_strdup ("");
	self->priv->_file_size = _tmp4_;
	_tmp5_ = g_strdup ("");
	self->priv->_file_path = _tmp5_;
}

static void
objects_attachment_finalize (GObject * obj)
{
	ObjectsAttachment * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OBJECTS_TYPE_ATTACHMENT, ObjectsAttachment);
	_g_free0 (self->priv->_id);
	_g_free0 (self->priv->_item_id);
	_g_free0 (self->priv->_file_type);
	_g_free0 (self->priv->_file_name);
	_g_free0 (self->priv->_file_size);
	_g_free0 (self->priv->_file_path);
	_g_object_unref0 (self->priv->_item);
	G_OBJECT_CLASS (objects_attachment_parent_class)->finalize (obj);
}

static GType
objects_attachment_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ObjectsAttachmentClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) objects_attachment_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ObjectsAttachment), 0, (GInstanceInitFunc) objects_attachment_instance_init, NULL };
	GType objects_attachment_type_id;
	objects_attachment_type_id = g_type_register_static (G_TYPE_OBJECT, "ObjectsAttachment", &g_define_type_info, 0);
	ObjectsAttachment_private_offset = g_type_add_instance_private (objects_attachment_type_id, sizeof (ObjectsAttachmentPrivate));
	return objects_attachment_type_id;
}

GType
objects_attachment_get_type (void)
{
	static volatile gsize objects_attachment_type_id__once = 0;
	if (g_once_init_enter (&objects_attachment_type_id__once)) {
		GType objects_attachment_type_id;
		objects_attachment_type_id = objects_attachment_get_type_once ();
		g_once_init_leave (&objects_attachment_type_id__once, objects_attachment_type_id);
	}
	return objects_attachment_type_id__once;
}

static void
_vala_objects_attachment_get_property (GObject * object,
                                       guint property_id,
                                       GValue * value,
                                       GParamSpec * pspec)
{
	ObjectsAttachment * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_TYPE_ATTACHMENT, ObjectsAttachment);
	switch (property_id) {
		case OBJECTS_ATTACHMENT_ID_PROPERTY:
		g_value_set_string (value, objects_attachment_get_id (self));
		break;
		case OBJECTS_ATTACHMENT_ITEM_ID_PROPERTY:
		g_value_set_string (value, objects_attachment_get_item_id (self));
		break;
		case OBJECTS_ATTACHMENT_FILE_TYPE_PROPERTY:
		g_value_set_string (value, objects_attachment_get_file_type (self));
		break;
		case OBJECTS_ATTACHMENT_FILE_NAME_PROPERTY:
		g_value_set_string (value, objects_attachment_get_file_name (self));
		break;
		case OBJECTS_ATTACHMENT_FILE_SIZE_PROPERTY:
		g_value_set_string (value, objects_attachment_get_file_size (self));
		break;
		case OBJECTS_ATTACHMENT_FILE_PATH_PROPERTY:
		g_value_set_string (value, objects_attachment_get_file_path (self));
		break;
		case OBJECTS_ATTACHMENT_ITEM_PROPERTY:
		g_value_set_object (value, objects_attachment_get_item (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_objects_attachment_set_property (GObject * object,
                                       guint property_id,
                                       const GValue * value,
                                       GParamSpec * pspec)
{
	ObjectsAttachment * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_TYPE_ATTACHMENT, ObjectsAttachment);
	switch (property_id) {
		case OBJECTS_ATTACHMENT_ID_PROPERTY:
		objects_attachment_set_id (self, g_value_get_string (value));
		break;
		case OBJECTS_ATTACHMENT_ITEM_ID_PROPERTY:
		objects_attachment_set_item_id (self, g_value_get_string (value));
		break;
		case OBJECTS_ATTACHMENT_FILE_TYPE_PROPERTY:
		objects_attachment_set_file_type (self, g_value_get_string (value));
		break;
		case OBJECTS_ATTACHMENT_FILE_NAME_PROPERTY:
		objects_attachment_set_file_name (self, g_value_get_string (value));
		break;
		case OBJECTS_ATTACHMENT_FILE_SIZE_PROPERTY:
		objects_attachment_set_file_size (self, g_value_get_string (value));
		break;
		case OBJECTS_ATTACHMENT_FILE_PATH_PROPERTY:
		objects_attachment_set_file_path (self, g_value_get_string (value));
		break;
		case OBJECTS_ATTACHMENT_ITEM_PROPERTY:
		objects_attachment_set_item (self, g_value_get_object (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;
}

