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

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

#include <glib.h>
#include "planify.h"
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <gio/gio.h>
#include <locale.h>
#include <glib/gi18n-lib.h>

#define BUILD_INSTALL_PREFIX "/usr"
#define BUILD_GETTEXT_PACKAGE "io.github.alainm23.planify"
#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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define PLANIFY_CLI_TYPE_LIST_ARGUMENTS (planify_cli_list_arguments_get_type ())
#define PLANIFY_CLI_LIST_ARGUMENTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLANIFY_CLI_TYPE_LIST_ARGUMENTS, PlanifyCLIListArguments))
#define PLANIFY_CLI_LIST_ARGUMENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLANIFY_CLI_TYPE_LIST_ARGUMENTS, PlanifyCLIListArgumentsClass))
#define PLANIFY_CLI_IS_LIST_ARGUMENTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLANIFY_CLI_TYPE_LIST_ARGUMENTS))
#define PLANIFY_CLI_IS_LIST_ARGUMENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLANIFY_CLI_TYPE_LIST_ARGUMENTS))
#define PLANIFY_CLI_LIST_ARGUMENTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLANIFY_CLI_TYPE_LIST_ARGUMENTS, PlanifyCLIListArgumentsClass))

typedef struct _PlanifyCLIListArguments PlanifyCLIListArguments;
typedef struct _PlanifyCLIListArgumentsClass PlanifyCLIListArgumentsClass;
#define _g_free0(var) (var = (g_free (var), NULL))

#define PLANIFY_CLI_TYPE_UPDATE_ARGUMENTS (planify_cli_update_arguments_get_type ())
#define PLANIFY_CLI_UPDATE_ARGUMENTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLANIFY_CLI_TYPE_UPDATE_ARGUMENTS, PlanifyCLIUpdateArguments))
#define PLANIFY_CLI_UPDATE_ARGUMENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLANIFY_CLI_TYPE_UPDATE_ARGUMENTS, PlanifyCLIUpdateArgumentsClass))
#define PLANIFY_CLI_IS_UPDATE_ARGUMENTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLANIFY_CLI_TYPE_UPDATE_ARGUMENTS))
#define PLANIFY_CLI_IS_UPDATE_ARGUMENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLANIFY_CLI_TYPE_UPDATE_ARGUMENTS))
#define PLANIFY_CLI_UPDATE_ARGUMENTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLANIFY_CLI_TYPE_UPDATE_ARGUMENTS, PlanifyCLIUpdateArgumentsClass))

typedef struct _PlanifyCLIUpdateArguments PlanifyCLIUpdateArguments;
typedef struct _PlanifyCLIUpdateArgumentsClass PlanifyCLIUpdateArgumentsClass;
typedef struct _Block3Data Block3Data;
#define _g_date_time_unref0(var) ((var == NULL) ? NULL : (var = (g_date_time_unref (var), NULL)))
typedef struct _Block4Data Block4Data;
#define _g_main_loop_unref0(var) ((var == NULL) ? NULL : (var = (g_main_loop_unref (var), NULL)))
#define _http_response_unref0(var) ((var == NULL) ? NULL : (var = (http_response_unref (var), NULL)))

#define TYPE_DBUS_CLIENT (dbus_client_get_type ())
#define DBUS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DBUS_CLIENT, DBusClient))
#define DBUS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DBUS_CLIENT, DBusClientClass))
#define IS_DBUS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DBUS_CLIENT))
#define IS_DBUS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DBUS_CLIENT))
#define DBUS_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DBUS_CLIENT, DBusClientClass))

typedef struct _DBusClient DBusClient;
typedef struct _DBusClientClass DBusClientClass;
typedef struct _DBusClientPrivate DBusClientPrivate;

#define TYPE_DBUS_CLIENT_INTERFACE (dbus_client_interface_get_type ())
#define DBUS_CLIENT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DBUS_CLIENT_INTERFACE, DBusClientInterface))
#define IS_DBUS_CLIENT_INTERFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DBUS_CLIENT_INTERFACE))
#define DBUS_CLIENT_INTERFACE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), TYPE_DBUS_CLIENT_INTERFACE, DBusClientInterfaceIface))

typedef struct _DBusClientInterface DBusClientInterface;
typedef struct _DBusClientInterfaceIface DBusClientInterfaceIface;

#define TYPE_DBUS_CLIENT_INTERFACE_PROXY (dbus_client_interface_proxy_get_type ())
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define _g_main_context_unref0(var) ((var == NULL) ? NULL : (var = (g_main_context_unref (var), NULL)))

#define PLANIFY_CLI_TYPE_TASK_ARGUMENTS (planify_cli_task_arguments_get_type ())
#define PLANIFY_CLI_TASK_ARGUMENTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLANIFY_CLI_TYPE_TASK_ARGUMENTS, PlanifyCLITaskArguments))
#define PLANIFY_CLI_TASK_ARGUMENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLANIFY_CLI_TYPE_TASK_ARGUMENTS, PlanifyCLITaskArgumentsClass))
#define PLANIFY_CLI_IS_TASK_ARGUMENTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLANIFY_CLI_TYPE_TASK_ARGUMENTS))
#define PLANIFY_CLI_IS_TASK_ARGUMENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLANIFY_CLI_TYPE_TASK_ARGUMENTS))
#define PLANIFY_CLI_TASK_ARGUMENTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLANIFY_CLI_TYPE_TASK_ARGUMENTS, PlanifyCLITaskArgumentsClass))

typedef struct _PlanifyCLITaskArguments PlanifyCLITaskArguments;
typedef struct _PlanifyCLITaskArgumentsClass PlanifyCLITaskArgumentsClass;

#define PLANIFY_CLI_TYPE_BACKUP_ARGUMENTS (planify_cli_backup_arguments_get_type ())
#define PLANIFY_CLI_BACKUP_ARGUMENTS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLANIFY_CLI_TYPE_BACKUP_ARGUMENTS, PlanifyCLIBackupArguments))
#define PLANIFY_CLI_BACKUP_ARGUMENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLANIFY_CLI_TYPE_BACKUP_ARGUMENTS, PlanifyCLIBackupArgumentsClass))
#define PLANIFY_CLI_IS_BACKUP_ARGUMENTS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLANIFY_CLI_TYPE_BACKUP_ARGUMENTS))
#define PLANIFY_CLI_IS_BACKUP_ARGUMENTS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLANIFY_CLI_TYPE_BACKUP_ARGUMENTS))
#define PLANIFY_CLI_BACKUP_ARGUMENTS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLANIFY_CLI_TYPE_BACKUP_ARGUMENTS, PlanifyCLIBackupArgumentsClass))

typedef struct _PlanifyCLIBackupArguments PlanifyCLIBackupArguments;
typedef struct _PlanifyCLIBackupArgumentsClass PlanifyCLIBackupArgumentsClass;

#define PLANIFY_CLI_TYPE_PARSED_COMMAND (planify_cli_parsed_command_get_type ())
#define PLANIFY_CLI_PARSED_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PLANIFY_CLI_TYPE_PARSED_COMMAND, PlanifyCLIParsedCommand))
#define PLANIFY_CLI_PARSED_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PLANIFY_CLI_TYPE_PARSED_COMMAND, PlanifyCLIParsedCommandClass))
#define PLANIFY_CLI_IS_PARSED_COMMAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLANIFY_CLI_TYPE_PARSED_COMMAND))
#define PLANIFY_CLI_IS_PARSED_COMMAND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PLANIFY_CLI_TYPE_PARSED_COMMAND))
#define PLANIFY_CLI_PARSED_COMMAND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PLANIFY_CLI_TYPE_PARSED_COMMAND, PlanifyCLIParsedCommandClass))

typedef struct _PlanifyCLIParsedCommand PlanifyCLIParsedCommand;
typedef struct _PlanifyCLIParsedCommandClass PlanifyCLIParsedCommandClass;
typedef enum  {
	PLANIFY_CLI_COMMAND_TYPE_NONE,
	PLANIFY_CLI_COMMAND_TYPE_ADD,
	PLANIFY_CLI_COMMAND_TYPE_LIST_PROJECTS,
	PLANIFY_CLI_COMMAND_TYPE_LIST,
	PLANIFY_CLI_COMMAND_TYPE_UPDATE,
	PLANIFY_CLI_COMMAND_TYPE_BACKUP
} PlanifyCLICommandType;

#define PLANIFY_CLI_TYPE_COMMAND_TYPE (planify_cli_command_type_get_type ())

struct _Block3Data {
	int _ref_count_;
	ObjectsItem* item;
};

struct _Block4Data {
	int _ref_count_;
	Block3Data * _data3_;
	GMainLoop* loop;
};

struct _DBusClientInterfaceIface {
	GTypeInterface parent_iface;
	void (*add_item) (DBusClientInterface* self, const gchar* id, GError** error);
	void (*update_item) (DBusClientInterface* self, const gchar* id, GError** error);
};

struct _DBusClient {
	GObject parent_instance;
	DBusClientPrivate * priv;
	DBusClientInterface* interface;
};

struct _DBusClientClass {
	GObjectClass parent_class;
};

VALA_EXTERN gint planify_cli_list_projects (void);
VALA_EXTERN void planify_cli_output_formatter_print_projects_list (GeeArrayList* projects);
VALA_EXTERN GType planify_cli_list_arguments_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PlanifyCLIListArguments, g_object_unref)
VALA_EXTERN gint planify_cli_list_tasks (PlanifyCLIListArguments* args);
VALA_EXTERN ObjectsProject* planify_cli_task_creator_find_project (const gchar* project_id,
                                                       const gchar* project_name,
                                                       gchar** error_message);
