/* Reminder.c generated by valac 0.56.19, the Vala compiler
 * generated from Reminder.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 <glib.h>
#include <stdlib.h>
#include <string.h>
#include <glib-object.h>
#include <json-glib/json-glib.h>
#include <gio/gio.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_REMINDER_0_PROPERTY,
	OBJECTS_REMINDER_NOTIFY_UID_PROPERTY,
	OBJECTS_REMINDER_ITEM_ID_PROPERTY,
	OBJECTS_REMINDER_SERVICE_PROPERTY,
	OBJECTS_REMINDER_DUE_PROPERTY,
	OBJECTS_REMINDER_MM_OFFSET_PROPERTY,
	OBJECTS_REMINDER_IS_DELETED_PROPERTY,
	OBJECTS_REMINDER_REMINDER_TYPE_PROPERTY,
	OBJECTS_REMINDER_ITEM_PROPERTY,
	OBJECTS_REMINDER_DATETIME_PROPERTY,
	OBJECTS_REMINDER_RELATIVE_TEXT_PROPERTY,
	OBJECTS_REMINDER_NUM_PROPERTIES
};
static GParamSpec* objects_reminder_properties[OBJECTS_REMINDER_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)))
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
#define __vala_JsonNode_free0(var) ((var == NULL) ? NULL : (var = (_vala_JsonNode_free (var), NULL)))
#define _http_response_unref0(var) ((var == NULL) ? NULL : (var = (http_response_unref (var), NULL)))

struct _ObjectsReminderPrivate {
	gint64 _notify_uid;
	gchar* _item_id;
	gchar* _service;
	ObjectsDueDate* _due;
	gint _mm_offset;
	gint _is_deleted;
	ReminderType _reminder_type;
	ObjectsItem* _item;
	GDateTime* _datetime;
	gchar* _relative_text;
};

static gint ObjectsReminder_private_offset;
static gpointer objects_reminder_parent_class = NULL;

static gchar* objects_reminder_real_get_add_json (ObjectsBaseObject* base,
                                           const gchar* temp_id,
                                           const gchar* uuid);
static gchar* objects_reminder_real_get_update_json (ObjectsBaseObject* base,
                                              const gchar* uuid,
                                              const gchar* temp_id);
static void _vala_JsonNode_free (JsonNode* self);
static void ___lambda28_ (ObjectsReminder* self,
                   GObject* obj,
                   GAsyncResult* res);
static void ____lambda28__gasync_ready_callback (GObject* source_object,
                                          GAsyncResult* res,
                                          gpointer self);
static GObject * objects_reminder_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static void _objects_reminder___lambda29_ (ObjectsReminder* self);
static void __objects_reminder___lambda29__objects_base_object_deleted (ObjectsBaseObject* _sender,
                                                                 gpointer self);
static void objects_reminder_finalize (GObject * obj);
static GType objects_reminder_get_type_once (void);
static void _vala_objects_reminder_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_objects_reminder_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_reminder_get_instance_private (ObjectsReminder* self)
{
	return G_STRUCT_MEMBER_P (self, ObjectsReminder_private_offset);
}

ObjectsReminder*
objects_reminder_construct_from_json (GType object_type,
                                      JsonNode* node)
{
	ObjectsReminder * self = NULL;
	JsonObject* _tmp0_;
	const gchar* _tmp1_;
	JsonObject* _tmp2_;
	const gchar* _tmp3_;
	ReminderType _tmp4_ = 0;
	JsonObject* _tmp5_;
	const gchar* _tmp6_;
	JsonObject* _tmp7_;
	ReminderType _tmp8_;
	g_return_val_if_fail (node != NULL, NULL);
	self = (ObjectsReminder*) objects_base_object_construct (object_type);
	_tmp0_ = json_node_get_object (node);
	_tmp1_ = json_object_get_string_member (_tmp0_, "id");
	objects_base_object_set_id ((ObjectsBaseObject*) self, _tmp1_);
	_tmp2_ = json_node_get_object (node);
	_tmp3_ = json_object_get_string_member (_tmp2_, "item_id");
	objects_reminder_set_item_id (self, _tmp3_);
	_tmp5_ = json_node_get_object (node);
	_tmp6_ = json_object_get_string_member (_tmp5_, "type");
	if (g_strcmp0 (_tmp6_, "absolute") == 0) {
		_tmp4_ = REMINDER_TYPE_ABSOLUTE;
	} else {
		_tmp4_ = REMINDER_TYPE_RELATIVE;
	}
	objects_reminder_set_reminder_type (self, _tmp4_);
	_tmp7_ = json_node_get_object (node);
	objects_reminder_set_mm_offset (self, (gint) ((gint32) json_object_get_int_member (_tmp7_, "item_id")));
	_tmp8_ = self->priv->_reminder_type;
	if (_tmp8_ == REMINDER_TYPE_ABSOLUTE) {
		ObjectsDueDate* _tmp9_;
		JsonObject* _tmp10_;
		JsonObject* _tmp11_;
		_tmp9_ = self->priv->_due;
		_tmp10_ = json_node_get_object (node);
		_tmp11_ = json_object_get_object_member (_tmp10_, "due");
		objects_due_date_update_from_todoist_json (_tmp9_, _tmp11_);
	}
	return self;
}

ObjectsReminder*
objects_reminder_new_from_json (JsonNode* node)
{
	return objects_reminder_construct_from_json (OBJECTS_TYPE_REMINDER, node);
}

static gchar*
objects_reminder_real_get_add_json (ObjectsBaseObject* base,
                                    const gchar* temp_id,
                                    const gchar* uuid)
{
	ObjectsReminder * self;
	gchar* _tmp0_;
	gchar* result;
	self = (ObjectsReminder*) base;
	g_return_val_if_fail (temp_id != NULL, NULL);
	g_return_val_if_fail (uuid != NULL, NULL);
	_tmp0_ = objects_base_object_get_update_json ((ObjectsBaseObject*) self, uuid, temp_id);
	result = _tmp0_;
	return result;
}

static void
_vala_JsonNode_free (JsonNode* self)
{
	g_boxed_free (json_node_get_type (), self);
}

static gchar*
objects_reminder_real_get_update_json (ObjectsBaseObject* base,
                                       const gchar* uuid,
                                       const gchar* temp_id)
{
	ObjectsReminder * self;
	JsonBuilder* builder = NULL;
	JsonBuilder* _tmp0_;
	JsonBuilder* _tmp1_;
	JsonBuilder* _tmp2_;
	JsonBuilder* _tmp3_;
	JsonBuilder* _tmp4_;
	JsonBuilder* _tmp5_;
	const gchar* _tmp6_ = NULL;
	JsonBuilder* _tmp7_;
	JsonBuilder* _tmp8_;
	JsonBuilder* _tmp9_;
	JsonBuilder* _tmp12_;
	JsonBuilder* _tmp13_;
	JsonBuilder* _tmp18_;
	JsonBuilder* _tmp19_;
	const gchar* _tmp20_;
	JsonBuilder* _tmp21_;
	JsonBuilder* _tmp22_;
	ReminderType _tmp23_;
	gchar* _tmp24_;
	gchar* _tmp25_;
	JsonBuilder* _tmp26_;
	JsonBuilder* _tmp27_;
	gint _tmp28_;
	ReminderType _tmp29_;
	JsonBuilder* _tmp38_;
	JsonBuilder* _tmp39_;
	JsonBuilder* _tmp40_;
	JsonBuilder* _tmp41_;
	JsonGenerator* generator = NULL;
	JsonGenerator* _tmp42_;
	JsonNode* root = NULL;
	JsonBuilder* _tmp43_;
	JsonNode* _tmp44_;
	gchar* _tmp45_;
	gchar* result;
	self = (ObjectsReminder*) base;
	g_return_val_if_fail (uuid != NULL, NULL);
	_tmp0_ = json_builder_new ();
	builder = _tmp0_;
	_tmp1_ = builder;
	json_builder_begin_object (_tmp1_);
	_tmp2_ = builder;
	json_builder_set_member_name (_tmp2_, "commands");
	_tmp3_ = builder;
	json_builder_begin_array (_tmp3_);
	_tmp4_ = builder;
	json_builder_begin_object (_tmp4_);
	_tmp5_ = builder;
	json_builder_set_member_name (_tmp5_, "type");
	if (temp_id == NULL) {
		_tmp6_ = "reminder_update";
	} else {
		_tmp6_ = "reminder_add";
	}
	_tmp7_ = builder;
	json_builder_add_string_value (_tmp7_, _tmp6_);
	_tmp8_ = builder;
	json_builder_set_member_name (_tmp8_, "uuid");
	_tmp9_ = builder;
	json_builder_add_string_value (_tmp9_, uuid);
	if (temp_id != NULL) {
		JsonBuilder* _tmp10_;
		JsonBuilder* _tmp11_;
		_tmp10_ = builder;
		json_builder_set_member_name (_tmp10_, "temp_id");
		_tmp11_ = builder;
		json_builder_add_string_value (_tmp11_, temp_id);
	}
	_tmp12_ = builder;
	json_builder_set_member_name (_tmp12_, "args");
	_tmp13_ = builder;
	json_builder_begin_object (_tmp13_);
	if (temp_id == NULL) {
		JsonBuilder* _tmp14_;
		JsonBuilder* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		_tmp14_ = builder;
		json_builder_set_member_name (_tmp14_, "id");
		_tmp15_ = builder;
		_tmp16_ = objects_base_object_get_id ((ObjectsBaseObject*) self);
		_tmp17_ = _tmp16_;
		json_builder_add_string_value (_tmp15_, _tmp17_);
	}
	_tmp18_ = builder;
	json_builder_set_member_name (_tmp18_, "item_id");
	_tmp19_ = builder;
	_tmp20_ = self->priv->_item_id;
	json_builder_add_string_value (_tmp19_, _tmp20_);
	_tmp21_ = builder;
	json_builder_set_member_name (_tmp21_, "type");
	_tmp22_ = builder;
	_tmp23_ = self->priv->_reminder_type;
	_tmp24_ = reminder_type_to_string (_tmp23_);
	_tmp25_ = _tmp24_;
	json_builder_add_string_value (_tmp22_, _tmp25_);
	_g_free0 (_tmp25_);
	_tmp26_ = builder;
	json_builder_set_member_name (_tmp26_, "minute_offset");
	_tmp27_ = builder;
	_tmp28_ = self->priv->_mm_offset;
	json_builder_add_int_value (_tmp27_, (gint64) _tmp28_);
	_tmp29_ = self->priv->_reminder_type;
	if (_tmp29_ == REMINDER_TYPE_ABSOLUTE) {
		JsonBuilder* _tmp30_;
		JsonBuilder* _tmp31_;
		JsonBuilder* _tmp32_;
		JsonBuilder* _tmp33_;
		ObjectsDueDate* _tmp34_;
		const gchar* _tmp35_;
		const gchar* _tmp36_;
		JsonBuilder* _tmp37_;
		_tmp30_ = builder;
		json_builder_set_member_name (_tmp30_, "due");
		_tmp31_ = builder;
		json_builder_begin_object (_tmp31_);
		_tmp32_ = builder;
		json_builder_set_member_name (_tmp32_, "date");
		_tmp33_ = builder;
		_tmp34_ = self->priv->_due;
		_tmp35_ = objects_due_date_get_date (_tmp34_);
		_tmp36_ = _tmp35_;
		json_builder_add_string_value (_tmp33_, _tmp36_);
		_tmp37_ = builder;
		json_builder_end_object (_tmp37_);
	}
	_tmp38_ = builder;
	json_builder_end_object (_tmp38_);
	_tmp39_ = builder;
	json_builder_end_object (_tmp39_);
	_tmp40_ = builder;
	json_builder_end_array (_tmp40_);
	_tmp41_ = builder;
	json_builder_end_object (_tmp41_);
	_tmp42_ = json_generator_new ();
	generator = _tmp42_;
	_tmp43_ = builder;
	_tmp44_ = json_builder_get_root (_tmp43_);
	root = _tmp44_;
	json_generator_set_root (generator, root);
	_tmp45_ = json_generator_to_data (generator, NULL);
	result = _tmp45_;
	__vala_JsonNode_free0 (root);
	_g_object_unref0 (generator);
	_g_object_unref0 (builder);
	return result;
}

static void
___lambda28_ (ObjectsReminder* self,
              GObject* obj,
              GAsyncResult* res)
{
	ServicesTodoist* _tmp0_;
	ServicesTodoist* _tmp1_;
	HttpResponse* _tmp2_;
	HttpResponse* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	gboolean _tmp6_;
	g_return_if_fail (res != NULL);
	_tmp0_ = services_todoist_get_default ();
	_tmp1_ = _tmp0_;
	_tmp2_ = services_todoist_delete_finish (_tmp1_, res);
	_tmp3_ = _tmp2_;
	_tmp4_ = http_response_get_status (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = _tmp5_;
	_http_response_unref0 (_tmp3_);
	_g_object_unref0 (_tmp1_);
	if (_tmp6_) {
		ServicesStore* _tmp7_;
		_tmp7_ = services_store_instance ();
		services_store_delete_reminder (_tmp7_, self);
		objects_base_object_set_loading ((ObjectsBaseObject*) self, FALSE);
	}
}

static void
____lambda28__gasync_ready_callback (GObject* source_object,
                                     GAsyncResult* res,
                                     gpointer self)
{
	___lambda28_ ((ObjectsReminder*) self, source_object, res);
	g_object_unref (self);
}

void
objects_reminder_delete (ObjectsReminder* self)
{
	ObjectsItem* _tmp0_;
	ObjectsItem* _tmp1_;
	ObjectsProject* _tmp2_;
	ObjectsProject* _tmp3_;
	SourceType _tmp4_;
	SourceType _tmp5_;
	g_return_if_fail (self != NULL);
	_tmp0_ = objects_reminder_get_item (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = objects_item_get_project (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = objects_project_get_source_type (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_ == SOURCE_TYPE_TODOIST) {
		ServicesTodoist* _tmp6_;
		ServicesTodoist* _tmp7_;
		objects_base_object_set_loading ((ObjectsBaseObject*) self, TRUE);
		_tmp6_ = services_todoist_get_default ();
		_tmp7_ = _tmp6_;
		services_todoist_delete (_tmp7_, (ObjectsBaseObject*) self, ____lambda28__gasync_ready_callback, g_object_ref (self));
		_g_object_unref0 (_tmp7_);
	} else {
		ServicesStore* _tmp8_;
		_tmp8_ = services_store_instance ();
		services_store_delete_reminder (_tmp8_, self);
		objects_base_object_set_loading ((ObjectsBaseObject*) self, FALSE);
	}
}

ObjectsReminder*
objects_reminder_duplicate (ObjectsReminder* self)
{
	ObjectsReminder* new_reminder = NULL;
	ObjectsReminder* _tmp0_;
	gint64 _tmp1_;
	const gchar* _tmp2_;
	ObjectsDueDate* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	ObjectsReminder* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = objects_reminder_new ();
	new_reminder = _tmp0_;
	_tmp1_ = self->priv->_notify_uid;
	objects_reminder_set_notify_uid (new_reminder, _tmp1_);
	_tmp2_ = self->priv->_service;
	objects_reminder_set_service (new_reminder, _tmp2_);
	_tmp3_ = self->priv->_due;
	objects_reminder_set_due (new_reminder, _tmp3_);
	_tmp4_ = self->priv->_mm_offset;
	objects_reminder_set_mm_offset (new_reminder, _tmp4_);
	_tmp5_ = self->priv->_mm_offset;
	objects_reminder_set_mm_offset (new_reminder, _tmp5_);
	result = new_reminder;
	return result;
}

ObjectsReminder*
objects_reminder_construct (GType object_type)
{
	ObjectsReminder * self = NULL;
	self = (ObjectsReminder*) objects_base_object_construct (object_type);
	return self;
}

ObjectsReminder*
objects_reminder_new (void)
{
	return objects_reminder_construct (OBJECTS_TYPE_REMINDER);
}

gint64
objects_reminder_get_notify_uid (ObjectsReminder* self)
{
	gint64 result;
	g_return_val_if_fail (self != NULL, -1LL);
	result = self->priv->_notify_uid;
	return result;
}

void
objects_reminder_set_notify_uid (ObjectsReminder* self,
                                 gint64 value)
{
	gint64 old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_reminder_get_notify_uid (self);
	if (old_value != value) {
		self->priv->_notify_uid = value;
		g_object_notify_by_pspec ((GObject *) self, objects_reminder_properties[OBJECTS_REMINDER_NOTIFY_UID_PROPERTY]);
	}
}

const gchar*
objects_reminder_get_item_id (ObjectsReminder* 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_reminder_set_item_id (ObjectsReminder* self,
                              const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_reminder_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_reminder_properties[OBJECTS_REMINDER_ITEM_ID_PROPERTY]);
	}
}

const gchar*
objects_reminder_get_service (ObjectsReminder* self)
{
	const gchar* result;
	const gchar* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_service;
	result = _tmp0_;
	return result;
}

void
objects_reminder_set_service (ObjectsReminder* self,
                              const gchar* value)
{
	gchar* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_reminder_get_service (self);
	if (g_strcmp0 (value, old_value) != 0) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (value);
		_g_free0 (self->priv->_service);
		self->priv->_service = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_reminder_properties[OBJECTS_REMINDER_SERVICE_PROPERTY]);
	}
}

ObjectsDueDate*
objects_reminder_get_due (ObjectsReminder* self)
{
	ObjectsDueDate* result;
	ObjectsDueDate* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_due;
	result = _tmp0_;
	return result;
}

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

void
objects_reminder_set_due (ObjectsReminder* self,
                          ObjectsDueDate* value)
{
	ObjectsDueDate* old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_reminder_get_due (self);
	if (old_value != value) {
		ObjectsDueDate* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_due);
		self->priv->_due = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, objects_reminder_properties[OBJECTS_REMINDER_DUE_PROPERTY]);
	}
}

gint
objects_reminder_get_mm_offset (ObjectsReminder* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_mm_offset;
	return result;
}

void
objects_reminder_set_mm_offset (ObjectsReminder* self,
                                gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_reminder_get_mm_offset (self);
	if (old_value != value) {
		self->priv->_mm_offset = value;
		g_object_notify_by_pspec ((GObject *) self, objects_reminder_properties[OBJECTS_REMINDER_MM_OFFSET_PROPERTY]);
	}
}

gint
objects_reminder_get_is_deleted (ObjectsReminder* self)
{
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	result = self->priv->_is_deleted;
	return result;
}

void
objects_reminder_set_is_deleted (ObjectsReminder* self,
                                 gint value)
{
	gint old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_reminder_get_is_deleted (self);
	if (old_value != value) {
		self->priv->_is_deleted = value;
		g_object_notify_by_pspec ((GObject *) self, objects_reminder_properties[OBJECTS_REMINDER_IS_DELETED_PROPERTY]);
	}
}

ReminderType
objects_reminder_get_reminder_type (ObjectsReminder* self)
{
	ReminderType result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_reminder_type;
	return result;
}

void
objects_reminder_set_reminder_type (ObjectsReminder* self,
                                    ReminderType value)
{
	ReminderType old_value;
	g_return_if_fail (self != NULL);
	old_value = objects_reminder_get_reminder_type (self);
	if (old_value != value) {
		self->priv->_reminder_type = value;
		g_object_notify_by_pspec ((GObject *) self, objects_reminder_properties[OBJECTS_REMINDER_REMINDER_TYPE_PROPERTY]);
	}
}

ObjectsItem*
objects_reminder_get_item (ObjectsReminder* 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;
}

void
objects_reminder_set_item (ObjectsReminder* 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_reminder_properties[OBJECTS_REMINDER_ITEM_PROPERTY]);
}

static gpointer
_g_date_time_ref0 (gpointer self)
{
	return self ? g_date_time_ref (self) : NULL;
}

GDateTime*
objects_reminder_get_datetime (ObjectsReminder* self)
{
	GDateTime* result;
	ReminderType _tmp0_;
	GDateTime* _tmp13_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_reminder_type;
	if (_tmp0_ == REMINDER_TYPE_ABSOLUTE) {
		ObjectsDueDate* _tmp1_;
		GDateTime* _tmp2_;
		GDateTime* _tmp3_;
		GDateTime* _tmp4_;
		_tmp1_ = self->priv->_due;
		_tmp2_ = objects_due_date_get_datetime (_tmp1_);
		_tmp3_ = _tmp2_;
		_tmp4_ = _g_date_time_ref0 (_tmp3_);
		_g_date_time_unref0 (self->priv->_datetime);
		self->priv->_datetime = _tmp4_;
	} else {
		ObjectsItem* _tmp5_;
		ObjectsItem* _tmp6_;
		ObjectsDueDate* _tmp7_;
		ObjectsDueDate* _tmp8_;
		GDateTime* _tmp9_;
		GDateTime* _tmp10_;
		gint _tmp11_;
		GDateTime* _tmp12_;
		_tmp5_ = objects_reminder_get_item (self);
		_tmp6_ = _tmp5_;
		_tmp7_ = objects_item_get_due (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = objects_due_date_get_datetime (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = self->priv->_mm_offset;
		_tmp12_ = g_date_time_add_minutes (_tmp10_, _tmp11_ * -1);
		_g_date_time_unref0 (self->priv->_datetime);
		self->priv->_datetime = _tmp12_;
	}
	_tmp13_ = self->priv->_datetime;
	result = _tmp13_;
	return result;
}

const gchar*
objects_reminder_get_relative_text (ObjectsReminder* self)
{
	const gchar* result;
	gchar* _tmp0_;
	ReminderType _tmp1_;
	const gchar* _tmp8_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup ("");
	_g_free0 (self->priv->_relative_text);
	self->priv->_relative_text = _tmp0_;
	_tmp1_ = self->priv->_reminder_type;
	if (_tmp1_ == REMINDER_TYPE_ABSOLUTE) {
		ObjectsDueDate* _tmp2_;
		GDateTime* _tmp3_;
		GDateTime* _tmp4_;
		gchar* _tmp5_;
		_tmp2_ = self->priv->_due;
		_tmp3_ = objects_due_date_get_datetime (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp5_ = utils_datetime_get_relative_date_from_date (_tmp4_);
		_g_free0 (self->priv->_relative_text);
		self->priv->_relative_text = _tmp5_;
	} else {
		gint _tmp6_;
		gchar* _tmp7_;
		_tmp6_ = self->priv->_mm_offset;
		_tmp7_ = util_get_reminders_mm_offset_text (_tmp6_);
		_g_free0 (self->priv->_relative_text);
		self->priv->_relative_text = _tmp7_;
	}
	_tmp8_ = self->priv->_relative_text;
	result = _tmp8_;
	return result;
}

static void
_objects_reminder___lambda29_ (ObjectsReminder* self)
{
	ServicesStore* _tmp0_;
	_tmp0_ = services_store_instance ();
	g_signal_emit_by_name (_tmp0_, "reminder-deleted", self);
}

static void
__objects_reminder___lambda29__objects_base_object_deleted (ObjectsBaseObject* _sender,
                                                            gpointer self)
{
	_objects_reminder___lambda29_ ((ObjectsReminder*) self);
}

static GObject *
objects_reminder_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	ObjectsReminder * self;
	parent_class = G_OBJECT_CLASS (objects_reminder_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OBJECTS_TYPE_REMINDER, ObjectsReminder);
	g_signal_connect_object ((ObjectsBaseObject*) self, "deleted", (GCallback) __objects_reminder___lambda29__objects_base_object_deleted, self, 0);
	return obj;
}

static void
objects_reminder_class_init (ObjectsReminderClass * klass,
                             gpointer klass_data)
{
	objects_reminder_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ObjectsReminder_private_offset);
	((ObjectsBaseObjectClass *) klass)->get_add_json = (gchar* (*) (ObjectsBaseObject*, const gchar*, const gchar*)) objects_reminder_real_get_add_json;
	((ObjectsBaseObjectClass *) klass)->get_update_json = (gchar* (*) (ObjectsBaseObject*, const gchar*, const gchar*)) objects_reminder_real_get_update_json;
	G_OBJECT_CLASS (klass)->get_property = _vala_objects_reminder_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_objects_reminder_set_property;
	G_OBJECT_CLASS (klass)->constructor = objects_reminder_constructor;
	G_OBJECT_CLASS (klass)->finalize = objects_reminder_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_NOTIFY_UID_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_NOTIFY_UID_PROPERTY] = g_param_spec_int64 ("notify-uid", "notify-uid", "notify-uid", G_MININT64, G_MAXINT64, (gint64) 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_ITEM_ID_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_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_REMINDER_SERVICE_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_SERVICE_PROPERTY] = g_param_spec_string ("service", "service", "service", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_DUE_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_DUE_PROPERTY] = g_param_spec_object ("due", "due", "due", OBJECTS_TYPE_DUE_DATE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_MM_OFFSET_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_MM_OFFSET_PROPERTY] = g_param_spec_int ("mm-offset", "mm-offset", "mm-offset", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_IS_DELETED_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_IS_DELETED_PROPERTY] = g_param_spec_int ("is-deleted", "is-deleted", "is-deleted", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_REMINDER_TYPE_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_REMINDER_TYPE_PROPERTY] = g_param_spec_enum ("reminder-type", "reminder-type", "reminder-type", TYPE_REMINDER_TYPE, REMINDER_TYPE_ABSOLUTE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_ITEM_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_ITEM_PROPERTY] = g_param_spec_object ("item", "item", "item", OBJECTS_TYPE_ITEM, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_DATETIME_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_DATETIME_PROPERTY] = g_param_spec_boxed ("datetime", "datetime", "datetime", G_TYPE_DATE_TIME, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), OBJECTS_REMINDER_RELATIVE_TEXT_PROPERTY, objects_reminder_properties[OBJECTS_REMINDER_RELATIVE_TEXT_PROPERTY] = g_param_spec_string ("relative-text", "relative-text", "relative-text", NULL, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
objects_reminder_instance_init (ObjectsReminder * self,
                                gpointer klass)
{
	gchar* _tmp0_;
	gchar* _tmp1_;
	ObjectsDueDate* _tmp2_;
	self->priv = objects_reminder_get_instance_private (self);
	self->priv->_notify_uid = (gint64) 0;
	_tmp0_ = g_strdup ("");
	self->priv->_item_id = _tmp0_;
	_tmp1_ = g_strdup ("");
	self->priv->_service = _tmp1_;
	_tmp2_ = objects_due_date_new ();
	self->priv->_due = _tmp2_;
	self->priv->_mm_offset = 0;
	self->priv->_is_deleted = 0;
	self->priv->_reminder_type = REMINDER_TYPE_ABSOLUTE;
}

static void
objects_reminder_finalize (GObject * obj)
{
	ObjectsReminder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, OBJECTS_TYPE_REMINDER, ObjectsReminder);
	_g_free0 (self->priv->_item_id);
	_g_free0 (self->priv->_service);
	_g_object_unref0 (self->priv->_due);
	_g_object_unref0 (self->priv->_item);
	_g_date_time_unref0 (self->priv->_datetime);
	_g_free0 (self->priv->_relative_text);
	G_OBJECT_CLASS (objects_reminder_parent_class)->finalize (obj);
}

static GType
objects_reminder_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ObjectsReminderClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) objects_reminder_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ObjectsReminder), 0, (GInstanceInitFunc) objects_reminder_instance_init, NULL };
	GType objects_reminder_type_id;
	objects_reminder_type_id = g_type_register_static (OBJECTS_TYPE_BASE_OBJECT, "ObjectsReminder", &g_define_type_info, 0);
	ObjectsReminder_private_offset = g_type_add_instance_private (objects_reminder_type_id, sizeof (ObjectsReminderPrivate));
	return objects_reminder_type_id;
}

GType
objects_reminder_get_type (void)
{
	static volatile gsize objects_reminder_type_id__once = 0;
	if (g_once_init_enter (&objects_reminder_type_id__once)) {
		GType objects_reminder_type_id;
		objects_reminder_type_id = objects_reminder_get_type_once ();
		g_once_init_leave (&objects_reminder_type_id__once, objects_reminder_type_id);
	}
	return objects_reminder_type_id__once;
}

static void
_vala_objects_reminder_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	ObjectsReminder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_TYPE_REMINDER, ObjectsReminder);
	switch (property_id) {
		case OBJECTS_REMINDER_NOTIFY_UID_PROPERTY:
		g_value_set_int64 (value, objects_reminder_get_notify_uid (self));
		break;
		case OBJECTS_REMINDER_ITEM_ID_PROPERTY:
		g_value_set_string (value, objects_reminder_get_item_id (self));
		break;
		case OBJECTS_REMINDER_SERVICE_PROPERTY:
		g_value_set_string (value, objects_reminder_get_service (self));
		break;
		case OBJECTS_REMINDER_DUE_PROPERTY:
		g_value_set_object (value, objects_reminder_get_due (self));
		break;
		case OBJECTS_REMINDER_MM_OFFSET_PROPERTY:
		g_value_set_int (value, objects_reminder_get_mm_offset (self));
		break;
		case OBJECTS_REMINDER_IS_DELETED_PROPERTY:
		g_value_set_int (value, objects_reminder_get_is_deleted (self));
		break;
		case OBJECTS_REMINDER_REMINDER_TYPE_PROPERTY:
		g_value_set_enum (value, objects_reminder_get_reminder_type (self));
		break;
		case OBJECTS_REMINDER_ITEM_PROPERTY:
		g_value_set_object (value, objects_reminder_get_item (self));
		break;
		case OBJECTS_REMINDER_DATETIME_PROPERTY:
		g_value_set_boxed (value, objects_reminder_get_datetime (self));
		break;
		case OBJECTS_REMINDER_RELATIVE_TEXT_PROPERTY:
		g_value_set_string (value, objects_reminder_get_relative_text (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_objects_reminder_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	ObjectsReminder * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, OBJECTS_TYPE_REMINDER, ObjectsReminder);
	switch (property_id) {
		case OBJECTS_REMINDER_NOTIFY_UID_PROPERTY:
		objects_reminder_set_notify_uid (self, g_value_get_int64 (value));
		break;
		case OBJECTS_REMINDER_ITEM_ID_PROPERTY:
		objects_reminder_set_item_id (self, g_value_get_string (value));
		break;
		case OBJECTS_REMINDER_SERVICE_PROPERTY:
		objects_reminder_set_service (self, g_value_get_string (value));
		break;
		case OBJECTS_REMINDER_DUE_PROPERTY:
		objects_reminder_set_due (self, g_value_get_object (value));
		break;
		case OBJECTS_REMINDER_MM_OFFSET_PROPERTY:
		objects_reminder_set_mm_offset (self, g_value_get_int (value));
		break;
		case OBJECTS_REMINDER_IS_DELETED_PROPERTY:
		objects_reminder_set_is_deleted (self, g_value_get_int (value));
		break;
		case OBJECTS_REMINDER_REMINDER_TYPE_PROPERTY:
		objects_reminder_set_reminder_type (self, g_value_get_enum (value));
		break;
		case OBJECTS_REMINDER_ITEM_PROPERTY:
		objects_reminder_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;
}