VALA_EXTERN const gchar* planify_cli_list_arguments_get_project_id (PlanifyCLIListArguments* self);
VALA_EXTERN const gchar* planify_cli_list_arguments_get_project_name (PlanifyCLIListArguments* self);
VALA_EXTERN void planify_cli_output_formatter_print_tasks_list (GeeArrayList* items);
VALA_EXTERN GType planify_cli_update_arguments_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PlanifyCLIUpdateArguments, g_object_unref)
VALA_EXTERN gint planify_cli_update_task (PlanifyCLIUpdateArguments* args);
static Block3Data* block3_data_ref (Block3Data* _data3_);
static void block3_data_unref (void * _userdata_);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_task_id (PlanifyCLIUpdateArguments* self);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_content (PlanifyCLIUpdateArguments* self);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_description (PlanifyCLIUpdateArguments* self);
VALA_EXTERN gint planify_cli_update_arguments_get_priority (PlanifyCLIUpdateArguments* self);
VALA_EXTERN gboolean planify_cli_task_validator_validate_priority (gint priority,
                                                       gchar** error_message);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_due_date (PlanifyCLIUpdateArguments* self);
VALA_EXTERN gboolean planify_cli_task_validator_validate_and_parse_date (const gchar* due_date,
                                                             GDateTime** datetime,
                                                             gchar** error_message);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_project_id (PlanifyCLIUpdateArguments* self);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_project_name (PlanifyCLIUpdateArguments* self);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_section_id (PlanifyCLIUpdateArguments* self);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_section_name (PlanifyCLIUpdateArguments* self);
VALA_EXTERN ObjectsSection* planify_cli_task_creator_find_section (const gchar* section_id,
                                                       const gchar* section_name,
                                                       ObjectsProject* project,
                                                       gchar** error_message);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_parent_id (PlanifyCLIUpdateArguments* self);
VALA_EXTERN gboolean planify_cli_task_validator_validate_parent_id (const gchar* parent_id,
                                                        gchar** error_message);
VALA_EXTERN const gchar* planify_cli_update_arguments_get_labels (PlanifyCLIUpdateArguments* self);
VALA_EXTERN gint planify_cli_update_arguments_get_checked (PlanifyCLIUpdateArguments* self);
static Block4Data* block4_data_ref (Block4Data* _data4_);
static void block4_data_unref (void * _userdata_);
static void ____lambda22_ (Block4Data* _data4_,
                    GObject* obj,
                    GAsyncResult* res);
static void _____lambda22__gasync_ready_callback (GObject* source_object,
                                           GAsyncResult* res,
                                           gpointer self);
VALA_EXTERN gint planify_cli_update_arguments_get_pinned (PlanifyCLIUpdateArguments* self);
VALA_EXTERN GType dbus_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DBusClient, g_object_unref)
VALA_EXTERN DBusClient* dbus_client_get_default (void);
VALA_EXTERN GType dbus_client_interface_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint dbus_client_interface_register_object (void* object,
                                             GDBusConnection* connection,
                                             const gchar* path,
                                             GError** error);
VALA_EXTERN GType dbus_client_interface_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DBusClientInterface, g_object_unref)
VALA_EXTERN void dbus_client_interface_update_item (DBusClientInterface* self,
                                        const gchar* id,
                                        GError** error);
VALA_EXTERN void planify_cli_output_formatter_print_task_result (ObjectsItem* item,
                                                     ObjectsProject* project);
VALA_EXTERN GType planify_cli_task_arguments_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PlanifyCLITaskArguments, g_object_unref)
VALA_EXTERN gint planify_cli_add_task (PlanifyCLITaskArguments* args);
VALA_EXTERN gboolean planify_cli_task_validator_validate_content (const gchar* content,
                                                      gchar** error_message);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_content (PlanifyCLITaskArguments* self);
VALA_EXTERN gint planify_cli_task_arguments_get_priority (PlanifyCLITaskArguments* self);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_due_date (PlanifyCLITaskArguments* self);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_parent_id (PlanifyCLITaskArguments* self);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_project_id (PlanifyCLITaskArguments* self);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_project_name (PlanifyCLITaskArguments* self);
VALA_EXTERN ObjectsItem* planify_cli_task_creator_create_item (const gchar* content,
                                                   const gchar* description,
                                                   gint priority,
                                                   GDateTime* due_datetime,
                                                   ObjectsProject* project,
                                                   const gchar* parent_id);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_description (PlanifyCLITaskArguments* self);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_section_id (PlanifyCLITaskArguments* self);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_section_name (PlanifyCLITaskArguments* self);
VALA_EXTERN const gchar* planify_cli_task_arguments_get_labels (PlanifyCLITaskArguments* self);
VALA_EXTERN gint planify_cli_task_arguments_get_pinned (PlanifyCLITaskArguments* self);
VALA_EXTERN gboolean planify_cli_task_creator_save_and_notify (ObjectsItem* item);
VALA_EXTERN GType planify_cli_backup_arguments_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PlanifyCLIBackupArguments, g_object_unref)
VALA_EXTERN gint planify_cli_backup (PlanifyCLIBackupArguments* args);
VALA_EXTERN const gchar* planify_cli_backup_arguments_get_output (PlanifyCLIBackupArguments* self);
static gint planify_cli_main (gchar** args,
                       gint args_length1);
VALA_EXTERN GType planify_cli_parsed_command_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (PlanifyCLIParsedCommand, g_object_unref)
VALA_EXTERN PlanifyCLIParsedCommand* planify_cli_argument_parser_parse (gchar** args,
                                                            gint args_length1,
                                                            gint* exit_code);
VALA_EXTERN GType planify_cli_command_type_get_type (void) G_GNUC_CONST ;
VALA_EXTERN PlanifyCLICommandType planify_cli_parsed_command_get_command_type (PlanifyCLIParsedCommand* self);
VALA_EXTERN PlanifyCLIListArguments* planify_cli_parsed_command_get_list_args (PlanifyCLIParsedCommand* self);
VALA_EXTERN PlanifyCLIUpdateArguments* planify_cli_parsed_command_get_update_args (PlanifyCLIParsedCommand* self);
VALA_EXTERN PlanifyCLITaskArguments* planify_cli_parsed_command_get_task_args (PlanifyCLIParsedCommand* self);
VALA_EXTERN PlanifyCLIBackupArguments* planify_cli_parsed_command_get_backup_args (PlanifyCLIParsedCommand* self);
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 gssize _vala_array_length (gpointer array);

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

gint
planify_cli_list_projects (void)
{
	ServicesDatabase* _tmp0_;
	ServicesDatabase* _tmp1_;
	GeeArrayList* projects = NULL;
	ServicesStore* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeArrayList* _tmp4_;
	GeeArrayList* _tmp5_;
	gint result;
	_tmp0_ = services_database_get_default ();
	_tmp1_ = _tmp0_;
	services_database_init_database (_tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = services_store_instance ();
	_tmp3_ = services_store_get_projects (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = _g_object_ref0 (_tmp4_);
	projects = _tmp5_;
	planify_cli_output_formatter_print_projects_list (projects);
	result = 0;
	_g_object_unref0 (projects);
	return result;
}

gint
planify_cli_list_tasks (PlanifyCLIListArguments* args)
{
	ServicesDatabase* _tmp0_;
	ServicesDatabase* _tmp1_;
	gchar* error_message = NULL;
	ObjectsProject* target_project = NULL;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	gchar* _tmp6_ = NULL;
	ObjectsProject* _tmp7_;
	ObjectsProject* _tmp8_;
	GeeArrayList* items = NULL;
	ServicesStore* _tmp11_;
	ObjectsProject* _tmp12_;
	GeeArrayList* _tmp13_;
	GeeArrayList* _tmp14_;
	gint result;
	g_return_val_if_fail (args != NULL, -1);
	_tmp0_ = services_database_get_default ();
	_tmp1_ = _tmp0_;
	services_database_init_database (_tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = planify_cli_list_arguments_get_project_id (args);
	_tmp3_ = _tmp2_;
	_tmp4_ = planify_cli_list_arguments_get_project_name (args);
	_tmp5_ = _tmp4_;
	_tmp7_ = planify_cli_task_creator_find_project (_tmp3_, _tmp5_, &_tmp6_);
	_g_free0 (error_message);
	error_message = _tmp6_;
	target_project = _tmp7_;
	_tmp8_ = target_project;
	if (_tmp8_ == NULL) {
		FILE* _tmp9_;
		const gchar* _tmp10_;
		_tmp9_ = stderr;
		_tmp10_ = error_message;
		fprintf (_tmp9_, "%s\n", _tmp10_);
		result = 1;
		_g_object_unref0 (target_project);
		_g_free0 (error_message);
		return result;
	}
	_tmp11_ = services_store_instance ();
	_tmp12_ = target_project;
	_tmp13_ = services_store_get_items_by_project (_tmp11_, _tmp12_);
	items = _tmp13_;
	_tmp14_ = items;
	planify_cli_output_formatter_print_tasks_list (_tmp14_);
	result = 0;
	_g_object_unref0 (items);
	_g_object_unref0 (target_project);
	_g_free0 (error_message);
	return result;
}

static Block3Data*
block3_data_ref (Block3Data* _data3_)
{
	g_atomic_int_inc (&_data3_->_ref_count_);
	return _data3_;
}

static void
block3_data_unref (void * _userdata_)
{
	Block3Data* _data3_;
	_data3_ = (Block3Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data3_->_ref_count_)) {
		_g_object_unref0 (_data3_->item);
		g_slice_free (Block3Data, _data3_);
	}
}

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

static Block4Data*
block4_data_ref (Block4Data* _data4_)
{
	g_atomic_int_inc (&_data4_->_ref_count_);
	return _data4_;
}

static void
block4_data_unref (void * _userdata_)
{
	Block4Data* _data4_;
	_data4_ = (Block4Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data4_->_ref_count_)) {
		_g_main_loop_unref0 (_data4_->loop);
		block3_data_unref (_data4_->_data3_);
		_data4_->_data3_ = NULL;
		g_slice_free (Block4Data, _data4_);
	}
}

static gchar*
g_date_time_to_string (GDateTime* self)
{
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_date_time_format (self, "%FT%H:%M:%S%z");
	result = _tmp0_;
	return result;
}

static void
____lambda22_ (Block4Data* _data4_,
               GObject* obj,
               GAsyncResult* res)
{
	Block3Data* _data3_;
	HttpResponse* response = NULL;
	ObjectsItem* _tmp0_;
	HttpResponse* _tmp1_;
	HttpResponse* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	GMainLoop* _tmp6_;
	_data3_ = _data4_->_data3_;
	g_return_if_fail (res != NULL);
	_tmp0_ = _data3_->item;
	_tmp1_ = objects_item_complete_item_finish (_tmp0_, res);
	response = _tmp1_;
	_tmp2_ = response;
	_tmp3_ = http_response_get_status (_tmp2_);
	_tmp4_ = _tmp3_;
	if (!_tmp4_) {
		FILE* _tmp5_;
		_tmp5_ = stderr;
		fprintf (_tmp5_, "Error: Failed to update task completion status\n");
	}
	_tmp6_ = _data4_->loop;
	g_main_loop_quit (_tmp6_);
	_http_response_unref0 (response);
}

static void
_____lambda22__gasync_ready_callback (GObject* source_object,
                                      GAsyncResult* res,
                                      gpointer self)
{
	____lambda22_ (self, source_object, res);
	block4_data_unref (self);
}

static gpointer
_g_main_context_ref0 (gpointer self)
{
	return self ? g_main_context_ref (self) : NULL;
}

gint
planify_cli_update_task (PlanifyCLIUpdateArguments* args)
{
	Block3Data* _data3_;
	gboolean _tmp0_ = FALSE;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	ServicesDatabase* _tmp8_;
	ServicesDatabase* _tmp9_;
	ServicesStore* _tmp10_;
	const gchar* _tmp11_;
	const gchar* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	ObjectsItem* _tmp15_;
	ObjectsItem* _tmp16_;
	ObjectsItem* _tmp17_;
	gchar* error_message = NULL;
	gboolean _tmp21_ = FALSE;
	const gchar* _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp33_;
	const gchar* _tmp34_;
	gint _tmp40_;
	gint _tmp41_;
	const gchar* _tmp51_;
	const gchar* _tmp52_;
	gboolean project_changed = FALSE;
	gchar* old_project_id = NULL;
	ObjectsItem* _tmp67_;
	const gchar* _tmp68_;
	const gchar* _tmp69_;
	gchar* _tmp70_;
	gchar* old_section_id = NULL;
	ObjectsItem* _tmp71_;
	const gchar* _tmp72_;
	const gchar* _tmp73_;
	gchar* _tmp74_;
	gchar* old_parent_id = NULL;
	ObjectsItem* _tmp75_;
	const gchar* _tmp76_;
	const gchar* _tmp77_;
	gchar* _tmp78_;
	gboolean _tmp79_ = FALSE;
	const gchar* _tmp80_;
	const gchar* _tmp81_;
	gboolean _tmp104_ = FALSE;
	const gchar* _tmp105_;
	const gchar* _tmp106_;
	const gchar* _tmp135_;
	const gchar* _tmp136_;
	const gchar* _tmp148_;
	const gchar* _tmp149_;
	gint _tmp198_;
	gint _tmp199_;
	gint _tmp215_;
	gint _tmp216_;
	gboolean dbus_notified = FALSE;
	ObjectsProject* current_project = NULL;
	ServicesStore* _tmp239_;
	ObjectsItem* _tmp240_;
	const gchar* _tmp241_;
	const gchar* _tmp242_;
	ObjectsProject* _tmp243_;
	ObjectsProject* _tmp244_;
	ObjectsItem* _tmp247_;
	ObjectsProject* _tmp248_;
	GError* _inner_error0_ = NULL;
	gint result;
	g_return_val_if_fail (args != NULL, -1);
	_data3_ = g_slice_new0 (Block3Data);
	_data3_->_ref_count_ = 1;
	_tmp1_ = planify_cli_update_arguments_get_task_id (args);
	_tmp2_ = _tmp1_;
	if (_tmp2_ == NULL) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		_tmp3_ = planify_cli_update_arguments_get_task_id (args);
		_tmp4_ = _tmp3_;
		_tmp5_ = string_strip (_tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = g_strcmp0 (_tmp6_, "") == 0;
		_g_free0 (_tmp6_);
	}
	if (_tmp0_) {
		FILE* _tmp7_;
		_tmp7_ = stderr;
		fprintf (_tmp7_, "Error: --task-id is required\n");
		result = 1;
		block3_data_unref (_data3_);
		_data3_ = NULL;
		return result;
	}
	_tmp8_ = services_database_get_default ();
	_tmp9_ = _tmp8_;
	services_database_init_database (_tmp9_);
	_g_object_unref0 (_tmp9_);
	_tmp10_ = services_store_instance ();
	_tmp11_ = planify_cli_update_arguments_get_task_id (args);
	_tmp12_ = _tmp11_;
	_tmp13_ = string_strip (_tmp12_);
	_tmp14_ = _tmp13_;
	_tmp15_ = services_store_get_item (_tmp10_, _tmp14_);
	_tmp16_ = _tmp15_;
	_g_free0 (_tmp14_);
	_data3_->item = _tmp16_;
	_tmp17_ = _data3_->item;
	if (_tmp17_ == NULL) {
		FILE* _tmp18_;
		const gchar* _tmp19_;
		const gchar* _tmp20_;
		_tmp18_ = stderr;
		_tmp19_ = planify_cli_update_arguments_get_task_id (args);
		_tmp20_ = _tmp19_;
		fprintf (_tmp18_, "Error: Task ID '%s' not found\n", _tmp20_);
		result = 1;
		block3_data_unref (_data3_);
		_data3_ = NULL;
		return result;
	}
	_tmp22_ = planify_cli_update_arguments_get_content (args);
	_tmp23_ = _tmp22_;
	if (_tmp23_ != NULL) {
		const gchar* _tmp24_;
		const gchar* _tmp25_;
		gchar* _tmp26_;
		gchar* _tmp27_;
		_tmp24_ = planify_cli_update_arguments_get_content (args);
		_tmp25_ = _tmp24_;
		_tmp26_ = string_strip (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp21_ = g_strcmp0 (_tmp27_, "") != 0;
		_g_free0 (_tmp27_);
	} else {
		_tmp21_ = FALSE;
	}
	if (_tmp21_) {
		ObjectsItem* _tmp28_;
		const gchar* _tmp29_;
		const gchar* _tmp30_;
		gchar* _tmp31_;
		gchar* _tmp32_;
		_tmp28_ = _data3_->item;
		_tmp29_ = planify_cli_update_arguments_get_content (args);
		_tmp30_ = _tmp29_;
		_tmp31_ = string_strip (_tmp30_);
		_tmp32_ = _tmp31_;
		objects_item_set_content (_tmp28_, _tmp32_);
		_g_free0 (_tmp32_);
	}
	_tmp33_ = planify_cli_update_arguments_get_description (args);
	_tmp34_ = _tmp33_;
	if (_tmp34_ != NULL) {
		ObjectsItem* _tmp35_;
		const gchar* _tmp36_;
		const gchar* _tmp37_;
		gchar* _tmp38_;
		gchar* _tmp39_;
		_tmp35_ = _data3_->item;
		_tmp36_ = planify_cli_update_arguments_get_description (args);
		_tmp37_ = _tmp36_;
		_tmp38_ = string_strip (_tmp37_);
		_tmp39_ = _tmp38_;
		objects_item_set_description (_tmp35_, _tmp39_);
		_g_free0 (_tmp39_);
	}
	_tmp40_ = planify_cli_update_arguments_get_priority (args);
	_tmp41_ = _tmp40_;
	if (_tmp41_ != -1) {
		gint _tmp42_;
		gint _tmp43_;
		gchar* _tmp44_ = NULL;
		gboolean _tmp45_;
		ObjectsItem* _tmp48_;
		gint _tmp49_;
		gint _tmp50_;
		_tmp42_ = planify_cli_update_arguments_get_priority (args);
		_tmp43_ = _tmp42_;
		_tmp45_ = planify_cli_task_validator_validate_priority (_tmp43_, &_tmp44_);
		_g_free0 (error_message);
		error_message = _tmp44_;
		if (!_tmp45_) {
			FILE* _tmp46_;
			const gchar* _tmp47_;
			_tmp46_ = stderr;
			_tmp47_ = error_message;
			fprintf (_tmp46_, "%s\n", _tmp47_);
			result = 1;
			_g_free0 (error_message);
			block3_data_unref (_data3_);
			_data3_ = NULL;
			return result;
		}
		_tmp48_ = _data3_->item;
		_tmp49_ = planify_cli_update_arguments_get_priority (args);
		_tmp50_ = _tmp49_;
		objects_item_set_priority (_tmp48_, 5 - _tmp50_);
	}
	_tmp51_ = planify_cli_update_arguments_get_due_date (args);
	_tmp52_ = _tmp51_;
	if (_tmp52_ != NULL) {
		GDateTime* due_datetime = NULL;
		const gchar* _tmp53_;
		const gchar* _tmp54_;
		GDateTime* _tmp55_ = NULL;
		gchar* _tmp56_ = NULL;
		gboolean _tmp57_;
		GDateTime* _tmp60_;
		_tmp53_ = planify_cli_update_arguments_get_due_date (args);
		_tmp54_ = _tmp53_;
		_tmp57_ = planify_cli_task_validator_validate_and_parse_date (_tmp54_, &_tmp55_, &_tmp56_);
		_g_date_time_unref0 (due_datetime);
		due_datetime = _tmp55_;
		_g_free0 (error_message);
		error_message = _tmp56_;
		if (!_tmp57_) {
			FILE* _tmp58_;
			const gchar* _tmp59_;
			_tmp58_ = stderr;
			_tmp59_ = error_message;
			fprintf (_tmp58_, "%s\n", _tmp59_);
			result = 1;
			_g_date_time_unref0 (due_datetime);
			_g_free0 (error_message);
			block3_data_unref (_data3_);
			_data3_ = NULL;
			return result;
		}
		_tmp60_ = due_datetime;
		if (_tmp60_ != NULL) {
			ObjectsItem* _tmp61_;
			ObjectsDueDate* _tmp62_;
			ObjectsDueDate* _tmp63_;
			GDateTime* _tmp64_;
			gchar* _tmp65_;
			gchar* _tmp66_;
			_tmp61_ = _data3_->item;
			_tmp62_ = objects_item_get_due (_tmp61_);
			_tmp63_ = _tmp62_;
			_tmp64_ = due_datetime;
			_tmp65_ = utils_datetime_get_todoist_datetime_format (_tmp64_);
			_tmp66_ = _tmp65_;
			objects_due_date_set_date (_tmp63_, _tmp66_);
			_g_free0 (_tmp66_);
		}
		_g_date_time_unref0 (due_datetime);
	}
	project_changed = FALSE;
	_tmp67_ = _data3_->item;
	_tmp68_ = objects_item_get_project_id (_tmp67_);
	_tmp69_ = _tmp68_;
	_tmp70_ = g_strdup (_tmp69_);
	old_project_id = _tmp70_;
	_tmp71_ = _data3_->item;
	_tmp72_ = objects_item_get_section_id (_tmp71_);
	_tmp73_ = _tmp72_;
	_tmp74_ = g_strdup (_tmp73_);
	old_section_id = _tmp74_;
	_tmp75_ = _data3_->item;
	_tmp76_ = objects_item_get_parent_id (_tmp75_);
	_tmp77_ = _tmp76_;
	_tmp78_ = g_strdup (_tmp77_);
	old_parent_id = _tmp78_;
	_tmp80_ = planify_cli_update_arguments_get_project_id (args);
	_tmp81_ = _tmp80_;
	if (_tmp81_ != NULL) {
		_tmp79_ = TRUE;
	} else {
		const gchar* _tmp82_;
		const gchar* _tmp83_;
		_tmp82_ = planify_cli_update_arguments_get_project_name (args);
		_tmp83_ = _tmp82_;
		_tmp79_ = _tmp83_ != NULL;
	}
	if (_tmp79_) {
		ObjectsProject* target_project = NULL;
		const gchar* _tmp84_;
		const gchar* _tmp85_;
		const gchar* _tmp86_;
		const gchar* _tmp87_;
		gchar* _tmp88_ = NULL;
		ObjectsProject* _tmp89_;
		ObjectsProject* _tmp90_;
		ObjectsItem* _tmp93_;
		const gchar* _tmp94_;
		const gchar* _tmp95_;
		ObjectsProject* _tmp96_;
		const gchar* _tmp97_;
		const gchar* _tmp98_;
		_tmp84_ = planify_cli_update_arguments_get_project_id (args);
		_tmp85_ = _tmp84_;
		_tmp86_ = planify_cli_update_arguments_get_project_name (args);
		_tmp87_ = _tmp86_;
		_tmp89_ = planify_cli_task_creator_find_project (_tmp85_, _tmp87_, &_tmp88_);
		_g_free0 (error_message);
		error_message = _tmp88_;
		target_project = _tmp89_;
		_tmp90_ = target_project;
		if (_tmp90_ == NULL) {
			FILE* _tmp91_;
			const gchar* _tmp92_;
			_tmp91_ = stderr;
			_tmp92_ = error_message;
			fprintf (_tmp91_, "%s\n", _tmp92_);
			result = 1;
			_g_object_unref0 (target_project);
			_g_free0 (old_parent_id);
			_g_free0 (old_section_id);
			_g_free0 (old_project_id);
			_g_free0 (error_message);
			block3_data_unref (_data3_);
			_data3_ = NULL;
			return result;
		}
		_tmp93_ = _data3_->item;
		_tmp94_ = objects_item_get_project_id (_tmp93_);
		_tmp95_ = _tmp94_;
		_tmp96_ = target_project;
		_tmp97_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp96_);
		_tmp98_ = _tmp97_;
		if (g_strcmp0 (_tmp95_, _tmp98_) != 0) {
			ObjectsItem* _tmp99_;
			ObjectsProject* _tmp100_;
			const gchar* _tmp101_;
			const gchar* _tmp102_;
			ObjectsItem* _tmp103_;
			_tmp99_ = _data3_->item;
			_tmp100_ = target_project;
			_tmp101_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp100_);
			_tmp102_ = _tmp101_;
			objects_item_set_project_id (_tmp99_, _tmp102_);
			_tmp103_ = _data3_->item;
			objects_item_set_section_id (_tmp103_, "");
			project_changed = TRUE;
		}
		_g_object_unref0 (target_project);
	}
	_tmp105_ = planify_cli_update_arguments_get_section_id (args);
	_tmp106_ = _tmp105_;
	if (_tmp106_ != NULL) {
		_tmp104_ = TRUE;
	} else {
		const gchar* _tmp107_;
		const gchar* _tmp108_;
		_tmp107_ = planify_cli_update_arguments_get_section_name (args);
		_tmp108_ = _tmp107_;
		_tmp104_ = _tmp108_ != NULL;
	}
	if (_tmp104_) {
		ObjectsProject* current_project = NULL;
		ServicesStore* _tmp109_;
		ObjectsItem* _tmp110_;
		const gchar* _tmp111_;
		const gchar* _tmp112_;
		ObjectsProject* _tmp113_;
		ObjectsProject* _tmp114_;
		_tmp109_ = services_store_instance ();
		_tmp110_ = _data3_->item;
		_tmp111_ = objects_item_get_project_id (_tmp110_);
		_tmp112_ = _tmp111_;
		_tmp113_ = services_store_get_project (_tmp109_, _tmp112_);
		current_project = _tmp113_;
		_tmp114_ = current_project;
		if (_tmp114_ != NULL) {
			ObjectsSection* target_section = NULL;
			const gchar* _tmp115_;
			const gchar* _tmp116_;
			const gchar* _tmp117_;
			const gchar* _tmp118_;
			ObjectsProject* _tmp119_;
			gchar* _tmp120_ = NULL;
			ObjectsSection* _tmp121_;
			ObjectsSection* _tmp122_;
			ObjectsItem* _tmp125_;
			const gchar* _tmp126_;
			const gchar* _tmp127_;
			ObjectsSection* _tmp128_;
			const gchar* _tmp129_;
			const gchar* _tmp130_;
			_tmp115_ = planify_cli_update_arguments_get_section_id (args);
			_tmp116_ = _tmp115_;
			_tmp117_ = planify_cli_update_arguments_get_section_name (args);
			_tmp118_ = _tmp117_;
			_tmp119_ = current_project;
			_tmp121_ = planify_cli_task_creator_find_section (_tmp116_, _tmp118_, _tmp119_, &_tmp120_);
			_g_free0 (error_message);
			error_message = _tmp120_;
			target_section = _tmp121_;
			_tmp122_ = target_section;
			if (_tmp122_ == NULL) {
				FILE* _tmp123_;
				const gchar* _tmp124_;
				_tmp123_ = stderr;
				_tmp124_ = error_message;
				fprintf (_tmp123_, "%s\n", _tmp124_);
				result = 1;
				_g_object_unref0 (target_section);
				_g_object_unref0 (current_project);
				_g_free0 (old_parent_id);
				_g_free0 (old_section_id);
				_g_free0 (old_project_id);
				_g_free0 (error_message);
				block3_data_unref (_data3_);
				_data3_ = NULL;
				return result;
			}
			_tmp125_ = _data3_->item;
			_tmp126_ = objects_item_get_section_id (_tmp125_);
			_tmp127_ = _tmp126_;
			_tmp128_ = target_section;
			_tmp129_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp128_);
			_tmp130_ = _tmp129_;
			if (g_strcmp0 (_tmp127_, _tmp130_) != 0) {
				ObjectsItem* _tmp131_;
				ObjectsSection* _tmp132_;
				const gchar* _tmp133_;
				const gchar* _tmp134_;
				_tmp131_ = _data3_->item;
				_tmp132_ = target_section;
				_tmp133_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp132_);
				_tmp134_ = _tmp133_;
				objects_item_set_section_id (_tmp131_, _tmp134_);
			}
			_g_object_unref0 (target_section);
		}
		_g_object_unref0 (current_project);
	}
	_tmp135_ = planify_cli_update_arguments_get_parent_id (args);
	_tmp136_ = _tmp135_;
	if (_tmp136_ != NULL) {
		const gchar* _tmp137_;
		const gchar* _tmp138_;
		gchar* _tmp139_ = NULL;
		gboolean _tmp140_;
		ObjectsItem* _tmp143_;
		const gchar* _tmp144_;
		const gchar* _tmp145_;
		gchar* _tmp146_;
		gchar* _tmp147_;
		_tmp137_ = planify_cli_update_arguments_get_parent_id (args);
		_tmp138_ = _tmp137_;
		_tmp140_ = planify_cli_task_validator_validate_parent_id (_tmp138_, &_tmp139_);
		_g_free0 (error_message);
		error_message = _tmp139_;
		if (!_tmp140_) {
			FILE* _tmp141_;
			const gchar* _tmp142_;
			_tmp141_ = stderr;
			_tmp142_ = error_message;
			fprintf (_tmp141_, "%s\n", _tmp142_);
			result = 1;
			_g_free0 (old_parent_id);
			_g_free0 (old_section_id);
			_g_free0 (old_project_id);
			_g_free0 (error_message);
			block3_data_unref (_data3_);
			_data3_ = NULL;
			return result;
		}
		_tmp143_ = _data3_->item;
		_tmp144_ = planify_cli_update_arguments_get_parent_id (args);
		_tmp145_ = _tmp144_;
		_tmp146_ = string_strip (_tmp145_);
		_tmp147_ = _tmp146_;
		objects_item_set_parent_id (_tmp143_, _tmp147_);
		_g_free0 (_tmp147_);
	}
	_tmp148_ = planify_cli_update_arguments_get_labels (args);
	_tmp149_ = _tmp148_;
	if (_tmp149_ != NULL) {
		GeeHashMap* new_labels = NULL;
		GeeHashMap* _tmp150_;
		gchar** label_names = NULL;
		const gchar* _tmp151_;
		const gchar* _tmp152_;
		gchar** _tmp153_;
		gchar** _tmp154_;
		gint label_names_length1;
		gint _label_names_size_;
		gchar** _tmp155_;
		gint _tmp155__length1;
		ObjectsItem* _tmp196_;
		GeeHashMap* _tmp197_;
		_tmp150_ = gee_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, OBJECTS_TYPE_LABEL, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
		new_labels = _tmp150_;
		_tmp151_ = planify_cli_update_arguments_get_labels (args);
		_tmp152_ = _tmp151_;
		_tmp154_ = _tmp153_ = g_strsplit (_tmp152_, ",", 0);
		label_names = _tmp154_;
		label_names_length1 = _vala_array_length (_tmp153_);
		_label_names_size_ = label_names_length1;
		_tmp155_ = label_names;
		_tmp155__length1 = label_names_length1;
		{
			gchar** label_name_collection = NULL;
			gint label_name_collection_length1 = 0;
			gint _label_name_collection_size_ = 0;
			gint label_name_it = 0;
			label_name_collection = _tmp155_;
			label_name_collection_length1 = _tmp155__length1;
			for (label_name_it = 0; label_name_it < label_name_collection_length1; label_name_it = label_name_it + 1) {
				gchar* _tmp156_;
				gchar* label_name = NULL;
				_tmp156_ = g_strdup (label_name_collection[label_name_it]);
				label_name = _tmp156_;
				{
					gchar* trimmed = NULL;
					const gchar* _tmp157_;
					gchar* _tmp158_;
					const gchar* _tmp159_;
					_tmp157_ = label_name;
					_tmp158_ = string_strip (_tmp157_);
					trimmed = _tmp158_;
					_tmp159_ = trimmed;
					if (g_strcmp0 (_tmp159_, "") != 0) {
						ObjectsLabel* label = NULL;
						ServicesStore* _tmp160_;
						const gchar* _tmp161_;
						ObjectsItem* _tmp162_;
						ObjectsProject* _tmp163_;
						ObjectsProject* _tmp164_;
						const gchar* _tmp165_;
						const gchar* _tmp166_;
						ObjectsLabel* _tmp167_;
						ObjectsLabel* _tmp168_;
						GeeHashMap* _tmp191_;
						ObjectsLabel* _tmp192_;
						const gchar* _tmp193_;
						const gchar* _tmp194_;
						ObjectsLabel* _tmp195_;
						_tmp160_ = services_store_instance ();
						_tmp161_ = trimmed;
						_tmp162_ = _data3_->item;
						_tmp163_ = objects_item_get_project (_tmp162_);
						_tmp164_ = _tmp163_;
						_tmp165_ = objects_project_get_source_id (_tmp164_);
						_tmp166_ = _tmp165_;
						_tmp167_ = services_store_get_label_by_name (_tmp160_, _tmp161_, TRUE, _tmp166_);
						label = _tmp167_;
						_tmp168_ = label;
						if (_tmp168_ == NULL) {
							ObjectsLabel* _tmp169_;
							ObjectsLabel* _tmp170_;
							Util* _tmp171_;
							Util* _tmp172_;
							ObjectsLabel* _tmp173_;
							gchar* _tmp174_;
							gchar* _tmp175_;
							ObjectsLabel* _tmp176_;
							const gchar* _tmp177_;
							ObjectsLabel* _tmp178_;
							Util* _tmp179_;
							Util* _tmp180_;
							gchar* _tmp181_;
							gchar* _tmp182_;
							ObjectsLabel* _tmp183_;
							ObjectsItem* _tmp184_;
							ObjectsProject* _tmp185_;
							ObjectsProject* _tmp186_;
							const gchar* _tmp187_;
							const gchar* _tmp188_;
							ServicesStore* _tmp189_;
							ObjectsLabel* _tmp190_;
							_tmp169_ = objects_label_new ();
							_g_object_unref0 (label);
							label = _tmp169_;
							_tmp170_ = label;
							_tmp171_ = util_get_default ();
							_tmp172_ = _tmp171_;
							_tmp173_ = label;
							_tmp174_ = util_generate_id (_tmp172_, (ObjectsBaseObject*) _tmp173_);
							_tmp175_ = _tmp174_;
							objects_base_object_set_id ((ObjectsBaseObject*) _tmp170_, _tmp175_);
							_g_free0 (_tmp175_);
							_g_object_unref0 (_tmp172_);
							_tmp176_ = label;
							_tmp177_ = trimmed;
							objects_base_object_set_name ((ObjectsBaseObject*) _tmp176_, _tmp177_);
							_tmp178_ = label;
							_tmp179_ = util_get_default ();
							_tmp180_ = _tmp179_;
							_tmp181_ = util_get_random_color (_tmp180_);
							_tmp182_ = _tmp181_;
							objects_base_object_set_color ((ObjectsBaseObject*) _tmp178_, _tmp182_);
							_g_free0 (_tmp182_);
							_g_object_unref0 (_tmp180_);
							_tmp183_ = label;
							_tmp184_ = _data3_->item;
							_tmp185_ = objects_item_get_project (_tmp184_);
							_tmp186_ = _tmp185_;
							_tmp187_ = objects_project_get_source_id (_tmp186_);
							_tmp188_ = _tmp187_;
							objects_label_set_source_id (_tmp183_, _tmp188_);
							_tmp189_ = services_store_instance ();
							_tmp190_ = label;
							services_store_insert_label (_tmp189_, _tmp190_);
						}
						_tmp191_ = new_labels;
						_tmp192_ = label;
						_tmp193_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp192_);
						_tmp194_ = _tmp193_;
						_tmp195_ = label;
						gee_abstract_map_set ((GeeAbstractMap*) _tmp191_, _tmp194_, _tmp195_);
						_g_object_unref0 (label);
					}
					_g_free0 (trimmed);
					_g_free0 (label_name);
				}
			}
		}
		_tmp196_ = _data3_->item;
		_tmp197_ = new_labels;
		objects_item_check_labels (_tmp196_, _tmp197_);
		label_names = (_vala_array_free (label_names, label_names_length1, (GDestroyNotify) g_free), NULL);
		_g_object_unref0 (new_labels);
	}
	_tmp198_ = planify_cli_update_arguments_get_checked (args);
	_tmp199_ = _tmp198_;
	if (_tmp199_ != -1) {
		gboolean old_checked = FALSE;
		ObjectsItem* _tmp200_;
		gboolean _tmp201_;
		gboolean _tmp202_;
		gboolean new_checked = FALSE;
		gint _tmp203_;
		gint _tmp204_;
		_tmp200_ = _data3_->item;
		_tmp201_ = objects_item_get_checked (_tmp200_);
		_tmp202_ = _tmp201_;
		old_checked = _tmp202_;
		_tmp203_ = planify_cli_update_arguments_get_checked (args);
		_tmp204_ = _tmp203_;
		new_checked = _tmp204_ == 1;
		if (old_checked != new_checked) {
			Block4Data* _data4_;
			ObjectsItem* _tmp205_;
			GMainLoop* _tmp212_;
			ObjectsItem* _tmp213_;
			GMainLoop* _tmp214_;
			_data4_ = g_slice_new0 (Block4Data);
			_data4_->_ref_count_ = 1;
			_data4_->_data3_ = block3_data_ref (_data3_);
			_tmp205_ = _data3_->item;
			objects_item_set_checked (_tmp205_, new_checked);
			if (new_checked) {
				ObjectsItem* _tmp206_;
				GDateTime* _tmp207_;
				GDateTime* _tmp208_;
				gchar* _tmp209_;
				gchar* _tmp210_;
				_tmp206_ = _data3_->item;
				_tmp207_ = g_date_time_new_now_local ();
				_tmp208_ = _tmp207_;
				_tmp209_ = g_date_time_to_string (_tmp208_);
				_tmp210_ = _tmp209_;
				objects_item_set_completed_at (_tmp206_, _tmp210_);
				_g_free0 (_tmp210_);
				_g_date_time_unref0 (_tmp208_);
			} else {
				ObjectsItem* _tmp211_;
				_tmp211_ = _data3_->item;
				objects_item_set_completed_at (_tmp211_, "");
			}
			_tmp212_ = g_main_loop_new (NULL, FALSE);
			_data4_->loop = _tmp212_;
			_tmp213_ = _data3_->item;
			objects_item_complete_item (_tmp213_, old_checked, _____lambda22__gasync_ready_callback, block4_data_ref (_data4_));
			_tmp214_ = _data4_->loop;
			g_main_loop_run (_tmp214_);
			block4_data_unref (_data4_);
			_data4_ = NULL;
		}
	}
	_tmp215_ = planify_cli_update_arguments_get_pinned (args);
	_tmp216_ = _tmp215_;
	if (_tmp216_ != -1) {
		ObjectsItem* _tmp217_;
		gint _tmp218_;
		gint _tmp219_;
		_tmp217_ = _data3_->item;
		_tmp218_ = planify_cli_update_arguments_get_pinned (args);
		_tmp219_ = _tmp218_;
		objects_item_set_pinned (_tmp217_, _tmp219_ == 1);
	}
	if (project_changed) {
		ServicesStore* _tmp220_;
		ObjectsItem* _tmp221_;
		const gchar* _tmp222_;
		const gchar* _tmp223_;
		const gchar* _tmp224_;
		_tmp220_ = services_store_instance ();
		_tmp221_ = _data3_->item;
		_tmp222_ = old_project_id;
		_tmp223_ = old_section_id;
		_tmp224_ = old_parent_id;
		services_store_move_item (_tmp220_, _tmp221_, _tmp222_, _tmp223_, _tmp224_);
	} else {
		ServicesStore* _tmp225_;
		ObjectsItem* _tmp226_;
		_tmp225_ = services_store_instance ();
		_tmp226_ = _data3_->item;
		services_store_update_item (_tmp225_, _tmp226_, "");
	}
	dbus_notified = FALSE;
	{
		DBusClient* _tmp227_;
		DBusClientInterface* _tmp228_;
		ObjectsItem* _tmp229_;
		const gchar* _tmp230_;
		const gchar* _tmp231_;
		_tmp227_ = dbus_client_get_default ();
		_tmp228_ = _tmp227_->interface;
		_tmp229_ = _data3_->item;
		_tmp230_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp229_);
		_tmp231_ = _tmp230_;
		dbus_client_interface_update_item (_tmp228_, _tmp231_, &_inner_error0_);
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		dbus_notified = TRUE;
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		GError* _tmp232_;
		const gchar* _tmp233_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp232_ = e;
		_tmp233_ = _tmp232_->message;
		g_debug ("Main.vala:235: DBus notification failed: %s", _tmp233_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		gint _tmp234_ = -1;
		_g_free0 (old_parent_id);
		_g_free0 (old_section_id);
		_g_free0 (old_project_id);
		_g_free0 (error_message);
		block3_data_unref (_data3_);
		_data3_ = NULL;
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
		g_clear_error (&_inner_error0_);
		return _tmp234_;
	}
	if (dbus_notified) {
		GMainContext* main_context = NULL;
		GMainContext* _tmp235_;
		GMainContext* _tmp236_;
		_tmp235_ = g_main_context_default ();
		_tmp236_ = _g_main_context_ref0 (_tmp235_);
		main_context = _tmp236_;
		while (TRUE) {
			GMainContext* _tmp237_;
			GMainContext* _tmp238_;
			_tmp237_ = main_context;
			if (!g_main_context_pending (_tmp237_)) {
				break;
			}
			_tmp238_ = main_context;
			g_main_context_iteration (_tmp238_, FALSE);
		}
		_g_main_context_unref0 (main_context);
	}
	_tmp239_ = services_store_instance ();
	_tmp240_ = _data3_->item;
	_tmp241_ = objects_item_get_project_id (_tmp240_);
	_tmp242_ = _tmp241_;
	_tmp243_ = services_store_get_project (_tmp239_, _tmp242_);
	current_project = _tmp243_;
	_tmp244_ = current_project;
	if (_tmp244_ == NULL) {
		ServicesStore* _tmp245_;
		ObjectsProject* _tmp246_;
		_tmp245_ = services_store_instance ();
		_tmp246_ = services_store_get_inbox_project (_tmp245_);
		_g_object_unref0 (current_project);
		current_project = _tmp246_;
	}
	_tmp247_ = _data3_->item;
	_tmp248_ = current_project;
	planify_cli_output_formatter_print_task_result (_tmp247_, _tmp248_);
	result = 0;
	_g_object_unref0 (current_project);
	_g_free0 (old_parent_id);
	_g_free0 (old_section_id);
	_g_free0 (old_project_id);
	_g_free0 (error_message);
	block3_data_unref (_data3_);
	_data3_ = NULL;
	return result;
}

gint
planify_cli_add_task (PlanifyCLITaskArguments* args)
{
	gchar* error_message = NULL;
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	gchar* _tmp2_ = NULL;
	gboolean _tmp3_;
	gint _tmp6_;
	gint _tmp7_;
	gchar* _tmp8_ = NULL;
	gboolean _tmp9_;
	GDateTime* due_datetime = NULL;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	GDateTime* _tmp14_ = NULL;
	gchar* _tmp15_ = NULL;
	gboolean _tmp16_;
	ServicesDatabase* _tmp19_;
	ServicesDatabase* _tmp20_;
	const gchar* _tmp21_;
	const gchar* _tmp22_;
	gchar* _tmp23_ = NULL;
	gboolean _tmp24_;
	ObjectsProject* target_project = NULL;
	const gchar* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	const gchar* _tmp30_;
	gchar* _tmp31_ = NULL;
	ObjectsProject* _tmp32_;
	ObjectsProject* _tmp33_;
	ObjectsItem* item = NULL;
	const gchar* _tmp36_;
	const gchar* _tmp37_;
	const gchar* _tmp38_;
	const gchar* _tmp39_;
	gint _tmp40_;
	gint _tmp41_;
	GDateTime* _tmp42_;
	ObjectsProject* _tmp43_;
	const gchar* _tmp44_;
	const gchar* _tmp45_;
	ObjectsItem* _tmp46_;
	gboolean _tmp47_ = FALSE;
	const gchar* _tmp48_;
	const gchar* _tmp49_;
	gboolean _tmp66_ = FALSE;
	const gchar* _tmp67_;
	const gchar* _tmp68_;
	gint _tmp113_;
	gint _tmp114_;
	ObjectsItem* _tmp118_;
	ObjectsItem* _tmp119_;
	ObjectsProject* _tmp120_;
	gint result;
	g_return_val_if_fail (args != NULL, -1);
	_tmp0_ = planify_cli_task_arguments_get_content (args);
	_tmp1_ = _tmp0_;
	_tmp3_ = planify_cli_task_validator_validate_content (_tmp1_, &_tmp2_);
	_g_free0 (error_message);
	error_message = _tmp2_;
	if (!_tmp3_) {
		FILE* _tmp4_;
		const gchar* _tmp5_;
		_tmp4_ = stderr;
		_tmp5_ = error_message;
		fprintf (_tmp4_, "%s\n", _tmp5_);
		result = 1;
		_g_free0 (error_message);
		return result;
	}
	_tmp6_ = planify_cli_task_arguments_get_priority (args);
	_tmp7_ = _tmp6_;
	_tmp9_ = planify_cli_task_validator_validate_priority (_tmp7_, &_tmp8_);
	_g_free0 (error_message);
	error_message = _tmp8_;
	if (!_tmp9_) {
		FILE* _tmp10_;
		const gchar* _tmp11_;
		_tmp10_ = stderr;
		_tmp11_ = error_message;
		fprintf (_tmp10_, "%s\n", _tmp11_);
		result = 1;
		_g_free0 (error_message);
		return result;
	}
	_tmp12_ = planify_cli_task_arguments_get_due_date (args);
	_tmp13_ = _tmp12_;
	_tmp16_ = planify_cli_task_validator_validate_and_parse_date (_tmp13_, &_tmp14_, &_tmp15_);
	_g_date_time_unref0 (due_datetime);
	due_datetime = _tmp14_;
	_g_free0 (error_message);
	error_message = _tmp15_;
	if (!_tmp16_) {
		FILE* _tmp17_;
		const gchar* _tmp18_;
		_tmp17_ = stderr;
		_tmp18_ = error_message;
		fprintf (_tmp17_, "%s\n", _tmp18_);
		result = 1;
		_g_date_time_unref0 (due_datetime);
		_g_free0 (error_message);
		return result;
	}
	_tmp19_ = services_database_get_default ();
	_tmp20_ = _tmp19_;
	services_database_init_database (_tmp20_);
	_g_object_unref0 (_tmp20_);
	_tmp21_ = planify_cli_task_arguments_get_parent_id (args);
	_tmp22_ = _tmp21_;
	_tmp24_ = planify_cli_task_validator_validate_parent_id (_tmp22_, &_tmp23_);
	_g_free0 (error_message);
	error_message = _tmp23_;
	if (!_tmp24_) {
		FILE* _tmp25_;
		const gchar* _tmp26_;
		_tmp25_ = stderr;
		_tmp26_ = error_message;
		fprintf (_tmp25_, "%s\n", _tmp26_);
		result = 1;
		_g_date_time_unref0 (due_datetime);
		_g_free0 (error_message);
		return result;
	}
	_tmp27_ = planify_cli_task_arguments_get_project_id (args);
	_tmp28_ = _tmp27_;
	_tmp29_ = planify_cli_task_arguments_get_project_name (args);
	_tmp30_ = _tmp29_;
	_tmp32_ = planify_cli_task_creator_find_project (_tmp28_, _tmp30_, &_tmp31_);
	_g_free0 (error_message);
	error_message = _tmp31_;
	target_project = _tmp32_;
	_tmp33_ = target_project;
	if (_tmp33_ == NULL) {
		FILE* _tmp34_;
		const gchar* _tmp35_;
		_tmp34_ = stderr;
		_tmp35_ = error_message;
		fprintf (_tmp34_, "%s\n", _tmp35_);
		result = 1;
		_g_object_unref0 (target_project);
		_g_date_time_unref0 (due_datetime);
		_g_free0 (error_message);
		return result;
	}
	_tmp36_ = planify_cli_task_arguments_get_content (args);
	_tmp37_ = _tmp36_;
	_tmp38_ = planify_cli_task_arguments_get_description (args);
	_tmp39_ = _tmp38_;
	_tmp40_ = planify_cli_task_arguments_get_priority (args);
	_tmp41_ = _tmp40_;
	_tmp42_ = due_datetime;
	_tmp43_ = target_project;
	_tmp44_ = planify_cli_task_arguments_get_parent_id (args);
	_tmp45_ = _tmp44_;
	_tmp46_ = planify_cli_task_creator_create_item (_tmp37_, _tmp39_, _tmp41_, _tmp42_, _tmp43_, _tmp45_);
	item = _tmp46_;
	_tmp48_ = planify_cli_task_arguments_get_section_id (args);
	_tmp49_ = _tmp48_;
	if (_tmp49_ != NULL) {
		_tmp47_ = TRUE;
	} else {
		const gchar* _tmp50_;
		const gchar* _tmp51_;
		_tmp50_ = planify_cli_task_arguments_get_section_name (args);
		_tmp51_ = _tmp50_;
		_tmp47_ = _tmp51_ != NULL;
	}
	if (_tmp47_) {
		ObjectsSection* target_section = NULL;
		const gchar* _tmp52_;
		const gchar* _tmp53_;
		const gchar* _tmp54_;
		const gchar* _tmp55_;
		ObjectsProject* _tmp56_;
		gchar* _tmp57_ = NULL;
		ObjectsSection* _tmp58_;
		ObjectsSection* _tmp59_;
		ObjectsItem* _tmp62_;
		ObjectsSection* _tmp63_;
		const gchar* _tmp64_;
		const gchar* _tmp65_;
		_tmp52_ = planify_cli_task_arguments_get_section_id (args);
		_tmp53_ = _tmp52_;
		_tmp54_ = planify_cli_task_arguments_get_section_name (args);
		_tmp55_ = _tmp54_;
		_tmp56_ = target_project;
		_tmp58_ = planify_cli_task_creator_find_section (_tmp53_, _tmp55_, _tmp56_, &_tmp57_);
		_g_free0 (error_message);
		error_message = _tmp57_;
		target_section = _tmp58_;
		_tmp59_ = target_section;
		if (_tmp59_ == NULL) {
			FILE* _tmp60_;
			const gchar* _tmp61_;
			_tmp60_ = stderr;
			_tmp61_ = error_message;
			fprintf (_tmp60_, "%s\n", _tmp61_);
			result = 1;
			_g_object_unref0 (target_section);
			_g_object_unref0 (item);
			_g_object_unref0 (target_project);
			_g_date_time_unref0 (due_datetime);
			_g_free0 (error_message);
			return result;
		}
		_tmp62_ = item;
		_tmp63_ = target_section;
		_tmp64_ = objects_base_object_get_id ((ObjectsBaseObject*) _tmp63_);
		_tmp65_ = _tmp64_;
		objects_item_set_section_id (_tmp62_, _tmp65_);
		_g_object_unref0 (target_section);
	}
	_tmp67_ = planify_cli_task_arguments_get_labels (args);
	_tmp68_ = _tmp67_;
	if (_tmp68_ != NULL) {
		const gchar* _tmp69_;
		const gchar* _tmp70_;
		gchar* _tmp71_;
		gchar* _tmp72_;
		_tmp69_ = planify_cli_task_arguments_get_labels (args);
		_tmp70_ = _tmp69_;
		_tmp71_ = string_strip (_tmp70_);
		_tmp72_ = _tmp71_;
		_tmp66_ = g_strcmp0 (_tmp72_, "") != 0;
		_g_free0 (_tmp72_);
	} else {
		_tmp66_ = FALSE;
	}
	if (_tmp66_) {
		gchar** label_names = NULL;
		const gchar* _tmp73_;
		const gchar* _tmp74_;
		gchar** _tmp75_;
		gchar** _tmp76_;
		gint label_names_length1;
		gint _label_names_size_;
		gchar** _tmp77_;
		gint _tmp77__length1;
		_tmp73_ = planify_cli_task_arguments_get_labels (args);
		_tmp74_ = _tmp73_;
		_tmp76_ = _tmp75_ = g_strsplit (_tmp74_, ",", 0);
		label_names = _tmp76_;
		label_names_length1 = _vala_array_length (_tmp75_);
		_label_names_size_ = label_names_length1;
		_tmp77_ = label_names;
		_tmp77__length1 = label_names_length1;
		{
			gchar** label_name_collection = NULL;
			gint label_name_collection_length1 = 0;
			gint _label_name_collection_size_ = 0;
			gint label_name_it = 0;
			label_name_collection = _tmp77_;
			label_name_collection_length1 = _tmp77__length1;
			for (label_name_it = 0; label_name_it < label_name_collection_length1; label_name_it = label_name_it + 1) {
				gchar* _tmp78_;
				gchar* label_name = NULL;
				_tmp78_ = g_strdup (label_name_collection[label_name_it]);
				label_name = _tmp78_;
				{
					gchar* trimmed = NULL;
					const gchar* _tmp79_;
					gchar* _tmp80_;
					const gchar* _tmp81_;
					_tmp79_ = label_name;
					_tmp80_ = string_strip (_tmp79_);
					trimmed = _tmp80_;
					_tmp81_ = trimmed;
					if (g_strcmp0 (_tmp81_, "") != 0) {
						ObjectsLabel* label = NULL;
						ServicesStore* _tmp82_;
						const gchar* _tmp83_;
						ObjectsProject* _tmp84_;
						const gchar* _tmp85_;
						const gchar* _tmp86_;
						ObjectsLabel* _tmp87_;
						ObjectsLabel* _tmp88_;
						ObjectsItem* _tmp109_;
						GeeArrayList* _tmp110_;
						GeeArrayList* _tmp111_;
						ObjectsLabel* _tmp112_;
						_tmp82_ = services_store_instance ();
						_tmp83_ = trimmed;
						_tmp84_ = target_project;
						_tmp85_ = objects_project_get_source_id (_tmp84_);
						_tmp86_ = _tmp85_;
						_tmp87_ = services_store_get_label_by_name (_tmp82_, _tmp83_, TRUE, _tmp86_);
						label = _tmp87_;
						_tmp88_ = label;
						if (_tmp88_ == NULL) {
							ObjectsLabel* _tmp89_;
							ObjectsLabel* _tmp90_;
							Util* _tmp91_;
							Util* _tmp92_;
							ObjectsLabel* _tmp93_;
							gchar* _tmp94_;
							gchar* _tmp95_;
							ObjectsLabel* _tmp96_;
							const gchar* _tmp97_;
							ObjectsLabel* _tmp98_;
							Util* _tmp99_;
							Util* _tmp100_;
							gchar* _tmp101_;
							gchar* _tmp102_;
							ObjectsLabel* _tmp103_;
							ObjectsProject* _tmp104_;
							const gchar* _tmp105_;
							const gchar* _tmp106_;
							ServicesStore* _tmp107_;
							ObjectsLabel* _tmp108_;
							_tmp89_ = objects_label_new ();
							_g_object_unref0 (label);
							label = _tmp89_;
							_tmp90_ = label;
							_tmp91_ = util_get_default ();
							_tmp92_ = _tmp91_;
							_tmp93_ = label;
							_tmp94_ = util_generate_id (_tmp92_, (ObjectsBaseObject*) _tmp93_);
							_tmp95_ = _tmp94_;
							objects_base_object_set_id ((ObjectsBaseObject*) _tmp90_, _tmp95_);
							_g_free0 (_tmp95_);
							_g_object_unref0 (_tmp92_);
							_tmp96_ = label;
							_tmp97_ = trimmed;
							objects_base_object_set_name ((ObjectsBaseObject*) _tmp96_, _tmp97_);
							_tmp98_ = label;
							_tmp99_ = util_get_default ();
							_tmp100_ = _tmp99_;
							_tmp101_ = util_get_random_color (_tmp100_);
							_tmp102_ = _tmp101_;
							objects_base_object_set_color ((ObjectsBaseObject*) _tmp98_, _tmp102_);
							_g_free0 (_tmp102_);
							_g_object_unref0 (_tmp100_);
							_tmp103_ = label;
							_tmp104_ = target_project;
							_tmp105_ = objects_project_get_source_id (_tmp104_);
							_tmp106_ = _tmp105_;
							objects_label_set_source_id (_tmp103_, _tmp106_);
							_tmp107_ = services_store_instance ();
							_tmp108_ = label;
							services_store_insert_label (_tmp107_, _tmp108_);
						}
						_tmp109_ = item;
						_tmp110_ = objects_item_get_labels (_tmp109_);
						_tmp111_ = _tmp110_;
						_tmp112_ = label;
						gee_abstract_collection_add ((GeeAbstractCollection*) _tmp111_, _tmp112_);
						_g_object_unref0 (label);
					}
					_g_free0 (trimmed);
					_g_free0 (label_name);
				}
			}
		}
		label_names = (_vala_array_free (label_names, label_names_length1, (GDestroyNotify) g_free), NULL);
	}
	_tmp113_ = planify_cli_task_arguments_get_pinned (args);
	_tmp114_ = _tmp113_;
	if (_tmp114_ != -1) {
		ObjectsItem* _tmp115_;
		gint _tmp116_;
		gint _tmp117_;
		_tmp115_ = item;
		_tmp116_ = planify_cli_task_arguments_get_pinned (args);
		_tmp117_ = _tmp116_;
		objects_item_set_pinned (_tmp115_, _tmp117_ == 1);
	}
	_tmp118_ = item;
	planify_cli_task_creator_save_and_notify (_tmp118_);
	_tmp119_ = item;
	_tmp120_ = target_project;
	planify_cli_output_formatter_print_task_result (_tmp119_, _tmp120_);
	result = 0;
	_g_object_unref0 (item);
	_g_object_unref0 (target_project);
	_g_date_time_unref0 (due_datetime);
	_g_free0 (error_message);
	return result;
}

static guint8*
string_get_data (const gchar* self,
                 gint* result_length1)
{
	guint8* result;
	guint8* res = NULL;
	gint res_length1;
	gint _res_size_;
	gint _tmp0_;
	gint _tmp1_;
	guint8* _tmp2_;
	gint _tmp2__length1;
	g_return_val_if_fail (self != NULL, NULL);
	res = (guint8*) self;
	res_length1 = -1;
	_res_size_ = res_length1;
	_tmp0_ = strlen (self);
	_tmp1_ = _tmp0_;
	res_length1 = (gint) _tmp1_;
	_tmp2_ = res;
	_tmp2__length1 = res_length1;
	if (result_length1) {
		*result_length1 = _tmp2__length1;
	}
	result = _tmp2_;
	return result;
}

gint
planify_cli_backup (PlanifyCLIBackupArguments* args)
{
	ServicesDatabase* _tmp0_;
	ServicesDatabase* _tmp1_;
	gchar* json = NULL;
	ServicesBackupExporter* _tmp2_;
	ServicesBackupExporter* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gboolean _tmp6_ = FALSE;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	GError* _inner_error0_ = NULL;
	gint result;
	g_return_val_if_fail (args != NULL, -1);
	_tmp0_ = services_database_get_default ();
	_tmp1_ = _tmp0_;
	services_database_init_database (_tmp1_);
	_g_object_unref0 (_tmp1_);
	_tmp2_ = services_backup_exporter_get_default ();
	_tmp3_ = _tmp2_;
	_tmp4_ = services_backup_exporter_export_to_json (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp3_);
	json = _tmp5_;
	_tmp7_ = planify_cli_backup_arguments_get_output (args);
	_tmp8_ = _tmp7_;
	if (_tmp8_ != NULL) {
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		gchar* _tmp12_;
		_tmp9_ = planify_cli_backup_arguments_get_output (args);
		_tmp10_ = _tmp9_;
		_tmp11_ = string_strip (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp6_ = g_strcmp0 (_tmp12_, "") != 0;
		_g_free0 (_tmp12_);
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		GFile* file = NULL;
		const gchar* _tmp13_;
		const gchar* _tmp14_;
		GFile* _tmp15_;
		_tmp13_ = planify_cli_backup_arguments_get_output (args);
		_tmp14_ = _tmp13_;
		_tmp15_ = g_file_new_for_path (_tmp14_);
		file = _tmp15_;
		{
			GFileOutputStream* stream = NULL;
			GFile* _tmp16_;
			GFileOutputStream* _tmp17_;
			GFileOutputStream* _tmp18_;
			const gchar* _tmp19_;
			guint8* _tmp20_;
			gint _tmp20__length1;
			gint _tmp21_ = 0;
			guint8* _tmp22_;
			gint _tmp22__length1;
			GFileOutputStream* _tmp23_;
			FILE* _tmp24_;
			const gchar* _tmp25_;
			const gchar* _tmp26_;
			_tmp16_ = file;
			_tmp17_ = g_file_replace (_tmp16_, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &_inner_error0_);
			stream = _tmp17_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp18_ = stream;
			_tmp19_ = json;
			_tmp20_ = string_get_data (_tmp19_, &_tmp21_);
			_tmp20__length1 = _tmp21_;
			_tmp22_ = _tmp20_;
			_tmp22__length1 = _tmp20__length1;
			g_output_stream_write ((GOutputStream*) _tmp18_, _tmp22_, (gsize) _tmp22__length1, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (stream);
				goto __catch0_g_error;
			}
			_tmp23_ = stream;
			g_output_stream_close ((GOutputStream*) _tmp23_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (stream);
				goto __catch0_g_error;
			}
			_tmp24_ = stderr;
			_tmp25_ = planify_cli_backup_arguments_get_output (args);
			_tmp26_ = _tmp25_;
			fprintf (_tmp24_, "Backup saved to %s\n", _tmp26_);
			_g_object_unref0 (stream);
		}
		goto __finally0;
		__catch0_g_error:
		{
			GError* e = NULL;
			FILE* _tmp27_;
			GError* _tmp28_;
			const gchar* _tmp29_;
			e = _inner_error0_;
			_inner_error0_ = NULL;
			_tmp27_ = stderr;
			_tmp28_ = e;
			_tmp29_ = _tmp28_->message;
			fprintf (_tmp27_, "Error writing backup: %s\n", _tmp29_);
			result = 1;
			_g_error_free0 (e);
			_g_object_unref0 (file);
			_g_free0 (json);
			return result;
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			gint _tmp30_ = -1;
			_g_object_unref0 (file);
			_g_free0 (json);
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return _tmp30_;
		}
		_g_object_unref0 (file);
	} else {
		FILE* _tmp31_;
		const gchar* _tmp32_;
		_tmp31_ = stdout;
		_tmp32_ = json;
		fprintf (_tmp31_, "%s\n", _tmp32_);
	}
	result = 0;
	_g_free0 (json);
	return result;
}

static gint
planify_cli_main (gchar** args,
                  gint args_length1)
{
	gchar* langpack_dir = NULL;
	gchar* _tmp0_;
	const gchar* _tmp1_;
	gint exit_code = 0;
	PlanifyCLIParsedCommand* parsed = NULL;
	gint _tmp2_ = 0;
	PlanifyCLIParsedCommand* _tmp3_;
	PlanifyCLIParsedCommand* _tmp4_;
	PlanifyCLIParsedCommand* _tmp5_;
	PlanifyCLICommandType _tmp6_;
	PlanifyCLICommandType _tmp7_;
	gint result;
	setlocale (LC_ALL, "");
	_tmp0_ = g_build_filename (BUILD_INSTALL_PREFIX, "share", "locale", NULL);
	langpack_dir = _tmp0_;
	_tmp1_ = langpack_dir;
	bindtextdomain (BUILD_GETTEXT_PACKAGE, _tmp1_);
	bind_textdomain_codeset (BUILD_GETTEXT_PACKAGE, "UTF-8");
	textdomain (BUILD_GETTEXT_PACKAGE);
	_tmp3_ = planify_cli_argument_parser_parse (args, (gint) args_length1, &_tmp2_);
	exit_code = _tmp2_;
	parsed = _tmp3_;
	_tmp4_ = parsed;
	if (_tmp4_ == NULL) {
		result = exit_code;
		_g_object_unref0 (parsed);
		_g_free0 (langpack_dir);
		return result;
	}
	_tmp5_ = parsed;
	_tmp6_ = planify_cli_parsed_command_get_command_type (_tmp5_);
	_tmp7_ = _tmp6_;
	switch (_tmp7_) {
		case PLANIFY_CLI_COMMAND_TYPE_LIST_PROJECTS:
		{
			result = planify_cli_list_projects ();
			_g_object_unref0 (parsed);
			_g_free0 (langpack_dir);
			return result;
		}
		case PLANIFY_CLI_COMMAND_TYPE_LIST:
		{
			PlanifyCLIParsedCommand* _tmp8_;
			PlanifyCLIListArguments* _tmp9_;
			PlanifyCLIListArguments* _tmp10_;
			_tmp8_ = parsed;
			_tmp9_ = planify_cli_parsed_command_get_list_args (_tmp8_);
			_tmp10_ = _tmp9_;
			result = planify_cli_list_tasks (_tmp10_);
			_g_object_unref0 (parsed);
			_g_free0 (langpack_dir);
			return result;
		}
		case PLANIFY_CLI_COMMAND_TYPE_UPDATE:
		{
			PlanifyCLIParsedCommand* _tmp11_;
			PlanifyCLIUpdateArguments* _tmp12_;
			PlanifyCLIUpdateArguments* _tmp13_;
			_tmp11_ = parsed;
			_tmp12_ = planify_cli_parsed_command_get_update_args (_tmp11_);
			_tmp13_ = _tmp12_;
			result = planify_cli_update_task (_tmp13_);
			_g_object_unref0 (parsed);
			_g_free0 (langpack_dir);
			return result;
		}
		case PLANIFY_CLI_COMMAND_TYPE_ADD:
		{
			PlanifyCLIParsedCommand* _tmp14_;
			PlanifyCLITaskArguments* _tmp15_;
			PlanifyCLITaskArguments* _tmp16_;
			_tmp14_ = parsed;
			_tmp15_ = planify_cli_parsed_command_get_task_args (_tmp14_);
			_tmp16_ = _tmp15_;
			result = planify_cli_add_task (_tmp16_);
			_g_object_unref0 (parsed);
			_g_free0 (langpack_dir);
			return result;
		}
		case PLANIFY_CLI_COMMAND_TYPE_BACKUP:
		{
			PlanifyCLIParsedCommand* _tmp17_;
			PlanifyCLIBackupArguments* _tmp18_;
			PlanifyCLIBackupArguments* _tmp19_;
			_tmp17_ = parsed;
			_tmp18_ = planify_cli_parsed_command_get_backup_args (_tmp17_);
			_tmp19_ = _tmp18_;
			result = planify_cli_backup (_tmp19_);
			_g_object_unref0 (parsed);
			_g_free0 (langpack_dir);
			return result;
		}
		default:
		{
			FILE* _tmp20_;
			_tmp20_ = stderr;
			fprintf (_tmp20_, "Error: Unknown command\n");
			result = 1;
			_g_object_unref0 (parsed);
			_g_free0 (langpack_dir);
			return result;
		}
	}
}

int
main (int argc,
      char ** argv)
{
	return planify_cli_main (argv, argc);
}

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

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

